RetroArch
Classes | Macros | Typedefs | Functions | Variables
exi.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "asm.h"
#include "irq.h"
#include "processor.h"
#include "spinlock.h"
#include "exi.h"
Include dependency graph for exi.c:

Classes

struct  _lck_dev
 
struct  _exibus_priv
 

Macros

#define EXI_LOCK_DEVS   32
 
#define EXI_MAX_CHANNELS   3
 
#define EXI_MAX_DEVICES   3
 
#define EXI_DEVICE0   0x0080
 
#define EXI_DEVICE1   0x0100
 
#define EXI_DEVICE2   0x0200
 
#define EXI_EXI_IRQ   0x0002
 
#define EXI_TC_IRQ   0x0008
 
#define EXI_EXT_IRQ   0x0800
 
#define EXI_EXT_BIT   0x1000
 
#define _SHIFTL(v, s, w)   ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
 
#define _SHIFTR(v, s, w)   ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
 

Typedefs

typedef struct _exibus_priv exibus_priv
 

Functions

static void __exi_irq_handler (u32, void *)
 
static void __tc_irq_handler (u32, void *)
 
static void __ext_irq_handler (u32, void *)
 
static __inline__ void __exi_clearirqs (s32 nChn, u32 nEXIIrq, u32 nTCIrq, u32 nEXTIrq)
 
static __inline__ void __exi_setinterrupts (s32 nChn, exibus_priv *exi)
 
static void __exi_initmap (exibus_priv *exim)
 
static s32 __exi_probe (s32 nChn)
 
static s32 __exi_attach (s32 nChn, EXICallback ext_cb)
 
s32 EXI_Lock (s32 nChn, s32 nDev, EXICallback unlockCB)
 Try to lock the desired EXI channel on the given device. More...
 
s32 EXI_Unlock (s32 nChn)
 Unlock the desired EXI channel. More...
 
s32 EXI_Select (s32 nChn, s32 nDev, s32 nFrq)
 Selects the spedified EXI channel on the given device with the given frequency. More...
 
s32 EXI_SelectSD (s32 nChn, s32 nDev, s32 nFrq)
 Performs a special select, for SD cards or adapters respectively, on the given device with the given frequence. More...
 
s32 EXI_Deselect (s32 nChn)
 Deselects the EXI channel. More...
 
s32 EXI_Sync (s32 nChn)
 Synchronize or finish respectively the last EXI transfer. More...
 
s32 EXI_Imm (s32 nChn, void *pData, u32 nLen, u32 nMode, EXICallback tc_cb)
 Initializes an immediate mode EXI transfer. More...
 
s32 EXI_ImmEx (s32 nChn, void *pData, u32 nLen, u32 nMode)
 Initializes an extended immediate mode EXI transfer. More...
 
s32 EXI_Dma (s32 nChn, void *pData, u32 nLen, u32 nMode, EXICallback tc_cb)
 Initializes a DMA mode EXI transfer. More...
 
s32 EXI_GetState (s32 nChn)
 Get the EXI state. More...
 
static s32 __unlocked_handler (s32 nChn, s32 nDev)
 
s32 EXI_GetID (s32 nChn, s32 nDev, u32 *nId)
 Get the ID of the connected EXI device on the given channel. More...
 
s32 EXI_Attach (s32 nChn, EXICallback ext_cb)
 Attach the device on the given channel. More...
 
s32 EXI_Detach (s32 nChn)
 Detach the device on the given channel. More...
 
EXICallback EXI_RegisterEXICallback (s32 nChn, EXICallback exi_cb)
 Register a callback function in the EXI driver for the EXI interrupt. More...
 
s32 EXI_Probe (s32 nChn)
 Probes the EXI channel. More...
 
s32 EXI_ProbeEx (s32 nChn)
 Performs an extended probe of the EXI channel. More...
 
void EXI_ProbeReset ()
 Resets certain internal flags and counters and performs a probe on all 3 channels. More...
 
void __exi_init ()
 
static s32 __probebarnacle (s32 chn, u32 dev, u32 *rev)
 
static s32 __queuelength ()
 
void __SYS_EnableBarnacle (s32 chn, u32 dev)
 
s32 InitializeUART ()
 
s32 WriteUARTN (void *buf, u32 len)
 

Variables

static lwp_queue _lckdev_queue
 
static struct _lck_dev lckdevs [EXI_LOCK_DEVS]
 
static exibus_priv eximap [EXI_MAX_CHANNELS]
 
