From d91fa39567f5659e3931cf61517d62fddcd87570 Mon Sep 17 00:00:00 2001 From: Robert de Bath Date: Sat, 12 Jan 2002 20:42:42 +0100 Subject: Import Dev86src-0.16.1.tar.gz --- libc/Config.dflt | 1 + libc/Makefile | 2 +- libc/bios/bios.c | 22 ++-- libc/bios/cprintf.c | 132 ------------------------ libc/conio/Config | 1 + libc/conio/Makefile | 36 +++++++ libc/conio/conio.c | 101 +++++++++++++++++++ libc/conio/cprintf.c | 221 +++++++++++++++++++++++++++++++++++++++++ libc/include/conio.h | 26 +++++ libc/msdos/conio.c | 83 ---------------- libc/syscall/syscall.dev86 | 26 +++-- libc/syscall/syscall.dev86.old | 160 +++++++++++++++++++++++++++++ 12 files changed, 580 insertions(+), 231 deletions(-) delete mode 100644 libc/bios/cprintf.c create mode 100644 libc/conio/Config create mode 100644 libc/conio/Makefile create mode 100644 libc/conio/conio.c create mode 100644 libc/conio/cprintf.c create mode 100644 libc/include/conio.h delete mode 100644 libc/msdos/conio.c create mode 100644 libc/syscall/syscall.dev86.old (limited to 'libc') diff --git a/libc/Config.dflt b/libc/Config.dflt index 1927f1e..5056bf7 100644 --- a/libc/Config.dflt +++ b/libc/Config.dflt @@ -1,5 +1,6 @@ bcc:+: bios:+: +conio:+: error:+: getent:+: gtermcap:+: diff --git a/libc/Makefile b/libc/Makefile index 21c3a30..6d6c5bb 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -11,7 +11,7 @@ endif VERMAJOR=0 VERMINOR=16 -VERPATCH=0 +VERPATCH=1 VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) CC=bcc diff --git a/libc/bios/bios.c b/libc/bios/bios.c index 402f689..e0e5c23 100644 --- a/libc/bios/bios.c +++ b/libc/bios/bios.c @@ -33,12 +33,22 @@ loop_save: .text export ___cstartup ! Crt0 startup ___cstartup: - mov ___argr+0,ax - mov ___argr+2,bx - mov ___argr+4,cx - mov ___argr+6,dx - mov ___argr+8,si - mov ___argr+10,di + cli + mov sp,cs + add sp,#__segoff + mov ds,sp + mov ss,sp + mov sp,#___argr+12 + push di + push si + push dx + push cx + push bx + push ax + xor bp,bp + mov sp,bp + push bp + sti zap_bss: ! Clear the BSS mov ax,ds diff --git a/libc/bios/cprintf.c b/libc/bios/cprintf.c deleted file mode 100644 index cd5f62b..0000000 --- a/libc/bios/cprintf.c +++ /dev/null @@ -1,132 +0,0 @@ - -#include -#define wchar(ch) putch(ch) - -cprintf(char * fmt, va_list ap) -{ - register int c; - int count = 0; - int type, base; - long val; - char * cp; - char padch=' '; - int minsize = 0; - - while(c=*fmt++) - { - if(c!='%') - { - wchar(c); - count++; - } - else - { - type=1; - do { c=*fmt++; } while( c>='0' && c<='9'); - - padch = *fmt; - minsize=0; - if(padch == '-') fmt++; - - for(;;) - { - c=*fmt++; - if( c<'0' || c>'9' ) break; - minsize*=10; minsize+=c-'0'; - } - - while( c=='.' || (c>='0' && c<='9')) { c=*fmt++; } - - if( padch == '-' ) minsize = -minsize; - else - if( padch == '0' ) padch='0'; else padch=' '; - - if( c == 0 ) break; - if(c=='h') - { - c=*fmt++; - type = 0; - } - else if(c=='l') - { - c=*fmt++; - type = 2; - } - - switch(c) - { - case 'x': base=16; type|=4; if(0) { - case 'o': base= 8; type|=4; } if(0) { - case 'u': base=10; type|=4; } if(0) { - case 'd': base=10; } - val=0; - switch(type) - { - case 0: val=va_arg(ap, short); break; - case 1: val=va_arg(ap, int); break; - case 2: val=va_arg(ap, long); break; - case 4: val=va_arg(ap, unsigned short); break; - case 5: val=va_arg(ap, unsigned int); break; - case 6: val=va_arg(ap, unsigned long); break; - } - cp = __numout(val,base); - if(0) { - case 's': - cp=va_arg(ap, char *); - } - if( minsize > 0 ) - { - minsize -= strlen(cp); - while(minsize>0) { wchar(padch); minsize--; } - minsize=0; - } - if( minsize < 0 ) minsize= -minsize-strlen(cp); - while(*cp) - wchar(*cp++); - while(minsize>0) { wchar(' '); minsize--; } - break; - case 'c': - wchar(va_arg(ap, int)); - break; - default: - wchar(c); - break; - } - } - } - return count; -} - - - -static char nstring[]="0123456789ABCDEF"; - -static unsigned char * -__numout(long i, int base) -{ - static unsigned char out[16]; - int n; - int flg = 0; - unsigned long val; - - if (i<0 && base==10) - { - flg = 1; - i = -i; - } - val = i; - - for (n = 0; n < 15; n++) - out[n] = ' '; - out[15] = '\0'; - n = 14; - do - { - out[n] = nstring[val % base]; - n--; - val /= base; - } - while(val); - if(flg) out[n--] = '-'; - return &out[n+1]; -} diff --git a/libc/conio/Config b/libc/conio/Config new file mode 100644 index 0000000..76765c8 --- /dev/null +++ b/libc/conio/Config @@ -0,0 +1 @@ +conio: Console io functions for BIOS and DOS. diff --git a/libc/conio/Makefile b/libc/conio/Makefile new file mode 100644 index 0000000..bd86b2c --- /dev/null +++ b/libc/conio/Makefile @@ -0,0 +1,36 @@ +# Copyright (C) 1996 Robert de Bath +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. + +ASRC=conio.c +AOBJ=getch.o getche.o kbhit.o putch.o cputs.o + +OBJ=$(AOBJ) cprintf.o + +CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) + +ifeq ($(LIB_CPU)-$(LIB_OS),i86-BIOS) +all: $(LIBC)($(OBJ)) + @$(RM) $(OBJ) +else +ifeq ($(LIB_CPU)-$(LIB_OS),i86-DOS) +all: $(LIBC)($(OBJ)) + @$(RM) $(OBJ) +else +all: + @: +endif +endif + +$(LIBC)($(AOBJ)): $(ASRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)(cprintf.o): cprintf.c + $(CC) -c -ansi $(ARCH) $(CCFLAGS) $(DEFS) $*.c + $(AR) $(ARFLAGS) $@ $*.o + + + +clean: + rm -f *.o libc.a diff --git a/libc/conio/conio.c b/libc/conio/conio.c new file mode 100644 index 0000000..c0e9cbb --- /dev/null +++ b/libc/conio/conio.c @@ -0,0 +1,101 @@ +/* Copyright (C) 1999 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#include + +/* + * I'm not sure if these should be BIOS or dos calls, so I'll assume they're + * BIOS calls but I may have to do something about Ctrl-C. + * + * These functions are also compiled for __STANDALONE__ so if ^C or DOS + * versions are made this will have to be addressed. + */ + +#ifdef L_getch +getch() +{ +#asm + xor ax,ax + int $16 +#endasm +} +#endif + +#ifdef L_getche +getche() +{ + int i = getch(); + if( i & 0xFF ) putch(i); + return i; +} +#endif + +#ifdef L_kbhit +kbhit() +{ +#asm + mov ah,#1 + int $16 + jz nokey + cmp ax,#0 + jnz dort + mov ax,#3 +dort: + ret +nokey: + xor ax,ax +#endasm +} +#endif + +#ifdef L_putch +putch() +{ +#asm +#if !__FIRST_ARG_IN_AX__ + mov bx,sp + mov ax,[bx+2] +#endif + cmp al,#$0A + jne not_nl + mov ax,#$0E0D + mov bx,#7 + int $10 + mov al,#$0A +not_nl: + mov ah,#$0E + mov bx,#7 + int $10 +#endasm +} +#endif + +#ifdef L_cputs +cputs(str) +char * str; +{ + while(*str) putch(*str++); +} +#endif + +#if 0 + +cgets() +{ +} + +cscanf() +{ +} + +getpass() +{ +} + +gotoxy() +{ +} + +#endif diff --git a/libc/conio/cprintf.c b/libc/conio/cprintf.c new file mode 100644 index 0000000..4bc3bac --- /dev/null +++ b/libc/conio/cprintf.c @@ -0,0 +1,221 @@ +#include +#include + +static unsigned char * __numout(long i, int base); + +int cprintf(char * fmt, ...) +{ + register int c; + int count = 0; + int type, base; + long val; + char * cp; + char padch=' '; + int minsize, maxsize; + va_list ap; + + va_start(ap, fmt); + + while(c=*fmt++) + { + count++; + if(c!='%') + putch(c); + else + { + type=1; + padch = *fmt; + maxsize=minsize=0; + if(padch == '-') fmt++; + + for(;;) + { + c=*fmt++; + if( c<'0' || c>'9' ) break; + minsize*=10; minsize+=c-'0'; + } + + if( c == '.' ) + for(;;) + { + c=*fmt++; + if( c<'0' || c>'9' ) break; + maxsize*=10; maxsize+=c-'0'; + } + + if( padch == '-' ) minsize = -minsize; + else + if( padch != '0' ) padch=' '; + + if( c == 0 ) break; + if(c=='h') + { + c=*fmt++; + type = 0; + } + else if(c=='l') + { + c=*fmt++; + type = 2; + } + + switch(c) + { + case 'x': base=16; type |= 4; if(0) { + case 'o': base= 8; type |= 4; } if(0) { + case 'u': base=10; type |= 4; } if(0) { + case 'd': base=-10; } + switch(type) + { + case 0: val=va_arg(ap, short); break; + case 1: val=va_arg(ap, int); break; + case 2: val=va_arg(ap, long); break; + case 4: val=va_arg(ap, unsigned short); break; + case 5: val=va_arg(ap, unsigned int); break; + case 6: val=va_arg(ap, unsigned long); break; + default:val=0; break; + } + cp = __numout(val,base); + if(0) { + case 's': + cp=va_arg(ap, char *); + } + count--; + c = strlen(cp); + if( !maxsize ) maxsize = c; + if( minsize > 0 ) + { + minsize -= c; + while(minsize>0) { putch(padch); count++; minsize--; } + minsize=0; + } + if( minsize < 0 ) minsize= -minsize-c; + while(*cp && maxsize-->0 ) + { + putch(*cp++); + count++; + } + while(minsize>0) { putch(' '); count++; minsize--; } + break; + case 'c': + putch(va_arg(ap, int)); + break; + default: + putch(c); + break; + } + } + } + va_end(ap); + return count; +} + +static char nstring[]="0123456789ABCDEF"; + +#ifndef __AS386_16__ +#define NUMLTH 11 + +static unsigned char * +__numout(long i, int base) +{ + static unsigned char out[NUMLTH+1]; + int n; + int flg = 0; + unsigned long val; + + if (base<0) + { + base = -base; + if (i<0) + { + flg = 1; + i = -i; + } + } + val = i; + + out[NUMLTH] = '\0'; + n = NUMLTH-1; + do + { + out[n--] = nstring[val % base]; + val /= base; + } + while(val); + if(flg) out[n--] = '-'; + return &out[n+1]; +} + +#else + +#asm +! numout.s +! +.bss +___out lcomm $C + +.text +___numout: +push bp +mov bp,sp +push di +push si +add sp,*-4 +mov byte ptr -8[bp],*$0 ! flg = 0 +mov si,4[bp] ; i or val.lo +mov di,6[bp] ; i or val.hi +mov cx,8[bp] ; base +test cx,cx ! base < 0 ? +jge .3num +neg cx ! base = -base +or di,di ! i < 0 ? +jns .5num +mov byte ptr -8[bp],*1 ! flg = 1 +neg di ! i = -i +neg si +sbb di,0 +.5num: +.3num: +mov byte ptr [___out+$B],*$0 ! out[11] = nul +mov -6[bp],*$A ! n = 10 + +.9num: +!!! out[n--] = nstring[val % base]; +xor dx,dx +xchg ax,di +div cx +xchg ax,di +xchg ax,si +div cx +xchg ax,si ! val(new) = val / base + +mov bx,dx ! dx = val % base + +mov al,_nstring[bx] +mov bx,-6[bp] +dec word ptr -6[bp] +mov ___out[bx],al + +mov ax,si +or ax,di ! while (val) +jne .9num + +cmp byte ptr -8[bp],*$0 ! flg == 0 ? +je .Dnum + +mov bx,-6[bp] +dec word ptr -6[bp] +mov byte ptr ___out[bx],*$2D ! out[n--] = minus + +.Dnum: +mov ax,-6[bp] +add ax,#___out+1 + +add sp,*4 +pop si +pop di +pop bp +ret +#endasm + +#endif diff --git a/libc/include/conio.h b/libc/include/conio.h new file mode 100644 index 0000000..7219a8f --- /dev/null +++ b/libc/include/conio.h @@ -0,0 +1,26 @@ + +#ifndef __CONIO_H +#define __CONIO_H +#include + +int cprintf __P((char *, ...)); +int cputs __P((char *)); +int getch __P((void)); +int getche __P((void)); +int kbhit __P((void)); +int putch __P((int)); + +#if 0 /* Unimplemented as yet */ +char * cgets __P((char *)); +int ungetch __P((int)); +int cscanf __P((char *, ...)); +#endif + +#if 0 /* Hummm */ +unsigned outpw __P((unsigned int, unsigned int)); +unsigned inpw __P((unsigned int)); +int outp __P((unsigned int, int)); +int inp __P((unsigned int)); +#endif + +#endif diff --git a/libc/msdos/conio.c b/libc/msdos/conio.c deleted file mode 100644 index f6f9105..0000000 --- a/libc/msdos/conio.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (C) 1999 Robert de Bath - * This file is part of the Linux-8086 C library and is distributed - * under the GNU Library General Public License. - */ - -/* - * I'm not sure if these should be BIOS or dos calls, so I'll assume they're - * BIOS calls but I may have to do something about Ctrl-C. - */ - -getch() -{ -#asm - xor ax,ax - int $16 -#endasm -} - -getche() -{ - int i = getch(); - if( i & 0xFF) putch(i); - return i; -} - -kbhit() -{ -#asm - mov ah,#1 - int $16 - jz nokey - cmp ax,#0 - jnz dort - mov ax,#3 -dort: - ret -nokey: - xor ax,ax -#endasm -} - -putch() -{ -#asm -#if !__FIRST_ARG_IN_AX__ - mov bx,sp - mov ax,[bx+2] -#endif - mov ah,#$0E - mov bx,#7 - int $10 -#endasm -} - -cputs(str) -char * str; -{ - while(*str) putch(*str++); -} - -#if 0 - -cgets() -{ -} - -cprintf() -{ -} - -cscanf() -{ -} - -getpass() -{ -} - -gotoxy() -{ -} - -#endif diff --git a/libc/syscall/syscall.dev86 b/libc/syscall/syscall.dev86 index 29e7b5e..2c5384c 100644 --- a/libc/syscall/syscall.dev86 +++ b/libc/syscall/syscall.dev86 @@ -47,25 +47,25 @@ ptrace 26 4 @ adb/sdb/dbx need this. alarm 27 2 fstat +28 2 pause 29 0 -utime 30 2 +utime +30 2 chroot +31 1 -vfork 32 0 +vfork +32 0 access +33 2 nice 34 1 sleep 35 1 sync +36 0 -kill 37 2 +kill +37 2 rename +38 2 mkdir +39 2 rmdir +40 1 dup +41 1 . There is a fcntl lib function too. -pipe 42 1 +pipe +42 1 times 43 2 * 2nd arg is pointer for long ret val. profil 44 4 @ dup2 +45 2 setgid +46 1 getgid 47 1 * this gets both gid and egid -signal 48 2 * have put the despatch table in user space. +signal +48 2 * have put the despatch table in user space. getinfo 49 1 @ possible? gets pid,ppid,uid,euid etc fcntl +50 3 acct 51 1 @ Accounting to named file (off if null) @@ -78,11 +78,19 @@ lstat +57 2 symlink +58 2 readlink +59 3 umask +60 1 -settimeofday 61 2 -gettimeofday 62 2 -select 63 5 * +settimeofday +61 2 +gettimeofday +62 2 +select +63 5 . 5 paramaters is possible readdir +64 3 * - +insmod +65 1 +fchown +66 3 +dlload +67 2 +setsid +68 0 +socket +69 3 +bind +70 3 +listen +71 2 +accept +72 3 +connect +73 3 # # Name No Args Flag&comment # diff --git a/libc/syscall/syscall.dev86.old b/libc/syscall/syscall.dev86.old new file mode 100644 index 0000000..29e7b5e --- /dev/null +++ b/libc/syscall/syscall.dev86.old @@ -0,0 +1,160 @@ +# +# WARNING! +# This file is used to generate the system call lists for Dev86(elks) +# ELKSemu and elks itself. Changes to this may require changes in +# all three of those packages. +# +# . = Ok, with comment +# * = Needs libc code (Prefix __) +# - = Obsolete/not required +# @ = May be required later +# +# An initial plus on the call number specifies that this call is +# implemented in the kernel. +# +# Package versions are matched. +# Dev86/Elksemu version - 0.13.1 +# Elks version - 0.0.66 +# +# Name No Args Flag, comment +# +exit +1 1 * c exit does stdio, _exit in crt0 +fork +2 0 +read +3 3 +write +4 3 +open +5 3 +close +6 1 +wait4 +7 4 +creat 8 0 - Not needed alias for open +link +9 2 +unlink +10 1 +execve +11 3 * execve minix style +chdir +12 1 +time 13 1 - Use settimeofday +mknod +14 3 +chmod +15 2 +chown +16 3 +brk +17 1 * This is only to tell the system +stat +18 2 +lseek +19 3 * nb 2nd arg is an io ptr to long not a long. +getpid +20 1 * this gets both pid & ppid +mount +21 5 +umount +22 1 +setuid +23 1 +getuid +24 1 * this gets both uid and euid +stime 25 2 - this must not exist - even as a libc. +ptrace 26 4 @ adb/sdb/dbx need this. +alarm 27 2 +fstat +28 2 +pause 29 0 +utime 30 2 +chroot +31 1 +vfork 32 0 +access +33 2 +nice 34 1 +sleep 35 1 +sync +36 0 +kill 37 2 +rename +38 2 +mkdir +39 2 +rmdir +40 1 +dup +41 1 . There is a fcntl lib function too. +pipe 42 1 +times 43 2 * 2nd arg is pointer for long ret val. +profil 44 4 @ +dup2 +45 2 +setgid +46 1 +getgid 47 1 * this gets both gid and egid +signal 48 2 * have put the despatch table in user space. +getinfo 49 1 @ possible? gets pid,ppid,uid,euid etc +fcntl +50 3 +acct 51 1 @ Accounting to named file (off if null) +phys 52 3 - Replaced my mmap() +lock 53 1 @ Prevent swapping for this proc if flg!=0 +ioctl +54 3 . make this and fcntl the same ? +reboot +55 3 . the magic number is 0xfee1,0xdead,... +mpx 56 2 - Replaced by fifos and select. +lstat +57 2 +symlink +58 2 +readlink +59 3 +umask +60 1 +settimeofday 61 2 +gettimeofday 62 2 +select 63 5 * +readdir +64 3 * + +# +# Name No Args Flag&comment +# +# ( awk '{$2=NR+500;OFS="\t";print ;}'| expand -24,32,40 | unexpand ) <