Skip to content

Commit 5c81f61

Browse files
committed
Fix MSR to stack pointer, add system reset request register
1 parent 2b23e08 commit 5c81f61

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

core/arm/armcpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,8 +1135,8 @@ void arm_cpu_execute(arm_t *arm) {
11351135
cpu->z = val >> 30 & 1;
11361136
cpu->n = val >> 31 & 1;
11371137
break;
1138-
case 0x80:
1139-
case 0x81:
1138+
case 0x08:
1139+
case 0x09:
11401140
*((opc >> 0 & 1) == cpu->spsel ? &cpu->sp : &cpu->altsp) = val >> 0 & ~3;
11411141
break;
11421142
case 0x10:

core/arm/armmem.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,16 @@ void arm_mem_store_word(arm_t *arm, uint32_t val, uint32_t addr) {
14391439
case 0x008: // VTOR
14401440
scb->vtor = val & SCB_VTOR_TBLOFF_Msk;
14411441
return;
1442+
case 0x00C: // AIRCR
1443+
if ((val & SCB_AIRCR_VECTKEY_Msk) == UINT32_C(0x05FA) << SCB_AIRCR_VECTKEY_Pos) {
1444+
if (val & SCB_AIRCR_SYSRESETREQ_Msk) {
1445+
arm_mem_reset(&arm->mem, PM_RCAUSE_SYST);
1446+
arm_cpu_reset(arm);
1447+
spsc_queue_clear(&arm->usart[0]);
1448+
spsc_queue_clear(&arm->usart[1]);
1449+
}
1450+
}
1451+
return;
14421452
case 0x01C: // SHP[0]
14431453
scb->shp[0] = val & UINT32_C(0xC0000000);
14441454
return;

0 commit comments

Comments
 (0)