ctr_firmware/trunk/bootrom/build/libraries/os/common/os_system.c
nakasima 5c54d429f3 SMPビルドスイッチ追加。
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@218 b871894f-2f95-9b40-918c-086798483c85
2009-01-27 09:06:36 +00:00

177 lines
5.0 KiB
C

/*---------------------------------------------------------------------------*
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)
#ifdef SDK_ARM11
#ifdef BROM_ENABLE_SMP_CODE
//============================================================================
// MULTI CORE
//============================================================================
/*---------------------------------------------------------------------------*
Name: osGetCpuID
Description: Get CPU-ID
Arguments: None.
Returns: CPU-ID (field 0-3)
*---------------------------------------------------------------------------*/
#include <brom/code32.h>
asm u8 osGetCpuID( void )
{
mrc p15,0, r0, c0, c0, 5
and r0, r0, #HW_C0_AP_CPU_ID_MASK
bx lr
}
#include <brom/codereset.h>
#endif // BROM_ENABLE_SMP_CODE
#endif // SDK_ARM11
//============================================================================
// PROCESSER MODE
//============================================================================
/*---------------------------------------------------------------------------*
Name: osGetProcMode
Description: Get processor mode from CPSR
Arguments: None.
Returns: CPU processor mode (field 0x10-0x1f)
*---------------------------------------------------------------------------*/
#include <brom/code32.h>
asm OSProcMode 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: osTerminate
Description: Halt CPU and loop
Arguments: None
Returns: -- (Never return)
*---------------------------------------------------------------------------*/
void osTerminate(void)
{
while (1)
{
(void)osDisableInterrupts();
osHalt();
}
}
#include <brom/code32.h>
/*---------------------------------------------------------------------------*
Name: osHalt
Description: Halt CPU
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
asm void osHalt( void )
{
#ifdef SDK_ARM11
wfi
#else // SDK_ARM9
mov r0, #0
mcr p15, 0, r0, c7, c0, 4
#endif // SDK_ARM9
bx lr
}
#ifdef SDK_ARM11
/*---------------------------------------------------------------------------*
Name: osHaltUntilEvent
Description: Halt CPU Core until Event
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
asm void osHaltUntilEvent( void )
{
wfe
bx lr
}
#endif // SDK_ARM11
#include <brom/codereset.h>
/*---------------------------------------------------------------------------*
Name: osExit
Description: Display exit string and Terminate.
This is useful for 'loadrun' tool command.
Arguments: status : exit status
Returns: -- (Never return)
*---------------------------------------------------------------------------*/
void osExit(int status)
{
#ifdef SDK_FINALROM
#pragma unused( status )
#endif
(void)osDisableInterrupts();
osTPrintf("\n" OS_EXIT_STRING, status);
osTerminate();
}