os-workshop

same materials and sample source for RV32 OS projects
git clone http://frotz.net/git/os-workshop.git
Log | Files | Refs

helpers.S (474B)


      1 // Copyright 2022, Brian Swetland <swetland@frotz.net>
      2 // Licensed under the Apache License, Version 2.0
      3 
      4 
      5 // trap-safe memory accesses
      6 
      7 .globl rd32safe // (addr)
      8 rd32safe:
      9 	la t0, rd32fail
     10 	mv t1, a0
     11 	li a0, 0
     12 	csrw mtvec, t0
     13 	lw a0, 0(t1)
     14 rd32fail:
     15 	ret
     16 
     17 .globl rd8safe // (addr)
     18 rd8safe:
     19 	la t0, rd8fail
     20 	mv t1, a0
     21 	li a0, 0
     22 	csrw mtvec, t0
     23 	lbu a0, 0(t1)
     24 rd8fail:
     25 	ret
     26 
     27 
     28 .globl console_call_cmd // (fn, a1, a2, a3, a4, a0)
     29 console_call_cmd:
     30 	mv t0, a0
     31 	mv a0, a5
     32 	jr t0