The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/device/subrs.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1993,1991,1990,1989,1988 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        subrs.c,v $
   29  * Revision 2.15  93/03/09  10:54:20  danner
   30  *      Removed string routines, and the Berkeley copyright that came
   31  *      with them.  The new ones we wrote now live in kern/strings.[ch].
   32  *      [93/03/06            af]
   33  * 
   34  * Revision 2.14  93/01/14  17:27:17  danner
   35  *      64bit cleanup.
   36  *      [92/11/30            af]
   37  * 
   38  * Revision 2.13  92/08/03  17:33:57  jfriedl
   39  *      removed silly prototypes
   40  *      [92/08/02            jfriedl]
   41  * 
   42  * Revision 2.12  92/05/21  17:09:49  jfriedl
   43  *      Cleanup to quiet gcc warnings. Replaced strlen with a faster one.
   44  *      [92/05/16            jfriedl]
   45  * 
   46  * Revision 2.11  91/09/12  16:37:39  bohman
   47  *      Added strlen() (BSD version).
   48  *      [91/09/11  17:07:25  bohman]
   49  * 
   50  * Revision 2.10  91/08/24  11:56:04  af
   51  *      Use BSD string functions now, which of course come with a
   52  *      copyright.  Also, undef them in case some smarty..
   53  *      [91/08/22            af]
   54  * 
   55  * Revision 2.9  91/07/31  17:34:27  dbg
   56  *      Add strcpy.
   57  *      [91/07/30  16:47:37  dbg]
   58  * 
   59  * Revision 2.8  91/05/14  16:01:30  mrt
   60  *      Correcting copyright
   61  * 
   62  * Revision 2.7  91/03/16  14:43:34  rpd
   63  *      Updated for new kmem_alloc interface.
   64  *      [91/03/03            rpd]
   65  * 
   66  * Revision 2.6  91/02/05  17:10:17  mrt
   67  *      Changed to new Mach copyright
   68  *      [91/01/31  17:30:39  mrt]
   69  * 
   70  * Revision 2.5  91/01/08  15:10:02  rpd
   71  *      Added continuation argument to thread_block.
   72  *      [90/12/08            rpd]
   73  * 
   74  * Revision 2.4  90/05/03  15:19:27  dbg
   75  *      Add compatibility routines for BSD-compatible device drivers:
   76  *      sleep, wakeup, geteblk, brelse.
   77  *      [90/03/14            dbg]
   78  * 
   79  * Revision 2.3  90/01/11  11:42:31  dbg
   80  *      De-linted.
   81  *      [89/12/15            dbg]
   82  * 
   83  *      Add lock initialization in if_init_queues.
   84  *      [89/11/30            dbg]
   85  * 
   86  * Revision 2.2  89/11/29  14:08:58  af
   87  *      RCS-ed, added strncmp (needed for scsi label comparisons).
   88  *      [89/10/28            af]
   89  * 
   90  */
   91 /*
   92  * Random device subroutines and stubs.
   93  */
   94 
   95 #include <vm/vm_kern.h>
   96 #include <device/buf.h>
   97 #include <device/if_hdr.h>
   98 #include <device/if_ether.h>
   99 
  100 
  101 
  102 /*
  103  * Print out disk name and block number for hard disk errors.
  104  */
  105 void harderr(bp, cp)
  106         struct buf *bp;
  107         char *  cp;
  108 {
  109         printf("%s%d%c: hard error sn%d ",
  110                cp,
  111                minor(bp->b_dev) >> 3,
  112                'a' + (minor(bp->b_dev) & 0x7),
  113                bp->b_blkno);
  114 }
  115 
  116 /*
  117  * Ethernet support routines.
  118  */
  119 u_char  etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  120 
  121 /*
  122  * Convert Ethernet address to printable (loggable) representation.
  123  */
  124 char *
  125 ether_sprintf(ap)
  126         register u_char *ap;
  127 {
  128         register i;
  129         static char etherbuf[18];
  130         register char *cp = etherbuf;
  131         static char digits[] = "0123456789abcdef";
  132 
  133         for (i = 0; i < 6; i++) {
  134                 *cp++ = digits[*ap >> 4];
  135                 *cp++ = digits[*ap++ & 0xf];
  136                 *cp++ = ':';
  137         }
  138         *--cp = 0;
  139         return (etherbuf);
  140 }
  141 
  142 /*
  143  * Initialize send and receive queues on an interface.
  144  */
  145 void if_init_queues(ifp)
  146         register struct ifnet *ifp;
  147 {
  148         IFQ_INIT(&ifp->if_snd);
  149         queue_init(&ifp->if_rcv_port_list);
  150         simple_lock_init(&ifp->if_rcv_port_list_lock);
  151 }
  152 
  153 
  154 /*
  155  * Compatibility with BSD device drivers.
  156  */
  157 void sleep(channel, priority)
  158         vm_offset_t     channel;
  159         int             priority;
  160 {
  161         assert_wait((event_t) channel, FALSE);  /* not interruptible XXX */
  162         thread_block((void (*)()) 0);
  163 }
  164 
  165 void wakeup(channel)
  166         vm_offset_t     channel;
  167 {
  168         thread_wakeup((event_t) channel);
  169 }
  170 
  171 struct buf *
  172 geteblk(size)
  173         int     size;
  174 {
  175         register io_req_t       ior;
  176 
  177         io_req_alloc(ior, 0);
  178         ior->io_device = (device_t)0;
  179         ior->io_unit = 0;
  180         ior->io_op = 0;
  181         ior->io_mode = 0;
  182         ior->io_recnum = 0;
  183         ior->io_count = size;
  184         ior->io_residual = 0;
  185         ior->io_error = 0;
  186 
  187         size = round_page(size);
  188         ior->io_alloc_size = size;
  189         if (kmem_alloc(kernel_map, (vm_offset_t *)&ior->io_data, size)
  190                 != KERN_SUCCESS)
  191                     panic("geteblk");
  192 
  193         return (ior);
  194 }
  195 
  196 void brelse(bp)
  197         struct buf *bp;
  198 {
  199         register io_req_t       ior = bp;
  200 
  201         (void) vm_deallocate(kernel_map,
  202                         (vm_offset_t) ior->io_data,
  203                         (vm_size_t) ior->io_alloc_size);
  204         io_req_free(ior);
  205 }

Cache object: 38c9757eb666393b58acc2211005dded


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.