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

Macros

#define DSPCR_DSPRESET   0x0800
 
#define DSPCR_DSPDMA   0x0200
 
#define DSPCR_DSPINTMSK   0x0100
 
#define DSPCR_DSPINT   0x0080
 
#define DSPCR_ARINTMSK   0x0040
 
#define DSPCR_ARINT   0x0020
 
#define DSPCR_AIINTMSK   0x0010
 
#define DSPCR_AIINT   0x0008
 
#define DSPCR_HALT   0x0004
 
#define DSPCR_PIINT   0x0002
 
#define DSPCR_RES   0x0001
 
#define AR_ARAMEXPANSION   2
 
#define _SHIFTL(v, s, w)   ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
 
#define _SHIFTR(v, s, w)   ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
 

Functions

static void __ARHandler (u32 irq, void *ctx)
 
static void __ARCheckSize (void)
 
static void __ARClearArea (u32 aramaddr, u32 len)
 
ARCallback AR_RegisterCallback (ARCallback callback)
 Register the given function as a DMA callback. More...
 
u32 AR_GetDMAStatus ()
 Get current status of DMA. More...
 
u32 AR_Init (u32 *stack_idx_array, u32 num_entries)
 Initializes ARAM subsystem. More...
 
void AR_StartDMA (u32 dir, u32 memaddr, u32 aramaddr, u32 len)
 Initiates a DMA between main memory and ARAM. More...
 
u32 AR_Alloc (u32 len)
 Allocate a block of memory from ARAM having len bytes. More...
 
u32 AR_Free (u32 *len)
 Free a block from ARAM. More...
 
void AR_Clear (u32 flag)
 Clear ARAM memory. More...
 
BOOL AR_CheckInit ()
 Get the ARAM subsystem initialization flag. More...
 
void AR_Reset ()
 Clears the ARAM subsystem initialization flag. More...
 
u32 AR_GetSize ()
 Get the total size - in bytes - of ARAM as calculated during AR_Init() More...
 
u32 AR_GetBaseAddress ()
 Get the baseaddress of ARAM memory. More...
 
u32 AR_GetInternalSize ()
 Get the size of the internal ARAM memory. More...
 
static __inline__ void __ARClearInterrupt ()
 
static __inline__ void __ARWaitDma ()
 
static void __ARReadDMA (u32 memaddr, u32 aramaddr, u32 len)
 
static void __ARWriteDMA (u32 memaddr, u32 aramaddr, u32 len)
 

Variables

static vu16 *const _dspReg = (u16*)0xCC005000
 
static ARCallback __ARDmaCallback = NULL
 
static u32 __ARInit_Flag = 0
 
static u32 __ARStackPointer = 0
 
static u32 __ARFreeBlocks = 0
 
static u32__ARBlockLen = NULL
 
static u32 __ARInternalSize = 0
 
static u32 __ARExpansionSize = 0
 
static u32 __ARSize = 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)))

◆ AR_ARAMEXPANSION

#define AR_ARAMEXPANSION   2

◆ DSPCR_AIINT

#define DSPCR_AIINT   0x0008

◆ DSPCR_AIINTMSK

#define DSPCR_AIINTMSK   0x0010

◆ DSPCR_ARINT

#define DSPCR_ARINT   0x0020

◆ DSPCR_ARINTMSK

#define DSPCR_ARINTMSK   0x0040

◆ DSPCR_DSPDMA

#define DSPCR_DSPDMA   0x0200

◆ DSPCR_DSPINT

#define DSPCR_DSPINT   0x0080

◆ DSPCR_DSPINTMSK

#define DSPCR_DSPINTMSK   0x0100

◆ DSPCR_DSPRESET

#define DSPCR_DSPRESET   0x0800

◆ DSPCR_HALT

#define DSPCR_HALT   0x0004

◆ DSPCR_PIINT

#define DSPCR_PIINT   0x0002

◆ DSPCR_RES

#define DSPCR_RES   0x0001

Function Documentation

◆ __ARCheckSize()

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

◆ __ARClearArea()

