aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/include
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-02-12 14:35:39 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-02-12 14:35:39 +0000
commit0243b256d6187ea610174531607366945e489605 (patch)
treefd2de9267b7493642626f8c84d7c81ebcd336bed /extras/mini-os/include
parent67bfbd67d1311a1a590b47e568a07622d4492873 (diff)
downloadxen-0243b256d6187ea610174531607366945e489605.tar.gz
xen-0243b256d6187ea610174531607366945e489605.tar.bz2
xen-0243b256d6187ea610174531607366945e489605.zip
Add stubdomain support. See stubdom/README for usage details.
- 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. - Had to change the Mini-OS compilation somehow, so as to export Mini-OS compilation flags to the Makefiles of libxc and ioemu. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/include')
-rw-r--r--extras/mini-os/include/arch/cc.h7
-rw-r--r--extras/mini-os/include/byteswap.h22
-rw-r--r--extras/mini-os/include/console.h3
-rw-r--r--extras/mini-os/include/errno.h7
-rw-r--r--extras/mini-os/include/fcntl.h3
-rw-r--r--extras/mini-os/include/fs.h1
-rw-r--r--extras/mini-os/include/ia64/arch_limits.h12
-rw-r--r--extras/mini-os/include/ia64/arch_mm.h4
-rw-r--r--extras/mini-os/include/ia64/page.h6
-rw-r--r--extras/mini-os/include/lib.h59
-rw-r--r--extras/mini-os/include/linux/types.h5
-rw-r--r--extras/mini-os/include/mm.h8
-rw-r--r--extras/mini-os/include/netfront.h4
-rw-r--r--extras/mini-os/include/posix/dirent.h24
-rw-r--r--extras/mini-os/include/posix/limits.h9
-rw-r--r--extras/mini-os/include/posix/netdb.h9
-rw-r--r--extras/mini-os/include/posix/netinet/in.h7
-rw-r--r--extras/mini-os/include/posix/netinet/tcp.h6
-rw-r--r--extras/mini-os/include/posix/pthread.h19
-rw-r--r--extras/mini-os/include/posix/stdlib.h8
-rw-r--r--extras/mini-os/include/posix/strings.h8
-rw-r--r--extras/mini-os/include/posix/sys/ioctl.h16
-rw-r--r--extras/mini-os/include/posix/sys/mman.h19
-rw-r--r--extras/mini-os/include/posix/sys/select.h7
-rw-r--r--extras/mini-os/include/posix/sys/socket.h31
-rw-r--r--extras/mini-os/include/posix/termios.h87
-rw-r--r--extras/mini-os/include/posix/time.h10
-rw-r--r--extras/mini-os/include/posix/unistd.h12
-rw-r--r--extras/mini-os/include/sched.h3
-rw-r--r--extras/mini-os/include/sys/time.h4
-rw-r--r--extras/mini-os/include/time.h11
-rw-r--r--extras/mini-os/include/x86/arch_limits.h20
-rw-r--r--extras/mini-os/include/x86/arch_mm.h22
-rw-r--r--extras/mini-os/include/x86/arch_sched.h4
-rw-r--r--extras/mini-os/include/x86/arch_spinlock.h1
-rw-r--r--extras/mini-os/include/x86/os.h1
36 files changed, 455 insertions, 24 deletions
diff --git a/extras/mini-os/include/arch/cc.h b/extras/mini-os/include/arch/cc.h
index 70191f0b30..e9a258d8bf 100644
--- a/extras/mini-os/include/arch/cc.h
+++ b/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
diff --git a/extras/mini-os/include/byteswap.h b/extras/mini-os/include/byteswap.h
new file mode 100644
index 0000000000..7c4ffe393c
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/console.h b/extras/mini-os/include/console.h
index 6ee04f1316..9ace8dfcb1 100644
--- a/extras/mini-os/include/console.h
+++ b/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_rx(char *buf, unsigned len, struct pt_regs *regs);
void xencons_tx(void);
void init_console(void);
+void console_print(char *data, int length);
#endif /* _LIB_CONSOLE_H_ */
diff --git a/extras/mini-os/include/errno.h b/extras/mini-os/include/errno.h
index 262ab3e0b4..2829420dd7 100644
--- a/extras/mini-os/include/errno.h
+++ b/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
diff --git a/extras/mini-os/include/fcntl.h b/extras/mini-os/include/fcntl.h
index 64020795ab..34a6484d35 100644
--- a/extras/mini-os/include/fcntl.h
+++ b/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
diff --git a/extras/mini-os/include/fs.h b/extras/mini-os/include/fs.h
index 1555a5adcc..4c822dfb20 100644
--- a/extras/mini-os/include/fs.h
+++ b/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);
diff --git a/extras/mini-os/include/ia64/arch_limits.h b/extras/mini-os/include/ia64/arch_limits.h
new file mode 100644
index 0000000000..c7bb9b6573
--- /dev/null
+++ b/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__ */
diff --git a/extras/mini-os/include/ia64/arch_mm.h b/extras/mini-os/include/ia64/arch_mm.h
index 2a8e1c82a6..adc1da6d0f 100644
--- a/extras/mini-os/include/ia64/arch_mm.h
+++ b/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__ */
diff --git a/extras/mini-os/include/ia64/page.h b/extras/mini-os/include/ia64/page.h
index 714227f172..67be0a555d 100644
--- a/extras/mini-os/include/ia64/page.h
+++ b/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 */
diff --git a/extras/mini-os/include/lib.h b/extras/mini-os/include/lib.h
index efe096bdba..2ddb8d07c8 100644
--- a/extras/mini-os/include/lib.h
+++ b/extras/mini-os/include/lib.h
@@ -57,6 +57,8 @@
#include <stdarg.h>
#include <stddef.h>
+#include <xen/xen.h>
+#include <xen/event_channel.h>
#ifdef HAVE_LIBC
#include <stdio.h>
@@ -103,6 +105,8 @@ char *strdup(const char *s);
int rand(void);
+#include <xenbus.h>
+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
struct kvec {
@@ -126,4 +130,59 @@ do { \
/* Consistency check as much as possible. */
void sanity_check(void);
+#ifdef HAVE_LIBC
+enum fd_type {
+ FTYPE_NONE = 0,
+ FTYPE_CONSOLE,
+ FTYPE_FILE,
+ FTYPE_XENBUS,
+ FTYPE_EVTCHN,
+ FTYPE_SOCKET,
+ FTYPE_TAP,
+ FTYPE_BLK,
+};
+
+#define MAX_EVTCHN_PORTS 16
+
+extern struct file {
+ enum fd_type type;
+ union {
+ struct {
+ /* lwIP fd */
+ int fd;
+ } socket;
+ struct {
+ /* FS import fd */
+ int fd;
+ off_t offset;
+ } file;
+ struct {
+ /* To each event channel FD is associated a series of ports which
+ * wakes select for this FD. */
+ struct {
+ evtchn_port_t port;
+ volatile unsigned long pending;
+ int bound;
+ } ports[MAX_EVTCHN_PORTS];
+ } evtchn;
+ struct {
+ struct netfront_dev *dev;
+ } tap;
+ struct {
+ struct blkfront_dev *dev;
+ } blk;
+ struct {
+ /* To each xenbus FD is associated a queue of watch events for this
+ * FD. */
+ struct xenbus_event *volatile events;
+ } xenbus;
+ };
+ volatile int read; /* maybe available for read */
+} files[];
+
+int alloc_fd(enum fd_type type);
+void close_all_files(void);
+extern struct thread *main_thread;
+#endif
+
#endif /* _LIB_H_ */
diff --git a/extras/mini-os/include/linux/types.h b/extras/mini-os/include/linux/types.h
new file mode 100644
index 0000000000..f153ce8e42
--- /dev/null
+++ b/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_ */
diff --git a/extras/mini-os/include/mm.h b/extras/mini-os/include/mm.h
index 4319fa2640..8396ec6b31 100644
--- a/extras/mini-os/include/mm.h
+++ b/extras/mini-os/include/mm.h
@@ -36,8 +36,13 @@
#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);
unsigned long alloc_pages(int order);
@@ -61,5 +66,8 @@ 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);
+#ifdef HAVE_LIBC
+extern unsigned long heap, brk, heap_mapped, heap_end;
+#endif
#endif /* _MM_H_ */
diff --git a/extras/mini-os/include/netfront.h b/extras/mini-os/include/netfront.h
index 5c8ec9c4fa..acfc91944b 100644
--- a/extras/mini-os/include/netfront.h
+++ b/extras/mini-os/include/netfront.h
@@ -6,6 +6,10 @@ struct netfront_dev;
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;
diff --git a/extras/mini-os/include/posix/dirent.h b/extras/mini-os/include/posix/dirent.h
new file mode 100644
index 0000000000..56b1d67258
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/posix/limits.h b/extras/mini-os/include/posix/limits.h
new file mode 100644
index 0000000000..ba800e33d2
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/posix/netdb.h b/extras/mini-os/include/posix/netdb.h
new file mode 100644
index 0000000000..8f76a95b76
--- /dev/null
+++ b/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_ */
diff --git a/extras/mini-os/include/posix/netinet/in.h b/extras/mini-os/include/posix/netinet/in.h
new file mode 100644
index 0000000000..cc1a91076d
--- /dev/null
+++ b/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_ */
diff --git a/extras/mini-os/include/posix/netinet/tcp.h b/extras/mini-os/include/posix/netinet/tcp.h
new file mode 100644
index 0000000000..3e3b060467
--- /dev/null
+++ b/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_ */
diff --git a/extras/mini-os/include/posix/pthread.h b/extras/mini-os/include/posix/pthread.h
new file mode 100644
index 0000000000..7e62001e3a
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/posix/stdlib.h b/extras/mini-os/include/posix/stdlib.h
new file mode 100644
index 0000000000..53e6289635
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/posix/strings.h b/extras/mini-os/include/posix/strings.h
new file mode 100644
index 0000000000..8619ba2865
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/posix/sys/ioctl.h b/extras/mini-os/include/posix/sys/ioctl.h
new file mode 100644
index 0000000000..ecf3080d5a
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/posix/sys/mman.h b/extras/mini-os/include/posix/sys/mman.h
new file mode 100644
index 0000000000..318d574877
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/posix/sys/select.h b/extras/mini-os/include/posix/sys/select.h
new file mode 100644
index 0000000000..5132c51224
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/posix/sys/socket.h b/extras/mini-os/include/posix/sys/socket.h
new file mode 100644
index 0000000000..7c039a2f03
--- /dev/null
+++ b/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_ */
diff --git a/extras/mini-os/include/posix/termios.h b/extras/mini-os/include/posix/termios.h
new file mode 100644
index 0000000000..a57aee4556
--- /dev/null
+++ b/extras/mini-os/include/posix/termios.h
@@ -0,0 +1,87 @@
+#ifndef _POSIX_TERMIOS_H
+#define _POSIX_TERMIOS_H
+
+#define NCC 32
+
+struct termios {
+ unsigned long c_iflag;
+ unsigned long c_oflag;
+ unsigned long c_lflag;
+ unsigned long c_cflag;
+ unsigned char c_cc[NCC];
+};
+
+/* modem lines */
+#define TIOCM_DTR 0x002
+#define TIOCM_RTS 0x004
+#define TIOCM_CTS 0x020
+#define TIOCM_CAR 0x040
+#define TIOCM_RI 0x080
+#define TIOCM_DSR 0x100
+
+/* c_iflag */
+#define IGNBRK 0x00000001
+#define BRKINT 0x00000002
+#define IGNPAR 0x00000004
+#define PARMRK 0x00000008
+#define INPCK 0x00000010
+#define ISTRIP 0x00000020
+#define INLCR 0x00000040
+#define IGNCR 0x00000080
+#define ICRNL 0x00000100
+#define IUCLC 0x00000200
+#define IXON 0x00000400
+#define IXANY 0x00000800
+#define IXOFF 0x00001000
+#define IMAXBEL 0x00002000
+#define IUTF8 0x00004000
+
+/* c_oflag */
+#define OPOST 0x00000001
+#define OLCUC 0x00000002
+#define ONLCR 0x00000004
+#define OCRNL 0x00000008
+#define ONOCR 0x00000010
+#define ONLRET 0x00000020
+#define OFILL 0x00000040
+#define OFDEL 0x00000080
+
+/* c_lflag */
+#define ISIG 0x00000001
+#define ICANON 0x00000002
+#define XCASE 0x00000004
+#define ECHO 0x00000008
+#define ECHOE 0x00000010
+#define ECHOK 0x00000020
+#define ECHONL 0x00000040
+#define NOFLSH 0x00000080
+#define TOSTOP 0x00000100
+#define ECHOCTL 0x00000200
+#define ECHOPRT 0x00000400
+#define ECHOKE 0x00000800
+#define FLUSHO 0x00002000
+#define PENDIN 0x00004000
+#define IEXTEN 0x00008000
+
+/* c_cflag */
+#define CSIZE 0x00000030
+#define CS8 0x00000030
+#define CSTOPB 0x00000040
+#define CREAD 0x00000080
+#define PARENB 0x00000100
+#define PARODD 0x00000200
+#define HUPCL 0x00000400
+#define CLOCAL 0x00000800
+
+/* c_cc */
+#define VTIME 5
+#define VMIN 6
+
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+int tcsetattr(int fildes, int action, const struct termios *tios);
+int tcgetattr(int fildes, struct termios *tios);
+
+#endif /* _POSIX_TERMIOS_H */
diff --git a/extras/mini-os/include/posix/time.h b/extras/mini-os/include/posix/time.h
new file mode 100644
index 0000000000..4f457cb5ad
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/posix/unistd.h b/extras/mini-os/include/posix/unistd.h
new file mode 100644
index 0000000000..0cd9396ec9
--- /dev/null
+++ b/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 */
diff --git a/extras/mini-os/include/sched.h b/extras/mini-os/include/sched.h
index a3d2022b8a..ba0d4e3df9 100644
--- a/extras/mini-os/include/sched.h
+++ b/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;
diff --git a/extras/mini-os/include/sys/time.h b/extras/mini-os/include/sys/time.h
index 87887c27d1..d6623a4e77 100644
--- a/extras/mini-os/include/sys/time.h
+++ b/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_ */
diff --git a/extras/mini-os/include/time.h b/extras/mini-os/include/time.h
index 914f2fcff2..e28bf171d7 100644
--- a/extras/mini-os/include/time.h
+++ b/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 @@ s_time_t get_v_time(void);
u64 monotonic_clock(void);
void block_domain(s_time_t until);
-#endif /* _TIME_H_ */
+#endif /* _MINIOS_TIME_H_ */
diff --git a/extras/mini-os/include/x86/arch_limits.h b/extras/mini-os/include/x86/arch_limits.h
new file mode 100644
index 0000000000..7f0351c67f
--- /dev/null
+++ b/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__ */
diff --git a/extras/mini-os/include/x86/arch_mm.h b/extras/mini-os/include/x86/arch_mm.h
index c5e106e6da..7ad8bc14be 100644
--- a/extras/mini-os/include/x86/arch_mm.h
+++ b/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)
@@ -177,9 +170,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. */
#ifdef CONFIG_X86_PAE
@@ -257,5 +247,11 @@ 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/include/x86/arch_sched.h b/extras/mini-os/include/x86/arch_sched.h
index 877440762e..d80323cd37 100644
--- a/extras/mini-os/include/x86/arch_sched.h
+++ b/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(void)
#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;
}
diff --git a/extras/mini-os/include/x86/arch_spinlock.h b/extras/mini-os/include/x86/arch_spinlock.h
index a181ed3c92..b711fe473c 100644
--- a/extras/mini-os/include/x86/arch_spinlock.h
+++ b/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 }
diff --git a/extras/mini-os/include/x86/os.h b/extras/mini-os/include/x86/os.h
index 7a4433b3f9..7217d0b3ca 100644
--- a/extras/mini-os/include/x86/os.h
+++ b/extras/mini-os/include/x86/os.h
@@ -563,6 +563,7 @@ static __inline__ int synch_var_test_bit(int nr, volatile void * addr)
synch_var_test_bit((nr),(addr)))
+#undef ADDR
#endif /* not assembly */
#endif /* _OS_H_ */