Annotation of researchv9/sys/boot/stand/s3map.s, revision 1.1

1.1     ! root        1: |      s3map.s 1.1 86/02/03 Copyright (c) 1985 by Sun Microsystems, Inc.
        !             2: |
        !             3: | /*
        !             4: |  * Memory Mapping and Paging on the Sun 3
        !             5: |  */
        !             6: | 
        !             7: | /*
        !             8: |  * Mapping registers are accessed thru the  movs  instruction in the Sun-3.
        !             9: |  *
        !            10: |  * The following subroutines accept any address in the mappable range
        !            11: |  * (256 megs).  They access the map for the current context register.  They
        !            12: |  * assume that currently we are running in supervisor state.
        !            13: |  */ 
        !            14: | 
        !            15: /* 
        !            16:  * These constants are fixed by the hardware, 
        !            17:  * so don't feel too bad that I redefined them here
        !            18:  */
        !            19: #define        FC_MAP          3               /* space for MMU ops */
        !            20: #define        NUMPMEGS        256             /* number of Pmegs */
        !            21: #define        PMAPOFF         0x10000000      /* offset for page map */
        !            22: #define        SMAPOFF         0x20000000      /* offset for segment map */
        !            23: #define        MAPADDRMASK     0x0FFFE000      /* translatable bits */
        !            24: #define        PME_INVALID     0               /* invalid page */
        !            25: 
        !            26:        .text
        !            27: 
        !            28:        .globl  _setpgmap
        !            29: _setpgmap:
        !            30:        movl    sp@(4),d0       | Get access address
        !            31:        andl    #MAPADDRMASK,d0 | Mask out irrelevant bits
        !            32:        addl    #PMAPOFF,d0     | Offset to page maps
        !            33:        movl    d0,a0
        !            34:        lea     FC_MAP,a1       | Get function code in a reg
        !            35: | The following code can be used to verify that the only page
        !            36: | table entries written to the Invalid Pmeg are invalid pages, since the 
        !            37: | consequences of writing valid entries here are somewhat spectacular.
        !            38:        movc    sfc,d0          | Save source function code
        !            39:        movc    a1,sfc          | Set source function code, too.
        !            40:        addl    #SMAPOFF-PMAPOFF,a0     | Offset to segment map
        !            41:        movsb   a0@,d1          | Get segment map entry number
        !            42:        subl    #SMAPOFF-PMAPOFF,a0     | Offset back to page map
        !            43:        movc    d0,sfc          | Restore source function code
        !            44: | If debug code is removed, next line must remain!
        !            45:        movl    sp@(8),d0       | Get page map entry to write
        !            46: | More debug code
        !            47: #if NUMPMEGS != 256
        !            48:        andb    #NUMPMEGS-1,d1  | Top bit ignored in 128-pmeg version
        !            49: #endif
        !            50:        cmpb    #NUMPMEGS-1,d1  | Are we writing in the Invalid Pmeg?
        !            51:        jne     1$              | Nope, go on.
        !            52:        cmpl    #PME_INVALID,d0 | Writing the Invalid Page Map Entry?
        !            53:        jeq     1$              | Yes, it's ok.
        !            54:        bras    .-1             | Fault out, this is nasty thing to do.
        !            55: 1$:
        !            56: | End of debugging code.
        !            57:        movc    dfc,d1          | Save dest function code
        !            58:        movc    a1,dfc          | Set destination function code
        !            59:        movsl   d0,a0@          | Write page map entry
        !            60:        movc    d1,dfc          | Restore dest function code
        !            61:        rts                     | done
        !            62: 
        !            63: |
        !            64: | Read the page map entry for the given address v
        !            65: | and return it in a form suitable for software use.
        !            66: |
        !            67: | long
        !            68: | getpgmap(v)
        !            69: | caddr_t v;
        !            70:        .globl  _getpgmap
        !            71: _getpgmap:
        !            72:        movl    sp@(4),d0               | get access address
        !            73:        andl    #MAPADDRMASK,d0         | clear extraneous bits
        !            74:        orl     #PMAPOFF,d0             | set to page map base offset
        !            75:        lea     FC_MAP,a1               | Get function code in a reg
        !            76:        movc    sfc,d1                  | Save source function code
        !            77:        movc    a1,sfc                  | Set source function code, too.
        !            78:        movl    d0,a0
        !            79:        movsl   a0@,d0                  | read page map entry
        !            80:                                        | no mods needed to make pte from pme
        !            81:        movc    d1,sfc                  | restore function code
        !            82:        rts                             | done
        !            83: 
        !            84:        .globl  _setsegmap
        !            85: _setsegmap:
        !            86:        movl    sp@(4),d0       | Get access address
        !            87:        andl    #MAPADDRMASK,d0 | Mask out irrelevant bits
        !            88:        addl    #SMAPOFF,d0     | Bump to segment map offset
        !            89:        movl    d0,a0
        !            90:        movl    sp@(8),d0       | Get seg map entry to write
        !            91:        movc    dfc,d1          | Save dest function code
        !            92:        lea     FC_MAP,a1       | Get function code in a reg
        !            93:        movc    a1,dfc          | Set destination function code
        !            94:        movsb   d0,a0@          | Write segment map entry
        !            95:        movc    d1,dfc          | Restore dest function code
        !            96:        rts                     | done

unix.superglobalmegacorp.com

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