ctr_firmware/trunk/bootrom/include/brom/pxi/common/fifo.h
nakasima f48f0be43f small arrange.
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@153 b871894f-2f95-9b40-918c-086798483c85
2009-01-05 10:51:10 +00:00

198 lines
6.0 KiB
C

/*---------------------------------------------------------------------------*
Project: CtrBrom - -include - PXI
File: fifo.h
Copyright 2009 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 BROM_PXI_COMMON_FIFO_H_
#define BROM_PXI_COMMON_FIFO_H_
#include <brom/types.h>
#include <brom/memorymap.h>
#include <brom/pxi/common/regname.h>
#ifdef __cplusplus
extern "C" {
#endif
/* TAG ID definition */
typedef enum
{
PXI_FIFO_TAG_EX = 0, // Extension format
PXI_FIFO_TAG_USER_0, // for application programmer, use it in free
PXI_FIFO_TAG_USER_1, // for application programmer, use it in free
PXI_FIFO_TAG_SYSTEM, // SDK inner usage
PXI_FIFO_TAG_NVRAM, // NVRAM
PXI_FIFO_TAG_RTC, // RTC
PXI_FIFO_TAG_TOUCHPANEL, // Touch Panel
PXI_FIFO_TAG_SOUND, // Sound
PXI_FIFO_TAG_PM, // Power Management
PXI_FIFO_TAG_MIC, // Microphone
PXI_FIFO_TAG_WM, // Wireless Manager
PXI_FIFO_TAG_FS, // File System
PXI_FIFO_TAG_OS, // OS
PXI_FIFO_TAG_CARD, // Card
PXI_FIFO_TAG_SDMC,
PXI_MAX_FIFO_TAG = 32 // MAX FIFO TAG
}
PXIFifoTag;
/* for Compatibility */
#define PXI_FIFO_DEVICE_TEST PXI_FIFO_TAG_USR_0
#define PXI_FIFO_DEVICE_FLASH PXI_FIFO_TAG_NVRAM
#define PXI_FIFO_DEVICE_RTC PXI_FIFO_TAG_RTC
#define PXI_FIFO_DEVICE_TOUCHPANEL PXI_FIFO_TAG_TOUCHPANEL
#define PXI_MAX_DEVICES PXI_MAX_FIFO_TAG
/* PXI_FIFO return code */
typedef enum
{
PXI_FIFO_SUCCESS = 0,
PXI_FIFO_FAIL_SEND_ERR = -1,
PXI_FIFO_FAIL_SEND_FULL = -2,
PXI_FIFO_FAIL_RECV_ERR = -3,
PXI_FIFO_FAIL_RECV_EMPTY = -4,
PXI_FIFO_NO_CALLBACK_ENTRY = -5
}
PXIFifoStatus;
/* type definition */
#define PXI_FIFOMESSAGE_BITSZ_TAG 5
#define PXI_FIFOMESSAGE_BITSZ_ERR 1
#define PXI_FIFOMESSAGE_BITSZ_DATA 26
typedef union
{
struct
{
u32 tag:PXI_FIFOMESSAGE_BITSZ_TAG;
u32 err:PXI_FIFOMESSAGE_BITSZ_ERR;
u32 data:PXI_FIFOMESSAGE_BITSZ_DATA;
}
e;
u32 raw;
}
PXIFifoMessage;
// type definition
typedef void (*PXIFifoCallback) (PXIFifoTag tag, u32 data, BOOL err);
typedef void (*PXIFifoEmtpyCallback) (void);
/*---------------------------------------------------------------------------*
Name: pxiIsFifoError
Description: Check if error on fifo?
Arguments: status Status
Returns: None.
*---------------------------------------------------------------------------*/
static inline BOOL pxiIsFifoError(PXIFifoStatus status)
{
return PXI_FIFO_SUCCESS == status;
}
/*---------------------------------------------------------------------------*
Name: pxiInitFifo
Description: initialize FIFO system
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void pxiInitFifo(void);
/*---------------------------------------------------------------------------*
Name: pxiSetFifoRecvCallback
Description: set callback function when data arrive via FIFO
Arguments: device_no DEVICE NO.
callback callback function to be called
Returns: None.
*---------------------------------------------------------------------------*/
void pxiSetFifoRecvCallback(int fifotag, PXIFifoCallback callback);
/*---------------------------------------------------------------------------*
Name: pxiIsCallbackReady
pxiIsArm11CallbackReady
pxiIsArm9CallbackReady
Description: check if callback is ready
Arguments: fifotag fifo tag NO (0-31)
proc processor name PXI_PROC_ARM11 or PXI_PROC_ARM9
Returns: TRUE if callback is ready
*---------------------------------------------------------------------------*/
BOOL pxiIsCallbackReady(int fifotag, PXIProc proc);
static inline BOOL pxiIsArm9CallbackReady(int fifotag)
{
return pxiIsCallbackReady(fifotag, PXI_PROC_ARM9);
}
static inline BOOL pxiIsArm11CallbackReady(int fifotag)
{
return pxiIsCallbackReady(fifotag, PXI_PROC_ARM11);
}
/*---------------------------------------------------------------------------*
Name: pxiSetFifoSendCallback
Description: set callback function when data is sent via FIFO
Arguments: callback callback function to be called
Returns: None.
*---------------------------------------------------------------------------*/
void pxiSetFifoSendCallback(PXIFifoEmtpyCallback callback);
/*---------------------------------------------------------------------------*
Name: pxiSendWordByFifo
Description: Send 32bit-word to anothre CPU via FIFO
Arguments: device_no DEVICE NO.
data data(26-bit) whichi is sent
Returns: if error occured, returns minus value
*---------------------------------------------------------------------------*/
int pxiSendWordByFifo(int fifotag, u32 data, BOOL err);
//======================================================================
// Interrupt handler called when RECV FIFO not empty
//======================================================================
void PXIi_HandlerRecvFifoNotEmpty(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* BROM_PXI_COMMON_FIFO_H_ */