Skip to contentSkip to conversation

Add stubdomain support

RFC Applied Samuel Thibault 3 participants 12 messages Feb 11, 2008 – Feb 13, 2008

lore
Share & tools
lore
#0 lore raw

RFC 1/1 Add stubdomain support

Hello,

At last, here is the big patch that adds the stubdomain support. I guess some reviewing will be needed before commiting it.

Add stubdomain support.

- Setup a xen-elf cross-compilation environment in stubdom/cross-root
- Add a POSIX layer on top of Mini-OS by linking against the newlib C library and lwIP, and implementing the Unixish part in mini-os/lib/sys.c
- Cross-compile zlib and libpci too.
- Add an xs.h-compatible layer on top of Mini-OS' xenbus.
- Cross-compile libxc with an additional xc_minios.c and a few things disabled.
- Cross-compile ioemu with an additional block-vbd, but without sound, tpm and other details. A few hacks are needed:
- Align ide and scsi buffers at least on sector size to permit direct transmission to the block backend. While we are at it, just page-align it to possibly save a segment. Also, limit the scsi buffer size because of limitations of the block paravirtualization protocol.
- Allocate big tables dynamically rather that letting them go to bss: when Mini-OS gets installed in memory, bss is not lazily allocated, and doing so during Mini-OS is unnecessarily trick while we can simply use malloc.
- Have the domain killer send SIGHUP to the device-model script, allow the script 10s to clean up, and if still not dead, send SIGKILL.
- Had to change the Mini-OS compilation somehow, so as to export Mini-OS compilation flags to the Makefiles of libxc and ioemu.

.hgignore +11 -0
diff -r 7b0c0ab0566b .hgignore
@@ -221,6 +221,17 @@
 ^tools/xm-test/lib/XmTestLib/config.py$
 ^tools/xm-test/lib/XmTestReport/xmtest.py$
 ^tools/xm-test/tests/.*\.test$
+^stubdom/binutils.*$
+^stubdom/cross-root.*$
+^stubdom/gcc.*$
+^stubdom/include.*$
+^stubdom/ioemu.*$
+^stubdom/libxc.*$
+^stubdom/lwip.*$
+^stubdom/mini-os.*$
+^stubdom/newlib.*$
+^stubdom/pciutils.*$
+^stubdom/zlib.*$
 ^xen/BLOG$
 ^xen/System.map$
 ^xen/TAGS$
Config.mk +8 -0
diff -r 7b0c0ab0566b Config.mk
@@ -27,6 +27,14 @@ DESTDIR     ?= /
 
 include $(XEN_ROOT)/config/$(XEN_OS).mk
 include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
+
+ifeq ($(stubdom),y)
+include $(XEN_ROOT)/extras/mini-os/Config.mk
+CFLAGS += $(DEF_CFLAGS) $(ARCH_CFLAGS)
+CPPFLAGS += $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) $(extra_incl)
+ASFLAGS += $(DEF_ASFLAGS) $(ARCH_ASFLAGS)
+LDFLAGS += $(DEF_LDFLAGS) $(ARCH_LDFLAGS)
+endif
 
 ifneq ($(EXTRA_PREFIX),)
 EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
extras/mini-os/Config.mk new file +75 -0

75 lines not on this page · raw message

extras/mini-os/Makefile +31 -50

106 lines not on this page · raw message

extras/mini-os/arch/ia64/Makefile +3 -1
diff -r 7b0c0ab0566b extras/mini-os/arch/ia64/Makefile
@@ -4,6 +4,8 @@
 
 XEN_ROOT = ../../../..
 include $(XEN_ROOT)/Config.mk
+
+include ../../Config.mk
 
 include arch.mk
 include ../../minios.mk
@@ -41,7 +43,7 @@ ARCH_OBJS += __divdi3.o
 
 GEN_OFF_SRC := gen_off.c
 GEN_OFF_ASM := gen_off.s
-GEN_OFF_H   := $(ARCH_INC)/offsets.h
+GEN_OFF_H   := $(MINI-OS_ROOT)/include/$(ARCH_INC)/offsets.h
 
 all: $(ARCH_LIB)
 
extras/mini-os/arch/ia64/minios-ia64.lds +12 -0
diff -r 7b0c0ab0566b extras/mini-os/arch/ia64/minios-ia64.lds
@@ -40,6 +40,18 @@ SECTIONS
   .rodata.str1.8 : AT(ADDR(.rodata.str1.8) - (((5<<(61))+0x100000000) - (1 << 20)))
   { *(.rodata.str1.8) }
 
+  /* newlib initialization functions */
+  . = ALIGN(64 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { *(.preinit_array) }
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { *(.init_array) }
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { *(.fini_array) }
+  PROVIDE (__fini_array_end = .);
+
   .IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - (((5<<(61))+0x100000000) - (1 << 20)))
   { *(.IA_64.unwind_info) }
 
extras/mini-os/arch/ia64/mm.c +8 -0
diff -r 7b0c0ab0566b extras/mini-os/arch/ia64/mm.c
@@ -42,6 +42,14 @@ extern uint64_t _text[], _etext[], _end[
 extern uint64_t _text[], _etext[], _end[], kstack[], phys_start[];
 
 uint64_t kernstart, kernend, kernsize, kernpstart, kernpend;
+
+#ifdef HAVE_LIBC
+uint8_t _heap[512 * 1024];
+unsigned long heap = (unsigned long)_heap,
+              brk = (unsigned long)_heap,
+              heap_mapped = (unsigned long)_heap + sizeof(_heap),
+              heap_end = (unsigned long)_heap + sizeof(_heap);
+#endif
 
 /* Print the available memory chunks. */
 static void
extras/mini-os/arch/x86/Makefile +2 -1
diff -r 7b0c0ab0566b extras/mini-os/arch/x86/Makefile
@@ -5,13 +5,14 @@
 
 XEN_ROOT = ../../../..
 include $(XEN_ROOT)/Config.mk
+include ../../Config.mk
 
 # include arch.mk has to be before mini-os.mk!
 
 include arch.mk
 include ../../minios.mk
 
-# Sources here are all *.c *.S without $(TARGET_ARCH).S
+# Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S
 # This is handled in $(HEAD_ARCH_OBJ)
 ARCH_SRCS := $(wildcard *.c)
 
extras/mini-os/arch/x86/arch.mk +4 -4
diff -r 7b0c0ab0566b extras/mini-os/arch/x86/arch.mk
@@ -3,11 +3,11 @@
 # (including x86_32, x86_32y and x86_64).
 #
 
-ifeq ($(TARGET_ARCH),x86_32)
+ifeq ($(XEN_TARGET_ARCH),x86_32)
 ARCH_CFLAGS  := -m32 -march=i686
 ARCH_LDFLAGS := -m elf_i386
 ARCH_ASFLAGS := -m32
-EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
+EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH)
 EXTRA_SRC += arch/$(EXTRA_INC)
 
 ifeq ($(XEN_TARGET_X86_PAE),y)
@@ -16,12 +16,12 @@ endif
 endif
 endif
 
-ifeq ($(TARGET_ARCH),x86_64)
+ifeq ($(XEN_TARGET_ARCH),x86_64)
 ARCH_CFLAGS := -m64 -mno-red-zone -fno-reorder-blocks
 ARCH_CFLAGS += -fno-asynchronous-unwind-tables
 ARCH_ASFLAGS := -m64
 ARCH_LDFLAGS := -m elf_x86_64
-EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
+EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH)
 EXTRA_SRC += arch/$(EXTRA_INC)
 endif
 
extras/mini-os/arch/x86/minios-x86_32.lds +12 -0
diff -r 7b0c0ab0566b extras/mini-os/arch/x86/minios-x86_32.lds
@@ -15,6 +15,18 @@ SECTIONS
   .rodata : { *(.rodata) *(.rodata.*) }
   . = ALIGN(4096);
   _erodata = .;
