1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

deleted unused files

This commit is contained in:
Annika Wierichs 2018-01-31 10:43:55 +01:00
parent 21f18865c1
commit 99dbcea7f8
5 changed files with 9 additions and 439 deletions

View file

@ -1,64 +0,0 @@
/*
* Copyright (c) 2017, Annika Wierichs, RWTH Aachen University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* TODO: Documentation
*
*/
#ifndef __IBV_GUEST_HOST_H__
#define __IBV_GUEST_HOST_H__
#include <hermit/verbs.h>
extern uint8_t * host_logical_addr;
typedef enum {GUEST, HOST} addr_type;
inline size_t guest_to_host(size_t address) {
return address ? virt_to_phys(address) + (size_t) host_logical_addr : address;
}
inline size_t host_to_guest(size_t address) {
return address ? phys_to_virt(address - (size_t) host_logical_addr) : address;
}
struct ibv_device * guest_to_host_ibv_device(struct ibv_device * device);
struct ibv_context * guest_to_host_ibv_context(struct ibv_context * context);
struct ibv_context_ops * guest_to_host_ibv_context_ops(struct ibv_context_ops * context_ops);
struct ibv_port_attr * guest_to_host_ibv_port_attr(struct ibv_port_attr * port_attr);
struct ibv_comp_channel * guest_to_host_ibv_comp_channel(struct ibv_comp_channel * channel);
struct ibv_abi_compat_v2 * guest_to_host_ibv_abi_compat_v2(struct ibv_abi_compat_v2 * abi_compat);
pthread_mutex_t * guest_to_host_pthread_mutex_t(pthread_mutex_t * mutex);
struct ibv_device * host_to_guest_ibv_device(struct ibv_device * device, addr_type type);
struct ibv_context * host_to_guest_ibv_context(struct ibv_context * context, addr_type type);
struct ibv_context_ops * host_to_guest_ibv_context_ops(struct ibv_context_ops * context_ops, addr_type type);
struct ibv_port_attr * host_to_guest_ibv_port_attr(struct ibv_port_attr * port_attr, addr_type type);
struct ibv_comp_channel * host_to_guest_ibv_comp_channel(struct ibv_comp_channel * channel, addr_type type);
struct ibv_abi_compat_v2 * host_to_guest_ibv_abi_compat_v2(struct ibv_abi_compat_v2 * abi_compat, addr_type type);
pthread_mutex_t * host_to_guest_pthread_mutex_t(pthread_mutex_t * mutex, addr_type type);
#endif // __IBV_GUEST_HOST_H__

View file

