#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;
///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
*
* 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
*
* 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);
* @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);
*
* @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
* @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
*
* @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
* @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);
static Handle dspHandle = 0;
-
Result dspInit(void)
{
Result ret = 0;
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);
return 0;
}
-
Result DSP_GetHeadphoneStatus(bool* is_inserted)
{
Result ret = 0;
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;
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;
return cmdbuf[1];
}
-
-
Result DSP_SetSemaphore(u16 value)
{
Result ret = 0;
return cmdbuf[1];
}
-
-
Result DSP_SetSemaphoreMask(u16 mask)
{
Result ret = 0;
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();
return cmdbuf[1];
}
-
-
Result DSP_UnloadComponent(void)
{
Result ret = 0;
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();
staticbufs[0] = saved1;
staticbufs[1] = saved2;
- *length_read = cmdbuf[2] & 0xFFFF;
+ 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();
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();
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();
return cmdbuf[1];
}
-
// Writes data to the reg regNo
// *(_WORD *)(8 * regNo + 0x1ED03024) = value
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();
*is_empty = cmdbuf[2] & 0xFF;
return cmdbuf[1];
}
-