+++ /dev/null
-SUBDIRS = libbug kerncrt boot bugexec
-SUBDIR = libbug kerncrt boot bugexec
-
-.include <bsd.prog.mk>
+++ /dev/null
-all: boot boot.out
-CFLAGS+=-fwritable-strings -I${.CURDIR}/../include
-CFLAGS+=-I${.CURDIR}/../.. -I${.CURDIR}/../../machine
-CFLAGS+=-I/usr/src/sys
-LDFLAGS+= -L ${.CURDIR}/../libbug -L/usr/local/lib
-BOOT=FC0000
-#BOOT=1000000
-
-LIBBUG!= cd $(.CURDIR)/../libbug; \
- printf "xxx:\n\techo \$${.OBJDIR}/libbug.a\n" | ${MAKE} -r -s -f - xxx
-
-LDADD+=${LIBBUG} #/usr/local/lib/libgcc.a
-SRCS+=bugcrt.c bugio.c main.c
-
-.PATH: ${.CURDIR}/../bugcrt ${.CURDIR}/../libbug ${.CURDIR}/../../../../lib/libc_sa ${.CURDIR}/${MACHINE_ARCH}
-
-boot: bugcrt.o main.o bcopy.o memset.o printf.o ${LIBBUG}
-# ld -o {.TARGET} -x -n -Ttext ${BOOT} bugcrt.o bugio.o main.o bcopy.o memset.o printf.o /usr/local/lib/libgcc.a
- ld -o ${.TARGET} -x -N -Ttext ${BOOT} ${.ALLSRC} ${LDADD}
-
-boot.out:
- ${.CURDIR}/wrtvid ${.OBJDIR}/boot && mv ${.OBJDIR}/boot.? ${.CURDIR}
-
-#main.o: main.c
-# ${CC} ${CFLAGS} -c -O ${.ALLSRC}
-# ${LD} -x -r ${.TARGET}
-# ${LD} -x ${.TARGET}
-# mv a.out ${.TARGET}
-
-.include <bsd.prog.mk>
+++ /dev/null
-#include <sys/param.h>
-#include <sys/reboot.h>
-#include "bug.h"
-#include "bugio.h"
-#include "machine/exec.h"
-
-int readblk __P((int, char *));
-int loados __P((void));
-void putchar __P((char));
-void _main __P((void));
-void tapefileseek __P((int));
-
-char Clun, Dlun;
-
-#define DEV_BSIZE 512
-#define KERNEL_LOAD_ADDR 0x10000
-#if !defined(BUG_BLKSIZE)
-#define BUG_BLKSIZE 256
-#endif /* BUG_BLKSIZE */
-#define sec2blk(x) ((x) * (DEV_BSIZE/BUG_BLKSIZE))
-
-struct kernel {
- void *entry;
- void *symtab;
- void *esym;
- int bflags;
- int bdev;
- char *kname;
- void *smini;
- void *emini;
- unsigned int end_loaded;
-} kernel;
-
-int howto = 0;
-int bootdev = 0;
-int *miniroot;
-
-void
-putchar(char c)
-{
- bugoutchr(c);
-}
-
-main(struct bugenv *env)
-{
- printf("Clun %x Dlun %x\n", env->clun, env->dlun);
- Clun = (char)env->clun;
- Dlun = (char)env->dlun;
- loados();
- return;
-}
-
-
-loados(void)
-{
- int i, size;
- register char *loadaddr = (char *)KERNEL_LOAD_ADDR; /* load addr 64k*/
- struct exec *hdr;
- int (*fptr)();
- int *esym;
- int cnt, strtablen, ret;
- char *addr;
-
- howto |= RB_SINGLE|RB_KDB;
-
- tapefileseek(2); /* seek to file 2 - the OS */
- if (readblk(1, loadaddr) == -1) {
- printf("Unable to read blk 0\n");
- return 1;
- }
- hdr = (struct exec *)loadaddr;
-
- /* We only deal with ZMAGIC files */
- if ((int)hdr->a_entry != (int)(loadaddr + sizeof(struct exec))) {
- printf("a_entry != loadaddr + exec size\n");
- }
- size = hdr->a_text + hdr->a_data;
- size -= DEV_BSIZE; /* account for the block already read */
-
- printf("Loading [%x+%x", hdr->a_text, hdr->a_data);
- if (readblk(size / DEV_BSIZE, loadaddr + DEV_BSIZE) == -1) {
- printf("Error reading the OS\n");
- return 1;
- }
-
- /* zero out BSS */
-
- printf("+%x]", hdr->a_bss);
-#if DEBUG
- printf("zero'd out %x (%x)\n", loadaddr + hdr->a_text + hdr->a_data,
- hdr->a_bss);
-#endif
- memset(loadaddr + hdr->a_text + hdr->a_data, 0, hdr->a_bss);
-
- addr = loadaddr + hdr->a_text + hdr->a_data + hdr->a_bss;
-
- if (hdr->a_syms != 0 /* && !(kernel.bflags & RB_NOSYM)*/) {
- /*
- * DDB expects the following layout:
- * no. of syms
- * symbols
- * size of strtab
- * entries of strtab
- * esym->...
- * Where as size of strtab is part of strtab, we need
- * to prepend the size of symtab to satisfy ddb.
- * esym is expected to point past the last byte of
- * string table, rouded up to an int.
- */
- bcopy(&hdr->a_syms, addr, sizeof(hdr->a_syms));
- addr += 4; /* account for a_syms copied above */
- printf (" + [ %x",hdr->a_syms);
-
- cnt = (hdr->a_syms + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1);
-
- ret = readblk(cnt / DEV_BSIZE, addr);
- if (ret != 0) {
- printf("unable to load kernel\n");
- return 1;
- }
-
- esym = (void *) ((int)addr + hdr->a_syms);
-
- if ((int)addr + cnt <= (int)esym) {
- printf("missed loading count of symbols\n\r");
- return 1;
- }
-
- addr += cnt;
-
- strtablen = *esym;
-#if 0
- printf("start load %x end load %x %x\n", addr,
- len, addr +len);
- printf("esym %x *esym %x\n",esym, len);
-#endif
- /*
- * If symbol table size is not a sector multiple, we
- * already read part of the string table. Look at the
- * part already read, and figure out the string table
- * size. Also, adjust the size yet to read.
- */
- if (hdr->a_syms != cnt) {
- /* already read part of the string table */
- strtablen -= (cnt - hdr->a_syms);
- }
-
- if (strtablen > 0) {
- printf(" + %x",*esym);
-
- cnt = (strtablen + DEV_BSIZE -1) & ~(DEV_BSIZE - 1);
-
- ret = readblk(cnt / DEV_BSIZE, addr);
- if (ret != 0) {
- printf("unable to load kernel\n");
- return 1;
- }
- addr += strtablen;
- printf(" ]\n");
- } else {
- printf("+ %x ]\n", *esym);
- }
- esym = (int *)(((int)esym) + *esym);
- esym = (int *)(((int)esym + 4 - 1) & ~3);
-
- kernel.symtab = (void *)hdr->a_syms;
- kernel.esym = esym;
- } else {
- kernel.symtab = 0;
- kernel.esym = 0;
- }
-
- kernel.end_loaded = (unsigned int)addr;
- miniroot = (int *)esym;
- miniroot = (int *)(((int)miniroot + 0x1000 - 1) & ~0xFFF);
- tapefileseek(3); /* seek to file 3 - minroot */
- if (readblk(1000, miniroot) != 0) {
- printf("miniroot not loaded\n");
- addr = (char *)miniroot;
- } else {
- addr = (char *)((int)miniroot + 1000 * DEV_BSIZE);
- }
- printf("esym %x miniroot @ %x (ends @ %x)\n", esym, miniroot, addr);
-#if 0
- {
- char *symaddr = (char *)0x01F00000;
- int i;
-
- tapefileseek(4); /* seek to file 4 - syms */
- readblk(1, symaddr);
- i = *symaddr;
- i = (i * 0x1C + 4 + DEV_BSIZE) & ~(DEV_BSIZE - 1);
- printf("loading %d symbols (%d sectors)\n",
- *symaddr, (i + 1) * DEV_BSIZE);
- readblk(i / DEV_BSIZE, symaddr + DEV_BSIZE);
- readblk(100, 0x01F00000);
- }
-#endif
-
- fptr = (int (*)())hdr->a_entry;
- /*
- * Args are passed as
- * r2 howto
- * r3 end addr
- * r4 (Clun << 8) | Dlun & FF
- * r5 esym
- * r6 miniroot
- */
- bootdev = ((Clun << 8) & 0xFF00 | Dlun & 0xFF) & 0xFFFF;
-#if 0
- asm volatile ("or r2, r0, %0\n\tor r3, r0, %1\n\tor r4, r0, %2\n\tor r5, r0, %3\n\tor r6, r0, %4\n\tor r7, r0, %5"
- : /* no outputs */
- : "r" (howto), "r" (addr), "r" (Clun), "r" (Dlun), "r" (esym), "r" (miniroot)
- : "r2", "r3", "r4", "r5", "r6", "r7");
-#endif /* 0 */
- (*fptr)(howto, addr, bootdev, esym, miniroot);
- return 0;
-}
-
-int
-readblk(int n, char *addr)
-{
- struct bugdisk_io io;
-
- io.clun = Clun;
- io.dlun = Dlun;
- io.status = 0;
- io.addr = (void *)addr;
- io.fileno = 0; /* for tape reads, start io at current pos */
- io.nblks = sec2blk(n);
- io.flag = IGNOREFILENO;
- io.am = 0;
- bugdskrd(&io);
- if (io.status)
- return -1;
- return 0;
-}
-
-void
-_main(void)
-{
- return;
-}
-
-void
-tapefileseek(int i)
-{
- struct bugdisk_io io;
- void *addr = (void *)KERNEL_LOAD_ADDR; /* some number - don't care */
-
- io.clun = Clun;
- io.dlun = Dlun;
- io.status = 0;
- io.addr = addr;
- io.fileno = i; /* for tape reads, this is the file no. */
- io.nblks = 0;
- io.flag = 0; /* we want to turn off IFN and EOF bits */
- io.am = 0;
- bugdskrd(&io);
-}
-
-__main()
-{
-}
+++ /dev/null
-#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)
-
-main(int argc, char **argv)
-{
- struct vid *pvid;
- struct cfg *pcfg;
- struct stat stat;
- int exe_file;
- int tape_vid;
- int tape_exe;
- unsigned int exe_addr;
- unsigned short exe_addr_u;
- unsigned short exe_addr_l;
- char *filename;
- char fileext[256];
-
- 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);
-
- pvid = (struct vid *) malloc(sizeof (struct vid));
-
- memset(pvid,0,sizeof(struct vid));
-
- strcpy(pvid->vid_id, "NBSD");
-
- fstat (exe_file,&stat);
- /* size in 512 byte blocks round up after a.out header removed */
- /* Actually, blocks == 256 bytes */
-
- pvid->vid_oss = 1;
- pvid->vid_osl = (short)sec2blk((stat.st_size - 0x20 + 511) / 512);
-
- lseek(exe_file,0x14,SEEK_SET);
- read(exe_file,&exe_addr,4);
- {
- union {
- struct {
- short osa_u;
- short osa_l;
- } osa_u_l;
- int osa;
- } u;
- u.osa = exe_addr;
- pvid->vid_osa_u = u.osa_u_l.osa_u;
- pvid->vid_osa_l = u.osa_u_l.osa_l;
- }
- pvid->vid_cas = 1;
- pvid->vid_cal = 1;
- /* do not want to write past end of structure, not null terminated */
- strcpy(pvid->vid_mot,"MOTOROL");
- pvid->vid_mot[7] = 'A';
-
- write(tape_vid,pvid,sizeof(struct vid));
-
- free(pvid);
-
- pcfg = (struct cfg *) malloc (sizeof(struct cfg));
-
- memset(pcfg,0,sizeof(struct cfg));
-
- pcfg->cfg_rec = 0x100;
- pcfg->cfg_psm = 0x200;
-
- write(tape_vid,pcfg,sizeof(struct cfg));
-
- free(pcfg);
-
- copy_exe(exe_file,tape_exe);
- close (exe_file);
- close (tape_vid);
- close (tape_exe);
-}
-
-#define BUF_SIZ 512
-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);
-}
+++ /dev/null
-STRIP_AOUT_HDR=rmaouthdr
-all: bootst.bug
-STRIP=-s
-SRCS=bootst.c
-S=${.CURDIR}/../../../..
-
-CFLAGS+=-I${.CURDIR}/../../include -I${.CURDIR}/${MACHINE_ARCH}
-
-.include "${S}/arch/${MACHINE}/stand/libbug/Makefile.inc"
-.include "${S}/arch/${MACHINE}/stand/bugcrt/Makefile.inc"
-.include "${S}/lib/libsa/Makefile.inc"
-.include "${S}/lib/libc_sa/Makefile.inc"
-.include "${S}/lib/libkern/Makefile.inc"
-
-LDADD+=${LIBBUG} ${SA_LIB} ${C_SA_LIB} ${KERNLIB}
-
-bootst.bug: bootst.o ${LDADD} ${BUGCRT}
- ${LD} ${STRIP} -N -T 0x3F0000 ${BUGCRT} bootst.o ${LDADD} -o bootst.bug
- ${.CURDIR}/../wrtvid/wrtvid bootst.bug
-
-clean:
- rm -f a.out *.core
- rm -f bootst.o bootst.bug stboot bootst
-
-install:
- install -c -m 555 -g bin -o bin bootst stboot /usr/mdec/
-
-.include <bsd.prog.mk>
+++ /dev/null
-#include "bug.h"
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/reboot.h>
-#include <sys/exec.h>
-/*
-#include <sys/exec_aout.h>
-*/
-
-#define KERNEL_LOAD_ADDRESS ((void *)0x4000)
-#define BUG_BLOCK_SIZE 512
-#define VERSION 0x0000
-
-#define RB_NOSYM 0x400
-
-
-
-void memset(void *,char,size_t);
-void printf(char *,...);
-void parse_args(struct bugargs *pbugargs);
-int read_tape_block(short ctrl, short dev, short *status, void *addr,
- int *cnt, int blk_num, unsigned char *flags,int verbose);
-int load_kern();
-
-struct kernel {
- void *entry;
- void *symtab;
- void *esym;
- int bflags;
- int bdev;
- char *kname;
- void *smini;
- void *emini;
- u_int end_loaded;
-} kernel;
-
-typedef (* kernel_entry)(struct bugargs *,struct kernel *);
-
-void main(struct bugargs *pbugargs)
-{
- kernel_entry addr;
-
- /*
- print_bugargs(pbugargs);
- print_time();
- print_brdid();
- print_memory();
- */
- parse_args(pbugargs);
- if (1 == load_kern(pbugargs)) {
- printf("unsuccessful in loading kernel\n\r");
- } else {
- addr = kernel.entry;
- printf("kernel loaded at %x\n\r",addr);
- printf("kernel.entry %x\n\r",kernel.entry);
- printf("kernel.symtab %x\n\r",kernel.symtab);
- printf("kernel.esym %x\n\r",kernel.esym);
- printf("kernel.bflags %x\n\r",kernel.bflags);
- printf("kernel.bdev %x\n\r",kernel.bdev);
- if (kernel.kname) {
- printf("kernel.kname <%s>\n\r",kernel.kname);
- } else {
- printf("kernel.kname <null>\n\r");
- }
- printf("kernel.end_loaded %x\n\r",kernel.end_loaded);
- if (kernel.bflags & RB_MINIROOT) {
- loadmini(kernel.end_loaded,pbugargs);
- }
- printf("kernel.smini %x\n\r",kernel.smini);
- printf("kernel.emini %x\n\r",kernel.emini);
- printf("kernel.end_loaded %x\n\r",kernel.end_loaded);
- if (*pbugargs->arg_start == 'e')
- bug_return();
- (addr)(pbugargs,&kernel);
- }
-
- return;
-}
-int
-read_tape_block(short ctrl, short dev, short *status, void *addr,
- int *cnt, int blk_num, unsigned char *flags,int verbose)
-{
- struct bug_dskio dio;
- int ret;
-
- dio.ctrl_lun = ctrl;
- dio.dev_lun = dev;
- dio.status = *status;
- dio.pbuffer = addr;
- dio.blk_num = blk_num;
- dio.blk_cnt = *cnt * 2;
- dio.flag = *flags;
- dio.addr_mod = 0;
-
- if (verbose){
- printf("saddr %x eaddr %x", dio.pbuffer,
- (int)dio.pbuffer + (dio.blk_cnt * BUG_BLOCK_SIZE/2 ));
- }
-
- ret = bug_diskrd(&dio);
-
- *status = dio.status;
- *cnt = dio.blk_cnt/2;
- if (verbose) {
- printf("status %x ret %d ",*status, ret);
- printf("flags %x\n\r",*flags);
- }
- return ret;
-}
-int load_kern(struct bugargs *pbugargs)
-{
- int ret;
- char *addr;
- unsigned char flags;
- short status = 0;
- int verbose = 0;
- int blk_num;
- struct exec *pexec;
- int magic;
- int *esym;
- int *symtab;
- int cnt, len;
-
- blk_num = 0;
- flags = IGNORE_FILENUM ;
- cnt = 512 / BUG_BLOCK_SIZE;
- addr = KERNEL_LOAD_ADDRESS;
- ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr,
- &cnt, blk_num, &flags, verbose);
- if (ret != 0) {
- printf("unable to load kernel\n\r");
- return 1;
- }
- pexec = (struct exec *) addr;
- if ((N_GETMID(*pexec) != MID_M68K) &&
- ( N_GETMID(*pexec) != MID_M68K4K ))
- {
- printf("invalid mid on kernel\n\r");
- return 1;
- }
- {
- short *pversion = (void *)0x4020;
- if (VERSION != *pversion) {
- printf("invalid version of kernel/loader\n\r");
- bug_return();
- }
- }
- magic = N_GETMAGIC(*pexec);
- switch (magic) {
- case ZMAGIC:
- break;
- case NMAGIC:
- printf ("NMAGIC not yet supported");
- case OMAGIC:
- case QMAGIC:
- default:
- printf("Unknown or unsupported magic type <%x>\n\r",
- magic);
- return 1;
- break;
- }
- if ( magic == ZMAGIC ) {
-
- status = 0;
- /* 2nd block of exe */
- addr += 512;
-
- if ((int)pexec->a_entry != (int)KERNEL_LOAD_ADDRESS + 0x22) {
- printf ("warning kernel start address not %x, %x\n\r",
- (int)KERNEL_LOAD_ADDRESS + 0x22,pexec->a_entry);
- printf ("kernel loaded at %x\n\r",KERNEL_LOAD_ADDRESS);
-
- }
- printf ("text 0x%x data 0x%x bss 0x%x\n\r",
- pexec->a_text, pexec->a_data, pexec->a_bss);
-
- len = (pexec->a_text - 512) ; /* XXX */
- len += (pexec->a_data );
-
- printf ("loading [ %x + %x ",pexec->a_text,pexec->a_data);
-
- cnt = (len + BUG_BLOCK_SIZE -1)/ BUG_BLOCK_SIZE;
- flags = IGNORE_FILENUM ;
- ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr,
- &cnt, blk_num, &flags, verbose);
- if (ret != 0 || cnt != (len + BUG_BLOCK_SIZE -1)/ BUG_BLOCK_SIZE) {
- printf("unable to load kernel\n\r");
- return 1;
- }
- addr += len;
-
- /* Skip over text and data and zero bss. */
- len = pexec->a_bss;
- printf ("+ %x",len);
- memset (KERNEL_LOAD_ADDRESS + (pexec->a_text + pexec->a_data),
- 0, pexec->a_bss);
- addr +=len;
-
- if (pexec->a_syms != 0 && !(kernel.bflags & RB_NOSYM)) {
- printf (" + [ %x",pexec->a_syms);
- /* align addr */
-#if 0
-#define ALIGN_F 0x200
- addr = (void *)((((int)addr + ALIGN_F -1)/ALIGN_F) * ALIGN_F);
-#endif
- addr += 4; /* skip over _end symbol */
- symtab = (void *)pexec->a_syms;
- len = pexec->a_syms;
- cnt = (len+(BUG_BLOCK_SIZE-1)) / BUG_BLOCK_SIZE;
- flags = IGNORE_FILENUM ;
- ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr,
- &cnt, blk_num, &flags, verbose);
- if (ret != 0 || cnt != (len+(BUG_BLOCK_SIZE-1)) / BUG_BLOCK_SIZE)
- {
- printf("unable to load kernel\n\r");
- return 1;
- }
-
- /* this value should have already been loaded XXX */
- esym = (void *) ((u_int)addr + pexec->a_syms);
- if ((int)addr +(cnt * BUG_BLOCK_SIZE) <= (int) esym) {
- printf("missed loading count of symbols\n\r");
- return 1;
- }
- addr +=cnt * BUG_BLOCK_SIZE;
-
-
- len = *esym;
-#if 0
- printf("start load %x end load %x %x\n\r", addr,
- len, addr +len);
- printf("esym %x *esym %x\n\r",esym, len);
-#endif
- /* dont load tail of already loaded */
- len -= (u_int)addr - (u_int)esym;
-
- if (len > 0) {
- printf(" + %x",*esym);
- esym = (void *)(addr + len);
- cnt = (len+(BUG_BLOCK_SIZE-1)) / BUG_BLOCK_SIZE;
- flags = IGNORE_FILENUM ;
- ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr,
- &cnt, blk_num, &flags, verbose);
- if (ret != 0 ||
- cnt != (len+(BUG_BLOCK_SIZE-1)) / BUG_BLOCK_SIZE)
- {
- printf("unable to load kernel\n\r");
- return 1;
- }
- addr += len;
- printf(" ]");
- } else {
- printf("+ %x ]",*esym);
- }
- esym = (int *)(((int)esym) + *esym);
-
- kernel.symtab = symtab;
- kernel.esym = esym;
- } else {
- kernel.symtab = 0;
- kernel.esym = 0;
- }
- kernel.end_loaded = (int)addr;
- flags = IGNORE_FILENUM | END_OF_FILE;
- cnt = 1000;
- printf ("removing pad [");
- ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr,
- &cnt, blk_num, &flags, verbose);
- if (ret != 0) {
- printf("unable to load kernel\n\r");
- return 1;
- }
- printf (" %d ]",cnt * BUG_BLOCK_SIZE);
-
- printf("]\n\r");
- }
-
-
- kernel.entry = (void *)pexec->a_entry;
- return 0;
-}
-loadmini(u_int addr,struct bugargs *pbugargs)
-{
- int ret;
- unsigned char flags;
- short status = 0;
- int verbose = 0;
- int blk_num;
- int cnt;
- blk_num = 3;
- /*
- flags = IGNORE_FILENUM | END_OF_FILE;
- */
- /* align addr to some boundary */
-#define ALIGN_F 0x4
- addr = (u_int)((((int)addr + ALIGN_F -1)/ALIGN_F) * ALIGN_F);
-#undef ALIGN_F
- flags = END_OF_FILE;
- cnt = 6144; /* some abserdly large value. (3meg / 512) */
- printf("loading miniroot[ ");
- ret = read_tape_block(4, pbugargs->dev_lun, &status, (void*)addr,
- &cnt, blk_num, &flags, verbose);
- if (ret != 0) {
- printf("unable to load miniroot\n\r");
- return 1;
- }
- kernel.smini = (void *)addr;
- printf("%d ]\n\r",(BUG_BLOCK_SIZE * cnt));
- kernel.emini = (void*)((u_int)addr + (BUG_BLOCK_SIZE * cnt));
- kernel.end_loaded = (u_int)kernel.emini;
-}
-void
-parse_args(struct bugargs *pargs)
-{
- char * ptr = pargs->arg_start;
- char c, *name;
- int howto;
- howto = ( 0 | RB_DFLTROOT );
- name = NULL;
-
- if (pargs->arg_start != pargs->arg_end) {
- while (c = *ptr) {
- while (c == ' ')
- c = *++ptr;
- if (!c)
- return;
- if (c == '-')
- while ((c = *++ptr) && c != ' ') {
- if (c == 'a')
- howto |= RB_ASKNAME;
- else if (c == 'b')
- howto |= RB_HALT;
- else if (c == 'y')
- howto |= RB_NOSYM;
-#ifdef CHECKSUM
- else if (c == 'c')
- cflag = 1;
-#endif
- else if (c == 'd')
- howto |= RB_KDB;
- else if (c == 'm')
- howto |= RB_MINIROOT;
- else if (c == 'r')
-/* change logic to have force root to config device UNLESS arg given */
- howto &= ~RB_DFLTROOT;
- else if (c == 's')
- howto |= RB_SINGLE;
- }
- else {
- name = ptr;
- while ((c = *++ptr) && c != ' ');
- if (c)
- *ptr++ = 0;
- }
- }
- if (RB_NOSYM & howto) printf("RB_NOSYM\n\r");
- if (RB_AUTOBOOT & howto) printf("RB_AUTOBOOT\n\r");
- if (RB_SINGLE & howto) printf("RB_SINGLE\n\r");
- if (RB_NOSYNC & howto) printf("RB_NOSYNC\n\r");
- if (RB_HALT & howto) printf("RB_HALT\n\r");
- if (RB_DFLTROOT & howto) printf("RB_DFLTROOT\n\r");
- if (RB_KDB & howto) printf("RB_KDB\n\r");
- if (RB_RDONLY & howto) printf("RB_RDONLY\n\r");
- if (RB_DUMP & howto) printf("RB_DUMP\n\r");
- if (RB_MINIROOT & howto) printf("RB_MINIROOT\n\r");
-
- }
- kernel.bflags = howto;
- kernel.kname = name;
-}
-
+++ /dev/null
-OBJ=bugcrt.o
-CFLAGS+=-I${.CURDIR}/../include
-CFLAGS+=-I${.CURDIR}/../..
-CFLAGS+=-I/usr/src/sys
-CFLAGS+=-fwritable-strings
-
-SRCS=bugcrt.c
-all: bugcrt.o
-
-.include <bsd.prog.mk>
+++ /dev/null
-#include "bug.h"
-
-asm (" text");
-/*asm ("_stack: word _stack0xFC0000; stack");*/
-asm ("stack: word stack");
-asm (" word _start");
-asm (" align 8");
-
-struct bugenv bugenv;
-extern char *end, *edata;
-
-start()
-{
- register int dlun asm("r2");
- register int clun asm("r3");
- register int ipl asm("r4");
- register int (*entryptr)() asm("r6");
- register int *cfg asm("r7");
- register char *strstr asm("r8");
- register char *endstr asm("r9");
- int i;
- char *str;
-
-asm ("; enable SFU1");
-asm (" ldcr r10,cr1");
-asm (" xor r10,r10,0x8");
-asm (" stcr r10,cr1");
-
- bugenv.clun = clun;
- bugenv.dlun = dlun;
- bugenv.ipl = ipl;
- bugenv.entry= entryptr;
-
- bzero(&edata,((char *)&end - (char *)&edata));
- for (str = strstr, i = 0; str <= strstr; str++, i++) {
- bugenv.bootargs[i] = *str;
- }
- bugenv.bootargs[i] = 0;
-
- main(&bugenv);
- bugreturn();
-}
+++ /dev/null
-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>
+++ /dev/null
-#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;
-}
+++ /dev/null
-#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);
-}
+++ /dev/null
-struct bugenv {
- int clun;
- int dlun;
- int ipl;
- int (*entry)();
- char bootargs[256];
-};
-
+++ /dev/null
-#include "sys/cdefs.h"
-
-struct bugdisk_io {
- char clun;
- char dlun;
- short status;
- void *addr;
- int blkno;
-#define fileno blkno
- short nblks;
- char flag;
-#define FILEMARKFLAG 0x80
-#define IGNOREFILENO 0x02
-#define ENDOFFILE 0x01
- char am;
-};
-
-/* values are in BCD {upper nibble+lower nibble} */
-
-struct bugrtc {
- unsigned char Y;
- unsigned char M;
- unsigned char D;
- unsigned char d;
- unsigned char H;
- unsigned char m;
- unsigned char s;
- unsigned char c;
-};
-
-/* Board ID - lots of info */
-
-struct bugbrdid {
- unsigned char eye[4];
- char rev;
- char month;
- char day;
- char year;
- short packetsize;
- short dummy;
- short brdno;
- unsigned char brdsuf[2];
- char options[3];
- char family:4;
- char cpu:4;
- short clun;
- short dlun;
- short type;
- short dev;
- int option;
-};
-
-char buginchr __P((void));
-int buginstat __P((void));
-int bugoutchr __P((unsigned char));
-int bugoutstr __P((char *, char *));
-int bugpcrlf __P((void));
-int bugdskrd __P((struct bugdisk_io *));
-int bugdskwr __P((struct bugdisk_io *));
-int bugrtcrd __P((struct bugrtc *));
-int bugreturn __P((void));
-int bugbrdid __P((struct bugbrdid *));
+++ /dev/null
-# $Id: Makefile,v 1.1.1.1 1997/03/03 19:30:46 rahnds Exp $
-
-CFLAGS+=-I${.CURDIR}/../include -I${.CURDIR}/${MACHINE_ARCH}
-
-.PATH: ${.CURDIR}/${MACHINE_ARCH}
-
-SRCS= kerncrt.c
-
-OBJS=${SRCS:.c=.o}
-
-all: ${OBJS}
-
-kerncrt.o: ${SRCS}
- ${CC} ${CFLAGS} -c -O ${.ALLSRC}
- ${LD} -x -r ${.TARGET}
- mv a.out ${.TARGET}
-
-install:
-
-lint tags:
-
-.include <bsd.prog.mk>
+++ /dev/null
-#include "bug.h"
-start(struct bugenv *bugarea)
-{
- main(bugarea);
- bugreturn();
-}
-
-__main()
-{
- return;
-}
+++ /dev/null
-#include "bugargs.h"
-#define volatile
-int _DYNAMIC;
-start(struct bugargs *bugarea)
-{
- main(bugarea);
- bug_return();
- /* NOTREACHED */
-}
+++ /dev/null
-LIB=bug
-
-CFLAGS+=-I${.CURDIR}/../include
-CFLAGS+=-I${.CURDIR}/../../include
-CFLAGS+=-I${.CURDIR}/../..
-CFLAGS+=-I/usr/src/sys
-CFLAGS+=-fwritable-strings
-
-NOPIC=
-
-SRCS+=bug.c
-#SRCS+=bugcrt.c bugio.c main.c
-
-.if (${MACHINE_ARCH} == "m68k")
-SRCS+=mvme147.c bcopy.c bzero.c
-.endif
-.if (${MACHINE_ARCH} == "m88k")
-SRCS+=bcopy.c bzero.c printf.c bugsupp.c
-.endif
-
-.PATH: ${.CURDIR}/../../../../lib/libkern ${.CURDIR}/../../../../lib/libsa ${.CURDIR}/${MACHINE_ARCH}
-
-all: bugio.o
-
-#bugio.o: bugio.c
-# ${CC} ${CFLAGS} -c -O ${.ALLSRC}
-# ${LD} -x -r ${.TARGET}
-# mv a.out ${.TARGET}
-
-.include <bsd.lib.mk>
+++ /dev/null
-/*
- * bug routines -- assumes that the necessary sections of memory
- * are preserved.
- */
-#include "bug.h"
-
-#define _INCHR "00"
-#define _INSTAT "01"
-#define _INLN "02"
-#define _READSTR "03"
-#define _READLN "04"
-#define _DSKRD "16"
-#define _DSKWR "17"
-#define _DSKCFIG "18"
-#define _DSKFMT "20"
-#define _DSKCTRL "12"
-#define _OUTCHR "32"
-#define _OUTSTR "33"
-#define _OUTLN "34"
-#define _WRITE "35"
-#define _WRITELN "36"
-#define _DELAY "67"
-#define _RTC_RD "83"
-#define _RETURN "99"
-#define _BRD_ID "112"
-
-/* BUG - tty routines */
-
-#define BUG_CALL(x) \
- asm volatile ("or r9,r0," x); \
- asm volatile ("tb0 0,r0,496");
-
-char bug_inchr()
-{
- register char a;
- asm volatile ("sub r31,r31,4");
- BUG_CALL(_INCHR);
- asm volatile ("or %0,r0,r2" : "=r" (a));
- return a;
-}
-
-/* returns 0 if no characters ready to read */
-int bug_instat()
-{
- short ret;
- BUG_CALL(_INSTAT);
- asm volatile ("or %0,r0,r2" : "=r" (ret));
- return (!(ret & 0x4));
-
-}
-
-void bug_outchr(char a)
-{
- asm volatile ("or r2, r0, %0" : :"r" (a));
- BUG_CALL(_OUTCHR);
- return;
-}
-
-void bug_outstr(char *pstrb, char *pstre)
-{
- asm volatile ("or r2,r0,%0": : "r" (pstrb) );
- asm volatile ("or r3,r0,%0": : "r" (pstre) );
- BUG_CALL(_OUTSTR);
- return;
-}
-
-void bug_outln(char *pstrb, char *pstre)
-{
- asm volatile ("or r2,r0,%0": : "r" (pstrb) );
- asm volatile ("or r3,r0,%0": : "r" (pstre) );
- BUG_CALL(_OUTLN);
- return;
-}
-
-/* BUG - disk routines */
-
-/* returns 0: success, nonzero: error */
-int bug_diskrd(bug_dskio *arg)
-{
- int ret;
- asm volatile ("or r2,r0,%0": : "r" (arg) );
- BUG_CALL(_DSKRD);
- return (!(ret & 0x4));
-}
-/* returns 0: success, nonzero: error */
-int bug_diskwr(bug_dskio *arg)
-{
- int ret;
- asm volatile ("or r2,r0,%0": : "r" (arg) );
- BUG_CALL(_DSKWR);
- return (!(ret & 0x4));
-}
-#ifdef NOTYET
-bug_diskcfig()
-{
-
-}
-bug_diskfmt(){}
-bug_diskctrl(){}
-#endif
-
-/* BUG - timing routine */
-
-void bug_delay(int delay_msec)
-{
- asm volatile ("or r2,r0,%0": : "r" (delay_msec) );
- BUG_CALL(_DELAY);
- return ;
-}
-
-/* BUG - return to bug routine */
-
-void bug_return()
-{
- BUG_CALL(_RETURN);
- /*NOTREACHED*/
-}
-
-/* BUG - query board routines */
-
-struct bug_brdid *bug_brdid()
-{
- struct bug_brdid *pbrd_id;
- BUG_CALL(_BRD_ID);
- asm volatile ("or %0,r0,r2": "=r" (pbrd_id):);
- return pbrd_id;
-}
-void bug_rtc_rd(struct bug_time *ptime)
-{
- asm volatile ("or r2,r0,%0": : "r" (ptime));
- BUG_CALL(_RTC_RD);
- return;
-}
+++ /dev/null
-#include "bugio.h"
-
-#define INCHR "0x0000"
-#define INSTAT "0x0001"
-#define INLN "0x0002"
-#define READSTR "0x0003"
-#define READLN "0x0004"
-#define DSKRD "0x0010"
-#define DSKWR "0x0011"
-#define DSKCFIG "0x0012"
-#define OUTCHR "0x0020"
-#define PCRLF "0x0026"
-#define TMDISP "0x0042"
-#define DELAY "0x0043"
-#define RTC_DSP "0x0052"
-#define RTC_RD "0x0053"
-#define RETURN "0x0063"
-#define BRD_ID "0x0070"
-#define BUGTRAP "0x01F0"
-
-char
-buginchr(void)
-{
- register int cc asm("r2");
- asm("or r9,r0," INCHR);
- asm("tb0 0,r0,0x1F0");
- /*asm("or %0,r0,r2" : "=r" (cc) : );*/
- return ((char)cc & 0xFF);
-}
-
-/* return 1 if not empty else 0 */
-
-buginstat(void)
-{
- int ret;
- asm("or r9,r0," INSTAT);
- asm("tb0 0,r0,0x1F0");
- asm("or %0,r0,r2" : "=r" (ret) : );
- return (ret & 0x40 ? 1 : 0);
-}
-
-bugoutchr(unsigned char c)
-{
- unsigned char cc;
-
- if ((cc = c) == '\n') {
- bugpcrlf();
- return;
- }
- asm("or r2,r0,%0" : : "r" (cc));
- asm("or r9,r0," OUTCHR);
- asm("tb0 0,r0,0x1F0");
-}
-
-bugpcrlf(void)
-{
- asm("or r9,r0," PCRLF);
- asm("tb0 0,r0,0x1F0");
-}
-/* return 0 on success */
-
-bugdskrd(struct bugdisk_io *arg)
-{
- int ret;
- asm("or r9,r0, " DSKRD);
- asm("tb0 0,r0,0x1F0");
- asm("or %0,r0,r2" : "=r" (ret) : );
- return ((ret&0x4) == 0x4 ? 1 : 0);
-}
-
-/* return 0 on success */
-
-bugdskwr(struct bugdisk_io *arg)
-{
- int ret;
- asm("or r9,r0, " DSKWR);
- asm("tb0 0,r0,0x1F0");
- asm("or %0,r0,r2" : "=r" (ret) : );
- return ((ret&0x4) == 0x4 ? 1 : 0);
-}
-
-bugrtcrd(struct bugrtc *rtc)
-{
- asm("or r9,r0, " RTC_RD);
- asm("tb0 0,r0,0x1F0");
-}
-
-bugreturn(void)
-{
- asm("or r9,r0, " RETURN);
- asm("tb0 0,r0,0x1F0");
-}
-
-bugbrdid(struct bugbrdid *id)
-{
- struct bugbrdid *ptr;
- asm("or r9,r0, " BRD_ID);
- asm("tb0 0,r0,0x1F0");
- asm("or %0,r0,r2" : "=r" (ptr) : );
- bcopy(ptr, id, sizeof(struct bugbrdid));
-}
+++ /dev/null
-#include "bug.h"
-
-int putchar(char a)
-{
- bug_outchr(a);
-}
-__main(){}