Annotation of lucent/sys/src/9/pc/bbmalloc.c, revision 1.1

1.1     ! root        1: #include       "u.h"
        !             2: #include       "../port/lib.h"
        !             3: #include       "mem.h"
        !             4: #include       "dat.h"
        !             5: #include       "fns.h"
        !             6: #include       "io.h"
        !             7: 
        !             8: /*
        !             9:  * Allocate memory for use in kernel bitblts.
        !            10:  *
        !            11:  * This code will have to be interlocked if we ever get
        !            12:  * a multiprocessor with a bitmapped display.
        !            13:  */
        !            14: 
        !            15: /* a 0->3 bitblt can take 800 longs */
        !            16: enum {
        !            17:        narena=2,       /* put interrupt time stuff in separate arena */
        !            18:        nbbarena=4096   /* number of words in an arena */
        !            19: };
        !            20: 
        !            21: static ulong   *bbarena[narena];
        !            22: static ulong   *bbcur[narena];
        !            23: static ulong   *bblast[narena];
        !            24: 
        !            25: #define INTENABLED(v)  ((v)&(1<<9))
        !            26: void *
        !            27: bbmalloc(int nbytes)
        !            28: {
        !            29:        int nw, a;
        !            30:        int s;
        !            31:        ulong *ans;
        !            32: 
        !            33:        nw = nbytes/sizeof(long);
        !            34:        s = splhi();
        !            35:        a = INTENABLED(s) ? 0 : 1;
        !            36:        if(bbcur[a] + nw > bbarena[a] + nbbarena)
        !            37:                ans = bbarena[a];
        !            38:        else
        !            39:                ans = bbcur[a];
        !            40:        bbcur[a] = ans + nw;
        !            41:        bblast[a] = ans;
        !            42:        splx(s);
        !            43:        return ans;
        !            44: }
        !            45: 
        !            46: void
        !            47: bbinit(void)
        !            48: {
        !            49:        int i;
        !            50: 
        !            51:        if(bbarena[0])
        !            52:                return;
        !            53:        for(i = 0; i < narena; i++){
        !            54:                bbarena[i] = xalloc(nbbarena * sizeof(long));
        !            55:                bbcur[i] = bbarena[i];
        !            56:                bblast[i] = 0;
        !            57:        }
        !            58: }
        !            59: 
        !            60: 
        !            61: void
        !            62: bbfree(void *p, int n)
        !            63: {
        !            64:        int a, s;
        !            65: 
        !            66:        s = splhi();
        !            67:        a = INTENABLED(s) ? 0 : 1;
        !            68:        if(p == bblast[a])
        !            69:                bbcur[a] = (ulong *)(((char *)bblast[a]) + n);
        !            70:        splx(s);
        !            71: }
        !            72: 
        !            73: void
        !            74: bbdflush(void *p, int n)
        !            75: {
        !            76:        USED(p, n);
        !            77: }
        !            78: 
        !            79: int
        !            80: bbonstack(void)
        !            81: {
        !            82:        return 0;
        !            83: }
        !            84: 
        !            85: void
        !            86: bbexec(void (*memstart)(void), int len, int onstack)
        !            87: {
        !            88:        USED(len, onstack);
        !            89:        memstart();
        !            90: }

unix.superglobalmegacorp.com

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