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

unix.superglobalmegacorp.com

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