Skip to content

Commit c76d61d

Browse files
committed
tuxedo: readd default system call exception handler
1 parent ac69b2e commit c76d61d

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

gc/tuxedo/ppc/exception.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extern PPCExcptHandlerFn __ppc_excpt_table[];
2929
extern PPCExcptPanicFn PPCExcptCurPanicFn;
3030

3131
void PPCExcptDefaultHandler(void);
32+
void PPCExcptDefaultScHandler(void);
3233

3334
MK_INLINE void PPCExcptSetHandler(unsigned exid, PPCExcptHandlerFn handler)
3435
{

tuxedo/exception.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ void PPCExcptInit(void)
1414
u32* target = (u32*)(0x80000000 + i*0x100);
1515
__builtin_memcpy(target, impl, impl[-1]);
1616

17+
PPCExcptHandlerFn fn = PPCExcptDefaultHandler;
18+
if (i == PPC_EXCPT_SYSCALL) {
19+
fn = PPCExcptDefaultScHandler;
20+
}
21+
1722
if (i != PPC_EXCPT_FPU) {
1823
target[11] |= i;
19-
PPCExcptSetHandler(i, PPCExcptDefaultHandler);
24+
PPCExcptSetHandler(i, fn);
2025
}
2126
}
2227

tuxedo/exception_asm.S

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,31 @@ FUNC_START PPCExcptFpuHandler, text, local
164164

165165
FUNC_END
166166

167+
FUNC_START PPCExcptDefaultScHandler
168+
169+
// Restore saved PC/MSR
170+
lis r11, __ppc_excpt_buf@ha
171+
lwz r12, __ppc_excpt_buf@l+PPC_CONTEXT_PC(r11)
172+
mtsrr0 r12
173+
lwz r12, __ppc_excpt_buf@l+PPC_CONTEXT_MSR(r11)
174+
mtsrr1 r12
175+
176+
// Perform PPCSync()
177+
mfspr r11, HID0
178+
ori r12, r11, HID0_ABE
179+
mtspr HID0, r12
180+
isync
181+
sync
182+
mtspr HID0, r11
183+
isync
184+
185+
// Restore saved GPR11/GPR12 and return
186+
mfsprg0 r11
187+
mfsprg1 r12
188+
rfi
189+
190+
FUNC_END
191+
167192
FUNC_START PPCExcptDefaultHandler
168193

169194
// Set up exception stack if needed

0 commit comments

Comments
 (0)