From: Kyle Hale Date: Mon, 22 Dec 2014 22:21:33 +0000 (-0600) Subject: Missing user space library X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=fd8ffc465479e68f4938f85b718a9fb35d05bee0 Missing user space library --- diff --git a/linux_usr/v3_io_chan.c b/linux_usr/v3_io_chan.c new file mode 100644 index 0000000..35630ea --- /dev/null +++ b/linux_usr/v3_io_chan.c @@ -0,0 +1,84 @@ +#define __V3_PAL_SIDE__ +#include +#include +#include +#include +#include +#include +#include + +#define __V3_PAL_SIDE__ + +// These two will be included in the library +#include "v3_io_chan.h" +#include "v3_user_host_dev.h" + + +int +v3_get_ioreq (v3_io_chan_handle_t chan, pal_ioreq_t ** req) +{ + return v3_user_host_dev_pull_request(chan, req); +} + + +int +v3_push_ioresp (v3_io_chan_handle_t chan, pal_ioresp_t * resp) +{ + return v3_user_host_dev_push_response(chan, resp); +} + + +v3_io_chan_handle_t +v3_io_chan_open (char * url, char * vmdev) +{ + return v3_user_host_dev_rendezvous(vmdev, url); +} + + +void +v3_io_chan_close (v3_io_chan_handle_t chan) +{ + v3_user_host_dev_depart(chan); +} + + +int +v3_raise_pal_irq (v3_io_chan_handle_t chan, uint8_t irq) +{ + return v3_user_host_dev_raise_irq(chan, irq); +} + + +int +v3_lower_pal_irq (v3_io_chan_handle_t chan, uint8_t irq) +{ + return v3_user_host_dev_lower_irq(chan, irq); +} + + +uint64_t +v3_read_guest_mem (v3_io_chan_handle_t chan, void *gpa, void * dest, uint64_t len){ + return v3_user_host_dev_read_guest_mem(chan, gpa, dest, len); +} + + +uint64_t +v3_write_guest_mem (v3_io_chan_handle_t chan, void *gpa, void *src, uint64_t len) +{ + return v3_user_host_dev_write_guest_mem(chan, gpa, src, len); +} + + +int +v3_has_ioreq (v3_io_chan_handle_t chan) +{ + return v3_user_host_dev_have_request(chan); +} + + +void +v3_free_req_resp (pal_ioreq_t * reqresp) +{ + free(reqresp); +} + diff --git a/linux_usr/v3_io_chan.h b/linux_usr/v3_io_chan.h new file mode 100644 index 0000000..9260b65 --- /dev/null +++ b/linux_usr/v3_io_chan.h @@ -0,0 +1,59 @@ +#ifndef __V3_IO_CHAN_H__ +#define __V3_IO_CHAN_H__ + +#ifndef __V3_PAL_SIDE__ +#include +#define PALACIOS_HOST_DEV_USER_REQUEST_READ_GUEST 1 +#define PALACIOS_HOST_DEV_USER_REQUEST_WRITE_GUEST 2 +#define PALACIOS_HOST_DEV_USER_REQUEST_IRQ_GUEST 3 + +#define PALACIOS_HOST_DEV_HOST_REQUEST_READ_IO 1 +#define PALACIOS_HOST_DEV_HOST_REQUEST_WRITE_IO 2 +#define PALACIOS_HOST_DEV_HOST_REQUEST_READ_MEM 3 +#define PALACIOS_HOST_DEV_HOST_REQUEST_WRITE_MEM 4 +#define PALACIOS_HOST_DEV_HOST_REQUEST_READ_CONF 5 +#define PALACIOS_HOST_DEV_HOST_REQUEST_WRITE_CONF 6 + +struct palacios_host_dev_user_op { + uint32_t type; // type of operation (from the #defs above) + void *gpa; // physical address in guest to read or write + void *data; // user address of data that will be read or written + uint64_t len; // number of bytes to move + uint8_t irq; // irq to inject +}; + + +struct palacios_host_dev_host_request_response { + // data_len must remain the first field in this structure + uint64_t data_len; // size of the structure + occupied data + uint64_t len; // size of the structure in total + uint32_t type; // one of the types given above + uint16_t port; // port number, for IO + void *gpa; // physical address in the guest for memory ops + uint64_t conf_addr; // address in the configuration for configuration ops + + uint64_t op_len; // response: bytes read/written to the device + // request: bytes to read/write + + uint8_t data[0]; // data (if any) + +}; +#endif + +typedef struct palacios_host_dev_host_request_response pal_ioreq_t; +typedef struct palacios_host_dev_host_request_response pal_ioresp_t; + +typedef long v3_io_chan_handle_t; + +v3_io_chan_handle_t v3_io_chan_open (char * url, char * vmdev); +int v3_has_ioreq (v3_io_chan_handle_t chan); +void v3_io_chan_close(v3_io_chan_handle_t chan); +int v3_get_ioreq (v3_io_chan_handle_t chan, pal_ioresp_t ** req); +int v3_push_ioresp (v3_io_chan_handle_t chan, pal_ioresp_t * resp); +int v3_raise_pal_irq (v3_io_chan_handle_t chan, uint8_t irq); +int v3_lower_pal_irq (v3_io_chan_handle_t chan, uint8_t irq); +void v3_free_req_resp (pal_ioreq_t * reqresp); +uint64_t v3_read_guest_mem(v3_io_chan_handle_t chan, void *gpa, void * dest, uint64_t len); +uint64_t v3_write_guest_mem(v3_io_chan_handle_t chan, void *gpa, void *src, uint64_t len); + +#endif