diff options
author | Dale S. Rahn <rahnds@cvs.openbsd.org> | 1997-03-03 20:23:07 +0000 |
---|---|---|
committer | Dale S. Rahn <rahnds@cvs.openbsd.org> | 1997-03-03 20:23:07 +0000 |
commit | b810033e0fa5b5b7163cee7059c523aaf907c6a5 (patch) | |
tree | fcde3ace3c188a7d797a313c9173a233532d44ca /sys/arch/mvme88k/stand/bugexec | |
parent | 90ff5a441368313fa226376473fea6908c2c3539 (diff) |
Cleanup after import. This also seems to bring up the current version.
Diffstat (limited to 'sys/arch/mvme88k/stand/bugexec')
-rw-r--r-- | sys/arch/mvme88k/stand/bugexec/Makefile | 26 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bugexec/hello.c | 54 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/bugexec/wrtos.c | 64 |
3 files changed, 144 insertions, 0 deletions
diff --git a/sys/arch/mvme88k/stand/bugexec/Makefile b/sys/arch/mvme88k/stand/bugexec/Makefile new file mode 100644 index 00000000000..3ed0ff02de6 --- /dev/null +++ b/sys/arch/mvme88k/stand/bugexec/Makefile @@ -0,0 +1,26 @@ +all: hello +SRCS= hello.c +OBJS= hello.o + +CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/${MACHINE_ARCH} +CFLAGS+=-I${.CURDIR}/../include -I${.CURDIR}/../.. -I/usr/src/sys +CFLAGS+=-fwritable-strings + +LIBBUG!= cd $(.CURDIR)/../libbug; \ + printf "xxx:\n\techo \$${.OBJDIR}/libbug.a\n" | ${MAKE} -r -s -f - xxx + +BUGCRT!= cd $(.CURDIR)/../bugcrt; \ + printf "xxx:\n\techo \$${.OBJDIR}/bugcrt.o\n" | ${MAKE} -r -s -f - xxx + +KERNCRT!= cd $(.CURDIR)/../kerncrt; \ + printf "xxx:\n\techo \$${.OBJDIR}/kerncrt.o\n" | ${MAKE} -r -s -f - xxx + +LDADD+=${LIBBUG} /usr/local/lib/libgcc.a + +hello: $(OBJS) ${LIBBUG} + ${LD} -x -Ttext 10020 ${KERNCRT} $(OBJS) ${LDADD} -o ${.TARGET} +clean: + rm -f a.out *.core + rm -f hello.o hello.bug hello.bug.1 hello.bug.2 + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/bugexec/hello.c b/sys/arch/mvme88k/stand/bugexec/hello.c new file mode 100644 index 00000000000..08ab75d2a27 --- /dev/null +++ b/sys/arch/mvme88k/stand/bugexec/hello.c @@ -0,0 +1,54 @@ +#include "bug.h" +#include "bugio.h" + +void putchar __P((char)); +int bcd2int __P((unsigned int)); + +void +putchar(char c) +{ + bugoutchr(c); +} + +main(struct bugenv *env) +{ + struct bugrtc rtc; + struct bugbrdid brdid; + + bugrtcrd(&rtc); + printf("From RTC:\n"); + printf("Year %d\tMonth %d\tDay %d\tDay of Week %d\n", + bcd2int(rtc.Y), bcd2int(rtc.M), bcd2int(rtc.D), bcd2int(rtc.d)); + printf("Hour %d\tMin %d\tSec %d\tCal %d\n", + bcd2int(rtc.H), bcd2int(rtc.m), bcd2int(rtc.s), bcd2int(rtc.c)); + printf("From BRDID:\n"); + bugbrdid(&brdid); +/* printf("Eye catcher %c%c%c%c\n", brdid.eye[0], brdid.eye[1], + brdid.eye[2], brdid.eye[3]); */ + printf("Board no %d (%d) \tsuffix %c%c\n", bcd2int(brdid.brdno), + brdid.brdno, brdid.brdsuf[0], brdid.brdsuf[1]); +/* printf("Clun %x\tdlun %x\n", brdid.clun, brdid.dlun); */ + return 0; +} + +ipow(int base, int i) +{ + int cnt = 1; + while (i--) { + cnt *= base; + } + return cnt; +} + +int +bcd2int(unsigned int i) +{ + unsigned val = 0; + int cnt = 0; + while (i) { + val += (i&0xf) * ipow(10,cnt); + cnt++; + i >>= 4; + } + return val; +} diff --git a/sys/arch/mvme88k/stand/bugexec/wrtos.c b/sys/arch/mvme88k/stand/bugexec/wrtos.c new file mode 100644 index 00000000000..1e01b697399 --- /dev/null +++ b/sys/arch/mvme88k/stand/bugexec/wrtos.c @@ -0,0 +1,64 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#include "vid.h" + +#define sec2blk(x) ((x) * 2) +#define BUF_SIZ 512 + +main(int argc, char **argv) +{ + struct vid *pvid; + struct cfg *pcfg; + struct stat stat; + int exe_file; + int tape_vid; + int tape_exe; + char *filename; + char fileext[256]; + char hdrbuf[BUF_SIZ]; + + if (argc == 0){ + filename = "a.out"; + } else { + filename = argv[1]; + } + exe_file = open(filename, O_RDONLY,0444); + if (exe_file == -1) + { + printf("file %s does not exist\n",filename); + exit(2); + } + sprintf (fileext,"%s%s",filename,".1"); + tape_vid = open(fileext, O_WRONLY|O_CREAT|O_TRUNC,0644); + sprintf (fileext,"%s%s",filename,".2"); + tape_exe = open(fileext, O_WRONLY|O_CREAT|O_TRUNC,0644); + + lseek(exe_file,0,SEEK_SET); + memset (hdrbuf,0,BUF_SIZ); + read(exe_file,hdrbuf, 0x20); /* read the header */ + + write(tape_vid,hdrbuf,BUF_SIZ); + + copy_exe(exe_file,tape_exe); + close (exe_file); + close (tape_vid); + close (tape_exe); +} + +copy_exe(exe_file,tape_exe) +{ + char *buf; + int cnt = 0; + + buf = (char *)malloc (BUF_SIZ); + + lseek (exe_file,0x20,SEEK_SET); + while (BUF_SIZ == (cnt = read(exe_file, buf , BUF_SIZ))) { + write (tape_exe,buf,cnt); + } + memset (&buf[cnt],0,BUF_SIZ-cnt); + write (tape_exe,buf,BUF_SIZ); +} |