From 69584eb0ca74be9a2cb116c1c138c64e91b551eb Mon Sep 17 00:00:00 2001 From: bal Date: Thu, 19 Jul 1984 11:50:28 +0000 Subject: [PATCH] Initial revision --- mach/m68k2/dl/Makefile | 19 ++++++++ mach/m68k2/dl/cv.c | 70 +++++++++++++++++++++++++++ mach/m68k2/dl/dl.c | 105 +++++++++++++++++++++++++++++++++++++++++ mach/pmds/cv/Makefile | 19 ++++++++ 4 files changed, 213 insertions(+) create mode 100644 mach/m68k2/dl/Makefile create mode 100644 mach/m68k2/dl/cv.c create mode 100644 mach/m68k2/dl/dl.c create mode 100644 mach/pmds/cv/Makefile diff --git a/mach/m68k2/dl/Makefile b/mach/m68k2/dl/Makefile new file mode 100644 index 000000000..637d879dd --- /dev/null +++ b/mach/m68k2/dl/Makefile @@ -0,0 +1,19 @@ +CFLAGS=-O + +cv: cv.o + cc -o cv -n cv.o + +install: cv + cp cv ../../../bin + +cmp: cv + -../compare cv + +opr: + make pr | opr + +pr: + @pr `pwd`/cv.c + +clean: + -rm -f *.o *.old cv diff --git a/mach/m68k2/dl/cv.c b/mach/m68k2/dl/cv.c new file mode 100644 index 000000000..aa273a992 --- /dev/null +++ b/mach/m68k2/dl/cv.c @@ -0,0 +1,70 @@ +/* + * (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 + * + */ + +#include +#include + +/* + * NOTE: Beware that the a.out.h file included here should be the a.out.h + * file of the TARGET machine, not of the SOURCE machine. + */ + +struct bhdr s_exec; + +main(argc,argv) char **argv; { + unsigned short losh,hish; + long addr,maxaddr; + short count; + + maxaddr=0; + if (argc != 3) { + fprintf(stderr,"Usage: %s VU-a.out Bleasdale-a.out\n",argv[0]); + exit(-1); + } + if (freopen(argv[1],"r",stdin)==NULL) { + perror(argv[1]); + exit(-1); + } + if (freopen(argv[2],"w",stdout)==NULL) { + perror(argv[2]); + exit(-1); + } + while (fread(&hish,sizeof(short),1,stdin)==1) { + if (fread(&losh,sizeof(short),1,stdin)!=1) + exit(fprintf(stderr,"foo\n")); + addr=losh+(((long)hish)*65536L); + addr -= 0x20000; /* entry point is 0x20000 on Bleasdale */ + if (fread(&count,sizeof(short),1,stdin)!=1) + exit(fprintf(stderr,"bar\n")); + fseek(stdout,addr+sizeof(s_exec),0); + while (count--) { + putchar(getchar()); + addr++; + } + if (addr>maxaddr) + maxaddr = addr; + } + s_exec.fmagic = FMAGIC; + s_exec.dsize = maxaddr; + s_exec.entry = 0x20000; + fseek(stdout,0L,0); + fwrite(&s_exec,sizeof(s_exec),1,stdout); + chmod(argv[2],0755); + return 0; +} + + diff --git a/mach/m68k2/dl/dl.c b/mach/m68k2/dl/dl.c new file mode 100644 index 000000000..4fa809caf --- /dev/null +++ b/mach/m68k2/dl/dl.c @@ -0,0 +1,105 @@ +#define MAXBYTE 24 +#include +char hex[] = "0123456789ABCDEF"; +FILE *fp, *fopen(); +char **s; +int bytes, bytcnt, checksum; +long pc; + + +main (argc,argv) +int argc; +char *argv[]; + { + if (argc != 2) fatal ("usage: %s filename\n",argv[0]); + if ((fp = fopen (*++argv,"r")) == NULL) + fatal ("can't open %s\n",*argv); + else { + s = argv; + convert (); + fclose (fp); + } + } + +convert () + { + int c; + do + { + pc = getword (); + pc = (pc << 16) | getword (); + bytes = getword (); + while (bytes != 0) + { + bytcnt = (bytes < MAXBYTE) ? bytes : MAXBYTE; + bytes -= bytcnt; + checksum = 0; + if (pc > 0xffffL) S2record (); else S1record (); + } + c = getc (fp); + ungetc (c, fp); + } + while (c != EOF); + printf ("S9030000FC\n"); + } + + +S2record () + { + printf ("S2"); + bytcnt += 4; + outbyte (bytcnt); + outbyte (pc); + record (); + } + +S1record () + { + printf ("S1"); + bytcnt += 3; + outbyte (bytcnt); + record (); + } + +record () + { + outbyte (pc << 8); + outbyte (pc << 16); + while (bytcnt != 0) + { + outbyte (getbyte ()); + pc ++; + } + outbyte (~checksum); + putchar ('\n'); + putchar (0); + putchar (0); + } + +outbyte (b) +int b; + { + checksum = (checksum + b) & 0377; + putchar (hex[(b>>4) & 017]); + putchar (hex[b & 017]); + -- bytcnt; + } + +getword () + { + int c; + c = getbyte (); + return ((getbyte () << 8) | c ); + } + +getbyte () + { + int c; + if ((c = getc (fp)) == EOF) fatal ("end of %s\n",*s); + return (c); + } +fatal (s,a) + { + printf (s,a); + exit (-1); + } diff --git a/mach/pmds/cv/Makefile b/mach/pmds/cv/Makefile new file mode 100644 index 000000000..637d879dd --- /dev/null +++ b/mach/pmds/cv/Makefile @@ -0,0 +1,19 @@ +CFLAGS=-O + +cv: cv.o + cc -o cv -n cv.o + +install: cv + cp cv ../../../bin + +cmp: cv + -../compare cv + +opr: + make pr | opr + +pr: + @pr `pwd`/cv.c + +clean: + -rm -f *.o *.old cv -- 2.34.1