Annotation of cci/d/demand/subs.c, revision 1.1

1.1     ! root        1: 
        !             2: #include "definitions"
        !             3: 
        !             4: extern long r_no, pt_base, ctlblk;
        !             5: long dummy;
        !             6: 
        !             7: /* To get value of base registers */
        !             8: mfpr(sr)
        !             9: long sr;
        !            10: {
        !            11:        asm("mfpr 4(fp),_dummy");
        !            12:        return(dummy);
        !            13: }
        !            14: 
        !            15: /* This routine modify the valid,protection bits (bit 27-31) of PTE
        !            16:    in any Page table. Input parameter :
        !            17:        reg_no     : contain a number specify one of the following :
        !            18:                     SBR,SLR,P0BR,P0LR,P1BR,P1LR,P2BR,P2LR
        !            19:        old_pte    : pointer to location to save original PTE
        !            20:                     (This could be used to read any PTE when pvbits_msk = 0)
        !            21:        which1     : PTE no; 0,1,2...X
        !            22:        pvbits_msk : bit 27-31 of PTE 
        !            23: */
        !            24: fixpv_pte(reg_no,which1,old_pte,pvbits_msk)
        !            25: long reg_no, *old_pte, which1, pvbits_msk;
        !            26: {      
        !            27:        long *st_base;
        !            28: 
        !            29:        r_no = reg_no;
        !            30: 
        !            31: /*     asm("mfpr _r_no,_pt_base"); */          /* Get base address  */
        !            32:        pt_base = mfpr(r_no);
        !            33: 
        !            34:        st_base = (long *)pt_base;
        !            35:        st_base += which1;
        !            36:        *old_pte = *st_base;                    /* Save original PTE */
        !            37:        /* Mask access and valid bits off */
        !            38:        *st_base = (*st_base) & (~(PTE_PROT | PTE_V));
        !            39:        *st_base = (*st_base)|(pvbits_msk);     /* Set V,protection bits */
        !            40:        asm("mtpr $0,$TBIA");           /* Invalidate translation buffers */
        !            41: }
        !            42: 
        !            43: /* This routine modify the modify,used,uncachable bits (22-24) of PTE
        !            44:    in any Page table. Input parameter :
        !            45:        reg_no     : contain a number specify one of the following :
        !            46:                     SBR,SLR,P0BR,P0LR,P1BR,P1LR,P2BR,P2LR
        !            47:        old_pte    : pointer to location to save original PTE
        !            48:                     (This could be used to read any PTE when pvbits_msk = 0)
        !            49:        which1     : PTE no; 0,1,2...X
        !            50:        pvbits_msk : bits 22-24 of PTE; if mask < 0 then just read back PTE. 
        !            51: */
        !            52: fixmuc_pte(reg_no,which1,old_pte,pvbits_msk)
        !            53: long reg_no, *old_pte, which1, pvbits_msk;
        !            54: {      
        !            55:        long *st_base;
        !            56: 
        !            57:        r_no = reg_no;
        !            58: 
        !            59: /*     asm("mfpr _r_no,_pt_base"); */          /* Get base address  */
        !            60:        pt_base = mfpr(r_no);
        !            61: 
        !            62:        st_base = (long *)pt_base;
        !            63:        st_base += which1;
        !            64:        *old_pte = *st_base;                    /* Save original PTE */
        !            65:        if (pvbits_msk < 0) return;
        !            66:        *st_base=(*st_base)&(~(PTE_UC|PTE_M|PTE_U)); /* Mask NC,M,U bit off */
        !            67:        *st_base = (*st_base)|(pvbits_msk);  
        !            68:        asm("mtpr $0,$TBIA");           /* Invalidate translation buffers */
        !            69: }
        !            70: 
        !            71: /* This routine modify the page frame number (bit 0-21) of PTE
        !            72:    in any Page table. Input parameter :
        !            73:        reg_no     : contain a number specify one of the following :
        !            74:                     SBR,SLR,P0BR,P0LR,P1BR,P1LR,P2BR,P2LR
        !            75:        old_pte    : pointer to location to save original PTE
        !            76:                     (This could be used to read any PTE when pvbits_msk = 0)
        !            77:        which1     : PTE no; 0,1,2...X
        !            78:        pfn        : New page frame no. (bit 0 thru 19 of pfn )
        !            79: */
        !            80: fixpfn_pte(reg_no,which1,old_pte,pfn)
        !            81: long reg_no, *old_pte, which1, pfn;
        !            82: {      
        !            83:        long *st_base;
        !            84: 
        !            85:        r_no = reg_no;
        !            86: 
        !            87: /*     asm("mfpr _r_no,_pt_base"); */          /* Get base address  */
        !            88:        pt_base = mfpr(r_no);
        !            89: 
        !            90:        st_base = (long *)pt_base;
        !            91:        st_base += which1;
        !            92:        *old_pte = *st_base;                    /* Save original PTE */
        !            93:        *st_base = (*st_base)&(~PTE_PFN);       /* Mask PFN off */
        !            94:        *st_base = (*st_base)|(pfn & PTE_PFN);  /* Set new PFN */
        !            95:        *st_base = (*st_base)&0xff7fffff;       /* Set PTE_M bit off */
        !            96:        asm("mtpr $0,$TBIA");           /* Invalidate translation buffers */
        !            97:        asm("mtpr $0,$PADC");           /* Purge all data cache */
        !            98: }
        !            99: 
        !           100: /* This routine saved a vector in SCB and set it to a new one
        !           101:    input parameters :
        !           102:        which1 : Vector no; 0,1,2,..X
        !           103:        saved_vec : pointer to a location to saved original vector
        !           104:        new_vec   : address of new handler
        !           105:        stack     : 'K' or 'k' : service on Kernel stack
        !           106:                    otherwise  : service on Interrupt stack
        !           107: */
        !           108: 
        !           109: 
        !           110: set_handler(which1,saved_vec,new_vec)
        !           111: long which1, *saved_vec, new_vec; 
        !           112: {      long *st_base;
        !           113: 
        !           114:        asm("movab _scb,_ctlblk");
        !           115:        st_base = (long *)ctlblk;       /* address of SCB is at page 2 */
        !           116:        st_base += which1;
        !           117:        *saved_vec = *st_base;          /* Save original vector */
        !           118:        *st_base = new_vec;
        !           119: }
        !           120: 
        !           121: 
        !           122: /* This routine write the who page of memory with "value"
        !           123:    Inpur parameters :
        !           124:        space   : Has 1 of these values (0,1,2,3) correspond to
        !           125:                  P0, P1, P2, System space respectively.
        !           126:        page_no : Virtual page no. to be written
        !           127:        value   : Value to be written
        !           128:        v_type  : | 0 : value is used to write in all locations.
        !           129:                  | 1 : value is the start value and is incremented
        !           130:                  |     for next locations.
        !           131: */
        !           132: 
        !           133: write_pg(space,page_no,value,v_type)
        !           134: long space, page_no, value, v_type;
        !           135: {
        !           136:        long *lptr;
        !           137:        int ix;
        !           138: 
        !           139:        lptr = (long *)(((space & 0x3)<<30)|((page_no & 0xfffff)<<PGSHIFT));
        !           140:        for (ix=0;ix<NBPG;ix += 4)
        !           141:                {
        !           142:                  *lptr++ = value;
        !           143:                  if (v_type) value += 4;
        !           144:                }
        !           145: }
        !           146: 
        !           147: /* This routine read the who page of memory .
        !           148:    Inpur parameters :
        !           149:        space   : Has 1 of these values (0,1,2,3) correspond to
        !           150:                  P0, P1, P2, System space respectively.
        !           151:        page_no : Virtual page no. to be read.
        !           152:        start_dst : pointer to array of longwords.
        !           153: */
        !           154: 
        !           155: read_pg(space,page_no,start_dst)
        !           156: long space, page_no, *start_dst;
        !           157: {
        !           158:        long *lptr;
        !           159:        int ix;
        !           160: 
        !           161:        lptr = (long *)(((space & 0x3)<<30)|((page_no & 0xfffff)<<PGSHIFT));
        !           162:        for (ix=0;ix<NBPG;ix += 4)
        !           163:                  *start_dst++ = *lptr++ ;
        !           164: }
        !           165: 

unix.superglobalmegacorp.com

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