@ -1,240 +0,0 @@
/*
* Copyright (c) 2017, Annika Wierichs, RWTH Aachen University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* TODO: Documentation
*
*/
#include <asm/page.h>
#include <hermit/ibv_guest_host.h>
/*
* struct ibv_device
*/
struct ibv_device * guest_to_host_ibv_device(struct ibv_device * device) {
// _ops obsolete.
return (struct ibv_device *) guest_to_host((size_t) device);
}
struct ibv_device * host_to_guest_ibv_device(struct ibv_device * device, addr_type type) {
struct ibv_device * vaddr = (type == GUEST) ? device
: (struct ibv_device *) host_to_guest((size_t) device);
return vaddr;
}
/*
* struct ibv_context
*/
struct ibv_context * guest_to_host_ibv_context(struct ibv_context * context) {
context->device = guest_to_host_ibv_device(context->device);
context->abi_compat = guest_to_host_ibv_abi_compat_v2(context->abi_compat);
guest_to_host_ibv_context_ops(&context->ops);
guest_to_host_pthread_mutex_t(&context->mutex); // TODO
return (struct ibv_context *) guest_to_host((size_t) context);
}
struct ibv_context * host_to_guest_ibv_context(struct ibv_context * context, addr_type type) {
struct ibv_context * vaddr = (type == GUEST) ? context
: (struct ibv_context *) host_to_guest((size_t) context);
vaddr->device = host_to_guest_ibv_device(vaddr->device, HOST);
vaddr->abi_compat = host_to_guest_ibv_abi_compat_v2(vaddr->abi_compat, HOST);
host_to_guest_ibv_context_ops(&vaddr->ops, GUEST);
host_to_guest_pthread_mutex_t(&vaddr->mutex, GUEST);
return vaddr;
}
/*
* struct ibv_port_attr
*/
struct ibv_port_attr * guest_to_host_ibv_port_attr(struct ibv_port_attr * port_attr) {
return (struct ibv_port_attr *) guest_to_host((size_t) port_attr);
}
struct ibv_port_attr * host_to_guest_ibv_port_attr(struct ibv_port_attr * port_attr, addr_type type) {
struct ibv_port_attr * vaddr = (type == GUEST) ? port_attr
: (struct ibv_port_attr *) host_to_guest((size_t) port_attr);
return vaddr;
}
/*
* struct ibv_comp_channel
*/
struct ibv_comp_channel * guest_to_host_ibv_comp_channel(struct ibv_comp_channel * channel) {
channel->context = guest_to_host_ibv_context(channel->context);
return (struct ibv_comp_channel *) guest_to_host((size_t) channel);
}
struct ibv_comp_channel * host_to_guest_ibv_comp_channel(struct ibv_comp_channel * channel, addr_type type) {
struct ibv_comp_channel * vaddr = (type == GUEST) ? channel
: (struct ibv_comp_channel *) host_to_guest((size_t) channel);
vaddr->context = host_to_guest_ibv_context(vaddr->context, HOST);
return vaddr;
}
/*
* struct ibv_abi_compat_v2
*/
struct ibv_abi_compat_v2 * guest_to_host_ibv_abi_compat_v2(struct ibv_abi_compat_v2 * abi_compat) {
guest_to_host_ibv_comp_channel(&abi_compat->channel);
guest_to_host_pthread_mutex_t(&abi_compat->in_use);
return (struct ibv_abi_compat_v2 *) guest_to_host((size_t) abi_compat);
}
struct ibv_abi_compat_v2 * host_to_guest_ibv_abi_compat_v2(struct ibv_abi_compat_v2 * abi_compat, addr_type type) {
struct ibv_abi_compat_v2 * vaddr = (type == GUEST) ? abi_compat
: (struct ibv_abi_compat_v2 *) host_to_guest((size_t) abi_compat);
host_to_guest_ibv_comp_channel(&abi_compat->channel, GUEST);
host_to_guest_pthread_mutex_t(&abi_compat->in_use, GUEST);
return vaddr;
}
/*
* pthread_mutex_t
*/
pthread_mutex_t * guest_to_host_pthread_mutex_t(pthread_mutex_t * mutex) {
/* mutex->__m_owner = guest_to_host__pthread_descr(mutex->__m_owner); */
return (pthread_mutex_t *) guest_to_host((size_t) mutex);
}
pthread_mutex_t * host_to_guest_pthread_mutex_t(pthread_mutex_t * mutex, addr_type type) {
pthread_mutex_t * vaddr = (type == GUEST) ? mutex
: (pthread_mutex_t *) host_to_guest((size_t) mutex);
/* host_to_guest__pthread_descr(mutex->__m_owner); */
return vaddr;
}
/*
* struct ibv_context_ops
*/
struct ibv_context_ops * guest_to_host_ibv_context_ops(struct ibv_context_ops * context_ops) {
// TODO: Does this work?
context_ops->query_device = (int (*)(struct ibv_context *, struct ibv_device_attr *)) guest_to_host((size_t) context_ops->query_device);
context_ops->query_port = (int (*)(struct ibv_context *, uint8_t, struct ibv_port_attr *)) guest_to_host((size_t) context_ops->query_port);
context_ops->alloc_pd = (struct ibv_pd * (*)(struct ibv_context *)) guest_to_host((size_t) context_ops->alloc_pd);
context_ops->dealloc_pd = (int (*)(struct ibv_pd *)) guest_to_host((size_t) context_ops->dealloc_pd);
context_ops->reg_mr = (struct ibv_mr * (*)(struct ibv_pd *, void *, size_t, int)) guest_to_host((size_t) context_ops->reg_mr);
context_ops->rereg_mr = (int (*)(struct ibv_mr *, int, struct ibv_pd *, void *, size_t, int)) guest_to_host((size_t) context_ops->rereg_mr);
context_ops->dereg_mr = (int (*)(struct ibv_mr *)) guest_to_host((size_t) context_ops->dereg_mr);
context_ops->alloc_mw = (struct ibv_mw * (*)(struct ibv_pd *, enum ibv_mw_type)) guest_to_host((size_t) context_ops->alloc_mw);
context_ops->bind_mw = (int (*)(struct ibv_qp *, struct ibv_mw *, struct ibv_mw_bind *)) guest_to_host((size_t) context_ops->bind_mw);
context_ops->dealloc_mw = (int (*)(struct ibv_mw *)) guest_to_host((size_t) context_ops->dealloc_mw);
context_ops->create_cq = (struct ibv_cq * (*)(struct ibv_context *, int, struct ibv_comp_channel *, int)) guest_to_host((size_t) context_ops->create_cq);
context_ops->poll_cq = (int (*)(struct ibv_cq *, int, struct ibv_wc *)) guest_to_host((size_t) context_ops->poll_cq);
context_ops->req_notify_cq = (int (*)(struct ibv_cq *, int)) guest_to_host((size_t) context_ops->req_notify_cq);
context_ops->cq_event = (void (*)(struct ibv_cq *)) guest_to_host((size_t) context_ops->cq_event);
context_ops->resize_cq = (int (*)(struct ibv_cq *, int)) guest_to_host((size_t) context_ops->resize_cq);
context_ops->destroy_cq = (int (*)(struct ibv_cq *)) guest_to_host((size_t) context_ops->destroy_cq);
context_ops->create_srq = (struct ibv_srq * (*)(struct ibv_pd *, struct ibv_srq_init_attr *)) guest_to_host((size_t) context_ops->create_srq);
context_ops->modify_srq = (int (*)(struct ibv_srq *, struct ibv_srq_attr *, int)) guest_to_host((size_t) context_ops->modify_srq);
context_ops->query_srq = (int (*)(struct ibv_srq *, struct ibv_srq_attr *)) guest_to_host((size_t) context_ops->query_srq);
context_ops->destroy_srq = (int (*)(struct ibv_srq *)) guest_to_host((size_t) context_ops->destroy_srq);
context_ops->post_srq_recv = (int (*)(struct ibv_srq *, struct ibv_recv_wr *, struct ibv_recv_wr **)) guest_to_host((size_t) context_ops->post_srq_recv);
context_ops->create_qp = (struct ibv_qp * (*)(struct ibv_pd *, struct ibv_qp_init_attr *)) guest_to_host((size_t) context_ops->create_qp);
context_ops->query_qp = (int (*)(struct ibv_qp *, struct ibv_qp_attr *, int, struct ibv_qp_init_attr *)) guest_to_host((size_t) context_ops->query_qp);
context_ops->modify_qp = (int (*)(struct ibv_qp *, struct ibv_qp_attr *, int)) guest_to_host((size_t) context_ops->modify_qp);
context_ops->destroy_qp = (int (*)(struct ibv_qp *)) guest_to_host((size_t) context_ops->destroy_qp);
context_ops->post_send = (int (*)(struct ibv_qp *, struct ibv_send_wr *, struct ibv_send_wr **)) guest_to_host((size_t) context_ops->post_send);
context_ops->post_recv = (int (*)(struct ibv_qp *, struct ibv_recv_wr *, struct ibv_recv_wr **)) guest_to_host((size_t) context_ops->post_recv);
context_ops->create_ah = (struct ibv_ah * (*)(struct ibv_pd *, struct ibv_ah_attr *)) guest_to_host((size_t) context_ops->create_ah);
context_ops->destroy_ah = (int (*)(struct ibv_ah *)) guest_to_host((size_t) context_ops->destroy_ah);
context_ops->attach_mcast = (int (*)(struct ibv_qp *, const union ibv_gid *, uint16_t)) guest_to_host((size_t) context_ops->attach_mcast);
context_ops->detach_mcast = (int (*)(struct ibv_qp *, const union ibv_gid *, uint16_t)) guest_to_host((size_t) context_ops->detach_mcast);
context_ops->async_event = (void (*)(struct ibv_async_event *)) guest_to_host((size_t) context_ops->async_event);
return (struct ibv_context_ops *) guest_to_host((size_t) context_ops);
}
struct ibv_context_ops * host_to_guest_ibv_context_ops(
struct ibv_context_ops * context_ops, addr_type type) {
struct ibv_context_ops * vaddr = (type == GUEST) ? context_ops
: (struct ibv_context_ops *) host_to_guest((size_t) context_ops);
vaddr->query_device = (int (*)(struct ibv_context *, struct ibv_device_attr *)) host_to_guest((size_t) vaddr->query_device);
vaddr->query_port = (int (*)(struct ibv_context *, uint8_t, struct ibv_port_attr *)) host_to_guest((size_t) vaddr->query_port);
vaddr->alloc_pd = (struct ibv_pd * (*)(struct ibv_context *)) host_to_guest((size_t) vaddr->alloc_pd);
vaddr->dealloc_pd = (int (*)(struct ibv_pd *)) host_to_guest((size_t) vaddr->dealloc_pd);
vaddr->reg_mr = (struct ibv_mr * (*)(struct ibv_pd *, void *, size_t, int)) host_to_guest((size_t) vaddr->reg_mr);
vaddr->rereg_mr = (int (*)(struct ibv_mr *, int, struct ibv_pd *, void *, size_t, int)) host_to_guest((size_t) vaddr->rereg_mr);
vaddr->dereg_mr = (int (*)(struct ibv_mr *)) host_to_guest((size_t) vaddr->dereg_mr);
vaddr->alloc_mw = (struct ibv_mw * (*)(struct ibv_pd *, enum ibv_mw_type)) host_to_guest((size_t) vaddr->alloc_mw);
vaddr->bind_mw = (int (*)(struct ibv_qp *, struct ibv_mw *, struct ibv_mw_bind *)) host_to_guest((size_t) vaddr->bind_mw);
vaddr->dealloc_mw = (int (*)(struct ibv_mw *)) host_to_guest((size_t) vaddr->dealloc_mw);
vaddr->create_cq = (struct ibv_cq * (*)(struct ibv_context *, int, struct ibv_comp_channel *, int)) host_to_guest((size_t) vaddr->create_cq);
vaddr->poll_cq = (int (*)(struct ibv_cq *, int, struct ibv_wc *)) host_to_guest((size_t) vaddr->poll_cq);
vaddr->req_notify_cq = (int (*)(struct ibv_cq *, int)) host_to_guest((size_t) vaddr->req_notify_cq);
vaddr->cq_event = (void (*)(struct ibv_cq *)) host_to_guest((size_t) vaddr->cq_event);
vaddr->resize_cq = (int (*)(struct ibv_cq *, int)) host_to_guest((size_t) vaddr->resize_cq);
vaddr->destroy_cq = (int (*)(struct ibv_cq *)) host_to_guest((size_t) vaddr->destroy_cq);
vaddr->create_srq = (struct ibv_srq * (*)(struct ibv_pd *, struct ibv_srq_init_attr *)) host_to_guest((size_t) vaddr->create_srq);
vaddr->modify_srq = (int (*)(struct ibv_srq *, struct ibv_srq_attr *, int)) host_to_guest((size_t) vaddr->modify_srq);
vaddr->query_srq = (int (*)(struct ibv_srq *, struct ibv_srq_attr *)) host_to_guest((size_t) vaddr->query_srq);
vaddr->destroy_srq = (int (*)(struct ibv_srq *)) host_to_guest((size_t) vaddr->destroy_srq);
vaddr->post_srq_recv = (int (*)(struct ibv_srq *, struct ibv_recv_wr *, struct ibv_recv_wr **)) host_to_guest((size_t) vaddr->post_srq_recv);
vaddr->create_qp = (struct ibv_qp * (*)(struct ibv_pd *, struct ibv_qp_init_attr *)) host_to_guest((size_t) vaddr->create_qp);
vaddr->query_qp = (int (*)(struct ibv_qp *, struct ibv_qp_attr *, int, struct ibv_qp_init_attr *)) host_to_guest((size_t) vaddr->query_qp);
vaddr->modify_qp = (int (*)(struct ibv_qp *, struct ibv_qp_attr *, int)) host_to_guest((size_t) vaddr->modify_qp);
vaddr->destroy_qp = (int (*)(struct ibv_qp *)) host_to_guest((size_t) vaddr->destroy_qp);
vaddr->post_send = (int (*)(struct ibv_qp *, struct ibv_send_wr *, struct ibv_send_wr **)) host_to_guest((size_t) vaddr->post_send);
vaddr->post_recv = (int (*)(struct ibv_qp *, struct ibv_recv_wr *, struct ibv_recv_wr **)) host_to_guest((size_t) vaddr->post_recv);
vaddr->create_ah = (struct ibv_ah * (*)(struct ibv_pd *, struct ibv_ah_attr *)) host_to_guest((size_t) vaddr->create_ah);
vaddr->destroy_ah = (int (*)(struct ibv_ah *)) host_to_guest((size_t) vaddr->destroy_ah);
vaddr->attach_mcast = (int (*)(struct ibv_qp *, const union ibv_gid *, uint16_t)) host_to_guest((size_t) vaddr->attach_mcast);
vaddr->detach_mcast = (int (*)(struct ibv_qp *, const union ibv_gid *, uint16_t)) host_to_guest((size_t) vaddr->detach_mcast);
vaddr->async_event = (void (*)(struct ibv_async_event *)) host_to_guest((size_t) vaddr->async_event);
return vaddr;
}

