diff options
author | Jonathan Larmour <jifl@eCosCentric.com> | 2002-04-29 21:51:25 +0000 |
---|---|---|
committer | Jonathan Larmour <jifl@eCosCentric.com> | 2002-04-29 21:51:25 +0000 |
commit | 6990dc5f3b4f0a7765ef1995f02d8a51264277f6 (patch) | |
tree | 20089e3f07fb21b3cf7f285633b933e73a12d156 /libgloss | |
parent | 822afa537ae4e03136d6262269ee460912ddabb1 (diff) | |
download | newlib-6990dc5f3b4f0a7765ef1995f02d8a51264277f6.zip newlib-6990dc5f3b4f0a7765ef1995f02d8a51264277f6.tar.gz newlib-6990dc5f3b4f0a7765ef1995f02d8a51264277f6.tar.bz2 |
* arm/syscall.h: New file. To define extra syscall values for RedBoot.
* arm/redboot-syscalls.c (_close): Fix setting of errno value.
(_lseek): Ditto.
(_open): Ditto.
(_write): Ditto.
(_read): Ditto.
(_rename): New function.
(_system): Ditto.
(_stat): Ditto.
(_unlink): Call a syscall for this now.
(isatty): Ditto.
(_fstat): Ditto.
(_gettimeofday): Ditto.
Diffstat (limited to 'libgloss')
-rw-r--r-- | libgloss/ChangeLog | 17 | ||||
-rw-r--r-- | libgloss/arm/redboot-syscalls.c | 105 | ||||
-rw-r--r-- | libgloss/arm/syscall.h | 54 |
3 files changed, 160 insertions, 16 deletions
diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index 3970e5a..1e813ae 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,20 @@ +2002-04-22 Jonathan Larmour <jlarmour@redhat.com> + + * arm/syscall.h: New file. To define extra syscall values for RedBoot. + + * arm/redboot-syscalls.c (_close): Fix setting of errno value. + (_lseek): Ditto. + (_open): Ditto. + (_write): Ditto. + (_read): Ditto. + (_rename): New function. + (_system): Ditto. + (_stat): Ditto. + (_unlink): Call a syscall for this now. + (isatty): Ditto. + (_fstat): Ditto. + (_gettimeofday): Ditto. + 2002-04-17 Joel Sherrill <joel@OARcorp.com> * debug.h: Change mem_err to volatile to match definition in diff --git a/libgloss/arm/redboot-syscalls.c b/libgloss/arm/redboot-syscalls.c index 1b990ff..3b5a02b 100644 --- a/libgloss/arm/redboot-syscalls.c +++ b/libgloss/arm/redboot-syscalls.c @@ -38,8 +38,11 @@ _close(int fd) { int err; err = __syscall(SYS_close, fd); - if (err) - errno = err; + if (err<0) + { + errno = -err; + return -1; + } return err; } @@ -53,11 +56,29 @@ _exit(int stat) int +_stat (const char *filename, struct stat *st) +{ + int err; + err = __syscall(SYS_stat, filename, st); + if (err<0) + { + errno = -err; + return -1; + } + return err; +} + +int _fstat (int file, struct stat *st) { - st->st_mode = S_IFCHR; - st->st_blksize = 4096; - return 0; + int err; + err = __syscall(SYS_fstat, file, st); + if (err<0) + { + errno = -err; + return -1; + } + return err; } int @@ -70,14 +91,28 @@ _getpid(void) int _gettimeofday (void * tp, void * tzp) { - return 0; + int err; + err = __syscall(SYS_gettimeofday, tp, tzp); + if (err<0) + { + errno = -err; + return -1; + } + return err; } int isatty(int fd) { - return (1); + int err; + err = __syscall(SYS_isatty, fd); + if (err<0) + { + errno = -err; + return -1; + } + return err; } @@ -95,8 +130,11 @@ _lseek(int fd, off_t offset, int whence) { int err; err = __syscall(SYS_lseek, fd, offset, whence); - if (err) - errno = err; + if (err<0) + { + errno = -err; + return (off_t)-1; + } return err; } @@ -106,8 +144,11 @@ _open(const char *buf, int flags, int mode) { int err ; err = __syscall(SYS_open, buf, flags, mode); - if (err) - errno = err; + if (err<0) + { + errno = -err; + return -1; + } return err; } @@ -118,8 +159,11 @@ _write(int fd, const char *buf, int nbytes) int err; err = __syscall(SYS_write, fd, buf, nbytes); - if (err) - errno = err; + if (err<0) + { + errno = -err; + return -1; + } return err; } @@ -147,8 +191,11 @@ _read(int fd, char *buf, int nbytes) { int err; err = __syscall(SYS_read, fd, buf, nbytes); - if (err) - errno = err; + if (err<0) + { + errno = -err; + return -1; + } return err; } @@ -190,13 +237,39 @@ _times(struct tms * tp) return utime; } +int +_rename (const char *oldpath, const char *newpath) +{ + int err ; + err = __syscall(SYS_rename, oldpath, newpath); + if (err<0) + { + errno = -err; + return -1; + } + return err; +} int _unlink (const char *pathname) { - return -1; + int err ; + err = __syscall(SYS_unlink, pathname); + if (err<0) + { + errno = -err; + return -1; + } + return err; } +int +_system (const char *command) +{ + int err ; + err = __syscall(SYS_system, command); + return err; +} #define SYS_meminfo 1001 diff --git a/libgloss/arm/syscall.h b/libgloss/arm/syscall.h new file mode 100644 index 0000000..759801f --- /dev/null +++ b/libgloss/arm/syscall.h @@ -0,0 +1,54 @@ +/* General use syscall.h file. + The more ports that use this file, the simpler sim/common/nltvals.def + remains. */ + +#ifndef LIBGLOSS_SYSCALL_H +#define LIBGLOSS_SYSCALL_H + +/* Note: This file may be included by assembler source. */ + +/* These should be as small as possible to allow a port to use a trap type + instruction, which the system call # as the trap (the d10v for instance + supports traps 0..31). An alternative would be to define one trap for doing + system calls, and put the system call number in a register that is not used + for the normal calling sequence (so that you don't have to shift down the + arguments to add the system call number). Obviously, if these system call + numbers are ever changed, all of the simulators and potentially user code + will need to be updated. */ + +/* There is no current need for the following: SYS_execv, SYS_creat, SYS_wait, + etc. etc. Don't add them. */ + +/* These are required by the ANSI C part of newlib (excluding system() of + course). */ +#define SYS_exit 1 +#define SYS_open 2 +#define SYS_close 3 +#define SYS_read 4 +#define SYS_write 5 +#define SYS_lseek 6 +#define SYS_unlink 7 +#define SYS_getpid 8 +#define SYS_kill 9 +#define SYS_fstat 10 +/*#define SYS_sbrk 11 - not currently a system call, but reserved. */ + +/* ARGV support. */ +#define SYS_argvlen 12 +#define SYS_argv 13 + +/* These are extras added for one reason or another. */ +#define SYS_chdir 14 +#define SYS_stat 15 +#define SYS_chmod 16 +#define SYS_utime 17 +#define SYS_time 18 +#define SYS_gettimeofday 19 +#define SYS_times 20 +#define SYS_link 21 +/* These are additional syscalls in RedBoot. */ +#define SYS_rename 3001 +#define SYS_isatty 3002 +#define SYS_system 3003 + +#endif |