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@282 b871894f-2f95-9b40-918c-086798483c85
201 lines
6.7 KiB
C
201 lines
6.7 KiB
C
/*---------------------------------------------------------------------------*
|
|
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
|