static u64 last_exi_idtime [EXI_MAX_CHANNELS]
 
static u32 exi_id_serport1 = 0
 
static u32 exi_uart_chan = EXI_CHANNEL_0
 
static u32 exi_uart_dev = EXI_DEVICE_0
 
static u32 exi_uart_barnacle_enabled = 0
 
static u32 exi_uart_enabled = 0
 

Macro Definition Documentation

◆ _SHIFTL

#define _SHIFTL (   v,
  s,
  w 
)    ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))

◆ _SHIFTR

#define _SHIFTR (   v,
  s,
  w 
)    ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))

◆ EXI_DEVICE0

#define EXI_DEVICE0   0x0080

◆ EXI_DEVICE1

#define EXI_DEVICE1   0x0100

◆ EXI_DEVICE2

#define EXI_DEVICE2   0x0200

◆ EXI_EXI_IRQ

#define EXI_EXI_IRQ   0x0002

◆ EXI_EXT_BIT

#define EXI_EXT_BIT   0x1000

◆ EXI_EXT_IRQ

#define EXI_EXT_IRQ   0x0800

◆ EXI_LOCK_DEVS

#define EXI_LOCK_DEVS   32

◆ EXI_MAX_CHANNELS

#define EXI_MAX_CHANNELS   3

◆ EXI_MAX_DEVICES

#define EXI_MAX_DEVICES   3

◆ EXI_TC_IRQ

#define EXI_TC_IRQ   0x0008

Typedef Documentation

◆ exibus_priv

typedef struct _exibus_priv exibus_priv

Function Documentation

◆ __exi_attach()

