Annotation of cci/d/memman/init.c, revision 1.1.1.1

1.1       root        1: 
                      2: /*     init.s                                                          */
                      3: 
                      4: 
                      5: /*     This file is a diagnostic version of locore.s.                  */
                      6: /*     It contains the following:                                      */
                      7: /*     *system data area = scb, dump buffer, interrupt stack,          */
                      8: /*     *system page table,user page tables,pcbs,iomap, & io buffers.   */
                      9: /*                                                                     */
                     10: /*     *system code = interrupt vectors, initialization of system data,*/
                     11: /*     *memory size calculation,initialization of SPT, zeroing of      */
                     12: /*     *unused memory, & loading of SBR & SLR.                         */
                     13: /*     *                                                               */
                     14: /*     *at the end of this code, you are ready to go to virtual mode.  */
                     15: /*     * --- GOOD LUCK!                                                */
                     16: 
                     17: 
                     18: /*     privileged registers addresses  */
                     19: #include       "prvreg.h"
                     20:        
                     21: /*     program status long word definition     */
                     22: #include       "psl.h" 
                     23: 
                     24: /*     page table entry definition             */
                     25: #include       "pte.h"
                     26:        
                     27: /*     process control block offsets   */
                     28: #include       "pcboffset.h"   
                     29: 
                     30: /*     fundamental constants for globl use     */
                     31: #include       "const.h"       
                     32: 
                     33: /*     system control block offsets*/
                     34: #include       "scboffset.h"
                     35: /*     SPT offsets                             */
                     36: #include       "sptoffset.h"
                     37: 
                     38: /*     trap numbers*/
                     39: #include       "trap.h"        
                     40: 
                     41: 
                     42: #define P0SPACE                1       /* This test run in P0 space */
                     43: #define TRUE           1
                     44: #define V_TRAP         0
                     45: #define V_SYSCALL      4
                     46: 
                     47:        .set    HIGH,0x1f       /*mask for disabling all interrupts     */
                     48:        .set    MCKVEC,4        /*scb offset for machinecheck vector    */
                     49:        .set    NISP,2          /*no. of interrupt stack pages          */
                     50:        .set    DONE,255        /*user process done code                */
                     51: 
                     52:        .text
                     53: 
                     54: #include "pstorage.s"          /* PROCESSOR STORAGE AREA               */
                     55: 
                     56:        .globl  _Entry
                     57: _Entry:
                     58:        jmp     start
                     59:        .space  (1024-6)
                     60: 
                     61: 
                     62: 
                     63: /*             globl dump buffer to be used for communication          */
                     64: /*             between tests & interrupt handlers, & other misc.       */
                     65: /*             purposes.                                               */
                     66:                                
                     67:                                /*physical page 3                       */
                     68: 
                     69:        .set    NLWU,30         /*no. of longwords already used         */
                     70:                                /*this must be changed when you define  */
                     71:                                /*additional variables below before     */
                     72:                                /*_dbuf                                 */
                     73:        .globl  _restart
                     74: _restart:
                     75:        .space  4               /*contains restart address for rastarting*/
                     76:                                /*after power is restored (loaded by    */
                     77:                                /*power fail interrupt handler & used by*/
                     78:                                /*CPU 2                                 */      
                     79:        .globl  _maxmem
                     80: _maxmem:
                     81:        .space  4               /*memory size in no of bytes            */
                     82: 
                     83:        .globl  _maxpages
                     84: _maxpages:
                     85:        .space  4               /*memory size in no. of physical pages  */
                     86: 
                     87:        .globl  _lastadd
                     88: _lastadd:
                     89:        .space  4               /*address of the last long word         */
                     90: 
                     91:        .globl  _unused
                     92: _unused:
                     93:        .space  4               /*first unused page in system space     */
                     94: 
                     95:        .globl  _ctlblk
                     96: _ctlblk:
                     97:        .long   0               /* pointer to SCB */
                     98: 
                     99:        .globl  _savvec0        /*save vectors area                     */
                    100: _savvec0:
                    101:        .space  4
                    102: 
                    103:        .globl  _savvec1        /*save vectors area                     */
                    104: _savvec1:
                    105:        .space  4
                    106: 
                    107:        .globl  _savvec2        /*save vectors area                     */
                    108: _savvec2:
                    109:        .space  4
                    110: 
                    111:        .globl  _savvec3        /*save vectors area                     */
                    112: _savvec3:
                    113:        .space  4
                    114: 
                    115:        .globl  _savvec4        /*save vectors area                     */
                    116: _savvec4:
                    117:        .space  4
                    118: 
                    119:        .globl  _savvec5        /*save vectors area                     */
                    120: _savvec5:
                    121:        .space  4
                    122:        .globl  _savvec6        /*save vectors area                     */
                    123: _savvec6:
                    124:        .space  4
                    125:        .globl  _savvec7        /*save vectors area                     */
                    126: _savvec7:
                    127:        .space  4
                    128:        .globl  _dbuf           /*dump buffer left out of 1K            */
                    129:        .globl  _r_no
                    130: _r_no:
                    131:        .long   0
                    132:        .globl  _pt_base
                    133: _pt_base:
                    134:        .long   0
                    135:        .globl  _saved_psl
                    136: _saved_psl:
                    137:        .long   0
                    138:        .globl  _saved_sp
                    139: _saved_sp:
                    140:        .long   0
                    141:        .globl  _saved_fp
                    142: _saved_fp:
                    143:        .long   0
                    144:        .globl  _p_ptr
                    145: _p_ptr:
                    146:        .long   0
                    147:        .globl  _ret_adr
                    148: _ret_adr:
                    149:        .long   0
                    150:        .globl  _exp_par0
                    151: _exp_par0:
                    152:        .long   0
                    153:        .globl  _exp_par1
                    154: _exp_par1:
                    155:        .long   0
                    156:        .globl  _exp_par2
                    157: _exp_par2:
                    158:        .long   0
                    159:        .globl  _exp_par3
                    160: _exp_par3:
                    161:        .long   0
                    162:        .globl  _act_par0
                    163: _act_par0:
                    164:        .long   0
                    165:        .globl  _act_par1
                    166: _act_par1:
                    167:        .long   0
                    168:        .globl  _act_par2
                    169: _act_par2:
                    170:        .long   0
                    171:        .globl  _act_par3
                    172: _act_par3:
                    173:        .long   0
                    174:        .globl  _test_no
                    175: _test_no:
                    176:        .long   0
                    177: _dbuf:
                    178:        .space  NBPG - (NLWU *4)
                    179: edbuf:
                    180: 
                    181: 
                    182:        .globl  _intstack       /* Interrupt stack                      */
                    183: _intstack:                     /* Physical pages 4 & 5                 */
                    184:        .space  NISP*NBPG
                    185: eintstack:
                    186: 
                    187: 
                    188:        .set    SYSPTSIZE,512   /* No. of entries in SPT                */
                    189:  
                    190: /*
                    191:        System Page Table -- physical page 6 & 7
                    192: */ 
                    193:        .align  2
                    194:        .globl  _Sysmap
                    195: _Sysmap:
                    196:        .space  SYSPTSIZE*4     /* 512 max pages allowed for system     */
                    197: eSysmap:
                    198:        .globl  _Syssize
                    199:        .set    _Syssize,(eSysmap-_Sysmap)/4    /* should be SYSPTSIZE  */
                    200:        
                    201:        .globl  _iomap          /* Physical page 8      */
                    202: _iomap:        .space  1024            /* IOMAP - unused       */
                    203:        .globl  _eiomap
                    204: _eiomap:
                    205: 
                    206:        .globl  _pcb0           /* Physical page 9      */
                    207: _pcb0: .space  128             /*process control block 0               */
                    208:        .globl  _pcb1
                    209: _pcb1: .space 128              /*process control block 1               */
                    210:        .globl  _pcb2
                    211: _pcb2: .space 128              /*process control block 2               */
                    212:        .globl  _pcb3
                    213: _pcb3: .space 128              /*process control block 3               */
                    214:        .globl  _pcb4
                    215: _pcb4: .space 128              /*process control block 4               */
                    216:        .globl  _pcb5
                    217: _pcb5: .space 128              /*process control block 5               */
                    218:        .globl  _pcb6
                    219: _pcb6: .space 128              /*process control block 6               */
                    220:        .globl  _pcb7
                    221: _pcb7: .space 128              /*process control block 7               */
                    222: 
                    223: /*
                    224:        *user #0 page tables -- P0PT, P1PT, P2PT                        
                    225:        *physical memory     --  page10, 11, & 12  respectively
                    226: */
                    227:        .align  2
                    228:        .globl  _u0p0pt
                    229: _u0p0pt:
                    230:        .space  1024            /*255 max pages for user #0 text        */
                    231:        .globl  _u0p1pt
                    232: _u0p1pt:       
                    233:        .space  1024            /*255 max pages for user #0 data        */
                    234:        .globl  _u0p2pt
                    235: _u0p2pt:       
                    236:        .space  1020            /*255 max pages for user #0 stack       */
                    237: eu0p2pt:
                    238:        .space  4
                    239: 
                    240: /*
                    241:        *user #1 page tables -- P0PT, P1PT, P2PT                        
                    242:        *physical memory     --  page13 ,14, & 15  respectively
                    243: */
                    244:        .align  2
                    245:        .globl  _u1p0pt
                    246: _u1p0pt:
                    247:        .space  1024            /*255 max pages for user #1 text        */
                    248:        .globl  _u1p1pt
                    249: _u1p1pt:       
                    250:        .space  1024            /*255 max pages for user #1 data        */
                    251:        .globl  _u1p2pt
                    252: _u1p2pt:       
                    253:        .space  1020            /*255 max pages for user #1 stack       */
                    254: eu1p2pt:
                    255:        .space  4
                    256: 
                    257: 
                    258: /*
                    259:        *user #2 page tables -- P0PT, P1PT, P2PT                        
                    260:        *physical memory     --  page 16, 17 , & 18  respectively
                    261: */
                    262:        .align  2
                    263:        .globl  _u2p0pt
                    264: _u2p0pt:
                    265:        .space  1024            /*255 max pages for user #2 text        */
                    266:        .globl  _u2p1pt
                    267: _u2p1pt:       
                    268:        .space  1024            /*255 max pages for user #2 data        */
                    269:        .globl  _u2p2pt
                    270: _u2p2pt:       
                    271:        .space  1020            /*255 max pages for user #2 stack       */
                    272: eu2p2pt:
                    273:        .space  4
                    274: 
                    275: 
                    276: /*
                    277:        *user #3 page tables -- P0PT, P1PT, P2PT                        
                    278:        *physical memory     --  page 19, 20 , & 21  respectively
                    279: */
                    280:        .align  2
                    281:        .globl  _u3p0pt
                    282: _u3p0pt:
                    283:        .space  1024            /*255 max pages for user #3 text        */
                    284:        .globl  _u3p1pt
                    285: _u3p1pt:       
                    286:        .space  1024            /*255 max pages for user #3 data        */
                    287:        .globl  _u3p2pt
                    288: _u3p2pt:       
                    289:        .space  1020            /*255 max pages for user #3 stack       */
                    290: eu3p2pt:
                    291:        .space  4
                    292: 
                    293: /*
                    294:        *user #4 thru 6 page tables
                    295:        *physical memory -- pages 22 thru 30
                    296: */
                    297:        .globl  _u4p0pt
                    298: _u4p0pt:
                    299:        .space  (9*NBPG) - 4
                    300: eu6p2pt:
                    301:        .space  4
                    302: 
                    303: /*
                    304:        *user #7 page tables -- P0PT, P1PT, P2PT                        
                    305:        *physical memory     --  page 31, 32 , & 33  respectively
                    306: */
                    307:        .align  2
                    308:        .globl  _u7p0pt
                    309: _u7p0pt:
                    310:        .space  1024            /*255 max pages for user #7 text        */
                    311:        .globl  _u7p1pt
                    312: _u7p1pt:       
                    313:        .space  1024            /*255 max pages for user #7 data        */
                    314:        .globl  _u7p2pt
                    315: _u7p2pt:       
                    316:        .space  1020            /*255 max pages for user #7 stack       */
                    317: eu7p2pt:
                    318:        .space  4
                    319: 
                    320:        .globl  _iob0           /*io buffer 0 */
                    321: _iob0: .space  1024
                    322:        .globl  _iob1           /*io buffer 1 */
                    323: _iob1: .space  1024
                    324:        .globl  _iob2           /*io buffer 2 */
                    325: _iob2: .space  1024
                    326:        .globl  _iob3           /*io buffer 3 */
                    327: _iob3: .space  1024
                    328:        .globl  _iob4           /*io buffer 4 */
                    329: _iob4: .space  1024
                    330:        .globl  _iob5           /*io buffer 5 */
                    331: _iob5: .space  1024
                    332:        .globl  _iob6           /*io buffer 6 */
                    333: _iob6: .space  1024
                    334: esysdata:
                    335: 
                    336: #include "scblock.s"           /* SYSTEM CONTROL BLOCK                 */
                    337: 
                    338: 
                    339: 
                    340: 
                    341: 
                    342: 
                    343: 
                    344: #include       "evthandlers.s" /*event handlers                        */
                    345: 
                    346: #define        ACBL(_n1,_n2,_n3,_n4) \
                    347: addl2  _n2,_n3;\
                    348: cmpl   _n3,_n1;\
                    349: bleq   _n4;
                    350: 
                    351: 
                    352: 
                    353: /*
                    354:        *INITIALIZATION CODE
                    355:        *
                    356:        * MME off; mode = k; IPL = 31; IS = 1
                    357:        *
                    358: */
                    359: 
                    360:        .globl  start
                    361: start:
                    362:        mtpr    $0,$MME                 /* Disable MME */
                    363:        movl    r0,_tno         /* R0 : Test no to run; 0 run all tests */
                    364:        movl    r1,_option
                    365:        movl    r2,_Cycle       /* R2 : Cycle count */
                    366: 
                    367:        clrl    _cycle
                    368:        andl3   _option,$0x8,_ss1       /* Heading message sense switch */
                    369:        andl3   _option,$0x4,_Emsg      /* Error message sense switch */
                    370:        clrl    _lptest
                    371: 
                    372:        tstl    _tno            /* Set lptest if tno == XX and loop forever */
                    373:        beql    mmtest
                    374:        cmpl    $-1,_Cycle
                    375:        bneq    mmtest
                    376:        incl    _lptest
                    377: mmtest:
                    378:        movab   _scb,r0
                    379:        mtpr    r0,$SCBB                /* Set SCBB  */
                    380:        mtpr    $0x1f,$IPL
                    381: 
                    382:        movpsl  r1
                    383:        andl2   $0xffffff00,r1          /* Mask out flags               */
                    384:        cmpl    r1,$0x041f0000          /*IS on,modes =k & IPL = 31?    */
                    385:        beql    1f
                    386: 2:     movl    $1,r0
                    387:        movl    $0x041f0000,r2
                    388:        halt                    /* PSL not initialized as expected      */
                    389: 1:
                    390:        mtpr    $_intstack+NISP*NBPG,$ISP       /* init. ISP            */
                    391:        movl    $_intstack+NISP*NBPG,sp /* in case we get exception     */
                    392:        movab   (sp),fp                 /* Initialize FP                */
                    393: 
                    394: /*
                    395:        Clear system data area all the way upto system code
                    396:        this includes dump buffer,interrupt stack,spt,iomap,pcbs,user 
                    397:        page tables, & io buffer area.
                    398: */
                    399: 3:     
                    400:        movab   esysdata,r7
                    401:        movab   _restart,r6
                    402: 1:     clrl    (r6)
                    403:        ACBL(r7,$4,r6,1b)
                    404: /*
                    405:        Initialize System Page Table
                    406: */
                    407: 5:
                    408:        clrl    r2
                    409:        movab   esysdata,r1     /* R1 = Last address in system data area */
                    410:        andl2   $0x3fffffff,r1  /* Mask out bit 30,31   */
                    411:        shar    $PGSHIFT,r1,r1  /* Get page no. of last system data addr  */
                    412:                                /* Map systm data area 1 to 1,kernel writable */
                    413: 1:
                    414:        movl    r2,r11          
                    415:        orl3    $PG_V|PG_KW,r11,_Sysmap[r2]
                    416:        aoblss  r1,r2,1b
                    417: /*
                    418:        Map system text area 1 to 1, Kernel read/write.
                    419:        For this to work, the label _etext must exist at the end 
                    420:        of system code; Add in 4 more pages for data area used in C
                    421: */
                    422:        movab   _edata + 4*(NBPG-1),r1  /* Map text+data 1 to 1; Kernel R/W */
                    423: /*     movab   _etext + 4*(NBPG-1), r1         */
                    424:        andl2   $0x3fffffff,r1
                    425:        shar    $PGSHIFT,r1,r1
                    426: 1:
                    427:        movl    r2,r11
                    428:        orl3    $PG_V|PG_KW,r11,_Sysmap[r2]     /* Kernel Read/Write */
                    429:        aoblss  r1,r2,1b
                    430: /*
                    431:        Map from here (1st unused page) to page 512 :
                    432:           * invalid,no access, & virtual = physical
                    433: */
                    434:        movl    r2,_unused      /* Save first unused physical page no   */
                    435:        movl    $LSP+1,r1
                    436: 1:     movl    r2,_Sysmap[r2]
                    437:        aoblss  r1,r2,1b
                    438: 
                    439: /*
                    440:        Initialize SBR, SLR
                    441:  *Following are some useful addresses for user 0 (in case you want
                    442:  *to start user 0:
                    443:  *
                    444:  *     p0br = $_u0p0pt (limit = 256 max)
                    445:  *     p1br = $_u0p1pt ( same limit)
                    446:  *     p2br = $0xbfc02c00 (funny)
                    447:  *     p2lr = $0x000ffff0 (funny)
                    448:  *
                    449:  *for other users, add NBPG*3 to above except for p2 area
                    450:  *
                    451:  *     u0_user_sp = 0xbffffbfc
                    452:  *     u0_k_sp    = 0xbfffe3fc
                    453:  *     u0_s_sp    = 0xbfffcbfc
                    454:  *     u0_e_sp    = 0xbfffcbfc
                    455:  *
                    456: */
                    457: 
                    458: sysrdy:
                    459:        cmpl    $TRUE,$P0SPACE
                    460:        bneq    0f
                    461:        mtpr    $_Sysmap,$SBR                   /*  Physical mode */
                    462:        brb     1f
                    463: 0:     mtpr    $(_Sysmap-0xc0000000),$SBR      /* Virtual mode version */
                    464: 1:     mtpr    $_Syssize,$SLR
                    465: 
                    466: /* 
                    467:        Double map the kernel into user addresses : 
                    468:        This will enable system to go to virtual mode the 1st time !!
                    469: */
                    470:        .globl  _ready
                    471:        mtpr    $_Sysmap,$P0BR
                    472:        mtpr    $_Syssize,$P0LR
                    473: _ready:                                
                    474:        cmpl    $P0SPACE,$TRUE          /* Run physical ? */
                    475:        beql    pmode
                    476:        
                    477: /*     GO TO VIRTUAL MODE      */
                    478:        mtpr    $1,$DCK                 /* Set data cache key */
                    479:        mtpr    $1,$DCR                 /* Enable data cache */
                    480:        mtpr    $1,$PADC                /* Purge all data cache */
                    481:        mtpr    $1,$TBIA                /* Purge all translation buffer */
                    482:        mtpr    $1,$MME                 /* Turn on MME */
                    483:        jmp     *$pmode                 /* Go .... */
                    484: pmode:
                    485:        mtpr    $0,$P0LR                /* Invalidate user map */
                    486:        mtpr    $_pcb0,$PCBB            /* Initialize PCBB */
                    487: 
                    488:        tstl    _ss1
                    489:        jeql    1f
                    490:        pushl   $M0
                    491:        callf   $4+4,_writes
                    492: 1:
                    493:        mtpr    $2,$DCR                 /* Disable data cache */
                    494:        cmpl    $0,_tno
                    495:        beql    t0
                    496:        cmpl    $1,_tno
                    497:        bneq    nxt1
                    498: t0:
                    499:        calls   $4,_vtest       /* and fetching virtual in P0 */
                    500:        tstl    _lptest
                    501:        bneq    t0
                    502: nxt1:
                    503:        mtpr    $1,$DCR                 /* Enable data cache */
                    504:        mtpr    $2,$DCK                 /* Set data cache key */
                    505:        mtpr    $1,$PADC                /* Purge all data cache */
                    506: 
                    507:        cmpl    $0,_tno
                    508:        beql    t1
                    509:        cmpl    $2,_tno
                    510:        bneq    nxt2
                    511: t1:
                    512:        calls   $4,_protect     /* Test1 : access protection of PTE's */
                    513:        tstl    _lptest
                    514:        bneq    t1
                    515: nxt2:
                    516:        cmpl    $0,_tno
                    517:        beql    t2
                    518:        cmpl    $3,_tno
                    519:        bneq    nxt3
                    520: t2:
                    521:        calls   $4,_vl_test     /* Test2 :  valid bit and length check */
                    522:        tstl    _lptest
                    523:        bneq    t2
                    524: nxt3:
                    525:        cmpl    $0,_tno
                    526:        beql    t3
                    527:        cmpl    $4,_tno
                    528:        bneq    nxt4
                    529: t3:
                    530:        calls   $4,_mu_test     /* Test3 : the M bit of PTE */
                    531:        tstl    _lptest
                    532:        bneq    t3
                    533: 
                    534: nxt4:
                    535:        cmpl    $0,_tno
                    536:        beql    t4
                    537:        cmpl    $5,_tno
                    538:        bneq    nxt5
                    539: t4:                            /* Test4 : if protection fault detected */
                    540:        calls   $4,_pv_test     /* prior to translation fault */
                    541:        tstl    _lptest
                    542:        bneq    t4
                    543: 
                    544: nxt5:
                    545:        cmpl    $0,_tno
                    546:        beql    t5
                    547:        cmpl    $6,_tno
                    548:        bneq    last
                    549: t5:
                    550:        calls   $4,_ucbit_chk   /* Test5 : Check the Noncachable bit */
                    551:        tstl    _lptest
                    552:        bneq    t5
                    553: last:
                    554:        cmpl    $-1,_Cycle      /* If Cycle == -1 then loop forever */
                    555:        jeql    mmtest
                    556: 
                    557:        incl    _cycle
                    558:        cmpl    _cycle,_Cycle
                    559:        jlss    mmtest
                    560: 
                    561:        .globl  passed
                    562: passed:
                    563:        tstl    _ss1
                    564:        jeql    1f
                    565:        pushl   $M2             /* Cycle count */
                    566:        callf   $4+4,_writes
                    567:        pushl   _Cycle
                    568:        callf   $4+4,_writeh
                    569:        pushl   $M1
                    570:        callf   $4+4,_writes
                    571: 1:
                    572:        movl    $0xcafebabe,r0
                    573:        halt                            /* Good halt :   R0 == CAFE BABE */
                    574:        .space  40                      /* Reserved some space */
                    575: 
                    576: 
                    577:        .align  2
                    578:        .globl  _ss1
                    579: _ss1:  .long   0       /* Heading sense switch : 1 then donot print */
                    580:        .globl  _tno
                    581: _tno:  .long   0       /* If -1 run ALL tests, else run test "tno" */
                    582:        .globl  _Cycle
                    583: _Cycle:        .long   0       /* Cycle count */
                    584:        .globl  _cycle
                    585: _cycle:        .long   0       /* Cycle count */
                    586:        .globl  _option
                    587: _option:
                    588:        .long   0
                    589:        .globl  _lptest
                    590: _lptest:
                    591:        .long   0       /* Loop on test specified by tno */
                    592:        .globl  _Emsg
                    593: _Emsg:
                    594:        .long   0
                    595: 
                    596:        .data   1               /* MESSAGE AREA */
                    597: M0:    .ascii  "\n** Memory Management Test **\n\0"
                    598: M1:    .ascii  "\n** Passed ... \n\0"
                    599: M2:    .ascii  "\n** Cycle count : \0"
                    600: 

unix.superglobalmegacorp.com

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