diff --git a/trunk/bootrom/build/libraries/os/ARM11/Makefile b/trunk/bootrom/build/libraries/os/ARM11/Makefile index cc287cc..4d8caf7 100644 --- a/trunk/bootrom/build/libraries/os/ARM11/Makefile +++ b/trunk/bootrom/build/libraries/os/ARM11/Makefile @@ -28,11 +28,14 @@ BROM_CODEGEN_ALL ?= TRUE SRCDIR = . ../common SRCS = \ - os_irqHandler.c \ + os_system.c \ os_timer.c \ + os_irqHandler.c \ os_interrupt.c \ os_interrupt_common.c \ +# os_init.c \ + TARGET_LIB = libos$(BROM_LIBSUFFIX).a include $(CTRBROM_ROOT)/build/buildtools/commondefs diff --git a/trunk/bootrom/build/libraries/os/ARM9/Makefile b/trunk/bootrom/build/libraries/os/ARM9/Makefile index 529569e..8c699f7 100644 --- a/trunk/bootrom/build/libraries/os/ARM9/Makefile +++ b/trunk/bootrom/build/libraries/os/ARM9/Makefile @@ -31,12 +31,15 @@ BROM_PROC = ARM9 SRCDIR = . ../common SRCS = \ - os_irqHandler.c \ + os_system.c \ os_timer.c \ os_tick.c \ + os_irqHandler.c \ os_interrupt.c \ os_interrupt_common.c \ +# os_init.c \ + TARGET_LIB = libos_sp$(BROM_LIBSUFFIX).a diff --git a/trunk/bootrom/build/libraries/os/common/os_init.c b/trunk/bootrom/build/libraries/os/common/os_init.c new file mode 100644 index 0000000..2ba86c0 --- /dev/null +++ b/trunk/bootrom/build/libraries/os/common/os_init.c @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------* + Project: CtrBrom - libraries - OS + File: os_init.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 + +//#define BROM_DEBUG_ITCM +#define FIRM_ENABLE_JTAG_AT_INIT + + +/*---------------------------------------------------------------------------* + Name: osInitBROM + + Description: initialize sdk os for bootrom + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void osInitBROM(void) +{ +#ifdef SDK_ARM9 + +#ifdef BROM_DEBUG_ITCM + MI_CpuFillFast( (void*)HW_ITCM, 0, HW_ITCM_SIZE ); +#endif // BROM_DEBUG_ITCM + +#else // SDK_ARM7 + + //---- Init Exception System + // the exception vecter of ARM9 is in the noninitialized main memory. + osInitException(); + +#endif // SDK_ARM7 + + //---- Init Interrupt + osInitInterrupt(); + +} + +/*---------------------------------------------------------------------------* + Name: osInit + + Description: initialize sdk os + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void osInit(void) +{ +#ifdef SDK_ARM7 + + // Enable JTAG +#ifdef FIRM_ENABLE_JTAG_AT_INIT + OSi_EnableCpuJTAG(); +#endif // FIRM_ENABLE_JTAG_AT_INIT + +#endif // SDK_ARM7 + + //---- Init Exception System + osInitException(); + + //---- Init Interrupt + osInitInterrupt(); +} + +#ifdef SDK_ARM9 + +/*---------------------------------------------------------------------------* + Name: OSi_EnableCpuJTAG + + Description: enable jtag of cpu + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void OSi_EnableCpuJTAG(void) +{ + reg_CFG_CPU_JTAG = REG_CFG_CPU_JTAG_E_MASK | REG_CFG_CPU_JTAG_A7_MASK; +} + +/*---------------------------------------------------------------------------* + Name: OSi_EnableDspJTAG + + Description: enable jtag of dsp + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void OSi_EnableDspJTAG(void) +{ + reg_CFG_DSP_JTAG = REG_CFG_DSP_JTAG_E_MASK; +} + +#endif // SDK_ARM9 + diff --git a/trunk/bootrom/build/libraries/os/common/os_system.c b/trunk/bootrom/build/libraries/os/common/os_system.c new file mode 100644 index 0000000..4b6d892 --- /dev/null +++ b/trunk/bootrom/build/libraries/os/common/os_system.c @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------* + Project: CtrBrom - libraries - OS + File: os_system.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 + +#define osTPrintf(...) ((void)0) + + +//============================================================================ +// PROCESSER MODE +//============================================================================ +/*---------------------------------------------------------------------------* + Name: i_osGetProcMode + + Description: Get processor mode from CPSR + + Arguments: None. + + Returns: CPU processor mode (field 0x10-0x1f) + *---------------------------------------------------------------------------*/ +#include +ASM OSProcMode i_osGetProcMode( void ) +{ + mrs r0, cpsr + and r0, r0, #HW_PSR_CPU_MODE_MASK + + bx lr +} +#include + +//============================================================================ +// WAIT +//============================================================================ +/*---------------------------------------------------------------------------* + Name: i_osWaitCpuCycles + + Description: Loop and Wait for specified CPU cycles at least + + Arguments: cycles waiting CPU cycle + + Returns: None + *---------------------------------------------------------------------------*/ +#include +ASM void i_osWaitCpuCycles( OSCpuCycle cycle ) +{ + sub r0, r0, #(6-2) // subtract call-return overhead and add the margin of 2 cycles +LSYM(1) + subs r0, r0, #4 // 1 cycle + bcs BSYM(1) // 3 cycle + bx lr +} +#include + +//============================================================================ +// TERMINATE and HALT +//============================================================================ +/*---------------------------------------------------------------------------* + Name: i_osTerminate + + Description: Halt CPU and loop + + Arguments: None + + Returns: -- (Never return) + *---------------------------------------------------------------------------*/ +void i_osTerminate(void) +{ + while (1) + { + (void)osDisableInterrupts(); + i_osHalt(); + } +} + +/*---------------------------------------------------------------------------* + Name: i_osHalt + + Description: Halt CPU + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +#include +ASM void i_osHalt( void ) +{ + mov r0, #0 + mcr p15, 0, r0, c7, c0, 4 + bx lr +} +#include + +/*---------------------------------------------------------------------------* + Name: i_osExit + + Description: Display exit string and Terminate. + This is useful for 'loadrun' tool command. + + Arguments: status : exit status + + Returns: -- (Never return) + *---------------------------------------------------------------------------*/ +void i_osExit(int status) +{ +#ifdef SDK_FINALROM +#pragma unused( status ) +#endif + (void)osDisableInterrupts(); + osTPrintf("\n" OS_EXIT_STRING, status); + i_osTerminate(); +}