mirror of
https://github.com/rvtr/ctr_firmware.git
synced 2025-10-31 07:51:08 -04:00
(shirait) イベント追加
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@282 b871894f-2f95-9b40-918c-086798483c85
This commit is contained in:
parent
3a53089d55
commit
56c174c989
@ -45,6 +45,7 @@ SRCS = \
|
|||||||
os_cache.c \
|
os_cache.c \
|
||||||
os_printf.c \
|
os_printf.c \
|
||||||
os_boot.c \
|
os_boot.c \
|
||||||
|
os_event.c \
|
||||||
os_mmu.c \
|
os_mmu.c \
|
||||||
|
|
||||||
TARGET_LIB = libos$(BROM_LIBSUFFIX).a
|
TARGET_LIB = libos$(BROM_LIBSUFFIX).a
|
||||||
|
|||||||
@ -48,6 +48,7 @@ SRCS = \
|
|||||||
os_cache.c \
|
os_cache.c \
|
||||||
os_printf.c \
|
os_printf.c \
|
||||||
os_boot.c \
|
os_boot.c \
|
||||||
|
os_event.c \
|
||||||
os_protectionUnit.c \
|
os_protectionUnit.c \
|
||||||
|
|
||||||
TARGET_LIB = libos_sp$(BROM_LIBSUFFIX).a
|
TARGET_LIB = libos_sp$(BROM_LIBSUFFIX).a
|
||||||
|
|||||||
244
trunk/bootrom/build/libraries/os/common/os_event.c
Normal file
244
trunk/bootrom/build/libraries/os/common/os_event.c
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - OS
|
||||||
|
File: os_event.c
|
||||||
|
|
||||||
|
Copyright 2007-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$
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
/*
|
||||||
|
#ifdef SDK_TWL
|
||||||
|
#include <twl/memorymap.h>
|
||||||
|
#else
|
||||||
|
#include <nitro/memorymap.h>
|
||||||
|
#endif*/
|
||||||
|
|
||||||
|
#include <brom/os.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(SDK_TCM_APPLY) && defined(SDK_ARM9)
|
||||||
|
#include <nitro/itcm_begin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: OS_InitEvent
|
||||||
|
|
||||||
|
Description: initialize event struct
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void osInitEvent( OSEvent *event )
|
||||||
|
{
|
||||||
|
osInitThreadQueue( &event->queue );
|
||||||
|
event->flag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osWaitEvent
|
||||||
|
|
||||||
|
Description: sleep thread and wait event
|
||||||
|
if event is NULL, just sleep.
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
pattern : event pattern
|
||||||
|
mode : event mode
|
||||||
|
OS_EVENT_MODE_AND ... wait for all event bit
|
||||||
|
OS_EVENT_MODE_OR ... wait for any event bit
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
u32 osWaitEvent(OSEvent* event, u32 pattern, OSEventMode mode )
|
||||||
|
{
|
||||||
|
return osWaitEventEx(event, pattern, mode, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osWaitEventEx
|
||||||
|
|
||||||
|
Description: sleep thread and wait event
|
||||||
|
if event is NULL, just sleep.
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
pattern : event pattern
|
||||||
|
mode : event mode
|
||||||
|
OS_EVENT_MODE_AND ... wait for all event bit
|
||||||
|
OS_EVENT_MODE_OR ... wait for any event bit
|
||||||
|
clearBit : clear bits (in case of the end of waiting)
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
u32 osWaitEventEx(OSEvent* event, u32 pattern, OSEventMode mode, u32 clearBit )
|
||||||
|
{
|
||||||
|
u32 retval = 0;
|
||||||
|
OSIntrMode enable = osDisableInterrupts();
|
||||||
|
|
||||||
|
SDK_ASSERT( event );
|
||||||
|
|
||||||
|
switch( mode )
|
||||||
|
{
|
||||||
|
case OS_EVENT_MODE_AND:
|
||||||
|
while( (event->flag & pattern) != pattern )
|
||||||
|
{
|
||||||
|
osSleepThread(&event->queue);
|
||||||
|
}
|
||||||
|
retval = event->flag;
|
||||||
|
break;
|
||||||
|
case OS_EVENT_MODE_OR:
|
||||||
|
while( (event->flag & pattern) == 0 )
|
||||||
|
{
|
||||||
|
osSleepThread(&event->queue);
|
||||||
|
}
|
||||||
|
retval = event->flag;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---- clear flag
|
||||||
|
if ( retval )
|
||||||
|
{
|
||||||
|
event->flag &= ~clearBit;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)osRestoreInterrupts(enable);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osSignalEvent
|
||||||
|
|
||||||
|
Description: set event bit and wakeup thread.
|
||||||
|
if setPattern == 0, do nothing
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
setPattern : bit pattern to set
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void osSignalEvent(OSEvent* event, u32 setPattern)
|
||||||
|
{
|
||||||
|
OSIntrMode enable = osDisableInterrupts();
|
||||||
|
SDK_ASSERT( event );
|
||||||
|
|
||||||
|
if ( setPattern )
|
||||||
|
{
|
||||||
|
event->flag |= setPattern;
|
||||||
|
osWakeupThread( &event->queue );
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)osRestoreInterrupts(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osClearAllEvent
|
||||||
|
|
||||||
|
Description: clear all event bits
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void osClearAllEvent(OSEvent* event)
|
||||||
|
{
|
||||||
|
SDK_ASSERT( event );
|
||||||
|
event->flag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osClearEvent
|
||||||
|
|
||||||
|
Description: clear specified event bits
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
clearBit : clear bits
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void osClearEvent(OSEvent* event, u32 clearBit)
|
||||||
|
{
|
||||||
|
OSIntrMode enable = osDisableInterrupts();
|
||||||
|
SDK_ASSERT( event );
|
||||||
|
|
||||||
|
event->flag &= ~clearBit;
|
||||||
|
|
||||||
|
(void)osRestoreInterrupts(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osPollEvent
|
||||||
|
|
||||||
|
Description: poll event struct if condition matches
|
||||||
|
|
||||||
|
Arguments: event : waiting condition
|
||||||
|
pattern : event pattern
|
||||||
|
mode : event mode
|
||||||
|
OS_EVENT_MODE_AND ... wait for all event bit
|
||||||
|
OS_EVENT_MODE_OR ... wait for any event bit
|
||||||
|
|
||||||
|
Returns: not 0 ... matched. return the event flag.
|
||||||
|
0 ... not match.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
u32 osPollEvent(OSEvent* event, u32 pattern, OSEventMode mode )
|
||||||
|
{
|
||||||
|
return osPollEventEx( event, pattern, mode, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osPollEventEx
|
||||||
|
|
||||||
|
Description: poll event struct if condition matches
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
pattern : event pattern
|
||||||
|
mode : event mode
|
||||||
|
OS_EVENT_MODE_AND ... wait for all event bit
|
||||||
|
OS_EVENT_MODE_OR ... wait for any event bit
|
||||||
|
clearBit : clear bits (in case of matching)
|
||||||
|
|
||||||
|
Returns: not 0 ... matched. return the event flag.
|
||||||
|
0 ... not match.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
u32 osPollEventEx(OSEvent* event, u32 pattern, OSEventMode mode, u32 clearBit )
|
||||||
|
{
|
||||||
|
u32 retval = 0;
|
||||||
|
OSIntrMode enable = osDisableInterrupts();
|
||||||
|
|
||||||
|
SDK_ASSERT( event );
|
||||||
|
|
||||||
|
switch( mode )
|
||||||
|
{
|
||||||
|
case OS_EVENT_MODE_AND:
|
||||||
|
if ( (event->flag & pattern) == pattern )
|
||||||
|
{
|
||||||
|
retval = event->flag;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OS_EVENT_MODE_OR:
|
||||||
|
if ( event->flag & pattern )
|
||||||
|
{
|
||||||
|
retval = event->flag;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---- clear flag
|
||||||
|
if ( retval )
|
||||||
|
{
|
||||||
|
event->flag &= ~clearBit;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)osRestoreInterrupts(enable);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(SDK_TCM_APPLY) && defined(SDK_ARM9)
|
||||||
|
#include <nitro/itcm_end.h>
|
||||||
|
#endif
|
||||||
@ -43,6 +43,7 @@ extern "C" {
|
|||||||
#include <brom/os/common/printf.h>
|
#include <brom/os/common/printf.h>
|
||||||
#include <brom/os/common/spinLock.h>
|
#include <brom/os/common/spinLock.h>
|
||||||
#include <brom/os/common/boot.h>
|
#include <brom/os/common/boot.h>
|
||||||
|
#include <brom/os/common/event.h>
|
||||||
|
|
||||||
#ifdef SDK_ARM11
|
#ifdef SDK_ARM11
|
||||||
#include <brom/os/ARM11/mmu.h>
|
#include <brom/os/ARM11/mmu.h>
|
||||||
|
|||||||
200
trunk/bootrom/include/brom/os/common/event.h
Normal file
200
trunk/bootrom/include/brom/os/common/event.h
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: TwlSDK - OS - include
|
||||||
|
File: event.h
|
||||||
|
|
||||||
|
Copyright 2003-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 NITRO_OS_EVENT_H_
|
||||||
|
#define NITRO_OS_EVENT_H_
|
||||||
|
|
||||||
|
#include <brom/os/common/thread.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//---------------- event mode
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
OS_EVENT_MODE_AND = 0,
|
||||||
|
OS_EVENT_MODE_OR = 1
|
||||||
|
}
|
||||||
|
OSEventMode;
|
||||||
|
|
||||||
|
|
||||||
|
//---------------- event parameter
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
vu32 flag;
|
||||||
|
OSThreadQueue queue;
|
||||||
|
}
|
||||||
|
OSEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osInitEvent
|
||||||
|
|
||||||
|
Description: initialize event struct
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void osInitEvent( OSEvent *event );
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osWaitEvent
|
||||||
|
|
||||||
|
Description: sleep thread and wait event
|
||||||
|
if event is NULL, just sleep.
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
pattern : event pattern
|
||||||
|
mode : event mode
|
||||||
|
OS_EVENT_MODE_AND ... wait for all event bit
|
||||||
|
OS_EVENT_MODE_OR ... wait for any event bit
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
u32 osWaitEvent(OSEvent* event, u32 pattern, OSEventMode mode );
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osWaitEventEx
|
||||||
|
|
||||||
|
Description: sleep thread and wait event
|
||||||
|
if event is NULL, just sleep.
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
pattern : event pattern
|
||||||
|
mode : event mode
|
||||||
|
OS_EVENT_MODE_AND ... wait for all event bit
|
||||||
|
OS_EVENT_MODE_OR ... wait for any event bit
|
||||||
|
clearBit : clear bits (in case of the end of waiting)
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
u32 osWaitEventEx(OSEvent* event, u32 pattern, OSEventMode mode, u32 clearBit );
|
||||||
|
|
||||||
|
|
||||||
|
//---- inline access
|
||||||
|
static inline u32 osWaitEvent_And( OSEvent* event, u32 pattern )
|
||||||
|
{
|
||||||
|
return osWaitEventEx( event, pattern, OS_EVENT_MODE_AND, 0 );
|
||||||
|
}
|
||||||
|
static inline u32 osWaitEvent_Or(OSEvent* event, u32 pattern )
|
||||||
|
{
|
||||||
|
return osWaitEventEx( event, pattern, OS_EVENT_MODE_OR, 0 );
|
||||||
|
}
|
||||||
|
static inline u32 osWaitEventEx_And( OSEvent* event, u32 pattern, u32 clearBit )
|
||||||
|
{
|
||||||
|
return osWaitEventEx( event, pattern, OS_EVENT_MODE_AND, clearBit );
|
||||||
|
}
|
||||||
|
static inline u32 osWaitEventEx_Or(OSEvent* event, u32 pattern, u32 clearBit )
|
||||||
|
{
|
||||||
|
return osWaitEventEx( event, pattern, OS_EVENT_MODE_OR, clearBit );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osSignalEvent
|
||||||
|
|
||||||
|
Description: set event bit and wakeup thread.
|
||||||
|
if setPattern == 0, do nothing
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
setPattern : bit pattern to set
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void osSignalEvent(OSEvent* event, u32 setPattern);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osClearEvent
|
||||||
|
|
||||||
|
Description: clear specified event bits
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
clearBit : clear bits
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void osClearEvent(OSEvent* event, u32 clearBit);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osClearAllEvent
|
||||||
|
|
||||||
|
Description: clear all event bits
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
|
||||||
|
Returns: none
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
void osClearAllEvent(OSEvent* event);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osPollEvent
|
||||||
|
|
||||||
|
Description: poll event struct if condition matches
|
||||||
|
|
||||||
|
Arguments: event : waiting condition
|
||||||
|
pattern : event pattern
|
||||||
|
mode : event mode
|
||||||
|
OS_EVENT_MODE_AND ... wait for all event bit
|
||||||
|
OS_EVENT_MODE_OR ... wait for any event bit
|
||||||
|
|
||||||
|
Returns: not 0 ... matched. returnd the event flag.
|
||||||
|
0 ... not match.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
u32 osPollEvent(OSEvent* event, u32 pattern, OSEventMode mode );
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Name: osPollEventEx
|
||||||
|
|
||||||
|
Description: poll event struct if condition matches
|
||||||
|
|
||||||
|
Arguments: event : pointer to event struct
|
||||||
|
pattern : event pattern
|
||||||
|
mode : event mode
|
||||||
|
OS_EVENT_MODE_AND ... wait for all event bit
|
||||||
|
OS_EVENT_MODE_OR ... wait for any event bit
|
||||||
|
clearBit : clear bits (in case of matching)
|
||||||
|
|
||||||
|
Returns: not 0 ... matched. returnd the event flag.
|
||||||
|
0 ... not match.
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
u32 osPollEventEx(OSEvent* event, u32 pattern, OSEventMode mode, u32 clearBit );
|
||||||
|
|
||||||
|
//---- inline access
|
||||||
|
static inline u32 osPollEvent_And( OSEvent* event, u32 pattern )
|
||||||
|
{
|
||||||
|
return osPollEventEx( event, pattern, OS_EVENT_MODE_AND, 0 );
|
||||||
|
}
|
||||||
|
static inline u32 osPollEvent_Or(OSEvent* event, u32 pattern )
|
||||||
|
{
|
||||||
|
return osPollEventEx( event, pattern, OS_EVENT_MODE_OR, 0 );
|
||||||
|
}
|
||||||
|
static inline u32 osPollEventEx_And( OSEvent* event, u32 pattern, u32 clearBit )
|
||||||
|
{
|
||||||
|
return osPollEventEx( event, pattern, OS_EVENT_MODE_AND, clearBit );
|
||||||
|
}
|
||||||
|
static inline u32 osPollEventEx_Or(OSEvent* event, u32 pattern, u32 clearBit )
|
||||||
|
{
|
||||||
|
return osPollEventEx( event, pattern, OS_EVENT_MODE_OR, clearBit );
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* NITRO_OS_EVENT_H_ */
|
||||||
|
#endif
|
||||||
@ -46,6 +46,7 @@ SRCS = \
|
|||||||
os_cache.c \
|
os_cache.c \
|
||||||
os_printf.c \
|
os_printf.c \
|
||||||
os_boot.c \
|
os_boot.c \
|
||||||
|
os_event.c \
|
||||||
os_mmu.c \
|
os_mmu.c \
|
||||||
|
|
||||||
TARGET_LIB = libos$(FIRM_LIBSUFFIX).a
|
TARGET_LIB = libos$(FIRM_LIBSUFFIX).a
|
||||||
|
|||||||
@ -50,6 +50,7 @@ SRCS = \
|
|||||||
os_printf.c \
|
os_printf.c \
|
||||||
os_boot.c \
|
os_boot.c \
|
||||||
os_protectionUnit.c \
|
os_protectionUnit.c \
|
||||||
|
os_event.c \
|
||||||
|
|
||||||
TARGET_LIB = libos_sp$(FIRM_LIBSUFFIX).a
|
TARGET_LIB = libos_sp$(FIRM_LIBSUFFIX).a
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user