mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
return value memory mappings, work in progress
This commit is contained in:
parent
ba8fea704f
commit
26691d555d
4 changed files with 38 additions and 21 deletions
30
kernel/ibv.c
30
kernel/ibv.c
|
@ -40,21 +40,37 @@ typedef struct {
|
|||
// In:
|
||||
int *num_devices;
|
||||
// Out:
|
||||
/*struct ibv_device **ret;*/
|
||||
struct ibv_device devices[MAX_NUM_OF_IBV_DEVICES];
|
||||
/*struct ibv_device devices[MAX_NUM_OF_IBV_DEVICES];*/
|
||||
struct ibv_device **device_list;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_list_t;
|
||||
|
||||
struct ibv_device** h_ibv_get_device_list(int *num_devices)
|
||||
{
|
||||
uhyve_ibv_get_device_list_t uhyve_args = {(int*) virt_to_phys((size_t) num_devices)};
|
||||
/*(struct ibv_device*) virt_to_phys((size_t) devices)};*/
|
||||
&uhyve_args.devices = (struct ibv_device*) virt_to_phys((size_t) uhyve_args.devices);
|
||||
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned)virt_to_phys((size_t)&uhyve_args));
|
||||
return &uhyve_args.devices;
|
||||
|
||||
// TODO: proxy implementation
|
||||
struct ibv_device **list;
|
||||
struct ibv_device *devs;
|
||||
list = calloc(MAX_NUM_OF_IBV_DEVICES, sizeof(struct ibv_device *)); // NUM + 1 ???
|
||||
devs = calloc(MAX_NUM_OF_IBV_DEVICES, sizeof(struct ibv_device));
|
||||
for (int i = 0; i < MAX_NUM_OF_IBV_DEVICES; i++) {
|
||||
list[i] = devs + i * sizeof(struct ibv_device)
|
||||
/*list[i] = calloc(1, sizeof(struct ibv_device));*/
|
||||
}
|
||||
uhyve_args.first_device = (struct ibv_device*) virt_to_phys((size_t) dev_arr);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned)virt_to_phys((size_t)&uhyve_args));
|
||||
return &dev_arr;
|
||||
}
|
||||
|
||||
/*void h_ibv_get_device_list(int *num_devices)*/
|
||||
/*{*/
|
||||
/*uhyve_ibv_get_device_list_t uhyve_args = {(int*) virt_to_phys((size_t) num_devices)};*/
|
||||
/*uhyve_args.first_device = (struct ibv_device*) virt_to_phys((size_t) uhyve_args.devices);*/
|
||||
/*[>&uhyve_args.devices = (struct ibv_device*) virt_to_phys((size_t) uhyve_args.devices);<]*/
|
||||
|
||||
/*uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned)virt_to_phys((size_t)&uhyve_args));*/
|
||||
/*}*/
|
||||
|
||||
|
||||
typedef struct {
|
||||
struct ibv_device *device;
|
||||
|
|
|
@ -32,7 +32,8 @@ typedef struct {
|
|||
// In:
|
||||
int *num_devices;
|
||||
// Out:
|
||||
struct ibv_device devices[MAX_NUM_OF_IBV_DEVICES];
|
||||
//struct ibv_device devices[MAX_NUM_OF_IBV_DEVICES];
|
||||
struct ibv_device **device_list;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_list_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -974,20 +974,20 @@ static int vcpu_loop(void)
|
|||
|
||||
int num_devices;
|
||||
struct ibv_device **temp_dev_list = ibv_get_device_list(&num_devices);
|
||||
|
||||
printf("uhyve.c: before memcpy num_devices.\nGuest mem value: %p\n", guest_mem);
|
||||
/*uhyve_read->ret = read(uhyve_read->fd, guest_mem+(size_t)uhyve_read->buf, uhyve_read->len);*/
|
||||
/*struct ibv_device **temp_dev_list = ibv_get_device_list(guest_mem+(size_t)args->num_devices);*/
|
||||
printf("uhyve.c: before memcpy num_devices.\n");
|
||||
memcpy(guest_mem+(size_t)args->num_devices, &num_devices, sizeof(num_devices));
|
||||
/*memcpy(args->num_devices, &num_devices, sizeof(num_devices));*/
|
||||
|
||||
/*printf("uhyve.c: before for loop.\n");*/
|
||||
/*for (int d = 0; d < 1; d++) {*/
|
||||
/*printf("uhyve.c: for loop: before dev ptr definition.\n");*/
|
||||
/*[>struct ibv_device* dest_device_guest = guest_mem + (size_t)args->devices + d*sizeof(struct ibv_device);<]*/
|
||||
/*printf("uhyve.c: device name: %s\n", temp_dev_list[d]->name);*/
|
||||
/*printf("uhyve.c: for loop: before memcpy device struct.\n args->devices val: %s\n", args->devices);*/
|
||||
/*memcpy(args->devices, temp_dev_list[d], sizeof(struct ibv_device));*/
|
||||
/*}*/
|
||||
printf("uhyve.c: before for loop.\n");
|
||||
for (int d = 0; d < 1; d++) { // TODO switch to num devices
|
||||
printf("uhyve.c: for loop: before dev ptr definition.\n");
|
||||
/*struct ibv_device* dest_device_guest = guest_mem + (size_t)args->first_device + d*sizeof(struct ibv_device);*/
|
||||
struct ibv_device* dest_device_guest = guest_mem + (size_t)args->first_device;
|
||||
printf("uhyve.c: device name: %s\n", temp_dev_list[d]->name);
|
||||
printf("uhyve.c: for loop: before memcpy device struct.\n args->devices val: %s\n", args->devices);
|
||||
memcpy(dest_device_guest, temp_dev_list[d], sizeof(struct ibv_device));
|
||||
}
|
||||
|
||||
/*memcpy(uhyve_netinfo->mac_str, uhyve_get_mac(), 18);*/
|
||||
/*memcpy(args->ret, ibv_get_device_list((int*)(guest_mem+(size_t)args->num_devices)), 18);*/
|
||||
|
|
|
@ -57,14 +57,14 @@ int main(int argc, char** argv)
|
|||
h_ibv_get_device_list(&num_devices);
|
||||
printf("after get dev list.\n");
|
||||
|
||||
printf("num devices: %s\n", num_devices);
|
||||
printf("num devices: %d\n", num_devices);
|
||||
/*printf("first device name: %s\n", (*dev_list)->name);*/
|
||||
|
||||
/*if (!dev_list) {*/
|
||||
/*perror("Failed to get IB devices list");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
printf("after dev list check.\n");
|
||||
/*printf("after dev list check.\n");*/
|
||||
|
||||
/*const char* dev_name = h_ibv_get_device_name(dev_list[0]);*/
|
||||
/*printf("after get device name.\n");*/
|
||||
|
|
Loading…
Add table
Reference in a new issue