#include "boot.h" int (*sread)() = 0; extern fail(); boot () { struct block0 d; register c, s, h, n; char *a; int (*f)(); init (); /* * read block 0 */ d.ncyl = d.nhead = d.nsect = 1; if ((*sread) (0, 0, 0, &d)) fail (); n = d.bootcount; c = d.bootcyl; s = d.bootsect; h = d.boothead; a = LOADADDR; while (n--) { if ((*sread) (c, h, s, a)) fail (); a += d.bps; if (++s >= d.nsect) { s = 0; /* new head */ if (++h >= d.nhead) { h = 0; /* new cylinder */ if (++c >= d.ncyl) { c = 0; /* wrap around */ } } } } /* * Loading completed * Jump into code. */ f = LOADADDR; (*f)(); } /* * init - initialization * * Init must set sread to either djread or mwread * Don't worry about the serial I/O, it will be set for us. */ init () { if (floppy ()) sread = djread; else sread = mwread; } floppy () { char c; if (djopen () < 0) return NO; prs ("Boot from the floppy?"); c = getchar (); putchar (c); /* echo */ c = tolower (c); } tolower (c) char c; { if ('A' <= c && c <= 'Z') c += ('a' - 'A'); return c; }