Annotation of researchv9/sys/sun3/map.s, revision 1.1

1.1     ! root        1: /*      @(#)map.s 1.1 86/02/03 SMI      */
        !             2: 
        !             3: /*
        !             4:  * Copyright (c) 1985 by Sun Microsystems, Inc.
        !             5:  */
        !             6: 
        !             7: /*
        !             8:  * Memory Mapping and Paging on the Sun-3.
        !             9:  * NOTE:  All of these routines assume that the
        !            10:  * default sfc and dfc have been preset to FC_MAP.
        !            11:  */
        !            12: 
        !            13: #include "../h/param.h"
        !            14: #include "../machine/asm_linkage.h"
        !            15: #include "../machine/mmu.h"
        !            16: #include "../machine/pte.h"
        !            17: 
        !            18:        .text
        !            19:        |
        !            20:        | Sets the pte Referenced and Modified bits based on the
        !            21:        | pme for page pageno and then clears the these bits in the pme.
        !            22:        |
        !            23:        | unloadpgmap(pageno, pte)
        !            24:        | u_int pageno;
        !            25:        | struct pte* pte;
        !            26:        ENTRY(unloadpgmap)
        !            27:        movl    sp@(8),a1
        !            28:        movl    a1@,d0                  | valid?
        !            29:        bge     0f                      | no, just return
        !            30:        movl    sp@(4),d0               | get first parameter
        !            31:        moveq   #PGSHIFT,d1             | set of count for shift
        !            32:        lsll    d1,d0                   | convert to address
        !            33:        orl     #PAGEBASE,d0            | set to page map base offset
        !            34:        movl    d0,a0                   | move into a0
        !            35:        movsl   a0@,d0                  | read page map entry
        !            36:        movl    d0,d1
        !            37:        bge     0f                      | skip if invalid
        !            38:        andl    #(PG_R+PG_M),d0         | save Reference and Modified bits
        !            39:        orl     d0,a1@                  | add these bits into software pte
        !            40:        andl    #~(PG_R+PG_M),d1        | turn off Reference and Modified bits
        !            41:        movsl   d1,a0@                  | put new page map entry back
        !            42: 0:
        !            43:        rts                             | done
        !            44: 
        !            45:        |
        !            46:        | Read the page map entry for the given address v
        !            47:        | and return it in a form suitable for software use.
        !            48:        |
        !            49:        | long
        !            50:        | getpgmap(v)
        !            51:        | caddr_t v;
        !            52:        ENTRY(getpgmap)
        !            53:        movl    sp@(4),d0               | get access address
        !            54:        andl    #PAGEADDRBITS,d0        | clear extraneous bits
        !            55:        orl     #PAGEBASE,d0            | set to page map base offset
        !            56:        movl    d0,a0
        !            57:        movsl   a0@,d0                  | read page map entry
        !            58:                                        | no mods needed to make pte from pme
        !            59:        rts                             | done
        !            60: 
        !            61:        |
        !            62:        | Set the pme for address v using the software pte given.
        !            63:        |
        !            64:        | setpgmap(v, pte)
        !            65:        | caddr_t v;
        !            66:        | long pte;
        !            67:        ENTRY(setpgmap)
        !            68:        movl    sp@(4),d0               | get access address
        !            69:        andl    #PAGEADDRBITS,d0        | clear extraneous bits
        !            70:        orl     #PAGEBASE,d0            | set to page map base offset
        !            71:        movl    d0,a0
        !            72:        movl    sp@(8),d0               | get page map entry to write
        !            73:                                        | no mods need to make pme from pte
        !            74:        movsl   d0,a0@                  | write page map entry
        !            75:        rts                             | done
        !            76: 
        !            77:        |
        !            78:        | Load the pme for page pageno using the pte given.
        !            79:        | If the original pme is valid and we are not on
        !            80:        | a new pmeg, then the R and M bits are preserved
        !            81:        | from the original pme.
        !            82:        |
        !            83:        | loadpgmap(pageno, pte, new)
        !            84:        | u_int pageno;         /* virtual page to set up */
        !            85:        | struct pte *pte;      /* pointer to pte to use */
        !            86:        | int new;              /* new pmeg flag */
        !            87:        ENTRY(loadpgmap)
        !            88:        movl    sp@(4),d0               | get first parameter
        !            89:        moveq   #PGSHIFT,d1             | set of count for shift
        !            90:        lsll    d1,d0                   | convert to address
        !            91:        andl    #PAGEADDRBITS,d0        | clear extraneous bits
        !            92:        orl     #PAGEBASE,d0            | set to page map base offset
        !            93:        movl    d0,a1
        !            94:        movl    sp@(8),a0               | get address of page map entry to write
        !            95:        movl    a0@,d0                  | read old page map entry
        !            96:        bge     0f                      | skip if not valid
        !            97:        tstl    sp@(12)                 | new pmeg?
        !            98:        bne     0f                      | yes, don't save bits
        !            99:        movsl   a1@,d1                  | get old pme
        !           100:        andl    #(PG_R+PG_M),d1         | mask off ref and mod bits
        !           101:        orl     d1,d0                   | or them into new pme
        !           102: 0:
        !           103:        movsl   d0,a1@                  | write page map entry
        !           104:        rts                             | done
        !           105: 
        !           106:        |
        !           107:        | Return the 8 bit segment map entry for the given segment number.
        !           108:        |
        !           109:        | u_char
        !           110:        | getsegmap(segno)
        !           111:        | u_int segno;
        !           112:        ENTRY(getsegmap)
        !           113:        movl    sp@(4),d0               | get segment number
        !           114:        moveq   #SGSHIFT,d1             | get count for shift
        !           115:        lsll    d1,d0                   | convert to address
        !           116:        andl    #SEGMENTADDRBITS,d0     | clear extraneous bits
        !           117:        orl     #SEGMENTBASE,d0         | set to segment map offset
        !           118:        movl    d0,a0
        !           119:        moveq   #0,d0                   | clear (upper part of) register
        !           120:        movsb   a0@,d0                  | read segment map entry
        !           121:        rts                             | done
        !           122: 
        !           123:        |
        !           124:        | Set the segment map entry for segno to pm.
        !           125:        |
        !           126:        | setsegmap(segno, pm)
        !           127:        | u_int segno;
        !           128:        | u_char pm;
        !           129:        ENTRY(setsegmap)
        !           130:        movl    sp@(4),d0               | get segment number
        !           131:        moveq   #SGSHIFT,d1             | get count for shift
        !           132:        lsll    d1,d0                   | convert to address
        !           133:        andl    #SEGMENTADDRBITS,d0     | clear extraneous bits
        !           134:        orl     #SEGMENTBASE,d0         | set to segment map offset
        !           135:        movl    d0,a0
        !           136:        movl    sp@(8),d0               | get seg map entry to write
        !           137:        movsb   d0,a0@                  | write segment map entry
        !           138:        rts                             | done
        !           139: 
        !           140:        |
        !           141:        | Return the current [user] context number.
        !           142:        |
        !           143:        | int
        !           144:        | getcontext()
        !           145:        ENTRY2(getcontext,getusercontext)
        !           146:        movsb   CONTEXTBASE,d0          | move context reg into result
        !           147:        andl    #CONTEXTMASK,d0         | clear high-order bits
        !           148:        rts                             | done
        !           149: 
        !           150:        |
        !           151:        | Set the current [user] context number to uc.
        !           152:        |
        !           153:        | setcontext(uc)
        !           154:        | int uc;
        !           155:        ENTRY2(setcontext,setusercontext)
        !           156:        movb    sp@(7),d0               | get context value to set
        !           157:        movsb   d0,CONTEXTBASE          | move value into context register
        !           158:        rts                             | done

unix.superglobalmegacorp.com

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