/****************************************************************************** * * Copyright 2007-2008 Samuel Thibault . * All rights reserved. * Use is subject to license terms. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, version 2 of the * License. */ #undef NDEBUG #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "xc_private.h" extern struct wait_queue_head event_queue; int xc_interface_open(void) { return alloc_fd(FTYPE_XC); } int xc_interface_close(int xc_handle) { files[xc_handle].type = FTYPE_NONE; return 0; } void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot, xen_pfn_t *arr, int num) { unsigned long pt_prot = 0; #ifdef __ia64__ /* TODO */ #else if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; #endif return map_frames_ex(arr, num, 1, 0, 1, dom, 1, pt_prot); } void *xc_map_foreign_range(int xc_handle, uint32_t dom, int size, int prot, unsigned long mfn) { unsigned long pt_prot = 0; #ifdef __ia64__ /* TODO */ #else if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; #endif assert(!(size % getpagesize())); return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, 0, pt_prot); } void *xc_map_foreign_ranges(int xc_handle, uint32_t dom, size_t size, int prot, size_t chunksize, privcmd_mmap_entry_t entries[], int nentries) { unsigned long *mfns; int i, j, n; unsigned long pt_prot = 0; void *ret; #ifdef __ia64__ /* TODO */ #else if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; #endif mfns = malloc((size / PAGE_SIZE) * sizeof(*mfns)); n = 0; for (i = 0; i < nentries; i++) for (j = 0; j < chunksize / PAGE_SIZE; j++) mfns[n++] = entries[i].mfn + j; ret = map_frames_ex(mfns, n, 1, 0, 1, dom, 0, pt_prot); free(mfns); return ret; } int do_xen_hypercall(int xc_handle, privcmd_hypercall_t *hypercall) { multicall_entry_t call; int i, ret; call.op = hypercall->op; for (i = 0; i < sizeof(hypercall->arg) / sizeof(*hypercall->arg); i++) call.args[i] = hypercall->arg[i]; ret = HYPERVISOR_multicall(&call, 1); if (ret < 0) { errno = -ret; return -1; } if ((long) call.result < 0) { errno = - (long) call.result; return -1; } return call.result; } int xc_find_device_number(const char *name) { printf("xc_find_device_number(%s)\n", name); do_exit(); } int xc_evtchn_open(void) { int fd = alloc_fd(FTYPE_EVTCHN), i; for (i = 0; i < MAX_EVTCHN_PORTS; i++) { files[fd].evtchn.ports[i].port = -1; files[fd].evtchn.ports[i].bound = 0; } printf("evtchn_open() -> %d\n", fd); return fd; } int xc_evtchn_close(int xce_handle) { int i; for (i = 0; i < MAX_EVTCHN_PORTS; i++) if (files[xce_handle].evtchn.ports[i].bound) unbind_evtchn(files[xce_handle].evtchn.ports[i].port); files[xce_handle].type = FTYPE_NONE; return 0; } int xc_evtchn_fd(int xce_handle) { return xce_handle; } int xc_evtchn_notify(int xce_handle, evtchn_port_t port) { int ret; ret = notify_remote_via_evtchn(port); if (ret < 0) { errno = -ret; ret = -1; } return ret; } /* XXX Note: This is not threadsafe */ static int port_alloc(int xce_handle) { int i; for (i= 0; i < MAX_EVTCHN_PORTS; i++) if (files[xce_handle].evtchn.ports[i].port == -1) break; if (i == MAX_EVTCHN_PORTS) { printf("Too many ports in xc handle\n"); errno = EMFILE; return -1; }
/* This is a
  Multi line comment
  example */
module addbit (
a,
b,
ci,
sum,
co);

// Input Ports  Single line comment
input           a;
input           b;
input           ci;
// Output ports
output         sum;
output         co;
// Data Types      
wire            a;
wire            b;
wire            ci;
wire            sum;
wire            co; 

endmodule