Changeset ae8d7b0 in mainline for boot/arch/riscv64/src/asm.S


Ignore:
Timestamp:
2017-08-21T18:23:39Z (7 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c58441d
Parents:
fdc29300
Message:

riscv64: update to the latest Privileged Architecture specification (1.10)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/riscv64/src/asm.S

    rfdc29300 rae8d7b0  
    2929#include <abi/asmtool.h>
    3030#include <arch/arch.h>
     31#include <arch/mm.h>
     32
     33#define MSTATUS_MPP_MASK        0x00001800
     34#define MSTATUS_MPP_USER        0x00000000
     35#define MSTATUS_MPP_SUPERVISOR  0x00000800
     36#define MSTATUS_MPP_MACHINE     0x00001800
     37
     38#define MSTATUS_SUM_MASK        0x00040000
     39
     40#define SATP_PFN_MASK  0x00000fffffffffff
     41
     42#define SATP_MODE_MASK  0xf000000000000000
     43#define SATP_MODE_BARE  0x0000000000000000
     44#define SATP_MODE_SV39  0x8000000000000000
     45#define SATP_MODE_SV48  0x9000000000000000
    3146
    3247.section BOOTSTRAP
     
    7691
    7792FUNCTION_BEGIN(jump_to_kernel)
    78         j halt
     93        /* Setup SV48 paging for supervisor mode */
     94        la t0, ptl_0
     95        srli t0, t0, 12
     96       
     97        li t1, SATP_PFN_MASK
     98        and t0, t0, t1
     99       
     100        li t1, SATP_MODE_SV48
     101        or t0, t0, t1
     102       
     103        csrw sptbr, t0
     104       
     105        /* Jump to supervisor mode */
     106        csrr t0, mstatus
     107       
     108        li t1, ~MSTATUS_MPP_MASK
     109        and t0, t0, t1
     110       
     111       
     112        /*
     113         * TODO: Enable running with Supervisor User Mode
     114         * access disabled.
     115         */
     116        li t1, MSTATUS_MPP_SUPERVISOR | MSTATUS_SUM_MASK
     117        or t0, t0, t1
     118       
     119        csrw mstatus, t0
     120       
     121        li ra, PA2KA(BOOT_OFFSET)
     122        csrw mepc, ra
     123       
     124        mret
    79125FUNCTION_END(jump_to_kernel)
    80126
     
    88134SYMBOL(boot_stack)
    89135        .space BOOT_STACK_SIZE
     136
     137.section .pt, "aw", @progbits
     138
     139.align PAGE_WIDTH
     140SYMBOL(ptl_0)
     141        .fill 256, 8, 0
     142        /* Identity mapping for [0; 512G) */
     143        .quad 0 + (PTL_DIRTY | PTL_ACCESSED | PTL_EXECUTABLE | PTL_WRITABLE | PTL_READABLE | PTL_VALID)
     144        .fill 255, 8, 0
Note: See TracChangeset for help on using the changeset viewer.