DSP code format cleanup

This commit is contained in:
fincs 2015-09-25 22:06:51 +02:00
parent 649e95cd39
commit c9a75d6a18
2 changed files with 30 additions and 43 deletions

View File

@ -7,12 +7,14 @@
#pragma once
#include <3ds/types.h>
typedef enum {
typedef enum
{
DSP_INTERRUPT_PIPE = 2
} DSP_InterruptType;
typedef enum {
typedef enum
{
DSP_PIPE_INPUT = 0, ///< DSP to ARM
DSP_PIPE_OUTPUT = 1 ///< ARM to DSP
} DSP_PipeDirection;
@ -35,7 +37,6 @@ Result dspExit(void);
///Checks if a headphone is inserted.
Result DSP_GetHeadphoneStatus(bool* is_inserted);
/**
* @brief Flushes the cache
* @param address Beginning of the memory range to flush, inside the Linear or DSP memory regions
@ -43,7 +44,7 @@ Result DSP_GetHeadphoneStatus(bool* is_inserted);
*
* Flushes the cache for the specified memory range and invalidates the cache
*/
Result DSP_FlushDataCache(u32 address, u32 size);
Result DSP_FlushDataCache(const void* address, u32 size);
/**
* @brief Invalidates the cache
@ -52,7 +53,7 @@ Result DSP_FlushDataCache(u32 address, u32 size);
*
* Invalidates the cache for the specified memory range
*/
Result DSP_InvalidateDataCache(u32 address, u32 size);
Result DSP_InvalidateDataCache(const void* address, u32 size);
///Retrieves the handle of the DSP semaphore
Result DSP_GetSemaphoreHandle(Handle* semaphore);
@ -74,7 +75,7 @@ Result DSP_SetSemaphoreMask(u16 mask);
* @note The binary must be signed (http://3dbrew.org/wiki/DSP_Binary)
* @note Seems to be called when the 3ds leaves the Sleep mode
*/
Result DSP_LoadComponent(u8 const* component,u32 size,u16 prog_mask,u16 data_mask,bool * is_loaded);
Result DSP_LoadComponent(const void* component, u32 size, u16 prog_mask, u16 data_mask, bool* is_loaded);
///Stops the DSP by unloading the binary
Result DSP_UnloadComponent(void);
@ -86,8 +87,7 @@ Result DSP_UnloadComponent(void);
*
* @note It is possible that interrupt are inverted
*/
Result DSP_RegisterInterruptEvents(Handle handle,u32 interrupt,u32 channel);
Result DSP_RegisterInterruptEvents(Handle handle, u32 interrupt, u32 channel);
/**
* @param channel unknown. Usually 2
@ -96,24 +96,23 @@ Result DSP_RegisterInterruptEvents(Handle handle,u32 interrupt,u32 channel);
* @param length Length of the buffer
* @param length_read Number of bytes read by the command
*/
Result DSP_ReadPipeIfPossible(u32 channel,u32 peer, u8 const *buffer, u16 length, u16* length_read);
Result DSP_ReadPipeIfPossible(u32 channel, u32 peer, void* buffer, u16 length, u16* length_read);
/**
* @param channel unknown. Usually 2
* @param buffer The message to send to the DSP process
* @param length Length of the message
*/
Result DSP_WriteProcessPipe(u32 channel,u8 const* buffer,u32 length);
Result DSP_WriteProcessPipe(u32 channel, const void* buffer, u32 length);
///Converts a DSP memory to a virtual address usable by the process
Result DSP_ConvertProcessAddressFromDspDram(u32 dsp_address, u32 *arm_address);
Result DSP_ConvertProcessAddressFromDspDram(u32 dsp_address, u32* arm_address);
/**
* @brief Reads a DSP register
* @param regNo Offset of the hardware register, base address is 0x1EC40000
*/
Result DSP_RecvData(u16 regNo, u16 * value);
Result DSP_RecvData(u16 regNo, u16* value);
/**
* @brief Checks if you can read a DSP register
@ -121,7 +120,7 @@ Result DSP_RecvData(u16 regNo, u16 * value);
*
* @warning This call might hang if the data is not ready. See @ref DSP_SendDataIsEmpty.
*/
Result DSP_RecvDataIsReady(u16 regNo, bool * is_ready);
Result DSP_RecvDataIsReady(u16 regNo, bool* is_ready);
/**
* @brief Writes to a DSP register
@ -135,4 +134,4 @@ Result DSP_SendData(u16 regNo, u16 value);
* @brief Checks if you can write to a DSP register ?
* @param regNo Offset of the hardware register, base address is 0x1EC40000
*/
Result DSP_SendDataIsEmpty(u16 regNo, bool * is_empty);
Result DSP_SendDataIsEmpty(u16 regNo, bool* is_empty);

View File

@ -6,7 +6,6 @@
static Handle dspHandle = 0;
Result dspInit(void)
{
Result ret = 0;
@ -22,7 +21,7 @@ Result dspInit(void)
Result dspExit(void)
{
Result ret = 0;
//No need to call unload, it will be done automatically by closing the handle
//No need to call unload, it will be done automatically by closing the handle
if (dspHandle != 0)
{
ret = svcCloseHandle(dspHandle);
@ -33,7 +32,6 @@ Result dspExit(void)
return 0;
}
Result DSP_GetHeadphoneStatus(bool* is_inserted)
{
Result ret = 0;
@ -44,13 +42,12 @@ Result DSP_GetHeadphoneStatus(bool* is_inserted)
return cmdbuf[1];
}
Result DSP_FlushDataCache(u32 address, u32 size)
Result DSP_FlushDataCache(const void* address, u32 size)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x13,2,2);
cmdbuf[1] = address;
cmdbuf[1] = (u32)address;
cmdbuf[2] = size;
cmdbuf[3] = IPC_Desc_SharedHandles(1);
cmdbuf[4] = CUR_PROCESS_HANDLE;
@ -58,13 +55,12 @@ Result DSP_FlushDataCache(u32 address, u32 size)
return cmdbuf[1];
}
Result DSP_InvalidateDataCache(u32 address, u32 size)
Result DSP_InvalidateDataCache(const void* address, u32 size)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x14,2,2);
cmdbuf[1] = address;
cmdbuf[1] = (u32)address;
cmdbuf[2] = size;
cmdbuf[3] = IPC_Desc_SharedHandles(1);
cmdbuf[4] = CUR_PROCESS_HANDLE;
@ -72,8 +68,6 @@ Result DSP_InvalidateDataCache(u32 address, u32 size)
return cmdbuf[1];
}
Result DSP_SetSemaphore(u16 value)
{
Result ret = 0;
@ -84,8 +78,6 @@ Result DSP_SetSemaphore(u16 value)
return cmdbuf[1];
}
Result DSP_SetSemaphoreMask(u16 mask)
{
Result ret = 0;
@ -106,7 +98,7 @@ Result DSP_GetSemaphoreHandle(Handle* semaphore)
return cmdbuf[1];
}
Result DSP_LoadComponent(u8 const* component,u32 size,u16 prog_mask,u16 data_mask,bool * is_loaded)
Result DSP_LoadComponent(const void* component, u32 size, u16 prog_mask, u16 data_mask, bool* is_loaded)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
@ -121,8 +113,6 @@ Result DSP_LoadComponent(u8 const* component,u32 size,u16 prog_mask,u16 data_mas
return cmdbuf[1];
}
Result DSP_UnloadComponent(void)
{
Result ret = 0;
@ -145,8 +135,7 @@ Result DSP_RegisterInterruptEvents(Handle handle, u32 interrupt, u32 channel)
return cmdbuf[1];
}
Result DSP_ReadPipeIfPossible(u32 channel,u32 peer, u8 const *buffer, u16 length, u16* length_read)
Result DSP_ReadPipeIfPossible(u32 channel, u32 peer, void* buffer, u16 length, u16* length_read)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
@ -168,11 +157,12 @@ Result DSP_ReadPipeIfPossible(u32 channel,u32 peer, u8 const *buffer, u16 length
staticbufs[0] = saved1;
staticbufs[1] = saved2;
if (length_read)
*length_read = cmdbuf[2] & 0xFFFF;
return cmdbuf[1];
}
Result DSP_WriteProcessPipe(u32 channel, u8 const *buffer, u32 length)
Result DSP_WriteProcessPipe(u32 channel, const void* buffer, u32 length)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
@ -180,12 +170,12 @@ Result DSP_WriteProcessPipe(u32 channel, u8 const *buffer, u32 length)
cmdbuf[1] = channel;
cmdbuf[2] = length;
cmdbuf[3] = IPC_Desc_StaticBuffer(length,1);
cmdbuf[4] = (u32) buffer;
cmdbuf[4] = (u32)buffer;
if ((ret = svcSendSyncRequest(dspHandle)) != 0) return ret;
return cmdbuf[1];
}
Result DSP_ConvertProcessAddressFromDspDram(u32 dsp_address, u32 *arm_address)
Result DSP_ConvertProcessAddressFromDspDram(u32 dsp_address, u32* arm_address)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
@ -196,18 +186,18 @@ Result DSP_ConvertProcessAddressFromDspDram(u32 dsp_address, u32 *arm_address)
return cmdbuf[1];
}
Result DSP_RecvData(u16 regNo, u16 * value)
Result DSP_RecvData(u16 regNo, u16* value)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x1,1,0) ;
cmdbuf[0] = IPC_MakeHeader(0x1,1,0);
cmdbuf[1] = regNo;
if ((ret = svcSendSyncRequest(dspHandle)) != 0) return ret;
*value = cmdbuf[2] & 0xFFFF;
return cmdbuf[1];
}
Result DSP_RecvDataIsReady(u16 regNo, bool * is_ready)
Result DSP_RecvDataIsReady(u16 regNo, bool* is_ready)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
@ -218,7 +208,6 @@ Result DSP_RecvDataIsReady(u16 regNo, bool * is_ready)
return cmdbuf[1];
}
// Writes data to the reg regNo
// *(_WORD *)(8 * regNo + 0x1ED03024) = value
Result DSP_SendData(u16 regNo, u16 value)
@ -232,7 +221,7 @@ Result DSP_SendData(u16 regNo, u16 value)
return cmdbuf[1];
}
Result DSP_SendDataIsEmpty(u16 regNo, bool * is_empty)
Result DSP_SendDataIsEmpty(u16 regNo, bool* is_empty)
{
Result ret = 0;
u32* cmdbuf = getThreadCommandBuffer();
@ -242,4 +231,3 @@ Result DSP_SendDataIsEmpty(u16 regNo, bool * is_empty)
*is_empty = cmdbuf[2] & 0xFF;
return cmdbuf[1];
}