/* * rountines to interface between internal * and external notions of what the settings are */ # include "setup.h" # define HIGHBYTE 0xff00 /* * Micro Decision specific offsets */ # define BIOS 0xf200 # define REVISION (bios [0x3f]) /* REV byte */ /* * revision numbers */ # define MINIMUM 0x20 /* minimum acceptable rev. level */ # define MD11 0x40 # define RAMDATY 0x42 # define SET 0x52 /* * offsets from ramdaty */ # define CBAUDOFF (-6) # define PBAUDOFF (-5) # define OLDDFLAG (11) # define NEWDFLAG (0x12) /* * bits */ # define HARDBIT (1 << 4) # define CENTBIT (1 << 5) /* * stuff having to do with the revision number */ # define REVISION (bios [0x3f]) /* offset to REV byte */ # define MINIMUM 0x20 /* minimum acceptable rev. level */ static unsigned dflag = 0; /* * block attempts to use with old versions of the system */ version () { if (REVISION < MINIMUM) fatal ("Old version of CP/M\r\n$"); if (REVISION >= MD11) dflag = NEWDFLAG; else dflag = OLDDFLAG; } /* * determine the memory address of the BIOS * in memory */ findsys () { unsigned *i; i = 1; bios = *i & HIGHBYTE; i = bios + RAMDATY; ramdaty = *i; } /* * read the settings * always from the currently running bios */ readsettings () { cbaud = ramdaty [CBAUDOFF] % NBAUD; pbaud = ramdaty [PBAUDOFF] % NBAUD; if (ramdaty [dflag] & CENTBIT) ptype = CENTRONICS; else ptype = SERIAL; if (ramdaty [dflag] & HARDBIT) protocol = HARDHAND; else protocol = XONXOFF; } writesettings (a) unsigned char *a; { a [CBAUDOFF] = cbaud; a [PBAUDOFF] = pbaud; a [dflag] &= ~(CENTBIT | HARDBIT); if (protocol == HARDHAND) a [dflag] |= HARDBIT; if (ptype == CENTRONICS) a [dflag] |= CENTBIT; } softset () { writesettings (ramdaty); bioset (); /* call the bios to have appropriate settings made */ } hardset () { biosread (); writesettings (ramdaty + (unsigned) biosbuf - (unsigned) bios); bioswrite (); } sysinit () { findsys (); version (); }