Annotation of coherent/b/STREAMS/i386/work.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * File:       work.c
        !             3:  *
        !             4:  * Purpose:    Manage temporary pages of virtual memory.
        !             5:  *             Pages are allocated in virtually contiguous pairs to allow
        !             6:  *             for straddle operations in target code.
        !             7:  *
        !             8:  * $Log:       work.c,v $
        !             9:  * Revision 2.2  93/07/26  13:57:36  nigel
        !            10:  * Nigel's R80
        !            11:  * 
        !            12:  * Revision 1.1  93/04/14  10:29:40  root
        !            13:  * r75
        !            14:  * 
        !            15:  */
        !            16: 
        !            17: /*
        !            18:  * ----------------------------------------------------------------------
        !            19:  * Includes.
        !            20:  */
        !            21: #include <sys/coherent.h>
        !            22: 
        !            23: /*
        !            24:  * ----------------------------------------------------------------------
        !            25:  * Definitions.
        !            26:  *     Constants.
        !            27:  *     Macros with argument lists.
        !            28:  *     Typedefs.
        !            29:  *     Enums.
        !            30:  */
        !            31: #define        START_WORK      0xFFFFA         /* Highest scratchpad click pair. */
        !            32: #define MAX_WORK_PAIRS 4               /* Max # in use at one time */
        !            33: 
        !            34: /*
        !            35:  * ----------------------------------------------------------------------
        !            36:  * Functions.
        !            37:  *     Import Functions.
        !            38:  *     Export Functions.
        !            39:  *     Local Functions.
        !            40:  */
        !            41: int    workAlloc();
        !            42: void   workFree();
        !            43: void   workPoolInit();
        !            44: 
        !            45: /*
        !            46:  * ----------------------------------------------------------------------
        !            47:  * Global Data.
        !            48:  *     Import Variables.
        !            49:  *     Export Variables.
        !            50:  *     Local Variables.
        !            51:  */
        !            52: static int     numWorkPairs;   /* Number of click pairs in use. */
        !            53: static int     maxWorkPairs;   /* For monitoring resource use. */
        !            54: 
        !            55: static int     workPool[MAX_WORK_PAIRS];
        !            56: 
        !            57: /*
        !            58:  * ----------------------------------------------------------------------
        !            59:  * Code.
        !            60:  */
        !            61: void
        !            62: workPoolInit()
        !            63: {
        !            64:        int i, w;
        !            65: 
        !            66:        for (i = 0, w = START_WORK; i < MAX_WORK_PAIRS; i++, w -= 2)
        !            67:                workPool[i] = w;
        !            68: }
        !            69: 
        !            70: /*
        !            71:  * Allocate a click pair of virtual space for temporary use.
        !            72:  * Panic if none available.
        !            73:  * Return value is a click number, e.g. 0xFFFFA, suitable for use as
        !            74:  * an index into ptable1_v[].  The return value plus one is also
        !            75:  * available for use as a virtual click number.
        !            76:  */
        !            77: int
        !            78: workAlloc()
        !            79: {
        !            80:        int s, ret;
        !            81: 
        !            82:        s = sphi();
        !            83:        if (numWorkPairs >= MAX_WORK_PAIRS)
        !            84:                panic("Work pair pool empty");
        !            85:        ret = workPool[numWorkPairs++];
        !            86:        spl(s);
        !            87: #if 0
        !            88:        if (numWorkPairs > maxWorkPairs) {
        !            89:                maxWorkPairs = numWorkPairs;
        !            90:                printf("Now using %d work pairs ", maxWorkPairs);
        !            91:        }
        !            92: #endif
        !            93:        return ret;
        !            94: }
        !            95: 
        !            96: /*
        !            97:  * Return a click pair of virtual space to the free pool.
        !            98:  */
        !            99: void
        !           100: workFree(w)
        !           101: int w;
        !           102: {
        !           103:        int s;
        !           104: 
        !           105:        if (w > START_WORK || w <= START_WORK - MAX_WORK_PAIRS)
        !           106:                panic("workFree(%x)", w);
        !           107: 
        !           108:        ptable1_v [w + 1] = ptable1_v [w] = SEG_ILL;
        !           109:        mmuupd ();
        !           110: 
        !           111:        s = sphi();
        !           112:        if (numWorkPairs == 0)
        !           113:                panic("Work pair pool exploded");
        !           114:        workPool[--numWorkPairs] = w;
        !           115:        spl(s);
        !           116: }

unix.superglobalmegacorp.com

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