diff options
Diffstat (limited to 'libc/msdos')
-rw-r--r-- | libc/msdos/Makefile | 9 | ||||
-rw-r--r-- | libc/msdos/TODO | 1 | ||||
-rw-r--r-- | libc/msdos/conio.c | 23 | ||||
-rw-r--r-- | libc/msdos/dirent.c | 8 | ||||
-rw-r--r-- | libc/msdos/dosound.c | 10 | ||||
-rw-r--r-- | libc/msdos/msdos.c | 96 | ||||
-rw-r--r-- | libc/msdos/mslib.c | 333 | ||||
-rw-r--r-- | libc/msdos/new86.c | 69 |
8 files changed, 536 insertions, 13 deletions
diff --git a/libc/msdos/Makefile b/libc/msdos/Makefile index d4bc49a..06d999a 100644 --- a/libc/msdos/Makefile +++ b/libc/msdos/Makefile @@ -3,10 +3,11 @@ # under the GNU Library General Public License. ASRC=msdos.c -AOBJ= dos_start.o __mkargv.o __mkenvp.o dos__fconv.o dos_read.o \ - dos_write.o dos_open.o dos_close.o dos_unlink.o dos_lseek.o \ - dos_segalloc.o dos_segfree.o dos_setvect.o dos_getvect.o \ - dos_isatty.o dos_getmod.o dos_stat.o +AOBJ= \ + dos_start.o __exterror.o __mkargv.o __mkenvp.o bdos.o \ + dos__fconv.o dos_abort.o dos_close.o dos_getmod.o dos_getvect.o \ + dos_isatty.o dos_lseek.o dos_open.o dos_read.o dos_segalloc.o \ + dos_segfree.o dos_setvect.o dos_stat.o dos_unlink.o dos_write.o BSRC=i86.c BOBJ= __seg_regs.o __peek_es.o __poke_es.o __deek_es.o __doke_es.o \ diff --git a/libc/msdos/TODO b/libc/msdos/TODO new file mode 100644 index 0000000..7d3eb12 --- /dev/null +++ b/libc/msdos/TODO @@ -0,0 +1 @@ +#define remove(x) unlink(x) diff --git a/libc/msdos/conio.c b/libc/msdos/conio.c new file mode 100644 index 0000000..3c51c92 --- /dev/null +++ b/libc/msdos/conio.c @@ -0,0 +1,23 @@ +/* Is this BIOS keyboard io ? */ + +cgets() + +cputs() + +getch() + +getche() + +cprintf() + +cscanf() + +getpass() + +gotoxy() + +kbhit() + +putch() + + diff --git a/libc/msdos/dirent.c b/libc/msdos/dirent.c new file mode 100644 index 0000000..00d774e --- /dev/null +++ b/libc/msdos/dirent.c @@ -0,0 +1,8 @@ + +opendir + +closedir + +readdir + +rewinddir diff --git a/libc/msdos/dosound.c b/libc/msdos/dosound.c new file mode 100644 index 0000000..80f49d6 --- /dev/null +++ b/libc/msdos/dosound.c @@ -0,0 +1,10 @@ + + +nosound() +{ +} + +sound(freq) +int freq +{ +} diff --git a/libc/msdos/msdos.c b/libc/msdos/msdos.c index 2d23374..99e8835 100644 --- a/libc/msdos/msdos.c +++ b/libc/msdos/msdos.c @@ -11,6 +11,7 @@ #include <fcntl.h> #include <errno.h> int errno; +unsigned _doserrno; #ifdef L_dos_start @@ -279,6 +280,52 @@ static char buf1[66], buf2[66], *str = 0; } #endif +#ifdef L___exterror + +static char errno_xlate[] = { + 0, EINVAL, ENOENT, ENOENT, EMFILE, EACCES, EBADF, EFAULT, ENOMEM, + EFAULT, ENOMEM, EINVAL, EINVAL, EINVAL, EINVAL, ENODEV, EPERM, EXDEV, + ENFILE, EROFS, ENODEV, ENXIO, EINVAL, EIO, EINVAL, ESPIPE, EIO, EIO, + EAGAIN, EIO, EIO, EIO, EBUSY, EBUSY, ENODEV, EFAULT, ENOLCK, EFAULT, + EFAULT, ENOSPC +}; + +__exterror() +{ +#asm +export exterror +exterror: + push ds + push es + push di + push si + push bp + xor bx,bx + mov ah,#$59 + int $21 + pop bp + pop si + pop di + pop es + pop ds + mov __doserrno,ax +#endasm + { + int nerrno; + extern unsigned _doserrno; + + if( _doserrno == 0 ) + /* No error? No change. */; + else if( _doserrno >= sizeof(errno_xlate) + || errno_xlate[_doserrno] == EFAULT ) + errno = 16384+_doserrno; + else + errno = errno_xlate[_doserrno]; + } + return -1; +} +#endif + #ifdef L_dos_read int read(fd, ptr, len) @@ -294,7 +341,7 @@ unsigned len; mov ah,#$3f int #$21 jnc readok - mov ax,#-1 + br exterror readok: #endasm } @@ -315,7 +362,7 @@ unsigned len; mov ah,#$40 int #$21 jnc writeok - mov ax,#-1 + br exterror writeok: #endasm } @@ -342,7 +389,6 @@ int cmode; else /* Warn, this assumes the standard vals for O_RDWR, O_RDONLY, O_WRONLY */ rv = __dos_open(nname, type&O_ACCMODE); - if( rv < 0 ) errno=ENOENT; return rv; } @@ -355,7 +401,7 @@ __dos_open(fname, mode) mov ah,#$3d ;ask for a open int #$21 jnc openok ;return handle if no error - mov ax,#-1 ;return -1 if error + br exterror openok: #endasm } @@ -370,7 +416,7 @@ char * fname; mov ah,#$3c ;ask for a create int #$21 jnc creok ;return handle if no error - mov ax,#-1 ;return -1 if error + br exterror creok: #endasm } @@ -386,7 +432,7 @@ close(fd) int #$21 mov ax,0 ;return 0 if no error jnc closeok - mov ax,#-1 ;return -1 if error + br exterror closeok: #endasm } @@ -407,7 +453,7 @@ char * fname; int #$21 mov ax,0 ;assume no errors jnc unlok - mov ax,#-1 ;return -1 if error + br exterror unlok: #endasm } @@ -428,7 +474,7 @@ long offset; mov ah,#$42 int #$21 ;do the lseek jnc seekok - mov ax,#-1 ;return -1 if error + call exterror mov dx,ax seekok: #endasm @@ -527,7 +573,7 @@ __dos_getmod(fname) mov ax,#$4300 int #$21 jnc statok - mov cx,#-1 + br exterror statok: mov ax,cx #endasm @@ -588,6 +634,38 @@ not_tty: } #endif +#ifdef L_dos_abort +abort() +{ + write(2, "Abnormal program termination\r\n", 30); + _exit(3); +} +#endif + +#ifdef L_bdos +bdos(dosfn, dosdx, dosal) +int dosfn; +unsigned dosdx, dosal; +{ +#asm +_bdosptr = _bdos + mov bx,sp + push si + push di + + mov dx,_bdos.dosdx[bx] + mov cx,_bdos.dosfn[bx] + mov ax,_bdos.dosal[bx] + mov ah,cl + + int $21 + + pop di + pop si +#endasm +} +#endif + #endif /* __MSDOS__ */ #endif /* __AS386_16__ */ #endif /* !__FIRST_ARG_IN_AX__ */ diff --git a/libc/msdos/mslib.c b/libc/msdos/mslib.c new file mode 100644 index 0000000..c1dfb30 --- /dev/null +++ b/libc/msdos/mslib.c @@ -0,0 +1,333 @@ +/* Copyright (C) 1998 Robert de Bath <rdebath@cix.compulink.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#if !__FIRST_ARG_IN_AX__ +#ifdef __AS386_16__ +#ifdef __MSDOS__ + +#include <dos.h> +#include <fcntl.h> +#include <errno.h> +int errno; + +#ifdef L_dos_chdir +chdir(path) +char * path; +{ +#asm + mov bx,sp + mov bx,_chdir.path[bx] + cmp [bx+1],': + jnz do_chdir + mov dl,[bx] + and dl,#$3F + dec dl + mov ah,#$0E + int $21 +do_chdir: + mov ah,#$3B + mov dx,bx +do_dxop: + int $21 + jnc op_ok + br exterror +op_ok: + xor ax,ax +#endasm +} +#endif + +#ifdef L_mkdir +mkdir(path) +char * path; +{ +#asm + mov bx,sp + mov dx,_mkdir.path[bx] + mov ah,#$39 + j do_dxop +#endasm +} +#endif + +#ifdef L_rmdir +rmdir(path) +char * path; +{ +#asm + mov bx,sp + mov dx,_rmdir.path[bx] + mov ah,#$3A + j do_dxop +#endasm +} +#endif + +#ifdef L_unlink +unlink(path) +char * path; +{ +#asm + mov bx,sp + mov dx,_unlink.path[bx] + mov ah,#$41 + xor cx,cx ! Attrib 0 for servers. + j do_dxop +#endasm +} +#endif + +#ifdef L_dos_access +access(filename, amode) +char * filename; +int amode; +{ + XXX; +} +#endif + +#ifdef L__dos_allocmem +_dos_allocmem(size + +} +#endif + +#ifdef L__chmod +_chmod(path, func, attrib) +char * path; +int func, attrib; +{ + XXX; +} +#endif + +#ifdef L_chmod +chmod(path, mode) +char * path; +int mode; +{ + XXX; +} +#endif + +#ifdef L_clock +clock_t clock() +{ + XXX; +} +#endif + +#ifdef L_ctrlbrk +ctrlbrk(func) +int (*func)(); +{ + XXX; +} +#endif + +#ifdef L_delay +delay(millis) +unsigned millis; +{ + XXX; +} +#endif + +#ifdef L_dosexterr +dosexterr(ptr) +struct DOSERROR * ptr; +{ + XXX; +} +#endif + +/* +#ifdef __dos_getdiskfree +*/ + +#ifdef L_dup +dup(fd) +int fd; +{ + XXX; +} +#endif + +#ifdef L_dup2 +dup2(ofd, nfd) +int ofd, nfd; +{ + XXX; +} +#endif + +#ifdef L_filelength +long +filelength(fd) +int fd; +{ + XXX; +} +#endif + +#ifdef L_findfirst +findfirst(path, fcb, attrib) +char * path; +void * fcb; +int attrib; +{ + XXX; +} +#endif + +#ifdef L_findnext +findnext(fcb) +void * fcb; +{ + XXX; +} +#endif + +#ifdef L_stat +stat(path, st) +char * path; +struct stat * st; +{ + XXX; +} +#endif + +#ifdef L_fstat +fstat(fd, st) +int fd; +struct stat * st; +{ + XXX; +} +#endif + +#ifdef L_getcbrk +getcbrk() +{ + XXX int 0x21/33; +} +#endif + +#ifdef L_setcbrk +setcbrk(mode) +int mode; +{ + XXX int 0x21/33; +} +#endif + +#ifdef L_getcwd +getcwd(buf, buflen) +char * buf; +int buflen; +{ + XXX; +} +#endif + +#ifdef L__getdrive +_getdrive() +{ + XXX; +} +#endif + +#ifdef L_getenv +char * +getenv(varname) +char * varname; +{ + XXX; +} +#endif + +#ifdef L_putenv +putenv(varname) +char * varname; +{ + XXX; +} +#endif + +#ifdef L_getpid +getpid() +{ + XXX; +} +#endif + +#ifdef L_int86 + XXX; +#endif + +#ifdef L_int86x + XXX; +#endif + +#ifdef L_rename +rename(oldname, newpath) +char *oldpath, *newpath; +{ + XXX; +} +#endif + +#ifdef L_segread +segread(segp) +struct SREGS * segp; +{ + XXX; +} +#endif + +#ifdef L_setmode +setmode(fd, amode) +int fd, amode; +{ + XXX; +} +#endif + +#ifdef L_sleep +sleep(secs) +unsigned secs; +{ + XXX; +} +#endif + +#ifdef L_system +system(cmd) +char * cmd; +{ + XXX; +} +#endif + +#ifdef L_umask +umask(mode) +int mode; +{ + XXX; +} +#endif + +#ifdef L_utime +utime(path, times) +char * path; +stuct utimbuf * times; +{ + XXX; +} +#endif + +#endif /* __MSDOS__ */ +#endif /* __AS386_16__ */ +#endif /* !__FIRST_ARG_IN_AX__ */ diff --git a/libc/msdos/new86.c b/libc/msdos/new86.c new file mode 100644 index 0000000..cc139bb --- /dev/null +++ b/libc/msdos/new86.c @@ -0,0 +1,69 @@ + +#define disable() _disable() +#define enable() _enable() + +_enable() +{ +#asm + sti +#endasm +} + +_disable() +{ +#asm + cli +#endasm +} + +geninterrupt(intr) +int intr; +{ +} + +inp(portno) +int portno; +{ +} + +inpw(portno) +int portno; +{ +} + +outp( +{ +} + +outpw( +{ +} + +peek(segment, offset) +unsigned segment, offset; +{ +} + +peekb(segment, offset) +unsigned segment, offset; +{ +} + +poke(segment, offset, value) +unsigned segment, offset, value; +{ +} + +pokeb(segment, offset, value) +unsigned segment, offset, value; +{ +} + + + + + + + + + |