Changeset 95c675b in mainline for kernel/arch/riscv64/src/mm/page.c


Ignore:
Timestamp:
2017-10-17T13:11:35Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
60af4cdb
Parents:
dbf32b1 (diff), a416d070 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/riscv64/src/mm/page.c

    rdbf32b1 r95c675b  
    3636#include <genarch/mm/page_pt.h>
    3737#include <arch/mm/frame.h>
     38#include <arch/cpu.h>
    3839#include <mm/frame.h>
    3940#include <mm/page.h>
    4041#include <mm/as.h>
    41 #include <typedefs.h>
    4242#include <align.h>
    4343#include <config.h>
     
    4646#include <arch/asm.h>
    4747#include <debug.h>
    48 #include <memstr.h>
    4948#include <print.h>
    5049#include <interrupt.h>
     
    5251void page_arch_init(void)
    5352{
    54         if (config.cpu_active == 1)
     53        if (config.cpu_active == 1) {
    5554                page_mapping_operations = &pt_mapping_operations;
     55               
     56                page_table_lock(AS_KERNEL, true);
     57               
     58                /*
     59                 * PA2KA(identity) mapping for all low-memory frames.
     60                 */
     61                for (uintptr_t cur = 0;
     62                    cur < min(config.identity_size, config.physmem_end);
     63                    cur += FRAME_SIZE)
     64                        page_mapping_insert(AS_KERNEL, PA2KA(cur), cur,
     65                            PAGE_GLOBAL | PAGE_CACHEABLE | PAGE_EXEC | PAGE_WRITE | PAGE_READ);
     66               
     67                page_table_unlock(AS_KERNEL, true);
     68               
     69                // FIXME: register page fault extension handler
     70               
     71                write_satp((uintptr_t) AS_KERNEL->genarch.page_table);
     72               
     73                /* The boot page table is no longer needed. */
     74                // FIXME: frame_mark_available(pt_frame, 1);
     75        }
    5676}
    5777
     
    6080}
    6181
     82void write_satp(uintptr_t ptl0)
     83{
     84        uint64_t satp = ((ptl0 >> FRAME_WIDTH) & SATP_PFN_MASK) |
     85            SATP_MODE_SV48;
     86       
     87        asm volatile (
     88                "csrw sptbr, %[satp]\n"
     89                :: [satp] "r" (satp)
     90        );
     91}
     92
    6293/** @}
    6394 */
Note: See TracChangeset for help on using the changeset viewer.