Add physical memory frame stack
This commit is contained in:
parent
0368408636
commit
6aaf71f214
@ -41,5 +41,9 @@ SECTIONS
|
||||
*(.bss)
|
||||
}
|
||||
|
||||
.pagereserve ALIGN (4K) : {
|
||||
*(.pagereserve)
|
||||
}
|
||||
|
||||
kernel_map_page = 0xFEF000;
|
||||
}
|
||||
|
@ -1,9 +1,15 @@
|
||||
.global main
|
||||
main:
|
||||
move.l #inital_stack, a7 | Load the initial stack pointer
|
||||
move.b #'H', 0xFF0200
|
||||
move.b #'i', 0xFF0200
|
||||
move.b #0xA, 0xFF0200
|
||||
jsr pmem_init
|
||||
move.l #0x1000, d0
|
||||
jsr push_page
|
||||
move.l #0x2000, d0
|
||||
jsr push_page
|
||||
move.l #0, d0
|
||||
jsr pop_page
|
||||
jsr pop_page
|
||||
jsr pop_page
|
||||
stop #0x2700
|
||||
|
||||
.bss
|
||||
|
54
kernel/pmem.68k
Normal file
54
kernel/pmem.68k
Normal file
@ -0,0 +1,54 @@
|
||||
.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 #map_page, mmu_tlb_clear_addr | Clear the TLB entry for the mapping page
|
||||
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 #map_page, mmu_tlb_clear_addr | Clear the TLB entry for the mapping page
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user