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

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

unix.superglobalmegacorp.com

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