57 lines
1.6 KiB
Plaintext
57 lines
1.6 KiB
Plaintext
.text
|
|
.global pmem_init
|
|
pmem_init:
|
|
move.b #0x5, d0 | Get the pointer to the MMU card
|
|
jsr find_first_card
|
|
adda.l #0x10, a0
|
|
move.l a0, mmu_tlb_clear_addr
|
|
move.l #((map_page - 0xC00000)), d1 | Get the entry offset for the mapping page in d1
|
|
lsr.l #8, d1
|
|
lsr.l #2, d1
|
|
move.l #kernel_map_page, a0 | Get the address of the mapping entry for the mapping page in a0
|
|
adda.l d1, a0
|
|
move.l a0, map_page_entry_addr
|
|
rts
|
|
|
|
.global push_page
|
|
| Page to push in d0
|
|
push_page:
|
|
move.l map_page_entry_addr, a0
|
|
move.l (a0), d1 | Read the mapping entry into d1
|
|
andi.l #(~0xFFF), d1 | Clear the entry's flags to get the pointer to it's physical page
|
|
ori.l #0x3, d0 | Map the mapping page to the passed in frame
|
|
move.l d0, (a0)
|
|
move.l mmu_tlb_clear_addr, a0 | Clear the TLB entry for the mapping page
|
|
move.l #map_page, (a0)
|
|
move.l d1, (map_page)
|
|
rts
|
|
|
|
.global pop_page
|
|
pop_page:
|
|
move.l map_page_entry_addr, a0
|
|
move.l (a0), d0 | Read the mapping entry into d0
|
|
btst #0, d0 | Check the entry's present flag
|
|
bne.b pop_no_page | If the entry isn't present, halt the CPU
|
|
andi.l #(~0xFFF), d0 | Clear the entry's flags to get the pointer to it's physical frame
|
|
move.l (map_page), d1 | Get the address of the frame pointed to by the top of the stack
|
|
cmpi.l #0x0, d1 | Compare the pointed-to frame to the null frame
|
|
beq.b 1f | If it is, unmap the mapping_page
|
|
ori.l #0x3, d1 | Map the mapping page to the frame pointed to by the top of the stack
|
|
1: move.l d1, (a0)
|
|
move.l mmu_tlb_clear_addr, a0 | Clear the TLB entry for the mapping page
|
|
move.l #map_page, (a0)
|
|
rts
|
|
pop_no_page:
|
|
stop #2700
|
|
|
|
.bss
|
|
mmu_tlb_clear_addr:
|
|
.ds.b 4
|
|
map_page_entry_addr:
|
|
.ds.b 4
|
|
|
|
.section .pagereserve
|
|
.balign 4096
|
|
map_page:
|
|
.ds.b 4096
|