+
+  /* newlib initialization functions */
+  . = ALIGN(32 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { *(.preinit_array) }
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { *(.init_array) }
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { *(.fini_array) }
+  PROVIDE (__fini_array_end = .);
 
   .data : {			/* Data */
 	*(.data)
extras/mini-os/arch/x86/minios-x86_64.lds +12 -0
diff -r 7b0c0ab0566b extras/mini-os/arch/x86/minios-x86_64.lds
@@ -15,6 +15,18 @@ SECTIONS
   .rodata : { *(.rodata) *(.rodata.*) }
   . = ALIGN(4096);
   _erodata = .;
+
+  /* newlib initialization functions */
+  . = ALIGN(64 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { *(.preinit_array) }
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { *(.init_array) }
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { *(.fini_array) }
+  PROVIDE (__fini_array_end = .);
 
   .data : {			/* Data */
 	*(.data)
extras/mini-os/arch/x86/mm.c +17 -0
diff -r 7b0c0ab0566b extras/mini-os/arch/x86/mm.c
@@ -448,6 +448,15 @@ static unsigned long demand_map_area_sta
 #define DEMAND_MAP_PAGES ((2ULL << 30) / PAGE_SIZE)
 #endif
 
+#ifdef HAVE_LIBC
+unsigned long heap, brk, heap_mapped, heap_end;
+#ifdef __x86_64__
+#define HEAP_PAGES ((128ULL << 30) / PAGE_SIZE)
+#else
+#define HEAP_PAGES ((1ULL << 30) / PAGE_SIZE)
+#endif
+#endif
+
 void arch_init_demand_mapping_area(unsigned long cur_pfn)
 {
     cur_pfn++;
@@ -455,6 +464,14 @@ void arch_init_demand_mapping_area(unsig
     demand_map_area_start = (unsigned long) pfn_to_virt(cur_pfn);
     cur_pfn += DEMAND_MAP_PAGES;
     printk("Demand map pfns at %lx-%lx.\n", demand_map_area_start, pfn_to_virt(cur_pfn));
+
+#ifdef HAVE_LIBC
+    cur_pfn++;
+    heap_mapped = brk = heap = (unsigned long) pfn_to_virt(cur_pfn);
+    cur_pfn += HEAP_PAGES;
+    heap_end = (unsigned long) pfn_to_virt(cur_pfn);
+    printk("Heap resides at %lx-%lx.\n", brk, heap_end);
+#endif
 }
 
 #define MAP_BATCH ((STACK_SIZE / 2) / sizeof(mmu_update_t))
extras/mini-os/blkfront.c +41 -5

98 lines not on this page · raw message

extras/mini-os/include/arch/cc.h +7 -0
diff -r 7b0c0ab0566b extras/mini-os/include/arch/cc.h
@@ -54,7 +54,14 @@ extern void lwip_die(char *fmt, ...);
 #include <errno.h>
 
 /*   Not required by the docs, but needed for network-order calculations */
+#ifdef HAVE_LIBC
+#include <machine/endian.h>
+#ifndef BIG_ENDIAN
+#error endian.h does not define byte order
+#endif
+#else
 #include <endian.h>
+#endif
 
 #include <inttypes.h>
 #define S16_F PRIi16
extras/mini-os/include/byteswap.h new file +22 -0
diff -r 7b0c0ab0566b extras/mini-os/include/byteswap.h
@@ -0,0 +1,22 @@
+#ifndef _BYTESWAP_H_
+#define _BYTESWAP_H_
+
+/* Unfortunately not provided by newlib.  */
+#define bswap_16(x) \
+    ((((x) & 0xff00) >> 8) | (((x) & 0xff) << 8))
+
+#define bswap_32(x) \
+    ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
+     (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
+
+#define bswap_64(x) \
+    ((((x) & 0xff00000000000000ULL) >> 56) | \
+     (((x) & 0x00ff000000000000ULL) >> 40) | \
+     (((x) & 0x0000ff0000000000ULL) >> 24) | \
+     (((x) & 0x000000ff00000000ULL) >>  8) | \
+     (((x) & 0x00000000ff000000ULL) <<  8) | \
+     (((x) & 0x0000000000ff0000ULL) << 24) | \
+     (((x) & 0x000000000000ff00ULL) << 40) | \
+     (((x) & 0x00000000000000ffULL) << 56))
+
+#endif /* _BYTESWAP_H */
extras/mini-os/include/console.h +3 -0
diff -r 7b0c0ab0566b extras/mini-os/include/console.h
@@ -36,7 +36,9 @@
 #ifndef _LIB_CONSOLE_H_
 #define _LIB_CONSOLE_H_
 
+#include<os.h>
 #include<traps.h>
+#include<stdarg.h>
 
 void print(int direct, const char *fmt, va_list args);
 void printk(const char *fmt, ...);
@@ -48,5 +50,6 @@ void xencons_tx(void);
 void xencons_tx(void);
 
 void init_console(void);
+void console_print(char *data, int length);
 
 #endif /* _LIB_CONSOLE_H_ */
extras/mini-os/include/errno.h +7 -0
diff -r 7b0c0ab0566b extras/mini-os/include/errno.h
@@ -107,4 +107,11 @@
 #define	EOWNERDEAD	130	/* Owner died */
 #define	ENOTRECOVERABLE	131	/* State not recoverable */
 
+#ifdef HAVE_LIBC
+#include <sched.h>
+extern int errno;
+#define ERRNO
+#define errno (get_current()->reent._errno)
 #endif
+
+#endif
extras/mini-os/include/fcntl.h +3 -0
diff -r 7b0c0ab0566b extras/mini-os/include/fcntl.h
@@ -86,4 +86,7 @@ struct flock64 {
 
 #define F_LINUX_SPECIFIC_BASE	1024
 */
+
+int open(const char *path, int flags, ...);
+int fcntl(int fd, int cmd, ...);
 #endif
extras/mini-os/include/fs.h +1 -0
diff -r 7b0c0ab0566b extras/mini-os/include/fs.h
@@ -22,6 +22,7 @@ struct fs_import
     struct semaphore reqs_sem;      /* Accounts requests resource           */
 };
 
+extern struct fs_import *fs_import;
 
 void init_fs_frontend(void);
 
extras/mini-os/include/ia64/arch_mm.h +2 -1
diff -r 7b0c0ab0566b extras/mini-os/include/ia64/arch_mm.h
@@ -35,11 +35,12 @@
 #define virt_to_mfn(x)	virt_to_pfn(x)
 #define virtual_to_mfn(x)      (ia64_tpa((uint64_t)(x)) >> PAGE_SHIFT)
 
-#define STACK_SIZE_PAGE_ORDER   1
+#define STACK_SIZE_PAGE_ORDER   2
 #define STACK_SIZE              (PAGE_SIZE * (1 << STACK_SIZE_PAGE_ORDER))
 
 #define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, 0, 0)
 /* TODO */
 #define map_zero(n, a) map_frames_ex(NULL, n, 0, 0, a, DOMID_SELF, 0, 0)
+#define do_map_zero(start, n) ((void)0)
 
 #endif /* __ARCH_MM_H__ */
extras/mini-os/include/ia64/os.h +3 -0
diff -r 7b0c0ab0566b extras/mini-os/include/ia64/os.h
@@ -292,9 +292,12 @@ do {									\
 /* This is a barrier for the compiler only, NOT the processor! */
 #define barrier() __asm__ __volatile__("": : :"memory")
 
+#ifndef __barriers_defined
+#define __barriers_defined
 #define mb()	ia64_mf()
 #define rmb()	mb()
 #define wmb()	mb()
+#endif
 
 
 #define BUG()	\
extras/mini-os/include/lib.h +59 -0

75 lines not on this page · raw message

extras/mini-os/include/linux/types.h new file +5 -0
diff -r 7b0c0ab0566b extras/mini-os/include/linux/types.h
@@ -0,0 +1,5 @@
+#ifndef _LINUX_TYPES_H_
+#define _LINUX_TYPES_H_
+#include <types.h>
+typedef u64 __u64;
+#endif /* _LINUX_TYPES_H_ */
extras/mini-os/include/mm.h +3 -0
diff -r 7b0c0ab0566b extras/mini-os/include/mm.h
@@ -61,5 +61,8 @@ void *map_frames_ex(unsigned long *f, un
 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);
+#ifdef HAVE_LIBC
+extern unsigned long heap, brk, heap_mapped, heap_end;
+#endif
 
 #endif /* _MM_H_ */
extras/mini-os/include/netfront.h +4 -0
diff -r 7b0c0ab0566b extras/mini-os/include/netfront.h
@@ -6,6 +6,10 @@ struct netfront_dev *init_netfront(char 
 struct netfront_dev *init_netfront(char *nodename, void (*netif_rx)(unsigned char *data, int len), unsigned char rawmac[6]);
 void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
 void shutdown_netfront(struct netfront_dev *dev);
+#ifdef HAVE_LIBC
+int netfront_tap_open(char *nodename);
+ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t len);
+#endif
 
 extern struct wait_queue_head netfront_queue;
 
extras/mini-os/include/posix/dirent.h new file +24 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/dirent.h
@@ -0,0 +1,24 @@
+#ifndef _POSIX_DIRENT_H
+#define _POSIX_DIRENT_H
+
+#include <sys/types.h>
+
+struct dirent {
+        char *d_name;
+};
+
+typedef struct {
+        struct dirent dirent;
+        char *name;
+        int32_t offset;
+        char **entries;
+        int32_t curentry;
+        int32_t nbentries;
+        int has_more;
+} DIR;
+
+DIR *opendir(const char *name);
+struct dirent *readdir(DIR *dir);
+int closedir(DIR *dir);
+
+#endif /* _POSIX_DIRENT_H */
extras/mini-os/include/posix/limits.h new file +8 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/limits.h
@@ -0,0 +1,8 @@
+#ifndef _POSIX_LIMITS_H
+#define _POSIX_LIMITS_H
+
+#include_next <limits.h>
+
+#define PATH_MAX PAGE_SIZE
+
+#endif /* _POSIX_LIMITS_H */
extras/mini-os/include/posix/netdb.h new file +9 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/netdb.h
@@ -0,0 +1,9 @@
+#ifndef _POSIX_NETDB_H_
+#define _POSIX_NETDB_H_
+
+struct hostent {
+    char *h_addr;
+};
+#define gethostbyname(buf) NULL
+
+#endif /* _POSIX_NETDB_H_ */
extras/mini-os/include/posix/netinet/in.h new file +7 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/netinet/in.h
@@ -0,0 +1,7 @@
+#ifndef _POSIX_SYS_IN_H_
+#define _POSIX_SYS_IN_H_
+
+#include <fcntl.h>
+#include <lwip/sockets.h>
+
+#endif /* _POSIX_SYS_IN_H_ */
extras/mini-os/include/posix/netinet/tcp.h new file +6 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/netinet/tcp.h
@@ -0,0 +1,6 @@
+#ifndef _POSIX_SYS_TCP_H_
+#define _POSIX_SYS_TCP_H_
+
+#include <lwip/tcp.h>
+
+#endif /* _POSIX_SYS_TCP_H_ */
extras/mini-os/include/posix/pthread.h new file +19 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/pthread.h
@@ -0,0 +1,19 @@
+#ifndef _POSIX_PTHREAD_H
+#define _POSIX_PTHREAD_H
+
+/* Let's be single-threaded for now.  */
+
+typedef void *pthread_key_t;
+typedef struct {} pthread_mutex_t, pthread_once_t;
+#define PTHREAD_MUTEX_INITIALIZER {}
+#define PTHREAD_ONCE_INIT {}
+static inline int pthread_mutex_lock(pthread_mutex_t *mutex) { return 0; }
+static inline int pthread_mutex_unlock(pthread_mutex_t *mutex) { return 0; }
+static inline int pthread_key_create(pthread_key_t *key, void (*destr_function)(void*)) { *key = NULL; return 0; }
+static inline int pthread_setspecific(pthread_key_t *key, const void *pointer) { *key = (void*) pointer; return 0; }
+static inline void *pthread_getspecific(pthread_key_t *key) { return *key; }
+static inline int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) { init_routine(); return 0; }
+
+#define __thread
+
+#endif /* _POSIX_PTHREAD_H */
extras/mini-os/include/posix/stdlib.h new file +8 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/stdlib.h
@@ -0,0 +1,8 @@
+#ifndef _POSIX_STDLIB_H
+#define _POSIX_STDLIB_H
+
+#include_next <stdlib.h>
+
+#define realpath(p,r) strcpy(r,p)
+
+#endif /* _POSIX_STDLIB_H */
extras/mini-os/include/posix/strings.h new file +8 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/strings.h
@@ -0,0 +1,8 @@
+#ifndef _POSIX_STRINGS_H
+#define _POSIX_STRINGS_H
+
+#include <string.h>
+
+#define bzero(ptr, size) (memset((ptr), '\0', (size)), (void) 0)
+
+#endif /* _POSIX_STRINGS_H */
extras/mini-os/include/posix/sys/ioctl.h new file +16 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/sys/ioctl.h
@@ -0,0 +1,16 @@
+#ifndef _POSIX_SYS_IOCTL_H
+#define _POSIX_SYS_IOCTL_H
+
+int ioctl(int fd, int request, ...);
+
+#define _IOC_NONE 0
+#define _IOC_WRITE 1
+#define _IOC_READ 2
+
+#define _IOC(rw, class, n, size) \
+    	(((rw   ) << 30) | \
+	 ((class) << 22) | \
+	 ((n    ) << 14) | \
+	 ((size ) << 0))
+
+#endif /* _POSIX_SYS_IOCTL_H */
extras/mini-os/include/posix/sys/mman.h new file +19 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/sys/mman.h
@@ -0,0 +1,19 @@
+#ifndef _POSIX_SYS_MMAN_H
+#define _POSIX_SYS_MMAN_H
+
+#define PROT_READ	0x1
+#define PROT_WRITE	0x2
+#define PROT_EXEC	0x4
+
+#define MAP_SHARED	0x01
+#define MAP_PRIVATE	0x02
+#define MAP_ANON	0x20
+
+#define MAP_FAILED	((void*)0)
+
+void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
+int munmap(void *start, size_t length);
+#define munlock(addr, len) ((void)addr, (void)len, 0)
+#define mlock(addr, len) ((void)addr, (void)len, 0)
+
+#endif /* _POSIX_SYS_MMAN_H */
extras/mini-os/include/posix/sys/select.h new file +7 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/sys/select.h
@@ -0,0 +1,7 @@
+#ifndef _POSIX_SELECT_H
+#define _POSIX_SELECT_H
+
+#include <sys/time.h>
+int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+
+#endif /* _POSIX_SELECT_H */
extras/mini-os/include/posix/sys/socket.h new file +31 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/sys/socket.h
@@ -0,0 +1,31 @@
+#ifndef _POSIX_SYS_SOCKET_H_
+#define _POSIX_SYS_SOCKET_H_
+
+#include <fcntl.h>
+#include <lwip/sockets.h>
+
+int accept(int s, struct sockaddr *addr, socklen_t *addrlen);
+int bind(int s, struct sockaddr *name, socklen_t namelen);
+int shutdown(int s, int how);
+int getpeername (int s, struct sockaddr *name, socklen_t *namelen);
+int getsockname (int s, struct sockaddr *name, socklen_t *namelen);
+int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
+int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
+int close(int s);
+int connect(int s, struct sockaddr *name, socklen_t namelen);
+int listen(int s, int backlog);
+int recv(int s, void *mem, int len, unsigned int flags);
+//int read(int s, void *mem, int len);
+int recvfrom(int s, void *mem, int len, unsigned int flags,
+      struct sockaddr *from, socklen_t *fromlen);
+int send(int s, void *dataptr, int size, unsigned int flags);
+int sendto(int s, void *dataptr, int size, unsigned int flags,
+    struct sockaddr *to, socklen_t tolen);
+int socket(int domain, int type, int protocol);
+//int write(int s, void *dataptr, int size);
+int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
+                struct timeval *timeout);
+//int ioctl(int s, long cmd, void *argp);
+int getsockname(int s, struct sockaddr *name, socklen_t *namelen);
+
+#endif /* _POSIX_SYS_SOCKET_H_ */
extras/mini-os/include/posix/termios.h new file +87 -0

87 lines not on this page · raw message

extras/mini-os/include/posix/time.h new file +10 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/time.h
@@ -0,0 +1,10 @@
+#ifndef _POSIX_TIME_H
+#define _POSIX_TIME_H
+
+#include <sys/time.h>
+#define CLOCK_MONOTONIC	2
+#include_next <time.h>
+
+int nanosleep(const struct timespec *req, struct timespec *rem);
+
+#endif /* _POSIX_TIME_H */
extras/mini-os/include/posix/unistd.h new file +11 -0
diff -r 7b0c0ab0566b extras/mini-os/include/posix/unistd.h
@@ -0,0 +1,11 @@
+#ifndef _POSIX_UNISTD_H
+#define _POSIX_UNISTD_H
+
+#include_next <unistd.h>
+#include <sys/select.h>
+
+#define getpagesize() PAGE_SIZE
+
+int ftruncate(int fd, off_t length);
+
+#endif /* _POSIX_UNISTD_H */
extras/mini-os/include/sched.h +3 -0
diff -r 7b0c0ab0566b extras/mini-os/include/sched.h
@@ -19,6 +19,9 @@ struct thread
     struct list_head thread_list;
     u32 flags;
     s_time_t wakeup_time;
+#ifdef HAVE_LIBC
+    struct _reent reent;
+#endif
 };
 
 extern struct thread *idle_thread;
extras/mini-os/include/sys/time.h +4 -0
diff -r 7b0c0ab0566b extras/mini-os/include/sys/time.h
@@ -20,6 +20,9 @@
 #ifndef _MINIOS_SYS_TIME_H_
 #define _MINIOS_SYS_TIME_H_
 
+#ifdef HAVE_LIBC
+#include_next <sys/time.h>
+#else
 struct timespec {
     time_t      tv_sec;
     long        tv_nsec;
@@ -34,5 +37,6 @@ struct timeval {
 };
 
 int      gettimeofday(struct timeval *tv, void *tz);
+#endif
 
 #endif /* _MINIOS_SYS_TIME_H_ */
extras/mini-os/include/time.h +8 -3
diff -r 7b0c0ab0566b extras/mini-os/include/time.h
@@ -17,8 +17,9 @@
  ****************************************************************************
  */
 
-#ifndef _TIME_H_
-#define _TIME_H_
+#ifndef _MINIOS_TIME_H_
+#define _MINIOS_TIME_H_
+#include <types.h>
 
 /*
  * System Time
@@ -44,8 +45,12 @@ typedef s64 s_time_t;
 /* wall clock time  */
 typedef long time_t;
 typedef long suseconds_t;
+
 #include <sys/time.h>
 
+#ifdef HAVE_LIBC
+#include_next <time.h>
+#endif
 
 /* prototypes */
 void     init_time(void);
@@ -54,4 +59,4 @@ u64      monotonic_clock(void);
 u64      monotonic_clock(void);
 void     block_domain(s_time_t until);
 
-#endif /* _TIME_H_ */
+#endif /* _MINIOS_TIME_H_ */
extras/mini-os/include/x86/arch_mm.h +7 -1
diff -r 7b0c0ab0566b extras/mini-os/include/x86/arch_mm.h
@@ -177,7 +177,7 @@ typedef unsigned long pgentry_t;
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
-#define STACK_SIZE_PAGE_ORDER  1
+#define STACK_SIZE_PAGE_ORDER  4
 #define STACK_SIZE             (PAGE_SIZE * (1 << STACK_SIZE_PAGE_ORDER))
 
 #ifndef __ASSEMBLY__
@@ -257,5 +257,11 @@ static __inline__ paddr_t machine_to_phy
 
 #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_ */
extras/mini-os/include/x86/arch_spinlock.h +1 -0
diff -r 7b0c0ab0566b extras/mini-os/include/x86/arch_spinlock.h
@@ -4,6 +4,7 @@
 #define __ARCH_ASM_SPINLOCK_H
 
 #include <lib.h>
+#include "os.h"
 
 
 #define ARCH_SPIN_LOCK_UNLOCKED (spinlock_t) { 1 }
extras/mini-os/include/x86/os.h +4 -0
diff -r 7b0c0ab0566b extras/mini-os/include/x86/os.h
@@ -139,6 +139,8 @@ do {									\
 /* This is a barrier for the compiler only, NOT the processor! */
 #define barrier() __asm__ __volatile__("": : :"memory")
 
+#ifndef __barriers_defined
+#define __barriers_defined
 #if defined(__i386__)
 #define mb()    __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
 #define rmb()   __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
@@ -147,6 +149,7 @@ do {									\
 #define mb()    __asm__ __volatile__ ("mfence":::"memory")
 #define rmb()   __asm__ __volatile__ ("lfence":::"memory")
 #define wmb()	__asm__ __volatile__ ("sfence" ::: "memory") /* From CONFIG_UNORDERED_IO (linux) */
+#endif
 #endif
 
 
@@ -563,6 +566,7 @@ static __inline__ int synch_var_test_bit
  synch_var_test_bit((nr),(addr)))
 
 
+#undef ADDR
 
 #endif /* not assembly */
 #endif /* _OS_H_ */
extras/mini-os/include/xs.h new file +168 -0

168 lines not on this page · raw message

extras/mini-os/include/xs_lib.h new file +69 -0

69 lines not on this page · raw message

extras/mini-os/lib/sys.c new file +1083 -0

1,083 lines not on this page · raw message

extras/mini-os/lib/xs.c new file +187 -0

187 lines not on this page · raw message

extras/mini-os/main-caml.c new file +42 -0

42 lines not on this page · raw message

extras/mini-os/main.c new file +167 -0

167 lines not on this page · raw message

extras/mini-os/minios.mk +5 -8
diff -r 7b0c0ab0566b extras/mini-os/minios.mk
@@ -9,7 +9,7 @@ DEF_CFLAGS += -fno-builtin -Wall -Werror
 DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
 DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
 DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
-DEF_CFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
+DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
 
 DEF_ASFLAGS = -D__ASSEMBLY__
 DEF_LDFLAGS =
@@ -24,11 +24,9 @@ endif
 # DEF_... flags are the common mini-os flags,
 # ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk
 CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS)
+CPPFLAGS := $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS)
 ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS)
 LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS)
-
-# The path pointing to the architecture specific header files.
-ARCH_INC := $(MINI-OS_ROOT)/include/$(TARGET_ARCH_FAM)
 
 # Special build dependencies.
 # Rebuild all after touching this/these file(s)
@@ -44,18 +42,17 @@ HDRS += $(extra_heads)
 HDRS += $(extra_heads)
 
 # Add the special header directories to the include paths.
-extra_incl := $(foreach dir,$(EXTRA_INC),-I$(MINI-OS_ROOT)/include/$(dir))
-override CPPFLAGS := -I$(MINI-OS_ROOT)/include $(CPPFLAGS) -I$(ARCH_INC)	$(extra_incl)
+override CPPFLAGS := $(CPPFLAGS) $(extra_incl)
 
 # The name of the architecture specific library.
 # This is on x86_32: libx86_32.a
 # $(ARCH_LIB) has to built in the architecture specific directory.
-ARCH_LIB_NAME = $(TARGET_ARCH)
+ARCH_LIB_NAME = $(XEN_TARGET_ARCH)
 ARCH_LIB := lib$(ARCH_LIB_NAME).a
 
 # This object contains the entrypoint for startup from Xen.
 # $(HEAD_ARCH_OBJ) has to be built in the architecture specific directory.
-HEAD_ARCH_OBJ := $(TARGET_ARCH).o
+HEAD_ARCH_OBJ := $(XEN_TARGET_ARCH).o
 HEAD_OBJ := $(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ)
 
 
extras/mini-os/mm.c +23 -0
diff -r 7b0c0ab0566b extras/mini-os/mm.c
@@ -360,6 +360,29 @@ void free_pages(void *pointer, int order
    
 }
 
+#ifdef HAVE_LIBC
+void *sbrk(ptrdiff_t increment)
+{
+    unsigned long old_brk = brk;
+    unsigned long new_brk = old_brk + increment;
+
+    if (new_brk > heap_end) {
+	printk("Heap exhausted: %p + %lx = %p > %p\n", old_brk, increment, new_brk, heap_end);
+	return NULL;
+    }
+    
+    if (new_brk > heap_mapped) {
+        unsigned long n = (new_brk - heap_mapped + PAGE_SIZE - 1) / PAGE_SIZE;
+        do_map_zero(heap_mapped, n);
+        heap_mapped += n * PAGE_SIZE;
+    }
+
+    brk = new_brk;
+
+    return (void *) old_brk;
+}
+#endif
+
 
 
 void init_mm(void)
extras/mini-os/netfront.c +94 -4

156 lines not on this page · raw message

extras/mini-os/sched.c +44 -0

24 lines not on this page · raw message

stubdom/Makefile new file +256 -0

256 lines not on this page · raw message

stubdom/README new file +41 -0

41 lines not on this page · raw message

stubdom/binutils.patch new file +14 -0
diff -r 7b0c0ab0566b stubdom/binutils.patch

Lines of this file are not shown. View the raw message.

stubdom/caml/Makefile new file +18 -0
diff -r 7b0c0ab0566b stubdom/caml/Makefile

Lines of this file are not shown. View the raw message.

stubdom/caml/hello.ml new file +4 -0
diff -r 7b0c0ab0566b stubdom/caml/hello.ml

Lines of this file are not shown. View the raw message.

stubdom/gcc.patch new file +31 -0
diff -r 7b0c0ab0566b stubdom/gcc.patch

Lines of this file are not shown. View the raw message.

stubdom/libpci.config.h new file +5 -0
diff -r 7b0c0ab0566b stubdom/libpci.config.h

Lines of this file are not shown. View the raw message.

stubdom/libpci.config.mak new file +2 -0
diff -r 7b0c0ab0566b stubdom/libpci.config.mak

Lines of this file are not shown. View the raw message.

stubdom/newlib.patch new file +183 -0

183 lines not on this page · raw message

stubdom/stubdom-dm new file +97 -0

97 lines not on this page · raw message

tools/ioemu/Makefile.target +35 -7

42 lines not on this page · raw message

tools/ioemu/aes.c +2 -0
diff -r 7b0c0ab0566b tools/ioemu/aes.c

Lines of this file are not shown. View the raw message.

tools/ioemu/block-vbd.c new file +341 -0

341 lines not on this page · raw message

tools/ioemu/block.c +3 -0
diff -r 7b0c0ab0566b tools/ioemu/block.c

Lines of this file are not shown. View the raw message.

tools/ioemu/configure +21 -1
diff -r 7b0c0ab0566b tools/ioemu/configure

Lines of this file are not shown. View the raw message.

tools/ioemu/exec-all.h +4 -0
diff -r 7b0c0ab0566b tools/ioemu/exec-all.h

Lines of this file are not shown. View the raw message.

tools/ioemu/hw/ide.c +3 -1
diff -r 7b0c0ab0566b tools/ioemu/hw/ide.c

Lines of this file are not shown. View the raw message.

tools/ioemu/hw/scsi-disk.c +7 -1
diff -r 7b0c0ab0566b tools/ioemu/hw/scsi-disk.c

Lines of this file are not shown. View the raw message.

tools/ioemu/hw/xen_machine_fv.c +3 -0
diff -r 7b0c0ab0566b tools/ioemu/hw/xen_machine_fv.c

Lines of this file are not shown. View the raw message.

tools/ioemu/vl.c +59 -16

75 lines not on this page · raw message

tools/ioemu/vl.h +3 -0
diff -r 7b0c0ab0566b tools/ioemu/vl.h

Lines of this file are not shown. View the raw message.

tools/ioemu/vnc.c +18 -1
diff -r 7b0c0ab0566b tools/ioemu/vnc.c

Lines of this file are not shown. View the raw message.

tools/ioemu/xenstore.c +17 -2
diff -r 7b0c0ab0566b tools/ioemu/xenstore.c

Lines of this file are not shown. View the raw message.

tools/libxc/Makefile +21 -2
diff -r 7b0c0ab0566b tools/libxc/Makefile

Lines of this file are not shown. View the raw message.

tools/libxc/ia64/Makefile +2 -0
diff -r 7b0c0ab0566b tools/libxc/ia64/Makefile

Lines of this file are not shown. View the raw message.

tools/libxc/xc_minios.c new file +308 -0

308 lines not on this page · raw message

tools/libxc/xc_pagetab.c +8 -0
diff -r 7b0c0ab0566b tools/libxc/xc_pagetab.c

Lines of this file are not shown. View the raw message.

tools/libxc/xc_private.h +4 -0
diff -r 7b0c0ab0566b tools/libxc/xc_private.h

Lines of this file are not shown. View the raw message.

tools/libxc/xenctrl.h +3 -0
diff -r 7b0c0ab0566b tools/libxc/xenctrl.h

Lines of this file are not shown. View the raw message.

tools/libxc/xg_private.h +4 -0
diff -r 7b0c0ab0566b tools/libxc/xg_private.h

Lines of this file are not shown. View the raw message.

tools/python/xen/xend/image.py +10 -2
diff -r 7b0c0ab0566b tools/python/xen/xend/image.py

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 7 lines · Samuel Thibault

- Setup a xen-elf cross-compilation environment in stubdom/cross-root
- Add a POSIX layer on top of Mini-OS by linking against the newlib C library and lwIP, and implementing the Unixish part in mini-os/lib/sys.c
- Cross-compile zlib and libpci too.
- Add an xs.h-compatible layer on top of Mini-OS' xenbus.
- Cross-compile libxc with an additional xc_minios.c and a few things disabled.

You hack the libxc headers a bit: is this because you need different definitions of certain things in minios environment (seems unlikely for things like memory barriers and page sizes) or because of namespace conflicts? If the latter we should be able to clean up namespace usage and avoid ifdef'ery. We don't really want CONFIG_MINIOS all over the place, it should be able to behave nicely like any other POSIXish host of libxc.

Apart from that it seems pretty clean. I suppose others may comment on the cleanliness of the changes to qemu code. Trying this patch out is probably the quickest way for me to find out how you've integrated into the build process. e.g., do you symlink out to libxc and so on, and store the object files and build targets somewhere under stubdom/?

-- Keir

#2 lore raw
Quoted 4 lines · Keir Fraser, le Mon 11 Feb 2008 19:14:16 +0000, a écrit :

You hack the libxc headers a bit: is this because you need different definitions of certain things in minios environment (seems unlikely for things like memory barriers and page sizes) or because of namespace conflicts?

Conflicts. Actually they get defined to the same things... Maybe we could have these go to public Xen headers so as to be simply shared.

Quoted 2 lines

do you symlink out to libxc and so on, and store the object files and build targets somewhere under stubdom/?

Exactly, except for extras/mini-os for now because there are various subdirectories and by default it is not compiled in any other way.

Samuel

#3 lore raw
Quoted 7 lines · Samuel Thibault
Quoted 4 lines

You hack the libxc headers a bit: is this because you need different definitions of certain things in minios environment (seems unlikely for things like memory barriers and page sizes) or because of namespace conflicts?

Conflicts. Actually they get defined to the same things... Maybe we could have these go to public Xen headers so as to be simply shared.

It's not really for Xen to define processor-architectural stuff. I'd rather just clean up libxc's namespace usage. Or perhaps it is more appropriate to clean up stubdom's -- it's private architectural definitions shouldn't be leaking into code that includes stubdom's public high-level headers. libxc's namespace should largely be its own playground.

-- Keir

#4 lore raw
Quoted 3 lines · Keir Fraser, le Mon 11 Feb 2008 21:23:37 +0000, a écrit :

perhaps it is more appropriate to clean up stubdom's -- it's private architectural definitions shouldn't be leaking into code that includes stubdom's public high-level headers.

Ok, actually I just had to move the actual definitions of PAGE_SIZE and STACK_SIZE to a separate header, and that let me avoid pulling all internal definitions.

BTW, one of the reason for not enabling its compilation by default could at least be that since we need to setup a cross-compilation environment (binutils, gcc, newlib), we have to download about 70MB of source...

Add stubdomain support.

- Move PAGE_SIZE and STACK_SIZE into __PAGE_SIZE and __STACK_SIZE in arch_limits.h so as to permit getting them from there without pulling all the internal Mini-OS defines.
- Setup a xen-elf cross-compilation environment in stubdom/cross-root
- Add a POSIX layer on top of Mini-OS by linking against the newlib C library and lwIP, and implementing the Unixish part in mini-os/lib/sys.c
- Cross-compile zlib and libpci too.
- Add an xs.h-compatible layer on top of Mini-OS' xenbus.
- Cross-compile libxc with an additional xc_minios.c and a few things disabled.
- Cross-compile ioemu with an additional block-vbd, but without sound, tpm and other details. A few hacks are needed:
- Align ide and scsi buffers at least on sector size to permit direct transmission to the block backend. While we are at it, just page-align it to possibly save a segment. Also, limit the scsi buffer size because of limitations of the block paravirtualization protocol.
- Allocate big tables dynamically rather that letting them go to bss: when Mini-OS gets installed in memory, bss is not lazily allocated, and doing so during Mini-OS is unnecessarily trick while we can simply use malloc.
- Have the domain killer send SIGHUP to the device-model script, allow the script 10s to clean up, and if still not dead, send SIGKILL.
- Had to change the Mini-OS compilation somehow, so as to export Mini-OS compilation flags to the Makefiles of libxc and ioemu.

.hgignore +11 -0
diff -r 88818d55e95a .hgignore
@@ -221,6 +221,17 @@
 ^tools/xm-test/lib/XmTestLib/config.py$
 ^tools/xm-test/lib/XmTestReport/xmtest.py$
 ^tools/xm-test/tests/.*\.test$
+^stubdom/binutils.*$
+^stubdom/cross-root.*$
+^stubdom/gcc.*$
+^stubdom/include.*$
+^stubdom/ioemu.*$
+^stubdom/libxc.*$
+^stubdom/lwip.*$
+^stubdom/mini-os.*$
+^stubdom/newlib.*$
+^stubdom/pciutils.*$
+^stubdom/zlib.*$
 ^xen/BLOG$
 ^xen/System.map$
 ^xen/TAGS$
Config.mk +8 -0
diff -r 88818d55e95a Config.mk
@@ -27,6 +27,14 @@ DESTDIR     ?= /
 
 include $(XEN_ROOT)/config/$(XEN_OS).mk
 include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
+
+ifeq ($(stubdom),y)
+include $(XEN_ROOT)/extras/mini-os/Config.mk
+CFLAGS += $(DEF_CFLAGS) $(ARCH_CFLAGS)
+CPPFLAGS += $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) $(extra_incl)
+ASFLAGS += $(DEF_ASFLAGS) $(ARCH_ASFLAGS)
+LDFLAGS += $(DEF_LDFLAGS) $(ARCH_LDFLAGS)
+endif
 
 ifneq ($(EXTRA_PREFIX),)
 EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
extras/mini-os/Config.mk new file +76 -0

76 lines not on this page · raw message

extras/mini-os/Makefile +31 -50

106 lines not on this page · raw message

extras/mini-os/arch/ia64/Makefile +3 -1
diff -r 88818d55e95a extras/mini-os/arch/ia64/Makefile
@@ -4,6 +4,8 @@
 
 XEN_ROOT = ../../../..
 include $(XEN_ROOT)/Config.mk
+
+include ../../Config.mk
 
 include arch.mk
 include ../../minios.mk
@@ -41,7 +43,7 @@ ARCH_OBJS += __divdi3.o
 
 GEN_OFF_SRC := gen_off.c
 GEN_OFF_ASM := gen_off.s
-GEN_OFF_H   := $(ARCH_INC)/offsets.h
+GEN_OFF_H   := $(MINI-OS_ROOT)/include/$(ARCH_INC)/offsets.h
 
 all: $(ARCH_LIB)
 
extras/mini-os/arch/ia64/minios-ia64.lds +12 -0
diff -r 88818d55e95a extras/mini-os/arch/ia64/minios-ia64.lds
@@ -40,6 +40,18 @@ SECTIONS
   .rodata.str1.8 : AT(ADDR(.rodata.str1.8) - (((5<<(61))+0x100000000) - (1 << 20)))
   { *(.rodata.str1.8) }
 
+  /* newlib initialization functions */
+  . = ALIGN(64 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { *(.preinit_array) }
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { *(.init_array) }
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { *(.fini_array) }
+  PROVIDE (__fini_array_end = .);
+
   .IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - (((5<<(61))+0x100000000) - (1 << 20)))
   { *(.IA_64.unwind_info) }
 
extras/mini-os/arch/ia64/mm.c +8 -0
diff -r 88818d55e95a extras/mini-os/arch/ia64/mm.c
@@ -42,6 +42,14 @@ extern uint64_t _text[], _etext[], _end[
 extern uint64_t _text[], _etext[], _end[], kstack[], phys_start[];
 
 uint64_t kernstart, kernend, kernsize, kernpstart, kernpend;
+
+#ifdef HAVE_LIBC
+uint8_t _heap[512 * 1024];
+unsigned long heap = (unsigned long)_heap,
+              brk = (unsigned long)_heap,
+              heap_mapped = (unsigned long)_heap + sizeof(_heap),
+              heap_end = (unsigned long)_heap + sizeof(_heap);
+#endif
 
 /* Print the available memory chunks. */
 static void
extras/mini-os/arch/x86/Makefile +2 -1
diff -r 88818d55e95a extras/mini-os/arch/x86/Makefile
@@ -5,13 +5,14 @@
 
 XEN_ROOT = ../../../..
 include $(XEN_ROOT)/Config.mk
+include ../../Config.mk
 
 # include arch.mk has to be before mini-os.mk!
 
 include arch.mk
 include ../../minios.mk
 
-# Sources here are all *.c *.S without $(TARGET_ARCH).S
+# Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S
 # This is handled in $(HEAD_ARCH_OBJ)
 ARCH_SRCS := $(wildcard *.c)
 
extras/mini-os/arch/x86/arch.mk +4 -4
diff -r 88818d55e95a extras/mini-os/arch/x86/arch.mk
@@ -3,11 +3,11 @@
 # (including x86_32, x86_32y and x86_64).
 #
 
-ifeq ($(TARGET_ARCH),x86_32)
+ifeq ($(XEN_TARGET_ARCH),x86_32)
 ARCH_CFLAGS  := -m32 -march=i686
 ARCH_LDFLAGS := -m elf_i386
 ARCH_ASFLAGS := -m32
-EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
+EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH)
 EXTRA_SRC += arch/$(EXTRA_INC)
 
 ifeq ($(XEN_TARGET_X86_PAE),y)
@@ -16,12 +16,12 @@ endif
 endif
 endif
 
-ifeq ($(TARGET_ARCH),x86_64)
+ifeq ($(XEN_TARGET_ARCH),x86_64)
 ARCH_CFLAGS := -m64 -mno-red-zone -fno-reorder-blocks
 ARCH_CFLAGS += -fno-asynchronous-unwind-tables
 ARCH_ASFLAGS := -m64
 ARCH_LDFLAGS := -m elf_x86_64
-EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
+EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH)
 EXTRA_SRC += arch/$(EXTRA_INC)
 endif
 
