PrintDebug("SYMMOD: VIRTIO SYMMOD Kick on loader queue\n");
- while (q->cur_avail_idx < q->avail->index) {
+ while (q->cur_avail_idx != q->avail->index) {
struct vring_desc * hdr_desc = NULL;
struct vring_desc * buf_desc = NULL;
struct vring_desc * status_desc = NULL;
return -1;
}
- memcpy(buf, module->data + offset, buf_desc->length);
+ memcpy(buf, module->start_addr + offset, buf_desc->length);
+ PrintDebug("Copying module to virtio buffers: SRC=%p, DST=%p, len=%d\n",
+ (void *)(module->start_addr + offset), (void *)buf, buf_desc->length);
if (tmp_status != 0) {
PrintError("Error loading module segment\n");
xfer_len += status_desc->length;
*status_ptr = status;
+ PrintDebug("Transferred %d bytes (xfer_len)\n", xfer_len);
q->used->ring[q->used->index % QUEUE_SIZE].id = q->avail->ring[q->cur_avail_idx % QUEUE_SIZE];
q->used->ring[q->used->index % QUEUE_SIZE].length = xfer_len; // set to total inbound xfer length
-static int virtio_load_module(struct v3_vm_info * vm, char * name, int mod_size, void * priv_data) {
+static int virtio_load_module(struct v3_vm_info * vm, struct v3_sym_module * mod, void * priv_data) {
struct virtio_sym_state * virtio = (struct virtio_sym_state *)priv_data;
// struct virtio_queue * q = virtio->cur_queue;
struct virtio_queue * q = &(virtio->queue[NOTIFY_QUEUE]);
+ uint32_t mod_size = mod->end_addr - mod->start_addr;
- if (strlen(name) >= 32) {
- PrintError("Module name is too long... (%d bytes) limit is 32\n", (uint32_t)strlen(name));
+ if (strlen(mod->name) >= 32) {
+ PrintError("Module name is too long... (%d bytes) limit is 32\n", (uint32_t)strlen(mod->name));
return -1;
}
}
- if (q->cur_avail_idx < q->avail->index) {
+ if (q->cur_avail_idx != q->avail->index) {
uint16_t notifier_idx = q->avail->ring[q->cur_avail_idx % q->queue_size];
struct symmod_hdr * notifier = NULL;
struct vring_desc * notifier_desc = NULL;
memset(notifier, 0, sizeof(struct symmod_hdr));
// set the module name
- memcpy(notifier->name, name, strlen(name));
+ memcpy(notifier->name, mod->name, strlen(mod->name));
// set module length
notifier->num_bytes = mod_size;