View file

@ -1,82 +0,0 @@
typedef struct {
// Parameters:
struct ibv_device * device;
// Return value:
struct ibv_context * ret;
} __attribute__((packed)) uhyve_ibv_open_device_t;
struct ibv_context * ibv_open_device(struct ibv_device * device) {
uhyve_ibv_open_device_t uhyve_args;
uhyve_args->device = (struct ibv_device *) virt_to_phys((size_t) device);
uhyve_args->ret = kmalloc(sizeof(struct ibv_context));
uhyve_send(UHYVE_PORT_IBV_OPEN_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
typedef struct {
// Parameters:
struct ibv_device * device;
// Return value:
const char * ret;
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
const char * ibv_get_device_name(struct ibv_device * device) {
uhyve_ibv_get_device_name_t uhyve_args;
uhyve_args->device = (struct ibv_device *) virt_to_phys((size_t) device);
uhyve_args->ret = kmalloc(sizeof(const char));
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_NAME, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
typedef struct {
// Parameters:
struct ibv_context * context;
uint8_t port_num;
struct ibv_port_attr * port_attr;
// Return value:
int ret;
} __attribute__((packed)) uhyve_ibv_query_port_t;
int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr) {
uhyve_ibv_query_port_t uhyve_args;
uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);
uhyve_args->port_num = port_num;
uhyve_args->port_attr = (struct ibv_port_attr *) virt_to_phys((size_t) port_attr);
uhyve_send(UHYVE_PORT_IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
typedef struct {
// Parameters:
struct ibv_context * context;
// Return value:
struct ibv_comp_channel * ret;
} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context) {
uhyve_ibv_create_comp_channel_t uhyve_args;
uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);
uhyve_args->ret = kmalloc(sizeof(struct ibv_comp_channel));
uhyve_send(UHYVE_PORT_IBV_CREATE_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}

View file

@ -1,30 +0,0 @@
typedef struct {
// Parameters:
struct ibv_device * device;
// Return value:
struct ibv_context * ret;
} __attribute__((packed)) uhyve_ibv_open_device_t;
typedef struct {
// Parameters:
struct ibv_device * device;
// Return value:
const char * ret;
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
typedef struct {
// Parameters:
struct ibv_context * context;
uint8_t port_num;
struct ibv_port_attr * port_attr;
// Return value:
int ret;
} __attribute__((packed)) uhyve_ibv_query_port_t;
typedef struct {
// Parameters:
struct ibv_context * context;
// Return value:
struct ibv_comp_channel * ret;
} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;

View file

@ -98,21 +98,19 @@ from parser import generate_struct_conversions
SRC_PATH = "function-prototypes.txt"
# Paths of the files that are generated by the script.
KERNEL_GEN_PATH = "GEN-kernel.c"
KERNEL_HEADER_GEN_PATH = "GEN-kernel-header.h"
UHYVE_CASES_GEN_PATH = "GEN-tools-uhyve.c"
KERNEL_GEN_PATH = "GEN-kernel.c"
KERNEL_HEADER_GEN_PATH = "GEN-kernel-header.h"
UHYVE_CASES_GEN_PATH = "GEN-tools-uhyve.c"
UHYVE_IBV_HEADER_GEN_PATH = "GEN-tools-uhyve-ibv-ports.h"
INCLUDE_STDDEF_GEN_PATH = "GEN-include-hermit-stddef.h"
# UHYVE_IBV_HEADER_STRUCTS_GEN_PATH = "GEN-tools-uhyve-ibv-structs.h"
UHYVE_HOST_FCNS_GEN_PATH = "GEN-tools-uhyve-ibv.c"
INCLUDE_STDDEF_GEN_PATH = "GEN-include-hermit-stddef.h"
UHYVE_HOST_FCNS_GEN_PATH = "GEN-tools-uhyve-ibv.c"
# VERBS_HEADER_PATH = "verbs-0.h"
# UHYVE_IBV_HEADER_STRUCTS_GEN_PATH = "GEN-tools-uhyve-ibv-structs.h"
# Starting number of the sequence used for IBV ports.
PORT_NUMBER_START = 0x610
TABS = ["", "\t", "\t\t", "\t\t\t", "\t\t\t\t"]
NEWLINES = ["", "\n", "\n\n"]
params_in_guest_mem = ['struct ibv_device_attr',
'struct ibv_device_attr_ex',
'struct ibv_port_attr',
@ -165,12 +163,6 @@ class Type:
def __init__(self, string):
ts = string
# if len(string) > 2 and string[-1] is "*":
# if string[-2] is "*" and string[-3] is not " ":
# ts = string[:-2] + " **"
# elif string[-2] is not " ":
# ts = string[:-1] + " *"
self.type_string = ts
self.type_components = ts.split(" ")
@ -195,7 +187,6 @@ class Type:
def is_void(self):
return self.type_string == "void"
class FunctionParameter:
def __init__(self, string):
components = string.split(" ")
@ -219,7 +210,6 @@ class FunctionParameter:
def is_pointer_pointer(self):
return self.type.is_pointer_pointer()
class FunctionPrototype:
def __init__(self, string):
parens_split = string.split("(")
@ -282,10 +272,6 @@ class FunctionPrototype:
return "uhyve_{0}_t".format(self.function_name)
# -----------------------------------------------------------------------------
def generate_pretty_comment(string):
return "/*\n * {0}\n */\n\n".format(string)
@ -337,7 +323,7 @@ def generate_uhyve_cases(function_prototypes):
Returns:
Generated switch-cases [string]
"""
code = "\t\t\tcase UHYVE_PORT_SET_IB_POOL_ADDR: {\n"
code = "\t\t\tcase UHYVE_PORT_SET_IB_POOL_ADDR: {\n"
code += "\t\t\t\t\tunsigned data = *((unsigned*)((size_t)run+run->io.data_offset));\n"
code += "\t\t\t\t\tuint64_t * temp = (uint64_t*)(guest_mem + data);\n"
code += "\t\t\t\t\tib_pool_addr = (uint8_t*) *temp;\n"
@ -360,7 +346,7 @@ def generate_uhyve_function(prototype):
fnc_name = prototype.function_name
ret_type = prototype.ret
code = generate_pretty_comment(fnc_name)
code = generate_pretty_comment(fnc_name)
code += "void call_{0}(struct kvm_run * run, uint8_t * guest_mem) {{\n".format(fnc_name)
code += "\tprintf(\"LOG: UHYVE - call_{0}\\n\");\n".format(fnc_name)
code += "\tunsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));\n"