mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@95 b871894f-2f95-9b40-918c-086798483c85
125 lines
3.8 KiB
C
125 lines
3.8 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)
|
|
|
|
|
|
//============================================================================
|
|
// 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();
|
|
}
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
Name: osHalt
|
|
|
|
Description: Halt CPU
|
|
|
|
Arguments: None
|
|
|
|
Returns: None
|
|
*---------------------------------------------------------------------------*/
|
|
#include <brom/code32.h>
|
|
ASM void osHalt( void )
|
|
{
|
|
mov r0, #0
|
|
mcr p15, 0, r0, c7, c0, 4
|
|
bx lr
|
|
}
|
|
#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();
|
|
}
|