Initial revision

This commit is contained in:
bal 1984-07-19 11:50:28 +00:00
parent 1eade4ac9d
commit 69584eb0ca
4 changed files with 213 additions and 0 deletions

19
mach/m68k2/dl/Makefile Normal file
View file

@ -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

70
mach/m68k2/dl/cv.c Normal file
View file

@ -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 <stdio.h>
#include <a.out.h>
/*
* 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;
}

105
mach/m68k2/dl/dl.c Normal file
View file

@ -0,0 +1,105 @@
#define MAXBYTE 24
#include <stdio.h>
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);
}

19
mach/pmds/cv/Makefile Normal file
View file

@ -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