diff --git a/.clang-format b/.clang-format index cf1709826a..5b72a9bb78 100644 --- a/.clang-format +++ b/.clang-format @@ -1,5 +1,6 @@ --- AlignAfterOpenBracket: AlwaysBreak +AlignConsecutiveMacros: true AllowShortFunctionsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: false diff --git a/README b/README index 242683e25f..b28adc6f85 100644 --- a/README +++ b/README @@ -34,6 +34,7 @@ linux386 produces ELF executables for PC Linux systems linux68k produces ELF executables for m68020 Linux systems linuxppc produces ELF executables for PowerPC Linux systems linuxmips produces ELF executables for little-endian MIPS32r2 Linux systems +minix68k produces Minix executables for m68000 Minix systems cpm produces i80 CP/M .COM files rpi produces Raspberry Pi GPU binaries pdpv7 produces PDP/11 V7 Unix binaries diff --git a/build.lua b/build.lua index eca4e649e8..716b7990d0 100644 --- a/build.lua +++ b/build.lua @@ -11,6 +11,7 @@ vars.plats = { "linux68k", "linuxppc", "linuxmips", + "minix68k", "msdos86", "msdos386", "osx386", diff --git a/lang/cem/libcc.ansi/core/misc/raise.c b/lang/cem/libcc.ansi/core/misc/raise.c index e501931363..84a67612b5 100644 --- a/lang/cem/libcc.ansi/core/misc/raise.c +++ b/lang/cem/libcc.ansi/core/misc/raise.c @@ -7,6 +7,7 @@ #include #include #include +#include #if ACKCONF_WANT_EMULATED_RAISE diff --git a/lang/cem/libcc.ansi/headers/ack/config.h b/lang/cem/libcc.ansi/headers/ack/config.h index cf8f5d8355..5589cfb90a 100644 --- a/lang/cem/libcc.ansi/headers/ack/config.h +++ b/lang/cem/libcc.ansi/headers/ack/config.h @@ -23,6 +23,14 @@ #define ACKCONF_WANT_STANDARD_SIGNALS 1 #endif +#ifndef ACKCONF_WANT_STANDARD_LIMITS +#define ACKCONF_WANT_STANDARD_LIMITS 1 +#endif + +#ifndef ACKCONF_WANT_SYS_ERRNO_H +#define ACKCONF_WANT_SYS_ERRNO_H 0 +#endif + #ifndef ACKCONF_WANT_TERMIOS /* Don't compile termios-using functions unless the plat explicitly asks for it. */ #define ACKCONF_WANT_TERMIOS 0 diff --git a/lang/cem/libcc.ansi/headers/errno.h b/lang/cem/libcc.ansi/headers/errno.h index c1976bad6f..8c03694c7f 100644 --- a/lang/cem/libcc.ansi/headers/errno.h +++ b/lang/cem/libcc.ansi/headers/errno.h @@ -6,6 +6,10 @@ #ifndef _ERRNO_H #define _ERRNO_H +#if ACKCONF_WANT_SYS_ERRNO_H +#include +#else + /* These values are defined by the ANSI standard. */ #define EDOM 33 @@ -51,3 +55,5 @@ extern int errno; #endif + +#endif diff --git a/lang/cem/libcc.ansi/headers/limits.h b/lang/cem/libcc.ansi/headers/limits.h index 85ada3f748..184ca67d5a 100644 --- a/lang/cem/libcc.ansi/headers/limits.h +++ b/lang/cem/libcc.ansi/headers/limits.h @@ -6,6 +6,8 @@ #if !defined(_LIMITS_H) #define _LIMITS_H +#include + #define CHAR_BIT 8 #define SCHAR_MIN -128 #define SCHAR_MAX 127 @@ -34,4 +36,8 @@ #define UINT_MAX 4294967295U #endif +#if !ACKCONF_WANT_STANDARD_LIMITS + #include +#endif + #endif /* _LIMITS_H */ diff --git a/lang/cem/libcc.ansi/headers/unistd.h b/lang/cem/libcc.ansi/headers/unistd.h index a316132d2f..cefe2f2dc4 100644 --- a/lang/cem/libcc.ansi/headers/unistd.h +++ b/lang/cem/libcc.ansi/headers/unistd.h @@ -81,10 +81,11 @@ struct timezone extern char** environ; -/* Implemented system calls */ +/* System calls (not all of which are implemented) */ extern int access(const char* pathname, int mode); extern int brk(void* ptr); +extern int chdir(const char* path); extern int close(int d); extern int creat(const char* path, mode_t mode); extern int dup(int oldfd); @@ -111,7 +112,7 @@ extern unsigned int alarm(unsigned int seconds); extern pid_t wait(int* wstatus); extern sighandler_t signal(int signum, sighandler_t handler); extern ssize_t read(int fd, void* buffer, size_t count); -extern ssize_t write(int fd, void* buffer, size_t count); +extern ssize_t write(int fd, const void* buffer, size_t count); extern void _exit(int); extern void* sbrk(int increment); diff --git a/lang/cem/libcc.ansi/sys/malloc/malloc.c b/lang/cem/libcc.ansi/sys/malloc/malloc.c index ea13816007..09755109cf 100644 --- a/lang/cem/libcc.ansi/sys/malloc/malloc.c +++ b/lang/cem/libcc.ansi/sys/malloc/malloc.c @@ -5,19 +5,19 @@ #if ACKCONF_WANT_MALLOC -block_t __mem_root = { &__mem_root, 0 }; -block_t* __mem_freelist = &__mem_root; +memblock_t __mem_root = { &__mem_root, 0 }; +memblock_t* __mem_freelist = &__mem_root; /* Pulls more memory from the system. */ -static block_t* brkmore(size_t nb) +static memblock_t* brkmore(size_t nb) { uintptr_t bytes; - block_t* p; + memblock_t* p; if (nb < BRKSIZE) nb = BRKSIZE; - bytes = nb * sizeof(block_t); + bytes = nb * sizeof(memblock_t); /* Danger, will robinson! sbrk's parameter is *signed*... but malloc() takes a * size_t. */ @@ -26,7 +26,7 @@ static block_t* brkmore(size_t nb) return NULL; p = sbrk(bytes); - if (p == (block_t*)-1) + if (p == (memblock_t*)-1) return NULL; /* Add it to the free list by pretending it's a used block and freeing it. */ @@ -38,8 +38,8 @@ static block_t* brkmore(size_t nb) void* malloc(size_t size) { - block_t* p; - block_t* prev; + memblock_t* p; + memblock_t* prev; size_t nblocks; /* Add on space for the header; make sure we allocate a round number @@ -47,7 +47,7 @@ void* malloc(size_t size) nblocks = BLOCKCOUNT(size); if (nblocks < size) return NULL; - nblocks /= sizeof(block_t); + nblocks /= sizeof(memblock_t); prev = __mem_freelist; p = prev->next; @@ -88,8 +88,8 @@ void* malloc(size_t size) void free(void* ptr) { - block_t* h = BLOCKOF(ptr); - block_t* p; + memblock_t* h = BLOCKOF(ptr); + memblock_t* p; if (!ptr) return; diff --git a/lang/cem/libcc.ansi/sys/malloc/malloc.h b/lang/cem/libcc.ansi/sys/malloc/malloc.h index d70e92ae09..546fb1e7f0 100644 --- a/lang/cem/libcc.ansi/sys/malloc/malloc.h +++ b/lang/cem/libcc.ansi/sys/malloc/malloc.h @@ -7,19 +7,19 @@ typedef struct block_s { struct block_s* next; - size_t size; /* in sizeof(block_t) units */ -} block_t; + size_t size; /* in sizeof(memblock_t) units */ +} memblock_t; -extern block_t __mem_root; -extern block_t* __mem_first_free; +extern memblock_t __mem_root; +extern memblock_t* __mem_first_free; -#define BLOCKOF(p) (((block_t*)(p)) - 1) +#define BLOCKOF(p) (((memblock_t*)(p)) - 1) /* Smallest amount to allocate from brk */ -#define BRKSIZE (512 / sizeof(block_t)) +#define BRKSIZE (512 / sizeof(memblock_t)) #define BLOCKCOUNT(bytes) \ - (bytes + sizeof(block_t) + sizeof(block_t) - 1) + (bytes + sizeof(memblock_t) + sizeof(memblock_t) - 1) #endif diff --git a/lang/cem/libcc.ansi/sys/malloc/realloc.c b/lang/cem/libcc.ansi/sys/malloc/realloc.c index 6e2b4c924f..8464b5fd68 100644 --- a/lang/cem/libcc.ansi/sys/malloc/realloc.c +++ b/lang/cem/libcc.ansi/sys/malloc/realloc.c @@ -8,7 +8,7 @@ void* realloc(void* ptr, size_t size) { - block_t* h; + memblock_t* h; size_t nblocks; void* newptr; @@ -37,7 +37,7 @@ void* realloc(void* ptr, size_t size) newptr = malloc(size); if (!newptr) return NULL; - memcpy(newptr, ptr, h->size * sizeof(block_t)); + memcpy(newptr, ptr, h->size * sizeof(memblock_t)); free(ptr); return newptr; } diff --git a/lang/cem/libcc.ansi/sys/misc/sleep.c b/lang/cem/libcc.ansi/sys/misc/sleep.c index 97db561de7..8c0b7ef8ba 100644 --- a/lang/cem/libcc.ansi/sys/misc/sleep.c +++ b/lang/cem/libcc.ansi/sys/misc/sleep.c @@ -18,7 +18,7 @@ alfun(int sig) longjmp(setjmpbuf, 1); } /* used with sleep() below */ -void sleep(int n) +unsigned int sleep(int n) { /* sleep(n) pauses for 'n' seconds by scheduling an alarm interrupt. */ unsigned oldalarm = 0; @@ -30,7 +30,7 @@ void sleep(int n) { signal(SIGALRM, oldsig); alarm(oldalarm); - return; + return 0; } oldalarm = alarm(5000); /* Who cares how long, as long * as it is long enough diff --git a/lib/minix/include/fcntl.h b/lib/minix/include/fcntl.h deleted file mode 100644 index 323c390201..0000000000 --- a/lib/minix/include/fcntl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* The header is needed by the open() and fcntl() system calls, - * which have a variety of parameters and flags. They are described here. - * The formats of the calls to each of these are: - * - * open(path, oflag [,mode]) open a file - * fcntl(fd, cmd [,arg]) get or set file attributes - * - */ - -#ifndef _FCNTL_H -#define _FCNTL_H - -/* These values are used for cmd in fcntl(). POSIX Table 6-1. */ -#define F_DUPFD 0 /* duplicate file descriptor */ -#define F_GETFD 1 /* get file descriptor flags */ -#define F_SETFD 2 /* set file descriptor flags */ -#define F_GETFL 3 /* get file status flags */ -#define F_SETFL 4 /* set file status flags */ -#define F_GETLK 5 /* get record locking information */ -#define F_SETLK 6 /* set record locking information */ -#define F_SETLKW 7 /* set record locking info; wait if blocked */ - -/* File descriptor flags used for fcntl(). POSIX Table 6-2. */ -#define FD_CLOEXEC 1 /* close on exec flag for third arg of fcntl */ - -/* L_type values for record locking with fcntl(). POSIX Table 6-3. */ -#define F_RDLCK 0 /* shared or read lock */ -#define F_WRLCK 1 /* exclusive or write lock */ -#define F_UNLCK 2 /* unlock */ - -/* Oflag values for open(). POSIX Table 6-4. */ -#define O_CREAT 00100 /* creat file if it doesn't exist */ -#define O_EXCL 00200 /* exclusive use flag */ -#define O_NOCTTY 00400 /* do not assign a controlling terminal */ -#define O_TRUNC 01000 /* truncate flag */ - -/* File status flags for open() and fcntl(). POSIX Table 6-5. */ -#define O_APPEND 02000 /* set append mode */ -#define O_NONBLOCK 04000 /* no delay */ - -/* File access modes for open() and fcntl(). POSIX Table 6-6. */ -#define O_RDONLY 0 /* open(name, O_RDONLY) opens read only */ -#define O_WRONLY 1 /* open(name, O_WRONLY) opens write only */ -#define O_RDWR 2 /* open(name, O_RDWR) opens read/write */ - -/* Mask for use with file access modes. POSIX Table 6-7. */ -#define O_ACCMODE 03 /* mask for file access modes */ - -/* Struct used for locking. POSIX Table 6-8. */ -struct flock { - short l_type; /* type: F_RDLCK, F_WRLCK, or F_UNLCK */ - short l_whence; /* flag for starting offset */ - off_t l_start; /* relative offset in bytes */ - off_t l_len; /* size; if 0, then until EOF */ - pid_t l_pid; /* process id of the locks' owner */ -}; - - -/* Function Prototypes. */ -#ifndef _ANSI_H -#include -#endif - -_PROTOTYPE( int creat, (const char *_path, Mode_t _mode) ); -_PROTOTYPE( int fcntl, (int _filedes, int _cmd, ...) ); -_PROTOTYPE( int open, (const char *_path, int _oflag, ...) ); - -#endif /* _FCNTL_H */ diff --git a/lib/minix/include/lib.h b/lib/minix/include/lib.h deleted file mode 100644 index be64bf1548..0000000000 --- a/lib/minix/include/lib.h +++ /dev/null @@ -1,41 +0,0 @@ -/* The header is the master header used by the library. - * All the C files in the lib subdirectories include it. - */ - -#ifndef _LIB_H -#define _LIB_H - -/* First come the defines. */ -#define _POSIX_SOURCE 1 /* tell headers to include POSIX stuff */ -#define _MINIX 1 /* tell headers to include MINIX stuff */ - -/* The following are so basic, all the lib files get them automatically. */ -#include /* must be first */ -#include -#include -#include -#include - -#include -#include -#include - -extern message _M; - -#define MM 0 -#define FS 1 - -_PROTOTYPE( int __execve, (char *_path, char **_argv, char **_envp, - int _nargs, int _nenvps) ); -_PROTOTYPE( int _callm1, (int _proc, int _syscallnr, - int _int1, int _int2, int _int3, - char *_ptr1, char *_ptr2, char *_ptr3) ); -_PROTOTYPE( int _callm3, (int _proc, int _syscallnr, int _int1, - const char *_name) ); -_PROTOTYPE( int _callx, (int _proc, int _syscallnr) ); -_PROTOTYPE( int _len, (const char *_s) ); -_PROTOTYPE( void panic, (const char *_message, int _errnum) ); -_PROTOTYPE( int _sendrec, (int _src_dest, message *_m_ptr) ); -_PROTOTYPE( void _begsig, (int _dummy) ); - -#endif /* _LIB_H */ diff --git a/lib/minix/include/limits.h b/lib/minix/include/limits.h deleted file mode 100644 index be0e0389c5..0000000000 --- a/lib/minix/include/limits.h +++ /dev/null @@ -1,69 +0,0 @@ -/* The header defines some basic sizes, both of the language types - * (e.g., the number of bits in an integer), and of the operating system (e.g. - * the number of characters in a file name. - */ - -#ifndef _LIMITS_H -#define _LIMITS_H - -/* Definitions about chars (8 bits in MINIX, and signed). */ -#define CHAR_BIT 8 /* # bits in a char */ -#define CHAR_MIN -128 /* minimum value of a char */ -#define CHAR_MAX 127 /* maximum value of a char */ -#define SCHAR_MIN -128 /* minimum value of a signed char */ -#define SCHAR_MAX 127 /* maximum value of a signed char */ -#define UCHAR_MAX 255 /* maximum value of an unsigned char */ -#define MB_LEN_MAX 1 /* maximum length of a multibyte char */ - -/* Definitions about shorts (16 bits in MINIX). */ -#define SHRT_MIN (-32767-1) /* minimum value of a short */ -#define SHRT_MAX 32767 /* maximum value of a short */ -#define USHRT_MAX 0xFFFF /* maximum value of unsigned short */ - -#if _EM_WSIZE == 4 -#define INT_MIN (-2147483647-1) -#define INT_MAX 2147483647 -#define UINT_MAX 0xFFFFFFFF -#else /* _EM_WSIZE == 2 */ -/* Definitions about ints (16 bits in MINIX for 8088, 80286, Atari etc) */ -#define INT_MIN (-32767-1) /* minimum value of an int */ -#define INT_MAX 32767 /* maximum value of an int */ -#define UINT_MAX 0xFFFF /* maximum value of an unsigned int */ -#endif - -/*Definitions about longs (32 bits in MINIX). */ -#define LONG_MIN (-2147483647L-1)/* minimum value of a long */ -#define LONG_MAX 2147483647L /* maximum value of a long */ -#define ULONG_MAX 0xFFFFFFFFL /* maximum value of an unsigned long */ - -/* Minimum sizes required by the POSIX P1003.1 standard (Table 2-2). */ -#ifdef _POSIX_SOURCE /* these are only visible for POSIX */ -#define _POSIX_ARG_MAX 4096 /* exec() may have 4K worth of args */ -#define _POSIX_CHILD_MAX 6 /* a process may have 6 children */ -#define _POSIX_LINK_MAX 8 /* a file may have 8 links */ -#define _POSIX_MAX_CANON 255 /* size of the canonical input queue */ -#define _POSIX_MAX_INPUT 255 /* you can type 255 chars ahead */ -#define _POSIX_NAME_MAX 14 /* a file name may have 14 chars */ -#define _POSIX_NGROUPS_MAX 0 /* supplementary group IDs are optional */ -#define _POSIX_OPEN_MAX 16 /* a process may have 16 files open */ -#define _POSIX_PATH_MAX 255 /* a pathname may contain 255 chars */ -#define _POSIX_PIPE_BUF 512 /* pipes writes of 512 bytes must be atomic */ - -/* Values actually implemented by MINIX (Tables 2-3, 2-4, and 2-5). */ -/* Some of these old names had better be defined when not POSIX. */ -#define _NO_LIMIT 100 /* arbitrary number; limit not enforced */ - -#define NGROUPS_MAX 0 /* supplemental group IDs not available */ -#define ARG_MAX 4096 /* # bytes of args + environ for exec() */ -#define CHILD_MAX _NO_LIMIT /* MINIX does not limit children */ -#define OPEN_MAX 20 /* # open files a process may have */ -#define LINK_MAX 127 /* # links a file may have */ -#define MAX_CANON 255 /* size of the canonical input queue */ -#define MAX_INPUT 255 /* size of the type-ahead buffer */ -#define NAME_MAX 14 /* # chars in a file name */ -#define PATH_MAX 255 /* # chars in a path name */ -#define PIPE_BUF 7168 /* # bytes in atomic write to a pipe */ - -#endif /* _POSIX_SOURCE */ - -#endif /* _LIMITS_H */ diff --git a/lib/minix/include/minix/callnr.h b/lib/minix/include/minix/callnr.h deleted file mode 100644 index 9ecc2d954e..0000000000 --- a/lib/minix/include/minix/callnr.h +++ /dev/null @@ -1,58 +0,0 @@ -#define NCALLS 70 /* number of system calls allowed */ - -#define EXIT 1 -#define FORK 2 -#define READ 3 -#define WRITE 4 -#define OPEN 5 -#define CLOSE 6 -#define WAIT 7 -#define CREAT 8 -#define LINK 9 -#define UNLINK 10 -#define CHDIR 12 -#define TIME 13 -#define MKNOD 14 -#define CHMOD 15 -#define CHOWN 16 -#define BRK 17 -#define STAT 18 -#define LSEEK 19 -#define GETPID 20 -#define MOUNT 21 -#define UMOUNT 22 -#define SETUID 23 -#define GETUID 24 -#define STIME 25 -#define PTRACE 26 -#define ALARM 27 -#define FSTAT 28 -#define PAUSE 29 -#define UTIME 30 -#define ACCESS 33 -#define SYNC 36 -#define KILL 37 -#define RENAME 38 -#define MKDIR 39 -#define RMDIR 40 -#define DUP 41 -#define PIPE 42 -#define TIMES 43 -#define SETGID 46 -#define GETGID 47 -#define SIGNAL 48 -#define IOCTL 54 -#define FCNTL 55 -#define EXEC 59 -#define UMASK 60 -#define CHROOT 61 - -/* The following are not system calls, but are processed like them. */ -#define KSIG 64 /* kernel detected a signal */ -#define UNPAUSE 65 /* to MM or FS: check for EINTR */ -#define BRK2 66 /* to MM: used to say how big FS & INIT are */ -#define REVIVE 67 /* to FS: revive a sleeping process */ -#define TASK_REPLY 68 /* to FS: reply code from tty task */ - -/* The following IS a system call for amoeba transactions */ -#define AM_SYSCALL 69 diff --git a/lib/minix/include/minix/com.h b/lib/minix/include/minix/com.h deleted file mode 100644 index 2096f8ba76..0000000000 --- a/lib/minix/include/minix/com.h +++ /dev/null @@ -1,166 +0,0 @@ -/* System calls. */ -#define SEND 1 /* function code for sending messages */ -#define RECEIVE 2 /* function code for receiving messages */ -#define BOTH 3 /* function code for SEND + RECEIVE */ -#define ANY (NR_PROCS+100) /* receive(ANY, buf) accepts from any source */ - -/* Task numbers, function codes and reply codes. */ - -#define TTY -NR_TASKS /* terminal I/O class */ -# define TTY_READ 3 /* fcn code for reading from tty */ -# define TTY_WRITE 4 /* fcn code for writing to tty */ -# define TTY_IOCTL 5 /* fcn code for ioctl */ -# define TTY_SETPGRP 6 /* fcn code for setpgrp */ -# define TTY_OPEN 7 /* fcn code for opening tty */ -# define TTY_CLOSE 8 /* fcn code for closing tty */ -# define SUSPEND -998 /* used in interrupts when tty has no data */ - -#ifdef AM_KERNEL -#define AMOEBA -#endif - -#ifdef AMOEBA - -/* There are AM_NTASK copies of the amoeba kernel task. - * If you change AM_NTASKS be sure to adjust kernel/table.c and fs/table.c - */ -#define AM_NTASKS 4 /* number of kernel tasks of this class */ - -#define AMINT_CLASS (TTY+1) /* Amoeba event handler */ -#define AMOEBA_CLASS (AMINT_CLASS+AM_NTASKS) /* transaction handlers */ -# define ETHER_ARRIV 1 /* fcn code for packet arrival */ -# define AM_TRANS 2 /* amoeba transaction */ -# define AM_GETREQ 3 /* amoeba getrequest */ -# define AM_PUTREP 4 /* amoeba putrep */ -# define AM_REVIVE 6 /* used by kernel task to revive luser task */ -# define AM_TIMEOUT 8 /* used to talk to clock task */ -# define AM_PUTSIG 9 /* when the luser hits the DEL ! */ -# define AM_TASK_DIED 10 /* sent if task died during a transaction */ - -#else /* if AMOEBA not defined */ - -#define AMOEBA_CLASS TTY - -#endif /* AMOEBA */ - -/* - * New class definitions should go here and should be defined relative - * to AMOEBA_CLASS (ie. as AMOEBA_CLASS+n, for the nth task added). - */ - -#define IDLE (AMOEBA_CLASS+1) /* task to run when there's nothing to run */ - -#define PRINTER -7 /* printer I/O class */ -/* The printer uses the same commands as TTY. */ - -#define WINCHESTER -6 /* winchester (hard) disk class */ -#define FLOPPY -5 /* floppy disk class */ -# define DISK_READ 3 /* fcn code to DISK (must equal TTY_READ) */ -# define DISK_WRITE 4 /* fcn code to DISK (must equal TTY_WRITE) */ -# define DISK_IOCTL 5 /* fcn code for setting up RAM disk */ -# define SCATTERED_IO 6 /* fcn code for multiple reads/writes */ -# define OPTIONAL_IO 16 /* modifier to DISK_* codes within vector */ - -#define MEM -4 /* /dev/ram, /dev/(k)mem and /dev/null class */ -# define RAM_DEV 0 /* minor device for /dev/ram */ -# define MEM_DEV 1 /* minor device for /dev/mem */ -# define KMEM_DEV 2 /* minor device for /dev/kmem */ -# define NULL_DEV 3 /* minor device for /dev/null */ -#if (CHIP == INTEL) -# define PORT_DEV 4 /* minor device for /dev/port */ -#endif - -#define CLOCK -3 /* clock class */ -# define SET_ALARM 1 /* fcn code to CLOCK, set up alarm */ -# define GET_TIME 3 /* fcn code to CLOCK, get real time */ -# define SET_TIME 4 /* fcn code to CLOCK, set real time */ -# define REAL_TIME 1 /* reply from CLOCK: here is real time */ - -#define SYSTASK -2 /* internal functions */ -# define SYS_XIT 1 /* fcn code for sys_xit(parent, proc) */ -# define SYS_GETSP 2 /* fcn code for sys_sp(proc, &new_sp) */ -# define SYS_SIG 3 /* fcn code for sys_sig(proc, sig) */ -# define SYS_FORK 4 /* fcn code for sys_fork(parent, child) */ -# define SYS_NEWMAP 5 /* fcn code for sys_newmap(procno, map_ptr) */ -# define SYS_COPY 6 /* fcn code for sys_copy(ptr) */ -# define SYS_EXEC 7 /* fcn code for sys_exec(procno, new_sp) */ -# define SYS_TIMES 8 /* fcn code for sys_times(procno, bufptr) */ -# define SYS_ABORT 9 /* fcn code for sys_abort() */ -# define SYS_FRESH 10 /* fcn code for sys_fresh() (Atari only) */ -# define SYS_KILL 11 /* fcn code for sys_kill(proc, sig) */ -# define SYS_GBOOT 12 /* fcn code for sys_gboot(procno, bootptr) */ -# define SYS_UMAP 13 /* fcn code for sys_umap(procno, etc) */ -# define SYS_MEM 14 /* fcn code for sys_mem() */ -# define SYS_TRACE 15 /* fcn code for sys_trace(req,pid,addr,data) */ - -#define HARDWARE -1 /* used as source on interrupt generated msgs*/ - -/* Names of message fields for messages to CLOCK task. */ -#define DELTA_TICKS m6_l1 /* alarm interval in clock ticks */ -#define FUNC_TO_CALL m6_f1 /* pointer to function to call */ -#define NEW_TIME m6_l1 /* value to set clock to (SET_TIME) */ -#define CLOCK_PROC_NR m6_i1 /* which proc (or task) wants the alarm? */ -#define SECONDS_LEFT m6_l1 /* how many seconds were remaining */ - -/* Names of message fields used for messages to block and character tasks. */ -#define DEVICE m2_i1 /* major-minor device */ -#define PROC_NR m2_i2 /* which (proc) wants I/O? */ -#define COUNT m2_i3 /* how many bytes to transfer */ -#define POSITION m2_l1 /* file offset */ -#define ADDRESS m2_p1 /* core buffer address */ - -/* Names of message fields for messages to TTY task. */ -#define TTY_LINE m2_i1 /* message parameter: terminal line */ -#define TTY_REQUEST m2_i3 /* message parameter: ioctl request code */ -#define TTY_SPEK m2_l1 /* message parameter: ioctl speed, erasing */ -#define TTY_FLAGS m2_l2 /* message parameter: ioctl tty mode */ -#define TTY_PGRP m2_i3 /* message parameter: process group */ - -/* Names of messages fields used in reply messages from tasks. */ -#define REP_PROC_NR m2_i1 /* # of proc on whose behalf I/O was done */ -#define REP_STATUS m2_i2 /* bytes transferred or error number */ - -/* Names of fields for copy message to SYSTASK. */ -#define SRC_SPACE m5_c1 /* T or D space (stack is also D) */ -#define SRC_PROC_NR m5_i1 /* process to copy from */ -#define SRC_BUFFER m5_l1 /* virtual address where data come from */ -#define DST_SPACE m5_c2 /* T or D space (stack is also D) */ -#define DST_PROC_NR m5_i2 /* process to copy to */ -#define DST_BUFFER m5_l2 /* virtual address where data go to */ -#define COPY_BYTES m5_l3 /* number of bytes to copy */ - -/* Field names for accounting, SYSTASK and miscellaneous. */ -#define USER_TIME m4_l1 /* user time consumed by process */ -#define SYSTEM_TIME m4_l2 /* system time consumed by process */ -#define CHILD_UTIME m4_l3 /* user time consumed by process' children */ -#define CHILD_STIME m4_l4 /* sys time consumed by process' children */ - -#define PROC1 m1_i1 /* indicates a process */ -#define PROC2 m1_i2 /* indicates a process */ -#define PID m1_i3 /* process id passed from MM to kernel */ -#define STACK_PTR m1_p1 /* used for stack ptr in sys_exec, sys_getsp */ -#define PR m6_i1 /* process number for sys_sig */ -#define SIGNUM m6_i2 /* signal number for sys_sig */ -#define FUNC m6_f1 /* function pointer for sys_sig */ -#define MEM_PTR m1_p1 /* tells where memory map is for sys_newmap */ -#define CANCEL 0 /* general request to force a task to cancel */ -#define SIG_MAP m1_i2 /* used by kernel for passing signal bit map */ - -#ifdef AMOEBA - -/* Names of message fields for amoeba tasks */ -#define AM_OP m2_i1 /* one of the above operators */ -#define AM_PROC_NR m2_i2 /* process # of proc doing operation */ -#define AM_COUNT m2_i3 /* size of buffer for operation */ -#define AM_ADDRESS m2_p1 /* address of buffer for operation */ - -/* For communication between MM and AMOEBA_CLASS kernel tasks */ -#define AM_STATUS m2_i3 /* same use as REP_STATUS but for amoeba */ -#define AM_FREE_IT m2_l1 /* 1=not a getreq, 0=is a getreq */ - -/* Special for passing a physical address from the ethernet driver */ -#define AM_PADDR m2_l1 /* to the transaction layer */ - -#endif /* AMOEBA */ - -#define HARD_INT 2 /* fcn code for all hardware interrupts */ diff --git a/lib/minix/include/minix/const.h b/lib/minix/include/minix/const.h deleted file mode 100644 index 7e8176fb65..0000000000 --- a/lib/minix/include/minix/const.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 1990 by Prentice-Hall, Inc. Permission is hereby granted - * to redistribute the binary and source programs of this system for - * educational or research purposes. For other use, written permission from - * Prentice-Hall is required. - */ - -#define EXTERN extern /* used in *.h files */ -#define static static /* static x limits the scope of x */ -#define PUBLIC /* PUBLIC is the opposite of static */ -#define FORWARD static /* some compilers require this to be 'static'*/ - -#define TRUE 1 /* used for turning integers into Booleans */ -#define FALSE 0 /* used for turning integers into Booleans */ - -#define HZ 60 /* clock freq (software settable on IBM-PC) */ -#define BLOCK_SIZE 1024 /* # bytes in a disk block */ -#define SUPER_USER (uid_t) 0 /* uid_t of superuser */ - -#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */ -#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */ - -#ifdef AM_KERNEL -#define NR_TASKS 14 /* must be 5 more than without amoeba */ -#else -#define NR_TASKS 9 /* number of tasks in the transfer vector */ -#endif - -#define NR_PROCS 32 /* number of slots in proc table */ -#define NR_SEGS 3 /* # segments per process */ -#define T 0 /* proc[i].mem_map[T] is for text */ -#define D 1 /* proc[i].mem_map[D] is for data */ -#define S 2 /* proc[i].mem_map[S] is for stack */ - -#define MAX_P_LONG 2147483647 /* maximum positive long, i.e. 2**31 - 1 */ - -/* Memory is allocated in clicks. */ -#if (CHIP == INTEL) || (CHIP == M68000) -#define CLICK_SIZE 256 /* unit in which memory is allocated */ -#define CLICK_SHIFT 8 /* log2 of CLICK_SIZE */ -#endif - -#define click_to_round_k(n) \ - ((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024)) -#if CLICK_SIZE < 1024 -#define k_to_click(n) ((n) * (1024 / CLICK_SIZE)) -#else -#define k_to_click(n) ((n) / (CLICK_SIZE / 1024)) -#endif - -/* Process numbers of some important processes */ -#define MM_PROC_NR 0 /* process number of memory manager */ -#define FS_PROC_NR 1 /* process number of file system */ -#define INIT_PROC_NR 2 /* init -- the process that goes multiuser */ -#define LOW_USER 2 /* first user not part of operating system */ - -/* Miscellaneous */ -#define BYTE 0377 /* mask for 8 bits */ -#define TO_USER 0 /* flag telling to copy from fs to user */ -#define FROM_USER 1 /* flag telling to copy from user to fs */ -#define READING 0 /* copy data to user */ -#define WRITING 1 /* copy data from user */ - -#if (MACHINE != ATARI) -#define ABS -999 /* this process means absolute memory */ -#endif - -#define WORD_SIZE 2 /* number of bytes per word */ - -#define NIL_PTR (char *) 0 /* generally useful expression */ - -#define NO_NUM 0x8000 /* used as numerical argument to panic() */ -#define SIG_PUSH_BYTES (4*sizeof(int)) /* how many bytes pushed by signal */ - -/* Flag bits for i_mode in the inode. */ -#define I_TYPE 0170000 /* this field gives inode type */ -#define I_REGULAR 0100000 /* regular file, not dir or special */ -#define I_BLOCK_SPECIAL 0060000 /* block special file */ -#define I_DIRECTORY 0040000 /* file is a directory */ -#define I_CHAR_SPECIAL 0020000 /* character special file */ -#define I_NAMED_PIPE 0010000 /* named pipe (FIFO) */ -#define I_SET_UID_BIT 0004000 /* set effective uid_t on exec */ -#define I_SET_GID_BIT 0002000 /* set effective gid_t on exec */ -#define ALL_MODES 0006777 /* all bits for user, group and others */ -#define RWX_MODES 0000777 /* mode bits for RWX only */ -#define R_BIT 0000004 /* Rwx protection bit */ -#define W_BIT 0000002 /* rWx protection bit */ -#define X_BIT 0000001 /* rwX protection bit */ -#define I_NOT_ALLOC 0000000 /* this inode is free */ diff --git a/lib/minix/include/minix/type.h b/lib/minix/include/minix/type.h deleted file mode 100644 index 0669cecae1..0000000000 --- a/lib/minix/include/minix/type.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef _TYPE_H -#define _TYPE_H -/* Macros */ -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - -/* Type definitions */ -typedef unsigned short unshort; /* must be 16-bit unsigned */ -typedef unshort block_nr; /* block number */ -typedef unshort zone_nr; /* zone number */ - -#define MAX_BLOCK_NR ((block_nr) 0177777) /* largest block number */ -#define HIGHEST_ZONE ((zone_nr) 0177777) /* largest zone number */ -#define MAX_INODE_NR ((ino_t 0177777) /* largest inode number */ -#define MAX_FILE_POS 017777777777L /* largest legal file offset */ - -#define NO_BLOCK ((block_nr) 0) /* absence of a block number */ -#define NO_ENTRY ((ino_t) 0) /* absence of a dir entry */ -#define NO_ZONE ((zone_nr) 0) /* absence of a zone number */ -#define NO_DEV ((dev_t) ~0) /* absence of a device numb */ - -typedef unshort bit_nr; /* if ino_t & zone_nr both unshort, - then also unshort, else long */ -typedef long zone_type; /* zone size */ - -#if (CHIP == INTEL) -typedef unsigned vir_bytes; /* virtual addresses and lengths in bytes */ -#endif - -#if (CHIP == M68000) -typedef long vir_bytes; /* virtual addresses and lengths in bytes */ -#endif - -typedef unsigned vir_clicks; /* virtual addresses and lengths in clicks */ -typedef long phys_bytes; /* physical addresses and lengths in bytes */ -typedef unsigned phys_clicks; /* physical addresses and lengths in clicks */ -typedef int signed_clicks; /* same length as phys_clicks, but signed */ - -/* Types relating to messages. */ -#define M1 1 -#define M3 3 -#define M4 4 -#define M3_STRING 14 - -typedef struct {int m1i1, m1i2, m1i3; char *m1p1, *m1p2, *m1p3;} mess_1; -typedef struct {int m2i1, m2i2, m2i3; long m2l1, m2l2; char *m2p1;} mess_2; -typedef struct {int m3i1, m3i2; char *m3p1; char m3ca1[M3_STRING];} mess_3; -typedef struct {long m4l1, m4l2, m4l3, m4l4;} mess_4; -typedef struct {char m5c1, m5c2; int m5i1, m5i2; long m5l1, m5l2, m5l3;} mess_5; -#if _ANSI -typedef struct {int m6i1, m6i2, m6i3; long m6l1; void (*m6f1)(int);} mess_6; -#else -typedef struct {int m6i1, m6i2, m6i3; long m6l1; void (*m6f1)();} mess_6; -#endif - -typedef struct { - int m_source; /* who sent the message */ - int m_type; /* what kind of message is it */ - union { - mess_1 m_m1; - mess_2 m_m2; - mess_3 m_m3; - mess_4 m_m4; - mess_5 m_m5; - mess_6 m_m6; - } m_u; -} message; - -#define MESS_SIZE (sizeof(message)) -#define NIL_MESS (message *) 0 - -/* The following defines provide names for useful members. */ -#define m1_i1 m_u.m_m1.m1i1 -#define m1_i2 m_u.m_m1.m1i2 -#define m1_i3 m_u.m_m1.m1i3 -#define m1_p1 m_u.m_m1.m1p1 -#define m1_p2 m_u.m_m1.m1p2 -#define m1_p3 m_u.m_m1.m1p3 - -#define m2_i1 m_u.m_m2.m2i1 -#define m2_i2 m_u.m_m2.m2i2 -#define m2_i3 m_u.m_m2.m2i3 -#define m2_l1 m_u.m_m2.m2l1 -#define m2_l2 m_u.m_m2.m2l2 -#define m2_p1 m_u.m_m2.m2p1 - -#define m3_i1 m_u.m_m3.m3i1 -#define m3_i2 m_u.m_m3.m3i2 -#define m3_p1 m_u.m_m3.m3p1 -#define m3_ca1 m_u.m_m3.m3ca1 - - -#define m4_l1 m_u.m_m4.m4l1 -#define m4_l2 m_u.m_m4.m4l2 -#define m4_l3 m_u.m_m4.m4l3 -#define m4_l4 m_u.m_m4.m4l4 - -#define m5_c1 m_u.m_m5.m5c1 -#define m5_c2 m_u.m_m5.m5c2 -#define m5_i1 m_u.m_m5.m5i1 -#define m5_i2 m_u.m_m5.m5i2 -#define m5_l1 m_u.m_m5.m5l1 -#define m5_l2 m_u.m_m5.m5l2 -#define m5_l3 m_u.m_m5.m5l3 - -#define m6_i1 m_u.m_m6.m6i1 -#define m6_i2 m_u.m_m6.m6i2 -#define m6_i3 m_u.m_m6.m6i3 -#define m6_l1 m_u.m_m6.m6l1 -#define m6_f1 m_u.m_m6.m6f1 - -struct mem_map { - vir_clicks mem_vir; /* virtual address */ - phys_clicks mem_phys; /* physical address */ - vir_clicks mem_len; /* length */ -}; - -struct copy_info { /* used by sys_copy(src, dst, bytes) */ - int cp_src_proc; - int cp_src_space; - vir_bytes cp_src_vir; - int cp_dst_proc; - int cp_dst_space; - vir_bytes cp_dst_vir; - vir_bytes cp_bytes; -}; - -struct iorequest_s { - long io_position; /* position in device file (really off_t) */ - char *io_buf; /* buffer in user space */ - unsigned short io_nbytes; /* size of request */ - unsigned short io_request; /* read, write (optionally) */ -}; -#endif /* _TYPE_H */ diff --git a/lib/minix/include/sgtty.h b/lib/minix/include/sgtty.h deleted file mode 100644 index eea80cc362..0000000000 --- a/lib/minix/include/sgtty.h +++ /dev/null @@ -1,96 +0,0 @@ -/* The header contains data structures for ioctl(). */ - -#ifndef _SGTTY_H -#define _SGTTY_H - -struct sgttyb { - char sg_ispeed; /* input speed */ - char sg_ospeed; /* output speed */ - char sg_erase; /* erase character */ - char sg_kill; /* kill character */ - int sg_flags; /* mode flags */ -}; - -struct tchars { - char t_intrc; /* SIGINT char */ - char t_quitc; /* SIGQUIT char */ - char t_startc; /* start output (initially CTRL-Q) */ - char t_stopc; /* stop output (initially CTRL-S) */ - char t_eofc; /* EOF (initially CTRL-D) */ - char t_brkc; /* input delimiter (like nl) */ -}; - -/* Field names */ -#define XTABS 0006000 /* do tab expansion */ -#define BITS8 0001400 /* 8 bits/char */ -#define BITS7 0001000 /* 7 bits/char */ -#define BITS6 0000400 /* 6 bits/char */ -#define BITS5 0000000 /* 5 bits/char */ -#define EVENP 0000200 /* even parity */ -#define ODDP 0000100 /* odd parity */ -#define RAW 0000040 /* enable raw mode */ -#define CRMOD 0000020 /* map lf to cr + lf */ -#define ECHO 0000010 /* echo input */ -#define CBREAK 0000002 /* enable cbreak mode */ -#define COOKED 0000000 /* neither CBREAK nor RAW */ - -#define DCD 0100000 /* Data Carrier Detect */ - -/* Line speeds */ -#define B0 0 /* code for line-hangup */ -#define B110 1 -#define B300 3 -#define B1200 12 -#define B2400 24 -#define B4800 48 -#define B9600 96 - -#define TIOCGETP (('t'<<8) | 8) -#define TIOCSETP (('t'<<8) | 9) -#define TIOCGETC (('t'<<8) | 18) -#define TIOCSETC (('t'<<8) | 17) -#define TIOCFLUSH (('t'<<8) | 16) - -/* Things Minix supports but not properly */ -/* the divide-by-100 encoding ain't too hot */ -#define ANYP 0000300 -#define B50 0 -#define B75 0 -#define B134 0 -#define B150 0 -#define B200 2 -#define B600 6 -#define B1800 18 -#define B3600 36 -#define B7200 72 -#define EXTA 192 -#define EXTB 0 - -/* Things Minix doesn't support but are fairly harmless if used */ -#define NLDELAY 0001400 -#define TBDELAY 0006000 -#define CRDELAY 0030000 -#define VTDELAY 0040000 -#define BSDELAY 0100000 -#define ALLDELAY 0177400 - -#if MACHINE == ATARI -/* ST specific clock stuff */ - -#define DCLOCK ('D'<<8) - -#define DC_RBMS100 (DCLOCK|1) -#define DC_RBMS200 (DCLOCK|2) -#define DC_RSUPRA (DCLOCK|3) -#define DC_RICD (DCLOCK|4) -#define DC_WBMS100 (DCLOCK|8) -#define DC_WBMS200 (DCLOCK|9) -#endif - -#include - -_PROTOTYPE( int gtty, (int _fd, struct sgttyb *_argp) ); -_PROTOTYPE( int ioctl, (int _fd, int _request, struct sgttyb *_argp) ); -_PROTOTYPE( int stty, (int _fd, struct sgttyb *_argp) ); - -#endif /* _SGTTY_H */ diff --git a/lib/minix/include/signal.h b/lib/minix/include/signal.h deleted file mode 100644 index 1fd850a870..0000000000 --- a/lib/minix/include/signal.h +++ /dev/null @@ -1,115 +0,0 @@ -/* The header defines all the ANSI and POSIX signals. - * MINIX supports all the signals required by POSIX. They are defined below. - * Some additional signals are also supported. - */ - -#ifndef _SIGNAL_H -#define _SIGNAL_H - -/* Here are types that are closely associated with signal handling. */ -typedef int sig_atomic_t; - -#ifdef _POSIX_SOURCE -typedef unsigned short sigset_t; -#endif - - -#define _NSIG 16 /* number of signals used */ - -#define SIGHUP 1 /* hangup */ -#define SIGINT 2 /* interrupt (DEL) */ -#define SIGQUIT 3 /* quit (ASCII FS) */ -#define SIGILL 4 /* illegal instruction */ -#define SIGTRAP 5 /* trace trap (not reset when caught) */ -#define SIGABRT 6 /* IOT instruction */ -#define SIGIOT 6 /* SIGABRT for people who speak PDP-11 */ -#define SIGUNUSED 7 /* spare code */ -#define SIGFPE 8 /* floating point exception */ -#define SIGKILL 9 /* kill (cannot be caught or ignored) */ -#define SIGUSR1 10 /* user defined signal # 1 */ -#define SIGSEGV 11 /* segmentation violation */ -#define SIGUSR2 12 /* user defined signal # 2 */ -#define SIGSYS 12 /* the usual UNIX name for this signal num */ -#define SIGPIPE 13 /* write on a pipe with no one to read it */ -#define SIGALRM 14 /* alarm clock */ -#define SIGTERM 15 /* software termination signal from kill */ -#define SIGSTKFLT 16 /* used by kernel to indicate stack fault */ - -#define SIGEMT 7 /* obsolete */ -#define SIGBUS 10 /* obsolete */ - -/* POSIX requires the following signals to be defined, even if they are - * not supported. Here are the definitions, but they are not supported. - */ -#define SIGCHLD 17 /* child process terminated or stopped */ -#define SIGCONT 18 /* continue if stopped */ -#define SIGSTOP 19 /* stop signal */ -#define SIGTSTP 20 /* interactive stop signal */ -#define SIGTTIN 21 /* background process wants to read */ -#define SIGTTOU 22 /* background process wants to write */ - -#ifdef _POSIX_SOURCE -#define SA_NOCLDSTOP 1 /* signal parent if child stops */ - -#endif /* _POSIX_SOURCE */ - -/* POSIX requires these values for use on system calls involving signals. */ -#define SIG_BLOCK 0 /* for blocking signals */ -#define SIG_UNBLOCK 1 /* for unblocking signals */ -#define SIG_SETMASK 2 /* for setting the signal mask */ - -#ifndef _ANSI_H -#include -#endif - -/* Macros used as function pointers and one awful prototype. */ -#if _ANSI -#define SIG_DFL ((void (*)(int))0) /* default signal handling */ -#define SIG_IGN ((void (*)(int))1) /* ignore signal */ -#define SIG_ERR ((void (*)(int))-1) - -void (*signal(int _sig, void (*_func)(int)))(int); - -#ifdef _POSIX_SOURCE -struct sigaction { - void (*sa_handler)(int); /* SIG_DFL, SIG_IGN, or pointer to function */ - sigset_t sa_mask; /* signals to be blocked during handler */ - int sa_flags; /* special flags */ -}; -#endif - -#else /* !_ANSI */ -#define SIG_DFL ((void (*)())0) /* default signal handling */ -#define SIG_IGN ((void (*)())1) /* ignore signal */ -#define SIG_ERR ((void (*)())-1) - -void (*signal()) (); - -#ifdef _POSIX_SOURCE /* otherwise sigset_t is not defined */ -struct sigaction { - void (*sa_handler)(); /* SIG_DFL, SIG_IGN, or pointer to function */ - sigset_t sa_mask; /* signals to be blocked during handler */ - int sa_flags; /* special flags */ -}; -#endif - -#endif /* _ANSI */ - -/* Function Prototypes. */ -_PROTOTYPE( int raise, (int _sig) ); - -#ifdef _POSIX_SOURCE -_PROTOTYPE( int kill, (pid_t _pid, int _sig) ); -_PROTOTYPE( int sigaddset, (sigset_t *_set) ); -_PROTOTYPE( int sigdelset, (sigset_t *_set) ); -_PROTOTYPE( int sigemptyset, (sigset_t *_set) ); -_PROTOTYPE( int sigfillset, (sigset_t *_set) ); -_PROTOTYPE( int sigismember, (sigset_t *_set, int _signo) ); -_PROTOTYPE( int sigpending, (sigset_t *set) ); -_PROTOTYPE( int sigprocmask, (int _how, sigset_t *_set, sigset_t *_oset)); -_PROTOTYPE( int sigsuspend, (sigset_t *_sigmask) ); -_PROTOTYPE( int sigaction, - (int _sig, struct sigaction *_a, struct sigaction *_oact) ); -#endif - -#endif /* _SIGNAL_H */ diff --git a/lib/minix/include/string.h b/lib/minix/include/string.h deleted file mode 100644 index caff01c6c6..0000000000 --- a/lib/minix/include/string.h +++ /dev/null @@ -1,57 +0,0 @@ -/* The header contains prototypes for the string handling - * functions. - */ - -#ifndef _STRING_H -#define _STRING_H - -#ifndef NULL -#define NULL ((void *)0) -#endif - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; /* type returned by sizeof */ -#endif /*_SIZE_T */ - -/* Function Prototypes. */ -#ifndef _ANSI_H -#include -#endif - -_PROTOTYPE( void *memcpy, (void *_s1, const void *_s2, size_t _n) ); -_PROTOTYPE( void *memmove, (void *_s1, const void *_s2, size_t _n) ); -_PROTOTYPE( char *strcpy, (char *_s1, const char *_s2) ); -_PROTOTYPE( char *strncpy, (char *_s1, const char *_s2, size_t _n) ); -_PROTOTYPE( char *strcat, (char *_s1, const char *_s2) ); -_PROTOTYPE( char *strncat, (char *_s1, const char *_s2, size_t _n) ); -_PROTOTYPE( int memcmp, (const void *_s1, const void *_s2, size_t _n) ); -_PROTOTYPE( int strcmp, (const char *_s1, const char *_s2) ); -_PROTOTYPE( int strcoll, (const char *_s1, const char *_s2) ); -_PROTOTYPE( int strncmp, (const char *_s1, const char *_s2, size_t _n) ); -_PROTOTYPE( size_t strxfrm, (char *_s1, const char *_s2, size_t _n) ); -_PROTOTYPE( void *memchr, (const void *_s, int _c, size_t _n) ); -_PROTOTYPE( char *strchr, (const char *_s, int _c) ); -_PROTOTYPE( size_t strcspn, (const char *_s1, const char *_s2) ); -_PROTOTYPE( char *strpbrk, (const char *_s1, const char *_s2) ); -_PROTOTYPE( char *strrchr, (const char *_s, int _c) ); -_PROTOTYPE( size_t strspn, (const char *_s1, const char *_s2) ); -_PROTOTYPE( char *strstr, (const char *_s1, const char *_s2) ); -_PROTOTYPE( char *strtok, (char *_s1, const char *_s2) ); -_PROTOTYPE( void *memset, (void *_s, int _c, size_t _n) ); -_PROTOTYPE( char *strerror, ( int _errnum) ); -_PROTOTYPE( size_t strlen, (const char *_s) ); - -#ifdef _MINIX -/* For backward compatibility. */ -_PROTOTYPE( char *index, (const char *_s, int _charwanted) ); -_PROTOTYPE( char *rindex, (const char *_s, int _charwanted) ); -_PROTOTYPE( void bcopy, (const char *_src, char *_dst, int _length) ); -_PROTOTYPE( int bcmp, (const char *_s1, const char *_s2, int _length) ); -_PROTOTYPE( void bzero, (char *_dst, int _length) ); -_PROTOTYPE( void *memccpy, (char *_dst, const char *_src, int _ucharstop, - size_t _size) ); - -#endif - -#endif /* _STRING_H */ diff --git a/lib/minix/include/sys/errno.h b/lib/minix/include/sys/errno.h deleted file mode 100644 index 9092ffb8cf..0000000000 --- a/lib/minix/include/sys/errno.h +++ /dev/null @@ -1,96 +0,0 @@ -/* The header defines the numbers of the various errors that can - * occur during program execution. They are visible to user programs and - * should be small positive integers. However, they are also used within - * MINIX, where they must be negative. For example, the READ system call is - * executed internally by calling do_read(). This function returns either a - * (negative) error number or a (positive) number of bytes actually read. - * - * To solve the problem of having the error numbers be negative inside the - * the system and positive outside, the following mechanism is used. All the - * definitions are are the form: - * - * #define EPERM (_SIGN 1) - * - * If the macro _SYSTEM is defined, then _SIGN is set to "-", otherwise it is - * set to "". Thus when compiling the operating system, the macro _SYSTEM - * will be defined, setting EPERM to (- 1), whereas when when this - * file is included in an ordinary user program, EPERM has the value ( 1). - */ - -#ifndef _ERRNO_H /* check if is already included */ -#define _ERRNO_H /* it is not included; note that fact */ - -/* Now define _SIGN as "" or "-" depending on _SYSTEM. */ -#ifdef _SYSTEM -# define _SIGN - -# define OK 0 -#else -# define _SIGN -#endif - -extern int errno; /* place where the error numbers go */ - -/* Here are the numerical values of the error numbers. */ -#define _NERROR 39 /* number of errors */ - -#define ERROR (_SIGN 99) /* generic error */ -#define EPERM (_SIGN 1) /* operation not permitted */ -#define ENOENT (_SIGN 2) /* no such file or directory */ -#define ESRCH (_SIGN 3) /* no such process */ -#define EINTR (_SIGN 4) /* interrupted function call */ -#define EIO (_SIGN 5) /* input/output error */ -#define ENXIO (_SIGN 6) /* no such device or address */ -#define E2BIG (_SIGN 7) /* arg list too long */ -#define ENOEXEC (_SIGN 8) /* exec format error */ -#define EBADF (_SIGN 9) /* bad file descriptor */ -#define ECHILD (_SIGN 10) /* no child process */ -#define EAGAIN (_SIGN 11) /* resource temporarily unavailable */ -#define ENOMEM (_SIGN 12) /* not enough space */ -#define EACCES (_SIGN 13) /* permission denied */ -#define EFAULT (_SIGN 14) /* bad address */ -#define ENOTBLK (_SIGN 15) /* Extension: not a block special file */ -#define EBUSY (_SIGN 16) /* resource busy */ -#define EEXIST (_SIGN 17) /* file exists */ -#define EXDEV (_SIGN 18) /* improper link */ -#define ENODEV (_SIGN 19) /* no such device */ -#define ENOTDIR (_SIGN 20) /* not a directory */ -#define EISDIR (_SIGN 21) /* is a directory */ -#define EINVAL (_SIGN 22) /* invalid argument */ -#define ENFILE (_SIGN 23) /* too many open files in system */ -#define EMFILE (_SIGN 24) /* too many open files */ -#define ENOTTY (_SIGN 25) /* inappropriate I/O control operation */ -#define ETXTBSY (_SIGN 26) /* no longer used */ -#define EFBIG (_SIGN 27) /* file too large */ -#define ENOSPC (_SIGN 28) /* no space left on device */ -#define ESPIPE (_SIGN 29) /* invalid seek */ -#define EROFS (_SIGN 30) /* read-only file system */ -#define EMLINK (_SIGN 31) /* too many links */ -#define EPIPE (_SIGN 32) /* broken pipe */ -#define EDOM (_SIGN 33) /* domain error (from ANSI C std) */ -#define ERANGE (_SIGN 34) /* result too large (from ANSI C std) */ -#define EDEADLK (_SIGN 35) /* resource deadlock avoided */ -#define ENAMETOOLONG (_SIGN 36) /* file name too long */ -#define ENOLCK (_SIGN 37) /* no locks available */ -#define ENOSYS (_SIGN 38) /* function not implemented */ -#define ENOTEMPTY (_SIGN 39) /* directory not empty */ - -/* The following are not POSIX errors, but they can still happen. */ -#define ELOCKED (_SIGN 101) /* can't send message */ -#define EBADCALL (_SIGN 102) /* error on send/receive */ - -/* The following error codes are generated by the kernel itself. */ -#ifdef _SYSTEM -#define E_BAD_DEST -1 /* destination address illegal */ -#define E_BAD_SRC -2 /* source address illegal */ -#define E_TRY_AGAIN -3 /* can't send-- tables full */ -#define E_OVERRUN -4 /* interrupt for task that is not waiting */ -#define E_BAD_BUF -5 /* message buf outside caller's addr space */ -#define E_TASK -6 /* can't send to task */ -#define E_NO_MESSAGE -7 /* RECEIVE failed: no message present */ -#define E_NO_PERM -8 /* ordinary users can't send to tasks */ -#define E_BAD_FCN -9 /* only valid fcns are SEND, RECEIVE, BOTH */ -#define E_BAD_ADDR -10 /* bad address given to utility routine */ -#define E_BAD_PROC -11 /* bad proc number given to utility */ -#endif /* _SYSTEM */ - -#endif /* _ERRNO_H */ diff --git a/lib/minix/include/sys/stat.h b/lib/minix/include/sys/stat.h deleted file mode 100644 index 66eff368ef..0000000000 --- a/lib/minix/include/sys/stat.h +++ /dev/null @@ -1,74 +0,0 @@ -/* The header defines a struct that is used in the stat() and - * fstat functions. The information in this struct comes from the i-node of - * some file. These calls are the only approved way to inspect i-nodes. - */ - -#ifndef _STAT_H -#define _STAT_H - -struct stat { - dev_t st_dev; /* major/minor device number */ - ino_t st_ino; /* i-node number */ - mode_t st_mode; /* file mode, protection bits, etc. */ - short int st_nlink; /* # links; TEMPORARY HACK: should be nlink_t*/ - uid_t st_uid; /* uid of the file's owner */ - short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */ - dev_t st_rdev; - off_t st_size; /* file size */ - time_t st_atime; /* time of last access */ - time_t st_mtime; /* time of last data modification */ - time_t st_ctime; /* time of last file status change */ -}; - -/* Traditional mask definitions for st_mode. */ -/* The ugly casts on only some of the definitions are to avoid suprising sign - * extensions such as S_IFREG != (mode_t) S_IFREG when ints are 32 bits. - */ -#define S_IFMT ((mode_t) 0170000) /* type of file */ -#define S_IFREG ((mode_t) 0100000) /* regular */ -#define S_IFBLK 0060000 /* block special */ -#define S_IFDIR 0040000 /* directory */ -#define S_IFCHR 0020000 /* character special */ -#define S_IFIFO 0010000 /* this is a FIFO */ -#define S_ISUID 0004000 /* set user id on execution */ -#define S_ISGID 0002000 /* set group id on execution */ - /* next is reserved for future use */ -#define S_ISVTX 01000 /* save swapped text even after use */ - -/* POSIX masks for st_mode. */ -#define S_IRWXU 00700 /* owner: rwx------ */ -#define S_IRUSR 00400 /* owner: r-------- */ -#define S_IWUSR 00200 /* owner: -w------- */ -#define S_IXUSR 00100 /* owner: --x------ */ - -#define S_IRWXG 00070 /* group: ---rwx--- */ -#define S_IRGRP 00040 /* group: ---r----- */ -#define S_IWGRP 00020 /* group: ----w---- */ -#define S_IXGRP 00010 /* group: -----x--- */ - -#define S_IRWXO 00007 /* others: ------rwx */ -#define S_IROTH 00004 /* others: ------r-- */ -#define S_IWOTH 00002 /* others: -------w- */ -#define S_IXOTH 00001 /* others: --------x */ - -/* The following macros test st_mode (from POSIX Sec. 5.6.1.1). */ -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* is a reg file */ -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* is a directory */ -#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* is a char spec */ -#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) /* is a block spec */ -#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* is a pipe/FIFO */ - - -/* Function Prototypes. */ -#ifndef _ANSI_H -#include -#endif - -_PROTOTYPE( int chmod, (const char *_path, Mode_t _mode) ); -_PROTOTYPE( int fstat, (int _fildes, struct stat *_buf) ); -_PROTOTYPE( int mkdir, (const char *_path, int _mode) ); -_PROTOTYPE( int mkfifo, (const char *_path, int _mode) ); -_PROTOTYPE( int stat , (const char *_path, struct stat *_buf) ); -_PROTOTYPE( mode_t umask, (int _cmask) ); - -#endif /* _STAT_H */ diff --git a/lib/minix/include/sys/types.h b/lib/minix/include/sys/types.h index f0f4285d0a..8cc8be770c 100644 --- a/lib/minix/include/sys/types.h +++ b/lib/minix/include/sys/types.h @@ -7,15 +7,7 @@ #ifndef _TYPES_H #define _TYPES_H -/* The type size_t holds the result of the size_of operator. This type is - * 'unsigned int', in order to be compatible with the old library (f.i. the - * argument of malloc was an unsigned int, and is now a size_t). This means - * that a 70K array can not be allocated. - */ -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; /* type returned by sizeof */ -#endif +#include #ifndef _TIME_T #define _TIME_T @@ -41,7 +33,6 @@ typedef char gid_t; /* group id */ typedef unsigned short ino_t; /* i-node number */ typedef short mode_t; /* mode number within an i-node */ typedef char nlink_t; /* number-of-links field within an i-node */ -typedef long off_t; /* offsets within a file */ typedef int pid_t; /* type for pids (must be signed) */ typedef short uid_t; /* user id */ typedef long zone_t; /* holds a zone number */ diff --git a/lib/minix/include/sys/wait.h b/lib/minix/include/sys/wait.h deleted file mode 100644 index d22796176c..0000000000 --- a/lib/minix/include/sys/wait.h +++ /dev/null @@ -1,40 +0,0 @@ -/* The header contains macros related to wait(). The value - * returned by wait() and waitpid() depends on whether the process - * terminated by an exit() call, was killed by a signal, or was stopped - * due to job control, as follows: - * - * High byte Low byte - * +---------------------+ - * exit(status) | status | 0 | - * +---------------------+ - * killed by signal | 0 | signal | - * +---------------------+ - * stopped (job control) | signal | 0177 | - * +---------------------+ - */ - -#ifndef _WAIT_H -#define _WAIT_H - -#define _LOW(v) ( (v) & 0377) -#define _HIGH(v) ( ((v) >> 8) & 0377) - -#define WNOHANG 1 /* do not wait for child to exit */ -#define WUNTRACED 2 /* for job control; not implemented */ - -#define WIFEXITED(s) (_LOW(s) == 0) /* normal exit */ -#define WEXITSTATUS(s) (_HIGH(s)) /* exit status */ -#define WTERMSIG(s) (_LOW(s) & 0177) /* sig value */ -#define WIFSIGNALED(s) (((unsigned int)(s)-1 & 0xFFFF) < 0xFF) /* signaled */ -#define WIFSTOPPED(s) (_LOW(s) == 0177) /* stopped */ -#define WSTOPSIG(s) (_HIGH(s) & 0377) /* stop signal */ - -/* Function Prototypes. */ -#ifndef _ANSI_H -#include -#endif - -_PROTOTYPE( pid_t wait, (int *_stat_loc) ); -_PROTOTYPE( pid_t waitpid, (pid_t _pid, int *_stat_loc, int _options) ); - -#endif /* _WAIT_H */ diff --git a/lib/minix/include/time.h b/lib/minix/include/time.h index fe2b5b70ae..2db1d4a27f 100644 --- a/lib/minix/include/time.h +++ b/lib/minix/include/time.h @@ -9,18 +9,14 @@ #ifndef _TIME_H #define _TIME_H +#include +#include + #define CLOCKS_PER_SEC 60 /* MINIX always uses 60 Hz, even in Europe */ #ifdef _POSIX_SOURCE #define CLK_TCK CLOCKS_PER_SEC #endif -#define NULL ((void *)0) - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; /* type returned by sizeof */ -#endif - #ifndef _TIME_T #define _TIME_T typedef long time_t; /* time in sec since 1 Jan 1970 0000 GMT */ diff --git a/lib/minix/include/unistd.h b/lib/minix/include/unistd.h index 6499de8bd4..1da63178bd 100644 --- a/lib/minix/include/unistd.h +++ b/lib/minix/include/unistd.h @@ -3,6 +3,11 @@ #ifndef _UNISTD_H #define _UNISTD_H +#include +#include + +extern char** environ; + /* Values used by access(). POSIX Table 2-6. */ #define F_OK 0 /* test if file exists */ #define X_OK 1 /* test if file is executable */ @@ -22,9 +27,6 @@ #define STDOUT_FILENO 1 /* file descriptor for stdout */ #define STDERR_FILENO 2 /* file descriptor for stderr */ -/* NULL must be defined in according to POSIX Sec. 2.8.1. */ -#define NULL ((void *)0) - /* The following relate to configurable system variables. POSIX Table 4-2. */ #define _SC_ARG_MAX 1 #define _SC_CHILD_MAX 2 @@ -112,7 +114,6 @@ _PROTOTYPE( char *ttyname, (int _fd) ); _PROTOTYPE( int unlink, (const char *_path) ); _PROTOTYPE( int write, (int _fd, char *_buf, unsigned int _n) ); -#ifdef _MINIX _PROTOTYPE( char *brk, (char *_addr) ); _PROTOTYPE( int mknod, (const char *_name, int _mode, int _addr) ); _PROTOTYPE( int mknod4, (const char *_name, int _mode, int _addr, @@ -125,6 +126,5 @@ _PROTOTYPE( long ptrace, (int _req, int _pid, long _addr, long _data) ); _PROTOTYPE( int stime, (long *top) ); _PROTOTYPE( int sync, (void) ); _PROTOTYPE( int umount, (const char *_name) ); -#endif #endif /* _UNISTD_H */ diff --git a/lib/minix/include/utime.h b/lib/minix/include/utime.h deleted file mode 100644 index 4be0989474..0000000000 --- a/lib/minix/include/utime.h +++ /dev/null @@ -1,19 +0,0 @@ -/* The header is used for the utime() system call. */ - -#ifndef _UTIME_H -#define _UTIME_H - -struct utimbuf { - time_t actime; /* access time */ - time_t modtime; /* modification time */ -}; - - -/* Function Prototypes. */ -#ifndef _ANSI_H -#include -#endif - -_PROTOTYPE( int utime, (char *_path, struct utimbuf *_times) ); - -#endif /* _UTIME_H */ diff --git a/lib/minixST/descr b/lib/minixST/descr deleted file mode 100644 index e9326714df..0000000000 --- a/lib/minixST/descr +++ /dev/null @@ -1,66 +0,0 @@ -# $Revision$ -var w=2 -var p=4 -var s=2 -var l=4 -var f=4 -var d=8 -var NAME=minixST -var M=m68k2 -var MLIB=lib/{M}/tail_ -var RT=lib/minixST/head_ -var LIB=lib/minixST/tail_ -var CPP_F=-D__unix -D_ATARI_ST -var SYSINCLUDES=-I{EM}/lib/minixST/include -I{EM}/lib/minix/include -var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -var C_LIB={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g -var OLD_C_LIB={C_LIB} -var MACHOPT_F=-ml10 -name be - from .m.g - to .s - program {EM}/lib.bin/{M}/cg - mapflag -gdb GF=-gdb - args {GF?} < - stdout - need .e -end -name as - from .s.so - to .o - program {EM}/lib.bin/{M}/as - args - -o > < - prep cond -end -name led - from .o.a - to .out - program {EM}/lib.bin/em_led - mapflag -l* LNAME={EM}/{LIB}* -# mapflag -i SEPID=-b1:0 - mapflag -fp LIBFP={EM}/{NLIB}fp - mapflag -ansi C_LIB={EM}/{LIB}ac - args {ALIGN} {SEPID?} -c (.e:{HEAD}={EM}/{RT}em) \ - ({RTS}:.ocm.bas={EM}/{RT}cc) \ - ({RTS}{ANSI?}:.c={EM}/{RT}cc) \ - ({RTS}{ANSI?}:.cansi={EM}/{RT}ac) \ - ({RTS}:.p={EM}/{RT}pc) \ - ({RTS}:.mod={EM}/{RT}m2) \ - -o > < \ - (.p:{TAIL}={EM}/{LIB}pc) \ - (.bas:{TAIL}={EM}/{LIB}bc) \ - (.ocm:{TAIL}={EM}/{LIB}ocm) \ - (.mod:{TAIL}={EM}/{LIB}m2) \ - (.ocm.bas:{TAIL}={OLD_C_LIB}) \ - (.c:{TAIL}={C_LIB}) \ - {LIBFP?} \ - (.e:{TAIL}={EM}/{LIB}mon {EM}/{MLIB}em {EM}/lib/m68k2/end_em) - linker -end -name cv - from .out - to .cv - program {EM}/lib.bin/minixST/cv - args < > - outfile a.out -end diff --git a/mach/m68020/ncg/build.lua b/mach/m68020/ncg/build.lua index 35af754e45..f940b072d7 100644 --- a/mach/m68020/ncg/build.lua +++ b/mach/m68020/ncg/build.lua @@ -3,7 +3,7 @@ bundle { srcs = { "./mach.c", "./mach.h", - "./whichone.h" + "./instrmacs.h" } } diff --git a/mach/m68020/ncg/mach.c b/mach/m68020/ncg/mach.c index 803fba61fd..484f6c0285 100644 --- a/mach/m68020/ncg/mach.c +++ b/mach/m68020/ncg/mach.c @@ -9,7 +9,9 @@ * machine dependent back end routines for the Motorola 68000, 68010 or 68020 */ -#include +#if !defined WORD_SIZE +#error WORD_SIZE not configured +#endif #if TBL68020 #define SYNTAX_68020 1 @@ -47,7 +49,7 @@ con_part(int sz, word w) { void con_mult(word sz) { - if (sz != 8) + if ((sz != 4) && (sz != 8)) fatal("bad icon/ucon size"); fprintf(codefile,".data8\t%s\n", str); } diff --git a/mach/m68020/ncg/mach.h b/mach/m68020/ncg/mach.h index 3d37243cdf..deb1e1172b 100644 --- a/mach/m68020/ncg/mach.h +++ b/mach/m68020/ncg/mach.h @@ -3,7 +3,10 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include + +#if !defined WORD_SIZE +#error WORD_SIZE not configured +#endif #ifndef TBL68020 #ifndef TBL68000 diff --git a/mach/m68020/ncg/table b/mach/m68020/ncg/table index 03a2ed3c68..311b05b623 100644 --- a/mach/m68020/ncg/table +++ b/mach/m68020/ncg/table @@ -12,7 +12,9 @@ rscid = "$Id$" * * ********************************/ -#include "whichone.h" +#if !defined WORD_SIZE +#error WORD_SIZE not configured +#endif #if TBL68881 && ! TBL68020 Something very wrong here! @@ -680,7 +682,7 @@ ext_w "ext.w" D_REG+LOCAL+D_REG4:rw:cc cost(2,2). jmp address+control4 cost(2,0). jsr address+control4 kills :cc d0 d1 d2 a0 a1 cost(2,3). lea address+control4:ro, A_REG+areg:wo cost(2,0). -lsl_l "lsl.l" shconreg:ro, D_REG4:rw:cc cost(2,4). +lsl_l "lsl.l" shconreg:ro, D_REG:rw:cc cost(2,4). /* lsl "lsl #1," memalt2:rw:cc cost(2,4). */ @@ -3988,6 +3990,7 @@ pat sli $1==4 with shconreg DD_REG4 gen asl_l %1, %2 yields %2 +#if WORD_SIZE==4 pat sli $1==8 with DD_REG4 DD_REG4 DD_REG4 uses AA_REG = %3 /* no 4th DD_REG */ @@ -4024,6 +4027,7 @@ pat loc sli ($1&32)!=0 && $2==8 with any4 DD_REG4 uses reusing %1, DD_REG = {bconst, $1&31} gen lsl_l %a, %2 yields {zero_const, 0} %2 +#endif #if WORD_SIZE==2 pat sri $1==2 @@ -4035,6 +4039,7 @@ pat sri $1==4 with shconreg DD_REG4 gen asr_l %1, %2 yields %2 +#if WORD_SIZE==4 pat sri $1==8 with DD_REG4 DD_REG4 DD_REG4 uses AA_REG = %2 /* no 4th DD_REG */ @@ -4071,6 +4076,7 @@ pat loc sri ($1&32)!=0 && $2==8 with DD_REG4 any4 uses reusing %2, DD_REG = {bconst, $1&31} gen asr_l %a, %1 yields %1 leaving loc 4 loc 8 cii +#endif /************************************************ * Group 4: unsigned arithmetic. * @@ -4175,6 +4181,7 @@ pat sru $1==4 with shconreg DD_REG4 gen lsr_l %1, %2 yields %2 +#if WORD_SIZE==4 pat sru $1==8 with DD_REG4 DD_REG4 DD_REG4 uses AA_REG = %2 /* no 4th DD_REG */ @@ -4211,6 +4218,7 @@ pat loc sru ($1&32)!=0 && $2==8 with DD_REG4 any4 uses reusing %2, DD_REG = {bconst, $1&31} gen lsr_l %a, %1 yields %1 {zero_const, 0} +#endif /************************************************ * Group 5: floating point arithmetic * @@ -5143,6 +5151,7 @@ pat rol $1==4 with shconreg DD_REG4 gen rol_l %1, %2 yields %2 +#if WORD_SIZE==4 pat rol $1==8 with DD_REG4 DD_REG4 DD_REG4 uses AA_REG, AA_REG /* no 4th DD_REG */ @@ -5186,6 +5195,7 @@ with DD_REG4 DD_REG4 yields %2 %1 pat loc rol ($1&63)==32 && $2==8 leaving exg 4 pat loc rol ($1&32)!=0 && $2==8 leaving loc (0-$1)&31 ror 8 +#endif #if WORD_SIZE==2 pat ror $1==2 @@ -5197,6 +5207,7 @@ pat ror $1==4 with shconreg DD_REG4 gen ror_l %1, %2 yields %2 +#if WORD_SIZE==4 pat ror $1==8 with DD_REG4 DD_REG4 DD_REG4 uses AA_REG, AA_REG /* no 4th DD_REG */ @@ -5240,7 +5251,7 @@ with DD_REG4 DD_REG4 yields %2 %1 pat loc ror ($1&63)==32 && $2==8 leaving exg 4 pat loc ror ($1&32)!=0 && $2==8 leaving loc (0-$1)&31 rol 8 - +#endif @@ -6725,6 +6736,7 @@ pat cmu zge $1==WORD_SIZE call cmuzxx("bcc","bls") pat cmu zgt $1==WORD_SIZE call cmuzxx("bhi","bcs") +#if WORD_SIZE==4 proc cmx8txx example cmi tlt with exact DD_REG4 DD_REG4 any4 any4 uses reusing %3, DD_REG4 = %3 @@ -6772,6 +6784,7 @@ pat cmu zlt $1==8 call cmx8zxx("bcs","bhi") pat cmu zle $1==8 call cmx8zxx("bls","bcc") pat cmu zge $1==8 call cmx8zxx("bcc","bls") pat cmu zgt $1==8 call cmx8zxx("bhi","bcs") +#endif #if TBL68881 @@ -7013,6 +7026,7 @@ uses reusing %1,DD_REG4 pat loc loc ciu $1==$2 /* skip this */ pat loc loc cui $1==$2 /* skip this */ +#if WORD_SIZE==4 pat loc loc cii $1==4 && $2==8 with exact test_set1+test_set2 yields %1 {zero_const, 0} @@ -7039,7 +7053,7 @@ pat loc loc cii $1==8 && $2==4 leaving asp 4 pat loc loc ciu $1==8 && $2==4 leaving asp 4 pat loc loc cui $1==8 && $2==4 leaving asp 4 pat loc loc cuu $1==8 && $2==4 leaving asp 4 - +#endif /* The following rules should be handled by the peephole optimizer, I think */ diff --git a/mach/m68020/ncg/whichone.h b/mach/m68020/ncg/whichone.h deleted file mode 100644 index cc0704aef1..0000000000 --- a/mach/m68020/ncg/whichone.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ - -#define WORD_SIZE 4 /* should be 2 or 4 */ -#define TBL68020 1 /* should be TBL68020 or TBL68000 */ -#define TBL68881 1 /* use floating point processor */ diff --git a/mach/m68k2/as/build.lua b/mach/m68k2/as/build.lua new file mode 100644 index 0000000000..788b768630 --- /dev/null +++ b/mach/m68k2/as/build.lua @@ -0,0 +1,12 @@ +bundle { + name = "headers", + srcs = { + "./mach0.c", + "./mach1.c", + "./mach2.c", + "./mach3.c", + "./mach4.c", + "./mach5.c", + } +} + diff --git a/mach/m68k2/as/mach1.c b/mach/m68k2/as/mach1.c index 7c50c37e22..8c57730faa 100644 --- a/mach/m68k2/as/mach1.c +++ b/mach/m68k2/as/mach1.c @@ -55,9 +55,9 @@ extern int curr_instr; #define PUTL 0x80 #ifndef extern -extern short eamode[]; +extern int eamode[]; #else -short eamode[] = { +int eamode[] = { /* 00A */ DTA |ALT, /* 01A */ ALT, /* 02A */ DTA|MEM|CTR|ALT, diff --git a/mach/m68k2/libem/build.lua b/mach/m68k2/libem/build.lua new file mode 100644 index 0000000000..96e08292fe --- /dev/null +++ b/mach/m68k2/libem/build.lua @@ -0,0 +1,46 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./ara.s", + "./cii.s", + "./cmi.s", + "./cmp.s", + "./cmu.s", + "./csa2.s", + "./csa4.s", + "./csb2.s", + "./csb4.s", + "./cuu.s", + "./exg.s", + "./inn.s", + "./los.s", + "./rck.s", + "./ret.s", + "./set.s", + "./sts.s", + "./nop.s", + "./mon.s", + "./dvi.s", + "./dvu.s", + "./mli.s", + "./mlu.s", + "./shp.s", + "./sig.s", + "./cms.s", + "./gto.s", + "./fp68881.s", + "./fat.s", + "./trp.s", + "./dia.s", + "./lxl.s", + "./lxa.s", + "./lpb.s", + }, + vars = { plat = plat }, + deps = { + "h+emheaders" + } + } +end + diff --git a/mach/m68k2/libem/csa.s b/mach/m68k2/libem/csa2.s similarity index 100% rename from mach/m68k2/libem/csa.s rename to mach/m68k2/libem/csa2.s diff --git a/mach/m68k2/libem/csb.s b/mach/m68k2/libem/csb2.s similarity index 100% rename from mach/m68k2/libem/csb.s rename to mach/m68k2/libem/csb2.s diff --git a/mach/m68k2/libend/build.lua b/mach/m68k2/libend/build.lua new file mode 100644 index 0000000000..bfbf21cd00 --- /dev/null +++ b/mach/m68k2/libend/build.lua @@ -0,0 +1,13 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./edata.s", + "./em_end.s", + "./end.s", + "./etext.s", + }, + vars = { plat = plat }, + } +end + diff --git a/mach/m68k2/ncg/table_dir b/mach/m68k2/ncg/table_dir deleted file mode 100644 index 5dc8802808..0000000000 --- a/mach/m68k2/ncg/table_dir +++ /dev/null @@ -1 +0,0 @@ -TABLE_DIR = $(SRC_HOME)/mach/m68020/ncg diff --git a/mach/m68k2/ncg/whichone.h b/mach/m68k2/ncg/whichone.h deleted file mode 100644 index 5e473cbe2a..0000000000 --- a/mach/m68k2/ncg/whichone.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ - -#define WORD_SIZE 2 /* should be 2 or 4 */ -#define TBL68000 1 /* should be TBL68020 or TBL68000 */ -/* #define TBL68881 1 /* use floating point processor */ diff --git a/mach/minixST/Action b/mach/minixST/Action deleted file mode 100644 index 9ac53acbf9..0000000000 --- a/mach/minixST/Action +++ /dev/null @@ -1,6 +0,0 @@ -name "Atari ST Minix systemcall library" -dir libsys -end -name "Atari ST Minix conversion program from ack.out --> Minix ST a.out" -dir cv -end diff --git a/mach/minixST/cv/cv.c b/mach/minixST/cv/cv.c deleted file mode 100644 index 28564d8691..0000000000 --- a/mach/minixST/cv/cv.c +++ /dev/null @@ -1,332 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - */ - -/* - * Convert ACK a.out file to ST-Minix object format. - */ - -#include -#include -#include -#include -#include - -struct outhead outhead; -struct outsect outsect[S_MAX]; - -#define TEXTSG 0 -#define ROMSG 1 -#define DATASG 2 -#define BSSSG 3 -#define LSECT BSSSG+1 -#define NSECT LSECT+1 - -char *output_file; -int outputfile_created; - -char *program ; - -/* Output file definitions and such */ - -int output; - -int unresolved; -long textsize ; -long datasize ; -long bsssize; - -char *chmemstr; - -minixhead() -{ - long mh[8]; - long stack; - long chmem(); - int i; - - mh[0] = 0x04100301L; - mh[1] = 0x00000020L; - mh[2] = textsize; - mh[3] = datasize; - mh[4] = bsssize; - mh[5] = 0; - stack = 0x00010000L - (mh[3] + mh[4]); - if ((mh[0] & 0x00200000L) == 0) /* not SEPARATE */ - stack -= mh[2]; - while (stack < 0) - stack += 0x00010000L; - if (chmemstr) - stack = chmem(chmemstr, stack); - printf("%ld bytes assigned to stack+malloc area\n", stack); - mh[6] = stack + (mh[3] + mh[4]); - if ((mh[0] & 0x00200000L) == 0) /* not SEPARATE */ - mh[6] += mh[2]; - mh[7] = 0; - for (i = 0; i < 8; i++) { - cvlong(&mh[i]); - } - - if (write(output, (char *) mh, sizeof(mh)) != sizeof(mh)) - fatal("write error\n"); -} - -long align(a,b) - long a,b; -{ - if (b == 0) return a; - a += b - 1; - return a - a % b; -} - -int -follows(pa, pb) - struct outsect *pa, *pb; -{ - /* return 1 if pa follows pb */ - - return pa->os_base == align(pb->os_base+pb->os_size, pa->os_lign); -} - -main(argc, argv) - int argc; - char *argv[]; -{ - - program= argv[0] ; - if (argc > 1) { - switch (argv[1][0]) { - case '-': - case '+': - case '=': - chmemstr = argv[1]; - argc--; - argv++; - } - } - switch (argc) { - case 3: if ((output = creat(argv[2], 0644)) < 0) - fatal("Can't write %s.\n", argv[2]); - output_file = argv[2]; - outputfile_created = 1; - if (! rd_open(argv[1])) - fatal("Can't read %s.\n", argv[1]); - break; - default:fatal("Usage: %s [+-= amount] .\n", argv[0]); - } - rd_ohead(&outhead); - if (BADMAGIC(outhead)) - fatal("Not an ack object file.\n"); - if (outhead.oh_flags & HF_LINK) { - unresolved++; - fatal("Contains unresolved references.\n"); - } - if ( outhead.oh_nsect!=LSECT && outhead.oh_nsect!=NSECT ) - fatal("Input file must have %d sections, not %ld\n", - NSECT,outhead.oh_nsect) ; - rd_sect(outsect, outhead.oh_nsect); - /* A few checks */ - if ( outsect[BSSSG].os_flen != 0 ) - fatal("bss space contains initialized data\n") ; - if (! follows(&outsect[BSSSG], &outsect[DATASG])) - fatal("bss segment must follow data segment\n") ; - textsize= (outsect[DATASG].os_base - outsect[TEXTSG].os_base); - if (! follows(&outsect[ROMSG],&outsect[TEXTSG])) - fatal("rom segment must follow text\n") ; - if (! follows(&outsect[DATASG],&outsect[ROMSG])) - fatal("data segment must follow rom\n") ; - outsect[TEXTSG].os_size = outsect[ROMSG].os_base - outsect[TEXTSG].os_base; - outsect[ROMSG].os_size = outsect[DATASG].os_base - outsect[ROMSG].os_base; - outsect[DATASG].os_size = outsect[BSSSG].os_base - outsect[DATASG].os_base; - datasize= outsect[DATASG].os_size ; - bsssize = outsect[BSSSG].os_size; - if ( outhead.oh_nsect==NSECT ) { - if (! follows(&outsect[LSECT],&outsect[BSSSG])) - fatal("end segment must follow bss\n") ; - if ( outsect[LSECT].os_size != 0 ) - fatal("end segment must be empty\n") ; - } - - minixhead(); - emits(&outsect[TEXTSG]) ; - emits(&outsect[ROMSG]) ; - emits(&outsect[DATASG]) ; - emit_relo(); - if ( outputfile_created) chmod(argv[2],0755); - return 0; -} - -/* - * Transfer the emitted byted from one file to another. - */ -emits(section) struct outsect *section ; { - char *p; - long sz = section->os_flen; - - rd_outsect(section - outsect); - while (sz) { - unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); - if (!(p = malloc(0x4000))) { - fatal("No memory.\n"); - } - rd_emit(p, (long) i); - if (write(output, p, (int)i) < i) { - fatal("write error.\n"); - } - free(p); - sz -= i; - } - - sz = section->os_size - section->os_flen; - if (sz) { - if (!(p = calloc(0x4000, 1))) { - fatal("No memory.\n"); - } - while (sz) { - unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); - if (write(output, p, (int)i) < i) { - fatal("write error.\n"); - } - sz -= i; - } - free(p); - } -} - -int -compare(a,b) - struct outrelo *a, *b; -{ - if (a->or_sect < b->or_sect) return -1; - if (a->or_sect > b->or_sect) return 1; - if (a->or_addr < b->or_addr) return -1; - if (a->or_addr > b->or_addr) return 1; - return 0; -} - -emit_relo() -{ - struct outrelo *ACKrelo; - struct outrelo *ap; - unsigned int cnt = outhead.oh_nrelo; - long last, curr, base; - int sect; - char *bp; - char *b; - - ACKrelo = ap = (struct outrelo *) calloc(cnt, sizeof(struct outrelo)); - bp = b = malloc(4 + cnt); - if (!ap || !bp) { - fatal("No memory.\n"); - } - rd_relo(ap, cnt); - qsort((char *) ap, (int) cnt, sizeof(struct outrelo), compare); - /* - * read relocation, modify to GEMDOS format, and write. - * Only longs can be relocated. - * - * The GEMDOS format starts with a long L: the offset to the - * beginning of text for the first long to be relocated. - * If L==0 then no relocations have to be made. - * - * The long is followed by zero or more bytes. Each byte B is - * processed separately, in one of the following ways: - * - * B==0: - * end of relocation - * B==1: - * no relocation, but add 254 to the current offset - * B==0bWWWWWWW0: - * B is added to the current offset and the long addressed - * is relocated. Note that 00000010 means 1 word distance. - * B==0bXXXXXXX1: - * illegal - */ - - last = 0; - curr = 0; - for (sect = S_MIN; sect <= S_MIN+2; sect++) { - base = outsect[sect-S_MIN].os_base; - for (;cnt > 0 && ap->or_sect == sect; ap++, cnt--) { - if (ap->or_type & RELPC || - ap->or_nami == outhead.oh_nname) { - continue; - } - assert(ap->or_type & RELO4); - curr = base + ap->or_addr; - if (last == 0) { - last = curr; - cvlong(&curr); - *((long *) b) = curr; - b += 4; - } - else { - while (curr - last > 255) { - *b++ = 1; - last += 254; - } - *b++ = curr - last; - last = curr; - } - } - assert(cnt == 0 || ap->or_sect > sect); - } - assert(cnt == 0); - if (cnt = (b - bp)) { - *b++ = '\0'; - write(output, bp, (int) cnt+1); - } - else write(output, "\0\0\0", 4); - free((char *) ACKrelo); - free(bp); -} - -long -chmem(str, old) -char *str; -long old; -{ - long num, new; - long atol(); - - num = atol(str+1); - if (num == 0) - fatal("bad chmem amount %s\n", str+1); - switch (str[0]) { - case '-': - new = old - num; break; - case '+': - new = old + num; break; - case '=': - new = num; break; - } - return(new); -} - -cvlong(l) - long *l; -{ - long x = *l; - char *p = (char *) l; - - *p++ = x >> 24; - *p++ = x >> 16; - *p++ = x >> 8; - *p = x; -} - -/* VARARGS1 */ -fatal(s, a1, a2) - char *s; -{ - fprintf(stderr,"%s: ",program) ; - fprintf(stderr, s, a1, a2); - if (outputfile_created) - unlink(output_file); - exit(-1); -} - -rd_fatal() { fatal("read error.\n"); } diff --git a/mach/minixST/cv/proto.make b/mach/minixST/cv/proto.make deleted file mode 100644 index 6c32d64739..0000000000 --- a/mach/minixST/cv/proto.make +++ /dev/null @@ -1,34 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -OBJLIB=$(TARGET_HOME)/modules/lib/libobject.$(LIBSUF) - -SRC_DIR = $(SRC_HOME)/mach/minixST/cv - -all: cv - -cv: cv.$(SUF) - $(CC) $(LDOPTIONS) -o cv cv.$(SUF) $(OBJLIB) - -cv.$(SUF): $(SRC_DIR)/cv.c - $(CC) $(COPTIONS) -I$(TARGET_HOME)/h -c $(SRC_DIR)/cv.c - -install: all - -mkdir $(TARGET_HOME)/lib.bin/minixST - cp cv $(TARGET_HOME)/lib.bin/minixST/cv - -cmp: all - -cmp cv $(TARGET_HOME)/lib.bin/minixST/cv - -clean: - rm -f *.$(SUF) Out cv - -lint: - $(LINT) $(LINTOPTIONS) -I$(TARGET_HOME)/h $(SRC_DIR)/cv.c $(UTIL_HOME)/modules/lib/$(LINTPREF)object.$(LINTSUF) - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/cv.c - -opr: - make pr | opr diff --git a/mach/minixST/libsys/_access.c b/mach/minixST/libsys/_access.c deleted file mode 100644 index 5bfd12fb54..0000000000 --- a/mach/minixST/libsys/_access.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define access _access -#include - -PUBLIC int access(name, mode) -char *name; -int mode; -{ - return(_callm3(FS, ACCESS, mode, name)); -} diff --git a/mach/minixST/libsys/_alarm.c b/mach/minixST/libsys/_alarm.c deleted file mode 100644 index 605ec1303f..0000000000 --- a/mach/minixST/libsys/_alarm.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#define alarm _alarm -#include - -PUBLIC unsigned int alarm(sec) -unsigned int sec; -{ - return(_callm1(MM, ALARM, (int) sec, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_brk.c b/mach/minixST/libsys/_brk.c deleted file mode 100644 index 82bbe6a809..0000000000 --- a/mach/minixST/libsys/_brk.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#define brk _brk -#define sbrk _sbrk -#include - -extern char *_brksize; - -PUBLIC char *brk(addr) -char *addr; -{ - if (_callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR) == 0) { - _brksize = _M.m2_p1; - return(NIL_PTR); - } else { - return((char *) -1); - } -} - - -PUBLIC char *sbrk(incr) -int incr; -{ - char *newsize, *oldsize; - - oldsize = _brksize; - newsize = _brksize + incr; - if (incr > 0 && newsize < oldsize || incr < 0 && newsize > oldsize) - return((char *) -1); - if (_brk(newsize) == 0) - return(oldsize); - else - return((char *) -1); -} diff --git a/mach/minixST/libsys/_chdir.c b/mach/minixST/libsys/_chdir.c deleted file mode 100644 index 0373eb374b..0000000000 --- a/mach/minixST/libsys/_chdir.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#define chdir _chdir -#include - -PUBLIC int chdir(name) -char *name; -{ - return(_callm3(FS, CHDIR, 0, name)); -} diff --git a/mach/minixST/libsys/_chmod.c b/mach/minixST/libsys/_chmod.c deleted file mode 100644 index 4306d7b651..0000000000 --- a/mach/minixST/libsys/_chmod.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define chmod _chmod -#include - -PUBLIC int chmod(name, mode) -_CONST char *name; -mode_t mode; -{ - return(_callm3(FS, CHMOD, mode, name)); -} diff --git a/mach/minixST/libsys/_chown.c b/mach/minixST/libsys/_chown.c deleted file mode 100644 index 53531c16fe..0000000000 --- a/mach/minixST/libsys/_chown.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define chown _chown -#include - -PUBLIC int chown(name, owner, grp) -char *name; -int owner, grp; -{ - return(_callm1(FS, CHOWN, _len(name), owner, grp, name, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_chroot.c b/mach/minixST/libsys/_chroot.c deleted file mode 100644 index b5b3ee5839..0000000000 --- a/mach/minixST/libsys/_chroot.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#define chroot _chroot -#include - -PUBLIC int chroot(name) -_CONST char *name; -{ - return(_callm3(FS, CHROOT, 0, name)); -} diff --git a/mach/minixST/libsys/_close.c b/mach/minixST/libsys/_close.c deleted file mode 100644 index 9da9c1526e..0000000000 --- a/mach/minixST/libsys/_close.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#define close _close -#include - -PUBLIC int close(fd) -int fd; -{ - return(_callm1(FS, CLOSE, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_creat.c b/mach/minixST/libsys/_creat.c deleted file mode 100644 index b8ce7deac4..0000000000 --- a/mach/minixST/libsys/_creat.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define creat _creat -#include - -PUBLIC int creat(name, mode) -_CONST char *name; -mode_t mode; -{ - return(_callm3(FS, CREAT, mode, name)); -} diff --git a/mach/minixST/libsys/_dup.c b/mach/minixST/libsys/_dup.c deleted file mode 100644 index 1a120634e4..0000000000 --- a/mach/minixST/libsys/_dup.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define dup _dup -#include -#include - -PUBLIC int dup(fd) -int fd; -{ - return(fcntl(fd, F_DUPFD, 0)); -} diff --git a/mach/minixST/libsys/_dup2.c b/mach/minixST/libsys/_dup2.c deleted file mode 100644 index 4a8e8e196b..0000000000 --- a/mach/minixST/libsys/_dup2.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#define dup2 _dup2 -#include -#include -#include -#include - -PUBLIC int dup2(fd, fd2) -int fd, fd2; -{ -/* The behavior of dup2 is defined by POSIX in 6.2.1.2 as almost, but not - * quite the same as fcntl. - */ - - if (fd2 < 0 || fd2 > OPEN_MAX) { - errno = EBADF; - return(-1); - } - - /* Check to see if fildes is valid. */ - if (fcntl(fd, F_GETFL) < 0) { - /* fd is not valid. */ - return(-1); - } else { - /* fd is valid. */ - if (fd == fd2) return(fd2); - close(fd2); - return(fcntl(fd, F_DUPFD, fd2)); - } -} diff --git a/mach/minixST/libsys/_exec.c b/mach/minixST/libsys/_exec.c deleted file mode 100644 index de72ea5e7a..0000000000 --- a/mach/minixST/libsys/_exec.c +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include -#define execl _execl -#define execle _execle -#define execv _execv -#define execve _execve - -extern char **environ; /* environment pointer */ - -#define PTRSIZE (sizeof(char *)) -_PROTOTYPE( char *_sbrk, (int _incr) ); - -#if _ANSI -#include - -PUBLIC int execl(char *name, ...) -{ - int retval; - va_list ap; - - va_start(ap, name); - retval = execve(name, (char **)ap, environ); - va_end(ap); - return retval; -} -#else -PUBLIC int execl(name, arg0) -char *name; -char *arg0; -{ - return(execve(name, &arg0, environ)); -} -#endif - -#if _ANSI -PUBLIC int execle(char *name, ...) -{ - int retval; - va_list ap; - char *p; - - va_start(ap, name); - do { - p = va_arg(ap, char *); - } while(p); - p = (char *)va_arg(ap, char **); - va_end(ap); - va_start(ap, name); - retval = execve(name, (char **)ap, (char **) p); - va_end(ap); - return retval; -} -#else -PUBLIC int execle(name, argv) -char *name, *argv; -{ - char **p; - p = (char **) &argv; - while (*p++) /* null statement */ - ; - return(execve(name, &argv, (char **) *p)); -} -#endif - -PUBLIC int execv(name, argv) -char *name, *argv[]; -{ - - return(execve(name, argv, environ)); -} - -PUBLIC int execve(path, argv, envp) -char *path; /* pointer to name of file to be executed */ -char *argv[]; /* pointer to argument array */ -char *envp[]; /* pointer to environment */ -{ - char **argtop; - char **envtop; - - /* Count the argument pointers and environment pointers. */ - for (argtop = argv; *argtop != (char *) NULL; ) argtop++; - for (envtop = envp; *envtop != (char *) NULL; ) envtop++; - return(__execve(path, argv, envp, (int)(argtop - argv), (int)(envtop - envp))); -} - -PUBLIC int __execve(path, argv, envp, nargs, nenvps) -char *path; /* pointer to name of file to be executed */ -char *argv[]; /* pointer to argument array */ -char *envp[]; /* pointer to environment */ -int nargs; /* number of args */ -int nenvps; /* number of environment strings */ -{ -/* This is split off from execve to be called from execvp, so execvp does not - * have to allocate up to ARG_MAX bytes just to prepend "sh" to the arg array. - */ - - char *hp, **ap, *p; - int i, stackbytes, npointers, overflow, temp; - char *stack; - /* Decide how big a stack is needed. Be paranoid about overflow. */ -#if ARG_MAX > INT_MAX -#error /* overflow checks and sbrk depend on sizes being ints */ -#endif - overflow = FALSE; - npointers = 1 + nargs + 1 + nenvps + 1; /* 1's for argc and NULLs */ - stackbytes = 0; /* changed because _len is used now */ - if (nargs < 0 || nenvps < 0 || nargs+nenvps < 0 || npointers < 0) - overflow = TRUE; - for (i = PTRSIZE; i != 0; i--) { - temp = stackbytes + npointers; - if (temp < stackbytes) overflow = TRUE; - stackbytes = temp; - } - for (i = 0, ap = argv; i < nargs; i++) { - temp = stackbytes + _len(*ap++); - if (temp < stackbytes) overflow = TRUE; - stackbytes = temp; - } - for (i = 0, ap = envp; i < nenvps; i++) { - temp = stackbytes + _len(*ap++); - if (temp < stackbytes) overflow = TRUE; - stackbytes = temp; - } - temp = stackbytes + PTRSIZE - 1; - if (temp < stackbytes) overflow = TRUE; - stackbytes = (temp / PTRSIZE) * PTRSIZE; - - /* Check for overflow before committing sbrk. */ - if (overflow || stackbytes > ARG_MAX) { - errno = E2BIG; - return(-1); - } - - /* Allocate the stack. */ - stack = _sbrk(stackbytes); - if (stack == (char *) -1) { - errno = E2BIG; - return(-1); - } - - /* Prepare the stack vector and argc. */ - ap = (char **) stack; - hp = &stack[npointers * PTRSIZE]; - *ap++ = (char *) nargs; - - /* Prepare the argument pointers and strings. */ - for (i = 0; i < nargs; i++) { - *ap++ = (char *) (hp - stack); - p = *argv++; - while ((*hp++ = *p++) != 0) - ; - } - *ap++ = (char *) NULL; - - /* Prepare the environment pointers and strings. */ - for (i = 0; i < nenvps; i++) { - *ap++ = (char *) (hp - stack); - p = *envp++; - while ((*hp++ = *p++) != 0) - ; - } - *ap++ = (char *) NULL; - - /* Do the real work. */ - temp = _callm1(MM, EXEC, _len(path), stackbytes, 0, path, stack, NIL_PTR); - _sbrk(-stackbytes); - return(temp); -} diff --git a/mach/minixST/libsys/_execn.c b/mach/minixST/libsys/_execn.c deleted file mode 100644 index 1ac59ec15d..0000000000 --- a/mach/minixST/libsys/_execn.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#define PTRSIZE sizeof(char *) -_PROTOTYPE( int _execn, (char * name)); - -PUBLIC int _execn(name) -char *name; /* pointer to file to be exec'd */ -{ -/* Special version used when there are no args and no environment. This call - * is principally used by INIT, to avoid having to allocate ARG_MAX. - */ - - static char stack[3 * PTRSIZE]; - - return(_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_execnl.c b/mach/minixST/libsys/_execnl.c deleted file mode 100644 index 71dcc7ae7b..0000000000 --- a/mach/minixST/libsys/_execnl.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file contains two functions that can be used to perform - * an EXEC call without the need for a "big" stack of MAX_ARG - * bytes. It is primarily used by the INIT module of the system. - */ -#include -#include -#include - -#define MAXSTK 256 /* maximum EXEC stack size */ -#define PTRSIZE sizeof(char *) - -_PROTOTYPE(int _execn,(char *name)); -_PROTOTYPE(int _execnl,(char *name, char *arg0)); -static _PROTOTYPE(int _nexec,(char *name, char *argv[])); - -PUBLIC int _execn(name) -char *name; /* pointer to file to be exec'd */ -{ -/* This funcion uses no arguments at all. */ - static char stack[3 * PTRSIZE]; - - return(_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR)); -} - - -PUBLIC int _execnl(name, arg0) -char *name; -char *arg0; -{ - /* This function resembles execl(2). */ - - return(_nexec(name, &arg0)); -} - -static int _nexec(name, argv) -char *name; /* pointer to name of file to be executed */ -char *argv[]; /* pointer to argument array */ -{ - char stack[MAXSTK]; - char **argorg, *hp, **ap, *p; - int i, nargs, stackbytes, offset; - - /* Count the argument pointers. */ - nargs = 0; - argorg = argv; - while (*argorg++ != NIL_PTR) nargs++; - - /* Prepare to set up the initial stack. */ - hp = &stack[(nargs + 3) * PTRSIZE]; - if (hp + nargs >= &stack[MAXSTK]) { - errno = E2BIG; - return(-1); - } - ap = (char **) stack; - *ap++ = (char *) nargs; - - /* Prepare the argument pointers and strings. */ - for (i = 0; i < nargs; i++) { - offset = hp - stack; - *ap++ = (char *) offset; - p = *argv++; - while (*p) { - *hp++ = *p++; - if (hp >= &stack[MAXSTK]) { - errno = E2BIG; - return(-1); - } - } - *hp++ = (char) 0; - } - *ap++ = NIL_PTR; - - stackbytes = (((int) (hp - stack) + PTRSIZE - 1) / PTRSIZE) * PTRSIZE; - return(_callm1(MM, EXEC, _len(name), stackbytes, 0, name, stack, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_exit.c b/mach/minixST/libsys/_exit.c deleted file mode 100644 index ad59c46f2f..0000000000 --- a/mach/minixST/libsys/_exit.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -PUBLIC void _exit(status) -int status; -{ - _callm1(MM, EXIT, status, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); -} diff --git a/mach/minixST/libsys/_fcntl.c b/mach/minixST/libsys/_fcntl.c deleted file mode 100644 index f96eebf6f3..0000000000 --- a/mach/minixST/libsys/_fcntl.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#define fcntl _fcntl -#include -#if _ANSI -#endif - -#if _ANSI -#include -PUBLIC int fcntl(int fd, int cmd, ...) -{ -#else -#include -PUBLIC int fcntl(va_alist) -va_dcl -{ -int fd; -int cmd; -#endif - va_list ap; - int int3; /* third integer parameter for callm1 */ - char *ptr1; /* first pointer parameter for callm1 */ - -#if _ANSI - va_start(ap, cmd); -#else - va_start(ap); - fd = va_arg(ap, int); - cmd = va_arg(ap, int); -#endif - - /* Set up for the sensible case where there is no variable parameter. This - * covers F_GETFD, F_GETFL and invalid commands. - */ - int3 = 0; - ptr1 = NIL_PTR; - - /* Adjust for the stupid cases. */ - switch(cmd) { - case F_DUPFD: - case F_SETFD: - case F_SETFL: - int3 = va_arg(ap, int); - break; - case F_GETLK: - case F_SETLK: - case F_SETLKW: - ptr1 = (char *) va_arg(ap, struct flock *); - break; - } - - /* Clean up and make the system call. */ - va_end(ap); - return(_callm1(FS, FCNTL, fd, cmd, int3, ptr1, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_fork.c b/mach/minixST/libsys/_fork.c deleted file mode 100644 index 0cf123b132..0000000000 --- a/mach/minixST/libsys/_fork.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#define fork _fork -#include - -PUBLIC int fork() -{ - return(_callm1(MM, FORK, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_fstat.c b/mach/minixST/libsys/_fstat.c deleted file mode 100644 index e7f24477b0..0000000000 --- a/mach/minixST/libsys/_fstat.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#define fstat _fstat -#include - -PUBLIC int fstat(fd, buffer) -int fd; -struct stat *buffer; -{ - return(_callm1(FS, FSTAT, fd, 0, 0, (char *)buffer, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_getcwd.c b/mach/minixST/libsys/_getcwd.c deleted file mode 100644 index de7e923f2f..0000000000 --- a/mach/minixST/libsys/_getcwd.c +++ /dev/null @@ -1,120 +0,0 @@ -/* getcwd - get current working directory Author: Terrence W. Holm */ - -/* Directly derived from Adri Koppes' pwd(1). - * Modified by Andy Tanenbaum for POSIX (29 Oct. 1989) - */ - -#include -#include -#include -#include -#include -#define getcwd _getcwd - -#define DIRECT_SIZE (sizeof (struct direct)) - -static _PROTOTYPE(void go_back, (char *path) ); - -char *getcwd(buffer, size) -char *buffer; -int size; -/* Get current working directory. */ -{ - int same_device, found, fd; - char *r, path[PATH_MAX + 1], temp_name[NAME_MAX + 1]; - struct stat current, parent, dir_entry; - struct direct d; - - if (buffer == (char *)NULL || size <= 0) { - errno = EINVAL; - return((char *)NULL); - } - path[0] = '\0'; - - /* Get the inode for the current directory */ - if (stat(".", ¤t) == -1) return((char *)NULL); - if ((current.st_mode & S_IFMT) != S_IFDIR) return((char *)NULL); - - /* Run backwards up the directory tree, grabbing dir names on the way. */ - while (1) { - same_device = 0; - found = 0; - - /* Get the inode for the parent directory */ - if (chdir("..") == -1) return((char *)NULL); - if (stat(".", &parent) == -1) return((char *)NULL); - if ((parent.st_mode & S_IFMT) != S_IFDIR) return((char *)NULL); - if (current.st_dev == parent.st_dev) same_device = 1; - - /* At the root, "." is the same as ".." */ - if (same_device && current.st_ino == parent.st_ino) break; - - /* Search the parent directory for the current entry */ - if ((fd = open(".", O_RDONLY)) == -1) return((char *)NULL); - while (!found && read(fd, (char *)&d, DIRECT_SIZE) == DIRECT_SIZE) { - if (d.d_ino == 0L) continue; /* empty slot */ - if (same_device) { - if (current.st_ino == d.d_ino) found = 1; - } else { - temp_name[0] = '\0'; - strncat(temp_name, d.d_name, NAME_MAX); - if (stat(temp_name, &dir_entry) == -1) { - close(fd); - go_back(path); - return((char *)NULL); - } - if (current.st_dev == dir_entry.st_dev && - current.st_ino == dir_entry.st_ino) - found = 1; - } - } - - close(fd); - if (!found) { - go_back(path); - return((char *)NULL); - } - if (strlen(path) + NAME_MAX + 1 > PATH_MAX) { - errno = ERANGE; - go_back(path); - return((char *)NULL); - } - strcat(path, "/"); - strncat(path, d.d_name, NAME_MAX); - current.st_dev = parent.st_dev; - current.st_ino = parent.st_ino; - } - - /* Copy the reversed path name into */ - if (strlen(path) + 1 > size) { - errno = ERANGE; - go_back(path); - return((char *)NULL); - } - if (strlen(path) == 0) { - strcpy(buffer, "/"); - return(buffer); - } - *buffer = '\0'; - while ((r = strrchr(path, '/')) != (char *)NULL) { - strcat(buffer, r); - *r = '\0'; - } - return(chdir(buffer) ? (char *)NULL : buffer); -} - -static void go_back(path) -char *path; -{ -/* If getcwd() gets in trouble and can't complete normally, reverse the - * path built so far and change there so we end up in the directory that - * we started in. - */ - - char *r; - - while ((r = strrchr(path, '/')) != (char *)NULL) { - chdir(r+1); - *r = '\0'; - } -} diff --git a/mach/minixST/libsys/_getegid.c b/mach/minixST/libsys/_getegid.c deleted file mode 100644 index 1508cc478d..0000000000 --- a/mach/minixST/libsys/_getegid.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#define getegid _getegid -#include - -PUBLIC gid_t getegid() -{ - int k; - k = _callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); - if (k < 0) return((gid_t) k); - return((gid_t) _M.m2_i1); -} diff --git a/mach/minixST/libsys/_geteuid.c b/mach/minixST/libsys/_geteuid.c deleted file mode 100644 index 230b3e565e..0000000000 --- a/mach/minixST/libsys/_geteuid.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#define geteuid _geteuid -#include - -PUBLIC uid_t geteuid() -{ - int k; - k = _callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); - if (k < 0) return((uid_t) k); - return((uid_t) _M.m2_i1); -} diff --git a/mach/minixST/libsys/_getgid.c b/mach/minixST/libsys/_getgid.c deleted file mode 100644 index 38b7123367..0000000000 --- a/mach/minixST/libsys/_getgid.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#define getgid _getgid -#include - -PUBLIC gid_t getgid() -{ - return((gid_t)_callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_getpid.c b/mach/minixST/libsys/_getpid.c deleted file mode 100644 index 6847d3caad..0000000000 --- a/mach/minixST/libsys/_getpid.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#define getpid _getpid -#include - -PUBLIC int getpid() -{ - return(_callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_getppid.c b/mach/minixST/libsys/_getppid.c deleted file mode 100644 index b54666acbc..0000000000 --- a/mach/minixST/libsys/_getppid.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#define getppid _getppid -#include - -PUBLIC int getppid() -{ - int p; - - p = _callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); - if (p < 0) return(p); - return(_M.m2_i1); -} diff --git a/mach/minixST/libsys/_getuid.c b/mach/minixST/libsys/_getuid.c deleted file mode 100644 index ab2b4678c5..0000000000 --- a/mach/minixST/libsys/_getuid.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#define getuid _getuid -#include - -PUBLIC uid_t getuid() -{ - return((uid_t)_callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_gtty.c b/mach/minixST/libsys/_gtty.c deleted file mode 100644 index 943ebe34f2..0000000000 --- a/mach/minixST/libsys/_gtty.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#define gtty _gtty -#define ioctl _ioctl -#include - -PUBLIC int gtty(fd, argp) -int fd; -struct sgttyb *argp; -{ - return(ioctl(fd, TIOCGETP, argp)); -} diff --git a/mach/minixST/libsys/_ioctl.c b/mach/minixST/libsys/_ioctl.c deleted file mode 100644 index e30bf1f5fa..0000000000 --- a/mach/minixST/libsys/_ioctl.c +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#define ioctl _ioctl -#include - -PUBLIC int ioctl(fd, request, argp) -int fd; -int request; -struct sgttyb *argp; -{ - int n; - long erase, kill, intr, quit, xon, xoff, eof, brk, speed; - struct tchars *argt; - - _M.TTY_REQUEST = request; - _M.TTY_LINE = fd; - - switch(request) { - case TIOCSETP: - erase = argp->sg_erase & BYTE; - kill = argp->sg_kill & BYTE; - speed = ((argp->sg_ospeed & BYTE) << 8) | (argp->sg_ispeed & BYTE); - _M.TTY_SPEK = (speed << 16) | (erase << 8) | kill; - _M.TTY_FLAGS = argp->sg_flags; - n = _callx(FS, IOCTL); - return(n); - - case TIOCSETC: - argt = (struct tchars * /* kludge */) argp; - intr = argt->t_intrc & BYTE; - quit = argt->t_quitc & BYTE; - xon = argt->t_startc & BYTE; - xoff = argt->t_stopc & BYTE; - eof = argt->t_eofc & BYTE; - brk = argt->t_brkc & BYTE; /* not used at the moment */ - _M.TTY_SPEK = (intr<<24) | (quit<<16) | (xon<<8) | (xoff<<0); - _M.TTY_FLAGS = (eof<<8) | (brk<<0); - n = _callx(FS, IOCTL); - return(n); - - case TIOCGETP: - n = _callx(FS, IOCTL); - argp->sg_erase = (_M.TTY_SPEK >> 8) & BYTE; - argp->sg_kill = (_M.TTY_SPEK >> 0) & BYTE; - argp->sg_flags = _M.TTY_FLAGS & 0xFFFFL; - speed = (_M.TTY_SPEK >> 16) & 0xFFFFL; - argp->sg_ispeed = speed & BYTE; - argp->sg_ospeed = (speed >> 8) & BYTE; - return(n); - - case TIOCGETC: - n = _callx(FS, IOCTL); - argt = (struct tchars *) argp; - argt->t_intrc = (_M.TTY_SPEK >> 24) & BYTE; - argt->t_quitc = (_M.TTY_SPEK >> 16) & BYTE; - argt->t_startc = (_M.TTY_SPEK >> 8) & BYTE; - argt->t_stopc = (_M.TTY_SPEK >> 0) & BYTE; - argt->t_eofc = (_M.TTY_FLAGS >> 8) & BYTE; - argt->t_brkc = (_M.TTY_FLAGS >> 8) & BYTE; - return(n); - -/* This is silly, do we want to add 1001 cases and _M.TTY_XYZ's here? - * We should just pop argp into the message for low-level interpretation. - */ - - case TIOCFLUSH: - _M.TTY_FLAGS = (int /* kludge */) argp; - return _callx(FS, IOCTL); - -/* decided to pop argp in the ADDRESS field. Left TIOCFLUSH a special case - * since it affects other platforms and old software too. FM - */ - default: - _M.ADDRESS = (char *)argp; - return _callx(FS, IOCTL); - } -} diff --git a/mach/minixST/libsys/_kill.c b/mach/minixST/libsys/_kill.c deleted file mode 100644 index 47d319f9fb..0000000000 --- a/mach/minixST/libsys/_kill.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define kill _kill -#include - -PUBLIC int kill(proc, sig) -int proc; /* which process is to be sent the signal */ -int sig; /* signal number */ -{ - return(_callm1(MM, KILL, proc, sig, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_link.c b/mach/minixST/libsys/_link.c deleted file mode 100644 index d21642843f..0000000000 --- a/mach/minixST/libsys/_link.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#define link _link -#include - -PUBLIC int link(name, name2) -_CONST char *name, *name2; -{ - return(_callm1(FS, LINK, _len(name), _len(name2), 0, - (char *) name, (char *) name2, /* perhaps callm1 preserves these */ - NIL_PTR)); -} diff --git a/mach/minixST/libsys/_lseek.c b/mach/minixST/libsys/_lseek.c deleted file mode 100644 index d2f3993c7a..0000000000 --- a/mach/minixST/libsys/_lseek.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#define lseek _lseek -#include - -PUBLIC off_t lseek(fd, offset, whence) -int fd; -off_t offset; -int whence; -{ - int k; - _M.m2_i1 = fd; - _M.m2_l1 = offset; - _M.m2_i2 = whence; - k = _callx(FS, LSEEK); - if (k != 0) return((off_t) k); /* _send() itself failed */ - return((off_t)_M.m2_l1); -} diff --git a/mach/minixST/libsys/_mkdir.c b/mach/minixST/libsys/_mkdir.c deleted file mode 100644 index 7fc46fcb8a..0000000000 --- a/mach/minixST/libsys/_mkdir.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define mkdir _mkdir -#include - -PUBLIC int mkdir(name, mode) -_CONST char *name; -int mode; -{ - return(_callm1(FS, MKDIR, _len(name), mode, 0, (char *)name, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_mkfifo.c b/mach/minixST/libsys/_mkfifo.c deleted file mode 100644 index 4d41f929f0..0000000000 --- a/mach/minixST/libsys/_mkfifo.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#define mkfifo _mkfifo -#include - -PUBLIC int mkfifo(name, mode) -_CONST char *name; -int mode; -{ - mode = (mode & 0777) | S_IFIFO; - return(_callm1(FS, MKNOD, _len(name), (int)mode, 0, - (char *)name, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_mknod.c b/mach/minixST/libsys/_mknod.c deleted file mode 100644 index ca83f62baf..0000000000 --- a/mach/minixST/libsys/_mknod.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#define mknod _mknod -#include - -PUBLIC int mknod(name, mode, addr) -_CONST char *name; -int mode, addr; -{ - return(_callm1(FS, MKNOD, _len(name), mode, addr, - (char *) name, (char *) 0, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_mknod4.c b/mach/minixST/libsys/_mknod4.c deleted file mode 100644 index de7682b53d..0000000000 --- a/mach/minixST/libsys/_mknod4.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#define mknod4 _mknod4 -#include - -PUBLIC int mknod4(name, mode, addr, size) -_CONST char *name; -int mode, addr; -unsigned int size; -{ - return(_callm1(FS, MKNOD, _len(name), mode, addr, - (char *) name, (char *) size, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_mount.c b/mach/minixST/libsys/_mount.c deleted file mode 100644 index 52ba1d9e1f..0000000000 --- a/mach/minixST/libsys/_mount.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define mount _mount -#include - -PUBLIC int mount(special, name, rwflag) -char *name, *special; -int rwflag; -{ - return(_callm1(FS, MOUNT, _len(special), _len(name), rwflag, special, name, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_open.c b/mach/minixST/libsys/_open.c deleted file mode 100644 index 5f0f94ae35..0000000000 --- a/mach/minixST/libsys/_open.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#define open _open -#include - -#if _ANSI -#include - -PUBLIC int open(const char *name, int flags, ...) -{ - int i; - va_list ap; - - if (flags & O_CREAT) { - va_start(ap, flags); - i = va_arg(ap, int); - i = _callm1(FS, OPEN, _len(name), flags, i, - (char *)name, NIL_PTR, NIL_PTR); - va_end(ap); - return i; - } - return _callm3(FS, OPEN, flags, name); -} -#else -PUBLIC int open(name, flags, mode) -_CONST char *name; -int flags, mode; -{ - if (flags & O_CREAT) - return _callm1(FS, OPEN, _len(name), flags, mode, - (char *)name, NIL_PTR, NIL_PTR); - return(_callm3(FS, OPEN, flags, name)); -} -#endif diff --git a/mach/minixST/libsys/_pause.c b/mach/minixST/libsys/_pause.c deleted file mode 100644 index 2a92a9a33c..0000000000 --- a/mach/minixST/libsys/_pause.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#define pause _pause -#include - -PUBLIC int pause() -{ - return(_callm1(MM, PAUSE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_pipe.c b/mach/minixST/libsys/_pipe.c deleted file mode 100644 index 4cfce75548..0000000000 --- a/mach/minixST/libsys/_pipe.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#define pipe _pipe -#include - -PUBLIC int pipe(fild) -int fild[2]; -{ - int k; - k = _callm1(FS, PIPE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); - if (k >= 0) { - fild[0] = _M.m1_i1; - fild[1] = _M.m1_i2; - return(0); - } else - return(k); -} diff --git a/mach/minixST/libsys/_ptrace.c b/mach/minixST/libsys/_ptrace.c deleted file mode 100644 index b74dfa2aec..0000000000 --- a/mach/minixST/libsys/_ptrace.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#define ptrace _ptrace -#include - -PUBLIC long ptrace(req, pid, addr, data) -int req, pid; -long addr, data; -{ - _M.m2_i1 = pid; - _M.m2_i2 = req; - _M.m2_l1 = addr; - _M.m2_l2 = data; - if (_callx(MM, PTRACE) == -1) return(-1L); - if (_M.m2_l2 == -1) { - errno = 0; - return(-1L); - } - return(_M.m2_l2); -} diff --git a/mach/minixST/libsys/_read.c b/mach/minixST/libsys/_read.c deleted file mode 100644 index ac4e90eee3..0000000000 --- a/mach/minixST/libsys/_read.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#define read _read -#include - -PUBLIC int read(fd, buffer, nbytes) -int fd; -char *buffer; -unsigned nbytes; -{ - return(_callm1(FS, READ, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_rename.c b/mach/minixST/libsys/_rename.c deleted file mode 100644 index 80495e5e15..0000000000 --- a/mach/minixST/libsys/_rename.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#define rename _rename -#include - -PUBLIC int rename(name, name2) -_CONST char *name, *name2; -{ - return(_callm1(FS, RENAME, _len(name), _len(name2), 0, - (char *) name, (char *) name2, /* perhaps callm1 preserves these */ - NIL_PTR)); -} diff --git a/mach/minixST/libsys/_rmdir.c b/mach/minixST/libsys/_rmdir.c deleted file mode 100644 index dedcdb240d..0000000000 --- a/mach/minixST/libsys/_rmdir.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#define rmdir _rmdir -#include - -PUBLIC int rmdir(name) -_CONST char *name; -{ - return(_callm3(FS, RMDIR, 0, name)); -} diff --git a/mach/minixST/libsys/_setgid.c b/mach/minixST/libsys/_setgid.c deleted file mode 100644 index 9972bec41c..0000000000 --- a/mach/minixST/libsys/_setgid.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#define setgid _setgid -#include - -PUBLIC int setgid(grp) -gid_t grp; -{ - return(_callm1(MM, SETGID, (int)grp, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_setuid.c b/mach/minixST/libsys/_setuid.c deleted file mode 100644 index 921635d2ef..0000000000 --- a/mach/minixST/libsys/_setuid.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#define setuid _setuid -#include - -PUBLIC int setuid(usr) -int usr; -{ - return(_callm1(MM, SETUID, (int)usr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_signal.c b/mach/minixST/libsys/_signal.c deleted file mode 100644 index 1b5e8e1e7a..0000000000 --- a/mach/minixST/libsys/_signal.c +++ /dev/null @@ -1,41 +0,0 @@ -#include -#define signal _signal -#include - -extern _PROTOTYPE(void (*_vectab[_NSIG]), (int)); /* array of funcs to catch signals */ - -/* The definition of signal really should be - * PUBLIC void (*signal(signr, func))() - * but some compilers refuse to accept this, even though it is correct. - * The only thing to do if you are stuck with such a defective compiler is - * change it to - * PUBLIC void *signal(signr, func) - * and change ../h/signal.h accordingly. - */ - -PUBLIC void (*signal(signr, func))() -int signr; /* which signal is being set */ -_PROTOTYPE( void (*func), (int)); /* pointer to function that catches signal */ -{ - int r; - _PROTOTYPE( void (*old), (int)); - - old = _vectab[signr - 1]; - _M.m6_i1 = signr; - if (func == SIG_IGN || func == SIG_DFL) - /* Keep old signal catcher until it is completely de-installed */ - _M.m6_f1 = func; - else { - /* Use new signal catcher immediately (old one may not exist) */ - _vectab[signr - 1] = func; - _M.m6_f1 = _begsig; - } - r = _callx(MM, SIGNAL); - if (r < 0) { - _vectab[signr - 1] = old;/* undo any pre-installation */ - return((void (*) ()) r); - } - _vectab[signr - 1] = func; /* redo any pre-installation */ - if (r == 1) return(SIG_IGN); - return(old); -} diff --git a/mach/minixST/libsys/_stat.c b/mach/minixST/libsys/_stat.c deleted file mode 100644 index 329b0141d4..0000000000 --- a/mach/minixST/libsys/_stat.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#define stat _stat -#include - -PUBLIC int stat(name, buffer) -_CONST char *name; -struct stat *buffer; -{ - return(_callm1(FS, STAT, _len(name), 0, 0, - (char *)name, (char *)buffer, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_stime.c b/mach/minixST/libsys/_stime.c deleted file mode 100644 index 9fa8e16afb..0000000000 --- a/mach/minixST/libsys/_stime.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define stime _stime -#include - -PUBLIC int stime(top) -long *top; -{ - _M.m2_l1 = *top; - return(_callx(FS, STIME)); -} diff --git a/mach/minixST/libsys/_stty.c b/mach/minixST/libsys/_stty.c deleted file mode 100644 index a213e3e860..0000000000 --- a/mach/minixST/libsys/_stty.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#define stty _stty -#define ioctl _ioctl -#include - -PUBLIC int stty(fd, argp) -int fd; -struct sgttyb *argp; -{ - return ioctl(fd, TIOCSETP, argp); -} diff --git a/mach/minixST/libsys/_sync.c b/mach/minixST/libsys/_sync.c deleted file mode 100644 index c72e86207d..0000000000 --- a/mach/minixST/libsys/_sync.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#define sync _sync -#include - -PUBLIC int sync() -{ - return(_callm1(FS, SYNC, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/_time.c b/mach/minixST/libsys/_time.c deleted file mode 100644 index 22957e27df..0000000000 --- a/mach/minixST/libsys/_time.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#define time _time -#include - -PUBLIC long time(tp) -long *tp; -{ - int k; - long l; - k = _callm1(FS, TIME, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); - if (_M.m_type < 0 || k != 0) { - errno = -_M.m_type; - return(-1L); - } - l = _M.m2_l1; - if (tp != (long *) 0) *tp = l; - return(l); -} diff --git a/mach/minixST/libsys/_times.c b/mach/minixST/libsys/_times.c deleted file mode 100644 index 223c8b3375..0000000000 --- a/mach/minixST/libsys/_times.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include -#define times _times -#include - -PUBLIC clock_t times(buf) -struct tms *buf; -{ - clock_t k; - k = (clock_t)_callm1(FS, TIMES, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); - buf->tms_utime = _M.m4_l1; - buf->tms_stime = _M.m4_l2; - buf->tms_cutime = _M.m4_l3; - buf->tms_cstime = _M.m4_l4; - return(k); -} diff --git a/mach/minixST/libsys/_umount.c b/mach/minixST/libsys/_umount.c deleted file mode 100644 index 103538c668..0000000000 --- a/mach/minixST/libsys/_umount.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#define umount _umount -#include - -PUBLIC int umount(name) -_CONST char *name; -{ - return(_callm3(FS, UMOUNT, 0, name)); -} diff --git a/mach/minixST/libsys/_unlink.c b/mach/minixST/libsys/_unlink.c deleted file mode 100644 index 3d225a76bc..0000000000 --- a/mach/minixST/libsys/_unlink.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#define unlink _unlink -#include - -PUBLIC int unlink(name) -_CONST char *name; -{ - return(_callm3(FS, UNLINK, 0, name)); -} diff --git a/mach/minixST/libsys/_utime.c b/mach/minixST/libsys/_utime.c deleted file mode 100644 index c22dbcd88e..0000000000 --- a/mach/minixST/libsys/_utime.c +++ /dev/null @@ -1,29 +0,0 @@ -/* _utime(2) for POSIX Authors: Terrence W. Holm & Edwin L. Froese */ - -#include -#define time _time -#include -#define utime _utime -#include - -long time(); - -PUBLIC int utime(name, timp) -char *name; -struct utimbuf *timp; -{ - long current_time; - - if (timp == (struct utimbuf *)NULL) { - current_time = time((long *)NULL); - _M.m2_l1 = current_time; - _M.m2_l2 = current_time; - } else { - _M.m2_l1 = timp->actime; - _M.m2_l2 = timp->modtime; - } - - _M.m2_i1 = _len(name); - _M.m2_p1 = name; - return _callx(FS, UTIME); -} diff --git a/mach/minixST/libsys/_wait.c b/mach/minixST/libsys/_wait.c deleted file mode 100644 index c1c2322e15..0000000000 --- a/mach/minixST/libsys/_wait.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#define wait _wait -#include - -PUBLIC int wait(status) -int *status; -{ - int k; - k = _callm1(MM, WAIT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); - if (k >= 0 && status != 0) *status = _M.m2_i1; - return(k); -} diff --git a/mach/minixST/libsys/_write.c b/mach/minixST/libsys/_write.c deleted file mode 100644 index a64da03aed..0000000000 --- a/mach/minixST/libsys/_write.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#define write _write -#include - -PUBLIC int write(fd, buffer, nbytes) -int fd; -char *buffer; -unsigned nbytes; -{ - return(_callm1(FS, WRITE, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR)); -} diff --git a/mach/minixST/libsys/call.c b/mach/minixST/libsys/call.c deleted file mode 100644 index c9e8a50453..0000000000 --- a/mach/minixST/libsys/call.c +++ /dev/null @@ -1,78 +0,0 @@ -#include - -PUBLIC int _callm1(proc, syscallnr, int1, int2, int3, ptr1, ptr2, ptr3) -int proc; /* FS or MM */ -int syscallnr; /* which system call */ -int int1; /* first integer parameter */ -int int2; /* second integer parameter */ -int int3; /* third integer parameter */ -char *ptr1; /* pointer parameter */ -char *ptr2; /* pointer parameter */ -char *ptr3; /* pointer parameter */ -{ -/* Send a message and get the response. The '_M.m_type' field of the - * reply contains a value (>= 0) or an error code (<0). Use message format m1. - */ - _M.m1_i1 = int1; - _M.m1_i2 = int2; - _M.m1_i3 = int3; - _M.m1_p1 = ptr1; - _M.m1_p2 = ptr2; - _M.m1_p3 = ptr3; - return _callx(proc, syscallnr); -} - - -PUBLIC int _callm3(proc, syscallnr, int1, name) -int proc; /* FS or MM */ -int syscallnr; /* which system call */ -int int1; /* integer parameter */ -_CONST char *name; /* string */ -{ -/* This form of system call is used for those calls that contain at most - * one integer parameter along with a string. If the string fits in the - * message, it is copied there. If not, a pointer to it is passed. - */ - int k; - char *rp; - k = _len(name); - _M.m3_i1 = k; - _M.m3_i2 = int1; - _M.m3_p1 = (char *) name; - rp = &_M.m3_ca1[0]; - if (k <= M3_STRING) while (k--) - *rp++ = *name++; - return _callx(proc, syscallnr); -} - - -PUBLIC int _callx(proc, syscallnr) -int proc; /* FS or MM */ -int syscallnr; /* which system call */ -{ -/* Send a message and get the response. The '_M.m_type' field of the - * reply contains a value (>= 0) or an error code (<0). - */ - int k; - - _M.m_type = syscallnr; - k = _sendrec(proc, &_M); - if (k != 0) return(k); /* _send() itself failed */ - if (_M.m_type < 0) { - errno = -_M.m_type; - return(-1); - } - return(_M.m_type); -} - - -PUBLIC int _len(s) -_CONST register char *s; /* character string whose length is needed */ -{ -/* Return the length of a character string, including the 0 at the end. */ - int k; - - k = 0; - while (*s++ != 0) k++; - return(k + 1); /* return length including the 0-byte at end */ -} diff --git a/mach/minixST/libsys/cleanup.c b/mach/minixST/libsys/cleanup.c deleted file mode 100644 index 07d507e3f2..0000000000 --- a/mach/minixST/libsys/cleanup.c +++ /dev/null @@ -1,3 +0,0 @@ -_cleanup() -{ -} diff --git a/mach/minixST/libsys/exit.c b/mach/minixST/libsys/exit.c deleted file mode 100644 index 03b6bd703a..0000000000 --- a/mach/minixST/libsys/exit.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -PUBLIC int exit(status) -int status; -{ - _cleanup(); - _exit(status); -} diff --git a/mach/minixST/libsys/fpathconf.c b/mach/minixST/libsys/fpathconf.c deleted file mode 100644 index 8448d9c369..0000000000 --- a/mach/minixST/libsys/fpathconf.c +++ /dev/null @@ -1,60 +0,0 @@ -/* POSIX fpathconf (Sec. 5.7.1) Author: Andy Tanenbaum */ - -#include -#include -#include -#define fstat _fstat -#include -#include -#include - -PUBLIC long fpathconf(fd, name) -int fd; /* file descriptor being interrogated */ -int name; /* property being inspected */ -{ -/* POSIX allows some of the values in to be increased at - * run time. The pathconf and fpathconf functions allow these values - * to be checked at run time. MINIX does not use this facility. - * The run-time limits are those given in . - */ - - struct stat stbuf; - - switch(name) { - case _PC_LINK_MAX: - /* Fstat the file. If that fails, return -1. */ - if (fstat(fd, &stbuf) != 0) return(-1L); - if (S_ISDIR(stbuf.st_mode)) - return(1L); /* no links to directories */ - else - return( (long) LINK_MAX); - - case _PC_MAX_CANON: - return( (long) MAX_CANON); - - case _PC_MAX_INPUT: - return( (long) MAX_INPUT); - - case _PC_NAME_MAX: - return( (long) NAME_MAX); - - case _PC_PATH_MAX: - return( (long) PATH_MAX); - - case _PC_PIPE_BUF: - return( (long) PIPE_BUF); - - case _PC_CHOWN_RESTRICTED: - return( (long) 1); /* MINIX defines CHOWN_RESTRICTED */ - - case _PC_NO_TRUNC: /* MINIX does not define NO_TRUNC */ - return( (long) 0); - - case _PC_VDISABLE: /* MINIX defines VDISABLE */ - return( (long) _POSIX_VDISABLE); - - default: - errno = EINVAL; - return(-1L); - } -} diff --git a/mach/minixST/libsys/pathconf.c b/mach/minixST/libsys/pathconf.c deleted file mode 100644 index c4476165e8..0000000000 --- a/mach/minixST/libsys/pathconf.c +++ /dev/null @@ -1,27 +0,0 @@ -/* POSIX pathconf (Sec. 5.7.1) Author: Andy Tanenbaum */ - -#include -#include -#define open _open -#include -#include -#define close _close - -PUBLIC long pathconf(path, name) -char *path; /* name of file being interrogated */ -int name; /* property being inspected */ -{ -/* POSIX allows some of the values in to be increased at - * run time. The pathconf and fpathconf functions allow these values - * to be checked at run time. MINIX does not use this facility. - * The run-time limits are those given in . - */ - - int fd; - long val; - - if ( (fd = open(path, O_RDONLY)) < 0) return(-1L); - val = fpathconf(fd, name); - close(fd); - return(val); -} diff --git a/mach/minixST/libsys/syslib.c b/mach/minixST/libsys/syslib.c deleted file mode 100644 index fe86f3b06b..0000000000 --- a/mach/minixST/libsys/syslib.c +++ /dev/null @@ -1,218 +0,0 @@ -#include -#include - -/*---------------------------------------------------------------------------- - Messages to systask (special calls) -----------------------------------------------------------------------------*/ -#if (CHIP == M68000) -PUBLIC _PROTOTYPE( void sys_xit, (int parent, int proc, - phys_clicks *basep, phys_clicks *sizep)); -#else -PUBLIC _PROTOTYPE( void sys_xit, (int parent, int proc)); -#endif -PUBLIC _PROTOTYPE( void sys_getsp, (int proc, vir_bytes *newsp)); -PUBLIC _PROTOTYPE( void sys_sig, (int proc, int sig, void (*sighandler)(int))); -#if (CHIP == M68000) -#ifdef ALCYON_C_BUG_FIXED -PUBLIC _PROTOTYPE( void sys_fork, (int prnt, int chld, int pd, phys_clicks shdw)); -#else -PUBLIC _PROTOTYPE( void sys_fork, (int parent, int child, int pid, int shadow)); -#endif -#else -PUBLIC _PROTOTYPE( void sys_fork, (int parent, int child, int pid)); -#endif -PUBLIC _PROTOTYPE( void sys_exec, (int proc, char *ptr, int traced)); -PUBLIC _PROTOTYPE( void sys_newmap, (int proc, char *ptr)); -PUBLIC _PROTOTYPE( void sys_copy, (message *mptr)); -PUBLIC _PROTOTYPE( void sys_times, (int proc, time_t ptr[4])); -PUBLIC _PROTOTYPE( void sys_abort, (void)); -#if (CHIP == M68000) -PUBLIC _PROTOTYPE( void sys_fresh, (int proc, char *ptr, phys_clicks dc, - phys_clicks *basep, phys_clicks *sizep)); -#endif -PUBLIC _PROTOTYPE( void sys_kill, (int proc, int sig)); -PUBLIC _PROTOTYPE( int sys_trace, (int req, int procnr, - long addr, long *data_p)); -PUBLIC _PROTOTYPE( void tell_fs, ( int what, int p1, int p2, int p3)); - - -#if (CHIP == M68000) -PUBLIC void sys_xit(parent, proc, basep, sizep) -phys_clicks *basep, *sizep; -#else -PUBLIC void sys_xit(parent, proc) -#endif -int parent; /* parent of exiting proc. */ -int proc; /* which proc has exited */ -{ -/* A proc has exited. Tell the kernel. */ - - _callm1(SYSTASK, SYS_XIT, parent, proc, 0, NIL_PTR, NIL_PTR, NIL_PTR); -#if (CHIP == M68000) - *basep = (phys_clicks) _M.m1_i1; - *sizep = (phys_clicks) _M.m1_i2; -#endif -} - - -PUBLIC void sys_getsp(proc, newsp) -int proc; /* which proc has enabled signals */ -vir_bytes *newsp; /* place to put sp read from kernel */ -{ -/* Ask the kernel what the sp is. */ - - - _callm1(SYSTASK, SYS_GETSP, proc, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); - *newsp = (vir_bytes) _M.STACK_PTR; -} - - -PUBLIC void sys_sig(proc, sig, sighandler) -int proc; /* which proc has exited */ -int sig; /* signal number: 1 - 16 */ -_PROTOTYPE(void (*sighandler), (int));/* pointer to signal handler in user space */ -{ -/* A proc has to be signaled. Tell the kernel. */ - - _M.m6_i1 = proc; - _M.m6_i2 = sig; - _M.m6_f1 = sighandler; - _callx(SYSTASK, SYS_SIG); -} - - -#if (CHIP == M68000) -PUBLIC void sys_fork(parent, child, pid, shadow) -#ifdef ALCYON_C_BUG_FIXED -phys_clicks shadow; /* memory allocated for shadow */ -#else -int shadow; -#endif -#else -PUBLIC void sys_fork(parent, child, pid) -#endif -int parent; /* proc doing the fork */ -int child; /* which proc has been created by the fork */ -int pid; /* process id assigned by MM */ -{ -/* A proc has forked. Tell the kernel. */ - -#if (CHIP == M68000) - _callm1(SYSTASK, SYS_FORK, parent, child, pid, (char *) shadow, NIL_PTR, NIL_PTR); -#else - _callm1(SYSTASK, SYS_FORK, parent, child, pid, NIL_PTR, NIL_PTR, NIL_PTR); -#endif -} - - -PUBLIC void sys_exec(proc, ptr, traced) -int proc; /* proc that did exec */ -char *ptr; /* new stack pointer */ -int traced; /* is tracing enabled? */ -{ -/* A proc has exec'd. Tell the kernel. */ - - _callm1(SYSTASK, SYS_EXEC, proc, traced, 0, ptr, NIL_PTR, NIL_PTR); -} - -PUBLIC void sys_newmap(proc, ptr) -int proc; /* proc whose map is to be changed */ -char *ptr; /* pointer to new map */ -{ -/* A proc has been assigned a new memory map. Tell the kernel. */ - - - _callm1(SYSTASK, SYS_NEWMAP, proc, 0, 0, ptr, NIL_PTR, NIL_PTR); -} - -PUBLIC void sys_copy(mptr) -message *mptr; /* pointer to message */ -{ -/* A proc wants to use local copy. */ - - /* Make this routine better. Also check other guys' error handling - * -DEBUG */ - mptr->m_type = SYS_COPY; - if (_sendrec(SYSTASK, mptr) != 0) panic("sys_copy can't send", NO_NUM); -} - -PUBLIC void sys_times(proc, ptr) -int proc; /* proc whose times are needed */ -time_t ptr[4]; /* pointer to time buffer */ -{ -/* Fetch the accounting info for a proc. */ - - _callm1(SYSTASK, SYS_TIMES, proc, 0, 0, (char *)ptr, NIL_PTR, NIL_PTR); - ptr[0] = _M.USER_TIME; - ptr[1] = _M.SYSTEM_TIME; - ptr[2] = _M.CHILD_UTIME; - ptr[3] = _M.CHILD_STIME; -} - - -PUBLIC void sys_abort() -{ -/* Something awful has happened. Abandon ship. */ - - _callm1(SYSTASK, SYS_ABORT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); -} - -#if (CHIP == M68000) -PUBLIC void sys_fresh(proc, ptr, dc, basep, sizep) -int proc; /* proc whose map is to be changed */ -char *ptr; /* pointer to new map */ -phys_clicks dc; /* size of initialized data */ -phys_clicks *basep, *sizep; /* base and size for free_mem() */ -{ -/* Create a fresh process image for exec(). Tell the kernel. */ - - _callm1(SYSTASK, SYS_FRESH, proc, (int) dc, 0, ptr, NIL_PTR, NIL_PTR); - *basep = (phys_clicks) _M.m1_i1; - *sizep = (phys_clicks) _M.m1_i2; -} - -#endif - - -PUBLIC void sys_kill(proc, sig) -int proc; /* which proc has exited */ -int sig; /* signal number: 1 - 16 */ -{ -/* A proc has to be signaled via MM. Tell the kernel. */ - - _M.m6_i1 = proc; - _M.m6_i2 = sig; - _callx(SYSTASK, SYS_KILL); -} - -PUBLIC int sys_trace(req, procnr, addr, data_p) -int req, procnr; -long addr, *data_p; -{ - int r; - - _M.m2_i1 = procnr; - _M.m2_i2 = req; - _M.m2_l1 = addr; - if (data_p) _M.m2_l2 = *data_p; - r = _callx(SYSTASK, SYS_TRACE); - if (data_p) *data_p = _M.m2_l2; - return(r); -} - -PUBLIC void tell_fs(what, p1, p2, p3) -int what, p1, p2, p3; -{ -/* This routine is only used by MM to inform FS of certain events: - * tell_fs(CHDIR, slot, dir, 0) - * tell_fs(EXEC, proc, 0, 0) - * tell_fs(EXIT, proc, 0, 0) - * tell_fs(FORK, parent, child, pid) - * tell_fs(SETGID, proc, realgid, effgid) - * tell_fs(SETUID, proc, realuid, effuid) - * tell_fs(SYNC, 0, 0, 0) - * tell_fs(UNPAUSE, proc, signr, 0) - * tell_fs(SETPGRP, proc, 0, 0) - */ - _callm1(FS, what, p1, p2, p3, NIL_PTR, NIL_PTR, NIL_PTR); -} diff --git a/mach/mips/as/mktables.lua b/mach/mips/as/mktables.lua index b6bbf1883f..0c548cc8fc 100755 --- a/mach/mips/as/mktables.lua +++ b/mach/mips/as/mktables.lua @@ -3,6 +3,8 @@ local args = {...} local words = {} local insns = {} +math.pow = math.pow or function(a, b) return a^b end + local function addword(word) local w = words[word] if not w then diff --git a/mach/proto/ncg/build.lua b/mach/proto/ncg/build.lua index f8d42ba56b..01312aec07 100644 --- a/mach/proto/ncg/build.lua +++ b/mach/proto/ncg/build.lua @@ -3,6 +3,7 @@ include("util/ncgg/build.lua") definerule("build_ncg", { arch = { type="string" }, + deps = { type="table", default={} }, }, function(e) -- Remember this is executed from the caller's directory; local @@ -22,12 +23,16 @@ definerule("build_ncg", "mach/proto/ncg/types.h", "mach/proto/ncg/xmach.h", "mach/"..e.arch.."/ncg+headers", - } + }, + vars = { + ["+cflags"] = { "-I." }, + }, } local tables = ncgg { name = e.name.."/tables", - srcs = { "mach/"..e.arch.."/ncg/table" } + srcs = { "mach/"..e.arch.."/ncg/table" }, + deps = e.deps } return cprogram { @@ -51,6 +56,9 @@ definerule("build_ncg", "mach/proto/ncg/var.c", matching(filenamesof(tables), "%.c$") }, + vars = { + ["+cflags"] = { "-I." }, + }, deps = { "h+emheaders", "modules+headers", diff --git a/plat/cpm/libsys/write.c b/plat/cpm/libsys/write.c index c741dc644a..0e74a0b41e 100644 --- a/plat/cpm/libsys/write.c +++ b/plat/cpm/libsys/write.c @@ -17,7 +17,7 @@ void _sys_write_tty(char c) cpm_conout(c); } -ssize_t write(int fd, void* buffer, size_t count) +ssize_t write(int fd, const void* buffer, size_t count) { const uint8_t* bbuffer = buffer; struct FCBE* fcbe = &__fd[fd]; diff --git a/plat/linux/libsys/write.c b/plat/linux/libsys/write.c index e0b9179874..a28d55897d 100644 --- a/plat/linux/libsys/write.c +++ b/plat/linux/libsys/write.c @@ -8,7 +8,7 @@ #include #include "libsys.h" -int write(int fd, void* buffer, size_t count) +int write(int fd, const void* buffer, size_t count) { return _syscall(__NR_write, fd, (quad) buffer, count); } diff --git a/plat/linux68k/build-tools.lua b/plat/linux68k/build-tools.lua index 03d659a15b..cda2a332cd 100644 --- a/plat/linux68k/build-tools.lua +++ b/plat/linux68k/build-tools.lua @@ -8,6 +8,9 @@ build_as { build_ncg { name = "ncg", arch = "m68020", + vars = { + ["+cflags"] = "-DWORD_SIZE=4 -DTBL68020=1 -DTBL68881=1" + } } return installable { diff --git a/plat/linuxppc/emu/mkdispatcher.lua b/plat/linuxppc/emu/mkdispatcher.lua index a660b8c344..7128b1fae4 100644 --- a/plat/linuxppc/emu/mkdispatcher.lua +++ b/plat/linuxppc/emu/mkdispatcher.lua @@ -1,3 +1,5 @@ +math.pow = math.pow or function(a, b) return a^b end + local function decode(line) local _, _, bits = line:find("^([^ ]+) ") if #bits ~= 32 then diff --git a/plat/minix/include/ack/fcntl.h b/plat/minix/include/ack/fcntl.h new file mode 100644 index 0000000000..6ecc5300ab --- /dev/null +++ b/plat/minix/include/ack/fcntl.h @@ -0,0 +1,97 @@ +/* The header is needed by the open() and fcntl() system calls, + * which have a variety of parameters and flags. They are described here. + * The formats of the calls to each of these are: + * + * open(path, oflag [,mode]) open a file + * fcntl(fd, cmd [,arg]) get or set file attributes + * + */ + +#ifndef _ACK_FCNTL_H +#define _ACK_FCNTL_H + +#include + +/* These values are used for cmd in fcntl(). POSIX Table 6-1. */ +#define F_DUPFD 0 /* duplicate file descriptor */ +#define F_GETFD 1 /* get file descriptor flags */ +#define F_SETFD 2 /* set file descriptor flags */ +#define F_GETFL 3 /* get file status flags */ +#define F_SETFL 4 /* set file status flags */ +#define F_GETLK 5 /* get record locking information */ +#define F_SETLK 6 /* set record locking information */ +#define F_SETLKW 7 /* set record locking info; wait if blocked */ + +/* File descriptor flags used for fcntl(). POSIX Table 6-2. */ +#define FD_CLOEXEC 1 /* close on exec flag for third arg of fcntl */ + +/* L_type values for record locking with fcntl(). POSIX Table 6-3. */ +#define F_RDLCK 0 /* shared or read lock */ +#define F_WRLCK 1 /* exclusive or write lock */ +#define F_UNLCK 2 /* unlock */ + +/* Oflag values for open(). POSIX Table 6-4. */ +#define O_CREAT 00100 /* creat file if it doesn't exist */ +#define O_EXCL 00200 /* exclusive use flag */ +#define O_NOCTTY 00400 /* do not assign a controlling terminal */ +#define O_TRUNC 01000 /* truncate flag */ + +/* File status flags for open() and fcntl(). POSIX Table 6-5. */ +#define O_APPEND 02000 /* set append mode */ +#define O_NONBLOCK 04000 /* no delay */ + +/* File access modes for open() and fcntl(). POSIX Table 6-6. */ +#define O_RDONLY 0 /* open(name, O_RDONLY) opens read only */ +#define O_WRONLY 1 /* open(name, O_WRONLY) opens write only */ +#define O_RDWR 2 /* open(name, O_RDWR) opens read/write */ + +/* Mask for use with file access modes. POSIX Table 6-7. */ +#define O_ACCMODE 03 /* mask for file access modes */ + +/* Struct used for locking. POSIX Table 6-8. */ +struct flock +{ + short l_type; /* type: F_RDLCK, F_WRLCK, or F_UNLCK */ + short l_whence; /* flag for starting offset */ + off_t l_start; /* relative offset in bytes */ + off_t l_len; /* size; if 0, then until EOF */ + pid_t l_pid; /* process id of the locks' owner */ +}; + +/* The following relate to configurable system variables. POSIX Table 4-2. */ +#define _SC_ARG_MAX 1 +#define _SC_CHILD_MAX 2 +#define _SC_CLOCKS_PER_SEC 3 +#define _SC_NGROUPS_MAX 4 +#define _SC_OPEN_MAX 5 +#define _SC_JOB_CONTROL 6 +#define _SC_SAVED_IDS 7 +#define _SC_VERSION 8 + +/* The following relate to configurable pathname variables. POSIX Table 5-2. */ +#define _PC_LINK_MAX 1 /* link count */ +#define _PC_MAX_CANON 2 /* size of the canonical input queue */ +#define _PC_MAX_INPUT 3 /* type-ahead buffer size */ +#define _PC_NAME_MAX 4 /* file name size */ +#define _PC_PATH_MAX 5 /* pathname size */ +#define _PC_PIPE_BUF 6 /* pipe size */ +#define _PC_NO_TRUNC 7 /* treatment of long name components */ +#define _PC_VDISABLE 8 /* tty disable */ +#define _PC_CHOWN_RESTRICTED 9 /* chown restricted or not */ + +/* POSIX defines several options that may be implemented or not, at the + * implementer's whim. This implementer has made the following choices: + * + * _POSIX_JOB_CONTROL not defined: no job control + * _POSIX_SAVED_IDS not defined: no saved uid/gid + * _POSIX_NO_TRUNC not defined: long path names are truncated + * _POSIX_CHOWN_RESTRICTED defined: you can't give away files + * _POSIX_VDISABLE defined: tty functions can be disabled + */ +#define _POSIX_CHOWN_RESTRICTED +#define _POSIX_VDISABLE '\t' /* can't set any control char to tab */ + +extern long fpathconf(int fd, int name); +extern long pathconf(const char* path, int name); + +#endif /* _FCNTL_H */ diff --git a/plat/minix/include/ack/limits.h b/plat/minix/include/ack/limits.h new file mode 100644 index 0000000000..57345d6a07 --- /dev/null +++ b/plat/minix/include/ack/limits.h @@ -0,0 +1,39 @@ +/* The header defines some basic sizes, both of the language types + * (e.g., the number of bits in an integer), and of the operating system (e.g. + * the number of characters in a file name. + */ + +#ifndef _ACK_LIMITS_H +#define _ACK_LIMITS_H + +/* Minimum sizes required by the POSIX P1003.1 standard (Table 2-2). */ +#ifdef _POSIX_SOURCE /* these are only visible for POSIX */ +#define _POSIX_ARG_MAX 4096 /* exec() may have 4K worth of args */ +#define _POSIX_CHILD_MAX 6 /* a process may have 6 children */ +#define _POSIX_LINK_MAX 8 /* a file may have 8 links */ +#define _POSIX_MAX_CANON 255 /* size of the canonical input queue */ +#define _POSIX_MAX_INPUT 255 /* you can type 255 chars ahead */ +#define _POSIX_NAME_MAX 14 /* a file name may have 14 chars */ +#define _POSIX_NGROUPS_MAX 0 /* supplementary group IDs are optional */ +#define _POSIX_OPEN_MAX 16 /* a process may have 16 files open */ +#define _POSIX_PATH_MAX 255 /* a pathname may contain 255 chars */ +#define _POSIX_PIPE_BUF 512 /* pipes writes of 512 bytes must be atomic */ + +/* Values actually implemented by MINIX (Tables 2-3, 2-4, and 2-5). */ +/* Some of these old names had better be defined when not POSIX. */ +#define _NO_LIMIT 100 /* arbitrary number; limit not enforced */ + +#define NGROUPS_MAX 0 /* supplemental group IDs not available */ +#define ARG_MAX 4096 /* # bytes of args + environ for exec() */ +#define CHILD_MAX _NO_LIMIT /* MINIX does not limit children */ +#define OPEN_MAX 20 /* # open files a process may have */ +#define LINK_MAX 127 /* # links a file may have */ +#define MAX_CANON 255 /* size of the canonical input queue */ +#define MAX_INPUT 255 /* size of the type-ahead buffer */ +#define NAME_MAX 14 /* # chars in a file name */ +#define PATH_MAX 255 /* # chars in a path name */ +#define PIPE_BUF 7168 /* # bytes in atomic write to a pipe */ + +#endif /* _POSIX_SOURCE */ + +#endif diff --git a/plat/minix/include/ack/signal.h b/plat/minix/include/ack/signal.h new file mode 100644 index 0000000000..24f9afd57c --- /dev/null +++ b/plat/minix/include/ack/signal.h @@ -0,0 +1,92 @@ +/* The header defines all the ANSI and POSIX signals. + * MINIX supports all the signals required by POSIX. They are defined below. + * Some additional signals are also supported. + */ + +#ifndef _ACK_SIGNAL_H +#define _ACK_SIGNAL_H + +#include + +/* Here are types that are closely associated with signal handling. */ +typedef int sig_atomic_t; + +#ifdef _POSIX_SOURCE +typedef unsigned short sigset_t; +#endif + +#define _NSIG 16 /* number of signals used */ + +#define SIGHUP 1 /* hangup */ +#define SIGINT 2 /* interrupt (DEL) */ +#define SIGQUIT 3 /* quit (ASCII FS) */ +#define SIGILL 4 /* illegal instruction */ +#define SIGTRAP 5 /* trace trap (not reset when caught) */ +#define SIGABRT 6 /* IOT instruction */ +#define SIGIOT 6 /* SIGABRT for people who speak PDP-11 */ +#define SIGUNUSED 7 /* spare code */ +#define SIGFPE 8 /* floating point exception */ +#define SIGKILL 9 /* kill (cannot be caught or ignored) */ +#define SIGUSR1 10 /* user defined signal # 1 */ +#define SIGSEGV 11 /* segmentation violation */ +#define SIGUSR2 12 /* user defined signal # 2 */ +#define SIGSYS 12 /* the usual UNIX name for this signal num */ +#define SIGPIPE 13 /* write on a pipe with no one to read it */ +#define SIGALRM 14 /* alarm clock */ +#define SIGTERM 15 /* software termination signal from kill */ +#define SIGSTKFLT 16 /* used by kernel to indicate stack fault */ + +#define SIGEMT 7 /* obsolete */ +#define SIGBUS 10 /* obsolete */ + +/* POSIX requires the following signals to be defined, even if they are + * not supported. Here are the definitions, but they are not supported. + */ +#define SIGCHLD 17 /* child process terminated or stopped */ +#define SIGCONT 18 /* continue if stopped */ +#define SIGSTOP 19 /* stop signal */ +#define SIGTSTP 20 /* interactive stop signal */ +#define SIGTTIN 21 /* background process wants to read */ +#define SIGTTOU 22 /* background process wants to write */ + +#ifdef _POSIX_SOURCE +#define SA_NOCLDSTOP 1 /* signal parent if child stops */ + +#endif /* _POSIX_SOURCE */ + +/* POSIX requires these values for use on system calls involving signals. */ +#define SIG_BLOCK 0 /* for blocking signals */ +#define SIG_UNBLOCK 1 /* for unblocking signals */ +#define SIG_SETMASK 2 /* for setting the signal mask */ + +#ifndef _ANSI_H +#include +#endif + +/* Macros used as function pointers and one awful prototype. */ +#define SIG_DFL ((void (*)(int))0) /* default signal handling */ +#define SIG_IGN ((void (*)(int))1) /* ignore signal */ +#define SIG_ERR ((void (*)(int)) - 1) + +void (*signal(int _sig, void (*_func)(int)))(int); + +#ifdef _POSIX_SOURCE +struct sigaction +{ + void (*sa_handler)(int); /* SIG_DFL, SIG_IGN, or pointer to function */ + sigset_t sa_mask; /* signals to be blocked during handler */ + int sa_flags; /* special flags */ +}; +#endif + +#ifdef _POSIX_SOURCE +_PROTOTYPE(int sigaddset, (sigset_t * _set)); +_PROTOTYPE(int sigdelset, (sigset_t * _set)); +_PROTOTYPE(int sigemptyset, (sigset_t * _set)); +_PROTOTYPE(int sigfillset, (sigset_t * _set)); +_PROTOTYPE(int sigismember, (sigset_t * _set, int _signo)); +_PROTOTYPE(int sigpending, (sigset_t * set)); +_PROTOTYPE(int sigsuspend, (sigset_t * _sigmask)); +#endif + +#endif /* _SIGNAL_H */ diff --git a/lib/minix/include/ansi.h b/plat/minix/include/ansi.h similarity index 57% rename from lib/minix/include/ansi.h rename to plat/minix/include/ansi.h index afe164bc68..cd6ece2729 100644 --- a/lib/minix/include/ansi.h +++ b/plat/minix/include/ansi.h @@ -1,11 +1,11 @@ /* The header checks whether the compiler claims conformance to ANSI - * Standard C. If so, the symbol _ANSI is defined as 1, otherwise it is + * Standard C. If so, the symbol _ANSI is defined as 1, otherwise it is * defined as 0. Based on the result, a macro * * _PROTOTYPE(function, params) * * is defined. This macro expands in different ways, generating either - * ANSI Standard C prototypes or old-style K&R (Kernighan & Ritchie) + * ANSI Standard C prototypes or old-style K&R (Kernighan & Ritchie) * prototypes, as needed. Finally, some programs use _CONST, _VOIDSTAR etc * in such a way that they are portable over both ANSI and K&R compilers. * The appropriate macros are defined here. @@ -18,12 +18,12 @@ * Some half-ANSI compilers define it as 0. Get around this here. */ -#define _ANSI 0 /* 0 if compiler is not ANSI C, 1 if it is */ +#define _ANSI 0 /* 0 if compiler is not ANSI C, 1 if it is */ -#ifdef __STDC__ /* __STDC__ defined for (near) ANSI compilers*/ -#if __STDC__ == 1 /* __STDC__ == 1 for conformant compilers */ -#undef _ANSI /* get rid of above definition */ -#define _ANSI 1 /* _ANSI = 1 for ANSI C compilers */ +#ifdef __STDC__ /* __STDC__ defined for (near) ANSI compilers*/ +#if __STDC__ == 1 /* __STDC__ == 1 for conformant compilers */ +#undef _ANSI /* get rid of above definition */ +#define _ANSI 1 /* _ANSI = 1 for ANSI C compilers */ #endif #endif @@ -33,21 +33,21 @@ */ #if _ANSI -#define _PROTOTYPE(function, params) function params -#define _VOIDSTAR void * -#define _VOID void -#define _CONST const -#define _VOLATILE volatile -#define _SIZET size_t +#define _PROTOTYPE(function, params) function params +#define _VOIDSTAR void* +#define _VOID void +#define _CONST const +#define _VOLATILE volatile +#define _SIZET size_t #else -#define _PROTOTYPE(function, params) function() -#define _VOIDSTAR void * -#define _VOID void -#define _CONST -#define _VOLATILE -#define _SIZET int +#define _PROTOTYPE(function, params) function() +#define _VOIDSTAR void* +#define _VOID void +#define _CONST +#define _VOLATILE +#define _SIZET int #endif /* _ANSI */ diff --git a/plat/minix/include/build.lua b/plat/minix/include/build.lua new file mode 100644 index 0000000000..54138b3417 --- /dev/null +++ b/plat/minix/include/build.lua @@ -0,0 +1,36 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "plat/minix/include/"..h + packagemap["$(PLATIND)/minix/include/"..h] = "plat/minix/include/"..h +end + +-- addheader("unistd.h") +addheader("ansi.h") +addheader("ack/fcntl.h") +addheader("ack/signal.h") +addheader("ack/limits.h") +addheader("minix/callnr.h") +addheader("minix/const.h") +addheader("minix/type.h") +addheader("minix/com.h") +addheader("utime.h") +addheader("sgtty.h") +addheader("sys/dir.h") +addheader("sys/types.h") +addheader("sys/errno.h") +addheader("sys/stat.h") +addheader("sys/wait.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} diff --git a/plat/minix/include/minix/callnr.h b/plat/minix/include/minix/callnr.h new file mode 100644 index 0000000000..85f0e8162f --- /dev/null +++ b/plat/minix/include/minix/callnr.h @@ -0,0 +1,58 @@ +#define NCALLS 70 /* number of system calls allowed */ + +#define EXIT 1 +#define FORK 2 +#define READ 3 +#define WRITE 4 +#define OPEN 5 +#define CLOSE 6 +#define WAIT 7 +#define CREAT 8 +#define LINK 9 +#define UNLINK 10 +#define CHDIR 12 +#define TIME 13 +#define MKNOD 14 +#define CHMOD 15 +#define CHOWN 16 +#define BRK 17 +#define STAT 18 +#define LSEEK 19 +#define GETPID 20 +#define MOUNT 21 +#define UMOUNT 22 +#define SETUID 23 +#define GETUID 24 +#define STIME 25 +#define PTRACE 26 +#define ALARM 27 +#define FSTAT 28 +#define PAUSE 29 +#define UTIME 30 +#define ACCESS 33 +#define SYNC 36 +#define KILL 37 +#define RENAME 38 +#define MKDIR 39 +#define RMDIR 40 +#define DUP 41 +#define PIPE 42 +#define TIMES 43 +#define SETGID 46 +#define GETGID 47 +#define SIGNAL 48 +#define IOCTL 54 +#define FCNTL 55 +#define EXEC 59 +#define UMASK 60 +#define CHROOT 61 + +/* The following are not system calls, but are processed like them. */ +#define KSIG 64 /* kernel detected a signal */ +#define UNPAUSE 65 /* to MM or FS: check for EINTR */ +#define BRK2 66 /* to MM: used to say how big FS & INIT are */ +#define REVIVE 67 /* to FS: revive a sleeping process */ +#define TASK_REPLY 68 /* to FS: reply code from tty task */ + +/* The following IS a system call for amoeba transactions */ +#define AM_SYSCALL 69 diff --git a/plat/minix/include/minix/com.h b/plat/minix/include/minix/com.h new file mode 100644 index 0000000000..189c0f0f3e --- /dev/null +++ b/plat/minix/include/minix/com.h @@ -0,0 +1,166 @@ +/* System calls. */ +#define SEND 1 /* function code for sending messages */ +#define RECEIVE 2 /* function code for receiving messages */ +#define BOTH 3 /* function code for SEND + RECEIVE */ +#define ANY (NR_PROCS + 100) /* receive(ANY, buf) accepts from any source */ + +/* Task numbers, function codes and reply codes. */ + +#define TTY -NR_TASKS /* terminal I/O class */ +#define TTY_READ 3 /* fcn code for reading from tty */ +#define TTY_WRITE 4 /* fcn code for writing to tty */ +#define TTY_IOCTL 5 /* fcn code for ioctl */ +#define TTY_SETPGRP 6 /* fcn code for setpgrp */ +#define TTY_OPEN 7 /* fcn code for opening tty */ +#define TTY_CLOSE 8 /* fcn code for closing tty */ +#define SUSPEND -998 /* used in interrupts when tty has no data */ + +#ifdef AM_KERNEL +#define AMOEBA +#endif + +#ifdef AMOEBA + +/* There are AM_NTASK copies of the amoeba kernel task. + * If you change AM_NTASKS be sure to adjust kernel/table.c and fs/table.c + */ +#define AM_NTASKS 4 /* number of kernel tasks of this class */ + +#define AMINT_CLASS (TTY + 1) /* Amoeba event handler */ +#define AMOEBA_CLASS (AMINT_CLASS + AM_NTASKS) /* transaction handlers */ +#define ETHER_ARRIV 1 /* fcn code for packet arrival */ +#define AM_TRANS 2 /* amoeba transaction */ +#define AM_GETREQ 3 /* amoeba getrequest */ +#define AM_PUTREP 4 /* amoeba putrep */ +#define AM_REVIVE 6 /* used by kernel task to revive luser task */ +#define AM_TIMEOUT 8 /* used to talk to clock task */ +#define AM_PUTSIG 9 /* when the luser hits the DEL ! */ +#define AM_TASK_DIED 10 /* sent if task died during a transaction */ + +#else /* if AMOEBA not defined */ + +#define AMOEBA_CLASS TTY + +#endif /* AMOEBA */ + +/* + * New class definitions should go here and should be defined relative + * to AMOEBA_CLASS (ie. as AMOEBA_CLASS+n, for the nth task added). + */ + +#define IDLE (AMOEBA_CLASS + 1) /* task to run when there's nothing to run */ + +#define PRINTER -7 /* printer I/O class */ +/* The printer uses the same commands as TTY. */ + +#define WINCHESTER -6 /* winchester (hard) disk class */ +#define FLOPPY -5 /* floppy disk class */ +#define DISK_READ 3 /* fcn code to DISK (must equal TTY_READ) */ +#define DISK_WRITE 4 /* fcn code to DISK (must equal TTY_WRITE) */ +#define DISK_IOCTL 5 /* fcn code for setting up RAM disk */ +#define SCATTERED_IO 6 /* fcn code for multiple reads/writes */ +#define OPTIONAL_IO 16 /* modifier to DISK_* codes within vector */ + +#define MEM -4 /* /dev/ram, /dev/(k)mem and /dev/null class */ +#define RAM_DEV 0 /* minor device for /dev/ram */ +#define MEM_DEV 1 /* minor device for /dev/mem */ +#define KMEM_DEV 2 /* minor device for /dev/kmem */ +#define NULL_DEV 3 /* minor device for /dev/null */ +#if (CHIP == INTEL) +#define PORT_DEV 4 /* minor device for /dev/port */ +#endif + +#define CLOCK -3 /* clock class */ +#define SET_ALARM 1 /* fcn code to CLOCK, set up alarm */ +#define GET_TIME 3 /* fcn code to CLOCK, get real time */ +#define SET_TIME 4 /* fcn code to CLOCK, set real time */ +#define REAL_TIME 1 /* reply from CLOCK: here is real time */ + +#define SYSTASK -2 /* internal functions */ +#define SYS_XIT 1 /* fcn code for sys_xit(parent, proc) */ +#define SYS_GETSP 2 /* fcn code for sys_sp(proc, &new_sp) */ +#define SYS_SIG 3 /* fcn code for sys_sig(proc, sig) */ +#define SYS_FORK 4 /* fcn code for sys_fork(parent, child) */ +#define SYS_NEWMAP 5 /* fcn code for sys_newmap(procno, map_ptr) */ +#define SYS_COPY 6 /* fcn code for sys_copy(ptr) */ +#define SYS_EXEC 7 /* fcn code for sys_exec(procno, new_sp) */ +#define SYS_TIMES 8 /* fcn code for sys_times(procno, bufptr) */ +#define SYS_ABORT 9 /* fcn code for sys_abort() */ +#define SYS_FRESH 10 /* fcn code for sys_fresh() (Atari only) */ +#define SYS_KILL 11 /* fcn code for sys_kill(proc, sig) */ +#define SYS_GBOOT 12 /* fcn code for sys_gboot(procno, bootptr) */ +#define SYS_UMAP 13 /* fcn code for sys_umap(procno, etc) */ +#define SYS_MEM 14 /* fcn code for sys_mem() */ +#define SYS_TRACE 15 /* fcn code for sys_trace(req,pid,addr,data) */ + +#define HARDWARE -1 /* used as source on interrupt generated msgs*/ + +/* Names of message fields for messages to CLOCK task. */ +#define DELTA_TICKS m6_l1 /* alarm interval in clock ticks */ +#define FUNC_TO_CALL m6_f1 /* pointer to function to call */ +#define NEW_TIME m6_l1 /* value to set clock to (SET_TIME) */ +#define CLOCK_PROC_NR m6_i1 /* which proc (or task) wants the alarm? */ +#define SECONDS_LEFT m6_l1 /* how many seconds were remaining */ + +/* Names of message fields used for messages to block and character tasks. */ +#define DEVICE m2_i1 /* major-minor device */ +#define PROC_NR m2_i2 /* which (proc) wants I/O? */ +#define COUNT m2_i3 /* how many bytes to transfer */ +#define POSITION m2_l1 /* file offset */ +#define ADDRESS m2_p1 /* core buffer address */ + +/* Names of message fields for messages to TTY task. */ +#define TTY_LINE m2_i1 /* message parameter: terminal line */ +#define TTY_REQUEST m2_i3 /* message parameter: ioctl request code */ +#define TTY_SPEK m2_l1 /* message parameter: ioctl speed, erasing */ +#define TTY_FLAGS m2_l2 /* message parameter: ioctl tty mode */ +#define TTY_PGRP m2_i3 /* message parameter: process group */ + +/* Names of messages fields used in reply messages from tasks. */ +#define REP_PROC_NR m2_i1 /* # of proc on whose behalf I/O was done */ +#define REP_STATUS m2_i2 /* bytes transferred or error number */ + +/* Names of fields for copy message to SYSTASK. */ +#define SRC_SPACE m5_c1 /* T or D space (stack is also D) */ +#define SRC_PROC_NR m5_i1 /* process to copy from */ +#define SRC_BUFFER m5_l1 /* virtual address where data come from */ +#define DST_SPACE m5_c2 /* T or D space (stack is also D) */ +#define DST_PROC_NR m5_i2 /* process to copy to */ +#define DST_BUFFER m5_l2 /* virtual address where data go to */ +#define COPY_BYTES m5_l3 /* number of bytes to copy */ + +/* Field names for accounting, SYSTASK and miscellaneous. */ +#define USER_TIME m4_l1 /* user time consumed by process */ +#define SYSTEM_TIME m4_l2 /* system time consumed by process */ +#define CHILD_UTIME m4_l3 /* user time consumed by process' children */ +#define CHILD_STIME m4_l4 /* sys time consumed by process' children */ + +#define PROC1 m1_i1 /* indicates a process */ +#define PROC2 m1_i2 /* indicates a process */ +#define PID m1_i3 /* process id passed from MM to kernel */ +#define STACK_PTR m1_p1 /* used for stack ptr in sys_exec, sys_getsp */ +#define PR m6_i1 /* process number for sys_sig */ +#define SIGNUM m6_i2 /* signal number for sys_sig */ +#define FUNC m6_f1 /* function pointer for sys_sig */ +#define MEM_PTR m1_p1 /* tells where memory map is for sys_newmap */ +#define CANCEL 0 /* general request to force a task to cancel */ +#define SIG_MAP m1_i2 /* used by kernel for passing signal bit map */ + +#ifdef AMOEBA + +/* Names of message fields for amoeba tasks */ +#define AM_OP m2_i1 /* one of the above operators */ +#define AM_PROC_NR m2_i2 /* process # of proc doing operation */ +#define AM_COUNT m2_i3 /* size of buffer for operation */ +#define AM_ADDRESS m2_p1 /* address of buffer for operation */ + +/* For communication between MM and AMOEBA_CLASS kernel tasks */ +#define AM_STATUS m2_i3 /* same use as REP_STATUS but for amoeba */ +#define AM_FREE_IT m2_l1 /* 1=not a getreq, 0=is a getreq */ + +/* Special for passing a physical address from the ethernet driver */ +#define AM_PADDR m2_l1 /* to the transaction layer */ + +#endif /* AMOEBA */ + +#define HARD_INT 2 /* fcn code for all hardware interrupts */ diff --git a/plat/minix/include/minix/const.h b/plat/minix/include/minix/const.h new file mode 100644 index 0000000000..791d6064f3 --- /dev/null +++ b/plat/minix/include/minix/const.h @@ -0,0 +1,87 @@ +/* Copyright (C) 1990 by Prentice-Hall, Inc. Permission is hereby granted + * to redistribute the binary and source programs of this system for + * educational or research purposes. For other use, written permission from + * Prentice-Hall is required. + */ + +#define EXTERN extern /* used in *.h files */ +#define static static /* static x limits the scope of x */ +#define PUBLIC /* PUBLIC is the opposite of static */ +#define FORWARD static /* some compilers require this to be 'static'*/ + +#define TRUE 1 /* used for turning integers into Booleans */ +#define FALSE 0 /* used for turning integers into Booleans */ + +#define HZ 60 /* clock freq (software settable on IBM-PC) */ +#define BLOCK_SIZE 1024 /* # bytes in a disk block */ +#define SUPER_USER (uid_t)0 /* uid_t of superuser */ + +#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */ +#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */ + +#ifdef AM_KERNEL +#define NR_TASKS 14 /* must be 5 more than without amoeba */ +#else +#define NR_TASKS 9 /* number of tasks in the transfer vector */ +#endif + +#define NR_PROCS 32 /* number of slots in proc table */ +#define NR_SEGS 3 /* # segments per process */ +#define T 0 /* proc[i].mem_map[T] is for text */ +#define D 1 /* proc[i].mem_map[D] is for data */ +#define S 2 /* proc[i].mem_map[S] is for stack */ + +#define MAX_P_LONG 2147483647 /* maximum positive long, i.e. 2**31 - 1 */ + +/* Memory is allocated in clicks. */ +#if (CHIP == INTEL) || (CHIP == M68000) +#define CLICK_SIZE 256 /* unit in which memory is allocated */ +#define CLICK_SHIFT 8 /* log2 of CLICK_SIZE */ +#endif + +#define click_to_round_k(n) ((unsigned)((((unsigned long)(n) << CLICK_SHIFT) + 512) / 1024)) +#if CLICK_SIZE < 1024 +#define k_to_click(n) ((n) * (1024 / CLICK_SIZE)) +#else +#define k_to_click(n) ((n) / (CLICK_SIZE / 1024)) +#endif + +/* Process numbers of some important processes */ +#define MM_PROC_NR 0 /* process number of memory manager */ +#define FS_PROC_NR 1 /* process number of file system */ +#define INIT_PROC_NR 2 /* init -- the process that goes multiuser */ +#define LOW_USER 2 /* first user not part of operating system */ + +/* Miscellaneous */ +#define BYTE 0377 /* mask for 8 bits */ +#define TO_USER 0 /* flag telling to copy from fs to user */ +#define FROM_USER 1 /* flag telling to copy from user to fs */ +#define READING 0 /* copy data to user */ +#define WRITING 1 /* copy data from user */ + +#if (MACHINE != ATARI) +#define ABS -999 /* this process means absolute memory */ +#endif + +#define WORD_SIZE 2 /* number of bytes per word */ + +#define NIL_PTR (char*)0 /* generally useful expression */ + +#define NO_NUM 0x8000 /* used as numerical argument to panic() */ +#define SIG_PUSH_BYTES (4 * sizeof(int)) /* how many bytes pushed by signal */ + +/* Flag bits for i_mode in the inode. */ +#define I_TYPE 0170000 /* this field gives inode type */ +#define I_REGULAR 0100000 /* regular file, not dir or special */ +#define I_BLOCK_SPECIAL 0060000 /* block special file */ +#define I_DIRECTORY 0040000 /* file is a directory */ +#define I_CHAR_SPECIAL 0020000 /* character special file */ +#define I_NAMED_PIPE 0010000 /* named pipe (FIFO) */ +#define I_SET_UID_BIT 0004000 /* set effective uid_t on exec */ +#define I_SET_GID_BIT 0002000 /* set effective gid_t on exec */ +#define ALL_MODES 0006777 /* all bits for user, group and others */ +#define RWX_MODES 0000777 /* mode bits for RWX only */ +#define R_BIT 0000004 /* Rwx protection bit */ +#define W_BIT 0000002 /* rWx protection bit */ +#define X_BIT 0000001 /* rwX protection bit */ +#define I_NOT_ALLOC 0000000 /* this inode is free */ diff --git a/plat/minix/include/minix/type.h b/plat/minix/include/minix/type.h new file mode 100644 index 0000000000..b87adafa49 --- /dev/null +++ b/plat/minix/include/minix/type.h @@ -0,0 +1,170 @@ +#ifndef _TYPE_H +#define _TYPE_H +/* Macros */ +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +/* Type definitions */ +typedef unsigned short unshort; /* must be 16-bit unsigned */ +typedef unshort block_nr; /* block number */ +typedef unshort zone_nr; /* zone number */ + +#define MAX_BLOCK_NR ((block_nr)0177777) /* largest block number */ +#define HIGHEST_ZONE ((zone_nr)0177777) /* largest zone number */ +#define MAX_INODE_NR ((ino_t 0177777) /* largest inode number */ +#define MAX_FILE_POS 017777777777L /* largest legal file offset */ + +#define NO_BLOCK ((block_nr)0) /* absence of a block number */ +#define NO_ENTRY ((ino_t)0) /* absence of a dir entry */ +#define NO_ZONE ((zone_nr)0) /* absence of a zone number */ +#define NO_DEV ((dev_t)~0) /* absence of a device numb */ + +typedef unshort bit_nr; /* if ino_t & zone_nr both unshort, + then also unshort, else long */ +typedef long zone_type; /* zone size */ + +#if (CHIP == INTEL) +typedef unsigned vir_bytes; /* virtual addresses and lengths in bytes */ +#endif + +#if (CHIP == M68000) +typedef long vir_bytes; /* virtual addresses and lengths in bytes */ +#endif + +typedef unsigned vir_clicks; /* virtual addresses and lengths in clicks */ +typedef long phys_bytes; /* physical addresses and lengths in bytes */ +typedef unsigned phys_clicks; /* physical addresses and lengths in clicks */ +typedef int signed_clicks; /* same length as phys_clicks, but signed */ + +/* Types relating to messages. */ +#define M1 1 +#define M3 3 +#define M4 4 +#define M3_STRING 14 + +typedef struct +{ + int m1i1, m1i2, m1i3; + char *m1p1, *m1p2, *m1p3; +} mess_1; +typedef struct +{ + int m2i1, m2i2, m2i3; + long m2l1, m2l2; + char* m2p1; +} mess_2; +typedef struct +{ + int m3i1, m3i2; + char* m3p1; + char m3ca1[M3_STRING]; +} mess_3; +typedef struct +{ + long m4l1, m4l2, m4l3, m4l4; +} mess_4; +typedef struct +{ + char m5c1, m5c2; + int m5i1, m5i2; + long m5l1, m5l2, m5l3; +} mess_5; +#if _ANSI +typedef struct +{ + int m6i1, m6i2, m6i3; + long m6l1; + void (*m6f1)(int); +} mess_6; +#else +typedef struct +{ + int m6i1, m6i2, m6i3; + long m6l1; + void (*m6f1)(); +} mess_6; +#endif + +typedef struct +{ + int m_source; /* who sent the message */ + int m_type; /* what kind of message is it */ + union + { + mess_1 m_m1; + mess_2 m_m2; + mess_3 m_m3; + mess_4 m_m4; + mess_5 m_m5; + mess_6 m_m6; + } m_u; +} message; + +#define MESS_SIZE (sizeof(message)) +#define NIL_MESS (message*)0 + +/* The following defines provide names for useful members. */ +#define m1_i1 m_u.m_m1.m1i1 +#define m1_i2 m_u.m_m1.m1i2 +#define m1_i3 m_u.m_m1.m1i3 +#define m1_p1 m_u.m_m1.m1p1 +#define m1_p2 m_u.m_m1.m1p2 +#define m1_p3 m_u.m_m1.m1p3 + +#define m2_i1 m_u.m_m2.m2i1 +#define m2_i2 m_u.m_m2.m2i2 +#define m2_i3 m_u.m_m2.m2i3 +#define m2_l1 m_u.m_m2.m2l1 +#define m2_l2 m_u.m_m2.m2l2 +#define m2_p1 m_u.m_m2.m2p1 + +#define m3_i1 m_u.m_m3.m3i1 +#define m3_i2 m_u.m_m3.m3i2 +#define m3_p1 m_u.m_m3.m3p1 +#define m3_ca1 m_u.m_m3.m3ca1 + +#define m4_l1 m_u.m_m4.m4l1 +#define m4_l2 m_u.m_m4.m4l2 +#define m4_l3 m_u.m_m4.m4l3 +#define m4_l4 m_u.m_m4.m4l4 + +#define m5_c1 m_u.m_m5.m5c1 +#define m5_c2 m_u.m_m5.m5c2 +#define m5_i1 m_u.m_m5.m5i1 +#define m5_i2 m_u.m_m5.m5i2 +#define m5_l1 m_u.m_m5.m5l1 +#define m5_l2 m_u.m_m5.m5l2 +#define m5_l3 m_u.m_m5.m5l3 + +#define m6_i1 m_u.m_m6.m6i1 +#define m6_i2 m_u.m_m6.m6i2 +#define m6_i3 m_u.m_m6.m6i3 +#define m6_l1 m_u.m_m6.m6l1 +#define m6_f1 m_u.m_m6.m6f1 + +struct mem_map +{ + vir_clicks mem_vir; /* virtual address */ + phys_clicks mem_phys; /* physical address */ + vir_clicks mem_len; /* length */ +}; + +struct copy_info +{ /* used by sys_copy(src, dst, bytes) */ + int cp_src_proc; + int cp_src_space; + vir_bytes cp_src_vir; + int cp_dst_proc; + int cp_dst_space; + vir_bytes cp_dst_vir; + vir_bytes cp_bytes; +}; + +struct iorequest_s +{ + long io_position; /* position in device file (really off_t) */ + char* io_buf; /* buffer in user space */ + unsigned short io_nbytes; /* size of request */ + unsigned short io_request; /* read, write (optionally) */ +}; +#endif /* _TYPE_H */ diff --git a/plat/minix/include/sgtty.h b/plat/minix/include/sgtty.h new file mode 100644 index 0000000000..d54da1c80c --- /dev/null +++ b/plat/minix/include/sgtty.h @@ -0,0 +1,98 @@ +/* The header contains data structures for ioctl(). */ + +#ifndef _SGTTY_H +#define _SGTTY_H + +struct sgttyb +{ + char sg_ispeed; /* input speed */ + char sg_ospeed; /* output speed */ + char sg_erase; /* erase character */ + char sg_kill; /* kill character */ + int sg_flags; /* mode flags */ +}; + +struct tchars +{ + char t_intrc; /* SIGINT char */ + char t_quitc; /* SIGQUIT char */ + char t_startc; /* start output (initially CTRL-Q) */ + char t_stopc; /* stop output (initially CTRL-S) */ + char t_eofc; /* EOF (initially CTRL-D) */ + char t_brkc; /* input delimiter (like nl) */ +}; + +/* Field names */ +#define XTABS 0006000 /* do tab expansion */ +#define BITS8 0001400 /* 8 bits/char */ +#define BITS7 0001000 /* 7 bits/char */ +#define BITS6 0000400 /* 6 bits/char */ +#define BITS5 0000000 /* 5 bits/char */ +#define EVENP 0000200 /* even parity */ +#define ODDP 0000100 /* odd parity */ +#define RAW 0000040 /* enable raw mode */ +#define CRMOD 0000020 /* map lf to cr + lf */ +#define ECHO 0000010 /* echo input */ +#define CBREAK 0000002 /* enable cbreak mode */ +#define COOKED 0000000 /* neither CBREAK nor RAW */ + +#define DCD 0100000 /* Data Carrier Detect */ + +/* Line speeds */ +#define B0 0 /* code for line-hangup */ +#define B110 1 +#define B300 3 +#define B1200 12 +#define B2400 24 +#define B4800 48 +#define B9600 96 + +#define TIOCGETP (('t' << 8) | 8) +#define TIOCSETP (('t' << 8) | 9) +#define TIOCGETC (('t' << 8) | 18) +#define TIOCSETC (('t' << 8) | 17) +#define TIOCFLUSH (('t' << 8) | 16) + +/* Things Minix supports but not properly */ +/* the divide-by-100 encoding ain't too hot */ +#define ANYP 0000300 +#define B50 0 +#define B75 0 +#define B134 0 +#define B150 0 +#define B200 2 +#define B600 6 +#define B1800 18 +#define B3600 36 +#define B7200 72 +#define EXTA 192 +#define EXTB 0 + +/* Things Minix doesn't support but are fairly harmless if used */ +#define NLDELAY 0001400 +#define TBDELAY 0006000 +#define CRDELAY 0030000 +#define VTDELAY 0040000 +#define BSDELAY 0100000 +#define ALLDELAY 0177400 + +#if MACHINE == ATARI +/* ST specific clock stuff */ + +#define DCLOCK ('D' << 8) + +#define DC_RBMS100 (DCLOCK | 1) +#define DC_RBMS200 (DCLOCK | 2) +#define DC_RSUPRA (DCLOCK | 3) +#define DC_RICD (DCLOCK | 4) +#define DC_WBMS100 (DCLOCK | 8) +#define DC_WBMS200 (DCLOCK | 9) +#endif + +#include + +_PROTOTYPE(int gtty, (int _fd, struct sgttyb* _argp)); +_PROTOTYPE(int ioctl, (int _fd, int _request, struct sgttyb* _argp)); +_PROTOTYPE(int stty, (int _fd, struct sgttyb* _argp)); + +#endif /* _SGTTY_H */ diff --git a/plat/minix/include/sys/dir.h b/plat/minix/include/sys/dir.h new file mode 100644 index 0000000000..1918d232b4 --- /dev/null +++ b/plat/minix/include/sys/dir.h @@ -0,0 +1,43 @@ +/* $Id$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef _ACK_DIR_H +#define _ACK_DIR_H + +#ifdef __BSD4_2 +#define MAXNAMLEN 255 +#else +#define MAXNAMLEN 14 +#endif +#define DIRBLKSIZ 512 +#undef DIRSIZ +#define DIRSIZ(dp) ((sizeof(struct direct) - (MAXNAMLEN + 1)) + (((dp)->d_namlen + 1 + 3) & ~3)) +struct direct +{ + long d_ino; + short d_reclen; + short d_namlen; + char d_name[MAXNAMLEN + 1]; +}; + +struct _dirdesc +{ + int dd_fd; + long dd_loc; + long dd_size; + char* dd_buf; + int dd_bsize; +}; + +typedef struct _dirdesc DIR; + +extern DIR* opendir(const char* name); +extern struct direct* readdir(DIR* dirp); +extern long telldir(DIR* dirp); +extern void seekdir(DIR* dirp, long loc); +#define rewinddir(dirp) seekdir((dirp), 0L) +extern int closedir(DIR* dirp); + +#endif /* _DIR_H */ diff --git a/lib/minix/include/errno.h b/plat/minix/include/sys/errno.h similarity index 97% rename from lib/minix/include/errno.h rename to plat/minix/include/sys/errno.h index 9092ffb8cf..38a15f0b47 100644 --- a/lib/minix/include/errno.h +++ b/plat/minix/include/sys/errno.h @@ -17,8 +17,8 @@ * file is included in an ordinary user program, EPERM has the value ( 1). */ -#ifndef _ERRNO_H /* check if is already included */ -#define _ERRNO_H /* it is not included; note that fact */ +#ifndef _SYS_ERRNO_H /* check if is already included */ +#define _SYS_ERRNO_H /* it is not included; note that fact */ /* Now define _SIGN as "" or "-" depending on _SYSTEM. */ #ifdef _SYSTEM diff --git a/plat/minix/include/sys/stat.h b/plat/minix/include/sys/stat.h new file mode 100644 index 0000000000..424e0bd7a5 --- /dev/null +++ b/plat/minix/include/sys/stat.h @@ -0,0 +1,76 @@ +/* The header defines a struct that is used in the stat() and + * fstat functions. The information in this struct comes from the i-node of + * some file. These calls are the only approved way to inspect i-nodes. + */ + +#ifndef _STAT_H +#define _STAT_H + +#include + +struct stat +{ + dev_t st_dev; /* major/minor device number */ + ino_t st_ino; /* i-node number */ + mode_t st_mode; /* file mode, protection bits, etc. */ + short int st_nlink; /* # links; TEMPORARY HACK: should be nlink_t*/ + uid_t st_uid; /* uid of the file's owner */ + short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */ + dev_t st_rdev; + off_t st_size; /* file size */ + time_t st_atime; /* time of last access */ + time_t st_mtime; /* time of last data modification */ + time_t st_ctime; /* time of last file status change */ +}; + +/* Traditional mask definitions for st_mode. */ +/* The ugly casts on only some of the definitions are to avoid suprising sign + * extensions such as S_IFREG != (mode_t) S_IFREG when ints are 32 bits. + */ +#define S_IFMT ((mode_t)0170000) /* type of file */ +#define S_IFREG ((mode_t)0100000) /* regular */ +#define S_IFBLK 0060000 /* block special */ +#define S_IFDIR 0040000 /* directory */ +#define S_IFCHR 0020000 /* character special */ +#define S_IFIFO 0010000 /* this is a FIFO */ +#define S_ISUID 0004000 /* set user id on execution */ +#define S_ISGID 0002000 /* set group id on execution */ +/* next is reserved for future use */ +#define S_ISVTX 01000 /* save swapped text even after use */ + +/* POSIX masks for st_mode. */ +#define S_IRWXU 00700 /* owner: rwx------ */ +#define S_IRUSR 00400 /* owner: r-------- */ +#define S_IWUSR 00200 /* owner: -w------- */ +#define S_IXUSR 00100 /* owner: --x------ */ + +#define S_IRWXG 00070 /* group: ---rwx--- */ +#define S_IRGRP 00040 /* group: ---r----- */ +#define S_IWGRP 00020 /* group: ----w---- */ +#define S_IXGRP 00010 /* group: -----x--- */ + +#define S_IRWXO 00007 /* others: ------rwx */ +#define S_IROTH 00004 /* others: ------r-- */ +#define S_IWOTH 00002 /* others: -------w- */ +#define S_IXOTH 00001 /* others: --------x */ + +/* The following macros test st_mode (from POSIX Sec. 5.6.1.1). */ +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* is a reg file */ +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* is a directory */ +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* is a char spec */ +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) /* is a block spec */ +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* is a pipe/FIFO */ + +/* Function Prototypes. */ +#ifndef _ANSI_H +#include +#endif + +_PROTOTYPE(int chmod, (const char* _path, mode_t _mode)); +_PROTOTYPE(int fstat, (int _fildes, struct stat* _buf)); +_PROTOTYPE(int mkdir, (const char* _path, int _mode)); +_PROTOTYPE(int mkfifo, (const char* _path, int _mode)); +_PROTOTYPE(int stat, (const char* _path, struct stat* _buf)); +_PROTOTYPE(mode_t umask, (int _cmask)); + +#endif /* _STAT_H */ diff --git a/plat/minix/include/sys/types.h b/plat/minix/include/sys/types.h new file mode 100644 index 0000000000..c29024afe5 --- /dev/null +++ b/plat/minix/include/sys/types.h @@ -0,0 +1,19 @@ +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H + +typedef long time_t; +typedef long suseconds_t; + +/* Types used in disk, inode, etc. data structures. */ +typedef short dev_t; /* holds (major|minor) device pair */ +typedef char gid_t; /* group id */ +typedef unsigned short ino_t; /* i-node number */ +typedef short mode_t; /* mode number within an i-node */ +typedef char nlink_t; /* number-of-links field within an i-node */ +typedef int pid_t; /* type for pids (must be signed) */ +typedef short uid_t; /* user id */ +typedef long zone_t; /* holds a zone number */ +typedef long block_t; /* block number */ +typedef long bit_t; /* used for bit number in a bit map */ + +#endif diff --git a/plat/minix/include/sys/wait.h b/plat/minix/include/sys/wait.h new file mode 100644 index 0000000000..f1ec55572d --- /dev/null +++ b/plat/minix/include/sys/wait.h @@ -0,0 +1,40 @@ +/* The header contains macros related to wait(). The value + * returned by wait() and waitpid() depends on whether the process + * terminated by an exit() call, was killed by a signal, or was stopped + * due to job control, as follows: + * + * High byte Low byte + * +---------------------+ + * exit(status) | status | 0 | + * +---------------------+ + * killed by signal | 0 | signal | + * +---------------------+ + * stopped (job control) | signal | 0177 | + * +---------------------+ + */ + +#ifndef _WAIT_H +#define _WAIT_H + +#define _LOW(v) ((v) & 0377) +#define _HIGH(v) (((v) >> 8) & 0377) + +#define WNOHANG 1 /* do not wait for child to exit */ +#define WUNTRACED 2 /* for job control; not implemented */ + +#define WIFEXITED(s) (_LOW(s) == 0) /* normal exit */ +#define WEXITSTATUS(s) (_HIGH(s)) /* exit status */ +#define WTERMSIG(s) (_LOW(s) & 0177) /* sig value */ +#define WIFSIGNALED(s) (((unsigned int)(s) - 1 & 0xFFFF) < 0xFF) /* signaled */ +#define WIFSTOPPED(s) (_LOW(s) == 0177) /* stopped */ +#define WSTOPSIG(s) (_HIGH(s) & 0377) /* stop signal */ + +/* Function Prototypes. */ +#ifndef _ANSI_H +#include +#endif + +_PROTOTYPE(pid_t wait, (int* _stat_loc)); +_PROTOTYPE(pid_t waitpid, (pid_t _pid, int* _stat_loc, int _options)); + +#endif /* _WAIT_H */ diff --git a/plat/minix/include/utime.h b/plat/minix/include/utime.h new file mode 100644 index 0000000000..771c55faf4 --- /dev/null +++ b/plat/minix/include/utime.h @@ -0,0 +1,14 @@ +/* The header is used for the utime() system call. */ + +#ifndef _UTIME_H +#define _UTIME_H + +struct utimbuf +{ + time_t actime; /* access time */ + time_t modtime; /* modification time */ +}; + +extern int utime(const char* _path, const struct utimbuf* _times); + +#endif /* _UTIME_H */ diff --git a/plat/minix68k/boot.s b/plat/minix68k/boot.s new file mode 100644 index 0000000000..211144ba4f --- /dev/null +++ b/plat/minix68k/boot.s @@ -0,0 +1,86 @@ +.define .lino,.filn +.define EXIT,BRK,WRITE +.define begtext,begdata,begbss +.define EARRAY,ERANGE,ESET,EIDIVZ,EHEAP,EILLINS,ECASE,EBADGTO +.define hol0,.reghp,.limhp,.trpim,.trppc +.sect .text +.sect .rom +.sect .data +.sect .bss + + + +! EM runtime start-off for the Bleasdale 68000 system + + +LINO_AD = 0 +FILN_AD = 4 + +EARRAY = 0 +ERANGE = 1 +ESET = 2 +EIDIVZ = 6 +EHEAP = 17 +EILLINS = 18 +ECASE = 20 +EBADGTO = 27 + + .sect .text +begtext: + ! Bleasdale puts the argument and environment vectors + ! themselves on top of the stack, instead of POINTERS + ! to these vectors. We get things right here. + move.l 4(sp),a0 + clr.l -4(a0) + move.l sp,a0 + sub.l #8,sp + move.l (a0),(sp) + add.l #4,a0 + move.l a0,4(sp) +1: + tst.l (a0)+ + bne 1b + move.l 4(sp),a1 + cmp.l (a1),a0 + blt 2f + sub.l #4,a0 +2: + move.l a0,8(sp) + + ! Now the stack contains an argc (4 bytes), argv-pointer and + ! envp pointer. + + add.l #2,sp !convert argc from 4-byte to 2-byte + jsr __m_a_i_n + add #010,sp +EXIT: + move.w d0,-(sp) + jsr __exit + +BRK: + jmp __brk + +WRITE: + jmp __write + + .sect .data +begdata: +hol0: +.lino: + .data2 0,0 ! lino +.filn: + .data4 0 ! filn +.reghp: + .data4 endbss +.limhp: + .data4 endbss +.trpim: + .data2 0 + +.define .trppc, .ignmask +.comm .trppc, 4 +.comm .ignmask, 4 + + + .sect .bss +begbss: !initialization is not needed because ALL entries are in zero space! diff --git a/plat/minix68k/build-pkg.lua b/plat/minix68k/build-pkg.lua new file mode 100644 index 0000000000..bbe8a1cbeb --- /dev/null +++ b/plat/minix68k/build-pkg.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "minix68k" } +} + +build_plat_libs { + name = "libs", + arch = "m68k2", + plat = "minix68k", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + "./include+pkg", + ["$(PLATIND)/minix68k/boot.o"] = "+boot", + ["$(PLATIND)/minix68k/libsys.a"] = "./libsys+lib", + } +} + diff --git a/plat/minix68k/build-tools.lua b/plat/minix68k/build-tools.lua new file mode 100644 index 0000000000..dbe127a075 --- /dev/null +++ b/plat/minix68k/build-tools.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "m68k2", +} + +build_ncg { + name = "ncg", + arch = "m68020", + vars = { + ["+cflags"] = "-DWORD_SIZE=2 -DTBL68000=1" + } +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/minix68k/as"] = "+as", + ["$(PLATDEP)/minix68k/ncg"] = "+ncg", + ["$(PLATDEP)/minix68k/cv"] = "plat/minix68k/cv+cv", + ["$(PLATIND)/descr/minix68k"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/minix68k/cv/build.lua b/plat/minix68k/cv/build.lua new file mode 100644 index 0000000000..2ee9190d62 --- /dev/null +++ b/plat/minix68k/cv/build.lua @@ -0,0 +1,9 @@ +cprogram { + name = "cv", + srcs = { "./cv.c" }, + deps = { + "h+emheaders", + "modules/src/data+lib", + "modules/src/object+lib" + } +} diff --git a/plat/minix68k/cv/cv.c b/plat/minix68k/cv/cv.c new file mode 100644 index 0000000000..83654176b2 --- /dev/null +++ b/plat/minix68k/cv/cv.c @@ -0,0 +1,362 @@ +/* $Id$ */ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + * + */ + +/* + * Convert ACK a.out file to ST-Minix object format. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "out.h" +#include "warnings.h" +#include "object.h" + +#if !defined O_BINARY +#define O_BINARY 0 +#endif + +struct outhead outhead; +struct outsect outsect[S_MAX]; + +#define TEXTSG 0 +#define ROMSG 1 +#define DATASG 2 +#define BSSSG 3 +#define LSECT BSSSG + 1 +#define NSECT LSECT + 1 + +static char* output_file; +static int outputfile_created; + +static char* program; + +/* Output file definitions and such */ + +static int output; + +static int unresolved; +static long textsize; +static long datasize; +static long bsssize; + +static char* chmemstr; + +static long chmem(char* str, long old); +static void cvlong(long* l); +static void emit_relo(void); +static void emits(struct outsect* section); + +static void minixhead(void) +{ + long mh[8]; + long stack; + int i; + + mh[0] = 0x04100301L; + mh[1] = 0x00000020L; + mh[2] = textsize; + mh[3] = datasize; + mh[4] = bsssize; + mh[5] = 0; + stack = 0x00010000L - (mh[3] + mh[4]); + if ((mh[0] & 0x00200000L) == 0) /* not SEPARATE */ + stack -= mh[2]; + while (stack < 0) + stack += 0x00010000L; + if (chmemstr) + stack = chmem(chmemstr, stack); + mh[6] = stack + (mh[3] + mh[4]); + if ((mh[0] & 0x00200000L) == 0) /* not SEPARATE */ + mh[6] += mh[2]; + mh[7] = 0; + for (i = 0; i < 8; i++) + { + cvlong(&mh[i]); + } + + if (write(output, (char*)mh, sizeof(mh)) != sizeof(mh)) + fatal("write error\n"); +} + +static long align(long a, long b) +{ + if (b == 0) + return a; + a += b - 1; + return a - a % b; +} + +static int follows(struct outsect* pa, struct outsect* pb) +{ + /* return 1 if pa follows pb */ + + return pa->os_base == align(pb->os_base + pb->os_size, pa->os_lign); +} + +int main(int argc, char* argv[]) +{ + program = argv[0]; + if (argc > 1) + { + switch (argv[1][0]) + { + case '-': + case '+': + case '=': + chmemstr = argv[1]; + argc--; + argv++; + } + } + switch (argc) + { + case 3: + output = open(argv[2], O_CREAT|O_RDWR|O_TRUNC|O_BINARY, 0755); + if (output < 0) + fatal("Can't write %s: %s\n", argv[2], strerror(errno)); + output_file = argv[2]; + outputfile_created = 1; + if (!rd_open(argv[1])) + fatal("Can't read %s: %s\n", argv[1], strerror(errno)); + break; + default: + fatal("Usage: %s [+-= amount] .\n", argv[0]); + } + rd_ohead(&outhead); + if (BADMAGIC(outhead)) + fatal("Not an ack object file.\n"); + if (outhead.oh_flags & HF_LINK) + { + unresolved++; + fatal("Contains unresolved references.\n"); + } + if (outhead.oh_nsect != LSECT && outhead.oh_nsect != NSECT) + fatal("Input file must have %d sections, not %ld\n", NSECT, outhead.oh_nsect); + rd_sect(outsect, outhead.oh_nsect); + /* A few checks */ + if (outsect[BSSSG].os_flen != 0) + fatal("bss space contains initialized data\n"); + if (!follows(&outsect[BSSSG], &outsect[DATASG])) + fatal("bss segment must follow data segment\n"); + textsize = (outsect[DATASG].os_base - outsect[TEXTSG].os_base); + if (!follows(&outsect[ROMSG], &outsect[TEXTSG])) + fatal("rom segment must follow text\n"); + if (!follows(&outsect[DATASG], &outsect[ROMSG])) + fatal("data segment must follow rom\n"); + outsect[TEXTSG].os_size = outsect[ROMSG].os_base - outsect[TEXTSG].os_base; + outsect[ROMSG].os_size = outsect[DATASG].os_base - outsect[ROMSG].os_base; + outsect[DATASG].os_size = outsect[BSSSG].os_base - outsect[DATASG].os_base; + datasize = outsect[DATASG].os_size; + bsssize = outsect[BSSSG].os_size; + if (outhead.oh_nsect == NSECT) + { + if (!follows(&outsect[LSECT], &outsect[BSSSG])) + fatal("end segment must follow bss\n"); + if (outsect[LSECT].os_size != 0) + fatal("end segment must be empty\n"); + } + + minixhead(); + emits(&outsect[TEXTSG]); + emits(&outsect[ROMSG]); + emits(&outsect[DATASG]); + emit_relo(); + if (outputfile_created) + chmod(argv[2], 0755); + return 0; +} + +/* + * Transfer the emitted byted from one file to another. + */ +static void emits(struct outsect* section) +{ + char* p; + long sz = section->os_flen; + + rd_outsect(section - outsect); + while (sz) + { + unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); + if (!(p = malloc(0x4000))) + { + fatal("No memory.\n"); + } + rd_emit(p, (long)i); + if (write(output, p, (int)i) < i) + { + fatal("write error.\n"); + } + free(p); + sz -= i; + } + + sz = section->os_size - section->os_flen; + if (sz) + { + if (!(p = calloc(0x4000, 1))) + { + fatal("No memory.\n"); + } + while (sz) + { + unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); + if (write(output, p, (int)i) < i) + { + fatal("write error.\n"); + } + sz -= i; + } + free(p); + } +} + +static int compare(const void* pa, const void* pb) +{ + const struct outrelo* a = pa; + const struct outrelo* b = pb; + + if (a->or_sect < b->or_sect) + return -1; + if (a->or_sect > b->or_sect) + return 1; + if (a->or_addr < b->or_addr) + return -1; + if (a->or_addr > b->or_addr) + return 1; + return 0; +} + +static void emit_relo(void) +{ + struct outrelo* ACKrelo; + struct outrelo* ap; + unsigned int cnt = outhead.oh_nrelo; + long last, curr, base; + int sect; + char* bp; + char* b; + + ACKrelo = ap = (struct outrelo*)calloc(cnt, sizeof(struct outrelo)); + bp = b = malloc(4 * cnt); + if (!ap || !bp) + { + fatal("No memory.\n"); + } + rd_relo(ap, cnt); + qsort((char*)ap, (int)cnt, sizeof(struct outrelo), compare); + + /* + * read relocation, modify to GEMDOS format, and write. + * Only longs can be relocated. + * + * The GEMDOS format starts with a long L: the offset to the + * beginning of text for the first long to be relocated. + * If L==0 then no relocations have to be made. + * + * The long is followed by zero or more bytes. Each byte B is + * processed separately, in one of the following ways: + * + * B==0: + * end of relocation + * B==1: + * no relocation, but add 254 to the current offset + * B==0bWWWWWWW0: + * B is added to the current offset and the long addressed + * is relocated. Note that 00000010 means 1 word distance. + * B==0bXXXXXXX1: + * illegal + */ + + last = 0; + curr = 0; + for (sect = S_MIN; sect <= S_MIN + 2; sect++) + { + base = outsect[sect - S_MIN].os_base; + for (; cnt > 0 && ap->or_sect == sect; ap++, cnt--) + { + if (ap->or_type & RELPC || ap->or_nami == outhead.oh_nname) + continue; + + assert(ap->or_type & RELO4); + curr = base + ap->or_addr; + if (last == 0) + { + last = curr; + cvlong(&curr); + *((long*)b) = curr; + b += 4; + } + else + { + while (curr - last > 255) + { + *b++ = 1; + last += 254; + } + *b++ = curr - last; + last = curr; + } + } + assert(cnt == 0 || ap->or_sect > sect); + } + assert(cnt == 0); + if (cnt = (b - bp)) + { + *b++ = '\0'; + write(output, bp, (int)cnt + 1); + } + else + write(output, "\0\0\0", 4); + free((char*)ACKrelo); + free(bp); +} + +static long chmem(char* str, long old) +{ + long num, new; + + num = atol(str + 1); + if (num == 0) + fatal("bad chmem amount %s\n", str + 1); + switch (str[0]) + { + case '-': + new = old - num; + break; + case '+': + new = old + num; + break; + case '=': + new = num; + break; + } + return (new); +} + +static void cvlong(long* l) +{ + long x = *l; + char* p = (char*)l; + + *p++ = x >> 24; + *p++ = x >> 16; + *p++ = x >> 8; + *p = x; +} + +void rd_fatal(void) +{ + fatal("read error.\n"); +} diff --git a/plat/minix68k/descr b/plat/minix68k/descr new file mode 100644 index 0000000000..461018a3aa --- /dev/null +++ b/plat/minix68k/descr @@ -0,0 +1,88 @@ +# $Revision$ +var w=2 +var wa=2 +var p=4 +var pa=2 +var s=2 +var sa=2 +var l=4 +var la=2 +var f=4 +var fa=2 +var d=8 +var da=2 +var x=8 +var xa=2 +var ARCH=m68k2 +var PLATFORM=minix68k +var SHAREDIR={EM}/share/ack +var PLATFORMDIR={SHAREDIR}/{PLATFORM} +var NAME=minixST +var M=m68k2 +var MLIB=lib/{M}/tail_ +var RT=lib/minixST/head_ +var LIB=lib/minixST/tail_ +var CPP_F=-D__unix -D_ATARI_ST +var SYSINCLUDES=-I{EM}/lib/minixST/include -I{EM}/lib/minix/include +var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 +var C_LIB={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g +var OLD_C_LIB={C_LIB} +var MACHOPT_F=-ml10 + +# Override the setting in fe so that files compiled for this platform can see +# the platform-specific headers. + +var C_INCLUDES=-I{SHAREDIR}/minix/include -I{PLATFORMDIR}/include -I{SHAREDIR}/include/ansi + +name be + from .m.g + to .s + program {EM}/lib/ack/{PLATFORM}/ncg + mapflag -gdb GF=-gdb + args {GF?} < + stdout + need .e +end +name as + from .s.so + to .o + program {EM}/lib/ack/{PLATFORM}/as + args - -o > < + prep cond +end +name led + from .o.a + to .out + program {EM}/lib/ack/em_led + mapflag -l* LNAME={EM}/{LIB}* +# mapflag -i SEPID=-b1:0 + mapflag -fp LIBFP={EM}/{NLIB}fp + mapflag -ansi C_LIB={EM}/{LIB}ac + args {ALIGN} {SEPID?} -c \ + ({RTS}:.b=-u _i_main) \ + (.e:{HEAD}={PLATFORMDIR}/boot.o) \ + ({RTS}:.ocm.bas.b={PLATFORMDIR}/c-ansi.o) \ + ({RTS}:.c={PLATFORMDIR}/c-ansi.o) \ + ({RTS}:.mod={PLATFORMDIR}/modula2.o) \ + ({RTS}:.p={PLATFORMDIR}/pascal.o) \ + -o > < \ + (.p:{TAIL}={PLATFORMDIR}/libpascal.a) \ + (.b:{TAIL}={PLATFORMDIR}/libb.a) \ + (.bas:{TAIL}={PLATFORMDIR}/libbasic.a) \ + (.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \ + (.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \ + (.ocm.bas.mod.b.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ + {FLOATS?} \ + (.e:{TAIL}={PLATFORMDIR}/libem.a \ + {PLATFORMDIR}/libsys.a \ + {PLATFORMDIR}/libem.a \ + {PLATFORMDIR}/libend.a) + linker +end +name cv + from .out + to .cv + program {EM}/lib/ack/{PLATFORM}/cv + args < > + outfile a.out +end diff --git a/lib/minixST/include/a.out.h b/plat/minix68k/include/a.out.h similarity index 100% rename from lib/minixST/include/a.out.h rename to plat/minix68k/include/a.out.h diff --git a/plat/minix68k/include/ack/plat.h b/plat/minix68k/include/ack/plat.h new file mode 100644 index 0000000000..7a68c3b924 --- /dev/null +++ b/plat/minix68k/include/ack/plat.h @@ -0,0 +1,16 @@ +/* $Source$ + * $State$ + * $Revision$ + */ + +#ifndef _ACK_PLAT_H +#define _ACK_PLAT_H + +#define _POSIX_SOURCE 1 +#define ACKCONF_WANT_EMULATED_TIME 0 +#define ACKCONF_WANT_STANDARD_O 0 +#define ACKCONF_WANT_STANDARD_SIGNALS 0 +#define ACKCONF_WANT_STANDARD_LIMITS 0 +#define ACKCONF_WANT_SYS_ERRNO_H 1 + +#endif diff --git a/plat/minix68k/include/build.lua b/plat/minix68k/include/build.lua new file mode 100644 index 0000000000..e78fb08691 --- /dev/null +++ b/plat/minix68k/include/build.lua @@ -0,0 +1,27 @@ +include("plat/build.lua") + +headermap = { + "plat/minix/include+headers", +} +packagemap = { + "plat/minix/include+pkg", +} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/minix68k/include/"..h] = "./"..h +end + +addheader("ack/plat.h") +addheader("minix/config.h") +addheader("a.out.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} diff --git a/lib/minixST/include/minix/config.h b/plat/minix68k/include/minix/config.h similarity index 100% rename from lib/minixST/include/minix/config.h rename to plat/minix68k/include/minix/config.h diff --git a/mach/minixST/libsys/LIST b/plat/minix68k/libsys/LIST similarity index 100% rename from mach/minixST/libsys/LIST rename to plat/minix68k/libsys/LIST diff --git a/plat/minix68k/libsys/_access.c b/plat/minix68k/libsys/_access.c new file mode 100644 index 0000000000..7e61f845dc --- /dev/null +++ b/plat/minix68k/libsys/_access.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define access _access +#include + +PUBLIC int access(const char* name, int mode) +{ + return (_callm3(FS, ACCESS, mode, name)); +} diff --git a/plat/minix68k/libsys/_alarm.c b/plat/minix68k/libsys/_alarm.c new file mode 100644 index 0000000000..9839b6e078 --- /dev/null +++ b/plat/minix68k/libsys/_alarm.c @@ -0,0 +1,9 @@ +#include "lib.h" +#define alarm _alarm +#include + +PUBLIC unsigned int alarm(sec) +unsigned int sec; +{ + return (_callm1(MM, ALARM, (int)sec, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_brk.c b/plat/minix68k/libsys/_brk.c new file mode 100644 index 0000000000..dfbef2cac2 --- /dev/null +++ b/plat/minix68k/libsys/_brk.c @@ -0,0 +1,33 @@ +#include "lib.h" +#define brk _brk +#define sbrk _sbrk +#include + +extern char* _brksize; + +PUBLIC int brk(void* addr) +{ + if (_callm1(MM, BRK, 0, 0, 0, addr, NIL_PTR, NIL_PTR) == 0) + { + _brksize = _M.m2_p1; + return 0; + } + else + { + return -1; + } +} + +PUBLIC void* sbrk(int incr) +{ + char *newsize, *oldsize; + + oldsize = _brksize; + newsize = _brksize + incr; + if (incr > 0 && newsize < oldsize || incr < 0 && newsize > oldsize) + return ((char*)-1); + if (_brk(newsize) == 0) + return (oldsize); + else + return ((void*)-1); +} diff --git a/plat/minix68k/libsys/_chdir.c b/plat/minix68k/libsys/_chdir.c new file mode 100644 index 0000000000..6c09c9989a --- /dev/null +++ b/plat/minix68k/libsys/_chdir.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define chdir _chdir +#include + +PUBLIC int chdir(const char* name) +{ + return (_callm3(FS, CHDIR, 0, name)); +} diff --git a/plat/minix68k/libsys/_chmod.c b/plat/minix68k/libsys/_chmod.c new file mode 100644 index 0000000000..b5d995921e --- /dev/null +++ b/plat/minix68k/libsys/_chmod.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define chmod _chmod +#include + +PUBLIC int chmod(_CONST char* name, mode_t mode) +{ + return (_callm3(FS, CHMOD, mode, name)); +} diff --git a/plat/minix68k/libsys/_chown.c b/plat/minix68k/libsys/_chown.c new file mode 100644 index 0000000000..c9dd447aee --- /dev/null +++ b/plat/minix68k/libsys/_chown.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define chown _chown +#include + +PUBLIC int chown(char* name, int owner, int grp) +{ + return (_callm1(FS, CHOWN, _len(name), owner, grp, name, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_chroot.c b/plat/minix68k/libsys/_chroot.c new file mode 100644 index 0000000000..b8c469f736 --- /dev/null +++ b/plat/minix68k/libsys/_chroot.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define chroot _chroot +#include + +PUBLIC int chroot(const char* name) +{ + return (_callm3(FS, CHROOT, 0, name)); +} diff --git a/plat/minix68k/libsys/_close.c b/plat/minix68k/libsys/_close.c new file mode 100644 index 0000000000..c8032c7f58 --- /dev/null +++ b/plat/minix68k/libsys/_close.c @@ -0,0 +1,9 @@ +#include "lib.h" +#define close _close +#include + +PUBLIC int close(fd) +int fd; +{ + return (_callm1(FS, CLOSE, fd, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_creat.c b/plat/minix68k/libsys/_creat.c new file mode 100644 index 0000000000..5f2f12b36b --- /dev/null +++ b/plat/minix68k/libsys/_creat.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define creat _creat +#include + +PUBLIC int creat(_CONST char* name, mode_t mode) +{ + return (_callm3(FS, CREAT, mode, name)); +} diff --git a/plat/minix68k/libsys/_dup.c b/plat/minix68k/libsys/_dup.c new file mode 100644 index 0000000000..32cda4668e --- /dev/null +++ b/plat/minix68k/libsys/_dup.c @@ -0,0 +1,9 @@ +#include "lib.h" +#define dup _dup +#include +#include + +PUBLIC int dup(int fd) +{ + return (fcntl(fd, F_DUPFD, 0)); +} diff --git a/plat/minix68k/libsys/_dup2.c b/plat/minix68k/libsys/_dup2.c new file mode 100644 index 0000000000..076e419daf --- /dev/null +++ b/plat/minix68k/libsys/_dup2.c @@ -0,0 +1,34 @@ +#include "lib.h" +#define dup2 _dup2 +#include +#include +#include +#include + +PUBLIC int dup2(int fd, int fd2) +{ + /* The behavior of dup2 is defined by POSIX in 6.2.1.2 as almost, but not + * quite the same as fcntl. + */ + + if (fd2 < 0 || fd2 > OPEN_MAX) + { + errno = EBADF; + return (-1); + } + + /* Check to see if fildes is valid. */ + if (fcntl(fd, F_GETFL) < 0) + { + /* fd is not valid. */ + return (-1); + } + else + { + /* fd is valid. */ + if (fd == fd2) + return (fd2); + close(fd2); + return (fcntl(fd, F_DUPFD, fd2)); + } +} diff --git a/plat/minix68k/libsys/_exec.c b/plat/minix68k/libsys/_exec.c new file mode 100644 index 0000000000..f962b5b88a --- /dev/null +++ b/plat/minix68k/libsys/_exec.c @@ -0,0 +1,160 @@ +#include "lib.h" +#define execl _execl +#define execle _execle +#define execv _execv +#define execve _execve +#include +#include + +extern char** environ; /* environment pointer */ + +#define PTRSIZE (sizeof(char*)) +_PROTOTYPE(char* _sbrk, (int _incr)); + +#if 0 // dtrg --- this is all very wrong and needs rewriting +PUBLIC int execl(const char* name, const char* arg, ...) +{ + int retval; + va_list ap; + + va_start(ap, name); + retval = execve(name, (char**)ap, environ); + va_end(ap); + return retval; +} + +PUBLIC int execle(const char* name, ...) +{ + int retval; + va_list ap; + char* p; + + va_start(ap, name); + do + { + p = va_arg(ap, char*); + } while (p); + p = (char*)va_arg(ap, char**); + va_end(ap); + va_start(ap, name); + retval = execve(name, (char**)ap, (char**)p); + va_end(ap); + return retval; +} + +PUBLIC int execv(const char* name, const char* argv) +{ + return execve(name, argv, environ); +} + +PUBLIC int execve( + const char* path /* pointer to name of file to be executed */, + const char* argv[] /* pointer to argument array */, + const char* envp[] /* pointer to environment */) +{ + char** argtop; + char** envtop; + + /* Count the argument pointers and environment pointers. */ + for (argtop = argv; *argtop != (char*)NULL;) + argtop++; + for (envtop = envp; *envtop != (char*)NULL;) + envtop++; + return (__execve(path, argv, envp, (int)(argtop - argv), (int)(envtop - envp))); +} + +PUBLIC int __execve( + const char* path /* pointer to name of file to be executed */, + const char* argv[] /* pointer to argument array */, + const char* envp[] /* pointer to environment */, + int nargs /* number of args */, + int nenvps /* number of environment strings */) +{ + /* This is split off from execve to be called from execvp, so execvp does not + * have to allocate up to ARG_MAX bytes just to prepend "sh" to the arg array. + */ + + char *hp, **ap, *p; + int i, stackbytes, npointers, overflow, temp; + char* stack; + /* Decide how big a stack is needed. Be paranoid about overflow. */ +#if ARG_MAX > INT_MAX +#error /* overflow checks and sbrk depend on sizes being ints */ +#endif + overflow = FALSE; + npointers = 1 + nargs + 1 + nenvps + 1; /* 1's for argc and NULLs */ + stackbytes = 0; /* changed because _len is used now */ + if (nargs < 0 || nenvps < 0 || nargs + nenvps < 0 || npointers < 0) + overflow = TRUE; + for (i = PTRSIZE; i != 0; i--) + { + temp = stackbytes + npointers; + if (temp < stackbytes) + overflow = TRUE; + stackbytes = temp; + } + for (i = 0, ap = argv; i < nargs; i++) + { + temp = stackbytes + _len(*ap++); + if (temp < stackbytes) + overflow = TRUE; + stackbytes = temp; + } + for (i = 0, ap = envp; i < nenvps; i++) + { + temp = stackbytes + _len(*ap++); + if (temp < stackbytes) + overflow = TRUE; + stackbytes = temp; + } + temp = stackbytes + PTRSIZE - 1; + if (temp < stackbytes) + overflow = TRUE; + stackbytes = (temp / PTRSIZE) * PTRSIZE; + + /* Check for overflow before committing sbrk. */ + if (overflow || stackbytes > ARG_MAX) + { + errno = E2BIG; + return (-1); + } + + /* Allocate the stack. */ + stack = _sbrk(stackbytes); + if (stack == (char*)-1) + { + errno = E2BIG; + return (-1); + } + + /* Prepare the stack vector and argc. */ + ap = (char**)stack; + hp = &stack[npointers * PTRSIZE]; + *ap++ = (char*)nargs; + + /* Prepare the argument pointers and strings. */ + for (i = 0; i < nargs; i++) + { + *ap++ = (char*)(hp - stack); + p = *argv++; + while ((*hp++ = *p++) != 0) + ; + } + *ap++ = (char*)NULL; + + /* Prepare the environment pointers and strings. */ + for (i = 0; i < nenvps; i++) + { + *ap++ = (char*)(hp - stack); + p = *envp++; + while ((*hp++ = *p++) != 0) + ; + } + *ap++ = (char*)NULL; + + /* Do the real work. */ + temp = _callm1(MM, EXEC, _len(path), stackbytes, 0, path, stack, NIL_PTR); + _sbrk(-stackbytes); + return (temp); +} +#endif \ No newline at end of file diff --git a/plat/minix68k/libsys/_execn.c b/plat/minix68k/libsys/_execn.c new file mode 100644 index 0000000000..c4015906db --- /dev/null +++ b/plat/minix68k/libsys/_execn.c @@ -0,0 +1,16 @@ +#include "lib.h" + +#define PTRSIZE sizeof(char*) +_PROTOTYPE(int _execn, (char* name)); + +PUBLIC int _execn(name) +char* name; /* pointer to file to be exec'd */ +{ + /* Special version used when there are no args and no environment. This call + * is principally used by INIT, to avoid having to allocate ARG_MAX. + */ + + static char stack[3 * PTRSIZE]; + + return (_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_execnl.c b/plat/minix68k/libsys/_execnl.c new file mode 100644 index 0000000000..25a0b53766 --- /dev/null +++ b/plat/minix68k/libsys/_execnl.c @@ -0,0 +1,80 @@ +/* + * This file contains two functions that can be used to perform + * an EXEC call without the need for a "big" stack of MAX_ARG + * bytes. It is primarily used by the INIT module of the system. + */ +#include "lib.h" +#include +#include + +#define MAXSTK 256 /* maximum EXEC stack size */ +#define PTRSIZE sizeof(char*) + +_PROTOTYPE(int _execn, (char* name)); +_PROTOTYPE(int _execnl, (char* name, char* arg0)); +static _PROTOTYPE(int _nexec, (char* name, char* argv[])); + +PUBLIC int _execn(name) +char* name; /* pointer to file to be exec'd */ +{ + /* This funcion uses no arguments at all. */ + static char stack[3 * PTRSIZE]; + + return (_callm1(MM, EXEC, _len(name), sizeof(stack), 0, name, stack, NIL_PTR)); +} + +PUBLIC int _execnl(name, arg0) +char* name; +char* arg0; +{ + /* This function resembles execl(2). */ + + return (_nexec(name, &arg0)); +} + +static int _nexec(name, argv) +char* name; /* pointer to name of file to be executed */ +char* argv[]; /* pointer to argument array */ +{ + char stack[MAXSTK]; + char **argorg, *hp, **ap, *p; + int i, nargs, stackbytes, offset; + + /* Count the argument pointers. */ + nargs = 0; + argorg = argv; + while (*argorg++ != NIL_PTR) + nargs++; + + /* Prepare to set up the initial stack. */ + hp = &stack[(nargs + 3) * PTRSIZE]; + if (hp + nargs >= &stack[MAXSTK]) + { + errno = E2BIG; + return (-1); + } + ap = (char**)stack; + *ap++ = (char*)nargs; + + /* Prepare the argument pointers and strings. */ + for (i = 0; i < nargs; i++) + { + offset = hp - stack; + *ap++ = (char*)offset; + p = *argv++; + while (*p) + { + *hp++ = *p++; + if (hp >= &stack[MAXSTK]) + { + errno = E2BIG; + return (-1); + } + } + *hp++ = (char)0; + } + *ap++ = NIL_PTR; + + stackbytes = (((int)(hp - stack) + PTRSIZE - 1) / PTRSIZE) * PTRSIZE; + return (_callm1(MM, EXEC, _len(name), stackbytes, 0, name, stack, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_exit.c b/plat/minix68k/libsys/_exit.c new file mode 100644 index 0000000000..3c154e3a0f --- /dev/null +++ b/plat/minix68k/libsys/_exit.c @@ -0,0 +1,7 @@ +#include "lib.h" +#include + +PUBLIC void _exit(status) int status; +{ + _callm1(MM, EXIT, status, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/plat/minix68k/libsys/_fcntl.c b/plat/minix68k/libsys/_fcntl.c new file mode 100644 index 0000000000..984ee5e4bd --- /dev/null +++ b/plat/minix68k/libsys/_fcntl.c @@ -0,0 +1,38 @@ +#include "lib.h" +#define fcntl _fcntl +#include +#include + +PUBLIC int fcntl(int fd, int cmd, ...) +{ + va_list ap; + int int3; /* third integer parameter for callm1 */ + char* ptr1; /* first pointer parameter for callm1 */ + + va_start(ap, cmd); + + /* Set up for the sensible case where there is no variable parameter. This + * covers F_GETFD, F_GETFL and invalid commands. + */ + int3 = 0; + ptr1 = NIL_PTR; + + /* Adjust for the stupid cases. */ + switch (cmd) + { + case F_DUPFD: + case F_SETFD: + case F_SETFL: + int3 = va_arg(ap, int); + break; + case F_GETLK: + case F_SETLK: + case F_SETLKW: + ptr1 = (char*)va_arg(ap, struct flock*); + break; + } + + /* Clean up and make the system call. */ + va_end(ap); + return (_callm1(FS, FCNTL, fd, cmd, int3, ptr1, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_fork.c b/plat/minix68k/libsys/_fork.c new file mode 100644 index 0000000000..99cb292704 --- /dev/null +++ b/plat/minix68k/libsys/_fork.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define fork _fork +#include + +PUBLIC int fork() +{ + return (_callm1(MM, FORK, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_fstat.c b/plat/minix68k/libsys/_fstat.c new file mode 100644 index 0000000000..165b844639 --- /dev/null +++ b/plat/minix68k/libsys/_fstat.c @@ -0,0 +1,11 @@ +#include "lib.h" +#include +#define fstat _fstat +#include + +PUBLIC int fstat(fd, buffer) +int fd; +struct stat* buffer; +{ + return (_callm1(FS, FSTAT, fd, 0, 0, (char*)buffer, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_getcwd.c b/plat/minix68k/libsys/_getcwd.c new file mode 100644 index 0000000000..66a483a2e0 --- /dev/null +++ b/plat/minix68k/libsys/_getcwd.c @@ -0,0 +1,140 @@ +/* getcwd - get current working directory Author: Terrence W. Holm */ + +/* Directly derived from Adri Koppes' pwd(1). + * Modified by Andy Tanenbaum for POSIX (29 Oct. 1989) + */ + +#include "lib.h" +#define getcwd _getcwd +#include +#include +#include +#include +#include + +#define DIRECT_SIZE (sizeof(struct direct)) + +static _PROTOTYPE(void go_back, (char* path)); + +char* getcwd(char* buffer, int size) +/* Get current working directory. */ +{ + int same_device, found, fd; + char *r, path[PATH_MAX + 1], temp_name[NAME_MAX + 1]; + struct stat current, parent, dir_entry; + struct direct d; + + if (buffer == (char*)NULL || size <= 0) + { + errno = EINVAL; + return ((char*)NULL); + } + path[0] = '\0'; + + /* Get the inode for the current directory */ + if (stat(".", ¤t) == -1) + return ((char*)NULL); + if ((current.st_mode & S_IFMT) != S_IFDIR) + return ((char*)NULL); + + /* Run backwards up the directory tree, grabbing dir names on the way. */ + while (1) + { + same_device = 0; + found = 0; + + /* Get the inode for the parent directory */ + if (chdir("..") == -1) + return ((char*)NULL); + if (stat(".", &parent) == -1) + return ((char*)NULL); + if ((parent.st_mode & S_IFMT) != S_IFDIR) + return ((char*)NULL); + if (current.st_dev == parent.st_dev) + same_device = 1; + + /* At the root, "." is the same as ".." */ + if (same_device && current.st_ino == parent.st_ino) + break; + + /* Search the parent directory for the current entry */ + if ((fd = open(".", O_RDONLY)) == -1) + return ((char*)NULL); + while (!found && read(fd, (char*)&d, DIRECT_SIZE) == DIRECT_SIZE) + { + if (d.d_ino == 0L) + continue; /* empty slot */ + if (same_device) + { + if (current.st_ino == d.d_ino) + found = 1; + } + else + { + temp_name[0] = '\0'; + strncat(temp_name, d.d_name, NAME_MAX); + if (stat(temp_name, &dir_entry) == -1) + { + close(fd); + go_back(path); + return ((char*)NULL); + } + if (current.st_dev == dir_entry.st_dev && current.st_ino == dir_entry.st_ino) + found = 1; + } + } + + close(fd); + if (!found) + { + go_back(path); + return ((char*)NULL); + } + if (strlen(path) + NAME_MAX + 1 > PATH_MAX) + { + errno = ERANGE; + go_back(path); + return ((char*)NULL); + } + strcat(path, "/"); + strncat(path, d.d_name, NAME_MAX); + current.st_dev = parent.st_dev; + current.st_ino = parent.st_ino; + } + + /* Copy the reversed path name into */ + if (strlen(path) + 1 > size) + { + errno = ERANGE; + go_back(path); + return ((char*)NULL); + } + if (strlen(path) == 0) + { + strcpy(buffer, "/"); + return (buffer); + } + *buffer = '\0'; + while ((r = strrchr(path, '/')) != (char*)NULL) + { + strcat(buffer, r); + *r = '\0'; + } + return (chdir(buffer) ? (char*)NULL : buffer); +} + +static void go_back(char* path) +{ + /* If getcwd() gets in trouble and can't complete normally, reverse the + * path built so far and change there so we end up in the directory that + * we started in. + */ + + char* r; + + while ((r = strrchr(path, '/')) != (char*)NULL) + { + chdir(r + 1); + *r = '\0'; + } +} diff --git a/plat/minix68k/libsys/_getegid.c b/plat/minix68k/libsys/_getegid.c new file mode 100644 index 0000000000..2dc381b99e --- /dev/null +++ b/plat/minix68k/libsys/_getegid.c @@ -0,0 +1,13 @@ +#include "lib.h" +#include +#define getegid _getegid +#include + +PUBLIC gid_t getegid(void) +{ + int k; + k = _callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k < 0) + return ((gid_t)k); + return ((gid_t)_M.m2_i1); +} diff --git a/plat/minix68k/libsys/_geteuid.c b/plat/minix68k/libsys/_geteuid.c new file mode 100644 index 0000000000..86be82414c --- /dev/null +++ b/plat/minix68k/libsys/_geteuid.c @@ -0,0 +1,13 @@ +#include "lib.h" +#include +#define geteuid _geteuid +#include + +PUBLIC uid_t geteuid(void) +{ + int k; + k = _callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k < 0) + return ((uid_t)k); + return ((uid_t)_M.m2_i1); +} diff --git a/plat/minix68k/libsys/_getgid.c b/plat/minix68k/libsys/_getgid.c new file mode 100644 index 0000000000..7d324c6e49 --- /dev/null +++ b/plat/minix68k/libsys/_getgid.c @@ -0,0 +1,9 @@ +#include "lib.h" +#include +#define getgid _getgid +#include + +PUBLIC gid_t getgid(void) +{ + return ((gid_t)_callm1(MM, GETGID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_getpid.c b/plat/minix68k/libsys/_getpid.c new file mode 100644 index 0000000000..c1042210cb --- /dev/null +++ b/plat/minix68k/libsys/_getpid.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define getpid _getpid +#include + +PUBLIC int getpid() +{ + return (_callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_getppid.c b/plat/minix68k/libsys/_getppid.c new file mode 100644 index 0000000000..c541f20e7a --- /dev/null +++ b/plat/minix68k/libsys/_getppid.c @@ -0,0 +1,13 @@ +#include "lib.h" +#define getppid _getppid +#include + +PUBLIC int getppid(void) +{ + int p; + + p = _callm1(MM, GETPID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (p < 0) + return (p); + return (_M.m2_i1); +} diff --git a/plat/minix68k/libsys/_getuid.c b/plat/minix68k/libsys/_getuid.c new file mode 100644 index 0000000000..b3cf3ebb1b --- /dev/null +++ b/plat/minix68k/libsys/_getuid.c @@ -0,0 +1,9 @@ +#include "lib.h" +#include +#define getuid _getuid +#include + +PUBLIC uid_t getuid(void) +{ + return ((uid_t)_callm1(MM, GETUID, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_gtty.c b/plat/minix68k/libsys/_gtty.c new file mode 100644 index 0000000000..b144337155 --- /dev/null +++ b/plat/minix68k/libsys/_gtty.c @@ -0,0 +1,11 @@ +#include "lib.h" +#define gtty _gtty +#define ioctl _ioctl +#include + +PUBLIC int gtty(fd, argp) +int fd; +struct sgttyb* argp; +{ + return (ioctl(fd, TIOCGETP, argp)); +} diff --git a/plat/minix68k/libsys/_ioctl.c b/plat/minix68k/libsys/_ioctl.c new file mode 100644 index 0000000000..a0b863b388 --- /dev/null +++ b/plat/minix68k/libsys/_ioctl.c @@ -0,0 +1,76 @@ +#include "lib.h" +#include +#include +#define ioctl _ioctl +#include + +PUBLIC int ioctl(int fd, int request, struct sgttyb* argp) +{ + int n; + long erase, kill, intr, quit, xon, xoff, eof, brk, speed; + struct tchars* argt; + + _M.TTY_REQUEST = request; + _M.TTY_LINE = fd; + + switch (request) + { + case TIOCSETP: + erase = argp->sg_erase & BYTE; + kill = argp->sg_kill & BYTE; + speed = ((argp->sg_ospeed & BYTE) << 8) | (argp->sg_ispeed & BYTE); + _M.TTY_SPEK = (speed << 16) | (erase << 8) | kill; + _M.TTY_FLAGS = argp->sg_flags; + n = _callx(FS, IOCTL); + return (n); + + case TIOCSETC: + argt = (struct tchars* /* kludge */)argp; + intr = argt->t_intrc & BYTE; + quit = argt->t_quitc & BYTE; + xon = argt->t_startc & BYTE; + xoff = argt->t_stopc & BYTE; + eof = argt->t_eofc & BYTE; + brk = argt->t_brkc & BYTE; /* not used at the moment */ + _M.TTY_SPEK = (intr << 24) | (quit << 16) | (xon << 8) | (xoff << 0); + _M.TTY_FLAGS = (eof << 8) | (brk << 0); + n = _callx(FS, IOCTL); + return (n); + + case TIOCGETP: + n = _callx(FS, IOCTL); + argp->sg_erase = (_M.TTY_SPEK >> 8) & BYTE; + argp->sg_kill = (_M.TTY_SPEK >> 0) & BYTE; + argp->sg_flags = _M.TTY_FLAGS & 0xFFFFL; + speed = (_M.TTY_SPEK >> 16) & 0xFFFFL; + argp->sg_ispeed = speed & BYTE; + argp->sg_ospeed = (speed >> 8) & BYTE; + return (n); + + case TIOCGETC: + n = _callx(FS, IOCTL); + argt = (struct tchars*)argp; + argt->t_intrc = (_M.TTY_SPEK >> 24) & BYTE; + argt->t_quitc = (_M.TTY_SPEK >> 16) & BYTE; + argt->t_startc = (_M.TTY_SPEK >> 8) & BYTE; + argt->t_stopc = (_M.TTY_SPEK >> 0) & BYTE; + argt->t_eofc = (_M.TTY_FLAGS >> 8) & BYTE; + argt->t_brkc = (_M.TTY_FLAGS >> 8) & BYTE; + return (n); + + /* This is silly, do we want to add 1001 cases and _M.TTY_XYZ's here? + * We should just pop argp into the message for low-level interpretation. + */ + + case TIOCFLUSH: + _M.TTY_FLAGS = (int /* kludge */)(intptr_t)argp; + return _callx(FS, IOCTL); + + /* decided to pop argp in the ADDRESS field. Left TIOCFLUSH a special case + * since it affects other platforms and old software too. FM + */ + default: + _M.ADDRESS = (char*)argp; + return _callx(FS, IOCTL); + } +} diff --git a/plat/minix68k/libsys/_kill.c b/plat/minix68k/libsys/_kill.c new file mode 100644 index 0000000000..c6d3717e39 --- /dev/null +++ b/plat/minix68k/libsys/_kill.c @@ -0,0 +1,10 @@ +#include "lib.h" +#define kill _kill +#include + +PUBLIC int kill(proc, sig) +int proc; /* which process is to be sent the signal */ +int sig; /* signal number */ +{ + return (_callm1(MM, KILL, proc, sig, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_link.c b/plat/minix68k/libsys/_link.c new file mode 100644 index 0000000000..2ea924461a --- /dev/null +++ b/plat/minix68k/libsys/_link.c @@ -0,0 +1,11 @@ +#include "lib.h" +#define link _link +#include + +PUBLIC int link(_CONST char* name, _CONST char* name2) +{ + return (_callm1( + FS, LINK, _len(name), _len(name2), 0, (char*)name, + (char*)name2, /* perhaps callm1 preserves these */ + NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_lseek.c b/plat/minix68k/libsys/_lseek.c new file mode 100644 index 0000000000..ed4d4b977a --- /dev/null +++ b/plat/minix68k/libsys/_lseek.c @@ -0,0 +1,19 @@ +#include "lib.h" +#include +#define lseek _lseek +#include + +PUBLIC off_t lseek(fd, offset, whence) +int fd; +off_t offset; +int whence; +{ + int k; + _M.m2_i1 = fd; + _M.m2_l1 = offset; + _M.m2_i2 = whence; + k = _callx(FS, LSEEK); + if (k != 0) + return ((off_t)k); /* _send() itself failed */ + return ((off_t)_M.m2_l1); +} diff --git a/plat/minix68k/libsys/_mkdir.c b/plat/minix68k/libsys/_mkdir.c new file mode 100644 index 0000000000..1d10129242 --- /dev/null +++ b/plat/minix68k/libsys/_mkdir.c @@ -0,0 +1,10 @@ +#include "lib.h" +#define mkdir _mkdir +#include + +PUBLIC int mkdir(name, mode) +_CONST char* name; +int mode; +{ + return (_callm1(FS, MKDIR, _len(name), mode, 0, (char*)name, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_mkfifo.c b/plat/minix68k/libsys/_mkfifo.c new file mode 100644 index 0000000000..52df71b1f2 --- /dev/null +++ b/plat/minix68k/libsys/_mkfifo.c @@ -0,0 +1,12 @@ +#include "lib.h" +#include +#define mkfifo _mkfifo +#include + +PUBLIC int mkfifo(name, mode) +_CONST char* name; +int mode; +{ + mode = (mode & 0777) | S_IFIFO; + return (_callm1(FS, MKNOD, _len(name), (int)mode, 0, (char*)name, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_mknod.c b/plat/minix68k/libsys/_mknod.c new file mode 100644 index 0000000000..cc7ebb1162 --- /dev/null +++ b/plat/minix68k/libsys/_mknod.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define mknod _mknod +#include + +PUBLIC int mknod(_CONST char* name, int mode, int addr) +{ + return (_callm1(FS, MKNOD, _len(name), mode, addr, (char*)name, (char*)0, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_mknod4.c b/plat/minix68k/libsys/_mknod4.c new file mode 100644 index 0000000000..207c032c77 --- /dev/null +++ b/plat/minix68k/libsys/_mknod4.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define mknod4 _mknod4 +#include + +PUBLIC int mknod4(_CONST char* name, int mode, int addr, unsigned int size) +{ + return (_callm1(FS, MKNOD, _len(name), mode, addr, (char*)name, (char*)size, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_mount.c b/plat/minix68k/libsys/_mount.c new file mode 100644 index 0000000000..e414ce36f3 --- /dev/null +++ b/plat/minix68k/libsys/_mount.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define mount _mount +#include + +PUBLIC int mount(char* name, char* special, int rwflag) +{ + return (_callm1(FS, MOUNT, _len(special), _len(name), rwflag, special, name, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_open.c b/plat/minix68k/libsys/_open.c new file mode 100644 index 0000000000..06cf89882c --- /dev/null +++ b/plat/minix68k/libsys/_open.c @@ -0,0 +1,33 @@ +#include "lib.h" +#include +#define open _open +#include + +#if _ANSI +#include + +PUBLIC int open(const char* name, int flags, ...) +{ + int i; + va_list ap; + + if (flags & O_CREAT) + { + va_start(ap, flags); + i = va_arg(ap, int); + i = _callm1(FS, OPEN, _len(name), flags, i, (char*)name, NIL_PTR, NIL_PTR); + va_end(ap); + return i; + } + return _callm3(FS, OPEN, flags, name); +} +#else +PUBLIC int open(name, flags, mode) +_CONST char* name; +int flags, mode; +{ + if (flags & O_CREAT) + return _callm1(FS, OPEN, _len(name), flags, mode, (char*)name, NIL_PTR, NIL_PTR); + return (_callm3(FS, OPEN, flags, name)); +} +#endif diff --git a/plat/minix68k/libsys/_pause.c b/plat/minix68k/libsys/_pause.c new file mode 100644 index 0000000000..d5dfdf50eb --- /dev/null +++ b/plat/minix68k/libsys/_pause.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define pause _pause +#include + +PUBLIC int pause() +{ + return (_callm1(MM, PAUSE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_pipe.c b/plat/minix68k/libsys/_pipe.c new file mode 100644 index 0000000000..69913b11f4 --- /dev/null +++ b/plat/minix68k/libsys/_pipe.c @@ -0,0 +1,18 @@ +#include "lib.h" +#define pipe _pipe +#include + +PUBLIC int pipe(fild) +int fild[2]; +{ + int k; + k = _callm1(FS, PIPE, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k >= 0) + { + fild[0] = _M.m1_i1; + fild[1] = _M.m1_i2; + return (0); + } + else + return (k); +} diff --git a/plat/minix68k/libsys/_ptrace.c b/plat/minix68k/libsys/_ptrace.c new file mode 100644 index 0000000000..c296ee216f --- /dev/null +++ b/plat/minix68k/libsys/_ptrace.c @@ -0,0 +1,19 @@ +#include "lib.h" +#define ptrace _ptrace +#include + +PUBLIC long ptrace(int req, int pid, long addr, long data) +{ + _M.m2_i1 = pid; + _M.m2_i2 = req; + _M.m2_l1 = addr; + _M.m2_l2 = data; + if (_callx(MM, PTRACE) == -1) + return (-1L); + if (_M.m2_l2 == -1) + { + errno = 0; + return (-1L); + } + return (_M.m2_l2); +} diff --git a/plat/minix68k/libsys/_read.c b/plat/minix68k/libsys/_read.c new file mode 100644 index 0000000000..a04682cd70 --- /dev/null +++ b/plat/minix68k/libsys/_read.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define read _read +#include + +PUBLIC ssize_t read(int fd, void* buffer, size_t nbytes) +{ + return (_callm1(FS, READ, fd, nbytes, 0, buffer, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_rename.c b/plat/minix68k/libsys/_rename.c new file mode 100644 index 0000000000..c8f118fb7a --- /dev/null +++ b/plat/minix68k/libsys/_rename.c @@ -0,0 +1,12 @@ +#include "lib.h" +#define rename _rename +#include + +PUBLIC int rename(name, name2) +_CONST char *name, *name2; +{ + return (_callm1( + FS, RENAME, _len(name), _len(name2), 0, (char*)name, + (char*)name2, /* perhaps callm1 preserves these */ + NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_rmdir.c b/plat/minix68k/libsys/_rmdir.c new file mode 100644 index 0000000000..9b7c870981 --- /dev/null +++ b/plat/minix68k/libsys/_rmdir.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define rmdir _rmdir +#include + +PUBLIC int rmdir(_CONST char* name) +{ + return (_callm3(FS, RMDIR, 0, name)); +} diff --git a/plat/minix68k/libsys/_setgid.c b/plat/minix68k/libsys/_setgid.c new file mode 100644 index 0000000000..1f46f559fc --- /dev/null +++ b/plat/minix68k/libsys/_setgid.c @@ -0,0 +1,9 @@ +#include "lib.h" +#include +#define setgid _setgid +#include + +PUBLIC int setgid(gid_t grp) +{ + return (_callm1(MM, SETGID, (int)grp, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_setuid.c b/plat/minix68k/libsys/_setuid.c new file mode 100644 index 0000000000..30021bbd8a --- /dev/null +++ b/plat/minix68k/libsys/_setuid.c @@ -0,0 +1,9 @@ +#include "lib.h" +#include +#define setuid _setuid +#include + +PUBLIC int setuid(int usr) +{ + return (_callm1(MM, SETUID, (int)usr, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_signal.c b/plat/minix68k/libsys/_signal.c new file mode 100644 index 0000000000..1871d4e94c --- /dev/null +++ b/plat/minix68k/libsys/_signal.c @@ -0,0 +1,43 @@ +#include "lib.h" +#define signal _signal +#include + +extern _PROTOTYPE(void(*_vectab[_NSIG]), (int)); /* array of funcs to catch signals */ + +/* The definition of signal really should be + * PUBLIC void (*signal(signr, func))() + * but some compilers refuse to accept this, even though it is correct. + * The only thing to do if you are stuck with such a defective compiler is + * change it to + * PUBLIC void *signal(signr, func) + * and change ../h/signal.h accordingly. + */ + +PUBLIC void (*signal(signr, func))() int signr; /* which signal is being set */ +_PROTOTYPE(void(*func), (int)); /* pointer to function that catches signal */ +{ + int r; + _PROTOTYPE(void(*old), (int)); + + old = _vectab[signr - 1]; + _M.m6_i1 = signr; + if (func == SIG_IGN || func == SIG_DFL) + /* Keep old signal catcher until it is completely de-installed */ + _M.m6_f1 = func; + else + { + /* Use new signal catcher immediately (old one may not exist) */ + _vectab[signr - 1] = func; + _M.m6_f1 = _begsig; + } + r = _callx(MM, SIGNAL); + if (r < 0) + { + _vectab[signr - 1] = old; /* undo any pre-installation */ + return ((void (*)())r); + } + _vectab[signr - 1] = func; /* redo any pre-installation */ + if (r == 1) + return (SIG_IGN); + return (old); +} diff --git a/plat/minix68k/libsys/_stat.c b/plat/minix68k/libsys/_stat.c new file mode 100644 index 0000000000..a2fe60aee7 --- /dev/null +++ b/plat/minix68k/libsys/_stat.c @@ -0,0 +1,10 @@ +#include "lib.h" +#define stat _stat +#include + +PUBLIC int stat(name, buffer) +_CONST char* name; +struct stat* buffer; +{ + return (_callm1(FS, STAT, _len(name), 0, 0, (char*)name, (char*)buffer, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_stime.c b/plat/minix68k/libsys/_stime.c new file mode 100644 index 0000000000..d1ae44531a --- /dev/null +++ b/plat/minix68k/libsys/_stime.c @@ -0,0 +1,9 @@ +#include "lib.h" +#define stime _stime +#include + +PUBLIC int stime(long* top) +{ + _M.m2_l1 = *top; + return (_callx(FS, STIME)); +} diff --git a/mach/minixST/libsys/_stsndrec.s b/plat/minix68k/libsys/_stsndrec.s similarity index 100% rename from mach/minixST/libsys/_stsndrec.s rename to plat/minix68k/libsys/_stsndrec.s diff --git a/plat/minix68k/libsys/_stty.c b/plat/minix68k/libsys/_stty.c new file mode 100644 index 0000000000..45ea8d68c0 --- /dev/null +++ b/plat/minix68k/libsys/_stty.c @@ -0,0 +1,11 @@ +#include "lib.h" +#define stty _stty +#define ioctl _ioctl +#include + +PUBLIC int stty(fd, argp) +int fd; +struct sgttyb* argp; +{ + return ioctl(fd, TIOCSETP, argp); +} diff --git a/plat/minix68k/libsys/_sync.c b/plat/minix68k/libsys/_sync.c new file mode 100644 index 0000000000..77e20786ad --- /dev/null +++ b/plat/minix68k/libsys/_sync.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define sync _sync +#include + +PUBLIC int sync(void) +{ + return (_callm1(FS, SYNC, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); +} diff --git a/plat/minix68k/libsys/_time.c b/plat/minix68k/libsys/_time.c new file mode 100644 index 0000000000..55897fc804 --- /dev/null +++ b/plat/minix68k/libsys/_time.c @@ -0,0 +1,20 @@ +#include "lib.h" +#define time _time +#include + +PUBLIC long time(tp) +long* tp; +{ + int k; + long l; + k = _callm1(FS, TIME, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (_M.m_type < 0 || k != 0) + { + errno = -_M.m_type; + return (-1L); + } + l = _M.m2_l1; + if (tp != (long*)0) + *tp = l; + return (l); +} diff --git a/plat/minix68k/libsys/_times.c b/plat/minix68k/libsys/_times.c new file mode 100644 index 0000000000..9d8c91b8df --- /dev/null +++ b/plat/minix68k/libsys/_times.c @@ -0,0 +1,17 @@ +#include "lib.h" +#include +#include +#define times _times +#include + +PUBLIC clock_t times(buf) +struct tms* buf; +{ + clock_t k; + k = (clock_t)_callm1(FS, TIMES, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + buf->tms_utime = _M.m4_l1; + buf->tms_stime = _M.m4_l2; + buf->tms_cutime = _M.m4_l3; + buf->tms_cstime = _M.m4_l4; + return (k); +} diff --git a/mach/minixST/libsys/_umask.c b/plat/minix68k/libsys/_umask.c similarity index 53% rename from mach/minixST/libsys/_umask.c rename to plat/minix68k/libsys/_umask.c index 70c80c395d..4e67baa05e 100644 --- a/mach/minixST/libsys/_umask.c +++ b/plat/minix68k/libsys/_umask.c @@ -1,10 +1,10 @@ -#include +#include "lib.h" #include -#define umask _umask +#define umask _umask #include PUBLIC mode_t umask(complmode) int complmode; { - return((mode_t)_callm1(FS, UMASK, (int)complmode, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); + return ((mode_t)_callm1(FS, UMASK, (int)complmode, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR)); } diff --git a/plat/minix68k/libsys/_umount.c b/plat/minix68k/libsys/_umount.c new file mode 100644 index 0000000000..f844751c1b --- /dev/null +++ b/plat/minix68k/libsys/_umount.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define umount _umount +#include + +PUBLIC int umount(_CONST char* name) +{ + return (_callm3(FS, UMOUNT, 0, name)); +} diff --git a/plat/minix68k/libsys/_unlink.c b/plat/minix68k/libsys/_unlink.c new file mode 100644 index 0000000000..f791930d2d --- /dev/null +++ b/plat/minix68k/libsys/_unlink.c @@ -0,0 +1,9 @@ +#include "lib.h" +#define unlink _unlink +#include + +PUBLIC int unlink(name) +_CONST char* name; +{ + return (_callm3(FS, UNLINK, 0, name)); +} diff --git a/plat/minix68k/libsys/_utime.c b/plat/minix68k/libsys/_utime.c new file mode 100644 index 0000000000..408ab244bf --- /dev/null +++ b/plat/minix68k/libsys/_utime.c @@ -0,0 +1,28 @@ +/* _utime(2) for POSIX Authors: Terrence W. Holm & Edwin L. Froese */ + +#include "lib.h" +#define time _time +#include +#define utime _utime +#include + +PUBLIC int utime(const char* name, const struct utimbuf* timp) +{ + long current_time; + + if (timp == (struct utimbuf*)NULL) + { + current_time = time((long*)NULL); + _M.m2_l1 = current_time; + _M.m2_l2 = current_time; + } + else + { + _M.m2_l1 = timp->actime; + _M.m2_l2 = timp->modtime; + } + + _M.m2_i1 = _len(name); + _M.m2_p1 = (void*) name; + return _callx(FS, UTIME); +} diff --git a/plat/minix68k/libsys/_wait.c b/plat/minix68k/libsys/_wait.c new file mode 100644 index 0000000000..eab3c2f6df --- /dev/null +++ b/plat/minix68k/libsys/_wait.c @@ -0,0 +1,13 @@ +#include "lib.h" +#define wait _wait +#include + +PUBLIC int wait(status) +int* status; +{ + int k; + k = _callm1(MM, WAIT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + if (k >= 0 && status != 0) + *status = _M.m2_i1; + return (k); +} diff --git a/plat/minix68k/libsys/_write.c b/plat/minix68k/libsys/_write.c new file mode 100644 index 0000000000..9f2cd6e4c8 --- /dev/null +++ b/plat/minix68k/libsys/_write.c @@ -0,0 +1,8 @@ +#include "lib.h" +#define write _write +#include + +PUBLIC ssize_t write(int fd, const void* buffer, size_t nbytes) +{ + return _callm1(FS, WRITE, fd, nbytes, 0, (char*)buffer, NULL, NULL); +} diff --git a/mach/minixST/libsys/access.s b/plat/minix68k/libsys/access.s similarity index 100% rename from mach/minixST/libsys/access.s rename to plat/minix68k/libsys/access.s diff --git a/mach/minixST/libsys/alarm.s b/plat/minix68k/libsys/alarm.s similarity index 100% rename from mach/minixST/libsys/alarm.s rename to plat/minix68k/libsys/alarm.s diff --git a/mach/minixST/libsys/brk.s b/plat/minix68k/libsys/brk.s similarity index 100% rename from mach/minixST/libsys/brk.s rename to plat/minix68k/libsys/brk.s diff --git a/plat/minix68k/libsys/build.lua b/plat/minix68k/libsys/build.lua new file mode 100644 index 0000000000..34de855cb4 --- /dev/null +++ b/plat/minix68k/libsys/build.lua @@ -0,0 +1,142 @@ +acklibrary { + name = "lib", + srcs = { + "./_access.c", + "./access.s", + "./_alarm.c", + "./alarm.s", + "./_brk.c", + "./brk.s", + "./call.c", + "./_chdir.c", + "./chdir.s", + "./_chmod.c", + "./chmod.s", + "./_chown.c", + "./chown.s", + "./_chroot.c", + "./chroot.s", + "./cleanup.c", + "./_close.c", + "./close.s", + "./_creat.c", + "./creat.s", + "./_dup2.c", + "./dup2.s", + "./_dup.c", + "./dup.s", + "./errno.c", + "./_exec.c", + "./_execn.c", + "./_execnl.c", + "./execnl.s", + "./execn.s", + "./exec.s", + "./_exit.c", + "./exit.c", + "./_fcntl.c", + "./fcntl.s", + "./_fork.c", + "./fork.s", + "./fpathconf.c", + "./_fstat.c", + "./fstat.s", + "./_getcwd.c", + "./getcwd.s", + "./_getegid.c", + "./getegid.s", + "./_geteuid.c", + "./geteuid.s", + "./_getgid.c", + "./getgid.s", + "./_getpid.c", + "./getpid.s", + "./_getppid.c", + "./getppid.s", + "./_getuid.c", + "./getuid.s", + "./_gtty.c", + "./gtty.s", + "./head_em.s", + "./_ioctl.c", + "./ioctl.s", + "./isatty.c", + "./_kill.c", + "./kill.s", + "./_link.c", + "./link.s", + "./_lseek.c", + "./lseek.s", + "./message.c", + "./_mkdir.c", + "./mkdir.s", + "./_mkfifo.c", + "./mkfifo.s", + "./_mknod4.c", + "./mknod4.s", + "./_mknod.c", + "./mknod.s", + "./_mount.c", + "./mount.s", + "./_open.c", + "./open.s", + "./pathconf.c", + "./_pause.c", + "./pause.s", + "./_pipe.c", + "./pipe.s", + "./_ptrace.c", + "./ptrace.s", + "./_read.c", + "./read.s", + "./_rename.c", + "./rename.s", + "./_rmdir.c", + "./rmdir.s", + "./_setgid.c", + "./setgid.s", + "./_setuid.c", + "./setuid.s", + "./_signal.c", + "./signal.s", + "./_stat.c", + "./stat.s", + "./stbrksz.s", + "./stcatch.s", + "./_stime.c", + "./stime.s", + "./_stsndrec.s", + "./stsndrec.s", + "./_stty.c", + "./stty.s", + "./_sync.c", + "./sync.s", + "./syslib.c", + "./_time.c", + "./time.s", + "./_times.c", + "./times.s", + "./_umask.c", + "./umask.s", + "./_umount.c", + "./umount.s", + "./_unlink.c", + "./unlink.s", + "./_utime.c", + "./utime.s", + "./vectab.c", + "./_wait.c", + "./wait.s", + "./_write.c", + "./write.s", + }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/minix68k/include+headers", + "./lib.h", + }, + vars = { + plat = "minix68k" + } +} + diff --git a/plat/minix68k/libsys/call.c b/plat/minix68k/libsys/call.c new file mode 100644 index 0000000000..976ac91593 --- /dev/null +++ b/plat/minix68k/libsys/call.c @@ -0,0 +1,79 @@ +#include "lib.h" + +PUBLIC int _callm1(proc, syscallnr, int1, int2, int3, ptr1, ptr2, ptr3) +int proc; /* FS or MM */ +int syscallnr; /* which system call */ +int int1; /* first integer parameter */ +int int2; /* second integer parameter */ +int int3; /* third integer parameter */ +char* ptr1; /* pointer parameter */ +char* ptr2; /* pointer parameter */ +char* ptr3; /* pointer parameter */ +{ + /* Send a message and get the response. The '_M.m_type' field of the + * reply contains a value (>= 0) or an error code (<0). Use message format m1. + */ + _M.m1_i1 = int1; + _M.m1_i2 = int2; + _M.m1_i3 = int3; + _M.m1_p1 = ptr1; + _M.m1_p2 = ptr2; + _M.m1_p3 = ptr3; + return _callx(proc, syscallnr); +} + +PUBLIC int _callm3(proc, syscallnr, int1, name) +int proc; /* FS or MM */ +int syscallnr; /* which system call */ +int int1; /* integer parameter */ +_CONST char* name; /* string */ +{ + /* This form of system call is used for those calls that contain at most + * one integer parameter along with a string. If the string fits in the + * message, it is copied there. If not, a pointer to it is passed. + */ + int k; + char* rp; + k = _len(name); + _M.m3_i1 = k; + _M.m3_i2 = int1; + _M.m3_p1 = (char*)name; + rp = &_M.m3_ca1[0]; + if (k <= M3_STRING) + while (k--) + *rp++ = *name++; + return _callx(proc, syscallnr); +} + +PUBLIC int _callx(proc, syscallnr) +int proc; /* FS or MM */ +int syscallnr; /* which system call */ +{ + /* Send a message and get the response. The '_M.m_type' field of the + * reply contains a value (>= 0) or an error code (<0). + */ + int k; + + _M.m_type = syscallnr; + k = _sendrec(proc, &_M); + if (k != 0) + return (k); /* _send() itself failed */ + if (_M.m_type < 0) + { + errno = -_M.m_type; + return (-1); + } + return (_M.m_type); +} + +PUBLIC int _len(s) +_CONST register char* s; /* character string whose length is needed */ +{ + /* Return the length of a character string, including the 0 at the end. */ + int k; + + k = 0; + while (*s++ != 0) + k++; + return (k + 1); /* return length including the 0-byte at end */ +} diff --git a/mach/minixST/libsys/chdir.s b/plat/minix68k/libsys/chdir.s similarity index 100% rename from mach/minixST/libsys/chdir.s rename to plat/minix68k/libsys/chdir.s diff --git a/mach/minixST/libsys/chmod.s b/plat/minix68k/libsys/chmod.s similarity index 100% rename from mach/minixST/libsys/chmod.s rename to plat/minix68k/libsys/chmod.s diff --git a/mach/minixST/libsys/chown.s b/plat/minix68k/libsys/chown.s similarity index 100% rename from mach/minixST/libsys/chown.s rename to plat/minix68k/libsys/chown.s diff --git a/mach/minixST/libsys/chroot.s b/plat/minix68k/libsys/chroot.s similarity index 100% rename from mach/minixST/libsys/chroot.s rename to plat/minix68k/libsys/chroot.s diff --git a/plat/minix68k/libsys/cleanup.c b/plat/minix68k/libsys/cleanup.c new file mode 100644 index 0000000000..3e16568fe5 --- /dev/null +++ b/plat/minix68k/libsys/cleanup.c @@ -0,0 +1,3 @@ +void _cleanup(void) +{ +} diff --git a/mach/minixST/libsys/close.s b/plat/minix68k/libsys/close.s similarity index 100% rename from mach/minixST/libsys/close.s rename to plat/minix68k/libsys/close.s diff --git a/mach/minixST/libsys/creat.s b/plat/minix68k/libsys/creat.s similarity index 100% rename from mach/minixST/libsys/creat.s rename to plat/minix68k/libsys/creat.s diff --git a/mach/minixST/libsys/dup.s b/plat/minix68k/libsys/dup.s similarity index 100% rename from mach/minixST/libsys/dup.s rename to plat/minix68k/libsys/dup.s diff --git a/mach/minixST/libsys/dup2.s b/plat/minix68k/libsys/dup2.s similarity index 100% rename from mach/minixST/libsys/dup2.s rename to plat/minix68k/libsys/dup2.s diff --git a/mach/minixST/libsys/errno.c b/plat/minix68k/libsys/errno.c similarity index 84% rename from mach/minixST/libsys/errno.c rename to plat/minix68k/libsys/errno.c index 538fd572f7..013f5b79dd 100644 --- a/mach/minixST/libsys/errno.c +++ b/plat/minix68k/libsys/errno.c @@ -1,4 +1,4 @@ -#include +#include "lib.h" /* errno.c - declare variable errno Author: F. Meulenbroeks */ int errno = 0; diff --git a/mach/minixST/libsys/exec.s b/plat/minix68k/libsys/exec.s similarity index 100% rename from mach/minixST/libsys/exec.s rename to plat/minix68k/libsys/exec.s diff --git a/mach/minixST/libsys/execn.s b/plat/minix68k/libsys/execn.s similarity index 100% rename from mach/minixST/libsys/execn.s rename to plat/minix68k/libsys/execn.s diff --git a/mach/minixST/libsys/execnl.s b/plat/minix68k/libsys/execnl.s similarity index 100% rename from mach/minixST/libsys/execnl.s rename to plat/minix68k/libsys/execnl.s diff --git a/plat/minix68k/libsys/exit.c b/plat/minix68k/libsys/exit.c new file mode 100644 index 0000000000..9d54b0fa2f --- /dev/null +++ b/plat/minix68k/libsys/exit.c @@ -0,0 +1,8 @@ +#include "lib.h" +#include + +PUBLIC int exit(int status) +{ + _cleanup(); + _exit(status); +} diff --git a/mach/minixST/libsys/fcntl.s b/plat/minix68k/libsys/fcntl.s similarity index 100% rename from mach/minixST/libsys/fcntl.s rename to plat/minix68k/libsys/fcntl.s diff --git a/mach/minixST/libsys/fork.s b/plat/minix68k/libsys/fork.s similarity index 100% rename from mach/minixST/libsys/fork.s rename to plat/minix68k/libsys/fork.s diff --git a/plat/minix68k/libsys/fpathconf.c b/plat/minix68k/libsys/fpathconf.c new file mode 100644 index 0000000000..8d0d53b2b7 --- /dev/null +++ b/plat/minix68k/libsys/fpathconf.c @@ -0,0 +1,61 @@ +/* POSIX fpathconf (Sec. 5.7.1) Author: Andy Tanenbaum */ + +#include "lib.h" +#include +#include +#define fstat _fstat +#include +#include +#include + +PUBLIC long +fpathconf(int fd /* file descriptor being interrogated */, int name /* property being inspected */) +{ + /* POSIX allows some of the values in to be increased at + * run time. The pathconf and fpathconf functions allow these values + * to be checked at run time. MINIX does not use this facility. + * The run-time limits are those given in . + */ + + struct stat stbuf; + + switch (name) + { + case _PC_LINK_MAX: + /* Fstat the file. If that fails, return -1. */ + if (fstat(fd, &stbuf) != 0) + return (-1L); + if (S_ISDIR(stbuf.st_mode)) + return (1L); /* no links to directories */ + else + return ((long)LINK_MAX); + + case _PC_MAX_CANON: + return ((long)MAX_CANON); + + case _PC_MAX_INPUT: + return ((long)MAX_INPUT); + + case _PC_NAME_MAX: + return ((long)NAME_MAX); + + case _PC_PATH_MAX: + return ((long)PATH_MAX); + + case _PC_PIPE_BUF: + return ((long)PIPE_BUF); + + case _PC_CHOWN_RESTRICTED: + return ((long)1); /* MINIX defines CHOWN_RESTRICTED */ + + case _PC_NO_TRUNC: /* MINIX does not define NO_TRUNC */ + return ((long)0); + + case _PC_VDISABLE: /* MINIX defines VDISABLE */ + return ((long)_POSIX_VDISABLE); + + default: + errno = EINVAL; + return (-1L); + } +} diff --git a/mach/minixST/libsys/fstat.s b/plat/minix68k/libsys/fstat.s similarity index 100% rename from mach/minixST/libsys/fstat.s rename to plat/minix68k/libsys/fstat.s diff --git a/mach/minixST/libsys/getcwd.s b/plat/minix68k/libsys/getcwd.s similarity index 100% rename from mach/minixST/libsys/getcwd.s rename to plat/minix68k/libsys/getcwd.s diff --git a/mach/minixST/libsys/getegid.s b/plat/minix68k/libsys/getegid.s similarity index 100% rename from mach/minixST/libsys/getegid.s rename to plat/minix68k/libsys/getegid.s diff --git a/mach/minixST/libsys/geteuid.s b/plat/minix68k/libsys/geteuid.s similarity index 100% rename from mach/minixST/libsys/geteuid.s rename to plat/minix68k/libsys/geteuid.s diff --git a/mach/minixST/libsys/getgid.s b/plat/minix68k/libsys/getgid.s similarity index 100% rename from mach/minixST/libsys/getgid.s rename to plat/minix68k/libsys/getgid.s diff --git a/mach/minixST/libsys/getpid.s b/plat/minix68k/libsys/getpid.s similarity index 100% rename from mach/minixST/libsys/getpid.s rename to plat/minix68k/libsys/getpid.s diff --git a/mach/minixST/libsys/getppid.s b/plat/minix68k/libsys/getppid.s similarity index 100% rename from mach/minixST/libsys/getppid.s rename to plat/minix68k/libsys/getppid.s diff --git a/mach/minixST/libsys/getuid.s b/plat/minix68k/libsys/getuid.s similarity index 100% rename from mach/minixST/libsys/getuid.s rename to plat/minix68k/libsys/getuid.s diff --git a/mach/minixST/libsys/gtty.s b/plat/minix68k/libsys/gtty.s similarity index 100% rename from mach/minixST/libsys/gtty.s rename to plat/minix68k/libsys/gtty.s diff --git a/mach/minixST/libsys/head_em.s b/plat/minix68k/libsys/head_em.s similarity index 100% rename from mach/minixST/libsys/head_em.s rename to plat/minix68k/libsys/head_em.s diff --git a/mach/minixST/libsys/ioctl.s b/plat/minix68k/libsys/ioctl.s similarity index 100% rename from mach/minixST/libsys/ioctl.s rename to plat/minix68k/libsys/ioctl.s diff --git a/plat/minix68k/libsys/isatty.c b/plat/minix68k/libsys/isatty.c new file mode 100644 index 0000000000..a348817144 --- /dev/null +++ b/plat/minix68k/libsys/isatty.c @@ -0,0 +1,15 @@ +#include + +int isatty(int fd) +{ + switch (fd) + { + case 0: + case 1: + case 2: + return 1; + + default: + return 0; + } +} \ No newline at end of file diff --git a/mach/minixST/libsys/kill.s b/plat/minix68k/libsys/kill.s similarity index 100% rename from mach/minixST/libsys/kill.s rename to plat/minix68k/libsys/kill.s diff --git a/plat/minix68k/libsys/lib.h b/plat/minix68k/libsys/lib.h new file mode 100644 index 0000000000..41f00b113c --- /dev/null +++ b/plat/minix68k/libsys/lib.h @@ -0,0 +1,48 @@ +/* The "lib.h" header is the master header used by the library. + * All the C files in the lib subdirectories include it. + */ + +#ifndef _LIB_H +#define _LIB_H + +/* First come the defines. */ +#define _POSIX_SOURCE 1 /* tell headers to include POSIX stuff */ +#define _MINIX 1 /* tell headers to include MINIX stuff */ + +/* The following are so basic, all the lib files get them automatically. */ +#include /* must be first */ +#include +#include +#include +#include + +#include +#include +#include + +extern message _M; + +#define MM 0 +#define FS 1 + +_PROTOTYPE(int __execve, (char* _path, char** _argv, char** _envp, int _nargs, int _nenvps)); +_PROTOTYPE( + int _callm1, + (int _proc, + int _syscallnr, + int _int1, + int _int2, + int _int3, + char* _ptr1, + char* _ptr2, + char* _ptr3)); +_PROTOTYPE(int _callm3, (int _proc, int _syscallnr, int _int1, const char* _name)); +_PROTOTYPE(int _callx, (int _proc, int _syscallnr)); +_PROTOTYPE(int _len, (const char* _s)); +_PROTOTYPE(void panic, (const char* _message, int _errnum)); +_PROTOTYPE(int _sendrec, (int _src_dest, message* _m_ptr)); +_PROTOTYPE(void _begsig, (int _dummy)); + +extern void _cleanup(void); + +#endif /* _LIB_H */ diff --git a/mach/minixST/libsys/link.s b/plat/minix68k/libsys/link.s similarity index 100% rename from mach/minixST/libsys/link.s rename to plat/minix68k/libsys/link.s diff --git a/mach/minixST/libsys/lseek.s b/plat/minix68k/libsys/lseek.s similarity index 100% rename from mach/minixST/libsys/lseek.s rename to plat/minix68k/libsys/lseek.s diff --git a/mach/minixST/libsys/message.c b/plat/minix68k/libsys/message.c similarity index 66% rename from mach/minixST/libsys/message.c rename to plat/minix68k/libsys/message.c index 0b49808732..891fe09b86 100644 --- a/mach/minixST/libsys/message.c +++ b/plat/minix68k/libsys/message.c @@ -1,4 +1,4 @@ -#include +#include "lib.h" /* Some compilers require an initializer to force storage allocation */ -message _M = {0}; +message _M = { 0 }; diff --git a/mach/minixST/libsys/mkdir.s b/plat/minix68k/libsys/mkdir.s similarity index 100% rename from mach/minixST/libsys/mkdir.s rename to plat/minix68k/libsys/mkdir.s diff --git a/mach/minixST/libsys/mkfifo.s b/plat/minix68k/libsys/mkfifo.s similarity index 100% rename from mach/minixST/libsys/mkfifo.s rename to plat/minix68k/libsys/mkfifo.s diff --git a/mach/minixST/libsys/mknod.s b/plat/minix68k/libsys/mknod.s similarity index 100% rename from mach/minixST/libsys/mknod.s rename to plat/minix68k/libsys/mknod.s diff --git a/mach/minixST/libsys/mknod4.s b/plat/minix68k/libsys/mknod4.s similarity index 100% rename from mach/minixST/libsys/mknod4.s rename to plat/minix68k/libsys/mknod4.s diff --git a/mach/minixST/libsys/mount.s b/plat/minix68k/libsys/mount.s similarity index 100% rename from mach/minixST/libsys/mount.s rename to plat/minix68k/libsys/mount.s diff --git a/mach/minixST/libsys/open.s b/plat/minix68k/libsys/open.s similarity index 100% rename from mach/minixST/libsys/open.s rename to plat/minix68k/libsys/open.s diff --git a/plat/minix68k/libsys/pathconf.c b/plat/minix68k/libsys/pathconf.c new file mode 100644 index 0000000000..a591eaacd1 --- /dev/null +++ b/plat/minix68k/libsys/pathconf.c @@ -0,0 +1,28 @@ +/* POSIX pathconf (Sec. 5.7.1) Author: Andy Tanenbaum */ + +#include "lib.h" +#define open _open +#define close _close +#include +#include +#include +#include + +PUBLIC long pathconf( + const char* path /* name of file being interrogated */, int name /* property being inspected */) +{ + /* POSIX allows some of the values in to be increased at + * run time. The pathconf and fpathconf functions allow these values + * to be checked at run time. MINIX does not use this facility. + * The run-time limits are those given in . + */ + + int fd; + long val; + + if ((fd = open(path, O_RDONLY)) < 0) + return (-1L); + val = fpathconf(fd, name); + close(fd); + return (val); +} diff --git a/mach/minixST/libsys/pause.s b/plat/minix68k/libsys/pause.s similarity index 100% rename from mach/minixST/libsys/pause.s rename to plat/minix68k/libsys/pause.s diff --git a/mach/minixST/libsys/pipe.s b/plat/minix68k/libsys/pipe.s similarity index 100% rename from mach/minixST/libsys/pipe.s rename to plat/minix68k/libsys/pipe.s diff --git a/mach/minixST/libsys/ptrace.s b/plat/minix68k/libsys/ptrace.s similarity index 100% rename from mach/minixST/libsys/ptrace.s rename to plat/minix68k/libsys/ptrace.s diff --git a/mach/minixST/libsys/read.s b/plat/minix68k/libsys/read.s similarity index 100% rename from mach/minixST/libsys/read.s rename to plat/minix68k/libsys/read.s diff --git a/mach/minixST/libsys/rename.s b/plat/minix68k/libsys/rename.s similarity index 100% rename from mach/minixST/libsys/rename.s rename to plat/minix68k/libsys/rename.s diff --git a/mach/minixST/libsys/rmdir.s b/plat/minix68k/libsys/rmdir.s similarity index 100% rename from mach/minixST/libsys/rmdir.s rename to plat/minix68k/libsys/rmdir.s diff --git a/mach/minixST/libsys/setgid.s b/plat/minix68k/libsys/setgid.s similarity index 100% rename from mach/minixST/libsys/setgid.s rename to plat/minix68k/libsys/setgid.s diff --git a/mach/minixST/libsys/setuid.s b/plat/minix68k/libsys/setuid.s similarity index 100% rename from mach/minixST/libsys/setuid.s rename to plat/minix68k/libsys/setuid.s diff --git a/mach/minixST/libsys/signal.s b/plat/minix68k/libsys/signal.s similarity index 100% rename from mach/minixST/libsys/signal.s rename to plat/minix68k/libsys/signal.s diff --git a/mach/minixST/libsys/stat.s b/plat/minix68k/libsys/stat.s similarity index 100% rename from mach/minixST/libsys/stat.s rename to plat/minix68k/libsys/stat.s diff --git a/mach/minixST/libsys/stbrksz.s b/plat/minix68k/libsys/stbrksz.s similarity index 100% rename from mach/minixST/libsys/stbrksz.s rename to plat/minix68k/libsys/stbrksz.s diff --git a/mach/minixST/libsys/stcatch.s b/plat/minix68k/libsys/stcatch.s similarity index 100% rename from mach/minixST/libsys/stcatch.s rename to plat/minix68k/libsys/stcatch.s diff --git a/mach/minixST/libsys/stime.s b/plat/minix68k/libsys/stime.s similarity index 100% rename from mach/minixST/libsys/stime.s rename to plat/minix68k/libsys/stime.s diff --git a/mach/minixST/libsys/stsndrec.s b/plat/minix68k/libsys/stsndrec.s similarity index 100% rename from mach/minixST/libsys/stsndrec.s rename to plat/minix68k/libsys/stsndrec.s diff --git a/mach/minixST/libsys/stty.s b/plat/minix68k/libsys/stty.s similarity index 100% rename from mach/minixST/libsys/stty.s rename to plat/minix68k/libsys/stty.s diff --git a/mach/minixST/libsys/sync.s b/plat/minix68k/libsys/sync.s similarity index 100% rename from mach/minixST/libsys/sync.s rename to plat/minix68k/libsys/sync.s diff --git a/plat/minix68k/libsys/syslib.c b/plat/minix68k/libsys/syslib.c new file mode 100644 index 0000000000..603847f22b --- /dev/null +++ b/plat/minix68k/libsys/syslib.c @@ -0,0 +1,200 @@ +#include "lib.h" +#include + +/*---------------------------------------------------------------------------- + Messages to systask (special calls) +----------------------------------------------------------------------------*/ +#if (CHIP == M68000) +PUBLIC _PROTOTYPE(void sys_xit, (int parent, int proc, phys_clicks* basep, phys_clicks* sizep)); +#else +PUBLIC _PROTOTYPE(void sys_xit, (int parent, int proc)); +#endif +PUBLIC _PROTOTYPE(void sys_getsp, (int proc, vir_bytes* newsp)); +PUBLIC _PROTOTYPE(void sys_sig, (int proc, int sig, void (*sighandler)(int))); +#if (CHIP == M68000) +#ifdef ALCYON_C_BUG_FIXED +PUBLIC _PROTOTYPE(void sys_fork, (int prnt, int chld, int pd, phys_clicks shdw)); +#else +PUBLIC _PROTOTYPE(void sys_fork, (int parent, int child, int pid, int shadow)); +#endif +#else +PUBLIC _PROTOTYPE(void sys_fork, (int parent, int child, int pid)); +#endif +PUBLIC _PROTOTYPE(void sys_exec, (int proc, char* ptr, int traced)); +PUBLIC _PROTOTYPE(void sys_newmap, (int proc, char* ptr)); +PUBLIC _PROTOTYPE(void sys_copy, (message * mptr)); +PUBLIC _PROTOTYPE(void sys_times, (int proc, time_t ptr[4])); +PUBLIC _PROTOTYPE(void sys_abort, (void)); +#if (CHIP == M68000) +PUBLIC _PROTOTYPE( + void sys_fresh, (int proc, char* ptr, phys_clicks dc, phys_clicks* basep, phys_clicks* sizep)); +#endif +PUBLIC _PROTOTYPE(void sys_kill, (int proc, int sig)); +PUBLIC _PROTOTYPE(int sys_trace, (int req, int procnr, long addr, long* data_p)); +PUBLIC _PROTOTYPE(void tell_fs, (int what, int p1, int p2, int p3)); + +#if (CHIP == M68000) +PUBLIC void sys_xit(parent, proc, basep, sizep) phys_clicks *basep, *sizep; +#else +PUBLIC void sys_xit(parent, proc) +#endif +int parent; /* parent of exiting proc. */ +int proc; /* which proc has exited */ +{ + /* A proc has exited. Tell the kernel. */ + + _callm1(SYSTASK, SYS_XIT, parent, proc, 0, NIL_PTR, NIL_PTR, NIL_PTR); +#if (CHIP == M68000) + *basep = (phys_clicks)_M.m1_i1; + *sizep = (phys_clicks)_M.m1_i2; +#endif +} + +PUBLIC void sys_getsp(proc, newsp) int proc; /* which proc has enabled signals */ +vir_bytes* newsp; /* place to put sp read from kernel */ +{ + /* Ask the kernel what the sp is. */ + + _callm1(SYSTASK, SYS_GETSP, proc, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); + *newsp = (vir_bytes)_M.STACK_PTR; +} + +PUBLIC void sys_sig(proc, sig, sighandler) int proc; /* which proc has exited */ +int sig; /* signal number: 1 - 16 */ +_PROTOTYPE(void(*sighandler), (int)); /* pointer to signal handler in user space */ +{ + /* A proc has to be signaled. Tell the kernel. */ + + _M.m6_i1 = proc; + _M.m6_i2 = sig; + _M.m6_f1 = sighandler; + _callx(SYSTASK, SYS_SIG); +} + +#if (CHIP == M68000) +PUBLIC void sys_fork(parent, child, pid, shadow) +#ifdef ALCYON_C_BUG_FIXED + phys_clicks shadow; /* memory allocated for shadow */ +#else + int shadow; +#endif +#else +PUBLIC void sys_fork(parent, child, pid) +#endif +int parent; /* proc doing the fork */ +int child; /* which proc has been created by the fork */ +int pid; /* process id assigned by MM */ +{ + /* A proc has forked. Tell the kernel. */ + +#if (CHIP == M68000) + _callm1(SYSTASK, SYS_FORK, parent, child, pid, (char*)shadow, NIL_PTR, NIL_PTR); +#else + _callm1(SYSTASK, SYS_FORK, parent, child, pid, NIL_PTR, NIL_PTR, NIL_PTR); +#endif +} + +PUBLIC void sys_exec(proc, ptr, traced) int proc; /* proc that did exec */ +char* ptr; /* new stack pointer */ +int traced; /* is tracing enabled? */ +{ + /* A proc has exec'd. Tell the kernel. */ + + _callm1(SYSTASK, SYS_EXEC, proc, traced, 0, ptr, NIL_PTR, NIL_PTR); +} + +PUBLIC void sys_newmap(proc, ptr) int proc; /* proc whose map is to be changed */ +char* ptr; /* pointer to new map */ +{ + /* A proc has been assigned a new memory map. Tell the kernel. */ + + _callm1(SYSTASK, SYS_NEWMAP, proc, 0, 0, ptr, NIL_PTR, NIL_PTR); +} + +PUBLIC void sys_copy(mptr) message* mptr; /* pointer to message */ +{ + /* A proc wants to use local copy. */ + + /* Make this routine better. Also check other guys' error handling + * -DEBUG */ + mptr->m_type = SYS_COPY; + if (_sendrec(SYSTASK, mptr) != 0) + panic("sys_copy can't send", NO_NUM); +} + +PUBLIC void sys_times(proc, ptr) int proc; /* proc whose times are needed */ +time_t ptr[4]; /* pointer to time buffer */ +{ + /* Fetch the accounting info for a proc. */ + + _callm1(SYSTASK, SYS_TIMES, proc, 0, 0, (char*)ptr, NIL_PTR, NIL_PTR); + ptr[0] = _M.USER_TIME; + ptr[1] = _M.SYSTEM_TIME; + ptr[2] = _M.CHILD_UTIME; + ptr[3] = _M.CHILD_STIME; +} + +PUBLIC void sys_abort() +{ + /* Something awful has happened. Abandon ship. */ + + _callm1(SYSTASK, SYS_ABORT, 0, 0, 0, NIL_PTR, NIL_PTR, NIL_PTR); +} + +#if (CHIP == M68000) +PUBLIC void sys_fresh(proc, ptr, dc, basep, sizep) int proc; /* proc whose map is to be changed */ +char* ptr; /* pointer to new map */ +phys_clicks dc; /* size of initialized data */ +phys_clicks *basep, *sizep; /* base and size for free_mem() */ +{ + /* Create a fresh process image for exec(). Tell the kernel. */ + + _callm1(SYSTASK, SYS_FRESH, proc, (int)dc, 0, ptr, NIL_PTR, NIL_PTR); + *basep = (phys_clicks)_M.m1_i1; + *sizep = (phys_clicks)_M.m1_i2; +} + +#endif + +PUBLIC void sys_kill(proc, sig) int proc; /* which proc has exited */ +int sig; /* signal number: 1 - 16 */ +{ + /* A proc has to be signaled via MM. Tell the kernel. */ + + _M.m6_i1 = proc; + _M.m6_i2 = sig; + _callx(SYSTASK, SYS_KILL); +} + +PUBLIC int sys_trace(req, procnr, addr, data_p) +int req, procnr; +long addr, *data_p; +{ + int r; + + _M.m2_i1 = procnr; + _M.m2_i2 = req; + _M.m2_l1 = addr; + if (data_p) + _M.m2_l2 = *data_p; + r = _callx(SYSTASK, SYS_TRACE); + if (data_p) + *data_p = _M.m2_l2; + return (r); +} + +PUBLIC void tell_fs(what, p1, p2, p3) int what, p1, p2, p3; +{ + /* This routine is only used by MM to inform FS of certain events: + * tell_fs(CHDIR, slot, dir, 0) + * tell_fs(EXEC, proc, 0, 0) + * tell_fs(EXIT, proc, 0, 0) + * tell_fs(FORK, parent, child, pid) + * tell_fs(SETGID, proc, realgid, effgid) + * tell_fs(SETUID, proc, realuid, effuid) + * tell_fs(SYNC, 0, 0, 0) + * tell_fs(UNPAUSE, proc, signr, 0) + * tell_fs(SETPGRP, proc, 0, 0) + */ + _callm1(FS, what, p1, p2, p3, NIL_PTR, NIL_PTR, NIL_PTR); +} diff --git a/mach/minixST/libsys/time.s b/plat/minix68k/libsys/time.s similarity index 100% rename from mach/minixST/libsys/time.s rename to plat/minix68k/libsys/time.s diff --git a/mach/minixST/libsys/times.s b/plat/minix68k/libsys/times.s similarity index 100% rename from mach/minixST/libsys/times.s rename to plat/minix68k/libsys/times.s diff --git a/mach/minixST/libsys/umask.s b/plat/minix68k/libsys/umask.s similarity index 100% rename from mach/minixST/libsys/umask.s rename to plat/minix68k/libsys/umask.s diff --git a/mach/minixST/libsys/umount.s b/plat/minix68k/libsys/umount.s similarity index 100% rename from mach/minixST/libsys/umount.s rename to plat/minix68k/libsys/umount.s diff --git a/mach/minixST/libsys/unlink.s b/plat/minix68k/libsys/unlink.s similarity index 100% rename from mach/minixST/libsys/unlink.s rename to plat/minix68k/libsys/unlink.s diff --git a/mach/minixST/libsys/utime.s b/plat/minix68k/libsys/utime.s similarity index 100% rename from mach/minixST/libsys/utime.s rename to plat/minix68k/libsys/utime.s diff --git a/mach/minixST/libsys/vectab.c b/plat/minix68k/libsys/vectab.c similarity index 82% rename from mach/minixST/libsys/vectab.c rename to plat/minix68k/libsys/vectab.c index 54eed904ac..b41b410a6f 100644 --- a/mach/minixST/libsys/vectab.c +++ b/plat/minix68k/libsys/vectab.c @@ -3,8 +3,8 @@ * the function is called within the user address space using _vectab[]. */ -#include +#include "lib.h" #include /* array of functions to catch signals */ -_PROTOTYPE( void (*_vectab[_NSIG]), (int)); +_PROTOTYPE(void(*_vectab[_NSIG]), (int)); diff --git a/mach/minixST/libsys/wait.s b/plat/minix68k/libsys/wait.s similarity index 100% rename from mach/minixST/libsys/wait.s rename to plat/minix68k/libsys/wait.s diff --git a/mach/minixST/libsys/write.s b/plat/minix68k/libsys/write.s similarity index 100% rename from mach/minixST/libsys/write.s rename to plat/minix68k/libsys/write.s diff --git a/mach/minixST/mach_params b/plat/minix68k/mach_params similarity index 100% rename from mach/minixST/mach_params rename to plat/minix68k/mach_params diff --git a/plat/msdos/libsys/write.c b/plat/msdos/libsys/write.c index cfc764246e..52851d7d87 100644 --- a/plat/msdos/libsys/write.c +++ b/plat/msdos/libsys/write.c @@ -9,7 +9,7 @@ #include #include "libsys.h" -ssize_t write(int fd, void* buffer, size_t count) +ssize_t write(int fd, const void* buffer, size_t count) { static const char crlf[2] = "\r\n"; int i; diff --git a/plat/pc86/libsys/write.c b/plat/pc86/libsys/write.c index 064e5f487f..0b27cf8806 100644 --- a/plat/pc86/libsys/write.c +++ b/plat/pc86/libsys/write.c @@ -19,7 +19,7 @@ void _sys_write_tty(char c) _sys_rawwrite('\r'); } -ssize_t write(int fd, void* buffer, size_t count) +ssize_t write(int fd, const void* buffer, size_t count) { int i; char* p = buffer; diff --git a/plat/qemuppc/libsys/write.c b/plat/qemuppc/libsys/write.c index 8d2dd0d746..aab2967e7d 100644 --- a/plat/qemuppc/libsys/write.c +++ b/plat/qemuppc/libsys/write.c @@ -19,7 +19,7 @@ void _sys_write_tty(char c) _sys_rawwrite('\r'); } -int write(int fd, void* buffer, size_t count) +int write(int fd, const void* buffer, size_t count) { int i; char* p = buffer; diff --git a/plat/rpi/libsys/write.c b/plat/rpi/libsys/write.c index 29cae0c384..ce4d92351b 100644 --- a/plat/rpi/libsys/write.c +++ b/plat/rpi/libsys/write.c @@ -20,7 +20,7 @@ void _sys_write_tty(char c) _sys_rawwrite('\r'); } -ssize_t write(int fd, void* buffer, size_t count) +ssize_t write(int fd, const void* buffer, size_t count) { int i; char* p = buffer; diff --git a/util/ncgg/build.lua b/util/ncgg/build.lua index ffceb03fe9..08246624e8 100644 --- a/util/ncgg/build.lua +++ b/util/ncgg/build.lua @@ -57,7 +57,8 @@ cprogram { definerule("ncgg", { - srcs = { type="targets" } + srcs = { type="targets" }, + deps = { type="table", default={} } }, function(e) -- Remember this is executed from the caller's directory; local @@ -69,7 +70,8 @@ definerule("ncgg", local cpptable = cppfile { name = e.name.."/cpptable", outleaf = "cpptable", - srcs = e.srcs + srcs = e.srcs, + deps = e.deps } return normalrule {