Annotation of coherent/d/286_KERNEL/USRSRC/286/md1.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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