Skip to contentSkip to conversation

openrisc: terminate qemu process upon receiving a halt signal.

PATCH In review Hesham ALMatary 2 participants 2 messages Apr 2, 2015 – Apr 3, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 openrisc: terminate qemu process upon receiving a halt signal.

or1ksim simulator currently handles "l.nop 0xC" instruction as a halt signal. Do the same for QEMU.

---
 target-openrisc/translate.c | 5 +++++
 1 file changed, 5 insertions(+)
target-openrisc/translate.c +5 -0
index dc76789..5fa8ede 100644
@@ -750,6 +750,11 @@ static void dec_misc(DisasContext *dc, uint32_t insn)
         switch (op1) {
         case 0x01:    /* l.nop */
             LOG_DIS("l.nop %d\n", I16);
+
+            if(I16 == 0xC) {
+                exit(0);
+            }
+
             break;
 
         default:
Signature · 1 line
2.1.0
#1 lore raw
Quoted 13 lines · Hesham ALMatary

or1ksim simulator currently handles "l.nop 0xC" instruction as a halt signal. Do the same for QEMU.

---
 target-openrisc/translate.c | 5 +++++
 1 file changed, 5 insertions(+)
target-openrisc/translate.c +0 -0
index dc76789..5fa8ede 100644

target-openrisc/translate.c static void dec_misc(DisasContext *dc, uint32_t insn) · line 757

Quoted 8 lines
target-openrisc/translate.c +5 -0
@@ -750,6 +750,11 @@ static void dec_misc(DisasContext *dc, uint32_t insn)
         switch (op1) {
         case 0x01:    /* l.nop */
             LOG_DIS("l.nop %d\n", I16);
+
+            if(I16 == 0xC) {
+                exit(0);
+            }
+

Ug. IMO l.nop was a poor choice; l.trap would have been better. But whatever...

Further:

(1) This is translation time, not execution time. You can't do the exit here, only when the instruction is executed.

(2) This, and the other 10 things hidden under l_nop are similar to the "-semihosting" switch available for arm, lm32, m68k, and xtensa.

Although semihosting is typically even more complex, generally implementing the exit/read/write/open/close/lseek/stat families of syscalls.

r~