diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-05-23 09:35:23 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-05-23 09:35:23 +0100 |
commit | 8543c562dd5553e92bb65cf27409551bc795ed52 (patch) | |
tree | f3d93e7e4b042913dbbf3d101d28ceb75c3ba9c0 /extras/mini-os | |
parent | 45ea54341290b85554730bdf71d96a27e02c1b26 (diff) | |
download | xen-8543c562dd5553e92bb65cf27409551bc795ed52.tar.gz xen-8543c562dd5553e92bb65cf27409551bc795ed52.tar.bz2 xen-8543c562dd5553e92bb65cf27409551bc795ed52.zip |
stubdom: complete libxc support
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os')
-rw-r--r-- | extras/mini-os/Config.mk | 5 | ||||
-rw-r--r-- | extras/mini-os/Makefile | 2 | ||||
-rw-r--r-- | extras/mini-os/arch/ia64/mm.c | 8 | ||||
-rw-r--r-- | extras/mini-os/include/lib.h | 1 | ||||
-rw-r--r-- | extras/mini-os/include/mm.h | 3 | ||||
-rw-r--r-- | extras/mini-os/include/x86/arch_mm.h | 5 | ||||
-rw-r--r-- | extras/mini-os/lib/sys.c | 67 |
7 files changed, 38 insertions, 53 deletions
diff --git a/extras/mini-os/Config.mk b/extras/mini-os/Config.mk index 1eb68d2f4b..15f7ed832c 100644 --- a/extras/mini-os/Config.mk +++ b/extras/mini-os/Config.mk @@ -41,10 +41,7 @@ include $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk extra_incl := $(foreach dir,$(EXTRA_INC),-I$(MINI-OS_ROOT)/include/$(dir)) DEF_CPPFLAGS += -I$(MINI-OS_ROOT)/include - -ifeq ($(stubdom),y) -DEF_CPPFLAGS += -DCONFIG_STUBDOM -endif +DEF_CPPFLAGS += -D__MINIOS__ ifeq ($(libc),y) DEF_CPPFLAGS += -DHAVE_LIBC diff --git a/extras/mini-os/Makefile b/extras/mini-os/Makefile index 4bb78a6708..8cec019e42 100644 --- a/extras/mini-os/Makefile +++ b/extras/mini-os/Makefile @@ -96,7 +96,7 @@ APP_LDLIBS += endif ifeq ($(libc),y) -LDLIBS += -L$(XEN_ROOT)/stubdom/libxc -lxenctrl -lxenguest +APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc -whole-archive -lxenguest -lxenctrl -no-whole-archive APP_LDLIBS += -lpci APP_LDLIBS += -lz LDLIBS += -lc diff --git a/extras/mini-os/arch/ia64/mm.c b/extras/mini-os/arch/ia64/mm.c index f2291f918c..273430da8b 100644 --- a/extras/mini-os/arch/ia64/mm.c +++ b/extras/mini-os/arch/ia64/mm.c @@ -131,6 +131,14 @@ arch_init_demand_mapping_area(unsigned long max_pfn) } /* Helper function used in gnttab.c. */ +void do_map_frames(unsigned long addr, + unsigned long *f, unsigned long n, unsigned long stride, + unsigned long increment, domid_t id, int may_fail, unsigned long prot) +{ + /* TODO */ + ASSERT(0); +} + void* map_frames_ex(unsigned long* frames, unsigned long n, unsigned long stride, unsigned long increment, unsigned long alignment, domid_t id, diff --git a/extras/mini-os/include/lib.h b/extras/mini-os/include/lib.h index b26a5eda39..ababf890fb 100644 --- a/extras/mini-os/include/lib.h +++ b/extras/mini-os/include/lib.h @@ -136,6 +136,7 @@ enum fd_type { FTYPE_CONSOLE, FTYPE_FILE, FTYPE_XENBUS, + FTYPE_XC, FTYPE_EVTCHN, FTYPE_SOCKET, FTYPE_TAP, diff --git a/extras/mini-os/include/mm.h b/extras/mini-os/include/mm.h index c2981c6fd8..28fb727f9f 100644 --- a/extras/mini-os/include/mm.h +++ b/extras/mini-os/include/mm.h @@ -67,6 +67,9 @@ void arch_init_p2m(unsigned long max_pfn_p); void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride, unsigned long increment, unsigned long alignment, domid_t id, int may_fail, unsigned long prot); +void do_map_frames(unsigned long addr, + unsigned long *f, unsigned long n, unsigned long stride, + unsigned long increment, domid_t id, int may_fail, unsigned long prot); #ifdef HAVE_LIBC extern unsigned long heap, brk, heap_mapped, heap_end; #endif diff --git a/extras/mini-os/include/x86/arch_mm.h b/extras/mini-os/include/x86/arch_mm.h index 98876b130b..580955d223 100644 --- a/extras/mini-os/include/x86/arch_mm.h +++ b/extras/mini-os/include/x86/arch_mm.h @@ -219,11 +219,6 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine) #define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, 0, L1_PROT) #define map_zero(n, a) map_frames_ex(&mfn_zero, n, 0, 0, a, DOMID_SELF, 0, L1_PROT_RO) -#ifndef __ASSEMBLY__ -void do_map_frames(unsigned long addr, - unsigned long *f, unsigned long n, unsigned long stride, - unsigned long increment, domid_t id, int may_fail, unsigned long prot); -#endif #define do_map_zero(start, n) do_map_frames(start, &mfn_zero, n, 0, 0, DOMID_SELF, 0, L1_PROT_RO) #endif /* _ARCH_MM_H_ */ diff --git a/extras/mini-os/lib/sys.c b/extras/mini-os/lib/sys.c index 730caab552..004e300728 100644 --- a/extras/mini-os/lib/sys.c +++ b/extras/mini-os/lib/sys.c @@ -81,6 +81,7 @@ #define NOFILE 32 extern int xc_evtchn_close(int fd); +extern int xc_interface_close(int fd); pthread_mutex_t fd_lock = PTHREAD_MUTEX_INITIALIZER; struct file files[NOFILE] = { @@ -259,10 +260,7 @@ int read(int fd, void *buf, size_t nbytes) } return ret * sizeof(union xenfb_in_event); } - case FTYPE_NONE: - case FTYPE_XENBUS: - case FTYPE_EVTCHN: - case FTYPE_BLK: + default: break; } printk("read(%d): Bad descriptor\n", fd); @@ -295,12 +293,7 @@ int write(int fd, const void *buf, size_t nbytes) case FTYPE_TAP: netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes); return nbytes; - case FTYPE_NONE: - case FTYPE_XENBUS: - case FTYPE_EVTCHN: - case FTYPE_BLK: - case FTYPE_KBD: - case FTYPE_FB: + default: break; } printk("write(%d): Bad descriptor\n", fd); @@ -351,15 +344,7 @@ int fsync(int fd) { } return 0; } - case FTYPE_NONE: - case FTYPE_CONSOLE: - case FTYPE_SOCKET: - case FTYPE_XENBUS: - case FTYPE_EVTCHN: - case FTYPE_TAP: - case FTYPE_BLK: - case FTYPE_KBD: - case FTYPE_FB: + default: break; } printk("fsync(%d): Bad descriptor\n", fd); @@ -391,6 +376,9 @@ int close(int fd) files[fd].type = FTYPE_NONE; return res; } + case FTYPE_XC: + xc_interface_close(fd); + return 0; case FTYPE_EVTCHN: xc_evtchn_close(fd); return 0; @@ -495,13 +483,7 @@ int fstat(int fd, struct stat *buf) stat_from_fs(buf, &stat); return 0; } - case FTYPE_NONE: - case FTYPE_XENBUS: - case FTYPE_EVTCHN: - case FTYPE_TAP: - case FTYPE_BLK: - case FTYPE_KBD: - case FTYPE_FB: + default: break; } @@ -522,15 +504,7 @@ int ftruncate(int fd, off_t length) } return 0; } - case FTYPE_NONE: - case FTYPE_CONSOLE: - case FTYPE_SOCKET: - case FTYPE_XENBUS: - case FTYPE_EVTCHN: - case FTYPE_TAP: - case FTYPE_BLK: - case FTYPE_KBD: - case FTYPE_FB: + default: break; } @@ -636,9 +610,10 @@ static const char file_types[] = { [FTYPE_NONE] = 'N', [FTYPE_CONSOLE] = 'C', [FTYPE_FILE] = 'F', - [FTYPE_XENBUS] = 'X', + [FTYPE_XENBUS] = 'S', + [FTYPE_XC] = 'X', [FTYPE_EVTCHN] = 'E', - [FTYPE_SOCKET] = 'S', + [FTYPE_SOCKET] = 's', [FTYPE_TAP] = 'T', [FTYPE_BLK] = 'B', [FTYPE_KBD] = 'K', @@ -722,7 +697,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce /* Then see others as well. */ for (i = 0; i < nfds; i++) { switch(files[i].type) { - case FTYPE_NONE: + default: if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds)) printk("bogus fd %d in select\n", i); /* Fallthrough. */ @@ -1083,14 +1058,20 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp) void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) { + unsigned long n = (length + PAGE_SIZE - 1) / PAGE_SIZE; + ASSERT(!start); - length = (length + PAGE_SIZE - 1) & PAGE_MASK; ASSERT(prot == (PROT_READ|PROT_WRITE)); - ASSERT(flags == (MAP_SHARED|MAP_ANON) || flags == (MAP_PRIVATE|MAP_ANON)); - ASSERT(fd == -1); + ASSERT((fd == -1 && (flags == (MAP_SHARED|MAP_ANON) || flags == (MAP_PRIVATE|MAP_ANON))) + || (fd != -1 && flags == MAP_SHARED)); ASSERT(offset == 0); - return map_zero(length / PAGE_SIZE, 1); + if (fd == -1) + return map_zero(n, 1); + else if (files[fd].type == FTYPE_XC) { + unsigned long zero = 0; + return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, 0, 0); + } else ASSERT(0); } #if defined(__x86_64__) || defined(__ia64__) __typeof__(mmap) mmap64 __attribute__((__alias__("mmap"))); @@ -1110,7 +1091,7 @@ int munmap(void *start, size_t length) call[i].args[0] = (unsigned long) &data[i]; call[i].args[1] = 0; call[i].args[2] = 0; - call[i].args[3] = UVMF_INVLPG | UVMF_ALL; + call[i].args[3] = UVMF_INVLPG; } ret = HYPERVISOR_multicall(call, n); |