//Pascal &or the FreePascal use of nintendo 2ds, 3ds regime // // Copyright (c) 2013, 2015, 2017 Kenneth Dwayne Lee Bsc. // all rights reserved // type DSP_InterruptType = (DSP_INTERRUPT_PIPE := 2); {/ DSP pipe directions. } {/< DSP to ARM } {/< ARM to DSP } DSP_PipeDirection = (DSP_PIPE_INPUT := 0,DSP_PIPE_OUTPUT := 1); {* * @brief Initializes the dsp service. * * Call this before calling any DSP_* function. * @note This will also unload any previously loaded DSP binary. * It is done this way since you have to provide your binary when the 3DS leaves sleep mode anyway. } function dspInit:s32;cdecl;external; {* * @brief Closes the dsp service. * @note This will also unload the DSP binary. } procedure dspExit;cdecl;external; {* * @brief Checks if a headphone is inserted. * @param is_inserted Pointer to output the insertion status to. } function DSP_GetHeadphoneStatus(is_inserted:Pbool):s32;cdecl;external; {* * @brief Flushes the cache * @param address Beginning of the memory range to flush, inside the Linear or DSP memory regions * @param size Size of the memory range to flush * * Flushes the cache for the specified memory range and invalidates the cache } (* Const before type ignored *) function DSP_FlushDataCache(address:pointer; size:u32):s32;cdecl;external; {* * @brief Invalidates the cache * @param address Beginning of the memory range to invalidate, inside the Linear or DSP memory regions * @param size Size of the memory range to flush * * Invalidates the cache for the specified memory range } (* Const before type ignored *) function DSP_InvalidateDataCache(address:pointer; size:u32):s32;cdecl;external; {* * @brief Retrieves the handle of the DSP semaphore. * @param semaphore Pointer to output the semaphore to. } function DSP_GetSemaphoreHandle(semaphore:PHandle):s32;cdecl;external; {* * @brief Sets the DSP hardware semaphore value. * @param value Value to set. } function DSP_SetSemaphore(value:u16):s32;cdecl;external; {* * @brief Masks the DSP hardware semaphore value. * @param mask Mask to apply. } function DSP_SetSemaphoreMask(mask:u16):s32;cdecl;external; {* * @brief Loads a DSP binary and starts the DSP * @param component The program file address in memory * @param size The size of the program * @param prog_mask DSP memory block related ? Default is 0xff. * @param data_mask DSP memory block related ? Default is 0xff. * @param is_loaded Indicates if the DSP was succesfully loaded. * * @note The binary must be signed (http://3dbrew.org/wiki/DSP_Binary) * @note Seems to be called when the 3ds leaves the Sleep mode } (* Const before type ignored *) function DSP_LoadComponent(component:pointer; size:u32; prog_mask:u16; data_mask:u16; is_loaded:Pbool):s32;cdecl;external; {/Stops the DSP by unloading the binary. } function DSP_UnloadComponent:s32;cdecl;external; {* * @brief Registers an event handle with the DSP through IPC * @param handle Event handle to register. * @param interrupt The type of interrupt that will trigger the event. Usual value is DSP_INTERRUPT_PIPE. * @param channel The pipe channel. Usual value is 2 * * @note It is possible that interrupt are inverted } function DSP_RegisterInterruptEvents(handle:Handle; interrupt:u32; channel:u32):s32;cdecl;external; {* * @brief Reads a pipe if possible. * @param channel unknown. Usually 2 * @param peer unknown. Usually 0 * @param buffer The buffer that will store the values read from the pipe * @param length Length of the buffer * @param length_read Number of bytes read by the command } function DSP_ReadPipeIfPossible(channel:u32; peer:u32; buffer:pointer; length:u16; length_read:Pu16):s32;cdecl;external; {* * @param Writes to a pipe. * @param channel unknown. Usually 2 * @param buffer The message to send to the DSP process * @param length Length of the message } (* Const before type ignored *) function DSP_WriteProcessPipe(channel:u32; buffer:pointer; length:u32):s32;cdecl;external; {* * @brief Converts a DSP memory address to a virtual address usable by the process. * @param dsp_address Address to convert. * @param arm_address Pointer to output the converted address to. } function DSP_ConvertProcessAddressFromDspDram(dsp_address:u32; arm_address:Pu32):s32;cdecl;external; {* * @brief Reads a DSP register * @param regNo Offset of the hardware register, base address is 0x1EC40000 * @param value Pointer to read the register value to. } function DSP_RecvData(regNo:u16; value:Pu16):s32;cdecl;external; {* * @brief Checks if you can read a DSP register * @param regNo Offset of the hardware register, base address is 0x1EC40000 * @param is_ready Pointer to write the ready status to. * * @warning This call might hang if the data is not ready. See @ref DSP_SendDataIsEmpty. } function DSP_RecvDataIsReady(regNo:u16; is_ready:Pbool):s32;cdecl;external; {* * @brief Writes to a DSP register * @param regNo Offset of the hardware register, base address is 0x1EC40000 * @param value Value to write. * * @warning This call might hang if the SendData is not empty. See @ref DSP_SendDataIsEmpty. } function DSP_SendData(regNo:u16; value:u16):s32;cdecl;external; {* * @brief Checks if you can write to a DSP register ? * @param regNo Offset of the hardware register, base address is 0x1EC40000 * @param is_empty Pointer to write the empty status to. } function DSP_SendDataIsEmpty(regNo:u16; is_empty:Pbool):s32;cdecl;external;