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

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

unix.superglobalmegacorp.com

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