Problem jumping to supervisor mode

53 views
Skip to first unread message

Xavier Barreto Tomeo

unread,
Jun 14, 2024, 7:01:50 PM (5 days ago) Jun 14
to RISC-V SW Dev
Hi, im working on my project but I have an issue still unsolved. I'm unable to jump to supervisor mode and I don't know why.

I'm going to paste my code and try to explain it and let's see if someone can help me asap haha! This is the code where qemu jumps and I write 0x888 to enable interrupts and set mpp 01 (supervisor) and also set mepc to start_kernel where is the function i why supervisor mode to jump. All the other things are for enabling interrupts and other stuff that I want to believe doesn't really influence at all.
Here is the code if you need me to explain something more in order to help me feel free.

Thanks to all!

_realentry:
la sp, stack
li a2, 1024*4 #definim tamany de pagina a 4096
add sp, sp, a2 #el punter apunta al bottom del stack


li t0, 0x888
csrw mstatus, t0
li a0, 0x0 # desactivem la paginacio per ara
csrw satp, a0


li a0, 0x3fffffffffffff //aixo vol dir totes les direcions de memoria posibles
csrw pmpaddr0, a0 //escribim pq formin part del grup 0

li a0, 0x0f //li donem els permisos f aka NAPOT RWX
csrw pmpcfg0, a0
la t0, start_kernel
csrw mepc, t0 #li diem on vol que salti al mret

li t0, 0x102
csrw sstatus, t0

#definim la delegacio d'interrupcions i excepcions ara pq despres no es poden tocar els registres m

#li t0, 0x00 #1010 0 MTIE = 0 #JJ DISABLE INTERRUPTS
li t0, 0x80 #1010 0 MTIE = 1
csrw mie, t0

li a0, 0xffff
csrw mideleg, a0

li a0, 0xffff
csrw medeleg, a0
li t0, 0x222
csrw sie,t0

la t1, interrupt_handler
csrw stvec, t1
la t0, timer_handler
csrw mtvec, t0

li t0, 1000000
li t1, 0x2004000 #mtimecmp address
sd t0, 0(t1)


mret
.end

Tommy Murphy

unread,
Jun 14, 2024, 8:14:36 PM (5 days ago) Jun 14
to Xavier Barreto Tomeo, RISC-V SW Dev
Isn't this basically a repeat of this thread? 


I gave you some suggestions there but you never responded.

Xavier Barreto Tomeo

unread,
Jun 14, 2024, 8:17:24 PM (5 days ago) Jun 14
to Tommy Murphy, RISC-V SW Dev
Yes but not at all.
Now this issue comes about how to jump to supervisor mode.

Sorry for not replying too many things on my head rn

El ds, 15 juny 2024 a les 2:14 Tommy Murphy <tommy_...@hotmail.com> va escriure:

Tommy Murphy

unread,
Jun 16, 2024, 4:00:37 PM (4 days ago) Jun 16
to Xavier Barreto Tomeo, RISC-V SW Dev
> Now this issue comes about how to jump to supervisor mode.
Reply all
Reply to author
Forward
0 new messages