extras/mini-os/arch/x86/minios-x86_32.lds +12 -0
diff -r 88818d55e95a extras/mini-os/arch/x86/minios-x86_32.lds
@@ -15,6 +15,18 @@ SECTIONS
   .rodata : { *(.rodata) *(.rodata.*) }
   . = ALIGN(4096);
   _erodata = .;
+
+  /* newlib initialization functions */
+  . = ALIGN(32 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { *(.preinit_array) }
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { *(.init_array) }
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { *(.fini_array) }
+  PROVIDE (__fini_array_end = .);
 
   .data : {			/* Data */
 	*(.data)
extras/mini-os/arch/x86/minios-x86_64.lds +12 -0
diff -r 88818d55e95a extras/mini-os/arch/x86/minios-x86_64.lds
@@ -15,6 +15,18 @@ SECTIONS
   .rodata : { *(.rodata) *(.rodata.*) }
   . = ALIGN(4096);
   _erodata = .;
+
+  /* newlib initialization functions */
+  . = ALIGN(64 / 8);
+  PROVIDE (__preinit_array_start = .);
+  .preinit_array     : { *(.preinit_array) }
+  PROVIDE (__preinit_array_end = .);
+  PROVIDE (__init_array_start = .);
+  .init_array     : { *(.init_array) }
+  PROVIDE (__init_array_end = .);
+  PROVIDE (__fini_array_start = .);
+  .fini_array     : { *(.fini_array) }
+  PROVIDE (__fini_array_end = .);
 
   .data : {			/* Data */
 	*(.data)
extras/mini-os/arch/x86/mm.c +17 -0
diff -r 88818d55e95a extras/mini-os/arch/x86/mm.c
@@ -448,6 +448,15 @@ static unsigned long demand_map_area_sta
 #define DEMAND_MAP_PAGES ((2ULL << 30) / PAGE_SIZE)
 #endif
 
+#ifdef HAVE_LIBC
+unsigned long heap, brk, heap_mapped, heap_end;
+#ifdef __x86_64__
+#define HEAP_PAGES ((128ULL << 30) / PAGE_SIZE)
+#else
+#define HEAP_PAGES ((1ULL << 30) / PAGE_SIZE)
+#endif
+#endif
+
 void arch_init_demand_mapping_area(unsigned long cur_pfn)
 {
     cur_pfn++;
@@ -455,6 +464,14 @@ void arch_init_demand_mapping_area(unsig
     demand_map_area_start = (unsigned long) pfn_to_virt(cur_pfn);
     cur_pfn += DEMAND_MAP_PAGES;
     printk("Demand map pfns at %lx-%lx.\n", demand_map_area_start, pfn_to_virt(cur_pfn));
+
+#ifdef HAVE_LIBC
+    cur_pfn++;
+    heap_mapped = brk = heap = (unsigned long) pfn_to_virt(cur_pfn);
+    cur_pfn += HEAP_PAGES;
+    heap_end = (unsigned long) pfn_to_virt(cur_pfn);
+    printk("Heap resides at %lx-%lx.\n", brk, heap_end);
+#endif
 }
 
 #define MAP_BATCH ((STACK_SIZE / 2) / sizeof(mmu_update_t))
extras/mini-os/arch/x86/x86_32.S +3 -3
diff -r 88818d55e95a extras/mini-os/arch/x86/x86_32.S
@@ -1,5 +1,5 @@
 #include <os.h>
-#include <arch_mm.h>
+#include <arch_limits.h>
 #include <xen/arch-x86_32.h>
 
 .section __xen_guest
@@ -22,12 +22,12 @@ _start:
 _start:
         cld
         lss stack_start,%esp
-        andl $(~(STACK_SIZE-1)), %esp
+        andl $(~(__STACK_SIZE-1)), %esp
         push %esi 
         call start_kernel
 
 stack_start:
-	.long stack+(2*STACK_SIZE), __KERNEL_SS
+	.long stack+(2*__STACK_SIZE), __KERNEL_SS
 
         /* Unpleasant -- the PTE that maps this page is actually overwritten */
         /* to map the real shared-info page! :-)                             */
extras/mini-os/arch/x86/x86_64.S +3 -3
diff -r 88818d55e95a extras/mini-os/arch/x86/x86_64.S
@@ -1,5 +1,5 @@
 #include <os.h>
-#include <arch_mm.h>
+#include <arch_limits.h>
 #include <xen/features.h>
 
 .section __xen_guest
@@ -19,12 +19,12 @@ _start:
 _start:
         cld
         movq stack_start(%rip),%rsp
-        andq $(~(STACK_SIZE-1)), %rsp
+        andq $(~(__STACK_SIZE-1)), %rsp
         movq %rsi,%rdi
         call start_kernel
 
 stack_start:
-        .quad stack+(2*STACK_SIZE)
+        .quad stack+(2*__STACK_SIZE)
 
         /* Unpleasant -- the PTE that maps this page is actually overwritten */
         /* to map the real shared-info page! :-)                             */
extras/mini-os/blkfront.c +41 -5

98 lines not on this page · raw message

extras/mini-os/include/arch/cc.h +7 -0
diff -r 88818d55e95a extras/mini-os/include/arch/cc.h
@@ -54,7 +54,14 @@ extern void lwip_die(char *fmt, ...);
 #include <errno.h>
 
 /*   Not required by the docs, but needed for network-order calculations */
+#ifdef HAVE_LIBC
+#include <machine/endian.h>
+#ifndef BIG_ENDIAN
+#error endian.h does not define byte order
+#endif
+#else
 #include <endian.h>
+#endif
 
 #include <inttypes.h>
 #define S16_F PRIi16
extras/mini-os/include/byteswap.h new file +22 -0
diff -r 88818d55e95a extras/mini-os/include/byteswap.h
@@ -0,0 +1,22 @@
+#ifndef _BYTESWAP_H_
+#define _BYTESWAP_H_
+
+/* Unfortunately not provided by newlib.  */
+#define bswap_16(x) \
+    ((((x) & 0xff00) >> 8) | (((x) & 0xff) << 8))
+
+#define bswap_32(x) \
+    ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
+     (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
+
+#define bswap_64(x) \
+    ((((x) & 0xff00000000000000ULL) >> 56) | \
+     (((x) & 0x00ff000000000000ULL) >> 40) | \
+     (((x) & 0x0000ff0000000000ULL) >> 24) | \
+     (((x) & 0x000000ff00000000ULL) >>  8) | \
+     (((x) & 0x00000000ff000000ULL) <<  8) | \
+     (((x) & 0x0000000000ff0000ULL) << 24) | \
+     (((x) & 0x000000000000ff00ULL) << 40) | \
+     (((x) & 0x00000000000000ffULL) << 56))
+
+#endif /* _BYTESWAP_H */
extras/mini-os/include/console.h +3 -0
diff -r 88818d55e95a extras/mini-os/include/console.h
@@ -36,7 +36,9 @@
 #ifndef _LIB_CONSOLE_H_
 #define _LIB_CONSOLE_H_
 
+#include<os.h>
 #include<traps.h>
+#include<stdarg.h>
 
 void print(int direct, const char *fmt, va_list args);
 void printk(const char *fmt, ...);
@@ -48,5 +50,6 @@ void xencons_tx(void);
 void xencons_tx(void);
 
 void init_console(void);
+void console_print(char *data, int length);
 
 #endif /* _LIB_CONSOLE_H_ */
extras/mini-os/include/errno.h +7 -0
diff -r 88818d55e95a extras/mini-os/include/errno.h
@@ -107,4 +107,11 @@
 #define	EOWNERDEAD	130	/* Owner died */
 #define	ENOTRECOVERABLE	131	/* State not recoverable */
 
+#ifdef HAVE_LIBC
+#include <sched.h>
+extern int errno;
+#define ERRNO
+#define errno (get_current()->reent._errno)
 #endif
+
+#endif
extras/mini-os/include/fcntl.h +3 -0
diff -r 88818d55e95a extras/mini-os/include/fcntl.h
@@ -86,4 +86,7 @@ struct flock64 {
 
 #define F_LINUX_SPECIFIC_BASE	1024
 */
+
+int open(const char *path, int flags, ...);
+int fcntl(int fd, int cmd, ...);
 #endif
extras/mini-os/include/fs.h +1 -0
diff -r 88818d55e95a extras/mini-os/include/fs.h
@@ -22,6 +22,7 @@ struct fs_import
     struct semaphore reqs_sem;      /* Accounts requests resource           */
 };
 
+extern struct fs_import *fs_import;
 
 void init_fs_frontend(void);
 
extras/mini-os/include/ia64/arch_limits.h new file +12 -0
diff -r 88818d55e95a extras/mini-os/include/ia64/arch_limits.h
@@ -0,0 +1,12 @@
+
+#ifndef __ARCH_LIMITS_H__
+#define __ARCH_LIMITS_H__
+
+/* Commonly 16K pages are used. */
+#define __PAGE_SHIFT	14	/* 16K pages */
+#define __PAGE_SIZE	(1<<(__PAGE_SHIFT))
+
+#define __STACK_SIZE_PAGE_ORDER   2
+#define __STACK_SIZE              (__PAGE_SIZE * (1 << __STACK_SIZE_PAGE_ORDER))
+          
+#endif /* __ARCH_LIMITS_H__ */
extras/mini-os/include/ia64/arch_mm.h +1 -3
diff -r 88818d55e95a extras/mini-os/include/ia64/arch_mm.h
@@ -35,11 +35,9 @@
 #define virt_to_mfn(x)	virt_to_pfn(x)
 #define virtual_to_mfn(x)      (ia64_tpa((uint64_t)(x)) >> PAGE_SHIFT)
 
-#define STACK_SIZE_PAGE_ORDER   1
-#define STACK_SIZE              (PAGE_SIZE * (1 << STACK_SIZE_PAGE_ORDER))
-
 #define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, 0, 0)
 /* TODO */
 #define map_zero(n, a) map_frames_ex(NULL, n, 0, 0, a, DOMID_SELF, 0, 0)
+#define do_map_zero(start, n) ((void)0)
 
 #endif /* __ARCH_MM_H__ */
extras/mini-os/include/ia64/page.h +3 -3
diff -r 88818d55e95a extras/mini-os/include/ia64/page.h
@@ -43,9 +43,9 @@
 /* The efi-pal page size for text and data. */
 #define PAL_TR_PAGE_SIZE	PTE_PS_1M
 
-/* Commonly 16K pages are used. */
-#define PAGE_SHIFT	14	/* 16K pages */
-#define PAGE_SIZE	(1<<(PAGE_SHIFT))
+#include "arch_limits.h"
+#define PAGE_SHIFT	__PAGE_SHIFT
+#define PAGE_SIZE	__PAGE_SIZE
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
 #define KSTACK_PAGES	4	/* 4 pages for the kernel stack + bsp */
extras/mini-os/include/lib.h +59 -0

75 lines not on this page · raw message

extras/mini-os/include/linux/types.h new file +5 -0
diff -r 88818d55e95a extras/mini-os/include/linux/types.h
@@ -0,0 +1,5 @@
+#ifndef _LINUX_TYPES_H_
+#define _LINUX_TYPES_H_
+#include <types.h>
+typedef u64 __u64;
+#endif /* _LINUX_TYPES_H_ */
extras/mini-os/include/mm.h +8 -0
diff -r 88818d55e95a extras/mini-os/include/mm.h
@@ -36,7 +36,12 @@
 #endif
 
 #include <lib.h>
+
+#include <arch_limits.h>
 #include <arch_mm.h>
+
+#define STACK_SIZE_PAGE_ORDER __STACK_SIZE_PAGE_ORDER
+#define STACK_SIZE __STACK_SIZE
 
 
 void init_mm(void);
@@ -61,5 +66,8 @@ void *map_frames_ex(unsigned long *f, un
 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);
+#ifdef HAVE_LIBC
+extern unsigned long heap, brk, heap_mapped, heap_end;
+#endif
 
 #endif /* _MM_H_ */
extras/mini-os/include/netfront.h +4 -0
diff -r 88818d55e95a extras/mini-os/include/netfront.h
@@ -6,6 +6,10 @@ struct netfront_dev *init_netfront(char 
 struct netfront_dev *init_netfront(char *nodename, void (*netif_rx)(unsigned char *data, int len), unsigned char rawmac[6]);
 void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
 void shutdown_netfront(struct netfront_dev *dev);
+#ifdef HAVE_LIBC
+int netfront_tap_open(char *nodename);
+ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t len);
+#endif
 
 extern struct wait_queue_head netfront_queue;
 
extras/mini-os/include/posix/dirent.h new file +24 -0
diff -r 88818d55e95a extras/mini-os/include/posix/dirent.h
@@ -0,0 +1,24 @@
+#ifndef _POSIX_DIRENT_H
+#define _POSIX_DIRENT_H
+
+#include <sys/types.h>
+
+struct dirent {
+        char *d_name;
+};
+
+typedef struct {
+        struct dirent dirent;
+        char *name;
+        int32_t offset;
+        char **entries;
+        int32_t curentry;
+        int32_t nbentries;
+        int has_more;
+} DIR;
+
+DIR *opendir(const char *name);
+struct dirent *readdir(DIR *dir);
+int closedir(DIR *dir);
+
+#endif /* _POSIX_DIRENT_H */
extras/mini-os/include/posix/limits.h new file +9 -0
diff -r 88818d55e95a extras/mini-os/include/posix/limits.h
@@ -0,0 +1,9 @@
+#ifndef _POSIX_LIMITS_H
+#define _POSIX_LIMITS_H
+
+#include_next <limits.h>
+#include <arch_limits.h>
+
+#define PATH_MAX __PAGE_SIZE
+
+#endif /* _POSIX_LIMITS_H */
extras/mini-os/include/posix/netdb.h new file +9 -0
diff -r 88818d55e95a extras/mini-os/include/posix/netdb.h
@@ -0,0 +1,9 @@
+#ifndef _POSIX_NETDB_H_
+#define _POSIX_NETDB_H_
+
+struct hostent {
+    char *h_addr;
+};
+#define gethostbyname(buf) NULL
+
+#endif /* _POSIX_NETDB_H_ */
extras/mini-os/include/posix/netinet/in.h new file +7 -0
diff -r 88818d55e95a extras/mini-os/include/posix/netinet/in.h
@@ -0,0 +1,7 @@
+#ifndef _POSIX_SYS_IN_H_
+#define _POSIX_SYS_IN_H_
+
+#include <fcntl.h>
+#include <lwip/sockets.h>
+
+#endif /* _POSIX_SYS_IN_H_ */
extras/mini-os/include/posix/netinet/tcp.h new file +6 -0
diff -r 88818d55e95a extras/mini-os/include/posix/netinet/tcp.h
@@ -0,0 +1,6 @@
+#ifndef _POSIX_SYS_TCP_H_
+#define _POSIX_SYS_TCP_H_
+
+#include <lwip/tcp.h>
+
+#endif /* _POSIX_SYS_TCP_H_ */
extras/mini-os/include/posix/pthread.h new file +19 -0
diff -r 88818d55e95a extras/mini-os/include/posix/pthread.h
@@ -0,0 +1,19 @@
+#ifndef _POSIX_PTHREAD_H
+#define _POSIX_PTHREAD_H
+
+/* Let's be single-threaded for now.  */
+
+typedef void *pthread_key_t;
+typedef struct {} pthread_mutex_t, pthread_once_t;
+#define PTHREAD_MUTEX_INITIALIZER {}
+#define PTHREAD_ONCE_INIT {}
+static inline int pthread_mutex_lock(pthread_mutex_t *mutex) { return 0; }
+static inline int pthread_mutex_unlock(pthread_mutex_t *mutex) { return 0; }
+static inline int pthread_key_create(pthread_key_t *key, void (*destr_function)(void*)) { *key = NULL; return 0; }
+static inline int pthread_setspecific(pthread_key_t *key, const void *pointer) { *key = (void*) pointer; return 0; }
+static inline void *pthread_getspecific(pthread_key_t *key) { return *key; }
+static inline int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) { init_routine(); return 0; }
+
+#define __thread
+
+#endif /* _POSIX_PTHREAD_H */
extras/mini-os/include/posix/stdlib.h new file +8 -0
diff -r 88818d55e95a extras/mini-os/include/posix/stdlib.h
@@ -0,0 +1,8 @@
+#ifndef _POSIX_STDLIB_H
+#define _POSIX_STDLIB_H
+
+#include_next <stdlib.h>
+
+#define realpath(p,r) strcpy(r,p)
+
+#endif /* _POSIX_STDLIB_H */
extras/mini-os/include/posix/strings.h new file +8 -0
diff -r 88818d55e95a extras/mini-os/include/posix/strings.h
@@ -0,0 +1,8 @@
+#ifndef _POSIX_STRINGS_H
+#define _POSIX_STRINGS_H
+
+#include <string.h>
+
+#define bzero(ptr, size) (memset((ptr), '\0', (size)), (void) 0)
+
+#endif /* _POSIX_STRINGS_H */
extras/mini-os/include/posix/sys/ioctl.h new file +16 -0
diff -r 88818d55e95a extras/mini-os/include/posix/sys/ioctl.h
@@ -0,0 +1,16 @@
+#ifndef _POSIX_SYS_IOCTL_H
+#define _POSIX_SYS_IOCTL_H
+
+int ioctl(int fd, int request, ...);
+
+#define _IOC_NONE 0
+#define _IOC_WRITE 1
+#define _IOC_READ 2
+
+#define _IOC(rw, class, n, size) \
+    	(((rw   ) << 30) | \
+	 ((class) << 22) | \
+	 ((n    ) << 14) | \
+	 ((size ) << 0))
+
+#endif /* _POSIX_SYS_IOCTL_H */
extras/mini-os/include/posix/sys/mman.h new file +19 -0
diff -r 88818d55e95a extras/mini-os/include/posix/sys/mman.h
@@ -0,0 +1,19 @@
+#ifndef _POSIX_SYS_MMAN_H
+#define _POSIX_SYS_MMAN_H
+
+#define PROT_READ	0x1
+#define PROT_WRITE	0x2
+#define PROT_EXEC	0x4
+
+#define MAP_SHARED	0x01
+#define MAP_PRIVATE	0x02
+#define MAP_ANON	0x20
+
+#define MAP_FAILED	((void*)0)
+
+void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
+int munmap(void *start, size_t length);
+#define munlock(addr, len) ((void)addr, (void)len, 0)
+#define mlock(addr, len) ((void)addr, (void)len, 0)
+
+#endif /* _POSIX_SYS_MMAN_H */
extras/mini-os/include/posix/sys/select.h new file +7 -0
diff -r 88818d55e95a extras/mini-os/include/posix/sys/select.h
@@ -0,0 +1,7 @@
+#ifndef _POSIX_SELECT_H
+#define _POSIX_SELECT_H
+
+#include <sys/time.h>
+int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+
+#endif /* _POSIX_SELECT_H */
extras/mini-os/include/posix/sys/socket.h new file +31 -0
diff -r 88818d55e95a extras/mini-os/include/posix/sys/socket.h
@@ -0,0 +1,31 @@
+#ifndef _POSIX_SYS_SOCKET_H_
+#define _POSIX_SYS_SOCKET_H_
+
+#include <fcntl.h>
+#include <lwip/sockets.h>
+
+int accept(int s, struct sockaddr *addr, socklen_t *addrlen);
+int bind(int s, struct sockaddr *name, socklen_t namelen);
+int shutdown(int s, int how);
+int getpeername (int s, struct sockaddr *name, socklen_t *namelen);
+int getsockname (int s, struct sockaddr *name, socklen_t *namelen);
+int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
+int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
+int close(int s);
+int connect(int s, struct sockaddr *name, socklen_t namelen);
+int listen(int s, int backlog);
+int recv(int s, void *mem, int len, unsigned int flags);
+//int read(int s, void *mem, int len);
+int recvfrom(int s, void *mem, int len, unsigned int flags,
+      struct sockaddr *from, socklen_t *fromlen);
+int send(int s, void *dataptr, int size, unsigned int flags);
+int sendto(int s, void *dataptr, int size, unsigned int flags,
+    struct sockaddr *to, socklen_t tolen);
+int socket(int domain, int type, int protocol);
+//int write(int s, void *dataptr, int size);
+int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
+                struct timeval *timeout);
+//int ioctl(int s, long cmd, void *argp);
+int getsockname(int s, struct sockaddr *name, socklen_t *namelen);
+
+#endif /* _POSIX_SYS_SOCKET_H_ */
extras/mini-os/include/posix/termios.h new file +87 -0

87 lines not on this page · raw message

extras/mini-os/include/posix/time.h new file +10 -0
diff -r 88818d55e95a extras/mini-os/include/posix/time.h
@@ -0,0 +1,10 @@
+#ifndef _POSIX_TIME_H
+#define _POSIX_TIME_H
+
+#include <sys/time.h>
+#define CLOCK_MONOTONIC	2
+#include_next <time.h>
+
+int nanosleep(const struct timespec *req, struct timespec *rem);
+
+#endif /* _POSIX_TIME_H */
extras/mini-os/include/posix/unistd.h new file +12 -0
diff -r 88818d55e95a extras/mini-os/include/posix/unistd.h
@@ -0,0 +1,12 @@
+#ifndef _POSIX_UNISTD_H
+#define _POSIX_UNISTD_H
+
+#include_next <unistd.h>
+#include <sys/select.h>
+#include <arch_limits.h>
+
+#define getpagesize() __PAGE_SIZE
+
+int ftruncate(int fd, off_t length);
+
+#endif /* _POSIX_UNISTD_H */
extras/mini-os/include/sched.h +3 -0
diff -r 88818d55e95a extras/mini-os/include/sched.h
@@ -19,6 +19,9 @@ struct thread
     struct list_head thread_list;
     u32 flags;
     s_time_t wakeup_time;
+#ifdef HAVE_LIBC
+    struct _reent reent;
+#endif
 };
 
 extern struct thread *idle_thread;
extras/mini-os/include/sys/time.h +4 -0
diff -r 88818d55e95a extras/mini-os/include/sys/time.h
@@ -20,6 +20,9 @@
 #ifndef _MINIOS_SYS_TIME_H_
 #define _MINIOS_SYS_TIME_H_
 
+#ifdef HAVE_LIBC
+#include_next <sys/time.h>
+#else
 struct timespec {
     time_t      tv_sec;
     long        tv_nsec;
@@ -34,5 +37,6 @@ struct timeval {
 };
 
 int      gettimeofday(struct timeval *tv, void *tz);
+#endif
 
 #endif /* _MINIOS_SYS_TIME_H_ */
extras/mini-os/include/time.h +8 -3
diff -r 88818d55e95a extras/mini-os/include/time.h
@@ -17,8 +17,9 @@
  ****************************************************************************
  */
 
-#ifndef _TIME_H_
-#define _TIME_H_
+#ifndef _MINIOS_TIME_H_
+#define _MINIOS_TIME_H_
+#include <types.h>
 
 /*
  * System Time
@@ -44,8 +45,12 @@ typedef s64 s_time_t;
 /* wall clock time  */
 typedef long time_t;
 typedef long suseconds_t;
+
 #include <sys/time.h>
 
+#ifdef HAVE_LIBC
+#include_next <time.h>
+#endif
 
 /* prototypes */
 void     init_time(void);
@@ -54,4 +59,4 @@ u64      monotonic_clock(void);
 u64      monotonic_clock(void);
 void     block_domain(s_time_t until);
 
-#endif /* _TIME_H_ */
+#endif /* _MINIOS_TIME_H_ */
extras/mini-os/include/x86/arch_limits.h new file +20 -0
diff -r 88818d55e95a extras/mini-os/include/x86/arch_limits.h
@@ -0,0 +1,20 @@
+
+#ifndef __ARCH_LIMITS_H__
+#define __ARCH_LIMITS_H__
+
+#define __PAGE_SHIFT      12
+
+#ifdef __ASSEMBLY__
+#define __PAGE_SIZE       (1 << __PAGE_SHIFT)
+#else
+#ifndef CONFIG_X86_PAE
+#define __PAGE_SIZE       (1UL << __PAGE_SHIFT)
+#else
+#define __PAGE_SIZE       (1ULL << __PAGE_SHIFT)
+#endif
+#endif
+
+#define __STACK_SIZE_PAGE_ORDER  4
+#define __STACK_SIZE             (__PAGE_SIZE * (1 << __STACK_SIZE_PAGE_ORDER))
+          
+#endif /* __ARCH_LIMITS_H__ */
extras/mini-os/include/x86/arch_mm.h +9 -13
diff -r 88818d55e95a extras/mini-os/include/x86/arch_mm.h
@@ -157,16 +157,9 @@ typedef unsigned long pgentry_t;
 #define L4_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
 #endif /* __i386__ || __x86_64__ */
 
-#ifdef __ASSEMBLY__
-#define PAGE_SIZE       (1 << L1_PAGETABLE_SHIFT)
-#else
-#ifndef CONFIG_X86_PAE
-#define PAGE_SIZE       (1UL << L1_PAGETABLE_SHIFT)
-#else
-#define PAGE_SIZE       (1ULL << L1_PAGETABLE_SHIFT)
-#endif
-#endif
-#define PAGE_SHIFT      L1_PAGETABLE_SHIFT
+#include "arch_limits.h"
+#define PAGE_SIZE       __PAGE_SIZE
+#define PAGE_SHIFT      __PAGE_SHIFT
 #define PAGE_MASK       (~(PAGE_SIZE-1))
 
 #define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> L1_PAGETABLE_SHIFT)
@@ -176,9 +169,6 @@ typedef unsigned long pgentry_t;
 
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
-#define STACK_SIZE_PAGE_ORDER  1
-#define STACK_SIZE             (PAGE_SIZE * (1 << STACK_SIZE_PAGE_ORDER))
 
 #ifndef __ASSEMBLY__
 /* Definitions for machine and pseudophysical addresses. */
@@ -257,5 +247,11 @@ static __inline__ paddr_t machine_to_phy
 
 #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_ */
extras/mini-os/include/x86/arch_sched.h +2 -2
diff -r 88818d55e95a extras/mini-os/include/x86/arch_sched.h
@@ -2,7 +2,7 @@
 #ifndef __ARCH_SCHED_H__
 #define __ARCH_SCHED_H__
 
-#include <arch_mm.h>
+#include <arch_limits.h>
 
 static inline struct thread* get_current(void)
 {
@@ -12,7 +12,7 @@ static inline struct thread* get_current
 #else
     register unsigned long sp asm("rsp");
 #endif 
-    current = (void *)(unsigned long)(sp & ~(STACK_SIZE-1));
+    current = (void *)(unsigned long)(sp & ~(__STACK_SIZE-1));
     return *current;
 }
 
extras/mini-os/include/x86/arch_spinlock.h +1 -0
diff -r 88818d55e95a extras/mini-os/include/x86/arch_spinlock.h
@@ -4,6 +4,7 @@
 #define __ARCH_ASM_SPINLOCK_H
 
 #include <lib.h>
+#include "os.h"
 
 
 #define ARCH_SPIN_LOCK_UNLOCKED (spinlock_t) { 1 }
extras/mini-os/include/x86/os.h +1 -0
diff -r 88818d55e95a extras/mini-os/include/x86/os.h
@@ -563,6 +563,7 @@ static __inline__ int synch_var_test_bit
  synch_var_test_bit((nr),(addr)))
 
 
+#undef ADDR
 
 #endif /* not assembly */
 #endif /* _OS_H_ */
extras/mini-os/lib/sys.c new file +1083 -0

1,083 lines not on this page · raw message

extras/mini-os/lib/xs.c new file +187 -0

187 lines not on this page · raw message

extras/mini-os/main-caml.c new file +42 -0

42 lines not on this page · raw message

extras/mini-os/main.c new file +167 -0

167 lines not on this page · raw message

extras/mini-os/minios.mk +5 -8
diff -r 88818d55e95a extras/mini-os/minios.mk
@@ -9,7 +9,7 @@ DEF_CFLAGS += -fno-builtin -Wall -Werror
 DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
 DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
 DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
-DEF_CFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
+DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
 
 DEF_ASFLAGS = -D__ASSEMBLY__
 DEF_LDFLAGS =
@@ -24,11 +24,9 @@ endif
 # DEF_... flags are the common mini-os flags,
 # ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk
 CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS)
+CPPFLAGS := $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS)
 ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS)
 LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS)
