mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
ARM11未定義命令例外ハンドラ追加。
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@141 b871894f-2f95-9b40-918c-086798483c85
This commit is contained in:
parent
6b63ce88c8
commit
94ac873d2c
@ -42,12 +42,12 @@ LSYM(0)
|
||||
bx lr
|
||||
|
||||
i_stupExcpVennerCode
|
||||
DCD i_stupExcpTerminateCode
|
||||
DCD i_stupExcpTerminateCode
|
||||
DCD i_stupSwiVeneerCode
|
||||
DCD i_stupExcpTerminateCode
|
||||
DCD i_stupIAbtTerminateCode
|
||||
DCD i_stupExcpTerminateCode
|
||||
DCD i_stupExcpTerminateCode // IRQ
|
||||
DCD i_stupExcpTerminateCode // FIQ
|
||||
DCD i_stupSwiVeneerCode // SWI
|
||||
DCD i_stupExcpTerminateCode // UNDEF
|
||||
DCD i_stupIAbtTerminateCode // IABT
|
||||
DCD i_stupExcpTerminateCode // DABT
|
||||
|
||||
LTORG
|
||||
}
|
||||
@ -55,7 +55,7 @@ i_stupExcpVennerCode
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupExcpTerminateCode
|
||||
|
||||
Description: Prefetch Abort veneer code
|
||||
Description: exception veneer code
|
||||
|
||||
Arguments: None
|
||||
|
||||
@ -70,7 +70,7 @@ ASM void i_stupExcpTerminateCode( void )
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupIAbtTerminateCode
|
||||
|
||||
Description: exception veneer code
|
||||
Description: Prefetch Abort veneer code
|
||||
|
||||
Arguments: None
|
||||
|
||||
@ -97,27 +97,6 @@ ASM void i_stupSwiVeneerCode( void )
|
||||
LTORG
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupDbgHandler
|
||||
|
||||
Description: Debug (FIQ, etc) handler
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
ASM void i_stupDbgHandler( void )
|
||||
{
|
||||
mrs sp, cpsr // IRQ/FIQ•s‹–‰Â
|
||||
orr sp, sp, #HW_PSR_IRQ_DISABLE | HW_PSR_FIQ_DISABLE
|
||||
msr cpsr_cxsf, sp
|
||||
|
||||
dbg_m
|
||||
b dbg_m
|
||||
|
||||
LTORG
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupIrqVeneer
|
||||
|
||||
@ -150,6 +129,38 @@ ASM void i_stupFiqVeneer( void )
|
||||
LTORG
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupSwiVeneer
|
||||
|
||||
Description: SWI veneer
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
ASM void i_stupSwiVeneer( void )
|
||||
{
|
||||
ldr pc, =HW_SWI_VENEER_BUF
|
||||
|
||||
LTORG
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupUndefInstVeneer
|
||||
|
||||
Description: Undefine Instruction veneer
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
ASM void i_stupUndefInstVeneer( void )
|
||||
{
|
||||
ldr pc, =HW_UDEF_VENEER_BUF
|
||||
|
||||
LTORG
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupPrefetchAbortVeneer
|
||||
|
||||
@ -182,39 +193,6 @@ ASM void i_stupDataAbortVeneer( void )
|
||||
LTORG
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupUndefInstVeneer
|
||||
|
||||
Description: Undefine Instruction veneer
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
ASM void i_stupUndefInstVeneer( void )
|
||||
{
|
||||
ldr pc, =HW_UDEF_VENEER_BUF
|
||||
|
||||
LTORG
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupSwiVeneer
|
||||
|
||||
Description: SWI veneer
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None.
|
||||
*---------------------------------------------------------------------------*/
|
||||
ASM void i_stupSwiVeneer( void )
|
||||
{
|
||||
ldr pc, =HW_SWI_VENEER_BUF
|
||||
|
||||
LTORG
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_stupSwiHandler
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ SRCS = \
|
||||
os_alarm.c \
|
||||
os_irqHandler.c \
|
||||
os_interrupt.c \
|
||||
os_exception.c \
|
||||
os_thread.c \
|
||||
os_context.c \
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@ SRCS = \
|
||||
os_alarm.c \
|
||||
os_irqHandler.c \
|
||||
os_interrupt.c \
|
||||
os_exception.c \
|
||||
os_thread.c \
|
||||
os_context.c \
|
||||
|
||||
|
||||
155
trunk/bootrom/build/libraries/os/common/os_exception.c
Normal file
155
trunk/bootrom/build/libraries/os/common/os_exception.c
Normal file
@ -0,0 +1,155 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: CtrBrom - library - os
|
||||
File: os_exception.c
|
||||
|
||||
Copyright 2008 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#include <brom/os.h>
|
||||
#include <brom/swi.h>
|
||||
|
||||
|
||||
void i_osUndefInstHandler( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInitException
|
||||
|
||||
Description: Initialize Exceptions for Application
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInitException( void )
|
||||
{
|
||||
#ifdef SDK_ARM11
|
||||
*(OSExcpHandler*)HW_UDEF_VECTOR_BUF = i_osUndefInstHandler;
|
||||
#endif // SDK_ARM11
|
||||
}
|
||||
|
||||
#ifdef SDK_ARM11
|
||||
|
||||
#include <brom/code32.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_osUndefInstHandler
|
||||
|
||||
Description: Undefine Instruction handler
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
ASM void i_osUndefInstHandler( void )
|
||||
{
|
||||
// change into previous mode
|
||||
mrs sp, spsr
|
||||
orr sp, sp, #HW_PSR_IRQ_DISABLE | HW_PSR_FIQ_DISABLE
|
||||
msr cpsr_fsxc, sp
|
||||
|
||||
stmfd sp!, {r0, r12, lr, pc} // push to previous mode stack (8byte alignment)
|
||||
|
||||
// get LR and SPSR into UNDEF mode
|
||||
msr cpsr_fsxc, #HW_PSR_UNDEF_MODE | HW_PSR_IRQ_DISABLE | HW_PSR_FIQ_DISABLE
|
||||
mov r12, lr
|
||||
mrs r0, spsr
|
||||
|
||||
// change into previous mode
|
||||
orr sp, r0, #HW_PSR_IRQ_DISABLE | HW_PSR_FIQ_DISABLE
|
||||
msr cpsr_fsxc, sp
|
||||
|
||||
tst r0, #HW_PSR_THUMB_STATE
|
||||
subne r12, r12, #2 // Thumb code return address
|
||||
subeq r12, r12, #4 // ARM code return address
|
||||
str r12, [sp, #4*3] // store LR_svc to return PC
|
||||
|
||||
stmfd sp!, {r0-r3} // push spsr (8byte alignment)
|
||||
|
||||
adr lr, i_return
|
||||
|
||||
tst r0, #HW_PSR_THUMB_STATE
|
||||
bne i_stupUndefInstHandlerDummy
|
||||
|
||||
tst r0, #HW_PSR_JAVA_STATE
|
||||
bne i_stupUndefInstHandlerDummy
|
||||
|
||||
ldr r0, [r12, #0] // called from ARM
|
||||
mov r12, r0, lsl #4
|
||||
sub r12, r12, #0xC0000000
|
||||
cmp r12, #0x30000000
|
||||
bhs i_stupUndefInstHandlerDummy
|
||||
|
||||
adr r12, i_return
|
||||
and r0, r0, #0x00000F00
|
||||
ldr pc, [r12, r0, lsr #8-2]
|
||||
|
||||
i_return
|
||||
ldmfd sp!, {r0-r3} // pop spsr
|
||||
msr cpsr_fsxc, r0
|
||||
ldmfd sp!, {r0, r12, lr, pc} // pop from USR stack
|
||||
|
||||
INASM_EXTERN( _VFP_Computation_Engine )
|
||||
|
||||
i_stupUndefCPHandlerTable
|
||||
DCD i_stupUndefInstHandlerDummy // CP 0
|
||||
DCD i_stupUndefInstHandlerDummy // CP 1
|
||||
DCD i_stupUndefInstHandlerDummy // CP 2
|
||||
DCD i_stupUndefInstHandlerDummy // CP 3
|
||||
DCD i_stupUndefInstHandlerDummy // CP 4
|
||||
DCD i_stupUndefInstHandlerDummy // CP 5
|
||||
DCD i_stupUndefInstHandlerDummy // CP 6
|
||||
DCD i_stupUndefInstHandlerDummy // CP 7
|
||||
DCD i_stupUndefInstHandlerDummy // CP 8
|
||||
DCD i_stupUndefInstHandlerDummy // CP 9
|
||||
DCD i_vfpUndefInstHandler // CP 10
|
||||
DCD i_vfpUndefInstHandler // CP 11
|
||||
DCD i_stupUndefInstHandlerDummy // CP 12
|
||||
DCD i_stupUndefInstHandlerDummy // CP 13
|
||||
DCD i_stupUndefInstHandlerDummy // CP 14
|
||||
DCD i_stupUndefInstHandlerDummy // CP 15
|
||||
}
|
||||
|
||||
ASM void i_vfpUndefInstHandler( void )
|
||||
{
|
||||
// VFP enable
|
||||
fmrx r12, fpexc
|
||||
tst r12, #HW_FPEXC_VFP_ENABLE
|
||||
LSYM(1)
|
||||
bne BSYM(1) // Error
|
||||
|
||||
mov r0, #(HW_FPEXC_EXCEPTION_STATE | HW_FPEXC_FPINST2_VALID)
|
||||
bic r12, r12, r0
|
||||
orr r12, r12, #HW_FPEXC_VFP_ENABLE
|
||||
fmxr fpexc, r12
|
||||
ldr r12, =(HW_FPSCR_ROUND_NEAR_MODE << HW_FPSCR_ROUND_MODE_SFT \
|
||||
| HW_FPSCR_VEC_LENGTH_1 << HW_FPSCR_VEC_LENGTH_SFT \
|
||||
| HW_FPSCR_VEC_STRIDE_1 << HW_FPSCR_VEC_STRIDE_SFT \
|
||||
| HW_FPSCR_DZE_ENABLE \
|
||||
| HW_FPSCR_DEFAULT_NAN_MODE \
|
||||
| HW_FPSCR_FLASH_TO_ZERO_MODE \
|
||||
)
|
||||
fmxr fpscr, r12
|
||||
|
||||
bx lr
|
||||
}
|
||||
|
||||
ASM void i_stupUndefInstHandlerDummy( void )
|
||||
{
|
||||
LSYM(1)
|
||||
b BSYM(1)
|
||||
bx lr
|
||||
}
|
||||
|
||||
#include <brom/codereset.h>
|
||||
|
||||
#endif // SDK_ARM11
|
||||
|
||||
@ -40,11 +40,14 @@ void osInitBROM(void)
|
||||
#ifdef SDK_ARM9
|
||||
|
||||
#ifdef BROM_DEBUG_ITCM
|
||||
MI_CpuFillFast( (void*)HW_ITCM, 0, HW_ITCM_SIZE );
|
||||
MI_CpuFillFast( (void*)HW_ITCM, 0, HW_ITCM_SIZE );
|
||||
#endif // BROM_DEBUG_ITCM
|
||||
|
||||
#endif // SDK_ARM9
|
||||
|
||||
//---- Init Timer
|
||||
osInitTimer();
|
||||
|
||||
//---- Init Interrupt
|
||||
osInitInterrupt();
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ OSIntrFunction osIntrTable[OS_INTR_ID_NUM] ATTRIBUTE_SECTION(.dtcm);
|
||||
#endif // SDK_ARM9
|
||||
|
||||
|
||||
asm void i_osIrqVeneer( void );
|
||||
void osIrqHandler( void );
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInitInterrupt
|
||||
@ -47,8 +47,7 @@ void osInitInterrupt( void )
|
||||
|
||||
i_osInitInterruptTable();
|
||||
|
||||
((u32*)HW_INTR_VENEER_BUF)[0] = ((u32*)i_osIrqVeneer)[0];
|
||||
((u32*)HW_INTR_VENEER_BUF)[1] = ((u32*)i_osIrqVeneer)[1];
|
||||
*(OSIntrHandler*)HW_INTR_VECTOR_BUF = osIrqHandler;
|
||||
|
||||
#ifdef SDK_ARM11
|
||||
reg_OS_CPUI_CNT = 0;
|
||||
@ -101,25 +100,6 @@ void osInitInterrupt( void )
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_osIrqVeneer
|
||||
|
||||
Description: Interrupt Vevver
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
#include <brom/code32.h>
|
||||
asm void i_osIrqVeneer( void )
|
||||
{
|
||||
INASM_EXTERN( osIrqHandler )
|
||||
|
||||
ldr pc, =osIrqHandler
|
||||
LTORG
|
||||
}
|
||||
#include <brom/codereset.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: i_osInitInterruptTable
|
||||
|
||||
|
||||
@ -37,10 +37,10 @@ extern "C" {
|
||||
#include <brom/os/common/thread.h>
|
||||
#include <brom/os/common/timer.h>
|
||||
#include <brom/os/common/interrupt.h>
|
||||
#include <brom/os/common/exception.h>
|
||||
#include <brom/os/common/cache.h>
|
||||
#if 0
|
||||
#include <brom/os/common/systemWork.h>
|
||||
#include <brom/os/common/exception.h>
|
||||
#include <brom/os/common/printf.h>
|
||||
#include <brom/os/common/spinLock.h>
|
||||
#include <brom/os/common/systemCall.h>
|
||||
|
||||
49
trunk/bootrom/include/brom/os/common/exception.h
Normal file
49
trunk/bootrom/include/brom/os/common/exception.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: CtrBrom - OS - include
|
||||
File: exception.h
|
||||
|
||||
Copyright 2008 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
|
||||
$Date:: $
|
||||
$Rev$
|
||||
$Author$
|
||||
*---------------------------------------------------------------------------*/
|
||||
#ifndef BROM_OS_EXCEPTION_H_
|
||||
#define BROM_OS_EXCEPTION_H_
|
||||
|
||||
#include <brom/types.h>
|
||||
#include <brom/memorymap.h>
|
||||
#include <ctr/ioreg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//---- exception handler type
|
||||
typedef void (*OSExcpHandler) (void);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: osInitException
|
||||
|
||||
Description: Initialize Exceptions for Application
|
||||
|
||||
Arguments: None
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
void osInitException( void );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
/* BROM_OS_EXCEPTION_H_ */
|
||||
#endif
|
||||
@ -53,7 +53,6 @@ OSFiqMode;
|
||||
|
||||
//---- interrupt handler type
|
||||
//typedef IRQ void (*OSIntrHandler) (void);
|
||||
typedef void (*OSExcpHandler) (void);
|
||||
typedef void (*OSIntrHandler) (void);
|
||||
typedef void (*OSIntrFunction) (void);
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
#ifndef SDK_ASM
|
||||
#include <ctr/hw/common/arm_reg_common.h>
|
||||
#include <ctr/hw/ARM11/vfp.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -45,11 +45,17 @@ extern "C" {
|
||||
#define HW_EXCP_VENEER_BUF_END (HW_EXCP_VENEER_BUF + HW_EXCP_VENEER_BUF_SIZE)
|
||||
#define HW_EXCP_VENEER_BUF_SIZE (8 * 6)
|
||||
#define HW_INTR_VENEER_BUF (HW_AXI_WRAM_SYSRV + HW_AXI_WRAM_SYSRV_OFS_INTR_VENEER)
|
||||
#define HW_INTR_VECTOR_BUF (HW_INTR_VENEER_BUF + 4)
|
||||
#define HW_FIQ_VENEER_BUF (HW_AXI_WRAM_SYSRV + HW_AXI_WRAM_SYSRV_OFS_FIQ_VENEER)
|
||||
#define HW_FIQ_VECTOR_BUF (HW_FIQ_VENEER_BUF + 4)
|
||||
#define HW_SWI_VENEER_BUF (HW_AXI_WRAM_SYSRV + HW_AXI_WRAM_SYSRV_OFS_SWI_VENEER)
|
||||
#define HW_SWI_VECTOR_BUF (HW_SWI_VENEER_BUF + 4)
|
||||
#define HW_UDEF_VENEER_BUF (HW_AXI_WRAM_SYSRV + HW_AXI_WRAM_SYSRV_OFS_UDEF_VENEER)
|
||||
#define HW_UDEF_VECTOR_BUF (HW_UDEF_VENEER_BUF + 4)
|
||||
#define HW_IABT_VENEER_BUF (HW_AXI_WRAM_SYSRV + HW_AXI_WRAM_SYSRV_OFS_IABT_VENEER)
|
||||
#define HW_IABT_VECTOR_BUF (HW_IABT_VENEER_BUF + 4)
|
||||
#define HW_DABT_VENEER_BUF (HW_AXI_WRAM_SYSRV + HW_AXI_WRAM_SYSRV_OFS_DABT_VENEER)
|
||||
#define HW_DABT_VECTOR_BUF (HW_DABT_VENEER_BUF + 4)
|
||||
#define HW_START_VECTOR1_BUF (HW_AXI_WRAM_SYSRV + HW_AXI_WRAM_SYSRV_OFS_START_VECTOR1)
|
||||
#define HW_INTR_CHECK0_BUF (HW_AXI_WRAM_SYSRV + HW_AXI_WRAM_SYSRV_OFS_INTR_CHECK0)
|
||||
#define HW_INTR_CHECK1_BUF (HW_AXI_WRAM_SYSRV + HW_AXI_WRAM_SYSRV_OFS_INTR_CHECK1)
|
||||
|
||||
@ -42,11 +42,17 @@ extern "C" {
|
||||
#define HW_EXCP_VENEER_BUF_END (HW_EXCP_VENEER_BUF + HW_EXCP_VENEER_BUF_SIZE)
|
||||
#define HW_EXCP_VENEER_BUF_SIZE (8 * 6)
|
||||
#define HW_INTR_VENEER_BUF (HW_PRV_WRAM_SYSRV + HW_PRV_WRAM_SYSRV_OFS_INTR_VENEER)
|
||||
#define HW_INTR_VECTOR_BUF (HW_INTR_VENEER_BUF + 4)
|
||||
#define HW_FIQ_VENEER_BUF (HW_PRV_WRAM_SYSRV + HW_PRV_WRAM_SYSRV_OFS_FIQ_VENEER)
|
||||
#define HW_FIQ_VECTOR_BUF (HW_FIQ_VENEER_BUF + 4)
|
||||
#define HW_SWI_VENEER_BUF (HW_PRV_WRAM_SYSRV + HW_PRV_WRAM_SYSRV_OFS_SWI_VENEER)
|
||||
#define HW_SWI_VECTOR_BUF (HW_SWI_VENEER_BUF + 4)
|
||||
#define HW_UDEF_VENEER_BUF (HW_PRV_WRAM_SYSRV + HW_PRV_WRAM_SYSRV_OFS_UDEF_VENEER)
|
||||
#define HW_UDEF_VECTOR_BUF (HW_UDEF_VENEER_BUF + 4)
|
||||
#define HW_IABT_VENEER_BUF (HW_PRV_WRAM_SYSRV + HW_PRV_WRAM_SYSRV_OFS_IABT_VENEER)
|
||||
#define HW_IABT_VECTOR_BUF (HW_IABT_VENEER_BUF + 4)
|
||||
#define HW_DABT_VENEER_BUF (HW_PRV_WRAM_SYSRV + HW_PRV_WRAM_SYSRV_OFS_DABT_VENEER)
|
||||
#define HW_DABT_VECTOR_BUF (HW_DABT_VENEER_BUF + 4)
|
||||
#define HW_INTR_CHECK_BUF (HW_PRV_WRAM_SYSRV + HW_PRV_WRAM_SYSRV_OFS_INTR_CHECK)
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user