Move kernel_main into the elna code
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
|
||||
.include "./arch/riscv/constants.s"
|
||||
|
||||
.section .data
|
||||
|
||||
.globl pmem_address
|
||||
pmem_address: .word
|
||||
|
||||
.section .text
|
||||
|
||||
# a0 - First pointer.
|
||||
@@ -245,9 +250,8 @@ memset:
|
||||
# Parameters:
|
||||
# a0 - Corresponding virtual address.
|
||||
# a1 - Physical page address.
|
||||
# a2 - Free memory page that can be used to create a leaf page table.
|
||||
# a3 - Page table level. If a3 is 0 a superpage is allocated, otherwise a normal page.
|
||||
# a4 - Flags.
|
||||
# a2 - Page table level. If a2 is 0 a superpage is allocated, otherwise a normal page.
|
||||
# a3 - Flags.
|
||||
#
|
||||
# If the function creates new page tables in a2, it advances a2 by the page size and
|
||||
# returns it in a0.
|
||||
@@ -268,7 +272,7 @@ pmem_map_at:
|
||||
and t2, t2, t5 # VPN[i] * PTESIZE.
|
||||
add t2, t0, t2 # a + VPN[i] * PTESIZE.
|
||||
|
||||
beqz a3, .Lpmem_map_at_leaf
|
||||
beqz a2, .Lpmem_map_at_leaf
|
||||
|
||||
lw t3, (t2)
|
||||
andi t6, t3, 0b1
|
||||
@@ -281,27 +285,29 @@ pmem_map_at:
|
||||
j .Lpmem_map_at_next
|
||||
|
||||
.Lpmem_map_at_create:
|
||||
la a7, pmem_address
|
||||
# Take a chunk of free memory and use it as the next page table.
|
||||
# The beginning addres off the chunk is the base address (a) for the next level.
|
||||
mv t0, a2
|
||||
lw t0, (a7)
|
||||
srli t3, t0, 2
|
||||
ori t3, t3, 0b1
|
||||
sw t3, (t2)
|
||||
|
||||
li t6, PAGE_SIZE
|
||||
add a2, a2, t6
|
||||
add t0, t0, t6
|
||||
sw t0, (a7)
|
||||
|
||||
.Lpmem_map_at_next:
|
||||
# Calculate the next page table address for the next level.
|
||||
addi t1, t1, -10
|
||||
addi a3, a3, -1
|
||||
addi a2, a2, -1
|
||||
|
||||
j .Lpmem_map_at_loop
|
||||
|
||||
.Lpmem_map_at_leaf:
|
||||
srli t3, a1, 2 # Physical page number mapped to 12 bits of the page table entry.
|
||||
ori a4, a4, 0b1
|
||||
or t3, t3, a4 # Execute, write, read and valid.
|
||||
ori a3, a3, 0b1
|
||||
or t3, t3, a3 # Execute, write, read and valid.
|
||||
sw t3, (t2)
|
||||
|
||||
mv a0, a2
|
||||
|
Reference in New Issue
Block a user