-
-# The path pointing to the architecture specific header files.
-ARCH_INC := $(MINI-OS_ROOT)/include/$(TARGET_ARCH_FAM)
 
 # Special build dependencies.
 # Rebuild all after touching this/these file(s)
@@ -44,18 +42,17 @@ HDRS += $(extra_heads)
 HDRS += $(extra_heads)
 
 # Add the special header directories to the include paths.
-extra_incl := $(foreach dir,$(EXTRA_INC),-I$(MINI-OS_ROOT)/include/$(dir))
-override CPPFLAGS := -I$(MINI-OS_ROOT)/include $(CPPFLAGS) -I$(ARCH_INC)	$(extra_incl)
+override CPPFLAGS := $(CPPFLAGS) $(extra_incl)
 
 # The name of the architecture specific library.
 # This is on x86_32: libx86_32.a
 # $(ARCH_LIB) has to built in the architecture specific directory.
-ARCH_LIB_NAME = $(TARGET_ARCH)
+ARCH_LIB_NAME = $(XEN_TARGET_ARCH)
 ARCH_LIB := lib$(ARCH_LIB_NAME).a
 
 # This object contains the entrypoint for startup from Xen.
 # $(HEAD_ARCH_OBJ) has to be built in the architecture specific directory.
-HEAD_ARCH_OBJ := $(TARGET_ARCH).o
+HEAD_ARCH_OBJ := $(XEN_TARGET_ARCH).o
 HEAD_OBJ := $(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ)
 
 
