hey, it's your thread
the title is generic enough for this to contain "random" DSP talk, I guess.
to make your example work, you need to do sth. likes this:
#include <stdio.h>
#include <inc_libc64.h>
#include <components/arrayutils/arrayutils.h>
/* let's assume there's an "ARRAYUTILS" component and it has a "GETMAXIMUM" function */
const unsigned int veryBig = 1<<20;
dsp_mem_region_t shm;
dsp_component_id_t compid_arrayutils;
int *bigArray;
/* Add missing fxns here (fillArrayWithRandomStufff()) */
static void __DSP64_GetMaximum_send(int *_bufAddrPhys, unsigned int _numInts) {
c64_msg_t req;
DSP_MSG_INIT(&req,
compid_arrayutils, ARRAYUTILS_CMD_GETMAXIMUM,
_bufAddrPhys, _numInts
);
/* Write back ARM caches so DSP sees actual data */
(void) dsp_cache_wb(_bufAddrPhys, _numInts * sizeof(int));
/* Send request to DSP */
(void) dsp_rpc_send(&req);
}
static int __DSP64_GetMaximum_recv(void) {
c64_msg_t reply;
(void) dsp_rpc_recv(&reply);
/* assumes that the 1st of the 2 retvals contains the error code and the
2nd one the actual result value */
return (int) reply.data[1].ret;
}
int main(int,char**) {
/* Open client connection to c64.ko kernel module */
(void) dsp_open();
/* Alloc. DSP<>GPP shared memory (should check return value) */
(void) dsp_shm_init(veryBig * sizeof(int));
/* Query physical (DSP-side) and virtual (GPP-side) addresses and size */
shm = dsp_shm_get();
/* Load arrayutils component (DSP overlay image) */
(void) dsp_component_load(NULL /*cwd*/, COMPONENT_NAME_ARRAYUTILS, &compid_arrayutils);
bigArray = (int*) shm.virt_addr;
fillArrayWithRandomStufff();
/* Send request to DSP and return immediately */
__DSP64_GetMaximum_send(shm.phys_addr /* bigArray */, veryBig);
//do other stuff like playSound();
/* Wait for DSP and pick up result */
int max = __DSP64_GetMaximum_recv();
printf("max=%d\n", max);
/* Unload DSP overlay, free shared memory, disconnect */
dsp_close();
return 0;
}
this is *almost* actual code (
did not try, it definitely misses error checking).