mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
add os_system.c.
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@94 b871894f-2f95-9b40-918c-086798483c85
This commit is contained in:
parent
be841b8c48
commit
601d1952d8
@ -28,11 +28,14 @@ BROM_CODEGEN_ALL ?= TRUE
|
|||||||
SRCDIR = . ../common
|
SRCDIR = . ../common
|
||||||
|
|
||||||
SRCS = \
|
SRCS = \
|
||||||
os_irqHandler.c \
|
os_system.c \
|
||||||
os_timer.c \
|
os_timer.c \
|
||||||
|
os_irqHandler.c \
|
||||||
os_interrupt.c \
|
os_interrupt.c \
|
||||||
os_interrupt_common.c \
|
os_interrupt_common.c \
|
||||||
|
|
||||||
|
# os_init.c \
|
||||||
|
|
||||||
TARGET_LIB = libos$(BROM_LIBSUFFIX).a
|
TARGET_LIB = libos$(BROM_LIBSUFFIX).a
|
||||||
|
|
||||||
include $(CTRBROM_ROOT)/build/buildtools/commondefs
|
include $(CTRBROM_ROOT)/build/buildtools/commondefs
|
||||||
|
|||||||
@ -31,12 +31,15 @@ BROM_PROC = ARM9
|
|||||||
SRCDIR = . ../common
|
SRCDIR = . ../common
|
||||||
|
|
||||||
SRCS = \
|
SRCS = \
|
||||||
os_irqHandler.c \
|
os_system.c \
|
||||||
os_timer.c \
|
os_timer.c \
|
||||||
os_tick.c \
|
os_tick.c \
|
||||||
|
os_irqHandler.c \
|
||||||
os_interrupt.c \
|
os_interrupt.c \
|
||||||
os_interrupt_common.c \
|
os_interrupt_common.c \
|
||||||
|
|
||||||
|
# os_init.c \
|
||||||
|
|
||||||
TARGET_LIB = libos_sp$(BROM_LIBSUFFIX).a
|
TARGET_LIB = libos_sp$(BROM_LIBSUFFIX).a
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
111
trunk/bootrom/build/libraries/os/common/os_init.c
Normal file
111
trunk/bootrom/build/libraries/os/common/os_init.c
Normal file
@ -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 <brom/os.h>
|
||||||
|
|
||||||
|
//#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
|
||||||
|
|
||||||
124
trunk/bootrom/build/libraries/os/common/os_system.c
Normal file
124
trunk/bootrom/build/libraries/os/common/os_system.c
Normal file
@ -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 <brom/os.h>
|
||||||
|
|
||||||
|
#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 <brom/code32.h>
|
||||||
|
ASM OSProcMode i_osGetProcMode( void )
|
||||||
|
{
|
||||||
|
mrs r0, cpsr
|
||||||
|
and r0, r0, #HW_PSR_CPU_MODE_MASK
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
}
|
||||||
|
#include <brom/codereset.h>
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// WAIT
|
||||||
|
//============================================================================
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: i_osWaitCpuCycles
|
||||||
|
|
||||||
|
Description: Loop and Wait for specified CPU cycles at least
|
||||||
|
|
||||||
|
Arguments: cycles waiting CPU cycle
|
||||||
|
|
||||||
|
Returns: None
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
#include <brom/code32.h>
|
||||||
|
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 <brom/codereset.h>
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// 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 <brom/code32.h>
|
||||||
|
ASM void i_osHalt( void )
|
||||||
|
{
|
||||||
|
mov r0, #0
|
||||||
|
mcr p15, 0, r0, c7, c0, 4
|
||||||
|
bx lr
|
||||||
|
}
|
||||||
|
#include <brom/codereset.h>
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
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();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user