extras/mini-os/mm.c +23 -0
diff -r 88818d55e95a extras/mini-os/mm.c
@@ -360,6 +360,29 @@ void free_pages(void *pointer, int order
    
 }
 
+#ifdef HAVE_LIBC
+void *sbrk(ptrdiff_t increment)
+{
+    unsigned long old_brk = brk;
+    unsigned long new_brk = old_brk + increment;
+
+    if (new_brk > heap_end) {
+	printk("Heap exhausted: %p + %lx = %p > %p\n", old_brk, increment, new_brk, heap_end);
+	return NULL;
+    }
+    
+    if (new_brk > heap_mapped) {
+        unsigned long n = (new_brk - heap_mapped + PAGE_SIZE - 1) / PAGE_SIZE;
+        do_map_zero(heap_mapped, n);
+        heap_mapped += n * PAGE_SIZE;
+    }
+
+    brk = new_brk;
+
+    return (void *) old_brk;
+}
+#endif
+
 
 
 void init_mm(void)
extras/mini-os/netfront.c +94 -4

156 lines not on this page · raw message

extras/mini-os/sched.c +44 -0

74 lines not on this page · raw message

stubdom/Makefile new file +256 -0

80 lines not on this page · raw message

stubdom/README new file +41 -0

41 lines not on this page · raw message

