From de47eb59bb829423b1d0f47ba13099073999b3cb Mon Sep 17 00:00:00 2001 From: Nicolas Planel Date: Wed, 29 Oct 2003 16:07:11 +0000 Subject: Corporate Server 2.1.1 release --- mdk-stage1/dietlibc/include/sys/cdefs.h | 35 +- mdk-stage1/dietlibc/include/sys/file.h | 11 +- mdk-stage1/dietlibc/include/sys/io.h | 47 +- mdk-stage1/dietlibc/include/sys/ioctl.h | 26 +- mdk-stage1/dietlibc/include/sys/ipc.h | 45 +- mdk-stage1/dietlibc/include/sys/kd.h | 179 +++++- mdk-stage1/dietlibc/include/sys/mman.h | 165 +++++- mdk-stage1/dietlibc/include/sys/mount.h | 73 ++- mdk-stage1/dietlibc/include/sys/msg.h | 48 +- mdk-stage1/dietlibc/include/sys/mtio.h | 336 +++++++++++- mdk-stage1/dietlibc/include/sys/param.h | 22 +- mdk-stage1/dietlibc/include/sys/poll.h | 40 +- mdk-stage1/dietlibc/include/sys/ptrace.h | 840 ++++++++++++++++++++++++++++- mdk-stage1/dietlibc/include/sys/reboot.h | 21 +- mdk-stage1/dietlibc/include/sys/resource.h | 53 +- mdk-stage1/dietlibc/include/sys/select.h | 22 + mdk-stage1/dietlibc/include/sys/sem.h | 74 ++- mdk-stage1/dietlibc/include/sys/sendfile.h | 8 +- mdk-stage1/dietlibc/include/sys/shm.h | 66 ++- mdk-stage1/dietlibc/include/sys/socket.h | 492 ++++++++++++++++- mdk-stage1/dietlibc/include/sys/stat.h | 494 ++++++++++++++++- mdk-stage1/dietlibc/include/sys/sysinfo.h | 20 +- mdk-stage1/dietlibc/include/sys/syslog.h | 2 +- mdk-stage1/dietlibc/include/sys/time.h | 50 +- mdk-stage1/dietlibc/include/sys/times.h | 12 +- mdk-stage1/dietlibc/include/sys/types.h | 136 ++++- mdk-stage1/dietlibc/include/sys/uio.h | 2 +- mdk-stage1/dietlibc/include/sys/un.h | 7 +- mdk-stage1/dietlibc/include/sys/vfs.h | 26 +- mdk-stage1/dietlibc/include/sys/wait.h | 10 +- 30 files changed, 3227 insertions(+), 135 deletions(-) (limited to 'mdk-stage1/dietlibc/include/sys') diff --git a/mdk-stage1/dietlibc/include/sys/cdefs.h b/mdk-stage1/dietlibc/include/sys/cdefs.h index 895bb74b8..4ccb0ed2f 100644 --- a/mdk-stage1/dietlibc/include/sys/cdefs.h +++ b/mdk-stage1/dietlibc/include/sys/cdefs.h @@ -1,10 +1,13 @@ #ifndef _SYS_CDEFS_H #define _SYS_CDEFS_H -#define __dietlibc__ +/* Suppress kernel-name space pollution unless user expressedly asks + for it. */ +#ifndef _LOOSE_KERNEL_NAMES +# define __KERNEL_STRICT_NAMES +#endif #ifndef __cplusplus -#define throw () #define __THROW #define __BEGIN_DECLS #define __END_DECLS @@ -16,21 +19,43 @@ #ifndef __GNUC__ #define __attribute__(xyz) +#define __extension__ #endif -#define __pure__ -#ifdef __GNUC__ #if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)) -#undef __pure__ #define __pure__ __attribute__ ((__pure__)) +#else +#define __pure__ #endif #if (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) #define __restrict__ #endif +#ifndef __STRICT_ANSI__ +#if __GNUC__ < 3 +#define __builtin_expect(foo,bar) (foo) +#define expect(foo,bar) (foo) +#else +#define expect(foo,bar) __builtin_expect(foo,bar) +#define __attribute_malloc__ __attribute__((malloc)) +#endif +#endif + +#ifndef __attribute_malloc__ +#define __attribute_malloc__ #endif #define __P(x) x +#define __ptr_t void* + +#ifdef __STRICT_ANSI__ +#define inline +#endif + +#ifndef __i386__ +#define regparm(x) +#endif + #endif diff --git a/mdk-stage1/dietlibc/include/sys/file.h b/mdk-stage1/dietlibc/include/sys/file.h index 93787fd42..cf2c74305 100644 --- a/mdk-stage1/dietlibc/include/sys/file.h +++ b/mdk-stage1/dietlibc/include/sys/file.h @@ -2,18 +2,9 @@ #define _SYS_FILE_H #include +#include extern int fcntl(int fd, int cmd, ...) __THROW; extern int flock(int fd, int operation) __THROW; -/* Operations for the `flock' call. */ -#define LOCK_SH 1 /* Shared lock. */ -#define LOCK_EX 2 /* Exclusive lock. */ -#define LOCK_UN 8 /* Unlock. */ - -/* Can be OR'd in to one of the above. */ -#define LOCK_NB 4 /* Don't block when locking. */ - - - #endif /* _SYS_FILE_H */ diff --git a/mdk-stage1/dietlibc/include/sys/io.h b/mdk-stage1/dietlibc/include/sys/io.h index cce841735..5edf33a57 100644 --- a/mdk-stage1/dietlibc/include/sys/io.h +++ b/mdk-stage1/dietlibc/include/sys/io.h @@ -1,41 +1,44 @@ -#ifndef _IO_H -#define _IO_H +#ifndef _SYS_IO_H +#define _SYS_IO_H -int ioperm(unsigned long from, unsigned long num, int turn_on) __THROW; +#include -#ifdef __i386__ - -static __inline void -outb (unsigned char value, unsigned short int port) -{ - __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); -} +extern int ioperm(unsigned long from, unsigned long num, int turn_on) __THROW; +extern int iopl(int level) __THROW; -static __inline unsigned char -inb (unsigned short int port) -{ +#ifndef __STRICT_ANSI__ +/* anyone have a cleaner solution for this mess? */ +#ifdef __i386__ +static inline unsigned char inb (unsigned short int port) { unsigned char _v; - __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port)); return _v; } -static __inline unsigned short int -inw (unsigned short int port) -{ +static inline unsigned short inw (unsigned short int port) { unsigned short _v; - __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port)); return _v; } -static __inline void -outw (unsigned short int value, unsigned short int port) -{ - __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port)); +static inline unsigned int inl (unsigned short int port) { + unsigned int _v; + __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static inline void outb (unsigned char value, unsigned short int port) { + __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); +} +static inline void outw (unsigned short value, unsigned short int port) { + __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port)); } +static inline void outl (unsigned int value, unsigned short int port) { + __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port)); +} +#endif #endif #endif diff --git a/mdk-stage1/dietlibc/include/sys/ioctl.h b/mdk-stage1/dietlibc/include/sys/ioctl.h index fca1aeeab..a7890f038 100644 --- a/mdk-stage1/dietlibc/include/sys/ioctl.h +++ b/mdk-stage1/dietlibc/include/sys/ioctl.h @@ -2,8 +2,30 @@ #define _IOCTL_H #include -#include -#include + +#if defined(__i386__) || defined(__x86_64__) || defined(__ia64__) +#include +#elif defined(__alpha__) +#include +#elif defined(__arm__) +#include +#elif defined(__sparc__) +#include +#elif defined(__mips__) +#include +#elif defined(__powerpc__) +#include +#elif defined(__s390__) +#include +#elif defined(__hppa__) +#include +#endif + +/* used for /dev/epoll */ +#define EP_ALLOC _IOR('P', 1, int) +#define EP_POLL _IOWR('P', 2, struct evpoll) +#define EP_FREE _IO('P', 3) +#define EP_ISPOLLED _IOWR('P', 4, struct pollfd) int ioctl(int d, int request, ...) __THROW; diff --git a/mdk-stage1/dietlibc/include/sys/ipc.h b/mdk-stage1/dietlibc/include/sys/ipc.h index 9184a2a82..481d97b62 100644 --- a/mdk-stage1/dietlibc/include/sys/ipc.h +++ b/mdk-stage1/dietlibc/include/sys/ipc.h @@ -2,7 +2,48 @@ #define _SYS_IPC_H #include -#include -#include +#include + +#define SEMOP 1 +#define SEMGET 2 +#define SEMCTL 3 +#define MSGSND 11 +#define MSGRCV 12 +#define MSGGET 13 +#define MSGCTL 14 +#define SHMAT 21 +#define SHMDT 22 +#define SHMGET 23 +#define SHMCTL 24 + +#define IPC_PRIVATE ((key_t) 0) + +#define IPC_CREAT 00001000 /* create if key is nonexistent */ +#define IPC_EXCL 00002000 /* fail if key exists */ +#define IPC_NOWAIT 00004000 /* return error on wait */ + +#define IPC_RMID 0 /* remove resource */ +#define IPC_SET 1 /* set ipc_perm options */ +#define IPC_STAT 2 /* get ipc_perm options */ +#define IPC_INFO 3 /* see ipcs */ + +/* + * Version flags for semctl, msgctl, and shmctl commands + * These are passed as bitflags or-ed with the actual command + */ +#define IPC_OLD 0 /* Old version (no 32-bit UID support on many + architectures) */ +#define IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger + message sizes, etc. */ + +struct ipc_perm { + key_t key; + uid_t uid; + gid_t gid; + uid_t cuid; + gid_t cgid; + mode_t mode; + unsigned short seq; +}; #endif diff --git a/mdk-stage1/dietlibc/include/sys/kd.h b/mdk-stage1/dietlibc/include/sys/kd.h index 9e9a5152b..98b337ede 100644 --- a/mdk-stage1/dietlibc/include/sys/kd.h +++ b/mdk-stage1/dietlibc/include/sys/kd.h @@ -1,6 +1,183 @@ #ifndef _SYS_KD_H #define _SYS_KD_H -#include +/* 0x4B is 'K', to avoid collision with termios and vt */ + +#define GIO_FONT 0x4B60 /* gets font in expanded form */ +#define PIO_FONT 0x4B61 /* use font in expanded form */ + +#define GIO_FONTX 0x4B6B /* get font using struct consolefontdesc */ +#define PIO_FONTX 0x4B6C /* set font using struct consolefontdesc */ + +struct consolefontdesc { + unsigned short charcount; /* characters in font (256 or 512) */ + unsigned short charheight; /* scan lines per character (1-32) */ + char *chardata; /* font data in expanded form */ +}; + +#define PIO_FONTRESET 0x4B6D /* reset to default font */ + +#define GIO_CMAP 0x4B70 /* gets colour palette on VGA+ */ +#define PIO_CMAP 0x4B71 /* sets colour palette on VGA+ */ + +#define KIOCSOUND 0x4B2F /* start sound generation (0 for off) */ +#define KDMKTONE 0x4B30 /* generate tone */ + +#define KDGETLED 0x4B31 /* return current led state */ +#define KDSETLED 0x4B32 /* set led state [lights, not flags] */ +#define LED_SCR 0x01 /* scroll lock led */ +#define LED_CAP 0x04 /* caps lock led */ +#define LED_NUM 0x02 /* num lock led */ + +#define KDGKBTYPE 0x4B33 /* get keyboard type */ +#define KB_84 0x01 +#define KB_101 0x02 /* this is what we always answer */ +#define KB_OTHER 0x03 + +#define KDADDIO 0x4B34 /* add i/o port as valid */ +#define KDDELIO 0x4B35 /* del i/o port as valid */ +#define KDENABIO 0x4B36 /* enable i/o to video board */ +#define KDDISABIO 0x4B37 /* disable i/o to video board */ + +#define KDSETMODE 0x4B3A /* set text/graphics mode */ +#define KD_TEXT 0x00 +#define KD_GRAPHICS 0x01 +#define KD_TEXT0 0x02 /* obsolete */ +#define KD_TEXT1 0x03 /* obsolete */ +#define KDGETMODE 0x4B3B /* get current mode */ + +#define KDMAPDISP 0x4B3C /* map display into address space */ +#define KDUNMAPDISP 0x4B3D /* unmap display from address space */ + +typedef char scrnmap_t; + +#define E_TABSZ 256 +#define GIO_SCRNMAP 0x4B40 /* get screen mapping from kernel */ +#define PIO_SCRNMAP 0x4B41 /* put screen mapping table in kernel */ +#define GIO_UNISCRNMAP 0x4B69 /* get full Unicode screen mapping */ +#define PIO_UNISCRNMAP 0x4B6A /* set full Unicode screen mapping */ + +#define GIO_UNIMAP 0x4B66 /* get unicode-to-font mapping from kernel */ + +struct unipair { + unsigned short unicode; + unsigned short fontpos; +}; + +struct unimapdesc { + unsigned short entry_ct; + struct unipair *entries; +}; + +#define PIO_UNIMAP 0x4B67 /* put unicode-to-font mapping in kernel */ +#define PIO_UNIMAPCLR 0x4B68 /* clear table, possibly advise hash algorithm */ + +struct unimapinit { + unsigned short advised_hashsize; /* 0 if no opinion */ + unsigned short advised_hashstep; /* 0 if no opinion */ + unsigned short advised_hashlevel; /* 0 if no opinion */ +}; + +#define UNI_DIRECT_BASE 0xF000 /* start of Direct Font Region */ +#define UNI_DIRECT_MASK 0x01FF /* Direct Font Region bitmask */ + +#define K_RAW 0x00 +#define K_XLATE 0x01 +#define K_MEDIUMRAW 0x02 +#define K_UNICODE 0x03 +#define KDGKBMODE 0x4B44 /* gets current keyboard mode */ +#define KDSKBMODE 0x4B45 /* sets current keyboard mode */ + +#define K_METABIT 0x03 +#define K_ESCPREFIX 0x04 +#define KDGKBMETA 0x4B62 /* gets meta key handling mode */ +#define KDSKBMETA 0x4B63 /* sets meta key handling mode */ + +#define K_SCROLLLOCK 0x01 +#define K_CAPSLOCK 0x02 +#define K_NUMLOCK 0x04 +#define KDGKBLED 0x4B64 /* get led flags (not lights) */ +#define KDSKBLED 0x4B65 /* set led flags (not lights) */ + +struct kbentry { + unsigned char kb_table; + unsigned char kb_index; + unsigned short kb_value; +}; + +#define K_NORMTAB 0x00 +#define K_SHIFTTAB 0x01 +#define K_ALTTAB 0x02 +#define K_ALTSHIFTTAB 0x03 + +#define KDGKBENT 0x4B46 /* gets one entry in translation table */ +#define KDSKBENT 0x4B47 /* sets one entry in translation table */ + +struct kbsentry { + unsigned char kb_func; + unsigned char kb_string[512]; +}; + +#define KDGKBSENT 0x4B48 /* gets one function key string entry */ +#define KDSKBSENT 0x4B49 /* sets one function key string entry */ + +struct kbdiacr { + unsigned char diacr, base, result; +}; + +struct kbdiacrs { + unsigned int kb_cnt; /* number of entries in following array */ + struct kbdiacr kbdiacr[256]; /* MAX_DIACR from keyboard.h */ +}; + +#define KDGKBDIACR 0x4B4A /* read kernel accent table */ +#define KDSKBDIACR 0x4B4B /* write kernel accent table */ + +struct kbkeycode { + unsigned int scancode, keycode; +}; + +#define KDGETKEYCODE 0x4B4C /* read kernel keycode table entry */ +#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */ + +#define KDSIGACCEPT 0x4B4E /* accept kbd generated signals */ + +struct hwclk_time { + unsigned int sec; /* 0..59 */ + unsigned int min; /* 0..59 */ + unsigned int hour; /* 0..23 */ + unsigned int day; /* 1..31 */ + unsigned int mon; /* 0..11 */ + unsigned int year; /* 70... */ + int wday; /* 0..6, 0 is Sunday, -1 means unknown/don't set */ +}; + +#define KDGHWCLK 0x4B50 /* get hardware clock */ +#define KDSHWCLK 0x4B51 /* set hardware clock */ + +struct kbd_repeat { + int delay; /* in msec; <= 0: don't change */ + int rate; /* in msec; <= 0: don't change */ +}; + +#define KDKBDREP 0x4B52 /* set keyboard delay/repeat rate; + * actually used values are returned */ + +#define KDFONTOP 0x4B72 /* font operations */ + +struct console_font_op { + unsigned int op; /* operation code KD_FONT_OP_* */ + unsigned int flags; /* KD_FONT_FLAG_* */ + unsigned int width, height; /* font size */ + unsigned int charcount; + unsigned char *data; /* font data with height fixed to 32 */ +}; + +#define KD_FONT_OP_SET 0 /* Set font */ +#define KD_FONT_OP_GET 1 /* Get font */ +#define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */ +#define KD_FONT_OP_COPY 3 /* Copy from another console */ + +#define KD_FONT_FLAG_DONT_RECALC 1 /* Don't recalculate hw charcell size [compat] */ #endif diff --git a/mdk-stage1/dietlibc/include/sys/mman.h b/mdk-stage1/dietlibc/include/sys/mman.h index dc398ba90..298773a92 100644 --- a/mdk-stage1/dietlibc/include/sys/mman.h +++ b/mdk-stage1/dietlibc/include/sys/mman.h @@ -3,13 +3,160 @@ #include #include -#include -#include -#ifndef PAGE_SIZE -#warning PAGE_SIZE undefined +#define MREMAP_MAYMOVE 1UL +#define MREMAP_FIXED 2UL + +#define PROT_READ 0x1 /* page can be read */ +#define PROT_WRITE 0x2 /* page can be written */ +#define PROT_EXEC 0x4 /* page can be executed */ +#define PROT_NONE 0x0 /* page can not be accessed */ + +#define MAP_SHARED 0x01 /* Share changes */ +#define MAP_PRIVATE 0x02 /* Changes are private */ + +#ifdef __mips__ +#define MAP_FIXED 0x010 /* Interpret addr exactly */ +#define MAP_NORESERVE 0x0400 /* don't check for reservations */ +#define MAP_ANONYMOUS 0x0800 /* don't use a file */ +#define MAP_GROWSDOWN 0x1000 /* stack-like segment */ +#define MAP_DENYWRITE 0x2000 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x4000 /* mark it as an executable */ +#define MAP_LOCKED 0x8000 /* pages are locked */ +#define MS_ASYNC 0x0001 /* sync memory asynchronously */ +#define MS_INVALIDATE 0x0002 /* invalidate mappings & caches */ +#define MS_SYNC 0x0004 /* synchronous memory sync */ +#define MCL_CURRENT 1 /* lock all current mappings */ +#define MCL_FUTURE 2 /* lock all future mappings */ +#define MADV_NORMAL 0x0 /* default page-in behavior */ +#define MADV_RANDOM 0x1 /* page-in minimum required */ +#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ +#define MADV_WILLNEED 0x3 /* pre-fault pages */ +#define MADV_DONTNEED 0x4 /* discard these pages */ +#else + +#ifdef __alpha__ +#define MAP_FIXED 0x100 /* Interpret addr exactly */ +#define MAP_ANONYMOUS 0x10 /* don't use a file */ +#define MAP_GROWSDOWN 0x1000 /* stack-like segment */ +#define MAP_DENYWRITE 0x2000 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x4000 /* mark it as an executable */ +#define MAP_LOCKED 0x8000 /* lock the mapping */ +#define MAP_NORESERVE 0x10000 /* don't check for reservations */ +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_SYNC 2 /* synchronous memory sync */ +#define MS_INVALIDATE 4 /* invalidate the caches */ +#define MCL_CURRENT 8192 /* lock all currently mapped pages */ +#define MCL_FUTURE 16384 /* lock all additions to address space */ +#define MADV_NORMAL 0 /* no further special treatment */ +#define MADV_RANDOM 1 /* expect random page references */ +#define MADV_SEQUENTIAL 2 /* expect sequential page references */ +#define MADV_WILLNEED 3 /* will need these pages */ +#define MADV_SPACEAVAIL 5 /* ensure resources are available */ +#define MADV_DONTNEED 6 /* dont need these pages */ +#else +#define MAP_FIXED 0x10 /* Interpret addr exactly */ +#define MAP_ANONYMOUS 0x20 /* don't use a file */ #endif +#if defined(__i386__) || defined(__s390__) || defined(__x86_64__) +#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ +#define MAP_LOCKED 0x2000 /* pages are locked */ +#define MAP_NORESERVE 0x4000 /* don't check for reservations */ +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_INVALIDATE 2 /* invalidate the caches */ +#define MS_SYNC 4 /* synchronous memory sync */ +#define MCL_CURRENT 1 /* lock all current mappings */ +#define MCL_FUTURE 2 /* lock all future mappings */ +#define MADV_NORMAL 0x0 /* default page-in behavior */ +#define MADV_RANDOM 0x1 /* page-in minimum required */ +#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ +#define MADV_WILLNEED 0x3 /* pre-fault pages */ +#define MADV_DONTNEED 0x4 /* discard these pages */ +#elif defined(__sparc__) || defined (__powerpc__) +#define MAP_RENAME MAP_ANONYMOUS /* In SunOS terminology */ +#define MAP_NORESERVE 0x40 /* don't reserve swap pages */ +#define MAP_INHERIT 0x80 /* SunOS doesn't do this, but... */ +#define MAP_LOCKED 0x100 /* lock the mapping */ +#define _MAP_NEW 0x80000000 /* Binary compatibility is fun... */ +#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_INVALIDATE 2 /* invalidate the caches */ +#define MS_SYNC 4 /* synchronous memory sync */ +#define MCL_CURRENT 0x2000 /* lock all currently mapped pages */ +#define MCL_FUTURE 0x4000 /* lock all additions to address space */ +#define MADV_NORMAL 0x0 /* default page-in behavior */ +#define MADV_RANDOM 0x1 /* page-in minimum required */ +#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ +#define MADV_WILLNEED 0x3 /* pre-fault pages */ +#define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_FREE 0x5 /* (Solaris) contents can be freed */ +#elif defined (__arm__) +#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ +#define MAP_LOCKED 0x2000 /* pages are locked */ +#define MAP_NORESERVE 0x4000 /* don't check for reservations */ +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_INVALIDATE 2 /* invalidate the caches */ +#define MS_SYNC 4 /* synchronous memory sync */ +#define MCL_CURRENT 1 /* lock all current mappings */ +#define MCL_FUTURE 2 /* lock all future mappings */ +#define MADV_NORMAL 0x0 /* default page-in behavior */ +#define MADV_RANDOM 0x1 /* page-in minimum required */ +#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ +#define MADV_WILLNEED 0x3 /* pre-fault pages */ +#define MADV_DONTNEED 0x4 /* discard these pages */ + +#elif defined(__hppa__) +#define MAP_TYPE 0x03 /* Mask for type of mapping */ +#define MAP_FIXED 0x04 /* Interpret addr exactly */ +#define MAP_ANONYMOUS 0x10 /* don't use a file */ + +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ +#define MAP_LOCKED 0x2000 /* pages are locked */ +#define MAP_NORESERVE 0x4000 /* don't check for reservations */ +#define MAP_GROWSDOWN 0x8000 /* stack-like segment */ + +#define MS_SYNC 1 /* synchronous memory sync */ +#define MS_ASYNC 2 /* sync memory asynchronously */ +#define MS_INVALIDATE 4 /* invalidate the caches */ + +#define MCL_CURRENT 1 /* lock all current mappings */ +#define MCL_FUTURE 2 + +#elif defined(__ia64__) + +#define MAP_TYPE 0x0f /* Mask for type of mapping */ +#define MAP_FIXED 0x10 /* Interpret addr exactly */ +#define MAP_ANONYMOUS 0x20 /* don't use a file */ + +#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ +#define MAP_GROWSUP 0x0200 /* register stack-like segment */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ +#define MAP_LOCKED 0x2000 /* pages are locked */ +#define MAP_NORESERVE 0x4000 /* don't check for reservations */ +#define MAP_WRITECOMBINED 0x10000 /* write-combine the area */ +#define MAP_NONCACHED 0x20000 /* don't cache the memory */ + +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_INVALIDATE 2 /* invalidate the caches */ +#define MS_SYNC 4 /* synchronous memory sync */ + +#endif + +#endif + +/* compatibility flags */ +#define MAP_ANON MAP_ANONYMOUS +#define MAP_FILE 0 + #define MAP_FAILED ((void *) -1) extern void *mmap (void *__addr, size_t __len, int __prot, @@ -19,15 +166,19 @@ extern int munmap (void *__addr, size_t __len) __THROW; extern int mprotect (void *__addr, size_t __len, int __prot) __THROW; extern int msync (void *__addr, size_t __len, int __flags) __THROW; extern void *mremap (void *__addr, size_t __old_len, size_t __new_len, - int __may_move) __THROW; + unsigned long __may_move) __THROW; extern int mincore (void *__start, size_t __len, unsigned char *__vec); -#ifdef __quad_t extern void *mmap64 (void *__addr, size_t __len, int __prot, int __flags, int __fd, off64_t __offset) __THROW; -#endif int mlockall(int flags) __THROW; +int mlock(const void *addr, size_t len) __THROW; +int munlock(const void *addr, size_t len) __THROW; int munlockall(void) __THROW; +int madvise(void *start, size_t length, int advice) __THROW; + +#define _POSIX_MAPPED_FILES + #endif diff --git a/mdk-stage1/dietlibc/include/sys/mount.h b/mdk-stage1/dietlibc/include/sys/mount.h index 2e9e86774..a5170fda9 100644 --- a/mdk-stage1/dietlibc/include/sys/mount.h +++ b/mdk-stage1/dietlibc/include/sys/mount.h @@ -3,17 +3,78 @@ #include #include -#include +#define _LINUX_CONFIG_H + +#define BLOCK_SIZE 1024 +#define BLOCK_SIZE_BITS 10 + + +/* These are the fs-independent mount-flags: up to 16 flags are + supported */ +enum +{ + MS_RDONLY = 1, /* Mount read-only. */ +#define MS_RDONLY MS_RDONLY + MS_NOSUID = 2, /* Ignore suid and sgid bits. */ +#define MS_NOSUID MS_NOSUID + MS_NODEV = 4, /* Disallow access to device special files. */ +#define MS_NODEV MS_NODEV + MS_NOEXEC = 8, /* Disallow program execution. */ +#define MS_NOEXEC MS_NOEXEC + MS_SYNCHRONOUS = 16, /* Writes are synced at once. */ +#define MS_SYNCHRONOUS MS_SYNCHRONOUS + MS_REMOUNT = 32, /* Alter flags of a mounted FS. */ +#define MS_REMOUNT MS_REMOUNT + MS_MANDLOCK = 64, /* Allow mandatory locks on an FS. */ +#define MS_MANDLOCK MS_MANDLOCK + S_WRITE = 128, /* Write on file/directory/symlink. */ +#define S_WRITE S_WRITE + S_APPEND = 256, /* Append-only file. */ +#define S_APPEND S_APPEND + S_IMMUTABLE = 512, /* Immutable file. */ +#define S_IMMUTABLE S_IMMUTABLE + MS_NOATIME = 1024, /* Do not update access times. */ +#define MS_NOATIME MS_NOATIME + MS_NODIRATIME = 2048, /* Do not update directory access times. */ +#define MS_NODIRATIME MS_NODIRATIME + MS_BIND = 4096, /* Bind directory at different place. */ +#define MS_BIND MS_BIND +}; + +/* Flags that can be altered by MS_REMOUNT */ +#define MS_RMT_MASK (MS_RDONLY | MS_MANDLOCK) + + +/* Magic mount flag number. Has to be or-ed to the flag values. */ + +#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */ +#define MS_MGC_MSK 0xffff0000 /* Magic flag number mask */ + + +/* The read-only stuff doesn't really belong here, but any other place + is probably as bad and I don't want to create yet another include + file. */ + +#define BLKROSET _IO(0x12, 93) /* Set device read-only (0 = read-write). */ +#define BLKROGET _IO(0x12, 94) /* Get read-only status (0 = read_write). */ +#define BLKRRPART _IO(0x12, 95) /* Re-read partition table. */ +#define BLKGETSIZE _IO(0x12, 96) /* Return device size. */ +#define BLKFLSBUF _IO(0x12, 97) /* Flush buffer cache. */ +#define BLKRASET _IO(0x12, 98) /* Set read ahead for block device. */ +#define BLKRAGET _IO(0x12, 99) /* Get current read ahead setting. */ + + +/* Possible value for FLAGS parameter of `umount2'. */ +enum +{ + MNT_FORCE = 1 /* Force unmounting. */ +#define MNT_FORCE MNT_FORCE +}; int mount(const char* specialfile, const char* dir, const char* filesystemtype, unsigned long rwflag, const void * data) __THROW; int umount(const char *specialfile) __THROW; - -int umount(const char *dir) __THROW; - int umount2(const char *specialfile, int mflag) __THROW; -int umount2(const char *dir, int mflag) __THROW; - #endif diff --git a/mdk-stage1/dietlibc/include/sys/msg.h b/mdk-stage1/dietlibc/include/sys/msg.h index ea1e470b6..564fd9472 100644 --- a/mdk-stage1/dietlibc/include/sys/msg.h +++ b/mdk-stage1/dietlibc/include/sys/msg.h @@ -1,9 +1,53 @@ #ifndef _SYS_MSG_H #define _SYS_MSG_H -#include #include -#include + +/* ipcs ctl commands */ +#define MSG_STAT 11 +#define MSG_INFO 12 + +/* msgrcv options */ +#define MSG_NOERROR 010000 /* no error if message is too big */ +#define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/ + +struct msqid_ds { + struct ipc_perm msg_perm; + struct msg *msg_first; /* first message on queue,unused */ + struct msg *msg_last; /* last message in queue,unused */ + time_t msg_stime; /* last msgsnd time */ + time_t msg_rtime; /* last msgrcv time */ + time_t msg_ctime; /* last change time */ + unsigned long msg_lcbytes; /* Reuse junk fields for 32 bit */ + unsigned long msg_lqbytes; /* ditto */ + unsigned short msg_cbytes; /* current number of bytes on queue */ + unsigned short msg_qnum; /* number of messages in queue */ + unsigned short msg_qbytes; /* max number of bytes on queue */ + pid_t msg_lspid; /* pid of last msgsnd */ + pid_t msg_lrpid; /* last receive pid */ +}; + +/* message buffer for msgsnd and msgrcv calls */ +struct msgbuf { + long mtype; /* type of message */ + char mtext[1]; /* message text */ +}; + +/* buffer for msgctl calls IPC_INFO, MSG_INFO */ +struct msginfo { + int msgpool; + int msgmap; + int msgmax; + int msgmnb; + int msgmni; + int msgssz; + int msgtql; + unsigned short msgseg; +}; + +#define MSGMNI 16 /* <= IPCMNI */ /* max # of msg queue identifiers */ +#define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */ +#define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */ extern int msgctl (int msqid, int cmd, struct msqid_ds *buf) __THROW; extern int msgget (key_t key, int msgflg) __THROW; diff --git a/mdk-stage1/dietlibc/include/sys/mtio.h b/mdk-stage1/dietlibc/include/sys/mtio.h index e70663407..08c735dcc 100644 --- a/mdk-stage1/dietlibc/include/sys/mtio.h +++ b/mdk-stage1/dietlibc/include/sys/mtio.h @@ -1,6 +1,340 @@ #ifndef _SYS_MTIO_H #define _SYS_MTIO_H -#include +#include + +/* structure for MTIOCTOP - mag tape op command */ +struct mtop { + short int mt_op; /* operations defined below */ + int mt_count; /* how many of them */ +}; + +/* Magnetic Tape operations [Not all operations supported by all drivers]: */ +#define MTRESET 0 /* +reset drive in case of problems */ +#define MTFSF 1 /* forward space over FileMark, + * position at first record of next file + */ +#define MTBSF 2 /* backward space FileMark (position before FM) */ +#define MTFSR 3 /* forward space record */ +#define MTBSR 4 /* backward space record */ +#define MTWEOF 5 /* write an end-of-file record (mark) */ +#define MTREW 6 /* rewind */ +#define MTOFFL 7 /* rewind and put the drive offline (eject?) */ +#define MTNOP 8 /* no op, set status only (read with MTIOCGET) */ +#define MTRETEN 9 /* retension tape */ +#define MTBSFM 10 /* +backward space FileMark, position at FM */ +#define MTFSFM 11 /* +forward space FileMark, position at FM */ +#define MTEOM 12 /* goto end of recorded media (for appending files). + * MTEOM positions after the last FM, ready for + * appending another file. + */ +#define MTERASE 13 /* erase tape -- be careful! */ + +#define MTRAS1 14 /* run self test 1 (nondestructive) */ +#define MTRAS2 15 /* run self test 2 (destructive) */ +#define MTRAS3 16 /* reserved for self test 3 */ + +#define MTSETBLK 20 /* set block length (SCSI) */ +#define MTSETDENSITY 21 /* set tape density (SCSI) */ +#define MTSEEK 22 /* seek to block (Tandberg, etc.) */ +#define MTTELL 23 /* tell block (Tandberg, etc.) */ +#define MTSETDRVBUFFER 24 /* set the drive buffering according to SCSI-2 */ + /* ordinary buffered operation with code 1 */ +#define MTFSS 25 /* space forward over setmarks */ +#define MTBSS 26 /* space backward over setmarks */ +#define MTWSM 27 /* write setmarks */ + +#define MTLOCK 28 /* lock the drive door */ +#define MTUNLOCK 29 /* unlock the drive door */ +#define MTLOAD 30 /* execute the SCSI load command */ +#define MTUNLOAD 31 /* execute the SCSI unload command */ +#define MTCOMPRESSION 32/* control compression with SCSI mode page 15 */ +#define MTSETPART 33 /* Change the active tape partition */ +#define MTMKPART 34 /* Format the tape with one or two partitions */ + +/* structure for MTIOCGET - mag tape get status command */ + +typedef int daddr_t; + +struct mtget { + long int mt_type; /* type of magtape device */ + long int mt_resid; /* residual count: (not sure) + * number of bytes ignored, or + * number of files not skipped, or + * number of records not skipped. + */ + /* the following registers are device dependent */ + long int mt_dsreg; /* status register */ + long int mt_gstat; /* generic (device independent) status */ + long int mt_erreg; /* error register */ + /* The next two fields are not always used */ + daddr_t mt_fileno; /* number of current file on tape */ + daddr_t mt_blkno; /* current block number */ +}; + +/* + * Constants for mt_type. Not all of these are supported, + * and these are not all of the ones that are supported. + */ +#define MT_ISUNKNOWN 0x01 +#define MT_ISQIC02 0x02 /* Generic QIC-02 tape streamer */ +#define MT_ISWT5150 0x03 /* Wangtek 5150EQ, QIC-150, QIC-02 */ +#define MT_ISARCHIVE_5945L2 0x04 /* Archive 5945L-2, QIC-24, QIC-02? */ +#define MT_ISCMSJ500 0x05 /* CMS Jumbo 500 (QIC-02?) */ +#define MT_ISTDC3610 0x06 /* Tandberg 6310, QIC-24 */ +#define MT_ISARCHIVE_VP60I 0x07 /* Archive VP60i, QIC-02 */ +#define MT_ISARCHIVE_2150L 0x08 /* Archive Viper 2150L */ +#define MT_ISARCHIVE_2060L 0x09 /* Archive Viper 2060L */ +#define MT_ISARCHIVESC499 0x0A /* Archive SC-499 QIC-36 controller */ +#define MT_ISQIC02_ALL_FEATURES 0x0F /* Generic QIC-02 with all features */ +#define MT_ISWT5099EEN24 0x11 /* Wangtek 5099-een24, 60MB, QIC-24 */ +#define MT_ISTEAC_MT2ST 0x12 /* Teac MT-2ST 155mb drive, Teac DC-1 card (Wangtek type) */ +#define MT_ISEVEREX_FT40A 0x32 /* Everex FT40A (QIC-40) */ +#define MT_ISDDS1 0x51 /* DDS device without partitions */ +#define MT_ISDDS2 0x52 /* DDS device with partitions */ +#define MT_ISONSTREAM_SC 0x61 /* OnStream SCSI tape drives (SC-x0) + and SCSI emulated (DI, DP, USB) */ +#define MT_ISSCSI1 0x71 /* Generic ANSI SCSI-1 tape unit */ +#define MT_ISSCSI2 0x72 /* Generic ANSI SCSI-2 tape unit */ + +/* QIC-40/80/3010/3020 ftape supported drives. + * 20bit vendor ID + 0x800000 (see ftape-vendors.h) + */ +#define MT_ISFTAPE_UNKNOWN 0x800000 /* obsolete */ +#define MT_ISFTAPE_FLAG 0x800000 + +struct mt_tape_info { + long int t_type; /* device type id (mt_type) */ + char* t_name; /* descriptive name */ +}; + +#define MT_TAPE_INFO { \ + {MT_ISUNKNOWN, "Unknown type of tape device"}, \ + {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \ + {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \ + {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \ + {MT_ISCMSJ500, "CMS Jumbo 500"}, \ + {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \ + {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \ + {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \ + {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \ + {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \ + {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \ + {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \ + {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \ + {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \ + {MT_ISONSTREAM_SC, "OnStream SC-, DI-, DP-, or USB tape drive"}, \ + {MT_ISSCSI1, "Generic SCSI-1 tape"}, \ + {MT_ISSCSI2, "Generic SCSI-2 tape"}, \ + {0, NULL} \ +} + + +/* structure for MTIOCPOS - mag tape get position command */ + +struct mtpos { + long int mt_blkno; /* current block number */ +}; + + +/* structure for MTIOCGETCONFIG/MTIOCSETCONFIG primarily intended + * as an interim solution for QIC-02 until DDI is fully implemented. + */ +struct mtconfiginfo { + long int mt_type; /* drive type */ + long int ifc_type; /* interface card type */ + unsigned short int irqnr; /* IRQ number to use */ + unsigned short int dmanr; /* DMA channel to use */ + unsigned short int port; /* IO port base address */ + + unsigned long int debug; /* debugging flags */ + + unsigned int have_dens:1; + unsigned int have_bsf:1; + unsigned int have_fsr:1; + unsigned int have_bsr:1; + unsigned int have_eod:1; + unsigned int have_seek:1; + unsigned int have_tell:1; + unsigned int have_ras1:1; + unsigned int have_ras2:1; + unsigned int have_ras3:1; + unsigned int have_qfa:1; + + unsigned int pad1:5; + char reserved[10]; +}; + +/* structure for MTIOCVOLINFO, query information about the volume + * currently positioned at (zftape) + */ +struct mtvolinfo { + unsigned int mt_volno; /* vol-number */ + unsigned int mt_blksz; /* blocksize used when recording */ + unsigned int mt_rawsize; /* raw tape space consumed, in kb */ + unsigned int mt_size; /* volume size after decompression, in kb */ + unsigned int mt_cmpr:1; /* this volume has been compressed */ +}; + +/* raw access to a floppy drive, read and write an arbitrary segment. + * For ftape/zftape to support formatting etc. + */ +#define MT_FT_RD_SINGLE 0 +#define MT_FT_RD_AHEAD 1 +#define MT_FT_WR_ASYNC 0 /* start tape only when all buffers are full */ +#define MT_FT_WR_MULTI 1 /* start tape, continue until buffers are empty */ +#define MT_FT_WR_SINGLE 2 /* write a single segment and stop afterwards */ +#define MT_FT_WR_DELETE 3 /* write deleted data marks, one segment at time */ + +struct mtftseg { + unsigned int mt_segno; /* the segment to read or write */ + unsigned int mt_mode; /* modes for read/write (sync/async etc.) */ + int mt_result; /* result of r/w request, not of the ioctl */ + void *mt_data; /* User space buffer: must be 29kb */ +}; + +/* get tape capacity (ftape/zftape) + */ +struct mttapesize { + unsigned long mt_capacity; /* entire, uncompressed capacity of a cartridge */ + unsigned long mt_used; /* what has been used so far, raw uncompressed amount */ +}; + +/* possible values of the ftfmt_op field + */ +#define FTFMT_SET_PARMS 1 /* set software parms */ +#define FTFMT_GET_PARMS 2 /* get software parms */ +#define FTFMT_FORMAT_TRACK 3 /* start formatting a tape track */ +#define FTFMT_STATUS 4 /* monitor formatting a tape track */ +#define FTFMT_VERIFY 5 /* verify the given segment */ + +struct ftfmtparms { + unsigned char ft_qicstd; /* QIC-40/QIC-80/QIC-3010/QIC-3020 */ + unsigned char ft_fmtcode; /* Refer to the QIC specs */ + unsigned char ft_fhm; /* floppy head max */ + unsigned char ft_ftm; /* floppy track max */ + unsigned short ft_spt; /* segments per track */ + unsigned short ft_tpc; /* tracks per cartridge */ +}; + +struct ftfmttrack { + unsigned int ft_track; /* track to format */ + unsigned char ft_gap3; /* size of gap3, for FORMAT_TRK */ +}; + +struct ftfmtstatus { + unsigned int ft_segment; /* segment currently being formatted */ +}; + +struct ftfmtverify { + unsigned int ft_segment; /* segment to verify */ + unsigned long ft_bsm; /* bsm as result of VERIFY cmd */ +}; + +struct mtftformat { + unsigned int fmt_op; /* operation to perform */ + union fmt_arg { + struct ftfmtparms fmt_parms; /* format parameters */ + struct ftfmttrack fmt_track; /* ctrl while formatting */ + struct ftfmtstatus fmt_status; + struct ftfmtverify fmt_verify; /* for verifying */ + } fmt_arg; +}; + +/* mag tape io control commands */ +#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */ +#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */ +#define MTIOCPOS _IOR('m', 3, struct mtpos) /* get tape position */ + +/* The next two are used by the QIC-02 driver for runtime reconfiguration. + * See tpqic02.h for struct mtconfiginfo. + */ +#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo) /* get tape config */ +#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo) /* set tape config */ + +/* the next six are used by the floppy ftape drivers and its frontends + * sorry, but MTIOCTOP commands are write only. + */ +#define MTIOCRDFTSEG _IOWR('m', 6, struct mtftseg) /* read a segment */ +#define MTIOCWRFTSEG _IOWR('m', 7, struct mtftseg) /* write a segment */ +#define MTIOCVOLINFO _IOR('m', 8, struct mtvolinfo) /* info about volume */ +#define MTIOCGETSIZE _IOR('m', 9, struct mttapesize)/* get cartridge size*/ +#define MTIOCFTFORMAT _IOWR('m', 10, struct mtftformat) /* format ftape */ +#define MTIOCFTCMD _IOWR('m', 11, struct mtftcmd) /* send QIC-117 cmd */ + +/* Generic Mag Tape (device independent) status macros for examining + * mt_gstat -- HP-UX compatible. + * There is room for more generic status bits here, but I don't + * know which of them are reserved. At least three or so should + * be added to make this really useful. + */ +#define GMT_EOF(x) ((x) & 0x80000000) +#define GMT_BOT(x) ((x) & 0x40000000) +#define GMT_EOT(x) ((x) & 0x20000000) +#define GMT_SM(x) ((x) & 0x10000000) /* DDS setmark */ +#define GMT_EOD(x) ((x) & 0x08000000) /* DDS EOD */ +#define GMT_WR_PROT(x) ((x) & 0x04000000) +/* #define GMT_ ? ((x) & 0x02000000) */ +#define GMT_ONLINE(x) ((x) & 0x01000000) +#define GMT_D_6250(x) ((x) & 0x00800000) +#define GMT_D_1600(x) ((x) & 0x00400000) +#define GMT_D_800(x) ((x) & 0x00200000) +/* #define GMT_ ? ((x) & 0x00100000) */ +/* #define GMT_ ? ((x) & 0x00080000) */ +#define GMT_DR_OPEN(x) ((x) & 0x00040000) /* door open (no tape) */ +/* #define GMT_ ? ((x) & 0x00020000) */ +#define GMT_IM_REP_EN(x) ((x) & 0x00010000) /* immediate report mode */ +/* 16 generic status bits unused */ + + +/* SCSI-tape specific definitions */ +/* Bitfield shifts in the status */ +#define MT_ST_BLKSIZE_SHIFT 0 +#define MT_ST_BLKSIZE_MASK 0xffffff +#define MT_ST_DENSITY_SHIFT 24 +#define MT_ST_DENSITY_MASK 0xff000000 + +#define MT_ST_SOFTERR_SHIFT 0 +#define MT_ST_SOFTERR_MASK 0xffff + +/* Bitfields for the MTSETDRVBUFFER ioctl */ +#define MT_ST_OPTIONS 0xf0000000 +#define MT_ST_BOOLEANS 0x10000000 +#define MT_ST_SETBOOLEANS 0x30000000 +#define MT_ST_CLEARBOOLEANS 0x40000000 +#define MT_ST_WRITE_THRESHOLD 0x20000000 +#define MT_ST_DEF_BLKSIZE 0x50000000 +#define MT_ST_DEF_OPTIONS 0x60000000 +#define MT_ST_TIMEOUTS 0x70000000 +#define MT_ST_SET_TIMEOUT (MT_ST_TIMEOUTS | 0x000000) +#define MT_ST_SET_LONG_TIMEOUT (MT_ST_TIMEOUTS | 0x100000) + +#define MT_ST_BUFFER_WRITES 0x1 +#define MT_ST_ASYNC_WRITES 0x2 +#define MT_ST_READ_AHEAD 0x4 +#define MT_ST_DEBUGGING 0x8 +#define MT_ST_TWO_FM 0x10 +#define MT_ST_FAST_MTEOM 0x20 +#define MT_ST_AUTO_LOCK 0x40 +#define MT_ST_DEF_WRITES 0x80 +#define MT_ST_CAN_BSR 0x100 +#define MT_ST_NO_BLKLIMS 0x200 +#define MT_ST_CAN_PARTITIONS 0x400 +#define MT_ST_SCSI2LOGICAL 0x800 +#define MT_ST_SYSV 0x1000 + +/* The mode parameters to be controlled. Parameter chosen with bits 20-28 */ +#define MT_ST_CLEAR_DEFAULT 0xfffff +#define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000) +#define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000) +#define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000) + +/* The offset for the arguments for the special HP changer load command. */ +#define MT_ST_HPLOADER_OFFSET 10000 + +/* Specify default tape device. */ +#ifndef DEFTAPE +#define DEFTAPE "/dev/tape/0" +#endif #endif diff --git a/mdk-stage1/dietlibc/include/sys/param.h b/mdk-stage1/dietlibc/include/sys/param.h index 05f4d40e2..0744dccdb 100644 --- a/mdk-stage1/dietlibc/include/sys/param.h +++ b/mdk-stage1/dietlibc/include/sys/param.h @@ -3,6 +3,26 @@ #include -#define MAXPATHLEN PATH_MAX +#define MAXPATHLEN PATH_MAX +#define MAXHOSTNAMELEN 64 +#define NGROUPS 32 +#define NOGROUP (-1) + +#undef MIN +#undef MAX +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + +#ifdef __alpha__ +#define HZ 1024 +#else +#define HZ 100 +#endif + +#ifndef howmany +# define howmany(x, y) (((x)+((y)-1))/(y)) +#endif +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +#define powerof2(x) ((((x)-1)&(x))==0) #endif diff --git a/mdk-stage1/dietlibc/include/sys/poll.h b/mdk-stage1/dietlibc/include/sys/poll.h index adce26687..fe36df79d 100644 --- a/mdk-stage1/dietlibc/include/sys/poll.h +++ b/mdk-stage1/dietlibc/include/sys/poll.h @@ -3,9 +3,45 @@ #include -#include +enum { + POLLIN = 0x0001, +#define POLLIN POLLIN + POLLPRI = 0x0002, +#define POLLPRI POLLPRI + POLLOUT = 0x0004, +#define POLLOUT POLLOUT + POLLERR = 0x0008, +#define POLLERR POLLERR + POLLHUP = 0x0010, +#define POLLHUP POLLHUP + POLLNVAL = 0x0020, +#define POLLNVAL POLLNVAL + POLLRDNORM = 0x0040, +#define POLLRDNORM POLLRDNORM + POLLRDBAND = 0x0080, +#define POLLRDBAND POLLRDBAND + POLLWRBAND = 0x0200, +#define POLLWRBAND POLLWRBAND + POLLMSG = 0x0400, +#define POLLMSG POLLMSG +/* POLLREMOVE is for /dev/epoll (/dev/misc/eventpoll), + * a new event notification mechanism for 2.6 */ + POLLREMOVE = 0x1000, +#define POLLREMOVE POLLREMOVE +}; -extern int poll(struct pollfd *ufds, unsigned int nfds, int timeout) __THROW; +#if defined(__sparc__) || defined (__mips__) +#define POLLWRNORM POLLOUT +#else +#define POLLWRNORM 0x0100 +#endif + +struct pollfd { + int fd; + short events; + short revents; +}; +extern int poll(struct pollfd *ufds, unsigned int nfds, int timeout) __THROW; #endif /* _SYS_POLL_H */ diff --git a/mdk-stage1/dietlibc/include/sys/ptrace.h b/mdk-stage1/dietlibc/include/sys/ptrace.h index 9dd730bc6..b09d3ac3a 100644 --- a/mdk-stage1/dietlibc/include/sys/ptrace.h +++ b/mdk-stage1/dietlibc/include/sys/ptrace.h @@ -3,8 +3,844 @@ #include -#include +#define PTRACE_TRACEME 0 +#define PTRACE_PEEKTEXT 1 +#define PTRACE_PEEKDATA 2 +#define PTRACE_PEEKUSR 3 +#define PTRACE_PEEKUSER PTRACE_PEEKUSR +#define PTRACE_POKETEXT 4 +#define PTRACE_POKEDATA 5 +#define PTRACE_POKEUSR 6 +#define PTRACE_POKEUSER PTRACE_POKEUSR +#define PTRACE_CONT 7 +#define PTRACE_KILL 8 +#define PTRACE_SINGLESTEP 9 -extern long int ptrace (int request, ...) __THROW; +#define PTRACE_ATTACH 0x10 +#define PTRACE_DETACH 0x11 + +#define PTRACE_SYSCALL 24 + +#define PT_TRACE_ME PTRACE_TRACEME +#define PT_READ_I PTRACE_PEEKTEXT +#define PT_READ_D PTRACE_PEEKDATA +#define PT_READ_U PTRACE_READ_U +#define PT_WRITE_I PTRACE_POKETEXT +#define PT_WRITE_D PTRACE_POKEDATA +#define PT_WRITE_U PTRACE_POKEUSER +#define PT_CONTINUE PTRACE_CONT +#define PT_KILL PTRACE_KILL +#define PT_STEP PTRACE_SINGLESTEP +#define PT_GETREGS PTRACE_GETREGS +#define PT_SETREGS PTRACE_SETREGS +#define PT_GETFPREGS PTRACE_GETFPREGS +#define PT_SETFPREGS PTRACE_SETFPREGS +#define PT_ATTACH PTRACE_ATTACH +#define PT_DETACH PTRACE_DETACH + +#if defined(__i386__) +#define EBX 0 +#define ECX 1 +#define EDX 2 +#define ESI 3 +#define EDI 4 +#define EBP 5 +#define EAX 6 +#define DS 7 +#define ES 8 +#define FS 9 +#define GS 10 +#define ORIG_EAX 11 +#define EIP 12 +#define CS 13 +#define EFL 14 +#define UESP 15 +#define SS 16 +#define FRAME_SIZE 17 + +/* this struct defines the way the registers are stored on the + stack during a system call. */ + +struct pt_regs { + long ebx; + long ecx; + long edx; + long esi; + long edi; + long ebp; + long eax; + int xds; + int xes; + long orig_eax; + long eip; + int xcs; + long eflags; + long esp; + int xss; +}; + +/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ +#define PTRACE_GETREGS 12 +#define PTRACE_SETREGS 13 +#define PTRACE_GETFPREGS 14 +#define PTRACE_SETFPREGS 15 +#define PTRACE_GETFPXREGS 18 +#define PTRACE_SETFPXREGS 19 + +#define PTRACE_SETOPTIONS 21 + +/* options set using PTRACE_SETOPTIONS */ +#define PTRACE_O_TRACESYSGOOD 0x00000001 + +#elif defined(__s390__) + +#define PT_PSWMASK 0x00 +#define PT_PSWADDR 0x04 +#define PT_GPR0 0x08 +#define PT_GPR1 0x0C +#define PT_GPR2 0x10 +#define PT_GPR3 0x14 +#define PT_GPR4 0x18 +#define PT_GPR5 0x1C +#define PT_GPR6 0x20 +#define PT_GPR7 0x24 +#define PT_GPR8 0x28 +#define PT_GPR9 0x2C +#define PT_GPR10 0x30 +#define PT_GPR11 0x34 +#define PT_GPR12 0x38 +#define PT_GPR13 0x3C +#define PT_GPR14 0x40 +#define PT_GPR15 0x44 +#define PT_ACR0 0x48 +#define PT_ACR1 0x4C +#define PT_ACR2 0x50 +#define PT_ACR3 0x54 +#define PT_ACR4 0x58 +#define PT_ACR5 0x5C +#define PT_ACR6 0x60 +#define PT_ACR7 0x64 +#define PT_ACR8 0x68 +#define PT_ACR9 0x6C +#define PT_ACR10 0x70 +#define PT_ACR11 0x74 +#define PT_ACR12 0x78 +#define PT_ACR13 0x7C +#define PT_ACR14 0x80 +#define PT_ACR15 0x84 +#define PT_ORIGGPR2 0x88 +#define PT_FPC 0x90 +#define PT_FPR0_HI 0x98 +#define PT_FPR0_LO 0x9C +#define PT_FPR1_HI 0xA0 +#define PT_FPR1_LO 0xA4 +#define PT_FPR2_HI 0xA8 +#define PT_FPR2_LO 0xAC +#define PT_FPR3_HI 0xB0 +#define PT_FPR3_LO 0xB4 +#define PT_FPR4_HI 0xB8 +#define PT_FPR4_LO 0xBC +#define PT_FPR5_HI 0xC0 +#define PT_FPR5_LO 0xC4 +#define PT_FPR6_HI 0xC8 +#define PT_FPR6_LO 0xCC +#define PT_FPR7_HI 0xD0 +#define PT_FPR7_LO 0xD4 +#define PT_FPR8_HI 0xD8 +#define PT_FPR8_LO 0XDC +#define PT_FPR9_HI 0xE0 +#define PT_FPR9_LO 0xE4 +#define PT_FPR10_HI 0xE8 +#define PT_FPR10_LO 0xEC +#define PT_FPR11_HI 0xF0 +#define PT_FPR11_LO 0xF4 +#define PT_FPR12_HI 0xF8 +#define PT_FPR12_LO 0xFC +#define PT_FPR13_HI 0x100 +#define PT_FPR13_LO 0x104 +#define PT_FPR14_HI 0x108 +#define PT_FPR14_LO 0x10C +#define PT_FPR15_HI 0x110 +#define PT_FPR15_LO 0x114 +#define PT_CR_9 0x118 +#define PT_CR_10 0x11C +#define PT_CR_11 0x120 +#define PT_IEEE_IP 0x13C +#define PT_LASTOFF PT_IEEE_IP +#define PT_ENDREGS 0x140-1 + +#define NUM_GPRS 16 +#define NUM_FPRS 16 +#define NUM_CRS 16 +#define NUM_ACRS 16 +#define GPR_SIZE 4 +#define FPR_SIZE 8 +#define FPC_SIZE 4 +#define FPC_PAD_SIZE 4 /* gcc insists on aligning the fpregs */ +#define CR_SIZE 4 +#define ACR_SIZE 4 + +#define STACK_FRAME_OVERHEAD 96 /* size of minimum stack frame */ + +#include + +/* this typedef defines how a Program Status Word looks like */ +typedef struct { + uint32_t mask; + uint32_t addr; +} psw_t __attribute__ ((aligned(8))); + +typedef union +{ + float f; + double d; + uint64_t ui; + struct + { + uint32_t hi; + uint32_t lo; + } fp; +} freg_t; + +typedef struct +{ + uint32_t fpc; + freg_t fprs[NUM_FPRS]; +} s390_fp_regs; + +#define FPC_EXCEPTION_MASK 0xF8000000 +#define FPC_FLAGS_MASK 0x00F80000 +#define FPC_DXC_MASK 0x0000FF00 +#define FPC_RM_MASK 0x00000003 +#define FPC_VALID_MASK 0xF8F8FF03 + +typedef struct +{ + psw_t psw; + uint32_t gprs[NUM_GPRS]; + uint32_t acrs[NUM_ACRS]; + uint32_t orig_gpr2; +} s390_regs; + +struct pt_regs +{ + psw_t psw; + uint32_t gprs[NUM_GPRS]; + uint32_t acrs[NUM_ACRS]; + uint32_t orig_gpr2; + uint32_t trap; + uint32_t old_ilc; +}; + +typedef struct +{ + uint32_t cr[3]; +} per_cr_words __attribute__((packed)); + +#define PER_EM_MASK 0xE8000000 + +typedef uint32_t addr_t; + +typedef struct +{ + unsigned em_branching : 1; + unsigned em_instruction_fetch : 1; + /* + * Switching on storage alteration automatically fixes + * the storage alteration event bit in the users std. + */ + unsigned em_storage_alteration : 1; + unsigned em_gpr_alt_unused : 1; + unsigned em_store_real_address : 1; + unsigned : 3; + unsigned branch_addr_ctl : 1; + unsigned : 1; + unsigned storage_alt_space_ctl : 1; + unsigned : 21; + addr_t starting_addr; + addr_t ending_addr; +} per_cr_bits __attribute__((packed)); + +typedef struct +{ + uint16_t perc_atmid; /* 0x096 */ + uint32_t address; /* 0x098 */ + uint8_t access_id; /* 0x0a1 */ +} per_lowcore_words __attribute__((packed)); + +typedef struct +{ + unsigned perc_branching : 1; /* 0x096 */ + unsigned perc_instruction_fetch : 1; + unsigned perc_storage_alteration : 1; + unsigned perc_gpr_alt_unused : 1; + unsigned perc_store_real_address : 1; + unsigned : 4; + unsigned atmid_validity_bit : 1; + unsigned atmid_psw_bit_32 : 1; + unsigned atmid_psw_bit_5 : 1; + unsigned atmid_psw_bit_16 : 1; + unsigned atmid_psw_bit_17 : 1; + unsigned si : 2; + addr_t address; /* 0x098 */ + unsigned : 4; /* 0x0a1 */ + unsigned access_id : 4; +} per_lowcore_bits __attribute__((packed)); + +typedef struct +{ + union { + per_cr_words words; + per_cr_bits bits; + } control_regs __attribute__((packed)); + /* + * Use these flags instead of setting em_instruction_fetch + * directly they are used so that single stepping can be + * switched on & off while not affecting other tracing + */ + unsigned single_step : 1; + unsigned instruction_fetch : 1; + unsigned : 30; + /* + * These addresses are copied into cr10 & cr11 if single + * stepping is switched off + */ + uint32_t starting_addr; + uint32_t ending_addr; + union { + per_lowcore_words words; + per_lowcore_bits bits; + } lowcore; +} per_struct __attribute__((packed)); + +typedef struct +{ + uint32_t len; + addr_t kernel_addr; + addr_t process_addr; +} ptrace_area; + +/* + * S/390 specific non posix ptrace requests. I chose unusual values so + * they are unlikely to clash with future ptrace definitions. + */ +#define PTRACE_PEEKUSR_AREA 0x5000 +#define PTRACE_POKEUSR_AREA 0x5001 +#define PTRACE_PEEKTEXT_AREA 0x5002 +#define PTRACE_PEEKDATA_AREA 0x5003 +#define PTRACE_POKETEXT_AREA 0x5004 +#define PTRACE_POKEDATA_AREA 0x5005 +/* + * PT_PROT definition is loosely based on hppa bsd definition in + * gdb/hppab-nat.c + */ +#define PTRACE_PROT 21 + +typedef enum +{ + ptprot_set_access_watchpoint, + ptprot_set_write_watchpoint, + ptprot_disable_watchpoint +} ptprot_flags; + +typedef struct +{ + addr_t lowaddr; + addr_t hiaddr; + ptprot_flags prot; +} ptprot_area; + +/* Sequence of bytes for breakpoint illegal instruction. */ +#define S390_BREAKPOINT {0x0,0x1} +#define S390_BREAKPOINT_U16 ((uint16_t)0x0001) +#define S390_SYSCALL_OPCODE ((uint16_t)0x0a00) +#define S390_SYSCALL_SIZE 2 + +/* + * The user_regs_struct defines the way the user registers are + * store on the stack for signal handling. + */ +struct user_regs_struct +{ + psw_t psw; + uint32_t gprs[NUM_GPRS]; + uint32_t acrs[NUM_ACRS]; + uint32_t orig_gpr2; + s390_fp_regs fp_regs; + /* + * These per registers are in here so that gdb can modify them + * itself as there is no "official" ptrace interface for hardware + * watchpoints. This is the way intel does it. + */ + per_struct per_info; + addr_t ieee_instruction_pointer; + /* Used to give failing instruction back to user for ieee exceptions */ +}; + +#elif defined(__arm__) + +/* this assumes armv */ +#define USR26_MODE 0x00 +#define FIQ26_MODE 0x01 +#define IRQ26_MODE 0x02 +#define SVC26_MODE 0x03 +#define USR_MODE 0x10 +#define FIQ_MODE 0x11 +#define IRQ_MODE 0x12 +#define SVC_MODE 0x13 +#define ABT_MODE 0x17 +#define UND_MODE 0x1b +#define SYSTEM_MODE 0x1f +#define MODE_MASK 0x1f +#define T_BIT 0x20 +#define F_BIT 0x40 +#define I_BIT 0x80 +#define CC_V_BIT (1 << 28) +#define CC_C_BIT (1 << 29) +#define CC_Z_BIT (1 << 30) +#define CC_N_BIT (1 << 31) +#define PCMASK 0 + +struct pt_regs { + long uregs[18]; +}; + +#define ARM_cpsr uregs[16] +#define ARM_pc uregs[15] +#define ARM_lr uregs[14] +#define ARM_sp uregs[13] +#define ARM_ip uregs[12] +#define ARM_fp uregs[11] +#define ARM_r10 uregs[10] +#define ARM_r9 uregs[9] +#define ARM_r8 uregs[8] +#define ARM_r7 uregs[7] +#define ARM_r6 uregs[6] +#define ARM_r5 uregs[5] +#define ARM_r4 uregs[4] +#define ARM_r3 uregs[3] +#define ARM_r2 uregs[2] +#define ARM_r1 uregs[1] +#define ARM_r0 uregs[0] +#define ARM_ORIG_r0 uregs[17] + +#elif defined(__alpha__) + +struct pt_regs { + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r19; + unsigned long r20; + unsigned long r21; + unsigned long r22; + unsigned long r23; + unsigned long r24; + unsigned long r25; + unsigned long r26; + unsigned long r27; + unsigned long r28; + unsigned long hae; +/* JRP - These are the values provided to a0-a2 by PALcode */ + unsigned long trap_a0; + unsigned long trap_a1; + unsigned long trap_a2; +/* These are saved by PAL-code: */ + unsigned long ps; + unsigned long pc; + unsigned long gp; + unsigned long r16; + unsigned long r17; + unsigned long r18; +}; + +struct switch_stack { + unsigned long r9; + unsigned long r10; + unsigned long r11; + unsigned long r12; + unsigned long r13; + unsigned long r14; + unsigned long r15; + unsigned long r26; + unsigned long fp[32]; /* fp[31] is fpcr */ +}; + +#elif defined(__mips__) + +/* 0 - 31 are integer registers, 32 - 63 are fp registers. */ +#define FPR_BASE 32 +#define PC 64 +#define CAUSE 65 +#define BADVADDR 66 +#define MMHI 67 +#define MMLO 68 +#define FPC_CSR 69 +#define FPC_EIR 70 + +struct pt_regs { + /* Pad bytes for argument save space on the stack. */ + unsigned long pad0[6]; + /* Saved main processor registers. */ + unsigned long regs[32]; + /* Other saved registers. */ + unsigned long lo; + unsigned long hi; + /* saved cp0 registers */ + unsigned long cp0_epc; + unsigned long cp0_badvaddr; + unsigned long cp0_status; + unsigned long cp0_cause; +}; + +#elif defined(__sparc__) + +struct pt_regs { + unsigned long psr; + unsigned long pc; + unsigned long npc; + unsigned long y; + unsigned long u_regs[16]; /* globals and ins */ +}; + +#define UREG_G0 0 +#define UREG_G1 1 +#define UREG_G2 2 +#define UREG_G3 3 +#define UREG_G4 4 +#define UREG_G5 5 +#define UREG_G6 6 +#define UREG_G7 7 +#define UREG_I0 8 +#define UREG_I1 9 +#define UREG_I2 10 +#define UREG_I3 11 +#define UREG_I4 12 +#define UREG_I5 13 +#define UREG_I6 14 +#define UREG_I7 15 +#define UREG_WIM UREG_G0 +#define UREG_FADDR UREG_G0 +#define UREG_FP UREG_I6 +#define UREG_RETPC UREG_I7 + +/* A register window */ +struct reg_window { + unsigned long locals[8]; + unsigned long ins[8]; +}; + +/* A Sparc stack frame */ +struct sparc_stackf { + unsigned long locals[8]; + unsigned long ins[6]; + struct sparc_stackf *fp; + unsigned long callers_pc; + char *structptr; + unsigned long xargs[6]; + unsigned long xxargs[1]; +}; + +#define TRACEREG_SZ sizeof(struct pt_regs) +#define STACKFRAME_SZ sizeof(struct sparc_stackf) +#define REGWIN_SZ sizeof(struct reg_window) + +/* These are for pt_regs. */ +#define PT_PSR 0x0 +#define PT_PC 0x4 +#define PT_NPC 0x8 +#define PT_Y 0xc +#define PT_G0 0x10 +#define PT_WIM PT_G0 +#define PT_G1 0x14 +#define PT_G2 0x18 +#define PT_G3 0x1c +#define PT_G4 0x20 +#define PT_G5 0x24 +#define PT_G6 0x28 +#define PT_G7 0x2c +#define PT_I0 0x30 +#define PT_I1 0x34 +#define PT_I2 0x38 +#define PT_I3 0x3c +#define PT_I4 0x40 +#define PT_I5 0x44 +#define PT_I6 0x48 +#define PT_FP PT_I6 +#define PT_I7 0x4c + +/* Reg_window offsets */ +#define RW_L0 0x00 +#define RW_L1 0x04 +#define RW_L2 0x08 +#define RW_L3 0x0c +#define RW_L4 0x10 +#define RW_L5 0x14 +#define RW_L6 0x18 +#define RW_L7 0x1c +#define RW_I0 0x20 +#define RW_I1 0x24 +#define RW_I2 0x28 +#define RW_I3 0x2c +#define RW_I4 0x30 +#define RW_I5 0x34 +#define RW_I6 0x38 +#define RW_I7 0x3c + +/* Stack_frame offsets */ +#define SF_L0 0x00 +#define SF_L1 0x04 +#define SF_L2 0x08 +#define SF_L3 0x0c +#define SF_L4 0x10 +#define SF_L5 0x14 +#define SF_L6 0x18 +#define SF_L7 0x1c +#define SF_I0 0x20 +#define SF_I1 0x24 +#define SF_I2 0x28 +#define SF_I3 0x2c +#define SF_I4 0x30 +#define SF_I5 0x34 +#define SF_FP 0x38 +#define SF_PC 0x3c +#define SF_RETP 0x40 +#define SF_XARG0 0x44 +#define SF_XARG1 0x48 +#define SF_XARG2 0x4c +#define SF_XARG3 0x50 +#define SF_XARG4 0x54 +#define SF_XARG5 0x58 +#define SF_XXARG 0x5c + +/* Stuff for the ptrace system call */ +#define PTRACE_SUNATTACH 10 +#define PTRACE_SUNDETACH 11 +#define PTRACE_GETREGS 12 +#define PTRACE_SETREGS 13 +#define PTRACE_GETFPREGS 14 +#define PTRACE_SETFPREGS 15 +#define PTRACE_READDATA 16 +#define PTRACE_WRITEDATA 17 +#define PTRACE_READTEXT 18 +#define PTRACE_WRITETEXT 19 +#define PTRACE_GETFPAREGS 20 +#define PTRACE_SETFPAREGS 21 + +#define PTRACE_GETUCODE 29 /* stupid bsd-ism */ + +#elif defined(__powerpc__) + +struct pt_regs { + unsigned long gpr[32]; + unsigned long nip; + unsigned long msr; + unsigned long orig_gpr3; /* Used for restarting system calls */ + unsigned long ctr; + unsigned long link; + unsigned long xer; + unsigned long ccr; + unsigned long mq; /* 601 only (not used at present) */ + /* Used on APUS to hold IPL value. */ + unsigned long trap; /* Reason for being here */ + unsigned long dar; /* Fault registers */ + unsigned long dsisr; + unsigned long result; /* Result of a system call */ +}; + +/* + * Offsets used by 'ptrace' system call interface. + * These can't be changed without breaking binary compatibility + * with MkLinux, etc. + */ +#define PT_R0 0 +#define PT_R1 1 +#define PT_R2 2 +#define PT_R3 3 +#define PT_R4 4 +#define PT_R5 5 +#define PT_R6 6 +#define PT_R7 7 +#define PT_R8 8 +#define PT_R9 9 +#define PT_R10 10 +#define PT_R11 11 +#define PT_R12 12 +#define PT_R13 13 +#define PT_R14 14 +#define PT_R15 15 +#define PT_R16 16 +#define PT_R17 17 +#define PT_R18 18 +#define PT_R19 19 +#define PT_R20 20 +#define PT_R21 21 +#define PT_R22 22 +#define PT_R23 23 +#define PT_R24 24 +#define PT_R25 25 +#define PT_R26 26 +#define PT_R27 27 +#define PT_R28 28 +#define PT_R29 29 +#define PT_R30 30 +#define PT_R31 31 + +#define PT_NIP 32 +#define PT_MSR 33 +#define PT_CTR 35 +#define PT_LNK 36 +#define PT_XER 37 +#define PT_CCR 38 +#define PT_MQ 39 + +#define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */ +#define PT_FPR31 (PT_FPR0 + 2*31) +#define PT_FPSCR (PT_FPR0 + 2*32 + 1) + +#elif defined(__hppa__) + +#include + +struct pt_regs { + unsigned long gr[32]; /* PSW is in gr[0] */ + uint64_t fr[32]; + unsigned long sr[ 8]; + unsigned long iasq[2]; + unsigned long iaoq[2]; + unsigned long cr27; + unsigned long pad0; /* available for other uses */ + unsigned long orig_r28; + unsigned long ksp; + unsigned long kpc; + unsigned long sar; /* CR11 */ + unsigned long iir; /* CR19 */ + unsigned long isr; /* CR20 */ + unsigned long ior; /* CR21 */ + unsigned long ipsw; /* CR22 */ +}; + +#define PTRACE_SINGLEBLOCK 12 /* resume execution until next branch */ +#define PTRACE_GETSIGINFO 13 /* get child's siginfo structure */ +#define PTRACE_SETSIGINFO 14 /* set child's siginfo structure */ + +#elif defined(__ia64__) + +struct ia64_fpreg { + union { + unsigned long bits[2]; + } u; +} __attribute__ ((aligned (16))); + +struct pt_regs { + unsigned long cr_ipsr; /* interrupted task's psr */ + unsigned long cr_iip; /* interrupted task's instruction pointer */ + unsigned long cr_ifs; /* interrupted task's function state */ + unsigned long ar_unat; /* interrupted task's NaT register (preserved) */ + unsigned long ar_pfs; /* prev function state */ + unsigned long ar_rsc; /* RSE configuration */ + unsigned long ar_rnat; /* RSE NaT */ + unsigned long ar_bspstore; /* RSE bspstore */ + unsigned long pr; /* 64 predicate registers (1 bit each) */ + unsigned long b6; /* scratch */ + unsigned long loadrs; /* size of dirty partition << 16 */ + unsigned long r1; /* the gp pointer */ + unsigned long r2; /* scratch */ + unsigned long r3; /* scratch */ + unsigned long r12; /* interrupted task's memory stack pointer */ + unsigned long r13; /* thread pointer */ + unsigned long r14; /* scratch */ + unsigned long r15; /* scratch */ + unsigned long r8; /* scratch (return value register 0) */ + unsigned long r9; /* scratch (return value register 1) */ + unsigned long r10; /* scratch (return value register 2) */ + unsigned long r11; /* scratch (return value register 3) */ + unsigned long r16; /* scratch */ + unsigned long r17; /* scratch */ + unsigned long r18; /* scratch */ + unsigned long r19; /* scratch */ + unsigned long r20; /* scratch */ + unsigned long r21; /* scratch */ + unsigned long r22; /* scratch */ + unsigned long r23; /* scratch */ + unsigned long r24; /* scratch */ + unsigned long r25; /* scratch */ + unsigned long r26; /* scratch */ + unsigned long r27; /* scratch */ + unsigned long r28; /* scratch */ + unsigned long r29; /* scratch */ + unsigned long r30; /* scratch */ + unsigned long r31; /* scratch */ + unsigned long ar_ccv; /* compare/exchange value (scratch) */ + unsigned long ar_fpsr; /* floating point status (preserved) */ + unsigned long b0; /* return pointer (bp) */ + unsigned long b7; /* scratch */ + struct ia64_fpreg f6; /* scratch */ + struct ia64_fpreg f7; /* scratch */ + struct ia64_fpreg f8; /* scratch */ + struct ia64_fpreg f9; /* scratch */ +}; + +struct switch_stack { + unsigned long caller_unat; /* user NaT collection register (preserved) */ + unsigned long ar_fpsr; /* floating-point status register */ + + struct ia64_fpreg f2; /* preserved */ + struct ia64_fpreg f3; /* preserved */ + struct ia64_fpreg f4; /* preserved */ + struct ia64_fpreg f5; /* preserved */ + + struct ia64_fpreg f10; /* scratch, but untouched by kernel */ + struct ia64_fpreg f11; /* scratch, but untouched by kernel */ + struct ia64_fpreg f12; /* scratch, but untouched by kernel */ + struct ia64_fpreg f13; /* scratch, but untouched by kernel */ + struct ia64_fpreg f14; /* scratch, but untouched by kernel */ + struct ia64_fpreg f15; /* scratch, but untouched by kernel */ + struct ia64_fpreg f16; /* preserved */ + struct ia64_fpreg f17; /* preserved */ + struct ia64_fpreg f18; /* preserved */ + struct ia64_fpreg f19; /* preserved */ + struct ia64_fpreg f20; /* preserved */ + struct ia64_fpreg f21; /* preserved */ + struct ia64_fpreg f22; /* preserved */ + struct ia64_fpreg f23; /* preserved */ + struct ia64_fpreg f24; /* preserved */ + struct ia64_fpreg f25; /* preserved */ + struct ia64_fpreg f26; /* preserved */ + struct ia64_fpreg f27; /* preserved */ + struct ia64_fpreg f28; /* preserved */ + struct ia64_fpreg f29; /* preserved */ + struct ia64_fpreg f30; /* preserved */ + struct ia64_fpreg f31; /* preserved */ + + unsigned long r4; /* preserved */ + unsigned long r5; /* preserved */ + unsigned long r6; /* preserved */ + unsigned long r7; /* preserved */ + + unsigned long b0; /* so we can force a direct return in copy_thread */ + unsigned long b1; + unsigned long b2; + unsigned long b3; + unsigned long b4; + unsigned long b5; + + unsigned long ar_pfs; /* previous function state */ + unsigned long ar_lc; /* loop counter (preserved) */ + unsigned long ar_unat; /* NaT bits for r4-r7 */ + unsigned long ar_rnat; /* RSE NaT collection register */ + unsigned long ar_bspstore; /* RSE dirty base (preserved) */ + unsigned long pr; /* 64 predicate registers (1 bit each) */ +}; + +#endif + +extern long int ptrace(int request, ...) __THROW; #endif diff --git a/mdk-stage1/dietlibc/include/sys/reboot.h b/mdk-stage1/dietlibc/include/sys/reboot.h index ba58d296a..b17a556e5 100644 --- a/mdk-stage1/dietlibc/include/sys/reboot.h +++ b/mdk-stage1/dietlibc/include/sys/reboot.h @@ -1,9 +1,26 @@ #ifndef _SYS_REBOOT_H #define _SYS_REBOOT_H -#include +#define LINUX_REBOOT_MAGIC1 0xfee1dead +#define LINUX_REBOOT_MAGIC2 672274793 +#define LINUX_REBOOT_MAGIC2A 85072278 +#define LINUX_REBOOT_MAGIC2B 369367448 + +#define LINUX_REBOOT_CMD_RESTART 0x01234567 +#define LINUX_REBOOT_CMD_HALT 0xCDEF0123 +#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF +#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000 +#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC +#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4 /* Reboot or halt the system. */ -int reboot (int flag, void *arg); +int reboot (int flag); + +/* the glibc people changed their macro names :-/ */ +#define RB_AUTOBOOT 0x01234567 +#define RB_HALT_SYSTEM 0xcdef0123 +#define RB_ENABLE_CAD 0x89abcdef +#define RB_DISABLE_CAD 0 +#define RB_POWER_OFF 0x4321fedc #endif /* _SYS_REBOOT_H */ diff --git a/mdk-stage1/dietlibc/include/sys/resource.h b/mdk-stage1/dietlibc/include/sys/resource.h index 442434cd1..df31b82ab 100644 --- a/mdk-stage1/dietlibc/include/sys/resource.h +++ b/mdk-stage1/dietlibc/include/sys/resource.h @@ -1,8 +1,59 @@ #ifndef _SYS_RESOURCE_H #define _SYS_RESOURCE_H +#include #include -#include + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN (-1) +#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +struct rlimit { + unsigned long rlim_cur; + unsigned long rlim_max; +}; + +#define PRIO_MIN (-20) +#define PRIO_MAX 20 + +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 + +#define RLIMIT_CPU 0 /* CPU time in ms */ +#define RLIMIT_FSIZE 1 /* Maximum filesize */ +#define RLIMIT_DATA 2 /* max data size */ +#define RLIMIT_STACK 3 /* max stack size */ +#define RLIMIT_CORE 4 /* max core file size */ +#define RLIMIT_RSS 5 /* max resident set size */ +#define RLIMIT_NPROC 6 /* max number of processes */ +#define RLIMIT_NOFILE 7 /* max number of open files */ +#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ +#define RLIMIT_AS 9 /* address space limit */ +#define RLIMIT_LOCKS 10 /* maximum file locks held */ + +#define RLIM_NLIMITS 11 + +#define RLIM_INFINITY ((long)(~0UL>>1)) int getpriority(int which, int who) __THROW; int setpriority(int which, int who, int prio) __THROW; diff --git a/mdk-stage1/dietlibc/include/sys/select.h b/mdk-stage1/dietlibc/include/sys/select.h index e69de29bb..ce67b8bee 100644 --- a/mdk-stage1/dietlibc/include/sys/select.h +++ b/mdk-stage1/dietlibc/include/sys/select.h @@ -0,0 +1,22 @@ +#ifndef _SYS_SELECT_H +#define _SYS_SELECT_H + +typedef long int fd_mask; + +#define NFDBITS (8 * sizeof(unsigned long)) +#define FD_SETSIZE 1024 +#define __FDSET_LONGS (FD_SETSIZE/NFDBITS) +#define __FDELT(d) ((d) / NFDBITS) +#define __FDMASK(d) (1UL << ((d) % NFDBITS)) + +typedef struct { + unsigned long fds_bits [__FDSET_LONGS]; +} fd_set; + +#define FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) +#define FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) +#define FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0) +#define FD_ZERO(set) \ + ((void) memset ((void*) (set), 0, sizeof (fd_set))) + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/sem.h b/mdk-stage1/dietlibc/include/sys/sem.h index cc182649c..ad16b5f53 100644 --- a/mdk-stage1/dietlibc/include/sys/sem.h +++ b/mdk-stage1/dietlibc/include/sys/sem.h @@ -1,11 +1,81 @@ #ifndef _SYS_SEM_H #define _SYS_SEM_H -#include #include +/* semop flags */ +#define SEM_UNDO 0x1000 /* undo the operation on exit */ + +/* semctl Command Definitions. */ +#define GETPID 11 /* get sempid */ +#define GETVAL 12 /* get semval */ +#define GETALL 13 /* get all semval's */ +#define GETNCNT 14 /* get semncnt */ +#define GETZCNT 15 /* get semzcnt */ +#define SETVAL 16 /* set semval */ +#define SETALL 17 /* set all semval's */ + +/* ipcs ctl cmds */ +#define SEM_STAT 18 +#define SEM_INFO 19 + +struct semid_ds { + struct ipc_perm sem_perm; /* permissions .. see ipc.h */ + time_t sem_otime; /* last semop time */ + time_t sem_ctime; /* last change time */ + struct sem *sem_base; /* ptr to first semaphore in array */ + struct sem_queue *sem_pending; /* pending operations to be processed */ + struct sem_queue **sem_pending_last; /* last pending operation */ + struct sem_undo *undo; /* undo requests on this array */ + unsigned short sem_nsems; /* no. of semaphores in array */ +}; + +/* semop system calls takes an array of these. */ +struct sembuf { + unsigned short sem_num; /* semaphore index in array */ + short sem_op; /* semaphore operation */ + short sem_flg; /* operation flags */ +}; + +/* please complain to the glibc goons for the following misbehaviour */ +#if 0 +/* arg for semctl system calls. */ +union semun { + int val; /* value for SETVAL */ + struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ + unsigned short *array; /* array for GETALL & SETALL */ + struct seminfo *__buf; /* buffer for IPC_INFO */ + void *__pad; +}; +#endif +#define _SEM_SEMUN_UNDEFINED + +struct seminfo { + int semmap; + int semmni; + int semmns; + int semmnu; + int semmsl; + int semopm; + int semume; + int semusz; + int semvmx; + int semaem; +}; + +#define SEMMNI 128 /* <= IPCMNI max # of semaphore identifiers */ +#define SEMMSL 250 /* <= 8 000 max num of semaphores per id */ +#define SEMMNS (SEMMNI*SEMMSL) /* <= INT_MAX max # of semaphores in system */ +#define SEMOPM 32 /* <= 1 000 max num of ops per semop call */ +#define SEMVMX 32767 /* <= 32767 semaphore maximum value */ + extern int semget( key_t key, int nsems, int semflg) __THROW; -extern int semctl(int semid, int semnum, int cmd, union semun arg) __THROW; + +/* The prototype really is: + * extern int semctl(int semid, int semnum, int cmd, union semun arg) __THROW; + * glibc bug compatibility forces us to write it like this: */ +extern int semctl(int semid, int semnum, int cmd, ...) __THROW; + extern int semop(int semid, struct sembuf *sops, unsigned nsops) __THROW; #endif diff --git a/mdk-stage1/dietlibc/include/sys/sendfile.h b/mdk-stage1/dietlibc/include/sys/sendfile.h index 2e0c04add..ce6630676 100644 --- a/mdk-stage1/dietlibc/include/sys/sendfile.h +++ b/mdk-stage1/dietlibc/include/sys/sendfile.h @@ -2,8 +2,12 @@ #define _SYS_SENDFILE_H #include +#include -extern ssize_t sendfile (int __out_fd, int __in_fd, off_t *offset, - size_t __count) __THROW; +extern ssize_t sendfile (int out_fd, int in_fd, off_t* offset, + size_t count) __THROW; + +extern ssize_t sendfile64 (int out_fd, int in_fd, loff_t* offset, + size_t count) __THROW; #endif /* sys/sendfile.h */ diff --git a/mdk-stage1/dietlibc/include/sys/shm.h b/mdk-stage1/dietlibc/include/sys/shm.h index c27f5ddcf..879a8786e 100644 --- a/mdk-stage1/dietlibc/include/sys/shm.h +++ b/mdk-stage1/dietlibc/include/sys/shm.h @@ -1,12 +1,70 @@ #ifndef _SYS_SHM_H #define _SYS_SHM_H -#include #include -#include -#ifndef PAGE_SIZE -#define PAGE_SIZE getpagesize() +#define SHMMAX 0x2000000 /* max shared seg size (bytes) */ +#define SHMMIN 1 /* min shared seg size (bytes) */ +#define SHMMNI 4096 /* max num of segs system wide */ +#define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */ +#define SHMSEG SHMMNI /* max shared segs per process */ + +struct shmid_ds { + struct ipc_perm shm_perm; /* operation perms */ + int shm_segsz; /* size of segment (bytes) */ + time_t shm_atime; /* last attach time */ + time_t shm_dtime; /* last detach time */ + time_t shm_ctime; /* last change time */ + pid_t shm_cpid; /* pid of creator */ + pid_t shm_lpid; /* pid of last operator */ + unsigned short shm_nattch; /* no. of current attaches */ + unsigned short shm_unused; /* compatibility */ + void *shm_unused2; /* ditto - used by DIPC */ + void *shm_unused3; /* unused */ +}; + +/* permission flag for shmget */ +#define SHM_R 0400 /* or S_IRUGO from */ +#define SHM_W 0200 /* or S_IWUGO from */ + +/* mode for attach */ +#define SHM_RDONLY 010000 /* read-only access */ +#define SHM_RND 020000 /* round attach address to SHMLBA boundary */ +#define SHM_REMAP 040000 /* take-over region on attach */ + +/* super user shmctl commands */ +#define SHM_LOCK 11 +#define SHM_UNLOCK 12 + +/* ipcs ctl commands */ +#define SHM_STAT 13 +#define SHM_INFO 14 + +/* Obsolete, used only for backwards compatibility */ +struct shminfo { + int shmmax; + int shmmin; + int shmmni; + int shmseg; + int shmall; +}; + +struct shm_info { + int used_ids; + unsigned long shm_tot; /* total allocated shm */ + unsigned long shm_rss; /* total resident shm */ + unsigned long shm_swp; /* total swapped shm */ + unsigned long swap_attempts; + unsigned long swap_successes; +}; + +#if defined(__i386__) || defined(__mips__) || defined(__arm__) || defined(__powerpc__) || defined(__s390__) || defined(__hppa__) || defined(__x86_64__) || defined(__ia64__) +#define PAGE_SIZE 4096UL +#define PAGE_SHIFT 12 +#elif defined(__alpha__) || defined(__sparc__) +/* sun4* has 4k except sun4 architecture, sparc64 has 8k */ +#define PAGE_SIZE 8192UL +#define PAGE_SHIFT 13 #endif extern int shmget(key_t key, int size, int shmflg) __THROW; diff --git a/mdk-stage1/dietlibc/include/sys/socket.h b/mdk-stage1/dietlibc/include/sys/socket.h index a1435501c..a1130c4f6 100644 --- a/mdk-stage1/dietlibc/include/sys/socket.h +++ b/mdk-stage1/dietlibc/include/sys/socket.h @@ -3,26 +3,380 @@ #include #include -#include -#ifndef SOCK_DGRAM -/* the Linux kernel headers suck really badly on non-x86 */ +/* For setsockoptions(2) */ +#if defined(__alpha__) || defined(__mips__) +#define SOL_SOCKET 0xffff + +#define SO_DEBUG 0x0001 +#define SO_REUSEADDR 0x0004 +#define SO_TYPE 0x1008 +#define SO_ERROR 0x1007 +#define SO_DONTROUTE 0x0010 +#define SO_BROADCAST 0x0020 +#define SO_SNDBUF 0x1001 +#define SO_RCVBUF 0x1002 +#define SO_KEEPALIVE 0x0008 +#define SO_OOBINLINE 0x0100 +#define SO_NO_CHECK 11 +#define SO_PRIORITY 12 +#define SO_LINGER 0x0080 +#define SO_BSDCOMPAT 14 +/* To add :#define SO_REUSEPORT 15 */ +#define SO_PASSCRED 17 +#define SO_PEERCRED 18 +#define SO_RCVLOWAT 0x1004 +#define SO_SNDLOWAT 0x1003 +#define SO_RCVTIMEO 0x1006 +#define SO_SNDTIMEO 0x1005 +#define SO_ACCEPTCONN 0x1009 + +#define SO_STYLE SO_TYPE /* Synonym */ + +#elif defined(__hppa__) +#define SOL_SOCKET 0xffff + +#define SO_DEBUG 0x0001 +#define SO_REUSEADDR 0x0004 +#define SO_KEEPALIVE 0x0008 +#define SO_DONTROUTE 0x0010 +#define SO_BROADCAST 0x0020 +#define SO_LINGER 0x0080 +#define SO_OOBINLINE 0x0100 +/* To add :#define SO_REUSEPORT 0x0200 */ +#define SO_SNDBUF 0x1001 +#define SO_RCVBUF 0x1002 +#define SO_SNDLOWAT 0x1003 +#define SO_RCVLOWAT 0x1004 +#define SO_SNDTIMEO 0x1005 +#define SO_RCVTIMEO 0x1006 +#define SO_ERROR 0x1007 +#define SO_TYPE 0x1008 +#define SO_PEERNAME 0x2000 + +#define SO_NO_CHECK 0x400b +#define SO_PRIORITY 0x400c +#define SO_BSDCOMPAT 0x400e +#define SO_PASSCRED 0x4010 +#define SO_PEERCRED 0x4011 +#define SO_TIMESTAMP 0x4012 +#define SCM_TIMESTAMP SO_TIMESTAMP + +/* Security levels - as per NRL IPv6 - don't actually do anything */ +#define SO_SECURITY_AUTHENTICATION 0x4016 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x4017 +#define SO_SECURITY_ENCRYPTION_NETWORK 0x4018 + +#define SO_BINDTODEVICE 0x4019 + +/* Socket filtering */ +#define SO_ATTACH_FILTER 0x401a +#define SO_DETACH_FILTER 0x401b + +#define SO_ACCEPTCONN 0x401c + +#elif defined(__sparc__) +#define SOL_SOCKET 0xffff + +#define SO_DEBUG 0x0001 +#define SO_PASSCRED 0x0002 +#define SO_REUSEADDR 0x0004 +#define SO_KEEPALIVE 0x0008 +#define SO_DONTROUTE 0x0010 +#define SO_BROADCAST 0x0020 +#define SO_PEERCRED 0x0040 +#define SO_LINGER 0x0080 +#define SO_OOBINLINE 0x0100 +/* To add :#define SO_REUSEPORT 0x0200 */ +#define SO_BSDCOMPAT 0x0400 +#define SO_RCVLOWAT 0x0800 +#define SO_SNDLOWAT 0x1000 +#define SO_RCVTIMEO 0x2000 +#define SO_SNDTIMEO 0x4000 +#define SO_ACCEPTCONN 0x8000 + +#define SO_DONTLINGER (~SO_LINGER) /* Older SunOS compat. hack */ + +#define SO_SNDBUF 0x1001 +#define SO_RCVBUF 0x1002 +#define SO_ERROR 0x1007 +#define SO_TYPE 0x1008 + +#define SO_ATTACH_FILTER 0x001a +#define SO_DETACH_FILTER 0x001b + +#define SO_PEERNAME 0x001c +#define SO_TIMESTAMP 0x001d +#define SCM_TIMESTAMP SO_TIMESTAMP + +/* Security levels - as per NRL IPv6 - don't actually do anything */ +#define SO_SECURITY_AUTHENTICATION 0x5001 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002 +#define SO_SECURITY_ENCRYPTION_NETWORK 0x5004 + +#else + +#define SOL_SOCKET 1 + +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_NO_CHECK 11 +#define SO_PRIORITY 12 +#define SO_LINGER 13 +#define SO_BSDCOMPAT 14 +/* To add :#define SO_REUSEPORT 15 */ +#define SO_PASSCRED 16 +#define SO_PEERCRED 17 +#define SO_RCVLOWAT 18 +#define SO_SNDLOWAT 19 +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 +#define SO_ACCEPTCONN 30 + +#endif + +#if !defined(__hppa__) && !defined(__sparc__) +/* Security levels - as per NRL IPv6 - don't actually do anything */ +#define SO_SECURITY_AUTHENTICATION 22 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 23 +#define SO_SECURITY_ENCRYPTION_NETWORK 24 + +#define SO_BINDTODEVICE 25 + +/* Socket filtering */ +#define SO_ATTACH_FILTER 26 +#define SO_DETACH_FILTER 27 + +#define SO_PEERNAME 28 +#define SO_TIMESTAMP 29 +#define SCM_TIMESTAMP SO_TIMESTAMP +#endif + +/* Socket types. */ +#ifdef __mips__ +#define SOCK_DGRAM 1 /* datagram (conn.less) socket */ +#define SOCK_STREAM 2 /* stream (connection) socket */ +#else #define SOCK_STREAM 1 /* stream (connection) socket */ #define SOCK_DGRAM 2 /* datagram (conn.less) socket */ +#endif #define SOCK_RAW 3 /* raw socket */ #define SOCK_RDM 4 /* reliably-delivered message */ #define SOCK_SEQPACKET 5 /* sequential packet socket */ #define SOCK_PACKET 10 /* linux specific way of */ -#endif + /* getting packets at the dev */ + /* level. For writing rarp and */ + /* other similar things on the */ + /* user level. */ + +struct sockaddr { + sa_family_t sa_family; + char sa_data[14]; +}; + +struct linger { + int l_onoff; + int l_linger; +}; + +struct iovec { + void* iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ + size_t iov_len; /* Must be size_t (1003.1g) */ +}; + +struct msghdr { + void* msg_name; /* Socket name */ + int msg_namelen; /* Length of name */ + struct iovec* msg_iov; /* Data blocks */ + size_t msg_iovlen; /* Number of blocks */ + void* msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ + size_t msg_controllen; /* Length of cmsg list */ + unsigned msg_flags; +}; + +struct cmsghdr { + size_t cmsg_len; /* data byte count, including hdr */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ +}; + +#define UIO_FASTIOV 8 +#define UIO_MAXIOV 1024 + +/* "Socket"-level control message types: */ + +#define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ +#define SCM_CREDENTIALS 0x02 /* rw: struct ucred */ +#define SCM_CONNECT 0x03 /* rw: struct scm_connect */ + +struct ucred { + unsigned int pid; + unsigned int uid; + unsigned int gid; +}; + +/* Supported address families. */ +#define AF_UNSPEC 0 +#define AF_UNIX 1 /* Unix domain sockets */ +#define AF_LOCAL 1 /* POSIX name for AF_UNIX */ +#define AF_INET 2 /* Internet IP Protocol */ +#define AF_AX25 3 /* Amateur Radio AX.25 */ +#define AF_IPX 4 /* Novell IPX */ +#define AF_APPLETALK 5 /* AppleTalk DDP */ +#define AF_NETROM 6 /* Amateur Radio NET/ROM */ +#define AF_BRIDGE 7 /* Multiprotocol bridge */ +#define AF_ATMPVC 8 /* ATM PVCs */ +#define AF_X25 9 /* Reserved for X.25 project */ +#define AF_INET6 10 /* IP version 6 */ +#define AF_ROSE 11 /* Amateur Radio X.25 PLP */ +#define AF_DECnet 12 /* Reserved for DECnet project */ +#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ +#define AF_SECURITY 14 /* Security callback pseudo AF */ +#define AF_KEY 15 /* PF_KEY key management API */ +#define AF_NETLINK 16 +#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */ +#define AF_PACKET 17 /* Packet family */ +#define AF_ASH 18 /* Ash */ +#define AF_ECONET 19 /* Acorn Econet */ +#define AF_ATMSVC 20 /* ATM SVCs */ +#define AF_SNA 22 /* Linux SNA Project (nutters!) */ +#define AF_IRDA 23 /* IRDA sockets */ +#define AF_PPPOX 24 /* PPPoX sockets */ +#define AF_WANPIPE 25 /* Wanpipe API Sockets */ +#define AF_MAX 32 /* For now.. */ + +/* Protocol families, same as address families. */ +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_LOCAL AF_LOCAL +#define PF_INET AF_INET +#define PF_AX25 AF_AX25 +#define PF_IPX AF_IPX +#define PF_APPLETALK AF_APPLETALK +#define PF_NETROM AF_NETROM +#define PF_BRIDGE AF_BRIDGE +#define PF_ATMPVC AF_ATMPVC +#define PF_X25 AF_X25 +#define PF_INET6 AF_INET6 +#define PF_ROSE AF_ROSE +#define PF_DECnet AF_DECnet +#define PF_NETBEUI AF_NETBEUI +#define PF_SECURITY AF_SECURITY +#define PF_KEY AF_KEY +#define PF_NETLINK AF_NETLINK +#define PF_ROUTE AF_ROUTE +#define PF_PACKET AF_PACKET +#define PF_ASH AF_ASH +#define PF_ECONET AF_ECONET +#define PF_ATMSVC AF_ATMSVC +#define PF_SNA AF_SNA +#define PF_IRDA AF_IRDA +#define PF_PPPOX AF_PPPOX +#define PF_WANPIPE AF_WANPIPE +#define PF_MAX AF_MAX + +/* Maximum queue length specifiable by listen. */ +#define SOMAXCONN 128 + +/* Flags we can use with send/ and recv. + Added those for 1003.1g not all are supported yet */ +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */ +#define MSG_CTRUNC 8 +#define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */ +#define MSG_TRUNC 0x20 +#define MSG_DONTWAIT 0x40 /* Nonblocking io */ +#define MSG_EOR 0x80 /* End of record */ +#define MSG_WAITALL 0x100 /* Wait for a full request */ +#define MSG_FIN 0x200 +#define MSG_EOF MSG_FIN +#define MSG_SYN 0x400 +#define MSG_CONFIRM 0x800 /* Confirm path validity */ +#define MSG_RST 0x1000 +#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ +#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ +#define MSG_MORE 0x8000 /* Sender will send more */ + +/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ +#define SOL_IP 0 +/* #define SOL_ICMP 1 No-no-no! Due to Linux :-) we cannot use SOL_ICMP=1 */ +#define SOL_TCP 6 +#define SOL_UDP 17 +#define SOL_IPV6 41 +#define SOL_ICMPV6 58 +#define SOL_RAW 255 +#define SOL_IPX 256 +#define SOL_AX25 257 +#define SOL_ATALK 258 +#define SOL_NETROM 259 +#define SOL_ROSE 260 +#define SOL_DECNET 261 +#define SOL_X25 262 +#define SOL_PACKET 263 +#define SOL_ATM 264 /* ATM layer (cell level) */ +#define SOL_AAL 265 /* ATM Adaption Layer (packet level) */ +#define SOL_IRDA 266 + +/* IPX options */ +#define IPX_TYPE 1 + +#define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) +#define __CMSG_NXTHDR(ctl, len, cmsg) __cmsg_nxthdr((ctl),(len),(cmsg)) +#define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr((mhdr), (cmsg)) + +static inline struct cmsghdr* __cmsg_nxthdr(void *__ctl, size_t __size, struct cmsghdr *__cmsg) +{ + struct cmsghdr * __ptr; + __ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len)); + if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size) + return (struct cmsghdr *)0; + return __ptr; +} + +static inline struct cmsghdr* cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg) +{ + return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); +} + +#define CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr)))) +#define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len)) +#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) + +#define __CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(ctl) : \ + (struct cmsghdr *)NULL) +#define CMSG_FIRSTHDR(msg) __CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen) struct sockaddr_storage { - char __tmp[sizeof(struct sockaddr)]; + sa_family_t ss_family; + uint32_t __ss_align; + char __ss_padding[(128 - (2 * sizeof (uint32_t ))) ]; }; +#ifndef SOCK_DGRAM +/* the Linux kernel headers suck really badly on non-x86 */ +#define SOCK_STREAM 1 /* stream (connection) socket */ +#define SOCK_DGRAM 2 /* datagram (conn.less) socket */ +#define SOCK_RAW 3 /* raw socket */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequential packet socket */ +#define SOCK_PACKET 10 /* linux specific way of */ +#endif + int socket(int domain, int type, int protocol) __THROW; int accept(int s, struct sockaddr *addr, socklen_t *addrlen) __THROW; int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) __THROW; -int bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) __THROW; +int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen) __THROW; int recv(int s, void *buf, size_t len, int flags) __THROW; int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) __THROW; int recvmsg(int s, struct msghdr *msg, int flags) __THROW; @@ -43,4 +397,130 @@ int listen(int s, int backlog) __THROW; #define SHUT_RDWR 2 int shutdown(int s, int how) __THROW; +int socketpair(int d, int type, int protocol, int sv[2]); + +/* currently not supported: */ +#define NI_NOFQDN 1 + +#define NI_NUMERICHOST 2 +#define NI_NAMEREQD 4 +#define NI_NUMERICSERV 8 +#define NI_DGRAM 16 + +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; + +int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags) __THROW; +int getaddrinfo(const char *node, const char *service, const struct + addrinfo *hints, struct addrinfo **res) __THROW; +void freeaddrinfo(struct addrinfo *res) __THROW; +const char *gai_strerror(int errcode) __THROW; + +#define EAI_FAMILY -1 +#define EAI_SOCKTYPE -2 +#define EAI_BADFLAGS -3 +#define EAI_NONAME -4 +#define EAI_SERVICE -5 +#define EAI_ADDRFAMILY -6 +#define EAI_NODATA -7 +#define EAI_MEMORY -8 +#define EAI_FAIL -9 +#define EAI_AGAIN -10 +#define EAI_SYSTEM -11 + +#define AI_NUMERICHOST 1 +#define AI_CANONNAME 2 +#define AI_PASSIVE 4 + +/* Linux-specific socket ioctls */ +#define SIOCINQ FIONREAD +#define SIOCOUTQ TIOCOUTQ + +/* Routing table calls. */ +#define SIOCADDRT 0x890B /* add routing table entry */ +#define SIOCDELRT 0x890C /* delete routing table entry */ +#define SIOCRTMSG 0x890D /* call to routing system */ + +/* Socket configuration controls. */ +#define SIOCGIFNAME 0x8910 /* get iface name */ +#define SIOCSIFLINK 0x8911 /* set iface channel */ +#define SIOCGIFCONF 0x8912 /* get iface list */ +#define SIOCGIFFLAGS 0x8913 /* get flags */ +#define SIOCSIFFLAGS 0x8914 /* set flags */ +#define SIOCGIFADDR 0x8915 /* get PA address */ +#define SIOCSIFADDR 0x8916 /* set PA address */ +#define SIOCGIFDSTADDR 0x8917 /* get remote PA address */ +#define SIOCSIFDSTADDR 0x8918 /* set remote PA address */ +#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */ +#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */ +#define SIOCGIFNETMASK 0x891b /* get network PA mask */ +#define SIOCSIFNETMASK 0x891c /* set network PA mask */ +#define SIOCGIFMETRIC 0x891d /* get metric */ +#define SIOCSIFMETRIC 0x891e /* set metric */ +#define SIOCGIFMEM 0x891f /* get memory address (BSD) */ +#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */ +#define SIOCGIFMTU 0x8921 /* get MTU size */ +#define SIOCSIFMTU 0x8922 /* set MTU size */ +#define SIOCSIFNAME 0x8923 /* set interface name */ +#define SIOCSIFHWADDR 0x8924 /* set hardware address */ +#define SIOCGIFENCAP 0x8925 /* get/set encapsulations */ +#define SIOCSIFENCAP 0x8926 +#define SIOCGIFHWADDR 0x8927 /* Get hardware address */ +#define SIOCGIFSLAVE 0x8929 /* Driver slaving support */ +#define SIOCSIFSLAVE 0x8930 +#define SIOCADDMULTI 0x8931 /* Multicast address lists */ +#define SIOCDELMULTI 0x8932 +#define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */ +#define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */ +#define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */ +#define SIOCGIFPFLAGS 0x8935 +#define SIOCDIFADDR 0x8936 /* delete PA address */ +#define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */ +#define SIOCGIFCOUNT 0x8938 /* get number of devices */ + +#define SIOCGIFBR 0x8940 /* Bridging support */ +#define SIOCSIFBR 0x8941 /* Set bridging options */ + +#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ +#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */ + +#define SIOCGIFDIVERT 0x8944 /* Frame diversion support */ +#define SIOCSIFDIVERT 0x8945 /* Set frame diversion options */ + +#define SIOCETHTOOL 0x8946 /* Ethtool interface */ + +/* ARP cache control calls. */ + /* 0x8950 - 0x8952 * obsolete calls, don't re-use */ +#define SIOCDARP 0x8953 /* delete ARP table entry */ +#define SIOCGARP 0x8954 /* get ARP table entry */ +#define SIOCSARP 0x8955 /* set ARP table entry */ + +/* RARP cache control calls. */ +#define SIOCDRARP 0x8960 /* delete RARP table entry */ +#define SIOCGRARP 0x8961 /* get RARP table entry */ +#define SIOCSRARP 0x8962 /* set RARP table entry */ + +/* Driver configuration calls */ + +#define SIOCGIFMAP 0x8970 /* Get device parameters */ +#define SIOCSIFMAP 0x8971 /* Set device parameters */ + +/* DLCI configuration calls */ + +#define SIOCADDDLCI 0x8980 /* Create new DLCI device */ +#define SIOCDELDLCI 0x8981 /* Delete DLCI device */ + +#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */ + +#define _LINUX_SOCKET_H + #endif diff --git a/mdk-stage1/dietlibc/include/sys/stat.h b/mdk-stage1/dietlibc/include/sys/stat.h index 10fddfa42..d31cbd1f2 100644 --- a/mdk-stage1/dietlibc/include/sys/stat.h +++ b/mdk-stage1/dietlibc/include/sys/stat.h @@ -3,30 +3,499 @@ #include #include +#include -#include -#include +#if defined(__i386__) +struct stat { + unsigned short st_dev; + unsigned short __pad1; + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned short __pad2; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + signed long st_atime; + unsigned long __unused1; + signed long st_mtime; + unsigned long __unused2; + signed long st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; + +struct stat64 { + unsigned short st_dev; + unsigned char __pad0[10]; + +#define STAT64_HAS_BROKEN_ST_INO 1 + unsigned long __st_ino; + + unsigned int st_mode; + unsigned int st_nlink; + + unsigned long st_uid; + unsigned long st_gid; + + unsigned short st_rdev; + unsigned char __pad3[10]; + +__extension__ long long st_size; + unsigned long st_blksize; + + unsigned long st_blocks; /* Number 512-byte blocks allocated. */ + unsigned long __pad4; /* future possible st_blocks high bits */ + + unsigned long st_atime; + unsigned long __pad5; + + signed long st_mtime; + unsigned long __pad6; + + unsigned long st_ctime; + unsigned long __pad7; /* will be high 32 bits of ctime someday */ + +__extension__ unsigned long long st_ino; +}; +#elif defined(__sparc__) +struct stat { + unsigned short st_dev; + unsigned long st_ino; + unsigned short st_mode; + short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + long st_size; + long st_atime; + unsigned long __unused1; + long st_mtime; + unsigned long __unused2; + long st_ctime; + unsigned long __unused3; + long st_blksize; + long st_blocks; + unsigned long __unused4[2]; +}; + +struct stat64 { + unsigned char __pad0[6]; + unsigned short st_dev; + +__extension__ unsigned long long st_ino; + + unsigned int st_mode; + unsigned int st_nlink; + + unsigned int st_uid; + unsigned int st_gid; + + unsigned char __pad2[6]; + unsigned short st_rdev; + + unsigned char __pad3[8]; + +__extension__ long long st_size; + unsigned int st_blksize; + + unsigned char __pad4[8]; + unsigned int st_blocks; + + signed int st_atime; + unsigned int __unused1; + + signed int st_mtime; + unsigned int __unused2; + + signed int st_ctime; + unsigned int __unused3; + + unsigned int __unused4; + unsigned int __unused5; +}; +#elif defined(__alpha__) +struct stat { + unsigned int st_dev; + unsigned int st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned int st_uid; + unsigned int st_gid; + unsigned int st_rdev; + long st_size; + signed long st_atime; + signed long st_mtime; + signed long st_ctime; + unsigned int st_blksize; + int st_blocks; + unsigned int st_flags; + unsigned int st_gen; +}; +#elif defined(__mips__) +struct stat { + unsigned int st_dev; + long st_pad1[3]; /* Reserved for network id */ + ino_t st_ino; + unsigned int st_mode; + int st_nlink; + int st_uid; + int st_gid; + unsigned int st_rdev; + long st_pad2[2]; + long st_size; + long st_pad3; + /* + * Actually this should be timestruc_t st_atime, st_mtime and st_ctime + * but we don't have it under Linux. + */ + time_t st_atime; + long reserved0; + time_t st_mtime; + long reserved1; + time_t st_ctime; + long reserved2; + long st_blksize; + long st_blocks; + char st_fstype[16]; /* Filesystem type name */ + long st_pad4[8]; + /* Linux specific fields */ + unsigned int st_flags; + unsigned int st_gen; +}; + +struct stat64 { + unsigned long st_dev; + unsigned long st_pad0[3]; /* Reserved for st_dev expansion */ +__extension__ unsigned long long st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned int st_uid; + unsigned int st_gid; + unsigned long st_rdev; + unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */ +__extension__ long long st_size; + /* + * Actually this should be timestruc_t st_atime, st_mtime and st_ctime + * but we don't have it under Linux. + */ + time_t st_atime; + unsigned long reserved0; /* Reserved for st_atime expansion */ + time_t st_mtime; + unsigned long reserved1; /* Reserved for st_atime expansion */ + time_t st_ctime; + unsigned long reserved2; /* Reserved for st_atime expansion */ + unsigned long st_blksize; + unsigned long st_pad2; +__extension__ long long st_blocks; +}; +#elif defined(__powerpc__) +struct stat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + unsigned long st_blksize; + unsigned long st_blocks; + signed long st_atime; + unsigned long __unused1; + signed long st_mtime; + unsigned long __unused2; + signed long st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; + +/* This matches struct stat64 in glibc2.1. + */ +struct stat64 { +__extension__ unsigned long long st_dev; /* Device. */ +__extension__ unsigned long long st_ino; /* File serial number. */ + unsigned int st_mode; /* File mode. */ + unsigned int st_nlink; /* Link count. */ + unsigned int st_uid; /* User ID of the file's owner. */ + unsigned int st_gid; /* Group ID of the file's group. */ +__extension__ unsigned long long st_rdev; /* Device number, if device. */ + unsigned short int __pad2; +__extension__ long long st_size; /* Size of file, in bytes. */ + long st_blksize; /* Optimal block size for I/O. */ + +__extension__ long long st_blocks; /* Number 512-byte blocks allocated. */ + long st_atime; /* Time of last access. */ + unsigned long int __unused1; + long st_mtime; /* Time of last modification. */ + unsigned long int __unused2; + long st_ctime; /* Time of last status change. */ + unsigned long int __unused3; + unsigned long int __unused4; + unsigned long int __unused5; +}; +#elif defined(__arm__) +struct stat { + unsigned short st_dev; + unsigned short __pad1; + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned short __pad2; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + signed long st_atime; + unsigned long __unused1; + signed long st_mtime; + unsigned long __unused2; + signed long st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; + +/* This matches struct stat64 in glibc2.1, hence the absolutely + * insane amounts of padding around dev_t's. + */ +struct stat64 { + unsigned short st_dev; + unsigned char __pad0[10]; + +#define STAT64_HAS_BROKEN_ST_INO 1 + unsigned long __st_ino; + unsigned int st_mode; + unsigned int st_nlink; + + unsigned long st_uid; + unsigned long st_gid; + + unsigned short st_rdev; + unsigned char __pad3[10]; + +__extension__ long long st_size; + unsigned long st_blksize; + + unsigned long st_blocks; /* Number 512-byte blocks allocated. */ + unsigned long __pad4; /* future possible st_blocks high bits */ + + signed long st_atime; + unsigned long __pad5; + + signed long st_mtime; + unsigned long __pad6; + + signed long st_ctime; + unsigned long __pad7; /* will be high 32 bits of ctime someday */ + +__extension__ unsigned long long st_ino; +}; +#elif defined(__s390__) +struct stat { + unsigned short st_dev; + unsigned short __pad1; + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned short __pad2; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long __unused1; + unsigned long st_mtime; + unsigned long __unused2; + unsigned long st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; +struct stat64 { + unsigned char __pad0[6]; + unsigned short st_dev; + unsigned int __pad1; +#define STAT64_HAS_BROKEN_ST_INO 1 + unsigned long __st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned long st_uid; + unsigned long st_gid; + unsigned char __pad2[6]; + unsigned short st_rdev; + unsigned int __pad3; +__extension__ long long st_size; + unsigned long st_blksize; + unsigned char __pad4[4]; + unsigned long __pad5; /* future possible st_blocks high bits */ + unsigned long st_blocks; /* Number 512-byte blocks allocated. */ + unsigned long st_atime; + unsigned long __pad6; + unsigned long st_mtime; + unsigned long __pad7; + unsigned long st_ctime; + unsigned long __pad8; /* will be high 32 bits of ctime someday */ +__extension__ unsigned long long st_ino; +}; + +#elif defined(__hppa__) + +struct stat { + unsigned long long st_dev; + unsigned short int _pad1; + unsigned long st_ino; + unsigned long st_mode; + unsigned long st_nlink; + unsigned long st_uid; + unsigned long st_gid; + unsigned long long st_rdev; + unsigned short int _pad2; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long int unused1; + unsigned long st_mtime; + unsigned long int unused2; + unsigned long st_ctime; + unsigned long int unused3; + unsigned long long unused4; +}; + +struct stat64 { + unsigned long long st_dev; + unsigned int __pad1; +#define STAT64_HAS_BROKEN_ST_INO 1 + unsigned long __st_ino; + unsigned long st_mode; + unsigned long st_nlink; + unsigned long st_uid; + unsigned long st_gid; + unsigned long long st_rdev; + unsigned int __pad2; + unsigned long long st_size; + unsigned long long st_blksize; + + unsigned long long st_blocks; + unsigned long st_atime; + unsigned long int __unused1; + unsigned long st_mtime; + unsigned long int __unused2; + unsigned long st_ctime; + unsigned long int __unused3; + unsigned long long st_ino; +}; + +#elif defined(__x86_64__) +struct stat { + unsigned long st_dev; + unsigned long st_ino; + unsigned long st_nlink; + unsigned int st_mode; + unsigned int st_uid; + unsigned int st_gid; + unsigned int __pad0; + unsigned long st_rdev; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long __reserved0; + unsigned long st_mtime; + unsigned long __reserved1; + unsigned long st_ctime; + unsigned long __reserved2; + long __unused[3]; +}; + +#elif defined(__ia64__) + +struct stat { + unsigned long st_dev; + unsigned long st_ino; + unsigned long st_nlink; + unsigned int st_mode; + unsigned int st_uid; + unsigned int st_gid; + unsigned int __pad; + unsigned long st_rdev; + unsigned long st_size; + unsigned long st_atime; + unsigned long reserved; + unsigned long st_mtime; + unsigned long reserved2; + unsigned long st_ctime; + unsigned long reserved3; + unsigned long st_blksize; + long st_blocks; + unsigned long pad[3]; +}; -#ifndef STAT64_HAS_BROKEN_ST_INO -#define __NO_STAT64 #endif +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + extern int stat(const char *__file, struct stat *__buf) __THROW; extern int fstat(int __fd, struct stat *__buf) __THROW; extern int lstat(const char *__file, struct stat *__buf) __THROW; -#ifdef __NO_STAT64 -#undef _FILE_OFFSET_BITS +#if __WORDSIZE == 64 +#define __NO_STAT64 #else extern int stat64(const char *__file, struct stat64 *__buf) __THROW; extern int fstat64(int __fd, struct stat64 *__buf) __THROW; extern int lstat64(const char *__file, struct stat64 *__buf) __THROW; -#endif -#if _FILE_OFFSET_BITS == 64 -#define lstat(file,buf) lstat64(file,buf) -#define fstat(file,buf) fstat64(file,buf) +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +#define lstat lstat64 +#define fstat fstat64 #define stat stat64 +#define pread pread64 +#define pwrite pwrite64 +#endif #endif #define major(dev) (((dev)>>8) & 0xff) @@ -34,15 +503,10 @@ extern int lstat64(const char *__file, struct stat64 *__buf) __THROW; #define makedev(major, minor) ((((unsigned int) (major)) << 8) | ((unsigned int) (minor))) extern int chmod (const char *__file, mode_t __mode) __THROW; - extern int fchmod (int __fd, mode_t __mode) __THROW; - extern mode_t umask (mode_t __mask) __THROW; - extern int mkdir (const char *__path, mode_t __mode) __THROW; - extern int mknod (const char *__path, mode_t __mode, dev_t __dev) __THROW; - extern int mkfifo (const char *__path, mode_t __mode) __THROW; #define S_IREAD S_IRUSR diff --git a/mdk-stage1/dietlibc/include/sys/sysinfo.h b/mdk-stage1/dietlibc/include/sys/sysinfo.h index 5f059d469..cf88be34c 100644 --- a/mdk-stage1/dietlibc/include/sys/sysinfo.h +++ b/mdk-stage1/dietlibc/include/sys/sysinfo.h @@ -2,7 +2,25 @@ #define _SYS_SYSINFO_H #include -#include + +#define SI_LOAD_SHIFT 16 +struct sysinfo { + long uptime; /* Seconds since boot */ + unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ + unsigned long totalram; /* Total usable main memory size */ + unsigned long freeram; /* Available memory size */ + unsigned long sharedram; /* Amount of shared memory */ + unsigned long bufferram; /* Memory used by buffers */ + unsigned long totalswap; /* Total swap space size */ + unsigned long freeswap; /* swap space still available */ + unsigned short procs; /* Number of current processes */ + unsigned short pad; /* explicit padding */ + unsigned long totalhigh; /* Total high memory size */ + unsigned long freehigh; /* Available high memory size */ + unsigned int mem_unit; /* Memory unit size in bytes */ + char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ +}; + int sysinfo(struct sysinfo *info) __THROW; diff --git a/mdk-stage1/dietlibc/include/sys/syslog.h b/mdk-stage1/dietlibc/include/sys/syslog.h index 91bf0d1fa..8722038a5 100644 --- a/mdk-stage1/dietlibc/include/sys/syslog.h +++ b/mdk-stage1/dietlibc/include/sys/syslog.h @@ -92,7 +92,7 @@ void vsyslog (int priority, const char *format, va_list arg_ptr) __THROW; /* yuck yuck yuck, only needed for syslogd. */ typedef struct _code { - char *c_name; + const char *const c_name; int c_val; } CODE; diff --git a/mdk-stage1/dietlibc/include/sys/time.h b/mdk-stage1/dietlibc/include/sys/time.h index 11144f57b..9fc40089f 100644 --- a/mdk-stage1/dietlibc/include/sys/time.h +++ b/mdk-stage1/dietlibc/include/sys/time.h @@ -2,11 +2,39 @@ #define _SYS_TIME_H 1 #include - #include -#include +#include + +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 -#if defined __USE_GNU || defined __USE_BSD +struct itimerspec { + struct timespec it_interval; /* timer period */ + struct timespec it_value; /* timer expiration */ +}; + +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +#if defined _GNU_SOURCE || defined _BSD_SOURCE typedef struct timezone *__timezone_ptr_t; #else typedef void *__timezone_ptr_t; @@ -18,17 +46,17 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue int gettimeofday(struct timeval *tv, struct timezone *tz) __THROW; int settimeofday(const struct timeval *tv , const struct timezone *tz) __THROW; -extern int adjtime (const struct timeval *__delta, - struct timeval *__olddelta) __THROW; +extern int utimes (const char *__file, const struct timeval __tvp[2]) __THROW; -struct tm -{ +extern int adjtime (const struct timeval *delta, struct timeval *olddelta) __THROW; + +struct tm { int tm_sec; /* Seconds. [0-60] (1 leap second) */ int tm_min; /* Minutes. [0-59] */ int tm_hour; /* Hours. [0-23] */ int tm_mday; /* Day. [1-31] */ int tm_mon; /* Month. [0-11] */ - int tm_year; /* Year - 1900. */ + int tm_year; /* Year - 1900. */ int tm_wday; /* Day of week. [0-6] */ int tm_yday; /* Days in year.[0-365] */ int tm_isdst; /* DST. [-1/0/1]*/ @@ -37,10 +65,4 @@ struct tm const char *tm_zone; /* Timezone abbreviation. */ }; -struct tm* gmtime(const time_t *t) __THROW; -struct tm* gmtime_r(const time_t *t, struct tm *r) __THROW; - -struct tm* localtime(const time_t *t) __THROW; -struct tm* localtime_r(const time_t *t, struct tm *r) __THROW; - #endif diff --git a/mdk-stage1/dietlibc/include/sys/times.h b/mdk-stage1/dietlibc/include/sys/times.h index 72ec62fec..27f75cdc5 100644 --- a/mdk-stage1/dietlibc/include/sys/times.h +++ b/mdk-stage1/dietlibc/include/sys/times.h @@ -1,8 +1,16 @@ #ifndef _SYS_TIMES_H #define _SYS_TIMES_H -#include +#include +#include -clock_t times(struct tms *buf); +struct tms { + clock_t tms_utime; + clock_t tms_stime; + clock_t tms_cutime; + clock_t tms_cstime; +}; + +clock_t times(struct tms *buf) __THROW; #endif diff --git a/mdk-stage1/dietlibc/include/sys/types.h b/mdk-stage1/dietlibc/include/sys/types.h index 34dbaa9f1..a3d2bf4be 100644 --- a/mdk-stage1/dietlibc/include/sys/types.h +++ b/mdk-stage1/dietlibc/include/sys/types.h @@ -1,33 +1,133 @@ #ifndef _SYS_TYPES_H #define _SYS_TYPES_H -#include -#include -#include - -#ifdef __GNUC__ -#define __quad_t __quad_t -typedef long long int __quad_t; -typedef unsigned long long int __u_quad_t; +#include +#include + +typedef unsigned long int blkcnt_t; /* Used for file block counts */ +typedef unsigned long int blksize_t; /* Used for block sizes */ +typedef unsigned long int clock_t; /* Used for system times in + clock ticks or CLOCKS_PER_SEC + (see ). */ + +/* TODO: + clockid_t + Used for clock ID type in the clock and timer functions. + fsblkcnt_t + Used for file system block counts + fsfilcnt_t + Used for file system file counts + pthread_attr_t + Used to identify a thread attribute object. + pthread_cond_t + Used for condition variables. + pthread_condattr_t + Used to identify a condition attribute object. + pthread_key_t + Used for thread-specific data keys. + pthread_mutex_t + Used for mutexes. + pthread_mutexattr_t + Used to identify a mutex attribute object. + pthread_once_t + Used for dynamic package initialisation. + pthread_rwlock_t + Used for read-write locks. + pthread_rwlockattr_t + Used for read-write lock attributes. + pthread_t + Used to identify a thread. + timer_t + Used for timer ID returned by timer_create(). +*/ + +#if defined(__alpha__) || defined(__mips__) || defined(__powerpc__) || defined(__hppa__) || defined(__sparc64__) \ + || defined(__x86_64__) || defined(__ia64__) +typedef unsigned int uid_t; /* Used for user IDs. */ +typedef unsigned int gid_t; /* Used for group IDs. */ +typedef unsigned int dev_t; /* Used for device IDs. */ #else -#warning no long long support - no 64 bit file I/O support -typedef long int __quad_t; -typedef unsigned long int __u_quad_t; +typedef unsigned short uid_t; /* Used for user IDs. */ +typedef unsigned short gid_t; /* Used for group IDs. */ +typedef unsigned short dev_t; /* Used for device IDs. */ #endif +#if defined(__alpha__) || defined(__mips__) || defined(__powerpc__) || defined(__sparc64__) \ + || defined(__x86_64__) || defined(__ia64__) +typedef unsigned int mode_t; /* Used for some file attributes. */ +#else +typedef unsigned short mode_t; /* Used for some file attributes. */ +#endif -#ifdef __quad_t -typedef __quad_t off64_t; -typedef __u_quad_t ino64_t; -typedef __quad_t blkcnt64_t; +#if defined(__alpha__) || defined(__mips__) || defined(__sparc64__) \ + || defined(__x86_64__) || defined(__ia64__) +typedef unsigned int nlink_t; /* Used for link counts. */ +#else +typedef unsigned short nlink_t; /* Used for link counts. */ #endif +typedef signed int id_t; /* Used as a general identifier; can be + used to contain at least a pid_t, + uid_t or a gid_t. */ +typedef unsigned long ino_t; /* Used for file serial numbers. */ +typedef signed int key_t; /* Used for interprocess communication. */ +typedef signed int pid_t; /* Used for process IDs and process group IDs. */ +typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */ +typedef signed long suseconds_t; /* Used for time in microseconds. */ +typedef signed long time_t; /* Used for time in seconds. */ +typedef signed long useconds_t; /* Used for time in microseconds. */ + +/* non-susv2 types: */ +__extension__ typedef signed long long loff_t; /* 64-bit offset */ + +__extension__ typedef signed long long off64_t; +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +typedef off64_t off_t; +#else +typedef signed long off_t; /* Used for file sizes. */ +#endif + +__extension__ typedef unsigned long long ino64_t; +__extension__ typedef signed long long blkcnt64_t; + +typedef uint32_t uid32_t; +typedef uint32_t gid32_t; + typedef long int fpos_t; -#define socklen_t socklen_t +#define __socklen_t_defined typedef unsigned int socklen_t; +typedef unsigned short sa_family_t; -typedef long int blksize_t; -typedef long int blkcnt_t; +#ifdef _BSD_SOURCE +/* die, BSD, die! */ +typedef uint16_t nshort; +typedef uint32_t ntime; +typedef uint32_t nlong; +typedef uint32_t ulong; +typedef uint16_t n_short; +typedef uint32_t n_time; +typedef uint32_t n_long; +# ifndef __dietlibc_u_char_defined +typedef char* caddr_t; +typedef uint32_t u_long; +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +# define __dietlibc_u_char_defined +# endif +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +#endif + +#ifdef _GNU_SOURCE +typedef uint8_t u_int8_t; +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +#ifndef __STRICT_ANSI__ +typedef uint64_t u_int64_t; +#endif +#endif #endif diff --git a/mdk-stage1/dietlibc/include/sys/uio.h b/mdk-stage1/dietlibc/include/sys/uio.h index d64fd33c9..5edbdc8b2 100644 --- a/mdk-stage1/dietlibc/include/sys/uio.h +++ b/mdk-stage1/dietlibc/include/sys/uio.h @@ -1,7 +1,7 @@ #ifndef _SYS_UIO #define _SYS_UIO 1 -#include +#include int readv(int filedes, const struct iovec *vector, size_t count); int writev(int filedes, const struct iovec *vector, size_t count); diff --git a/mdk-stage1/dietlibc/include/sys/un.h b/mdk-stage1/dietlibc/include/sys/un.h index 213d9290e..000a937c1 100644 --- a/mdk-stage1/dietlibc/include/sys/un.h +++ b/mdk-stage1/dietlibc/include/sys/un.h @@ -3,6 +3,11 @@ #include -#include +#define UNIX_PATH_MAX 108 + +struct sockaddr_un { + sa_family_t sun_family; /* AF_UNIX */ + char sun_path[UNIX_PATH_MAX]; /* pathname */ +}; #endif /* sys/un.h */ diff --git a/mdk-stage1/dietlibc/include/sys/vfs.h b/mdk-stage1/dietlibc/include/sys/vfs.h index e4740a225..19b3242bb 100644 --- a/mdk-stage1/dietlibc/include/sys/vfs.h +++ b/mdk-stage1/dietlibc/include/sys/vfs.h @@ -3,7 +3,31 @@ #include #include -#include + +typedef struct { + int __val[2]; +} __kernel_fsid_t; + +struct statfs { + long f_type; + long f_bsize; +#ifdef __mips__ + long f_frsize; +#endif + long f_blocks; + long f_bfree; +#ifndef __mips__ + long f_bavail; +#endif + long f_files; + long f_ffree; +#ifdef __mips__ + long f_bavail; +#endif + __kernel_fsid_t f_fsid; + long f_namelen; + long f_spare[6]; +}; int statfs(const char *path, struct statfs *buf) __THROW; int fstatfs(int fd, struct statfs *buf) __THROW; diff --git a/mdk-stage1/dietlibc/include/sys/wait.h b/mdk-stage1/dietlibc/include/sys/wait.h index eb70112e2..0ba55499e 100644 --- a/mdk-stage1/dietlibc/include/sys/wait.h +++ b/mdk-stage1/dietlibc/include/sys/wait.h @@ -3,7 +3,13 @@ #include #include -#include + +#define WNOHANG 0x00000001 +#define WUNTRACED 0x00000002 + +#define __WNOTHREAD 0x20000000 /* Don't wait on children of other threads in this group */ +#define __WALL 0x40000000 /* Wait on all children, regardless of type */ +#define __WCLONE 0x80000000 /* Wait only on non-SIGCHLD children */ /* If WIFEXITED(STATUS), the low-order 8 bits of the status. */ #define __WEXITSTATUS(status) (((status) & 0xff00) >> 8) @@ -26,6 +32,8 @@ /* Nonzero if STATUS indicates the child is stopped. */ #define WIFSTOPPED(status) (((status) & 0xff) == 0x7f) +/* Nonzero if STATUS indicates the child dumped core. */ +#define WCOREDUMP(status) ((status) & 0x80) pid_t wait(int *status) __THROW; pid_t waitpid(pid_t pid, int *status, int options) __THROW; -- cgit v1.2.1