static void __ARClearArea ( u32  aramaddr,
u32  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __ARClearInterrupt()

static __inline__ void __ARClearInterrupt ( )
static
Here is the caller graph for this function:

◆ __ARHandler()

static void __ARHandler ( u32  irq,
void ctx 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __ARReadDMA()

static void __ARReadDMA ( u32  memaddr,
u32  aramaddr,
u32  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __ARWaitDma()

static __inline__ void __ARWaitDma ( )
static
Here is the caller graph for this function:

◆ __ARWriteDMA()

static void __ARWriteDMA ( u32  memaddr,
u32  aramaddr,
u32  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AR_Alloc()

u32 AR_Alloc ( u32  len)

Allocate a block of memory from ARAM having len bytes.

   The <i>len</i> parameter <b><i>must</i></b> be a multiple of 32
Parameters
[in]lenlength of the specified block of memory in ARAM
Returns
address of the block if successful, otherwise NULL

◆ AR_CheckInit()

BOOL AR_CheckInit ( )

Get the ARAM subsystem initialization flag.

Returns
TRUE if the ARAM subsystem has been initialized(via AR_Init())
FALSE if the ARAM subsystem has not been initialized, or has been reset(via AR_Reset())

◆ AR_Clear()

void AR_Clear ( u32  flag)

Clear ARAM memory.

Parameters
[in]flagspecifies the region of ARAM to clear
Returns
none
Here is the call graph for this function:

◆ AR_Free()

u32 AR_Free ( u32 len)

Free a block from ARAM.

Parameters
[out]lenpointer to receive the length of the free'd ARAM block. This is optional and can be NULL.
Returns
ARAM current baseaddress after free'ing the block

◆ AR_GetBaseAddress()

u32 AR_GetBaseAddress ( )

Get the baseaddress of ARAM memory.

Returns
ARAM memory baseaddress

◆ AR_GetDMAStatus()

u32 AR_GetDMAStatus ( )

Get current status of DMA.

Returns
zero if DMA is idle, non-zero if a DMA is in progress
Here is the caller graph for this function:

◆ AR_GetInternalSize()

u32 AR_GetInternalSize ( )

Get the size of the internal ARAM memory.

Returns
ARAM internal memory size

◆ AR_GetSize()

u32 AR_GetSize ( )

Get the total size - in bytes - of ARAM as calculated during AR_Init()

Returns
size of the specified ARAM block

◆ AR_Init()

u32 AR_Init ( u32 stack_idx_array,
u32  num_entries 
)

Initializes ARAM subsystem.

   Following tasks are performed:

 - Disables ARAM DMA
 - Sets DMA callback to NULL
 - Initializes ARAM controller
 - Determines size of ARAM memory
 - Initializes the ARAM stack based memory allocation system<br>

   The parameter u32 *stack_idx_array points to an array of u32 integers. The parameter u32 num_entries specifies the number of entries in this array.<br>
   The user application is responsible for determining how many ARAM blocks the device driver can allocate.<br>

   As an example, consider:
#define MAX_NUM_BLOCKS 10
u32 aram_blocks[MAX_NUM_BLOCKS];
...
void func(void)
{
AR_Init(aram_blocks, MAX_NUM_BLOCKS);
}
   Here, we are telling AR that the application will allocate, at most, 10 blocks (of arbitrary size), and that AR should store addresses for those blocks in the array aram_blocks. Note that the array is simply storage supplied by the application so that AR can track the number and size of memory blocks allocated by AR_Alloc().
   AR_Free()also uses this array to release blocks.<br>
   If you do not wish to use AR_Alloc() and AR_Free() and would rather manage ARAM usage within your application, then call AR_Init() like so:<br>

          AR_Init(NULL, 0);<br>

   The AR_Init() function also calculates the total size of the ARAM aggregate. Note that this procedure is <b><i>destructive</i></b> - i.e., any data stored in ARAM will be corrupted.<br>
   AR_Init()may be invoked multiple times. This function checks the state of an initialization flag; if asserted, this function will simply exit on subsequent calls. To perform another initialization of the ARAM driver, call AR_Reset() before invoking AR_Init() again.
Parameters
[in]stack_idx_arraypointer to an array of u32 integer
[in]num_entriesnumber of entries in the specified array
Returns
base address of the "user" ARAM area. As of this writing, the operating system reserves the bottom 16 KB of ARAM. Therefore, AR_Init() returns 0x04000 to indicate the starting location of the ARAM user area.
Here is the call graph for this function:

◆ AR_RegisterCallback()

ARCallback AR_RegisterCallback ( ARCallback  callback)

Register the given function as a DMA callback.

   Any existing callback is replaced unconditionally
Parameters
[in]callbackto be invoked upon completion of DMA transaction
Returns
pointer to the previously registered callback and NULL respectively
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AR_Reset()

void AR_Reset ( )

Clears the ARAM subsystem initialization flag.

   Calling AR_Init() after this function will cause a "real" initialization of ARAM
Returns
none

◆ AR_StartDMA()

void AR_StartDMA ( u32  dir,
u32  memaddr,
u32  aramaddr,
u32  len 
)

Initiates a DMA between main memory and ARAM.

   This function:

 - Does <b><i>not</i></b> perform boundery-checking on addresses and lengths.
 - Will assert failure if a DMA is allready in progress.
 - Is provided for debugging purpose. Application programmers must use the ARQ API in order to access ARAM.
Parameters
[in]dirspecifies the direction of transfer.
[in]memaddrspecifies main memory address for the transfer
[in]aramaddrspecifies the ARAM address for the transfer. NOTE: Addresses are 27bits wide and refer to bytes
[in]lenspecifies the length of the block to transfer. NOTE: Must be in bytes and a multiple of 32
Returns
none
Here is the caller graph for this function:

Variable Documentation

◆ __ARBlockLen

u32* __ARBlockLen = NULL
static

◆ __ARDmaCallback

ARCallback __ARDmaCallback = NULL
static

◆ __ARExpansionSize

u32 __ARExpansionSize = 0
static

◆ __ARFreeBlocks

u32 __ARFreeBlocks = 0
static

◆ __ARInit_Flag

u32 __ARInit_Flag = 0
static

◆ __ARInternalSize

u32 __ARInternalSize = 0
static

◆ __ARSize

u32 __ARSize = 0
static

◆ __ARStackPointer

u32 __ARStackPointer = 0
static

◆ _dspReg

vu16* const _dspReg = (u16*)0xCC005000
static