stubdom/binutils.patch new file +14 -0
diff -r 88818d55e95a stubdom/binutils.patch

Lines of this file are not shown. View the raw message.

stubdom/caml/Makefile new file +18 -0
diff -r 88818d55e95a stubdom/caml/Makefile

Lines of this file are not shown. View the raw message.

stubdom/caml/hello.ml new file +4 -0
diff -r 88818d55e95a stubdom/caml/hello.ml

Lines of this file are not shown. View the raw message.

stubdom/gcc.patch new file +31 -0
diff -r 88818d55e95a stubdom/gcc.patch

Lines of this file are not shown. View the raw message.

stubdom/libpci.config.h new file +5 -0
diff -r 88818d55e95a stubdom/libpci.config.h

Lines of this file are not shown. View the raw message.

stubdom/libpci.config.mak new file +2 -0
diff -r 88818d55e95a stubdom/libpci.config.mak

Lines of this file are not shown. View the raw message.

stubdom/newlib.patch new file +203 -0

203 lines not on this page · raw message

stubdom/stubdom-dm new file +97 -0

97 lines not on this page · raw message

tools/ioemu/Makefile.target +35 -7

42 lines not on this page · raw message

tools/ioemu/aes.c +2 -0
diff -r 88818d55e95a tools/ioemu/aes.c