static s32 __exi_attach ( s32  nChn,
EXICallback  ext_cb 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __exi_clearirqs()

static __inline__ void __exi_clearirqs ( s32  nChn,
u32  nEXIIrq,
u32  nTCIrq,
u32  nEXTIrq 
)
static
Here is the caller graph for this function:

◆ __exi_init()

void __exi_init ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __exi_initmap()

static void __exi_initmap ( exibus_priv exim)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __exi_irq_handler()

void __exi_irq_handler ( u32  nIrq,
void pCtx 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __exi_probe()

static s32 __exi_probe ( s32  nChn)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __exi_setinterrupts()

static __inline__ void __exi_setinterrupts ( s32  nChn,
exibus_priv exi 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __ext_irq_handler()

void __ext_irq_handler ( u32  nIrq,
void pCtx 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __probebarnacle()

static s32 __probebarnacle ( s32  chn,
u32  dev,
u32 rev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __queuelength()

static s32 __queuelength ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __SYS_EnableBarnacle()

void __SYS_EnableBarnacle ( s32  chn,
u32  dev 
)
Here is the call graph for this function:

◆ __tc_irq_handler()

void __tc_irq_handler ( u32  nIrq,
void pCtx 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __unlocked_handler()

static s32 __unlocked_handler ( s32  nChn,
s32  nDev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_Attach()

s32 EXI_Attach ( s32  nChn,
EXICallback  ext_cb 
)

Attach the device on the given channel.

Parameters
[in]nChnEXI channel to select
[in]ext_cbpointer to callback to call when device is physically removed.
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_Deselect()

s32 EXI_Deselect ( s32  nChn)

Deselects the EXI channel.

Parameters
[in]nChnEXI channel to deselect
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_Detach()

s32 EXI_Detach ( s32  nChn)

Detach the device on the given channel.

Parameters
[in]nChnEXI channel to select
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_Dma()

s32 EXI_Dma ( s32  nChn,
void pData,
u32  nLen,
u32  nMode,
EXICallback  tc_cb 
)

Initializes a DMA mode EXI transfer.

Parameters
[in]nChnEXI channel to select
[in,out]pDatapointer to a buffer to read/copy from/to data.
[in]nLenlenght of data to transfer.
[in]nModedirection of transferoperation(EXI_READ,EXI_WRITE,EXI_READWRITE)
[in]tc_cbpointer to a callback to call when transfer has completed. May be NULL.
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_GetID()

s32 EXI_GetID ( s32  nChn,
s32  nDev,
u32 nId 
)

Get the ID of the connected EXI device on the given channel.

Parameters
[in]nChnEXI channel to select
[in]nDevEXI device to select
[out]nIdEXI device ID to return.
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_GetState()

s32 EXI_GetState ( s32  nChn)

Get the EXI state.

Parameters
[in]nChnEXI channel to select
Returns
EXI channels state flag.
Here is the caller graph for this function:

◆ EXI_Imm()

s32 EXI_Imm ( s32  nChn,
void pData,
u32  nLen,
u32  nMode,
EXICallback  tc_cb 
)

Initializes an immediate mode EXI transfer.

Parameters
[in]nChnEXI channel to select
[in,out]pDatapointer to a buffer to read/copy from/to data.
[in]nLenlenght of data to transfer <=4.
[in]nModedirection of transferoperation(EXI_READ,EXI_WRITE,EXI_READWRITE)
[in]tc_cbpointer to a callback to call when transfer has completed. May be NULL.
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_ImmEx()

s32 EXI_ImmEx ( s32  nChn,
void pData,
u32  nLen,
u32  nMode 
)

Initializes an extended immediate mode EXI transfer.

Parameters
[in]nChnEXI channel to select
[in,out]pDatapointer to a buffer to read/copy from/to data.
[in]nLenlenght of data to transfer.
[in]nModedirection of transferoperation(EXI_READ,EXI_WRITE,EXI_READWRITE)
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_Lock()

s32 EXI_Lock ( s32  nChn,
s32  nDev,
EXICallback  unlockCB 
)

Try to lock the desired EXI channel on the given device.

Parameters
[in]nChnEXI channel to lock
[in]nDevEXI device to lock
[in]unlockCBpointer to callback to call when EXI_Unlock() is called. Thus allowing us a small way of mutual exclusion.
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_Probe()

s32 EXI_Probe ( s32  nChn)

Probes the EXI channel.

Parameters
[in]nChnEXI channel to probe
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_ProbeEx()

s32 EXI_ProbeEx ( s32  nChn)

Performs an extended probe of the EXI channel.

Parameters
[in]nChnEXI channel to probe
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_ProbeReset()

void EXI_ProbeReset ( )

Resets certain internal flags and counters and performs a probe on all 3 channels.

Returns
nothing
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_RegisterEXICallback()

EXICallback EXI_RegisterEXICallback ( s32  nChn,
EXICallback  exi_cb 
)

Register a callback function in the EXI driver for the EXI interrupt.

Parameters
[in]nChnEXI channel to select
[in]exi_cbpointer to the function which to call when EXI interrupt has triggered.
Returns
old callback function pointer or NULL
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_Select()

s32 EXI_Select ( s32  nChn,
s32  nDev,
s32  nFrq 
)

Selects the spedified EXI channel on the given device with the given frequency.

Parameters
[in]nChnEXI channel to select
[in]nDevEXI device to select
[in]nFrqEXI frequency to select
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_SelectSD()

s32 EXI_SelectSD ( s32  nChn,
s32  nDev,
s32  nFrq 
)

Performs a special select, for SD cards or adapters respectively, on the given device with the given frequence.

Parameters
[in]nChnEXI channel to select
[in]nDevEXI device to select
[in]nFrqEXI frequency to select
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EXI_Sync()

s32 EXI_Sync ( s32  nChn)

Synchronize or finish respectively the last EXI transfer.

Parameters
[in]nChnEXI channel to select
Returns
1 on success, <=0 on error
Here is the caller graph for this function:

◆ EXI_Unlock()

s32 EXI_Unlock ( s32  nChn)

Unlock the desired EXI channel.

Parameters
[in]nChnEXI channel to unlock
Returns
1 on success, <=0 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeUART()

s32 InitializeUART ( )

◆ WriteUARTN()

s32 WriteUARTN ( void buf,
u32  len 
)
Here is the call graph for this function:

Variable Documentation

◆ _lckdev_queue

lwp_queue _lckdev_queue
static

◆ exi_id_serport1

u32 exi_id_serport1 = 0
static

◆ exi_uart_barnacle_enabled

u32 exi_uart_barnacle_enabled = 0
static

◆ exi_uart_chan

u32 exi_uart_chan = EXI_CHANNEL_0
static

◆ exi_uart_dev

u32 exi_uart_dev = EXI_DEVICE_0
static

◆ exi_uart_enabled

u32 exi_uart_enabled = 0
static

◆ eximap

exibus_priv eximap[EXI_MAX_CHANNELS]
static

◆ last_exi_idtime

u64 last_exi_idtime[EXI_MAX_CHANNELS]
static

◆ lckdevs

struct _lck_dev lckdevs[EXI_LOCK_DEVS]
static