Annotation of researchv9/sys/sun3/dummy1.c, revision 1.1.1.2

1.1       root        1: #define DUMMY(x) x(){ panic("x"); }
                      2: 
                      3: DUMMY(dumpsys)
1.1.1.2 ! root        4: 
        !             5: #include "../h/param.h"
        !             6: #include "../h/callout.h"
        !             7: #include "../h/map.h"
        !             8: 
        !             9: /*
        !            10:  * untimeout is called to remove a function timeout call
        !            11:  * from the callout structure.
        !            12:  */
        !            13: untimeout(fun, arg)
        !            14:        int (*fun)();
        !            15:        caddr_t arg;
        !            16: {
        !            17:        register struct callout *p1, *p2;
        !            18:        register int s;
        !            19: 
        !            20:        s = splclock();
        !            21:        for (p1 = &calltodo; (p2 = p1->c_next) != 0; p1 = p2) {
        !            22:                if (p2->c_func == fun && p2->c_arg == arg) {
        !            23:                        if (p2->c_next && p2->c_time > 0)
        !            24:                                p2->c_next->c_time += p2->c_time;
        !            25:                        p1->c_next = p2->c_next;
        !            26:                        p2->c_next = callfree;
        !            27:                        callfree = p2;
        !            28:                        break;
        !            29:                }
        !            30:        }
        !            31:        (void) splx(s);
        !            32: }
        !            33: 
        !            34: /*
        !            35:  * Allocate 'size' units from the given map, starting at address 'addr'.
        !            36:  * Return 'addr' if successful, 0 if not.
        !            37:  * This may cause the creation or destruction of a resource map segment.
        !            38:  *
        !            39:  * This routine will return failure status if there is not enough room
        !            40:  * for a required additional map segment.
        !            41:  *
        !            42:  * An attempt to use this on 'swapmap' will result in
        !            43:  * a failure return.  This is due mainly to laziness and could be fixed
        !            44:  * to do the right thing, although it probably will never be used.
        !            45:  */
        !            46: rmget(mp, size, addr)
        !            47:        register struct map *mp;
        !            48: {
        !            49:        register struct mapent *ep = (struct mapent *)(mp+1);
        !            50:        register struct mapent *bp, *bp2;
        !            51: 
        !            52:        if (size <= 0)
        !            53:                panic("rmget");
        !            54:        if (mp == swapmap)
        !            55:                return (0);
        !            56:        /*
        !            57:         * Look for a map segment containing the requested address.
        !            58:         * If none found, return failure.
        !            59:         */
        !            60:        for (bp = ep; bp->m_size; bp++)
        !            61:                if (bp->m_addr <= addr && bp->m_addr + bp->m_size > addr)
        !            62:                        break;
        !            63:        if (bp->m_size == 0)
        !            64:                return (0);
        !            65: 
        !            66:        /*
        !            67:         * If segment is too small, return failure.
        !            68:         * If big enough, allocate the block, compressing or expanding
        !            69:         * the map as necessary.
        !            70:         */
        !            71:        if (bp->m_addr + bp->m_size < addr + size)
        !            72:                return (0);
        !            73:        if (bp->m_addr == addr)
        !            74:                if (bp->m_addr + bp->m_size == addr + size) {
        !            75:                        /*
        !            76:                         * Allocate entire segment and compress map
        !            77:                         */
        !            78:                        bp2 = bp;
        !            79:                        while (bp2->m_size) {
        !            80:                                bp2++;
        !            81:                                (bp2-1)->m_addr = bp2->m_addr;
        !            82:                                (bp2-1)->m_size = bp2->m_size;
        !            83:                        }
        !            84:                } else {
        !            85:                        /*
        !            86:                         * Allocate first part of segment
        !            87:                         */
        !            88:                        bp->m_addr += size;
        !            89:                        bp->m_size -= size;
        !            90:                }
        !            91:        else
        !            92:                if (bp->m_addr + bp->m_size == addr + size) {
        !            93:                        /*
        !            94:                         * Allocate last part of segment
        !            95:                         */
        !            96:                        bp->m_size -= size;
        !            97:                } else {
        !            98:                        /*
        !            99:                         * Allocate from middle of segment, but only
        !           100:                         * if table can be expanded.
        !           101:                         */
        !           102:                        for (bp2=bp; bp2->m_size; bp2++)
        !           103:                                ;
        !           104:                        if (bp2 == mp->m_limit)
        !           105:                                return (0);
        !           106:                        while (bp2 > bp) {
        !           107:                                (bp2+1)->m_addr = bp2->m_addr;
        !           108:                                (bp2+1)->m_size = bp2->m_size;
        !           109:                                bp2--;
        !           110:                        }
        !           111:                        (bp+1)->m_addr = addr + size;
        !           112:                        (bp+1)->m_size =
        !           113:                            bp->m_addr + bp->m_size - (addr + size);
        !           114:                        bp->m_size = addr - bp->m_addr;
        !           115:                }
        !           116:        return (addr);
        !           117: }
        !           118: 
        !           119: /*
        !           120:  * Set the local ethernet address
        !           121:  */
        !           122: localetheraddr(f, t)
        !           123: u_char *f, *t;
        !           124: {
        !           125:        static first = 1;
        !           126:        static u_char ether[6];
        !           127: 
        !           128:        if (first && f) {
        !           129:                first = 0;
        !           130:                bcopy(f, ether, 6);
        !           131:                printf("Ethernet address = ");
        !           132:                printf("%x:%x:%x:%x:%x:%x\n",
        !           133:                        f[0], f[1], f[2], f[3], f[4], f[5]);
        !           134:        }
        !           135:        if (t)
        !           136:                bcopy(ether, t, 6);
        !           137: }

unix.superglobalmegacorp.com

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