Lines of this file are not shown. View the raw message.

tools/ioemu/block-vbd.c new file +341 -0

341 lines not on this page · raw message

tools/ioemu/block.c +3 -0
diff -r 88818d55e95a tools/ioemu/block.c

Lines of this file are not shown. View the raw message.

tools/ioemu/configure +21 -1
diff -r 88818d55e95a tools/ioemu/configure

Lines of this file are not shown. View the raw message.

tools/ioemu/exec-all.h +4 -0
diff -r 88818d55e95a tools/ioemu/exec-all.h

Lines of this file are not shown. View the raw message.

tools/ioemu/hw/ide.c +3 -1
diff -r 88818d55e95a tools/ioemu/hw/ide.c

Lines of this file are not shown. View the raw message.

tools/ioemu/hw/scsi-disk.c +7 -1
diff -r 88818d55e95a tools/ioemu/hw/scsi-disk.c

Lines of this file are not shown. View the raw message.

tools/ioemu/hw/xen_machine_fv.c +3 -0
diff -r 88818d55e95a tools/ioemu/hw/xen_machine_fv.c

Lines of this file are not shown. View the raw message.

tools/ioemu/vl.c +55 -14

69 lines not on this page · raw message

tools/ioemu/vl.h +3 -0
diff -r 88818d55e95a tools/ioemu/vl.h

Lines of this file are not shown. View the raw message.

tools/ioemu/vnc.c +18 -1
diff -r 88818d55e95a tools/ioemu/vnc.c

Lines of this file are not shown. View the raw message.

tools/ioemu/xenstore.c +17 -2
diff -r 88818d55e95a tools/ioemu/xenstore.c

Lines of this file are not shown. View the raw message.

tools/libxc/Makefile +21 -2
diff -r 88818d55e95a tools/libxc/Makefile

Lines of this file are not shown. View the raw message.

tools/libxc/ia64/Makefile +2 -0
diff -r 88818d55e95a tools/libxc/ia64/Makefile

Lines of this file are not shown. View the raw message.

tools/libxc/xc_minios.c new file +313 -0

313 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

Applied
#5 lore raw
Quoted 7 lines · Samuel Thibault

Ok, actually I just had to move the actual definitions of PAGE_SIZE and STACK_SIZE to a separate header, and that let me avoid pulling all internal definitions.

BTW, one of the reason for not enabling its compilation by default could at least be that since we need to setup a cross-compilation environment (binutils, gcc, newlib), we have to download about 70MB of source...

Applied, but please send another patch to override XEN_OS and hence present yourself as a new 'OS environment' to the overall build system. That'll clean up a good number of your Makefile changes outside stubdom/.

-- Keir

#6 lore raw
Quoted 1 line · Keir Fraser, le Tue 12 Feb 2008 14:32:25 +0000, a écrit :

Applied

Cool!

Quoted 3 lines

please send another patch to override XEN_OS and hence present yourself as a new 'OS environment' to the overall build system. That'll clean up a good number of your Makefile changes outside stubdom/.

It does indeed, here it is.

Make stubdom/Makefile override XEN_OS to MiniOS, and add config/MiniOS.mk. Add PTHREAD_LIBS to configs (usually holding -lpthread).

Config.mk +0 -8
diff -r d0b12316994b Config.mk
@@ -27,14 +27,6 @@ DESTDIR     ?= /
 
 include $(XEN_ROOT)/config/$(XEN_OS).mk
 include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
-
-ifeq ($(stubdom),y)
-include $(XEN_ROOT)/extras/mini-os/Config.mk
-CFLAGS += $(DEF_CFLAGS) $(ARCH_CFLAGS)
-CPPFLAGS += $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) $(extra_incl)
-ASFLAGS += $(DEF_ASFLAGS) $(ARCH_ASFLAGS)
-LDFLAGS += $(DEF_LDFLAGS) $(ARCH_LDFLAGS)
-endif
 
 ifneq ($(EXTRA_PREFIX),)
 EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
config/MiniOS.mk new file +9 -0
diff -r d0b12316994b config/MiniOS.mk
@@ -0,0 +1,9 @@
+include $(XEN_ROOT)/config/StdGNU.mk
+include $(XEN_ROOT)/extras/mini-os/Config.mk
+CFLAGS += $(DEF_CFLAGS) $(ARCH_CFLAGS)
+CPPFLAGS += $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) $(extra_incl)
+ASFLAGS += $(DEF_ASFLAGS) $(ARCH_ASFLAGS)
+LDFLAGS += $(DEF_LDFLAGS) $(ARCH_LDFLAGS)
+
+# Override settings for this OS
+PTHREAD_LIBS =
config/StdGNU.mk +1 -0
diff -r d0b12316994b config/StdGNU.mk
@@ -35,6 +35,7 @@ PRIVATE_BINDIR = $(PRIVATE_PREFIX)/bin
 
 SOCKET_LIBS =
 CURSES_LIBS = -lncurses
+PTHREAD_LIBS = -lpthread
 UTIL_LIBS = -lutil
 SONAME_LDFLAG = -soname
 SHLIB_CFLAGS = -shared
config/SunOS.mk +1 -0
diff -r d0b12316994b config/SunOS.mk
@@ -39,6 +39,7 @@ SunOS_LIBDIR_x86_64 = /usr/sfw/lib/amd64
 
 SOCKET_LIBS = -lsocket
 CURSES_LIBS = -lcurses
+PTHREAD_LIBS = -lpthread
 UTIL_LIBS =
 SONAME_LDFLAG = -h
 SHLIB_CFLAGS = -R $(SunOS_LIBDIR) -shared
stubdom/Makefile +2 -0
diff -r d0b12316994b stubdom/Makefile
@@ -1,4 +1,6 @@ XEN_ROOT = ..
 XEN_ROOT = ..
+
+export XEN_OS=MiniOS
 
 include $(XEN_ROOT)/Config.mk
 export stubdom=y
tools/libxc/Makefile +3 -9
diff -r d0b12316994b tools/libxc/Makefile
@@ -25,13 +25,11 @@ CTRL_SRCS-y       += xc_resume.c
 CTRL_SRCS-y       += xc_resume.c
 endif
 CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
-ifneq ($(stubdom),y)
 CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c
 CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
 CTRL_SRCS-$(CONFIG_X86_Linux) += xc_ptrace.c xc_ptrace_core.c
 CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c
-endif
-CTRL_SRCS-$(stubdom) += xc_minios.c
+CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c
 
 GUEST_SRCS-y :=
 GUEST_SRCS-y += xg_private.c
@@ -74,10 +72,6 @@ CFLAGS   += -Wp,-MD,.$(@F).d
 CFLAGS   += -Wp,-MD,.$(@F).d
 LDFLAGS  += -L.
 DEPS     = .*.d
-
-ifneq ($(stubdom),y)
-LDLIBS   = -lpthread
-endif
 
 CTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y))
 CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y))
