diff --git a/mach/sun2/cv/cv.c b/mach/sun2/cv/cv.c new file mode 100644 index 000000000..f516428cc --- /dev/null +++ b/mach/sun2/cv/cv.c @@ -0,0 +1,560 @@ +/* + * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. + * + * This product is part of the Amsterdam Compiler Kit. + * + * Permission to use, sell, duplicate or disclose this software must be + * obtained in writing. Requests for such permissions may be sent to + * + * Dr. Andrew S. Tanenbaum + * Wiskundig Seminarium + * Vrije Universiteit + * Postbox 7161 + * 1007 MC Amsterdam + * The Netherlands + * + */ + +/* + * Convert ACK a.out file to SUN3 object format. + */ + +#include +#include +#include + +long lseek(); + +#define OMAGIC 0407 /* old-fashioned */ +#define NMAGIC 0410 /* text write protexted */ +#define ZMAGIC 0413 /* demand paging */ + +#define MACH 2 + +struct bhdr { + short machtype; + short magic; + long tsize; + long dsize; + long bsize; + long ssize; + long entry; + long rtsize; + long rdsize; +}; + +struct machrelo { + long address; + long relodata; +}; +#define setpcrel(X,f) (X |= (f<<7)) +#define setsymbolnum(X,n) (X = (X & 0377) | ((long)n << 8)) +#define setextern(X,f) (X |= (f << 4)) +#define setlength(X,l) (X = (X & ~0x60)|((long) l << 5)) + +struct sym { + long name; + char type; + char other; + short desc; + long value; +}; + +#define N_UNDF 0 +#define N_ABS 02 +#define N_TEXT 04 +#define N_DATA 06 +#define N_BSS 010 +#define N_EXT 01 +#define N_FN 0x1f + +/* + * Header and section table of new format object file. + */ +struct outhead outhead; +struct outsect outsect[S_MAX]; + +char *output_file; +int outputfile_created; +long magic; + +int rom_in_data; + +char *program ; + +char flag ; + +/* Output file definitions and such */ + +struct bhdr bh; + +#define ENTRY 0x02000 +#define TOT_HDRSIZE (sizeof(struct bhdr)) + + + +#define TEXTSG 0 +#define ROMSG 1 +#define DATASG 2 +#define BSSSG 3 +#define LSECT BSSSG+1 +#define NSECT LSECT+1 + +int output; + +int unresolved; +long textsize ; +long datasize ; +long bsssize; + +main(argc, argv) + int argc; + char *argv[]; +{ + register int nsect; + + program= argv[0] ; + if ( argc>1 && argv[1][0]=='-' ) { + flag=argv[1][1] ; + argc-- ; argv++ ; + } + switch (argc) { + case 3: if ((output = creat(argv[2], 0644)) < 0 || + (close(output), output = open(argv[2],2)) < 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 .\n", argv[0]); + } + rd_ohead(&outhead); + if (BADMAGIC(outhead)) + fatal("Not an ack object file.\n"); + if (outhead.oh_flags & HF_LINK) { + unresolved++; + fprintf(stderr,"Warning: contains unresolved references.\n"); + } + else if (outhead.oh_nrelo > 0) + fprintf(stderr, "Warning: relocation information present.\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 ( !unresolved && outsect[BSSSG].os_base != outsect[DATASG].os_base+ + outsect[DATASG].os_size ) + fatal("bss segment must follow data segment\n") ; + if ( outsect[ROMSG].os_lign == 0x20000 ) { + /* 410/413 file with ROMSG in data space */ + rom_in_data = 1; + magic= NMAGIC ; + textsize= outsect[TEXTSG].os_size ; + datasize= outsect[ROMSG].os_size + outsect[DATASG].os_size ; + if ( outsect[DATASG].os_base != outsect[ROMSG].os_base+ + outsect[ROMSG].os_size ) + fatal("data segment must follow rom\n") ; + } else + if ( outsect[DATASG].os_lign == 0x20000 ) { + /* 410/413 file with ROMSG in instruction space */ + rom_in_data = 0; + magic= NMAGIC ; + textsize= outsect[TEXTSG].os_size + outsect[ROMSG].os_size ; + datasize= outsect[DATASG].os_size ; + if ( outsect[ROMSG].os_base != outsect[TEXTSG].os_base+ + outsect[TEXTSG].os_size ) + fatal("rom segment must follow text\n") ; + } else { + /* Plain 407 file */ + rom_in_data = 0; + magic= OMAGIC ; + textsize= outsect[TEXTSG].os_size + outsect[ROMSG].os_size ; + datasize= outsect[DATASG].os_size ; + if (!unresolved) { + if (outsect[ROMSG].os_base != outsect[TEXTSG].os_base+ + outsect[TEXTSG].os_size ) + fatal("rom segment must follow text\n") ; + if ( outsect[DATASG].os_base != outsect[ROMSG].os_base+ + outsect[ROMSG].os_size ) + fatal("data segment must follow rom\n") ; + } + } + if (outsect[TEXTSG].os_base == TOT_HDRSIZE+ENTRY) { + if (magic != NMAGIC) { + fatal("illegal alignments.\n"); + } + magic = ZMAGIC; + textsize = (textsize + TOT_HDRSIZE + (0x2000 - 1)) & ~(0x2000 - 1); + datasize = (datasize + (0x2000 - 1)) & ~(0x2000 - 1); + } + bsssize = outsect[BSSSG].os_size; + if ( outhead.oh_nsect==NSECT ) { + if ( outsect[LSECT].os_base != outsect[BSSSG].os_base+ + outsect[BSSSG].os_size ) + fatal("end segment must follow bss\n") ; + if ( outsect[LSECT].os_size != 0 ) + fatal("end segment must be empty\n") ; + } + + if (magic != OMAGIC && unresolved) { + fatal("unresolved references with wrong magic number\n"); + } + + if ((magic == ZMAGIC && outsect[TEXTSG].os_base != TOT_HDRSIZE+ENTRY) || + (magic != ZMAGIC && !unresolved && outsect[TEXTSG].os_base != ENTRY)) { + fatal("Illegal entry point.\n"); + } + + bh.magic = magic; + bh.machtype = MACH; + bh.tsize = textsize; + bh.bsize = bsssize; + bh.dsize = datasize; + bh.rtsize = 0; + bh.rdsize = 0; + if (magic == ZMAGIC) bh.entry = TOT_HDRSIZE+ENTRY; + else if (!unresolved) bh.entry = ENTRY; + else bh.entry = 0; + + /* Action at last */ + lseek(output,(long) TOT_HDRSIZE,0); + emits(&outsect[TEXTSG]) ; + if (rom_in_data && magic == ZMAGIC) { + lseek(output,textsize,0); + } + emits(&outsect[ROMSG]) ; + if (!rom_in_data && magic == ZMAGIC) { + lseek(output,textsize,0); + } + emits(&outsect[DATASG]) ; + if (magic == ZMAGIC) { + lseek(output,textsize + datasize,0); + } + if (unresolved) emit_relo(); + emit_symtab(); + bh.ssize = outhead.oh_nname * sizeof(struct sym); + lseek(output,0L,0); + cvshort(&(bh.machtype)); + cvshort(&(bh.magic)); + cvlong(&(bh.tsize)); + cvlong(&(bh.dsize)); + cvlong(&(bh.bsize)); + cvlong(&(bh.ssize)); + cvlong(&(bh.entry)); + cvlong(&(bh.rtsize)); + cvlong(&(bh.rdsize)); + writef(&bh, 1, (long) TOT_HDRSIZE); + if ( outputfile_created && !unresolved ) chmod(argv[2],0755); + return 0; +} + +writef(addr,sz,cnt) + char *addr; + long cnt; +{ + cnt *= sz; + + while (cnt) { + int i = cnt >= 0x4000 ? 0x4000 : cnt; + + cnt -= i; + if (write(output, addr, i) < i) { + fatal("write error\n"); + } + addr += i; + } +} + +/* + * Transfer the emitted byted from one file to another. + */ +emits(section) struct outsect *section ; { + char *p; + char *calloc(); + long sz = section->os_flen; + + rd_outsect(section - outsect); + while (sz) { + unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); + if (!(p = calloc(i, 1))) { + fatal("No memory.\n"); + } + rd_emit(p, i); + if (write(output, p, i) < i) { + fatal("write error.\n"); + } + free(p); + sz -= i; + } + + sz = section->os_size - section->os_flen; + while (sz) { + unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); + if (!(p = calloc(i, 1))) { + fatal("No memory.\n"); + } + if (write(output, p, i) < i) { + fatal("write error.\n"); + } + free(p); + sz -= i; + } +} + +struct outname *ACKnames; + +emit_relo() +{ + struct outrelo *ACKrelo; + struct machrelo *MACHtrelo,*MACHdrelo; + register struct outrelo *ap; + register struct machrelo *mtp, *mdp; + unsigned int cnt = outhead.oh_nrelo; + + ACKrelo = (struct outrelo *) calloc(cnt, sizeof(struct outrelo)); + MACHtrelo = (struct machrelo *) calloc(cnt, sizeof(struct machrelo)); + MACHdrelo = (struct machrelo *) calloc(cnt, sizeof(struct machrelo)); + ACKnames = (struct outname *) calloc(outhead.oh_nname, sizeof(struct outname)); + if (!(ap = ACKrelo) || !(mtp = MACHtrelo) || !(mdp = MACHdrelo) || + !ACKnames) { + fatal("No memory.\n"); + } + rd_relo(ACKrelo, cnt); + rd_name(ACKnames, outhead.oh_nname); + while (cnt-- != 0) { + register struct machrelo *mp; + + if (ap->or_sect - S_MIN <= ROMSG) mp = mtp++; + else mp = mdp++; + setlength(mp->relodata,(ap->or_type&RELSZ) >> 1); + setpcrel(mp->relodata,(ap->or_type&RELPC != 0)); + mp->address = ap->or_addr; + if (ap->or_sect == ROMSG+S_MIN) { + mp->address += outsect[TEXTSG].os_size; + } + if (ap->or_nami < outhead.oh_nname) { + if (ACKnames[ap->or_nami].on_type & S_EXT) { + setsymbolnum(mp->relodata, ap->or_nami); + setextern(mp->relodata,1); + } + else { + patch(ap, &ACKnames[ap->or_nami], mp); + } + } + else { + setsymbolnum(mp->relodata, N_ABS); + } + cvlong(&(mp->address)); + cvlong(&(mp->relodata)); + ap++; + } + bh.rtsize = (char *) mtp - (char *) MACHtrelo; + bh.rdsize = (char *) mdp - (char *) MACHdrelo; + writef(MACHtrelo, 1, bh.rtsize); + writef(MACHdrelo, 1, bh.rdsize); + free(ACKrelo); + free(MACHtrelo); + free(MACHdrelo); +} + +long +get(sz) +{ + char buf[10]; + long l = 0; + register char *p = buf; + + read(output,buf,sz); + while (sz--) { + l = (l << 8) | (*p++ & 0377); + } +} + +put(l,sz) + long l; +{ + char buf[10]; + register char *p; + + *p++ = l >> 24; + *p++ = l >> 16; + *p++ = l >> 8; + *p++ = l; + p -= sz; + if (write(output, p, sz) < sz) { + fatal("write error.\n"); + } +} + +patch(ap, an, mp) + register struct outrelo *ap; + register struct outname *an; + register struct machrelo *mp; +{ + int whichsect = (an->on_type & S_TYP) - S_MIN; + long correction = 0; + long where = TOT_HDRSIZE+ap->or_addr; + long X; + long here; + int sz; + + if (!(an->on_type & S_SCT)) { + fprintf(stderr,"funny on_type %x\n", an->on_type); + } + switch(whichsect) { + case TEXTSG: + setsymbolnum(mp->relodata,N_TEXT); + return; + case DATASG: + correction = outsect[ROMSG].os_size + outsect[TEXTSG].os_size; + setsymbolnum(mp->relodata,N_DATA); + break; + case ROMSG: + correction += outsect[TEXTSG].os_size; + setsymbolnum(mp->relodata,N_TEXT); + break; + default: + assert(0); + } + + switch(ap->or_sect - S_MIN) { + case DATASG: + where += outsect[ROMSG].os_size; + case ROMSG: + where += outsect[TEXTSG].os_size; + case TEXTSG: + break; + default: + assert(0); + } + here = lseek(output, 0L, 1); + lseek(output, where, 0); + sz = ap->or_type & RELSZ; + X = get(sz) + correction; + lseek(output, where, 0); + put(X,sz); + lseek(output, here, 0); +} + +cvlong(l) + long *l; +{ + long x = *l; + char *p = (char *) l; + + *p++ = x >> 24; + *p++ = x >> 16; + *p++ = x >> 8; + *p = x; +} + +cvshort(s) + short *s; +{ + short x = *s; + char *p = (char *) s; + + *p++ = x >> 8; + *p = x; +} + +emit_symtab() +{ + register unsigned short i = outhead.oh_nname; + register struct outname *A; + struct sym *MACHnames; + register struct sym *M; + extern char *malloc(), *calloc(); + char *chars; + long offX = OFF_CHAR(outhead) - 4; + + if (!(A = ACKnames)) { + if (!(A = (struct outname *) + calloc(i, sizeof(struct outname)))) { + fatal("No memory.\n"); + } + rd_name(A, outhead.oh_nname); + } + if (!(M = (struct sym *) calloc(i, sizeof(struct sym)))) { + fatal("No memory.\n"); + } + MACHnames = M; + ACKnames = A; + for (; i; i--, A++, M++) { + M->value = A->on_valu; + switch(A->on_type & S_TYP) { + case S_UND: + M->type = N_UNDF; + break; + case S_ABS: + M->type = N_ABS; + break; + case S_MIN + TEXTSG: + if (! A->on_type & S_COM) { + M->value += outsect[TEXTSG].os_base; + } + M->type = N_TEXT; + break; + case S_MIN + ROMSG: + M->type = (rom_in_data ? N_DATA : N_TEXT); + if (! A->on_type & S_COM) { + M->value += outsect[ROMSG].os_base; + } + break; + case S_MIN + DATASG: + M->type = N_DATA; + if (! A->on_type & S_COM) { + M->value += outsect[DATASG].os_base; + } + break; + case S_MIN + BSSSG: + M->type = N_BSS; + if (! A->on_type & S_COM) { + M->value += outsect[BSSSG].os_base; + } + break; + case S_MIN + LSECT: + M->type = N_BSS; + if (! A->on_type & S_COM) { + M->value += outsect[LSECT].os_base; + } + break; + default: + fprintf(stderr,"warning: unknown s_type: %d\n", + A->on_type & S_TYP); + } + if (A->on_type & S_EXT) M->type |= N_EXT; + if (M->name = A->on_foff) { + M->name -= offX; + } + cvlong(&(M->name)); + cvlong(&(M->value)); + } + writef(MACHnames, sizeof(struct sym), (long) outhead.oh_nname); + free(MACHnames); + free(ACKnames); + if ((unsigned) outhead.oh_nchar != outhead.oh_nchar || + !( chars = malloc((unsigned) outhead.oh_nchar))) { + fatal("No memory\n."); + } + put(outhead.oh_nchar+4,4); + rd_string(chars,outhead.oh_nchar); + writef(chars, 1, outhead.oh_nchar); + free(chars); +} + +/* 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/sun3/Action b/mach/sun3/Action new file mode 100644 index 000000000..ecfe36b91 --- /dev/null +++ b/mach/sun3/Action @@ -0,0 +1,6 @@ +name "Ack.out --> SUN 68020 a.out format conversion program" +dir cv +end +name "SUN 68020 systemcall library" +dir libsys +end diff --git a/mach/sun3/cv/Makefile b/mach/sun3/cv/Makefile new file mode 100644 index 000000000..5cfa97a6a --- /dev/null +++ b/mach/sun3/cv/Makefile @@ -0,0 +1,25 @@ +EMHOME = ../../.. +LIBOBJ = $(EMHOME)/modules/lib/libobject.a +INCLUDE = $(EMHOME)/h +CFLAGS = -I. -I$(INCLUDE) -O +TARGETS = cv + +all: $(TARGETS) + +install: all + ../../install cv + +cmp: all + ../../compare cv + +cv: cv.o + $(CC) $(LDFLAGS) -o cv cv.o $(LIBOBJ) + +clean: + rm -f $(TARGETS) *.o nohup.out Out + +pr: + @pr Makefile cv.c + +opr: + make pr | opr diff --git a/mach/sun3/cv/cv.c b/mach/sun3/cv/cv.c new file mode 100644 index 000000000..f516428cc --- /dev/null +++ b/mach/sun3/cv/cv.c @@ -0,0 +1,560 @@ +/* + * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. + * + * This product is part of the Amsterdam Compiler Kit. + * + * Permission to use, sell, duplicate or disclose this software must be + * obtained in writing. Requests for such permissions may be sent to + * + * Dr. Andrew S. Tanenbaum + * Wiskundig Seminarium + * Vrije Universiteit + * Postbox 7161 + * 1007 MC Amsterdam + * The Netherlands + * + */ + +/* + * Convert ACK a.out file to SUN3 object format. + */ + +#include +#include +#include + +long lseek(); + +#define OMAGIC 0407 /* old-fashioned */ +#define NMAGIC 0410 /* text write protexted */ +#define ZMAGIC 0413 /* demand paging */ + +#define MACH 2 + +struct bhdr { + short machtype; + short magic; + long tsize; + long dsize; + long bsize; + long ssize; + long entry; + long rtsize; + long rdsize; +}; + +struct machrelo { + long address; + long relodata; +}; +#define setpcrel(X,f) (X |= (f<<7)) +#define setsymbolnum(X,n) (X = (X & 0377) | ((long)n << 8)) +#define setextern(X,f) (X |= (f << 4)) +#define setlength(X,l) (X = (X & ~0x60)|((long) l << 5)) + +struct sym { + long name; + char type; + char other; + short desc; + long value; +}; + +#define N_UNDF 0 +#define N_ABS 02 +#define N_TEXT 04 +#define N_DATA 06 +#define N_BSS 010 +#define N_EXT 01 +#define N_FN 0x1f + +/* + * Header and section table of new format object file. + */ +struct outhead outhead; +struct outsect outsect[S_MAX]; + +char *output_file; +int outputfile_created; +long magic; + +int rom_in_data; + +char *program ; + +char flag ; + +/* Output file definitions and such */ + +struct bhdr bh; + +#define ENTRY 0x02000 +#define TOT_HDRSIZE (sizeof(struct bhdr)) + + + +#define TEXTSG 0 +#define ROMSG 1 +#define DATASG 2 +#define BSSSG 3 +#define LSECT BSSSG+1 +#define NSECT LSECT+1 + +int output; + +int unresolved; +long textsize ; +long datasize ; +long bsssize; + +main(argc, argv) + int argc; + char *argv[]; +{ + register int nsect; + + program= argv[0] ; + if ( argc>1 && argv[1][0]=='-' ) { + flag=argv[1][1] ; + argc-- ; argv++ ; + } + switch (argc) { + case 3: if ((output = creat(argv[2], 0644)) < 0 || + (close(output), output = open(argv[2],2)) < 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 .\n", argv[0]); + } + rd_ohead(&outhead); + if (BADMAGIC(outhead)) + fatal("Not an ack object file.\n"); + if (outhead.oh_flags & HF_LINK) { + unresolved++; + fprintf(stderr,"Warning: contains unresolved references.\n"); + } + else if (outhead.oh_nrelo > 0) + fprintf(stderr, "Warning: relocation information present.\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 ( !unresolved && outsect[BSSSG].os_base != outsect[DATASG].os_base+ + outsect[DATASG].os_size ) + fatal("bss segment must follow data segment\n") ; + if ( outsect[ROMSG].os_lign == 0x20000 ) { + /* 410/413 file with ROMSG in data space */ + rom_in_data = 1; + magic= NMAGIC ; + textsize= outsect[TEXTSG].os_size ; + datasize= outsect[ROMSG].os_size + outsect[DATASG].os_size ; + if ( outsect[DATASG].os_base != outsect[ROMSG].os_base+ + outsect[ROMSG].os_size ) + fatal("data segment must follow rom\n") ; + } else + if ( outsect[DATASG].os_lign == 0x20000 ) { + /* 410/413 file with ROMSG in instruction space */ + rom_in_data = 0; + magic= NMAGIC ; + textsize= outsect[TEXTSG].os_size + outsect[ROMSG].os_size ; + datasize= outsect[DATASG].os_size ; + if ( outsect[ROMSG].os_base != outsect[TEXTSG].os_base+ + outsect[TEXTSG].os_size ) + fatal("rom segment must follow text\n") ; + } else { + /* Plain 407 file */ + rom_in_data = 0; + magic= OMAGIC ; + textsize= outsect[TEXTSG].os_size + outsect[ROMSG].os_size ; + datasize= outsect[DATASG].os_size ; + if (!unresolved) { + if (outsect[ROMSG].os_base != outsect[TEXTSG].os_base+ + outsect[TEXTSG].os_size ) + fatal("rom segment must follow text\n") ; + if ( outsect[DATASG].os_base != outsect[ROMSG].os_base+ + outsect[ROMSG].os_size ) + fatal("data segment must follow rom\n") ; + } + } + if (outsect[TEXTSG].os_base == TOT_HDRSIZE+ENTRY) { + if (magic != NMAGIC) { + fatal("illegal alignments.\n"); + } + magic = ZMAGIC; + textsize = (textsize + TOT_HDRSIZE + (0x2000 - 1)) & ~(0x2000 - 1); + datasize = (datasize + (0x2000 - 1)) & ~(0x2000 - 1); + } + bsssize = outsect[BSSSG].os_size; + if ( outhead.oh_nsect==NSECT ) { + if ( outsect[LSECT].os_base != outsect[BSSSG].os_base+ + outsect[BSSSG].os_size ) + fatal("end segment must follow bss\n") ; + if ( outsect[LSECT].os_size != 0 ) + fatal("end segment must be empty\n") ; + } + + if (magic != OMAGIC && unresolved) { + fatal("unresolved references with wrong magic number\n"); + } + + if ((magic == ZMAGIC && outsect[TEXTSG].os_base != TOT_HDRSIZE+ENTRY) || + (magic != ZMAGIC && !unresolved && outsect[TEXTSG].os_base != ENTRY)) { + fatal("Illegal entry point.\n"); + } + + bh.magic = magic; + bh.machtype = MACH; + bh.tsize = textsize; + bh.bsize = bsssize; + bh.dsize = datasize; + bh.rtsize = 0; + bh.rdsize = 0; + if (magic == ZMAGIC) bh.entry = TOT_HDRSIZE+ENTRY; + else if (!unresolved) bh.entry = ENTRY; + else bh.entry = 0; + + /* Action at last */ + lseek(output,(long) TOT_HDRSIZE,0); + emits(&outsect[TEXTSG]) ; + if (rom_in_data && magic == ZMAGIC) { + lseek(output,textsize,0); + } + emits(&outsect[ROMSG]) ; + if (!rom_in_data && magic == ZMAGIC) { + lseek(output,textsize,0); + } + emits(&outsect[DATASG]) ; + if (magic == ZMAGIC) { + lseek(output,textsize + datasize,0); + } + if (unresolved) emit_relo(); + emit_symtab(); + bh.ssize = outhead.oh_nname * sizeof(struct sym); + lseek(output,0L,0); + cvshort(&(bh.machtype)); + cvshort(&(bh.magic)); + cvlong(&(bh.tsize)); + cvlong(&(bh.dsize)); + cvlong(&(bh.bsize)); + cvlong(&(bh.ssize)); + cvlong(&(bh.entry)); + cvlong(&(bh.rtsize)); + cvlong(&(bh.rdsize)); + writef(&bh, 1, (long) TOT_HDRSIZE); + if ( outputfile_created && !unresolved ) chmod(argv[2],0755); + return 0; +} + +writef(addr,sz,cnt) + char *addr; + long cnt; +{ + cnt *= sz; + + while (cnt) { + int i = cnt >= 0x4000 ? 0x4000 : cnt; + + cnt -= i; + if (write(output, addr, i) < i) { + fatal("write error\n"); + } + addr += i; + } +} + +/* + * Transfer the emitted byted from one file to another. + */ +emits(section) struct outsect *section ; { + char *p; + char *calloc(); + long sz = section->os_flen; + + rd_outsect(section - outsect); + while (sz) { + unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); + if (!(p = calloc(i, 1))) { + fatal("No memory.\n"); + } + rd_emit(p, i); + if (write(output, p, i) < i) { + fatal("write error.\n"); + } + free(p); + sz -= i; + } + + sz = section->os_size - section->os_flen; + while (sz) { + unsigned int i = (sz >= 0x4000 ? 0x4000 : sz); + if (!(p = calloc(i, 1))) { + fatal("No memory.\n"); + } + if (write(output, p, i) < i) { + fatal("write error.\n"); + } + free(p); + sz -= i; + } +} + +struct outname *ACKnames; + +emit_relo() +{ + struct outrelo *ACKrelo; + struct machrelo *MACHtrelo,*MACHdrelo; + register struct outrelo *ap; + register struct machrelo *mtp, *mdp; + unsigned int cnt = outhead.oh_nrelo; + + ACKrelo = (struct outrelo *) calloc(cnt, sizeof(struct outrelo)); + MACHtrelo = (struct machrelo *) calloc(cnt, sizeof(struct machrelo)); + MACHdrelo = (struct machrelo *) calloc(cnt, sizeof(struct machrelo)); + ACKnames = (struct outname *) calloc(outhead.oh_nname, sizeof(struct outname)); + if (!(ap = ACKrelo) || !(mtp = MACHtrelo) || !(mdp = MACHdrelo) || + !ACKnames) { + fatal("No memory.\n"); + } + rd_relo(ACKrelo, cnt); + rd_name(ACKnames, outhead.oh_nname); + while (cnt-- != 0) { + register struct machrelo *mp; + + if (ap->or_sect - S_MIN <= ROMSG) mp = mtp++; + else mp = mdp++; + setlength(mp->relodata,(ap->or_type&RELSZ) >> 1); + setpcrel(mp->relodata,(ap->or_type&RELPC != 0)); + mp->address = ap->or_addr; + if (ap->or_sect == ROMSG+S_MIN) { + mp->address += outsect[TEXTSG].os_size; + } + if (ap->or_nami < outhead.oh_nname) { + if (ACKnames[ap->or_nami].on_type & S_EXT) { + setsymbolnum(mp->relodata, ap->or_nami); + setextern(mp->relodata,1); + } + else { + patch(ap, &ACKnames[ap->or_nami], mp); + } + } + else { + setsymbolnum(mp->relodata, N_ABS); + } + cvlong(&(mp->address)); + cvlong(&(mp->relodata)); + ap++; + } + bh.rtsize = (char *) mtp - (char *) MACHtrelo; + bh.rdsize = (char *) mdp - (char *) MACHdrelo; + writef(MACHtrelo, 1, bh.rtsize); + writef(MACHdrelo, 1, bh.rdsize); + free(ACKrelo); + free(MACHtrelo); + free(MACHdrelo); +} + +long +get(sz) +{ + char buf[10]; + long l = 0; + register char *p = buf; + + read(output,buf,sz); + while (sz--) { + l = (l << 8) | (*p++ & 0377); + } +} + +put(l,sz) + long l; +{ + char buf[10]; + register char *p; + + *p++ = l >> 24; + *p++ = l >> 16; + *p++ = l >> 8; + *p++ = l; + p -= sz; + if (write(output, p, sz) < sz) { + fatal("write error.\n"); + } +} + +patch(ap, an, mp) + register struct outrelo *ap; + register struct outname *an; + register struct machrelo *mp; +{ + int whichsect = (an->on_type & S_TYP) - S_MIN; + long correction = 0; + long where = TOT_HDRSIZE+ap->or_addr; + long X; + long here; + int sz; + + if (!(an->on_type & S_SCT)) { + fprintf(stderr,"funny on_type %x\n", an->on_type); + } + switch(whichsect) { + case TEXTSG: + setsymbolnum(mp->relodata,N_TEXT); + return; + case DATASG: + correction = outsect[ROMSG].os_size + outsect[TEXTSG].os_size; + setsymbolnum(mp->relodata,N_DATA); + break; + case ROMSG: + correction += outsect[TEXTSG].os_size; + setsymbolnum(mp->relodata,N_TEXT); + break; + default: + assert(0); + } + + switch(ap->or_sect - S_MIN) { + case DATASG: + where += outsect[ROMSG].os_size; + case ROMSG: + where += outsect[TEXTSG].os_size; + case TEXTSG: + break; + default: + assert(0); + } + here = lseek(output, 0L, 1); + lseek(output, where, 0); + sz = ap->or_type & RELSZ; + X = get(sz) + correction; + lseek(output, where, 0); + put(X,sz); + lseek(output, here, 0); +} + +cvlong(l) + long *l; +{ + long x = *l; + char *p = (char *) l; + + *p++ = x >> 24; + *p++ = x >> 16; + *p++ = x >> 8; + *p = x; +} + +cvshort(s) + short *s; +{ + short x = *s; + char *p = (char *) s; + + *p++ = x >> 8; + *p = x; +} + +emit_symtab() +{ + register unsigned short i = outhead.oh_nname; + register struct outname *A; + struct sym *MACHnames; + register struct sym *M; + extern char *malloc(), *calloc(); + char *chars; + long offX = OFF_CHAR(outhead) - 4; + + if (!(A = ACKnames)) { + if (!(A = (struct outname *) + calloc(i, sizeof(struct outname)))) { + fatal("No memory.\n"); + } + rd_name(A, outhead.oh_nname); + } + if (!(M = (struct sym *) calloc(i, sizeof(struct sym)))) { + fatal("No memory.\n"); + } + MACHnames = M; + ACKnames = A; + for (; i; i--, A++, M++) { + M->value = A->on_valu; + switch(A->on_type & S_TYP) { + case S_UND: + M->type = N_UNDF; + break; + case S_ABS: + M->type = N_ABS; + break; + case S_MIN + TEXTSG: + if (! A->on_type & S_COM) { + M->value += outsect[TEXTSG].os_base; + } + M->type = N_TEXT; + break; + case S_MIN + ROMSG: + M->type = (rom_in_data ? N_DATA : N_TEXT); + if (! A->on_type & S_COM) { + M->value += outsect[ROMSG].os_base; + } + break; + case S_MIN + DATASG: + M->type = N_DATA; + if (! A->on_type & S_COM) { + M->value += outsect[DATASG].os_base; + } + break; + case S_MIN + BSSSG: + M->type = N_BSS; + if (! A->on_type & S_COM) { + M->value += outsect[BSSSG].os_base; + } + break; + case S_MIN + LSECT: + M->type = N_BSS; + if (! A->on_type & S_COM) { + M->value += outsect[LSECT].os_base; + } + break; + default: + fprintf(stderr,"warning: unknown s_type: %d\n", + A->on_type & S_TYP); + } + if (A->on_type & S_EXT) M->type |= N_EXT; + if (M->name = A->on_foff) { + M->name -= offX; + } + cvlong(&(M->name)); + cvlong(&(M->value)); + } + writef(MACHnames, sizeof(struct sym), (long) outhead.oh_nname); + free(MACHnames); + free(ACKnames); + if ((unsigned) outhead.oh_nchar != outhead.oh_nchar || + !( chars = malloc((unsigned) outhead.oh_nchar))) { + fatal("No memory\n."); + } + put(outhead.oh_nchar+4,4); + rd_string(chars,outhead.oh_nchar); + writef(chars, 1, outhead.oh_nchar); + free(chars); +} + +/* 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/sun3/libsys/LIST b/mach/sun3/libsys/LIST new file mode 100644 index 000000000..2b746292f --- /dev/null +++ b/mach/sun3/libsys/LIST @@ -0,0 +1,159 @@ +libmon_s.a +accept.s +access.s +acct.s +adjtime.s +alarm.c +async_dem.s +bind.s +cerror.s +chdir.s +chmod.s +chown.s +chroot.s +cleanup.c +close.s +connect.s +creat.s +dup.s +dup2.s +execl.c +execle.c +execv.c +execve.s +exit.c +exportfs.s +fchmod.s +fchown.s +fcntl.s +flock.s +fork.s +fstat.s +fstatfs.s +fsync.s +ftime.c +ftruncate.s +getdirent.s +getdomnam.s +getdopt.s +getdtabsz.s +getfh.s +getgid.s +getgroups.s +gethostid.s +gethostnam.s +getitimer.s +getpagesiz.s +getpeernam.s +getpgrp.s +getpid.s +getprio.s +getrlimit.s +getrusage.s +getsocknam.s +getsockopt.s +gettimday.s +getuid.s +ioctl.s +kill.s +killpg.s +link.s +listen.s +lseek.s +lstat.s +madvise.s +mincore.s +mkdir.s +mknod.s +mmap.s +mount.s +mprotect.s +mremap.s +msgsys.s +munmap.s +nfssvc.s +nice.c +open.s +pause.c +pipe.s +profil.s +ptrace.s +quotactl.s +read.s +readlink.s +readv.s +reboot.s +recv.s +recvfrom.s +recvmsg.s +rename.s +rmdir.s +sbrk.s +select.s +semsys.s +send.s +sendmsg.s +sendto.s +setdomnam.s +setdopt.s +setgroups.s +sethostnam.s +setitimer.s +setpgrp.s +setprio.s +setregid.s +setreuid.s +setrlimit.s +setsockopt.s +settimday.s +shmsys.s +shutdown.s +sigblock.s +signal.c +sigpause.s +sigsetmask.s +sigstack.s +sigtramp.s +sigvec.c +socket.s +socketpair.s +sstk.s +stat.s +statfs.s +swapon.s +symlink.s +sync.s +syscall.s +time.c +times.c +truncate.s +umask.s +unlink.s +unmount.s +ustat.s +utime.c +utimes.s +vhangup.s +wait.s +write.s +writev.s +_exit.s +stty.c +gtty.c +getegid.s +geteuid.s +getppid.s +lockf.c +msg.s +plock.c +sem.s +setgid.c +setuid.c +shm.s +stime.c +tell.c +ulimit.c +uname.c +vadvise.s +vfork.s +wait3.s diff --git a/mach/sun3/libsys/Makefile b/mach/sun3/libsys/Makefile new file mode 100644 index 000000000..5861ef1dd --- /dev/null +++ b/mach/sun3/libsys/Makefile @@ -0,0 +1,29 @@ +# $Header$ +MACH=m68020 +all: libmon_o.a head_em.o + +install: all + ../../install head_em.o head_em + ../../install libmon_o.a tail_mon + + +cmp: all + -../../compare head_em.o head_em + -../../compare libmon_o.a tail_mon + +libmon_o.a: libmon_s.a + ASAR=aal ; export ASAR ;\ + march . libmon_o.a + +head_em.o: head_em.s + $(MACH) -I../../../h -c head_em.s + +clean: + rm -f *.o libmon_o.a + +opr : + make pr | opr + +pr: + @pr `pwd`/head_em.s + @arch pv libmon_s.a | pr -h `pwd`/libmon_s.a diff --git a/mach/sun3/libsys/_exit.s b/mach/sun3/libsys/_exit.s new file mode 100644 index 000000000..c7347ad6c --- /dev/null +++ b/mach/sun3/libsys/_exit.s @@ -0,0 +1,7 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define __exit +__exit: + pea (SYS_exit) + trap #0 + jmp (cerror) diff --git a/mach/sun3/libsys/accept.s b/mach/sun3/libsys/accept.s new file mode 100644 index 000000000..c7746ab25 --- /dev/null +++ b/mach/sun3/libsys/accept.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _accept +_accept: SYSTEM(SYS_accept) diff --git a/mach/sun3/libsys/access.s b/mach/sun3/libsys/access.s new file mode 100644 index 000000000..203953ed0 --- /dev/null +++ b/mach/sun3/libsys/access.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _access +_access: SYSTEM(SYS_access) diff --git a/mach/sun3/libsys/acct.s b/mach/sun3/libsys/acct.s new file mode 100644 index 000000000..d28b968fc --- /dev/null +++ b/mach/sun3/libsys/acct.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _acct +_acct: SYSTEM(SYS_acct) diff --git a/mach/sun3/libsys/adjtime.s b/mach/sun3/libsys/adjtime.s new file mode 100644 index 000000000..524996deb --- /dev/null +++ b/mach/sun3/libsys/adjtime.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _adjtime +_adjtime: SYSTEM(SYS_adjtime) diff --git a/mach/sun3/libsys/alarm.c b/mach/sun3/libsys/alarm.c new file mode 100644 index 000000000..ddbf2442c --- /dev/null +++ b/mach/sun3/libsys/alarm.c @@ -0,0 +1,13 @@ +unsigned +alarm(n) + unsigned n; +{ + struct { long l1,l2,l3,l4; } t1,t2; + t1.l1 = 0; + t1.l2 = 0; + t1.l4 = 0; + t1.l3 = n; + if (setitimer(0,&t1,&t2) < 0) return -1; + if (t2.l4) t2.l3++; + return t2.l3; +} diff --git a/mach/sun3/libsys/async_dem.s b/mach/sun3/libsys/async_dem.s new file mode 100644 index 000000000..cba18f347 --- /dev/null +++ b/mach/sun3/libsys/async_dem.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _async_daemon +_async_daemon: SYSTEM(SYS_async_daemon) diff --git a/mach/sun3/libsys/bind.s b/mach/sun3/libsys/bind.s new file mode 100644 index 000000000..28441a49f --- /dev/null +++ b/mach/sun3/libsys/bind.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _bind +_bind: SYSTEM(SYS_bind) diff --git a/mach/sun3/libsys/cerror.s b/mach/sun3/libsys/cerror.s new file mode 100644 index 000000000..985bb56f4 --- /dev/null +++ b/mach/sun3/libsys/cerror.s @@ -0,0 +1,9 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define cerror,_errno +cerror: + move.l d0,(_errno) + move.l #-1,d0 + rts + +.sect .bss +_errno: .space 4 diff --git a/mach/sun3/libsys/chdir.s b/mach/sun3/libsys/chdir.s new file mode 100644 index 000000000..2deb808cd --- /dev/null +++ b/mach/sun3/libsys/chdir.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _chdir +_chdir: SYSTEM(SYS_chdir) diff --git a/mach/sun3/libsys/chmod.s b/mach/sun3/libsys/chmod.s new file mode 100644 index 000000000..cf8d36695 --- /dev/null +++ b/mach/sun3/libsys/chmod.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _chmod +_chmod: SYSTEM(SYS_chmod) diff --git a/mach/sun3/libsys/chown.s b/mach/sun3/libsys/chown.s new file mode 100644 index 000000000..ff635d566 --- /dev/null +++ b/mach/sun3/libsys/chown.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _chown +_chown: SYSTEM(SYS_chown) diff --git a/mach/sun3/libsys/chroot.s b/mach/sun3/libsys/chroot.s new file mode 100644 index 000000000..a8a16163a --- /dev/null +++ b/mach/sun3/libsys/chroot.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _chroot +_chroot: SYSTEM(SYS_chroot) diff --git a/mach/sun3/libsys/cleanup.c b/mach/sun3/libsys/cleanup.c new file mode 100644 index 000000000..6cd9c63e6 --- /dev/null +++ b/mach/sun3/libsys/cleanup.c @@ -0,0 +1 @@ +_cleanup() { } diff --git a/mach/sun3/libsys/close.s b/mach/sun3/libsys/close.s new file mode 100644 index 000000000..8e7b0ac54 --- /dev/null +++ b/mach/sun3/libsys/close.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _close +_close: SYSTEM(SYS_close) diff --git a/mach/sun3/libsys/compmodule b/mach/sun3/libsys/compmodule new file mode 100755 index 000000000..58dc66c61 --- /dev/null +++ b/mach/sun3/libsys/compmodule @@ -0,0 +1,4 @@ +if m68020 -c -L $1 1>&2 +then echo `basename $1 $2`.o +else exit 1 +fi diff --git a/mach/sun3/libsys/connect.s b/mach/sun3/libsys/connect.s new file mode 100644 index 000000000..b2ee04302 --- /dev/null +++ b/mach/sun3/libsys/connect.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _connect +_connect: SYSTEM(SYS_connect) diff --git a/mach/sun3/libsys/creat.s b/mach/sun3/libsys/creat.s new file mode 100644 index 000000000..1cd2f2359 --- /dev/null +++ b/mach/sun3/libsys/creat.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _creat +_creat: SYSTEM(SYS_creat) diff --git a/mach/sun3/libsys/dup.s b/mach/sun3/libsys/dup.s new file mode 100644 index 000000000..dcaa27529 --- /dev/null +++ b/mach/sun3/libsys/dup.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _dup +_dup: SYSTEM(SYS_dup) diff --git a/mach/sun3/libsys/dup2.s b/mach/sun3/libsys/dup2.s new file mode 100644 index 000000000..bb32d50cf --- /dev/null +++ b/mach/sun3/libsys/dup2.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _dup2 +_dup2: SYSTEM(SYS_dup2) diff --git a/mach/sun3/libsys/execl.c b/mach/sun3/libsys/execl.c new file mode 100644 index 000000000..9989439b1 --- /dev/null +++ b/mach/sun3/libsys/execl.c @@ -0,0 +1,8 @@ +execl(name,args) + char *name; + int args; +{ + extern char **environ; + + execve(name,&args,environ); +} diff --git a/mach/sun3/libsys/execle.c b/mach/sun3/libsys/execle.c new file mode 100644 index 000000000..aed036387 --- /dev/null +++ b/mach/sun3/libsys/execle.c @@ -0,0 +1,9 @@ +execle(name,args) + char *name; + char *args; +{ + char **p = &args; + while (*p++) ; + + execve(name,&args,*p); +} diff --git a/mach/sun3/libsys/execv.c b/mach/sun3/libsys/execv.c new file mode 100644 index 000000000..200486f63 --- /dev/null +++ b/mach/sun3/libsys/execv.c @@ -0,0 +1,7 @@ +execv(name,args) + char *name; + char **args; +{ + extern char **environ; + execve(name,args,environ); +} diff --git a/mach/sun3/libsys/execve.s b/mach/sun3/libsys/execve.s new file mode 100644 index 000000000..915c86dd7 --- /dev/null +++ b/mach/sun3/libsys/execve.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _execve +_execve: SYSTEM(SYS_execve) diff --git a/mach/sun3/libsys/exit.c b/mach/sun3/libsys/exit.c new file mode 100644 index 000000000..afd54b3f7 --- /dev/null +++ b/mach/sun3/libsys/exit.c @@ -0,0 +1,5 @@ +exit(n) +{ + _cleanup(); + _exit(n); +} diff --git a/mach/sun3/libsys/exportfs.s b/mach/sun3/libsys/exportfs.s new file mode 100644 index 000000000..d406ccb03 --- /dev/null +++ b/mach/sun3/libsys/exportfs.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _exportfs +_exportfs: SYSTEM(SYS_exportfs) diff --git a/mach/sun3/libsys/fchmod.s b/mach/sun3/libsys/fchmod.s new file mode 100644 index 000000000..b2cb8d877 --- /dev/null +++ b/mach/sun3/libsys/fchmod.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _fchmod +_fchmod: SYSTEM(SYS_fchmod) diff --git a/mach/sun3/libsys/fchown.s b/mach/sun3/libsys/fchown.s new file mode 100644 index 000000000..38627b891 --- /dev/null +++ b/mach/sun3/libsys/fchown.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _fchown +_fchown: SYSTEM(SYS_fchown) diff --git a/mach/sun3/libsys/fcntl.s b/mach/sun3/libsys/fcntl.s new file mode 100644 index 000000000..c8baec29f --- /dev/null +++ b/mach/sun3/libsys/fcntl.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _fcntl +_fcntl: SYSTEM(SYS_fcntl) diff --git a/mach/sun3/libsys/flock.s b/mach/sun3/libsys/flock.s new file mode 100644 index 000000000..d98cd8d20 --- /dev/null +++ b/mach/sun3/libsys/flock.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _flock +_flock: SYSTEM(SYS_flock) diff --git a/mach/sun3/libsys/fork.s b/mach/sun3/libsys/fork.s new file mode 100644 index 000000000..5afda0471 --- /dev/null +++ b/mach/sun3/libsys/fork.s @@ -0,0 +1,14 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _fork +_fork: + pea (SYS_fork) + trap #0 + bcs 1f + tst.l d1 + beq 2f + clr.l d0 +2: + rts +1: + jmp (cerror) diff --git a/mach/sun3/libsys/fstat.s b/mach/sun3/libsys/fstat.s new file mode 100644 index 000000000..c3df3de7f --- /dev/null +++ b/mach/sun3/libsys/fstat.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _fstat +_fstat: SYSTEM(SYS_fstat) diff --git a/mach/sun3/libsys/fstatfs.s b/mach/sun3/libsys/fstatfs.s new file mode 100644 index 000000000..f151cb1d0 --- /dev/null +++ b/mach/sun3/libsys/fstatfs.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _fstatfs +_fstatfs: SYSTEM(SYS_fstatfs) diff --git a/mach/sun3/libsys/fsync.s b/mach/sun3/libsys/fsync.s new file mode 100644 index 000000000..444b61484 --- /dev/null +++ b/mach/sun3/libsys/fsync.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _fsync +_fsync: SYSTEM(SYS_fsync) diff --git a/mach/sun3/libsys/ftime.c b/mach/sun3/libsys/ftime.c new file mode 100644 index 000000000..af4047c35 --- /dev/null +++ b/mach/sun3/libsys/ftime.c @@ -0,0 +1,15 @@ +#include + +ftime(p) + struct { time_t time; unsigned short millitm; + short timezone; short dstflag; } *p; +{ + struct { long l1,l2; } t1,t2; + + if (gettimeofday(&t1,&t2) < 0) return -1; + p->time = t1.l1; + p->millitm = t1.l2/1000; + p->dstflag = t2.l2; + p->timezone = t2.l1; + return 0; +} diff --git a/mach/sun3/libsys/ftruncate.s b/mach/sun3/libsys/ftruncate.s new file mode 100644 index 000000000..37ba7a645 --- /dev/null +++ b/mach/sun3/libsys/ftruncate.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _ftruncate +_ftruncate: SYSTEM(SYS_ftruncate) diff --git a/mach/sun3/libsys/getdirent.s b/mach/sun3/libsys/getdirent.s new file mode 100644 index 000000000..2ae287236 --- /dev/null +++ b/mach/sun3/libsys/getdirent.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getdirentries +_getdirentries: SYSTEM(SYS_getdirentries) diff --git a/mach/sun3/libsys/getdomnam.s b/mach/sun3/libsys/getdomnam.s new file mode 100644 index 000000000..172e9f0a0 --- /dev/null +++ b/mach/sun3/libsys/getdomnam.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getdomainname +_getdomainname: SYSTEM(SYS_getdomainname) diff --git a/mach/sun3/libsys/getdopt.s b/mach/sun3/libsys/getdopt.s new file mode 100644 index 000000000..27c97957a --- /dev/null +++ b/mach/sun3/libsys/getdopt.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getdopt +_getdopt: SYSTEM(SYS_getdopt) diff --git a/mach/sun3/libsys/getdtabsz.s b/mach/sun3/libsys/getdtabsz.s new file mode 100644 index 000000000..db274311f --- /dev/null +++ b/mach/sun3/libsys/getdtabsz.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getdtablesize +_getdtablesize: SYSTEM(SYS_getdtablesize) diff --git a/mach/sun3/libsys/getegid.s b/mach/sun3/libsys/getegid.s new file mode 100644 index 000000000..d191387a5 --- /dev/null +++ b/mach/sun3/libsys/getegid.s @@ -0,0 +1,8 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getegid +_getegid: + pea (SYS_getgid) + trap #0 + move.l d1,d0 + rts diff --git a/mach/sun3/libsys/geteuid.s b/mach/sun3/libsys/geteuid.s new file mode 100644 index 000000000..4b181ac4e --- /dev/null +++ b/mach/sun3/libsys/geteuid.s @@ -0,0 +1,8 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _geteuid +_geteuid: + pea (SYS_getuid) + trap #0 + move.l d1,d0 + rts diff --git a/mach/sun3/libsys/getfh.s b/mach/sun3/libsys/getfh.s new file mode 100644 index 000000000..cbe866535 --- /dev/null +++ b/mach/sun3/libsys/getfh.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getfh +_getfh: SYSTEM(SYS_getfh) diff --git a/mach/sun3/libsys/getgid.s b/mach/sun3/libsys/getgid.s new file mode 100644 index 000000000..76569d052 --- /dev/null +++ b/mach/sun3/libsys/getgid.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getgid +_getgid: SYSTEM(SYS_getgid) diff --git a/mach/sun3/libsys/getgroups.s b/mach/sun3/libsys/getgroups.s new file mode 100644 index 000000000..e9da4d8af --- /dev/null +++ b/mach/sun3/libsys/getgroups.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getgroups +_getgroups: SYSTEM(SYS_getgroups) diff --git a/mach/sun3/libsys/gethostid.s b/mach/sun3/libsys/gethostid.s new file mode 100644 index 000000000..07db17a62 --- /dev/null +++ b/mach/sun3/libsys/gethostid.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _gethostid +_gethostid: SYSTEM(SYS_gethostid) diff --git a/mach/sun3/libsys/gethostnam.s b/mach/sun3/libsys/gethostnam.s new file mode 100644 index 000000000..107643f06 --- /dev/null +++ b/mach/sun3/libsys/gethostnam.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _gethostname +_gethostname: SYSTEM(SYS_gethostname) diff --git a/mach/sun3/libsys/getitimer.s b/mach/sun3/libsys/getitimer.s new file mode 100644 index 000000000..8d33cb8b0 --- /dev/null +++ b/mach/sun3/libsys/getitimer.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getitimer +_getitimer: SYSTEM(SYS_getitimer) diff --git a/mach/sun3/libsys/getpagesiz.s b/mach/sun3/libsys/getpagesiz.s new file mode 100644 index 000000000..7c8c71455 --- /dev/null +++ b/mach/sun3/libsys/getpagesiz.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getpagesize +_getpagesize: SYSTEM(SYS_getpagesize) diff --git a/mach/sun3/libsys/getpeernam.s b/mach/sun3/libsys/getpeernam.s new file mode 100644 index 000000000..d1e6e3824 --- /dev/null +++ b/mach/sun3/libsys/getpeernam.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getpeername +_getpeername: SYSTEM(SYS_getpeername) diff --git a/mach/sun3/libsys/getpgrp.s b/mach/sun3/libsys/getpgrp.s new file mode 100644 index 000000000..904c10a99 --- /dev/null +++ b/mach/sun3/libsys/getpgrp.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getpgrp +_getpgrp: SYSTEM(SYS_getpgrp) diff --git a/mach/sun3/libsys/getpid.s b/mach/sun3/libsys/getpid.s new file mode 100644 index 000000000..192e55f13 --- /dev/null +++ b/mach/sun3/libsys/getpid.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getpid +_getpid: SYSTEM(SYS_getpid) diff --git a/mach/sun3/libsys/getppid.s b/mach/sun3/libsys/getppid.s new file mode 100644 index 000000000..e44e431dd --- /dev/null +++ b/mach/sun3/libsys/getppid.s @@ -0,0 +1,8 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getppid +_getppid: + pea (SYS_getpid) + trap #0 + move.l d1,d0 + rts diff --git a/mach/sun3/libsys/getprio.s b/mach/sun3/libsys/getprio.s new file mode 100644 index 000000000..1e35849a5 --- /dev/null +++ b/mach/sun3/libsys/getprio.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getpriority +_getpriority: SYSTEM(SYS_getpriority) diff --git a/mach/sun3/libsys/getrlimit.s b/mach/sun3/libsys/getrlimit.s new file mode 100644 index 000000000..076d02283 --- /dev/null +++ b/mach/sun3/libsys/getrlimit.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getrlimit +_getrlimit: SYSTEM(SYS_getrlimit) diff --git a/mach/sun3/libsys/getrusage.s b/mach/sun3/libsys/getrusage.s new file mode 100644 index 000000000..091010d91 --- /dev/null +++ b/mach/sun3/libsys/getrusage.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getrusage +_getrusage: SYSTEM(SYS_getrusage) diff --git a/mach/sun3/libsys/getsocknam.s b/mach/sun3/libsys/getsocknam.s new file mode 100644 index 000000000..477e0b1fc --- /dev/null +++ b/mach/sun3/libsys/getsocknam.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getsockname +_getsockname: SYSTEM(SYS_getsockname) diff --git a/mach/sun3/libsys/getsockopt.s b/mach/sun3/libsys/getsockopt.s new file mode 100644 index 000000000..20878c200 --- /dev/null +++ b/mach/sun3/libsys/getsockopt.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getsockopt +_getsockopt: SYSTEM(SYS_getsockopt) diff --git a/mach/sun3/libsys/gettimday.s b/mach/sun3/libsys/gettimday.s new file mode 100644 index 000000000..63c8c8a2d --- /dev/null +++ b/mach/sun3/libsys/gettimday.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _gettimeofday +_gettimeofday: SYSTEM(SYS_gettimeofday) diff --git a/mach/sun3/libsys/getuid.s b/mach/sun3/libsys/getuid.s new file mode 100644 index 000000000..86dd28fed --- /dev/null +++ b/mach/sun3/libsys/getuid.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _getuid +_getuid: SYSTEM(SYS_getuid) diff --git a/mach/sun3/libsys/gtty.c b/mach/sun3/libsys/gtty.c new file mode 100644 index 000000000..7f42ea1fb --- /dev/null +++ b/mach/sun3/libsys/gtty.c @@ -0,0 +1,7 @@ +#include +int gtty(fildes,argp) + int fildes ; + struct sgttyb *argp ; +{ + return ioctl(fildes,TIOCGETP,argp) ; +} diff --git a/mach/sun3/libsys/head_em.s b/mach/sun3/libsys/head_em.s new file mode 100644 index 000000000..36dd0b3f9 --- /dev/null +++ b/mach/sun3/libsys/head_em.s @@ -0,0 +1,65 @@ +.define .lino,.filn +.define EXIT +.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 + + + +! runtime startof for 68020 machine + + +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: + move.l (sp),d2 + lea (4,sp),a0 + move.l d2,d1 + add.l #1,d1 + asl.l #2,d1 + move.l a0,a1 + add.l d1,a1 + pea (a1) + pea (a0) + move.l d2,-(sp) + move.l #0,a6 + jsr (_m_a_i_n) + move.l d0,(sp) ! no stack cleanup needed +EXIT: + jsr (_exit) + + .sect .data +begdata: + .data4 0 ! may be at virtual address 0 with no problem +hol0: +.lino: + .data4 0 ! lino +.filn: + .data4 0 ! filn +.reghp: + .data4 endbss +.limhp: + .data4 endbss +.trppc: + .data4 0 +.trpim: + .data4 0 ! USED TO BE 2 BYTES; IS THIS RIGHT? + + + .sect .bss +begbss: !initialization is not needed because ALL entries are in zero space! diff --git a/mach/sun3/libsys/ioctl.s b/mach/sun3/libsys/ioctl.s new file mode 100644 index 000000000..1d90f1612 --- /dev/null +++ b/mach/sun3/libsys/ioctl.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _ioctl +_ioctl: SYSTEM(SYS_ioctl) diff --git a/mach/sun3/libsys/kill.s b/mach/sun3/libsys/kill.s new file mode 100644 index 000000000..ad723cca7 --- /dev/null +++ b/mach/sun3/libsys/kill.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _kill +_kill: SYSTEM(SYS_kill) diff --git a/mach/sun3/libsys/killpg.s b/mach/sun3/libsys/killpg.s new file mode 100644 index 000000000..8318d6182 --- /dev/null +++ b/mach/sun3/libsys/killpg.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _killpg +_killpg: SYSTEM(SYS_killpg) diff --git a/mach/sun3/libsys/link.s b/mach/sun3/libsys/link.s new file mode 100644 index 000000000..1968b8e2e --- /dev/null +++ b/mach/sun3/libsys/link.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _link +_link: SYSTEM(SYS_link) diff --git a/mach/sun3/libsys/listen.s b/mach/sun3/libsys/listen.s new file mode 100644 index 000000000..e0c5e8aa5 --- /dev/null +++ b/mach/sun3/libsys/listen.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _listen +_listen: SYSTEM(SYS_listen) diff --git a/mach/sun3/libsys/lockf.c b/mach/sun3/libsys/lockf.c new file mode 100644 index 000000000..43764d48c --- /dev/null +++ b/mach/sun3/libsys/lockf.c @@ -0,0 +1,43 @@ +#include +lockf(fildes, mode, size) + long size; +{ + struct { + short type, whence; long start, end; short pid; + } x; + int i = 8; + extern int errno; + + x.type = 2; + x.whence = 1; + x.start = 0; + x.end = size; + switch(mode) { + case 0: + x.type = 3; + break; + case 1: + i = 9; + break; + case 2: + break; + case 3: + if (fcntl(fildes,7,&x) == -1) { + return -1; + } + if (x.type == 3) { + return 0; + } + errno = EACCES; + return -1; + default: + errno = EINVAL; + return -1; + } + if (fcntl(fildes,i,&x) == -1) { + if (errno = 79) { + errno = 78; + } + return -1; + } +} diff --git a/mach/sun3/libsys/lseek.s b/mach/sun3/libsys/lseek.s new file mode 100644 index 000000000..ea2f18ef8 --- /dev/null +++ b/mach/sun3/libsys/lseek.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _lseek +_lseek: SYSTEM(SYS_lseek) diff --git a/mach/sun3/libsys/lstat.s b/mach/sun3/libsys/lstat.s new file mode 100644 index 000000000..b6e4ffe9f --- /dev/null +++ b/mach/sun3/libsys/lstat.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _lstat +_lstat: SYSTEM(SYS_lstat) diff --git a/mach/sun3/libsys/madvise.s b/mach/sun3/libsys/madvise.s new file mode 100644 index 000000000..310b5d485 --- /dev/null +++ b/mach/sun3/libsys/madvise.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _madvise +_madvise: SYSTEM(SYS_madvise) diff --git a/mach/sun3/libsys/mincore.s b/mach/sun3/libsys/mincore.s new file mode 100644 index 000000000..d79685307 --- /dev/null +++ b/mach/sun3/libsys/mincore.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _mincore +_mincore: SYSTEM(SYS_mincore) diff --git a/mach/sun3/libsys/mkdir.s b/mach/sun3/libsys/mkdir.s new file mode 100644 index 000000000..63128046c --- /dev/null +++ b/mach/sun3/libsys/mkdir.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _mkdir +_mkdir: SYSTEM(SYS_mkdir) diff --git a/mach/sun3/libsys/mknod.s b/mach/sun3/libsys/mknod.s new file mode 100644 index 000000000..75577fb0c --- /dev/null +++ b/mach/sun3/libsys/mknod.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _mknod +_mknod: SYSTEM(SYS_mknod) diff --git a/mach/sun3/libsys/mmap.s b/mach/sun3/libsys/mmap.s new file mode 100644 index 000000000..323b7ef19 --- /dev/null +++ b/mach/sun3/libsys/mmap.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _mmap +_mmap: SYSTEM(SYS_mmap) diff --git a/mach/sun3/libsys/mount.s b/mach/sun3/libsys/mount.s new file mode 100644 index 000000000..bc55d3a5c --- /dev/null +++ b/mach/sun3/libsys/mount.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _mount +_mount: SYSTEM(SYS_mount) diff --git a/mach/sun3/libsys/mprotect.s b/mach/sun3/libsys/mprotect.s new file mode 100644 index 000000000..eda5fa6e9 --- /dev/null +++ b/mach/sun3/libsys/mprotect.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _mprotect +_mprotect: SYSTEM(SYS_mprotect) diff --git a/mach/sun3/libsys/mremap.s b/mach/sun3/libsys/mremap.s new file mode 100644 index 000000000..7506f662b --- /dev/null +++ b/mach/sun3/libsys/mremap.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _mremap +_mremap: SYSTEM(SYS_mremap) diff --git a/mach/sun3/libsys/msg.s b/mach/sun3/libsys/msg.s new file mode 100644 index 000000000..f6b5871eb --- /dev/null +++ b/mach/sun3/libsys/msg.s @@ -0,0 +1,18 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _msgget,_msgctl,_msgrcv,_msgsnd +_msgget: + pea (0) + bra 1f +_msgctl: + pea (1) + bra 1f +_msgrcv: + pea (2) + bra 1f +_msgsnd: + pea (3) +1: + move.l (4,sp),d0 + move.l (sp),(4,sp) + move.l d0,(sp) + jmp (_msgsys) diff --git a/mach/sun3/libsys/msgsys.s b/mach/sun3/libsys/msgsys.s new file mode 100644 index 000000000..e17715862 --- /dev/null +++ b/mach/sun3/libsys/msgsys.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _msgsys +_msgsys: SYSTEM(SYS_msgsys) diff --git a/mach/sun3/libsys/munmap.s b/mach/sun3/libsys/munmap.s new file mode 100644 index 000000000..8f420d196 --- /dev/null +++ b/mach/sun3/libsys/munmap.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _munmap +_munmap: SYSTEM(SYS_munmap) diff --git a/mach/sun3/libsys/nfssvc.s b/mach/sun3/libsys/nfssvc.s new file mode 100644 index 000000000..0082a793a --- /dev/null +++ b/mach/sun3/libsys/nfssvc.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _nfssvc +_nfssvc: SYSTEM(SYS_nfssvc) diff --git a/mach/sun3/libsys/nice.c b/mach/sun3/libsys/nice.c new file mode 100644 index 000000000..23505669e --- /dev/null +++ b/mach/sun3/libsys/nice.c @@ -0,0 +1,13 @@ +nice(incr) +{ + extern int errno; + int sav = errno; + int prio; + + errno = 0; + prio = getpriority(0,0); + if (prio == -1 && errno) return -1; + if (setpriority(0,0,prio+incr) < 0) return -1; + errno = sav; + return 0; +} diff --git a/mach/sun3/libsys/open.s b/mach/sun3/libsys/open.s new file mode 100644 index 000000000..9419b0bf7 --- /dev/null +++ b/mach/sun3/libsys/open.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _open +_open: SYSTEM(SYS_open) diff --git a/mach/sun3/libsys/pause.c b/mach/sun3/libsys/pause.c new file mode 100644 index 000000000..97c0242e3 --- /dev/null +++ b/mach/sun3/libsys/pause.c @@ -0,0 +1,3 @@ +pause() { + sigpause(sigblock()); +} diff --git a/mach/sun3/libsys/pipe.s b/mach/sun3/libsys/pipe.s new file mode 100644 index 000000000..1af4b8d54 --- /dev/null +++ b/mach/sun3/libsys/pipe.s @@ -0,0 +1,14 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _pipe +_pipe: + pea (SYS_pipe) + trap #0 + bcs 1f + move.l (4,sp),a0 + move.l d0,(a0)+ + move.l d1,(a0) + clr.l d0 + rts +1: + jmp (cerror) diff --git a/mach/sun3/libsys/plock.c b/mach/sun3/libsys/plock.c new file mode 100644 index 000000000..22a58c806 --- /dev/null +++ b/mach/sun3/libsys/plock.c @@ -0,0 +1,8 @@ +#include +plock(op) +{ + extern int errno; + + errno = EPERM; + return -1; +} diff --git a/mach/sun3/libsys/profil.s b/mach/sun3/libsys/profil.s new file mode 100644 index 000000000..be107bf2d --- /dev/null +++ b/mach/sun3/libsys/profil.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _profil +_profil: SYSTEM(SYS_profil) diff --git a/mach/sun3/libsys/ptrace.s b/mach/sun3/libsys/ptrace.s new file mode 100644 index 000000000..1f2a6a98d --- /dev/null +++ b/mach/sun3/libsys/ptrace.s @@ -0,0 +1,7 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _ptrace +.extern _errno +_ptrace: + clr.l (_errno) + SYSTEM(SYS_ptrace) diff --git a/mach/sun3/libsys/quotactl.s b/mach/sun3/libsys/quotactl.s new file mode 100644 index 000000000..88a2469a2 --- /dev/null +++ b/mach/sun3/libsys/quotactl.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _quotactl +_quotactl: SYSTEM(SYS_quotactl) diff --git a/mach/sun3/libsys/read.s b/mach/sun3/libsys/read.s new file mode 100644 index 000000000..de9df797b --- /dev/null +++ b/mach/sun3/libsys/read.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _read +_read: SYSTEM(SYS_read) diff --git a/mach/sun3/libsys/readlink.s b/mach/sun3/libsys/readlink.s new file mode 100644 index 000000000..18fd73308 --- /dev/null +++ b/mach/sun3/libsys/readlink.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _readlink +_readlink: SYSTEM(SYS_readlink) diff --git a/mach/sun3/libsys/readv.s b/mach/sun3/libsys/readv.s new file mode 100644 index 000000000..43c5cc887 --- /dev/null +++ b/mach/sun3/libsys/readv.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _readv +_readv: SYSTEM(SYS_readv) diff --git a/mach/sun3/libsys/reboot.s b/mach/sun3/libsys/reboot.s new file mode 100644 index 000000000..4aff452d9 --- /dev/null +++ b/mach/sun3/libsys/reboot.s @@ -0,0 +1,10 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _reboot +_reboot: + pea (SYS_reboot) + trap #0 + bcs 1f + stop #0 +1: + jmp (cerror) diff --git a/mach/sun3/libsys/recv.s b/mach/sun3/libsys/recv.s new file mode 100644 index 000000000..16fd7a5cc --- /dev/null +++ b/mach/sun3/libsys/recv.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _recv +_recv: SYSTEM(SYS_recv) diff --git a/mach/sun3/libsys/recvfrom.s b/mach/sun3/libsys/recvfrom.s new file mode 100644 index 000000000..1c94feaff --- /dev/null +++ b/mach/sun3/libsys/recvfrom.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _recvfrom +_recvfrom: SYSTEM(SYS_recvfrom) diff --git a/mach/sun3/libsys/recvmsg.s b/mach/sun3/libsys/recvmsg.s new file mode 100644 index 000000000..9bac27365 --- /dev/null +++ b/mach/sun3/libsys/recvmsg.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _recvmsg +_recvmsg: SYSTEM(SYS_recvmsg) diff --git a/mach/sun3/libsys/rename.s b/mach/sun3/libsys/rename.s new file mode 100644 index 000000000..79b51bcfc --- /dev/null +++ b/mach/sun3/libsys/rename.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _rename +_rename: SYSTEM(SYS_rename) diff --git a/mach/sun3/libsys/rmdir.s b/mach/sun3/libsys/rmdir.s new file mode 100644 index 000000000..34395d046 --- /dev/null +++ b/mach/sun3/libsys/rmdir.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _rmdir +_rmdir: SYSTEM(SYS_rmdir) diff --git a/mach/sun3/libsys/sbrk.s b/mach/sun3/libsys/sbrk.s new file mode 100644 index 000000000..b67d5800c --- /dev/null +++ b/mach/sun3/libsys/sbrk.s @@ -0,0 +1,41 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sbrk,_brk +_sbrk: + move.l (4,sp),d0 + add.l #3,d0 + move.l #~3,d1 + and.l d1,d0 + move.l d0,a0 + move.l (curbrk),d0 + add.l #3,d0 + and.l d1,d0 + move.l d0,(curbrk) + add.l d0,a0 + move.l a0,(4,sp) + pea (17) ! not SYS_sbrk + trap #0 + bcs 1f + move.l (curbrk),d0 + move.l (4,sp),(curbrk) + rts +1: + jmp (cerror) + +_brk: + move.l (4,sp),d0 + add.l #3,d0 + move.l #~3,d1 + and.l d1,d0 + move.l d0,(4,sp) + pea (17) + trap #0 + bcs 1f + move.l (4,sp),(curbrk) + clr.l d0 + rts +1: + jmp (cerror) + +.sect .data +curbrk: .data4 endbss diff --git a/mach/sun3/libsys/select.s b/mach/sun3/libsys/select.s new file mode 100644 index 000000000..7f0425b7a --- /dev/null +++ b/mach/sun3/libsys/select.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _select +_select: SYSTEM(SYS_select) diff --git a/mach/sun3/libsys/sem.s b/mach/sun3/libsys/sem.s new file mode 100644 index 000000000..30de39ec3 --- /dev/null +++ b/mach/sun3/libsys/sem.s @@ -0,0 +1,15 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _semget,_semctl,_semop +_semget: + pea (1) + bra 1f +_semctl: + pea (0) + bra 1f +_semop: + pea (2) +1: + move.l (4,sp),d0 + move.l (sp),(4,sp) + move.l d0,(sp) + jmp (_semsys) diff --git a/mach/sun3/libsys/semsys.s b/mach/sun3/libsys/semsys.s new file mode 100644 index 000000000..9ae7bc088 --- /dev/null +++ b/mach/sun3/libsys/semsys.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _semsys +_semsys: SYSTEM(SYS_semsys) diff --git a/mach/sun3/libsys/send.s b/mach/sun3/libsys/send.s new file mode 100644 index 000000000..729704349 --- /dev/null +++ b/mach/sun3/libsys/send.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _send +_send: SYSTEM(SYS_send) diff --git a/mach/sun3/libsys/sendmsg.s b/mach/sun3/libsys/sendmsg.s new file mode 100644 index 000000000..3d38f3b6b --- /dev/null +++ b/mach/sun3/libsys/sendmsg.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sendmsg +_sendmsg: SYSTEM(SYS_sendmsg) diff --git a/mach/sun3/libsys/sendto.s b/mach/sun3/libsys/sendto.s new file mode 100644 index 000000000..22d752320 --- /dev/null +++ b/mach/sun3/libsys/sendto.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sendto +_sendto: SYSTEM(SYS_sendto) diff --git a/mach/sun3/libsys/setdomnam.s b/mach/sun3/libsys/setdomnam.s new file mode 100644 index 000000000..3bfeb0c1b --- /dev/null +++ b/mach/sun3/libsys/setdomnam.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setdomainname +_setdomainname: SYSTEM(SYS_setdomainname) diff --git a/mach/sun3/libsys/setdopt.s b/mach/sun3/libsys/setdopt.s new file mode 100644 index 000000000..65674e894 --- /dev/null +++ b/mach/sun3/libsys/setdopt.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setdopt +_setdopt: SYSTEM(SYS_setdopt) diff --git a/mach/sun3/libsys/setgid.c b/mach/sun3/libsys/setgid.c new file mode 100644 index 000000000..3137b1b05 --- /dev/null +++ b/mach/sun3/libsys/setgid.c @@ -0,0 +1,4 @@ +setgid(u) +{ + setregid(u,u); +} diff --git a/mach/sun3/libsys/setgroups.s b/mach/sun3/libsys/setgroups.s new file mode 100644 index 000000000..f3ad691d5 --- /dev/null +++ b/mach/sun3/libsys/setgroups.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setgroups +_setgroups: SYSTEM(SYS_setgroups) diff --git a/mach/sun3/libsys/sethostnam.s b/mach/sun3/libsys/sethostnam.s new file mode 100644 index 000000000..b4756c769 --- /dev/null +++ b/mach/sun3/libsys/sethostnam.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sethostname +_sethostname: SYSTEM(SYS_sethostname) diff --git a/mach/sun3/libsys/setitimer.s b/mach/sun3/libsys/setitimer.s new file mode 100644 index 000000000..acdf385c8 --- /dev/null +++ b/mach/sun3/libsys/setitimer.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setitimer +_setitimer: SYSTEM(SYS_setitimer) diff --git a/mach/sun3/libsys/setpgrp.s b/mach/sun3/libsys/setpgrp.s new file mode 100644 index 000000000..9ef2fd625 --- /dev/null +++ b/mach/sun3/libsys/setpgrp.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setpgrp +_setpgrp: SYSTEM(SYS_setpgrp) diff --git a/mach/sun3/libsys/setprio.s b/mach/sun3/libsys/setprio.s new file mode 100644 index 000000000..0004f5bdb --- /dev/null +++ b/mach/sun3/libsys/setprio.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setpriority +_setpriority: SYSTEM(SYS_setpriority) diff --git a/mach/sun3/libsys/setregid.s b/mach/sun3/libsys/setregid.s new file mode 100644 index 000000000..9c4206b1a --- /dev/null +++ b/mach/sun3/libsys/setregid.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setregid +_setregid: SYSTEM(SYS_setregid) diff --git a/mach/sun3/libsys/setreuid.s b/mach/sun3/libsys/setreuid.s new file mode 100644 index 000000000..b0a9d85eb --- /dev/null +++ b/mach/sun3/libsys/setreuid.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setreuid +_setreuid: SYSTEM(SYS_setreuid) diff --git a/mach/sun3/libsys/setrlimit.s b/mach/sun3/libsys/setrlimit.s new file mode 100644 index 000000000..8f39b3fa9 --- /dev/null +++ b/mach/sun3/libsys/setrlimit.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setrlimit +_setrlimit: SYSTEM(SYS_setrlimit) diff --git a/mach/sun3/libsys/setsockopt.s b/mach/sun3/libsys/setsockopt.s new file mode 100644 index 000000000..8a0a340c6 --- /dev/null +++ b/mach/sun3/libsys/setsockopt.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _setsockopt +_setsockopt: SYSTEM(SYS_setsockopt) diff --git a/mach/sun3/libsys/settimday.s b/mach/sun3/libsys/settimday.s new file mode 100644 index 000000000..30f7ed92c --- /dev/null +++ b/mach/sun3/libsys/settimday.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _settimeofday +_settimeofday: SYSTEM(SYS_settimeofday) diff --git a/mach/sun3/libsys/setuid.c b/mach/sun3/libsys/setuid.c new file mode 100644 index 000000000..bf851e10a --- /dev/null +++ b/mach/sun3/libsys/setuid.c @@ -0,0 +1,4 @@ +setuid(u) +{ + setreuid(u,u); +} diff --git a/mach/sun3/libsys/shm.s b/mach/sun3/libsys/shm.s new file mode 100644 index 000000000..54b58f3a4 --- /dev/null +++ b/mach/sun3/libsys/shm.s @@ -0,0 +1,18 @@ +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _shmget,_shmctl,_shmrcv,_shmsnd +_shmget: + pea (3) + bra 1f +_shmctl: + pea (1) + bra 1f +_shmat: + pea (4) + bra 1f +_shmdt: + pea (2) +1: + move.l (4,sp),d0 + move.l (sp),(4,sp) + move.l d0,(sp) + jmp (_shmsys) diff --git a/mach/sun3/libsys/shmsys.s b/mach/sun3/libsys/shmsys.s new file mode 100644 index 000000000..8f3f9f1a1 --- /dev/null +++ b/mach/sun3/libsys/shmsys.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _shmsys +_shmsys: SYSTEM(SYS_shmsys) diff --git a/mach/sun3/libsys/shutdown.s b/mach/sun3/libsys/shutdown.s new file mode 100644 index 000000000..a7400a13f --- /dev/null +++ b/mach/sun3/libsys/shutdown.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _shutdown +_shutdown: SYSTEM(SYS_shutdown) diff --git a/mach/sun3/libsys/sigblock.s b/mach/sun3/libsys/sigblock.s new file mode 100644 index 000000000..fd2393d14 --- /dev/null +++ b/mach/sun3/libsys/sigblock.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sigblock +_sigblock: SYSTEM(SYS_sigblock) diff --git a/mach/sun3/libsys/signal.c b/mach/sun3/libsys/signal.c new file mode 100644 index 000000000..5c829ae1c --- /dev/null +++ b/mach/sun3/libsys/signal.c @@ -0,0 +1,25 @@ +static long masks[32]; +static long flags[32]; +int (* +signal(sig,handler))() + int (*handler)(); +{ + struct { + int (*sv_handler)(); + long sv_mask; + long sv_flags; + } v, ov; + + v.sv_handler = handler; + v.sv_mask = masks[sig]; + v.sv_flags = flags[sig]; + if (sigvec(sig,&v, &ov) < 0) return (int (*)()) -1; + if (v.sv_mask != ov.sv_mask || v.sv_flags != ov.sv_flags) { + v.sv_mask = ov.sv_mask; + masks[sig] = ov.sv_mask; + v.sv_flags = ov.sv_flags; + flags[sig] = ov.sv_flags; + if (sigvec(sig,&v,(char *) 0) < 0) return (int (*)()) -1; + } + return ov.sv_handler; +} diff --git a/mach/sun3/libsys/sigpause.s b/mach/sun3/libsys/sigpause.s new file mode 100644 index 000000000..b58223d25 --- /dev/null +++ b/mach/sun3/libsys/sigpause.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sigpause +_sigpause: SYSTEM(SYS_sigpause) diff --git a/mach/sun3/libsys/sigsetmask.s b/mach/sun3/libsys/sigsetmask.s new file mode 100644 index 000000000..fab366a87 --- /dev/null +++ b/mach/sun3/libsys/sigsetmask.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sigsetmask +_sigsetmask: SYSTEM(SYS_sigsetmask) diff --git a/mach/sun3/libsys/sigstack.s b/mach/sun3/libsys/sigstack.s new file mode 100644 index 000000000..efbf6d876 --- /dev/null +++ b/mach/sun3/libsys/sigstack.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sigstack +_sigstack: SYSTEM(SYS_sigstack) diff --git a/mach/sun3/libsys/sigtramp.s b/mach/sun3/libsys/sigtramp.s new file mode 100644 index 000000000..188fa0ee1 --- /dev/null +++ b/mach/sun3/libsys/sigtramp.s @@ -0,0 +1,17 @@ +.sect .text +.define __sigtramp +__sigtramp: + movem.l d0/d1/a0/a1,-(sp) + move.l (_sigfunc),a0 + move.l (0x14,sp),d0 + lsl.l #2,d0 + move.l (a0,d0),a0 + move.l (0x1c,sp),-(sp) + move.l (0x1c,sp),-(sp) + move.l (0x1c,sp),-(sp) + jsr (a0) + add.l #12,sp + movem.l (sp)+,d0/d1/a0/a1 + add.l #8,sp + pea (0x8b) + trap #0 diff --git a/mach/sun3/libsys/sigvec.c b/mach/sun3/libsys/sigvec.c new file mode 100644 index 000000000..d3e9205df --- /dev/null +++ b/mach/sun3/libsys/sigvec.c @@ -0,0 +1,35 @@ +#include "syscall.h" +#include +struct sigvec { int (*handler)(); int mask,flags; }; +int (*(_sigfunc[32]))(); +extern int _sigtramp(); + +sigvec(sig,vec,ovec) + register struct sigvec *vec; + struct sigvec *ovec; +{ + struct sigvec tmp; + int (*old)(); + + if ((unsigned) sig >= 32) { + errno = EINVAL; + return -1; + } + old = _sigfunc[sig]; + if (vec) { + tmp = *vec; + vec = &tmp; + if (vec->handler && vec->handler != (int (*)()) 1) { + _sigfunc[sig] = vec->handler; + vec->handler = _sigtramp; + } + } + if (syscall(SYS_sigvec,sig,vec,ovec) < 0) { + _sigfunc[sig] = old; + return -1; + } + if (ovec->handler == _sigtramp) { + ovec->handler = old; + } + return 0; +} diff --git a/mach/sun3/libsys/socket.s b/mach/sun3/libsys/socket.s new file mode 100644 index 000000000..6494aee78 --- /dev/null +++ b/mach/sun3/libsys/socket.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _socket +_socket: SYSTEM(SYS_socket) diff --git a/mach/sun3/libsys/socketpair.s b/mach/sun3/libsys/socketpair.s new file mode 100644 index 000000000..f02d06e50 --- /dev/null +++ b/mach/sun3/libsys/socketpair.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _socketpair +_socketpair: SYSTEM(SYS_socketpair) diff --git a/mach/sun3/libsys/sstk.s b/mach/sun3/libsys/sstk.s new file mode 100644 index 000000000..30f6900e1 --- /dev/null +++ b/mach/sun3/libsys/sstk.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sstk +_sstk: SYSTEM(SYS_sstk) diff --git a/mach/sun3/libsys/stat.s b/mach/sun3/libsys/stat.s new file mode 100644 index 000000000..37067e6a9 --- /dev/null +++ b/mach/sun3/libsys/stat.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _stat +_stat: SYSTEM(SYS_stat) diff --git a/mach/sun3/libsys/statfs.s b/mach/sun3/libsys/statfs.s new file mode 100644 index 000000000..8af106a31 --- /dev/null +++ b/mach/sun3/libsys/statfs.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _statfs +_statfs: SYSTEM(SYS_statfs) diff --git a/mach/sun3/libsys/stime.c b/mach/sun3/libsys/stime.c new file mode 100644 index 000000000..3b5b15f55 --- /dev/null +++ b/mach/sun3/libsys/stime.c @@ -0,0 +1,9 @@ +stime(tp) + long *tp; +{ + struct { long l1,l2; } x; + + x.l1 = *tp; + x.l2 = 0; + settimeofday(&x, (char *) 0); +} diff --git a/mach/sun3/libsys/stty.c b/mach/sun3/libsys/stty.c new file mode 100644 index 000000000..222310cc3 --- /dev/null +++ b/mach/sun3/libsys/stty.c @@ -0,0 +1,7 @@ +#include +int stty(fildes,argp) + int fildes ; + struct sgttyb *argp ; +{ + return ioctl(fildes,TIOCSETP,argp) ; +} diff --git a/mach/sun3/libsys/swapon.s b/mach/sun3/libsys/swapon.s new file mode 100644 index 000000000..d6947896d --- /dev/null +++ b/mach/sun3/libsys/swapon.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _swapon +_swapon: SYSTEM(SYS_swapon) diff --git a/mach/sun3/libsys/symlink.s b/mach/sun3/libsys/symlink.s new file mode 100644 index 000000000..b7e9372b5 --- /dev/null +++ b/mach/sun3/libsys/symlink.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _symlink +_symlink: SYSTEM(SYS_symlink) diff --git a/mach/sun3/libsys/sync.s b/mach/sun3/libsys/sync.s new file mode 100644 index 000000000..24cf538ba --- /dev/null +++ b/mach/sun3/libsys/sync.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _sync +_sync: SYSTEM(SYS_sync) diff --git a/mach/sun3/libsys/syscall.h b/mach/sun3/libsys/syscall.h new file mode 100644 index 000000000..48911ca6c --- /dev/null +++ b/mach/sun3/libsys/syscall.h @@ -0,0 +1,127 @@ +#define SYSTEM(sys) pea (sys); trap #0; bcs 1f; rts; 1: jmp (cerror) +#define SYS_exit 1 +#define SYS_fork 2 +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_creat 8 +#define SYS_link 9 +#define SYS_unlink 10 +#define SYS_execv 11 +#define SYS_chdir 12 +#define SYS_mknod 14 +#define SYS_chmod 15 +#define SYS_chown 16 +#define SYS_lseek 19 +#define SYS_getpid 20 +#define SYS_getuid 24 +#define SYS_ptrace 26 +#define SYS_access 33 +#define SYS_sync 36 +#define SYS_kill 37 +#define SYS_stat 38 +#define SYS_lstat 40 +#define SYS_dup 41 +#define SYS_pipe 42 +#define SYS_profil 44 +#define SYS_getgid 47 +#define SYS_acct 51 +#define SYS_ioctl 54 +#define SYS_reboot 55 +#define SYS_symlink 57 +#define SYS_readlink 58 +#define SYS_execve 59 +#define SYS_umask 60 +#define SYS_chroot 61 +#define SYS_fstat 62 +#define SYS_getpagesize 64 +#define SYS_mremap 65 +#define SYS_vfork 66 +#define SYS_sbrk 69 +#define SYS_sstk 70 +#define SYS_mmap 71 +#define SYS_vadvise 72 +#define SYS_munmap 73 +#define SYS_mprotect 74 +#define SYS_madvise 75 +#define SYS_vhangup 76 +#define SYS_mincore 78 +#define SYS_getgroups 79 +#define SYS_setgroups 80 +#define SYS_getpgrp 81 +#define SYS_setpgrp 82 +#define SYS_setitimer 83 +#define SYS_wait 84 +#define SYS_swapon 85 +#define SYS_getitimer 86 +#define SYS_gethostname 87 +#define SYS_sethostname 88 +#define SYS_getdtablesize 89 +#define SYS_dup2 90 +#define SYS_getdopt 91 +#define SYS_fcntl 92 +#define SYS_select 93 +#define SYS_setdopt 94 +#define SYS_fsync 95 +#define SYS_setpriority 96 +#define SYS_socket 97 +#define SYS_connect 98 +#define SYS_accept 99 +#define SYS_getpriority 100 +#define SYS_send 101 +#define SYS_recv 102 +#define SYS_bind 104 +#define SYS_setsockopt 105 +#define SYS_listen 106 +#define SYS_sigvec 108 +#define SYS_sigblock 109 +#define SYS_sigsetmask 110 +#define SYS_sigpause 111 +#define SYS_sigstack 112 +#define SYS_recvmsg 113 +#define SYS_sendmsg 114 +#define SYS_gettimeofday 116 +#define SYS_getrusage 117 +#define SYS_getsockopt 118 +#define SYS_readv 120 +#define SYS_writev 121 +#define SYS_settimeofday 122 +#define SYS_fchown 123 +#define SYS_fchmod 124 +#define SYS_recvfrom 125 +#define SYS_setreuid 126 +#define SYS_setregid 127 +#define SYS_rename 128 +#define SYS_truncate 129 +#define SYS_ftruncate 130 +#define SYS_flock 131 +#define SYS_sendto 133 +#define SYS_shutdown 134 +#define SYS_socketpair 135 +#define SYS_mkdir 136 +#define SYS_rmdir 137 +#define SYS_utimes 138 +#define SYS_adjtime 140 +#define SYS_getpeername 141 +#define SYS_gethostid 142 +#define SYS_getrlimit 144 +#define SYS_setrlimit 145 +#define SYS_killpg 146 +#define SYS_getsockname 150 +#define SYS_nfssvc 155 +#define SYS_getdirentries 156 +#define SYS_statfs 157 +#define SYS_fstatfs 158 +#define SYS_unmount 159 +#define SYS_async_daemon 160 +#define SYS_getfh 161 +#define SYS_getdomainname 162 +#define SYS_setdomainname 163 +#define SYS_quotactl 165 +#define SYS_exportfs 166 +#define SYS_mount 167 +#define SYS_ustat 168 +#define SYS_semsys 169 +#define SYS_msgsys 170 +#define SYS_shmsys 171 diff --git a/mach/sun3/libsys/syscall.s b/mach/sun3/libsys/syscall.s new file mode 100644 index 000000000..5e7320613 --- /dev/null +++ b/mach/sun3/libsys/syscall.s @@ -0,0 +1,14 @@ +.sect .text +.define _syscall +_syscall: + move.l (4,sp),d0 + move.l (sp),(4,sp) + move.l d0,(sp) + trap #0 + bcs 1f + move.l (sp),a0 + jmp (a0) +1: + move.l (sp),a0 + move.l a0,-(sp) + jmp (cerror) diff --git a/mach/sun3/libsys/tell.c b/mach/sun3/libsys/tell.c new file mode 100644 index 000000000..49e2a917a --- /dev/null +++ b/mach/sun3/libsys/tell.c @@ -0,0 +1,7 @@ +long +tell(f) +{ + long lseek(); + + return lseek(f, 0L, 1); +} diff --git a/mach/sun3/libsys/time.c b/mach/sun3/libsys/time.c new file mode 100644 index 000000000..3dd1eeaed --- /dev/null +++ b/mach/sun3/libsys/time.c @@ -0,0 +1,12 @@ +long +time(loc) + long *loc; +{ + struct { long l1,l2; } t1; + + if (gettimeofday(&t1, (char *) 0) < 0) { + return -1; + } + if (loc) *loc = t1.l1; + return t1.l1; +} diff --git a/mach/sun3/libsys/times.c b/mach/sun3/libsys/times.c new file mode 100644 index 000000000..4e23d92b9 --- /dev/null +++ b/mach/sun3/libsys/times.c @@ -0,0 +1,16 @@ +#include + +#define Xval(xx) ((xx).l1*60+(xx).l2/(100000/6)) + +times(bp) + struct { time_t l1,l2,l3,l4;} *bp; +{ + struct { struct { long l1,l2; }s1,s2; long x[20]; } t; + if (getrusage(0,&t) < 0) return -1; + bp->l1 = Xval(t.s1); + bp->l2 = Xval(t.s2); + if (getrusage(-1,&t) < 0) return -1; + bp->l3 = Xval(t.s1); + bp->l4 = Xval(t.s2); + return 0; +} diff --git a/mach/sun3/libsys/truncate.s b/mach/sun3/libsys/truncate.s new file mode 100644 index 000000000..c92966063 --- /dev/null +++ b/mach/sun3/libsys/truncate.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _truncate +_truncate: SYSTEM(SYS_truncate) diff --git a/mach/sun3/libsys/ulimit.c b/mach/sun3/libsys/ulimit.c new file mode 100644 index 000000000..0e3715b35 --- /dev/null +++ b/mach/sun3/libsys/ulimit.c @@ -0,0 +1,26 @@ +#include + +ulimit(cmd, newlimit) + long newlimit; +{ + extern int errno; + struct { + long soft, hard; + } x; + + switch(cmd) { + case 1: + if (getrlimit(1, &x) < 0) return -1; + return ((x.soft + 511) & ~511) >> 9; + case 2: + x.soft = x.hard = (newlimit << 9); + if (setrlimit(1, &x) < 0) return -1; + return x.soft; + case 3: + if (getrlimit(2, &x) < 0) return -1; + return x.soft; + default: + errno = EINVAL; + return -1; + } +} diff --git a/mach/sun3/libsys/umask.s b/mach/sun3/libsys/umask.s new file mode 100644 index 000000000..cf1102ebc --- /dev/null +++ b/mach/sun3/libsys/umask.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _umask +_umask: SYSTEM(SYS_umask) diff --git a/mach/sun3/libsys/uname.c b/mach/sun3/libsys/uname.c new file mode 100644 index 000000000..4670c25c8 --- /dev/null +++ b/mach/sun3/libsys/uname.c @@ -0,0 +1,26 @@ +extern int errno; + +struct utsname { + char sysname[9],nodename[9],release[9],version[9],machine[9]; +}; + +static char def_node[] = "unknown"; +static char rel[] = "4.2BSD"; +static char ver[] = "vm"; +static char mach[] = "sun"; + +uname(nm) + register struct utsname *nm; +{ + register char *p = nm->nodename; + + while (p <= nm->release) *p++ = 0; + if (gethostname(nm->nodename,9) == -1) { + strcpy(nm->nodename, def_node); + } + strncpy(nm->sysname,nm->nodename,9); + strncpy(nm->release,rel,9); + strncpy(nm->version,ver,9); + strncpy(nm->machine,mach,9); + return 0; +} diff --git a/mach/sun3/libsys/unlink.s b/mach/sun3/libsys/unlink.s new file mode 100644 index 000000000..f25076820 --- /dev/null +++ b/mach/sun3/libsys/unlink.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _unlink +_unlink: SYSTEM(SYS_unlink) diff --git a/mach/sun3/libsys/unmount.s b/mach/sun3/libsys/unmount.s new file mode 100644 index 000000000..4e23bd9f1 --- /dev/null +++ b/mach/sun3/libsys/unmount.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _unmount +_unmount: SYSTEM(SYS_unmount) diff --git a/mach/sun3/libsys/ustat.s b/mach/sun3/libsys/ustat.s new file mode 100644 index 000000000..cc03ac0fc --- /dev/null +++ b/mach/sun3/libsys/ustat.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _ustat +_ustat: SYSTEM(SYS_ustat) diff --git a/mach/sun3/libsys/utime.c b/mach/sun3/libsys/utime.c new file mode 100644 index 000000000..a3804e336 --- /dev/null +++ b/mach/sun3/libsys/utime.c @@ -0,0 +1,13 @@ +#include + +utime(file, timep) + char *file; + time_t timep[2]; +{ + struct { long l1,l2,l3,l4; } x; + + x.l2 = x.l4 = 0; + x.l1 = timep[0]; + x.l3 = timep[1]; + utimes(file,&x); +} diff --git a/mach/sun3/libsys/utimes.s b/mach/sun3/libsys/utimes.s new file mode 100644 index 000000000..4cfa34cbf --- /dev/null +++ b/mach/sun3/libsys/utimes.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _utimes +_utimes: SYSTEM(SYS_utimes) diff --git a/mach/sun3/libsys/vadvise.s b/mach/sun3/libsys/vadvise.s new file mode 100644 index 000000000..b21b4d697 --- /dev/null +++ b/mach/sun3/libsys/vadvise.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _vadvise +_vadvise: SYSTEM(SYS_vadvise) diff --git a/mach/sun3/libsys/vfork.s b/mach/sun3/libsys/vfork.s new file mode 100644 index 000000000..5ee9cace8 --- /dev/null +++ b/mach/sun3/libsys/vfork.s @@ -0,0 +1,18 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _vfork +_vfork: + move.l (sp)+,a0 + pea (SYS_vfork) + trap #0 + bcs 1f + tst.l d1 + bne 2f + jmp (a0) +1: + move.l d0,(_errno) + move.l #-1,d0 + jmp (a0) +2: + clr.l d0 + jmp (a0) diff --git a/mach/sun3/libsys/vhangup.s b/mach/sun3/libsys/vhangup.s new file mode 100644 index 000000000..d322320d9 --- /dev/null +++ b/mach/sun3/libsys/vhangup.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _vhangup +_vhangup: SYSTEM(SYS_vhangup) diff --git a/mach/sun3/libsys/wait.s b/mach/sun3/libsys/wait.s new file mode 100644 index 000000000..42ece9ee4 --- /dev/null +++ b/mach/sun3/libsys/wait.s @@ -0,0 +1,15 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _wait +_wait: + pea (SYS_wait) + trap #0 + bcs 1f + tst.l (4,sp) + beq 2f + move.l (4,sp),a0 + move.l d1,(a0) +2: + rts +1: + jmp (cerror) diff --git a/mach/sun3/libsys/wait3.s b/mach/sun3/libsys/wait3.s new file mode 100644 index 000000000..d55b6aca7 --- /dev/null +++ b/mach/sun3/libsys/wait3.s @@ -0,0 +1,18 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _wait3 +_wait3: + move.l (8,sp),d0 + move.l (12,sp),d1 + pea (SYS_wait) + or.b #0x1f,ccr + trap #0 + bcc 1f + jmp (cerror) +1: + tst.l (4,sp) + beq 1f + move.l (4,sp),a0 + move.l d1,(a0) +1: + rts diff --git a/mach/sun3/libsys/write.s b/mach/sun3/libsys/write.s new file mode 100644 index 000000000..3ace177a7 --- /dev/null +++ b/mach/sun3/libsys/write.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _write +_write: SYSTEM(SYS_write) diff --git a/mach/sun3/libsys/writev.s b/mach/sun3/libsys/writev.s new file mode 100644 index 000000000..89f4f5286 --- /dev/null +++ b/mach/sun3/libsys/writev.s @@ -0,0 +1,4 @@ +#include "syscall.h" +.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text +.define _writev +_writev: SYSTEM(SYS_writev)