Annotation of Gnu-Mach/device/subrs.c, revision 1.1.1.3

1.1       root        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  [email protected]
                     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:  * Random device subroutines and stubs.
                     28:  */
                     29: 
1.1.1.3 ! root       30: #include <kern/debug.h>
        !            31: #include <kern/printf.h>
1.1       root       32: #include <vm/vm_kern.h>
1.1.1.3 ! root       33: #include <vm/vm_user.h>
1.1       root       34: #include <device/buf.h>
                     35: #include <device/if_hdr.h>
                     36: #include <device/if_ether.h>
                     37: 
                     38: 
                     39: 
                     40: /*
                     41:  * Print out disk name and block number for hard disk errors.
                     42:  */
                     43: void harderr(bp, cp)
                     44:        struct buf *bp;
                     45:        char *  cp;
                     46: {
                     47:        printf("%s%d%c: hard error sn%d ",
                     48:               cp,
                     49:               minor(bp->b_dev) >> 3,
                     50:               'a' + (minor(bp->b_dev) & 0x7),
                     51:               bp->b_blkno);
                     52: }
                     53: 
                     54: /*
                     55:  * Ethernet support routines.
                     56:  */
                     57: u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
                     58: 
                     59: /*
                     60:  * Convert Ethernet address to printable (loggable) representation.
                     61:  */
                     62: char *
                     63: ether_sprintf(ap)
                     64:        register u_char *ap;
                     65: {
1.1.1.3 ! root       66:        register int i;
1.1       root       67:        static char etherbuf[18];
                     68:        register char *cp = etherbuf;
                     69:        static char digits[] = "0123456789abcdef";
                     70: 
                     71:        for (i = 0; i < 6; i++) {
                     72:                *cp++ = digits[*ap >> 4];
                     73:                *cp++ = digits[*ap++ & 0xf];
                     74:                *cp++ = ':';
                     75:        }
                     76:        *--cp = 0;
                     77:        return (etherbuf);
                     78: }
                     79: 
                     80: /*
                     81:  * Initialize send and receive queues on an interface.
                     82:  */
                     83: void if_init_queues(ifp)
                     84:        register struct ifnet *ifp;
                     85: {
                     86:        IFQ_INIT(&ifp->if_snd);
                     87:        queue_init(&ifp->if_rcv_port_list);
1.1.1.3 ! root       88:        queue_init(&ifp->if_snd_port_list);
1.1       root       89:        simple_lock_init(&ifp->if_rcv_port_list_lock);
1.1.1.3 ! root       90:        simple_lock_init(&ifp->if_snd_port_list_lock);
1.1       root       91: }
                     92: 
                     93: 
                     94: /*
                     95:  * Compatibility with BSD device drivers.
                     96:  */
                     97: void sleep(channel, priority)
                     98:        vm_offset_t     channel;
                     99:        int             priority;
                    100: {
                    101:        assert_wait((event_t) channel, FALSE);  /* not interruptible XXX */
                    102:        thread_block((void (*)()) 0);
                    103: }
                    104: 
                    105: void wakeup(channel)
                    106:        vm_offset_t     channel;
                    107: {
                    108:        thread_wakeup((event_t) channel);
                    109: }
                    110: 
                    111: struct buf *
                    112: geteblk(size)
                    113:        int     size;
                    114: {
                    115:        register io_req_t       ior;
                    116: 
                    117:        io_req_alloc(ior, 0);
1.1.1.2   root      118:        ior->io_device = (mach_device_t)0;
1.1       root      119:        ior->io_unit = 0;
                    120:        ior->io_op = 0;
                    121:        ior->io_mode = 0;
                    122:        ior->io_recnum = 0;
                    123:        ior->io_count = size;
                    124:        ior->io_residual = 0;
                    125:        ior->io_error = 0;
                    126: 
                    127:        size = round_page(size);
                    128:        ior->io_alloc_size = size;
                    129:        if (kmem_alloc(kernel_map, (vm_offset_t *)&ior->io_data, size)
                    130:                != KERN_SUCCESS)
                    131:                    panic("geteblk");
                    132: 
                    133:        return (ior);
                    134: }
                    135: 
                    136: void brelse(bp)
                    137:        struct buf *bp;
                    138: {
                    139:        register io_req_t       ior = bp;
                    140: 
                    141:        (void) vm_deallocate(kernel_map,
                    142:                        (vm_offset_t) ior->io_data,
1.1.1.3 ! root      143:                        ior->io_alloc_size);
1.1       root      144:        io_req_free(ior);
                    145: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.