@@ -152,7 +146,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$(
 	ln -sf $< $@
 
 libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ $(LDLIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ $(PTHREAD_LIBS)
 
 # libxenguest
 
@@ -165,7 +159,7 @@ libxenguest.so.$(MAJOR): libxenguest.so.
 	ln -sf $< $@
 
 libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so
-	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $(GUEST_PIC_OBJS) -lz -lxenctrl $(LDLIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $(GUEST_PIC_OBJS) -lz -lxenctrl $(PTHREAD_LIBS)
 
 -include $(DEPS)
#7 lore raw
In reply to Keir Fraser

It looks like the stubdom/ patches for binutils, gcc, and newlib didn't make through, here they are again.

stubdom/binutils.patch new file +14 -0
diff -r 7e91007fa727 stubdom/binutils.patch
@@ -0,0 +1,14 @@
+It looks like binutils has troubles with makeinfo and the doc generation.
+We don't need it anyway
+
+--- binutils-2.18/bfd/Makefile.inorig	2008-01-16 16:17:43.004484000 +0000
++++ binutils-2.18/bfd/Makefile.in	2008-01-16 16:17:50.505526000 +0000
+@@ -271,7 +271,7 @@
+ INCDIR = $(srcdir)/../include
+ CSEARCH = -I. -I$(srcdir) -I$(INCDIR)
+ MKDEP = gcc -MM
+-SUBDIRS = doc po
++SUBDIRS = po
+ bfddocdir = doc
+ bfdlib_LTLIBRARIES = libbfd.la
+ AM_CFLAGS = $(WARN_CFLAGS)
stubdom/gcc.patch new file +31 -0
diff -r 7e91007fa727 stubdom/gcc.patch
@@ -0,0 +1,31 @@
+Backported from later versions
+
+--- gcc-4.2.2/gcc/config.gcc       2007-11-22 16:27:45.000000000 +0000
++++ gcc-4.2.2/gcc/config.gcc       2007-11-22 16:23:00.000000000 +0000
+@@ -1033,6 +1033,11 @@
+ 	tmake_file="i386/t-i386elf t-svr4"
+ 	use_fixproto=yes
+ 	;;
++x86_64-*-elf*)
++	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h i386/x86-64.h"
++	tmake_file="i386/t-i386elf t-svr4"
++	use_fixproto=yes
++	;;
+ i[34567]86-sequent-ptx4* | i[34567]86-sequent-sysv4*)
+ 	if test x$gas = xyes
+ 	then
+
+We don't have a libc yet at this stage. Unused anyway
+
+--- gcc-4.2.2/gcc/unwind-generic.h.orig 2008-01-11 18:54:40.000000000 +0100
++++ gcc-4.2.2/gcc/unwind-generic.h      2008-01-11 18:54:31.000000000 +0100
+@@ -203,7 +203,6 @@
+    compatible with the standard ABI for IA-64, we inline these.  */
+ 
+ #ifdef __ia64__
+-#include <stdlib.h>
+ 
+ static inline _Unwind_Ptr
+ _Unwind_GetDataRelBase (struct _Unwind_Context *_C)
+Backported from later versions
+
stubdom/newlib.patch new file +203 -0

203 lines not on this page · raw message

#8 lore raw
Quoted 4 lines · Samuel Thibault

It looks like the stubdom/ patches for binutils, gcc, and newlib didn't make through, here they are again.

The files are in my local tree but masked by .hgignore. Please send me a patch to .hgignore: that will reveal the missing files and I'll check in the whole lot (.hgignore + missing patches) in one changeset.

-- Keir

#9 lore raw
Quoted 8 lines · Keir Fraser, le Tue 12 Feb 2008 15:24:39 +0000, a écrit :
Quoted 4 lines · Samuel Thibault

It looks like the stubdom/ patches for binutils, gcc, and newlib didn't make through, here they are again.

The files are in my local tree but masked by .hgignore.

Oh right, I had paid attention to the few lines that mention "patch", but not the stubdom/ ones which match a bit too much. Here is a patch.

Rename stubdom/*.build into stubdom/*-build, newlib into newlib-cvs, lwip into lwip-cvs. Fix .hgignore to ignore only them and not the patches.

.hgignore +11 -11
diff -r f7ec8df22304 .hgignore
@@ -80,17 +80,17 @@
 ^pristine-.*$
 ^ref-.*$
 ^tmp-.*$
-^stubdom/binutils.*$
-^stubdom/cross-root.*$
-^stubdom/gcc.*$
-^stubdom/include.*$
-^stubdom/ioemu.*$
-^stubdom/libxc.*$
-^stubdom/lwip.*$
-^stubdom/mini-os.*$
-^stubdom/newlib.*$
-^stubdom/pciutils.*$
-^stubdom/zlib.*$
+^stubdom/binutils-.*$
+^stubdom/cross-root-.*$
+^stubdom/gcc-.*$
+^stubdom/include$
+^stubdom/ioemu$
+^stubdom/libxc$
+^stubdom/lwip-.*$
+^stubdom/mini-os$
+^stubdom/newlib-.*$
+^stubdom/pciutils-.*$
+^stubdom/zlib-.*$
 ^tools/.*/TAGS$
 ^tools/.*/build/lib.*/.*\.py$
 ^tools/blktap/Makefile\.smh$
stubdom/Makefile +20 -19
diff -r f7ec8df22304 stubdom/Makefile
@@ -54,8 +54,8 @@ BINUTILS_STAMPFILE=$(CROSS_ROOT)/bin/$(G
 .PHONY: cross-binutils
 cross-binutils: $(BINUTILS_STAMPFILE)
 $(BINUTILS_STAMPFILE): binutils-$(BINUTILS_VERSION)
-	mkdir -p binutils.build
-	( cd binutils.build && \
+	mkdir -p binutils-build
+	( cd binutils-build && \
 	  ../binutils-$(BINUTILS_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf && \
 	  $(MAKE) && \
 	  $(MAKE) check && \
@@ -76,8 +76,8 @@ GCC_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TA
 .PHONY: cross-gcc
 cross-gcc: $(GCC_STAMPFILE)
 $(GCC_STAMPFILE): gcc-$(GCC_VERSION) $(BINUTILS_STAMPFILE)
-	mkdir -p gcc.build
-	( cd gcc.build && \
+	mkdir -p gcc-build
+	( cd gcc-build && \
 	  ../gcc-$(GCC_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-languages=c --disable-libssp --with-gnu-as --with-gnu-ld && \
 	  $(MAKE) GCC_FOR_TARGET='$$$$r/gcc/xgcc -B$$$$r/gcc/ '"$(TARGET_CFLAGS)"' $$(FLAGS_FOR_TARGET)' && \
 	  $(MAKE) install )
@@ -88,16 +88,16 @@ cross-gcc: $(GCC_STAMPFILE)
 
 newlib:
 	cvs -z 9 -d :pserver:[email protected]:/cvs/src co -D $(NEWLIB_DATE) newlib
-	mv src newlib
-	( cd newlib && patch -p0 < ../newlib.patch)
+	mv src newlib-cvs
+	( cd newlib-cvs && patch -p0 < ../newlib.patch)
 
 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
 .PHONY: cross-newlib
 cross-newlib: $(NEWLIB_STAMPFILE)
 $(NEWLIB_STAMPFILE): newlib $(GCC_STAMPFILE)
-	mkdir -p newlib.build
-	( cd newlib.build && \
-	  CC_FOR_TARGET="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" ../newlib/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long && \
+	mkdir -p newlib-build
+	( cd newlib-build && \
+	  CC_FOR_TARGET="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" ../newlib-cvs/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long && \
 	  $(MAKE) && \
 	  $(MAKE) install )
 
@@ -144,8 +144,9 @@ cross-libpci: $(LIBPCI_STAMPFILE)
 # lwIP
 ######
 
-lwip:
+lwip-cvs:
 	cvs -z 9 -d :pserver:[email protected]:/sources/lwip co -D $(LWIP_DATE) lwip
+	mv lwip lwip-cvs
 
 #######
 # Links
@@ -190,7 +191,7 @@ ioemu: cross-zlib cross-libpci mk-symlin
 ioemu: cross-zlib cross-libpci mk-symlinks libxc
 	[ -f ioemu/config-host.mak ] || \
 	  ( cd ioemu ; XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
-	$(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip
+	$(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs
 
 ######
 # caml
@@ -205,12 +206,12 @@ caml:
 ########
 
 .PHONY: qemu-stubdom
-qemu-stubdom: mk-symlinks lwip libxc ioemu
-	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip QEMUDIR=$(CURDIR)/ioemu
+qemu-stubdom: mk-symlinks lwip-cvs libxc ioemu
+	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs QEMUDIR=$(CURDIR)/ioemu
 
 .PHONY: caml-stubdom
-caml-stubdom: mk-symlinks lwip libxc cross-libpci caml
-	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip CAMLDIR=$(CURDIR)/caml
+caml-stubdom: mk-symlinks lwip-cvs libxc cross-libpci caml
+	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwia-cvs CAMLDIR=$(CURDIR)/caml
 
 #########
 # install
@@ -227,7 +228,7 @@ install: mini-os/mini-os.gz
 # Only clean the libxc/ioemu/mini-os part
 .PHONY: clean
 clean:
-	-$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip clean
+	-$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs clean
 	$(MAKE) -C caml clean
 	rm -fr libxc ioemu mini-os include
 
@@ -235,7 +236,7 @@ clean:
 .PHONY: crossclean
 crossclean: clean
 	rm -fr $(CROSS_ROOT)
-	rm -fr binutils.build gcc.build newlib.build
+	rm -fr binutils-build gcc-build newlib-build
 	rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
 
 # clean patched sources
@@ -243,8 +244,8 @@ patchclean: crossclean
 patchclean: crossclean
 	rm -fr binutils-$(BINUTILS_VERSION)
 	rm -fr gcc-$(GCC_VERSION)
-	rm -fr newlib
-	rm -fr lwip
+	rm -fr newlib-cvs
+	rm -fr lwip-cvs
 
 # clean downloads
 .PHONY: downloadclean
#10 lore raw

stubdom: missing two renames

stubdom: missing two renames
to avoid always re-compiling newlib.

stubdom/Makefile +2 -2
diff -r f3eb383d2bd5 stubdom/Makefile
@@ -86,7 +86,7 @@ cross-gcc: $(GCC_STAMPFILE)
 # Cross-newlib
 ##############
 
-newlib:
+newlib-cvs:
 	cvs -z 9 -d :pserver:[email protected]:/cvs/src co -D $(NEWLIB_DATE) newlib
 	mv src newlib-cvs
 	( cd newlib-cvs && patch -p0 < ../newlib.patch)
@@ -94,7 +94,7 @@ NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TAR
 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
 .PHONY: cross-newlib
 cross-newlib: $(NEWLIB_STAMPFILE)
-$(NEWLIB_STAMPFILE): newlib $(GCC_STAMPFILE)
+$(NEWLIB_STAMPFILE): newlib-cvs $(GCC_STAMPFILE)
 	mkdir -p newlib-build
 	( cd newlib-build && \
 	  CC_FOR_TARGET="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" ../newlib-cvs/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long && \
#11 lore raw
In reply to Samuel Thibault
Quoted 20 lines · Samuel Thibault

Hello,

At last, here is the big patch that adds the stubdomain support. I guess some reviewing will be needed before commiting it.

diff -r 7b0c0ab0566b extras/mini-os/include/byteswap.h

extras/mini-os/include/byteswap.h new file +11 -0
@@ -0,0 +1,22 @@
+#ifndef _BYTESWAP_H_
+#define _BYTESWAP_H_
+
+/* Unfortunately not provided by newlib.  */
+#define bswap_16(x) \
+    ((((x) & 0xff00) >> 8) | (((x) & 0xff) << 8))
+
+#define bswap_32(x) \
+    ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
+     (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
+

extras/mini-os/include/byteswap.h line 21

Quoted 10 lines
extras/mini-os/include/byteswap.h new file +10 -0
+#define bswap_64(x) \
+    ((((x) & 0xff00000000000000ULL) >> 56) | \
+     (((x) & 0x00ff000000000000ULL) >> 40) | \
+     (((x) & 0x0000ff0000000000ULL) >> 24) | \
+     (((x) & 0x000000ff00000000ULL) >>  8) | \
+     (((x) & 0x00000000ff000000ULL) <<  8) | \
+     (((x) & 0x0000000000ff0000ULL) << 24) | \
+     (((x) & 0x000000000000ff00ULL) << 40) | \
+     (((x) & 0x00000000000000ffULL) << 56))
+

Perhaps make these inline for type checking.

Just wondering about some of the TODO notes in the patchset. I'll take a closer look.

Mike

Signature · 5 lines
Mike D. Day
IBM LTC
Cell: 919 412-3900
Sametime: [email protected] AIM: ncmikeday  Yahoo: ultra.runner
PGP key: http://www.ncultra.org/ncmike/pubkey.asc