int nmppsFFT512InvInitAlloc(NmppsFFTSpec** spec, const void* src,const void* dst, int settings) { struct aura_buffer *iobuf_src = aura_buffer_request(n, 512*8); struct aura_buffer *iobuf_dst = aura_buffer_request(n, 512*8); struct aura_buffer *retbuf; int ret = aura_call(n, "nmppsFFT512InvInitAlloc", &retbuf, iobuf_src, iobuf_dst, settings); if (ret != 0) { slog(0, SLOG_ERROR, "call failed, reason: %d\n", ret); BUG(n, "Call nmppsFFT512InvInitAlloc failed!"); } *spec = (NmppsFFTSpec*) aura_buffer_get_u32(retbuf); ret = aura_buffer_get_u32(retbuf); aura_buffer_release( iobuf_src); aura_buffer_release( iobuf_dst); aura_buffer_release( retbuf); slog(3, SLOG_INFO, "ARM: Call nmppsFFT512InvInitAlloc -ok"); return ret; }
int nmppsCmpNeC_8s8um (const nm8s* src, int8b nCmpVal, nm8u* dst, int size, struct NmppsTmpSpec* spec) { int ret; struct aura_buffer *iobuf_src = aura_buffer_request(n, size*1); struct aura_buffer *iobuf_dst = aura_buffer_request(n, size*1); memcpy(iobuf_src->data,src,size*1); struct aura_buffer *retbuf; ret = aura_call(n, "nmppsCmpNeC_8s8um", &retbuf, iobuf_src, nCmpVal, iobuf_dst, size); if (ret != 0) { BUG(n, "Call:nmppsCmpNeC_8s8um failed!"); } memcpy(dst,iobuf_dst->data,size); aura_buffer_release( iobuf_dst); aura_buffer_release( iobuf_src); aura_buffer_release( retbuf); slog(3, SLOG_INFO, "ARM: Call nmppsCmpNeC_8s8um -ok"); return 0; }
void nmppsFFT512Inv(const nm32sc* src, nm32sc* dst, const NmppsFFTSpec* spec) { int ret; int size=512; int k=8; struct aura_buffer *iobuf_src = aura_buffer_request(n, size*k); struct aura_buffer *iobuf_dst = aura_buffer_request(n, size*k); memcpy(iobuf_src->data,src,size*k); struct aura_buffer *retbuf; ret = aura_call(n, "nmppsFFT512Inv", &retbuf, iobuf_src, iobuf_dst, spec); if (ret != 0) { slog(0, SLOG_ERROR, "call nmppsFFT512Inv failed, reason: %d\n", ret); BUG(n, "Call nmppsFFT512Inv failed!"); } memcpy(dst,iobuf_dst->data,size*k); aura_buffer_release( iobuf_dst); aura_buffer_release( iobuf_src); aura_buffer_release( retbuf); slog(3, SLOG_INFO, "ARM: Call nmppsFFT512Inv -ok"); }
long run_second(struct aura_node *n) { struct aura_buffer *buf; long start = current_time(); int i; for (i=0; i<90000; i++) { buf = aura_buffer_request(n, (rand() % 512) + 1); aura_buffer_release(buf); } return current_time() - start; }
int nmppsMax_16sm (const nm16s* src, int size, int16b* pMaxValue, nm32s* tmp) { int ret; struct aura_buffer *iobuf_src = aura_buffer_request(n, size*2); memcpy(iobuf_src->data,src,size*2); struct aura_buffer *retbuf; ret = aura_call(n, "nmppsMax_16sm", &retbuf, iobuf_src, size); if (ret != 0) { BUG(n, "Call:nmppsMax_16sm failed!"); } *pMaxValue = aura_buffer_get_u32(retbuf); ret = aura_buffer_get_u32(retbuf); aura_buffer_release( iobuf_src); aura_buffer_release( retbuf); slog(3, SLOG_INFO, "ARM: Call nmppsMax_16sm -ok"); return ret; }
static void submit_event_readout(struct aura_node *node) { struct usb_dev_info *inf = aura_get_transportdata(node); struct aura_buffer *buf = aura_buffer_request(node, inf->io_buf_size); if (!buf) return; /* Nothing bad, we'll try again later */ slog(0, SLOG_DEBUG, "Starting evt readout, max %d bytes, pending %d", inf->io_buf_size, inf->pending); libusb_fill_control_setup((unsigned char *)buf->data, LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_IN, RQ_GET_EVENT, 0, 0, buf->size - LIBUSB_CONTROL_SETUP_SIZE); libusb_fill_control_transfer(inf->ctransfer, inf->handle, (unsigned char *)buf->data, cb_event_readout_done, node, 1500); inf->current_buffer = buf; submit_control(node); }
void test_buf(struct aura_node *n) { int ret; struct aura_buffer *retbuf; struct aura_buffer *iobuf = aura_buffer_request(n, 80); uint32_t test = 0xdeadf00d; memcpy(iobuf->data, &test, sizeof(test)); ret = aura_call(n, "echo_buf", &retbuf, iobuf); slog(0, SLOG_DEBUG, "call ret %d", ret); if (ret) BUG(n, "call failed"); struct aura_buffer *tmp = aura_buffer_get_buf(retbuf); if (tmp != iobuf) BUG(n, "test not ok"); aura_buffer_release(n, retbuf); aura_buffer_release(n, tmp); slog(0, SLOG_INFO, "BUF test passed"); }
int main() { slog_init(NULL, 18); int ret; struct aura_node *n = aura_open("dummy", NULL); struct aura_buffer *retbuf; struct aura_buffer *iobuf = aura_buffer_request(n, 80); ret = aura_call(n, "echo_buf", &retbuf, iobuf); slog(0, SLOG_DEBUG, "call ret %d", ret); if (ret) BUG(n, "call failed"); struct aura_buffer *tmp = aura_buffer_get_buf(retbuf); if (tmp != iobuf) BUG(n, "test not ok"); aura_buffer_release(n, retbuf); aura_buffer_release(n, tmp); aura_close(n); return 0; }
static struct aura_buffer *lua_to_buffer(lua_State *L, struct aura_node *node, int stackpos, struct aura_object *o) { int i; struct aura_buffer *buf; const char *fmt; fmt = o->arg_fmt; if (lua_gettop(L) - stackpos + 1 != o->num_args) { slog(0, SLOG_ERROR, "Invalid argument count for %s: %d / %d", o->name, lua_gettop(L) - stackpos, o->num_args); return NULL; } buf = aura_buffer_request(node, o->arglen); if (!buf) { slog(0, SLOG_ERROR, "Epic fail during buffer allocation"); return NULL; } /* Let's serialize the data, arguments are on the stack, * Starting from #3. */ for (i = stackpos; i <= lua_gettop(L); i++) { double tmp; switch (*fmt++) { case URPC_U8: tmp = lua_tonumber(L, i); aura_buffer_put_u8(buf, tmp); break; case URPC_S8: tmp = lua_tonumber(L, i); aura_buffer_put_s8(buf, tmp); break; case URPC_U16: tmp = lua_tonumber(L, i); aura_buffer_put_u16(buf, (uint16_t)tmp); break; case URPC_S16: tmp = lua_tonumber(L, i); aura_buffer_put_s16(buf, tmp); break; case URPC_U32: tmp = lua_tonumber(L, i); aura_buffer_put_u32(buf, tmp); break; case URPC_S32: tmp = lua_tonumber(L, i); aura_buffer_put_s32(buf, tmp); break; case URPC_S64: tmp = lua_tonumber(L, i); aura_buffer_put_s64(buf, tmp); break; case URPC_U64: tmp = lua_tonumber(L, i); aura_buffer_put_u64(buf, tmp); break; /* Binary is the tricky part. String or usata? */ case URPC_BIN: { const char *srcbuf = NULL; int len = 0; int blen; if (lua_isstring(L, i)) { srcbuf = lua_tostring(L, i); len = strlen(srcbuf); } else if (lua_isuserdata(L, i)) { srcbuf = lua_touserdata(L, i); } blen = atoi(fmt); if (blen == 0) { slog(0, SLOG_ERROR, "Internal serilizer bug processing: %s", fmt); goto err; } if (!srcbuf) { slog(0, SLOG_ERROR, "Internal bug fetching src pointer"); goto err; } if (blen < len) len = blen; aura_buffer_put_bin(buf, srcbuf, len); while (*fmt && (*fmt++ != '.')); break; } default: BUG(node, "Unknown token: %c\n", *(--fmt)); break; } } return buf; err: aura_buffer_release(buf); return NULL; }