-#ifdef BOOTDEBUG
-/*
- * If we are debugging the pmap_bootstrap code, we ignore what it has
- * just done (without clobbering it) and do it ourselves here with the
- * code we know works.
- */
- .globl _Xavail_start
- movl _Xavali_start,a4 | grab new first avail PA
- movl a4,d1 | new firstpa
- movl d5,d0
- addl a5,d0 | old firstpa
- subl d0,d1 | new - old == amount allocated
- addl d1,d5 | update firstva
-/*
- * Allocate kernel segment/page table resources.
- * In LUNA, kernel is always loaded at 0, so PA = VA.
- * a4 contains the PA(also VA) of first available page at any time
- * We assume (i.e. do not check) that the initial page table size
- *
- * (Sysptsize) is big enough to map everything we allocate here.
- *
- */
- .globl _Sysseg, _Sysmap, _Sysptmap, _Sysptsize
-#if 0
- movl #0,a5 | kernel is loaded at 0
- movl #_end,d5 | end of static kernel text/data
- addl #NBPG-1,d5
- andl #PG_FRAME,d5 | round to a page
- movl d5,a4
-#endif
-/* allocate kernel segment table */
- movl a4,_Sysseg | remember VA for pmap module
- movl a4,sp@- | remember PA for loading MMU
- addl #NBPG,a4
-/* allocate kernel page table map */
- movl a4,_Sysptmap | remember VA for pmap module
- movl a4,sp@- | remember PA for PT map load
- addl #NBPG,a4
-/* compute KVA of Sysptmap; mapped after page table pages */
- movl d0,d2 | remember PT size (bytes)
- moveq #SG_ISHIFT-PGSHIFT,d1
- lsll d1,d0 | page table size serves as seg index
- movl d0,_Sysmap | remember VA for pmap module
-/* initialize ST and PT map: PT pages + PT map */
- movl sp@+,a1 | PT map PA
- movl sp@+,d4 | start of PT pages
- movl sp@+,a0 | ST phys addr
- lea a0@(NBPG),a2 | end of ST (LUNA)
- movl d4,d3
- orl #SG_RW+SG_V,d4 | create proto STE for ST
- orl #PG_RW+PG_CI+PG_V,d3 | create proto PTE for PT map
-List1:
- movl d4,a0@+
- movl d3,a1@+
- addl #NBPG,d4
- addl #NBPG,d3
- cmpl a4,d4 | sleezy, but works ok
- jcs List1
-/* initialize ST and PT map: invalidate up to last entry */
-List2:
- movl #SG_NV,a0@+
- movl #PG_NV,a1@+
- cmpl a2,a0
- jcs List2
-
-/* IOPT setup: allocate IOPT and setup routine call (LUNA) */
- movl _ioptpage,d0 | IOPTPAGE(=11PG)
- movl #PGSHIFT,d1
- lsll d1,d0 | convert bytes
- movl a4,a2 | save start of IOPT
- addl d0,a4
- moveml #0xC0C0,sp@- | save scratch regs
- movl a2,sp@- | start of IOPT
- jbsr _iopage_setup | IOPT setup routine
- addql #4,sp | pop arg
- moveml sp@+,#0x0303 | restore regs
-
-/*
- * 0x3FF00000 for UPAGES is used for mapping the current process
- * u-area (u + kernel stack).
- */
- movl a4,d1 | grab next available for PT page
- andl #SG_FRAME,d1 | mask to frame number
- orl #SG_RW+SG_V,d1 | RW and valid
- movl a0,a2 | remember addr for PT load
- movl a0,sp@- | push end of ST entry
- subl #NBPG,a0 | start of ST entry
- movl #KERNELSTACK,d3 | compute kernel stack
- movl #SG_ISHIFT,d4 | ST entry offset
- lsrl d4,d3 |
- lsll #2,d3 |
- addl d3,a0 | ST entry address
- movl d1,a0@ | store at 0x3FC00000 ST entry
- movl sp@+,a0 | pop start of PT entry
- andl #PG_FRAME,d1
- orl #PG_RW+PG_V,d1 | convert to PTE
- movl a1,sp@- | push end of PT map
- subl #NBPG,a1 | start of PT map
- addl d3,a1 | offset computed above
- movl d1,a1@ | store in PT map
- movl sp@+,a1 | pop end of PT map
- movl a4,a0 | physical beginning of PT page
- lea a0@(NBPG),a1 | end of page
-Lispt7:
- movl #PG_NV,a0@+ | invalidate
- cmpl a1,a0
- jcs Lispt7
- addl #NBPG,a4
-/* record KVA at which to access current u-area PTEs */
- movl _Sysmap,d0 | get system PT address
- movl #NPTEPG*NBPG,d1 | size of system PT
- lsrl #2,d1 | kernel MAX VA = 0x4000000 (LUNA)
- addl d1,d0 | end of system PT
- subl #HIGHPAGES*4,d0 | back up to first PTE for u-area
- movl d0,_Umap | remember location
-/* initialize page table pages */
- movl a2,a0 | end of ST is start of PT
- addl d2,a2 | add size to get end of PT
-/* text pages are read-only */
- clrl d0 | assume load at VA 0
- clrl d1 | PA = VA
- andl #PG_FRAME,d1 | convert to a page frame
-#ifdef KGDB
- orl #PG_RW+PG_V,d1 | XXX: RW for now
-#else
- orl #PG_RO+PG_V,d1 | create proto PTE
-#endif
- movl #_etext,a1 | go til end of text
-Lipt1:
- movl d1,a0@+ | load PTE
- addl #NBPG,d1 | increment page frame number
- addl #NBPG,d0 | and address counter
- cmpl a1,d0 | done yet?
- jcs Lipt1 | no, keep going
-/* data, bss and dynamic tables are read/write */
- andl #PG_FRAME,d1 | mask out old prot bits
- orl #PG_RW+PG_V,d1 | mark as valid and RW
- movl d5,a1 | go til end of data allocated so far
- addl #(UPAGES+1)*NBPG,a1 | and proc0 PT/u-area (to be allocated)
-Lipt2:
- movl d1,a0@+ | load PTE
- addl #NBPG,d1 | increment page frame number
- addl #NBPG,d0 | and address counter
- cmpl a1,d0 | done yet?
- jcs Lipt2 | no, keep going
-/* invalidate remainder of kernel PT */
- movl a2,a1 | end of PT
-Lipt3:
- movl #PG_NV,a0@+ | invalidate PTE
- cmpl a1,a0 | done yet?
- jcs Lipt3 | no, keep going
-
-/*
- * Setup page table for process 0.
- *
- * We set up page table access for the kernel via Umap and access to
- * the u-area itself via `u'. First available UPAGES pages (start at
- * VA=PA: a4) are used for the u-area.
- */
- movl a4,d0
- movl a4,a2
- lea a4@(-HIGHPAGES*4),a0 | u-area PTE base in Umap PT
- lea a0@(UPAGES*4),a1 | end of PTEs for u-area
- movl d0,d1 | get base of u-area
- andl #PG_FRAME,d1 | mask to page frame number
- orl #PG_RW+PG_V,d1 | add valid and writable
-Liudot2:
- movl d1,a0@+ | validate p_addr PTE
- addl #NBPG,d1 | to next page
- cmpl a1,a0 | done yet?
- jcs Liudot2 | no, keep going
-/* clear process 0 u-area */
- addl #NBPG*UPAGES,d0 | end of u-area
-Lclru1:
- clrl a2@+ | clear
- cmpl d0,a2 | done yet?
- jcs Lclru1 | no, keep going
- movl a2,a4 | save phys addr of first avail page
- RELOC(_proc0paddr, a0)
- movl d5,a0@ | save KVA of proc0 u-area
- addl #UPAGES*NBPG,d5 | increment virtual addr as well
-#endif
-