Annotation of coherent/d/PS2_KERNEL/i286/md1.c, revision 1.1.1.1

1.1       root        1: /* $Header: /kernel/kersrc/i286/RCS/md1.c,v 1.1 92/07/17 15:21:32 bin Exp Locker: bin $ */
                      2: /* (lgl-
                      3:  *     The information contained herein is a trade secret of Mark Williams
                      4:  *     Company, and  is confidential information.  It is provided  under a
                      5:  *     license agreement,  and may be  copied or disclosed  only under the
                      6:  *     terms of  that agreement.  Any  reproduction or disclosure  of this
                      7:  *     material without the express written authorization of Mark Williams
                      8:  *     Company or persuant to the license agreement is unlawful.
                      9:  *
                     10:  *     COHERENT Version 2.3.37
                     11:  *     Copyright (c) 1982, 1983, 1984.
                     12:  *     An unpublished work by Mark Williams Company, Chicago.
                     13:  *     All rights reserved.
                     14:  -lgl) */
                     15: /*
                     16:  * 8086/8088 Coherent.
                     17:  * All machines.
                     18:  * Machine dependent stuff.
                     19:  *
                     20:  * $Log:       md1.c,v $
                     21:  * Revision 1.1  92/07/17  15:21:32  bin
                     22:  * Initial revision
                     23:  * 
                     24:  * Revision 1.2        88/08/05  15:34:26      src
                     25:  * mproto(), segload(), and msetsys() functions simplified.
                     26:  * 
                     27:  * Revision 1.1        88/03/24  17:39:43      src
                     28:  * Initial revision
                     29:  * 
                     30:  * 88/03/10    Allan Cornish           /usr/src/sys/coh/proc.c
                     31:  * Numerous temporary fixes due to AMD 286 chip being buggy in protected mode.
                     32:  * These partial fixes will be removed once all CPU's are replaced.
                     33:  *
                     34:  * 88/02/13    Allan Cornish           /usr/src/sys/i8086/src/md1.c
                     35:  * segload() now checks for regl[OIP] being system code segment.
                     36:  * iAPX-286 protected mode interrupt gates enable interrupts momentarily.
                     37:  *
                     38:  * 88/01/21    Allan Cornish           /usr/src/sys/i8086/src/md1.c
                     39:  * Segments are now de-associated from processes before freeing the segment.
                     40:  *
                     41:  * 87/11/05    Allan Cornish           /usr/src/sys/i8086/src/md1.c
                     42:  * New seg struct now used to allow extended addressing.
                     43:  *
                     44:  * 87/09/21    Allan Cornish   /usr/src/sys/i8086/src/md1.c
                     45:  * mproto() and setload() modified to support loadable driver processes.
                     46:  */
                     47: #include <sys/coherent.h>
                     48: #include <sys/i8086.h>
                     49: #include <sys/clist.h>
                     50: #include <errno.h>
                     51: #include <sys/inode.h>
                     52: #include <sys/proc.h>
                     53: #include <sys/seg.h>
                     54: #include <signal.h>
                     55: 
                     56: /*
                     57:  * Calculate segmentation for a
                     58:  * new program. If there is a stack segment
                     59:  * present merge it into the data segment and
                     60:  * relocate the argument list.
                     61:  * Make sure that the changes are reflected in the u.u_segl array
                     62:  * which sproto sets up.
                     63:  */
                     64: mproto()
                     65: {
                     66:        register PROC   *pp;
                     67:        register SEG    *dsp;
                     68:        register SEG    *ssp;
                     69:        register SEG    *csp;
                     70:        fsize_t         ds;
                     71:        fsize_t         ss;
                     72:        unsigned int    so;
                     73:        unsigned int    *up;
                     74:        unsigned int    v;
                     75: 
                     76:        pp = SELF;
                     77: 
                     78:        dsp = pp->p_segp[SIPDATA];
                     79: 
                     80:        if ( ((pp->p_flags & PFKERN) == 0)
                     81:          && ((ssp=pp->p_segp[SISTACK]) != NULL) ) {
                     82:                ds = dsp->s_size;
                     83:                ss = ssp->s_size;
                     84:                so = ds + ss;
                     85:                if (seggrow(dsp, (fsize_t)so) == 0)
                     86:                        return (0);
                     87:                plrcopy( ssp->s_paddr, dsp->s_paddr + ds, ss);
                     88:                pp->p_segp[SISTACK] = NULL;
                     89:                sfree(ssp);
                     90:                u.u_sproto.mp_svb = ds;
                     91:                u.u_sproto.mp_svl = so;
                     92:                if (u.u_argp != NULL) {
                     93:                        abase(FP_SEL(dsp->s_faddr));
                     94:                        up = u.u_argp += so;
                     95:                        --up;
                     96:                        while (ageti(--up) != NULL)
                     97:                                ;
                     98:                        up -= 2+u.u_argc;
                     99:                        while ((v=ageti(up)) != NULL)
                    100:                                aputi(up++, v+so);
                    101:                        while ((v=ageti(++up)) != NULL)
                    102:                                aputi(up, v+so);
                    103:                }
                    104:                return (sproto());      /* Recurse to fix u.u_segl */
                    105:        }
                    106: 
                    107:        /*
                    108:         * Shared code, private code, or kernel code [csp == NULL].
                    109:         * NOTE: Combined code/data no longer supported.
                    110:         */
                    111:        if ( (csp = pp->p_segp[SISTEXT]) == NULL )
                    112:                csp = pp->p_segp[SIPTEXT];
                    113: 
                    114:        /*
                    115:         * Special case if no code/data segment specified.
                    116:         */
                    117:        u.u_sproto.mp_cbp = (csp != NULL) ? &FP_SEL(csp->s_faddr) : &scs;
                    118:        u.u_sproto.mp_dbp = (dsp != NULL) ? &FP_SEL(dsp->s_faddr) : &sds;
                    119:        u.u_sproto.mp_csl = (csp != NULL) ? csp->s_size - 1 : 0;
                    120:        u.u_sproto.mp_dsl = (dsp != NULL) ? dsp->s_size - 1 : 0;
                    121: 
                    122:        return (1);
                    123: }
                    124: 
                    125: /*
                    126:  * Load up segmentation registers.
                    127:  */
                    128: segload()
                    129: {
                    130:        register unsigned *ip;
                    131:        register unsigned s;
                    132: 
                    133:        ucs = *u.u_sproto.mp_cbp;
                    134:        uds = *u.u_sproto.mp_dbp;
                    135:        ucl =  u.u_sproto.mp_csl;
                    136:        udl =  u.u_sproto.mp_dsl;
                    137: 
                    138:        ip = regl;
                    139:        ip[OCS] = ucs;
                    140:        ip[ODS] = s = uds;
                    141:        ip[OES] = s;
                    142:        ip[OSS] = s;
                    143: }
                    144: 
                    145: /*
                    146:  * Set up a new process.
                    147:  */
                    148: msetusr(ip, sp)
                    149: vaddr_t sp;
                    150: vaddr_t ip;
                    151: {
                    152:        regl[OIP] = ip;
                    153:        regl[OSP] = sp + u.u_sproto.mp_svl;
                    154: }
                    155: 
                    156: /*
                    157:  * Set up initial context for a system process.
                    158:  * System processes run at depth 1, just like any
                    159:  * user process. This is necessary to make sure that
                    160:  * the machine state save is correctly handled, just
                    161:  * in case the clock hits a kernel process executing
                    162:  * out of the IBM ROM.
                    163:  */
                    164: msetsys(mp, fn, us)
                    165: register MCON *mp;
                    166: int (*fn)();
                    167: saddr_t us;
                    168: {
                    169:        mp->mc_sp = (int)(&u) + UPASIZE - 32;
                    170:        mp->mc_pc = fn;
                    171:        mp->mc_fw = 0;
                    172:        mp->mc_depth = 1;
                    173: }
                    174: 
                    175: /*
                    176:  * Set the given address in the user area to the given value if it is
                    177:  * okay to do so.
                    178:  */
                    179: msetuof(a, v)
                    180: register int a;
                    181: {
                    182:        if (a<UPASIZE+OBP*2 || a>UPASIZE+OFW*2)
                    183:                return (0);
                    184:        if (a == UPASIZE+OCS*2)
                    185:                return (0);
                    186:        if (a == UPASIZE+ODS*2)
                    187:                return (0);
                    188:        if (a == UPASIZE+OES*2)
                    189:                return (0);
                    190:        if (a == UPASIZE+OSS*2)
                    191:                return (0);
                    192:        if (a == UPASIZE+OID*2)         /* Protect trap id */
                    193:                return (0);
                    194:        if (a == UPASIZE+ORA*2)
                    195:                return (0);             /* Protect trap return link */
                    196:        *((int *)((int)&u+a)) = v;
                    197:        return (1);
                    198: }
                    199: 
                    200: /*
                    201:  * Cause a signal routine to be executed.
                    202:  */
                    203: msigint(n, f)
                    204: {
                    205:        register int *usp;
                    206: 
                    207:        usp = regl[OSP];
                    208:        putuwd(--usp, regl[OFW]);
                    209:        putuwd(--usp, regl[OIP]);
                    210:        putuwd(--usp, n);
                    211:        regl[OFW] &= ~MFTTB;
                    212:        regl[OIP] = f;
                    213:        regl[OSP] = usp;
                    214:        if (n != SIGTRAP)
                    215:                u.u_sfunc[n-1] = SIG_DFL;
                    216: }
                    217: 
                    218: /*
                    219:  * Cause the next instruction to single step.
                    220:  */
                    221: msigsin()
                    222: {
                    223:        regl[OFW] |= MFTTB;
                    224: }
                    225: 
                    226: /*
                    227:  * Fix up context.
                    228:  */
                    229: mfixcon(pp)
                    230: PROC *pp;
                    231: {
                    232: }
                    233: 
                    234: /*
                    235:  * Idle kernel process.
                    236:  */
                    237: idle()
                    238: {
                    239:        for (;;) {
                    240:                disflag = 1;
                    241:                _idle();
                    242:        }
                    243: }

unix.superglobalmegacorp.com

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