Automated installs (very long)

Louis Mandelstam lma at
Thu Oct 9 08:57:57 GMT 1997

On Wed, 8 Oct 1997, Jason Gerrity wrote:

> >
> >1. Installer sets BIOS to boot A:,C: (we usually keep it C:,A: - with the
> >   BIOS setup protected from casual meddling by a password)
> Haha Oops Now that I've reread this yet again, I realize that by Installer
> you mean the person doing the install.  Dooh!  I had originally thought you
> some how got the CMOS to automatically swithc the boot sequence... Kinda
> funny when you think about it..

Well, you had half the right idea.

1. I need to manually set A:,C: if I'm going to use the install boot

2. The install script automagically sets it back to C:,A: but stroking
   some bits in the CMOS RAM.  Now, it's important that you realize that
   this is a rather motherboard/BIOS-specific thing.

   I checked that all the machines that needed to be supported by this
   system have Award BIOSes, either version 4.50PG or 4.51PG.  The
   motherboards are all ASUS, but different models.

   Tests I did on each model showed that different values are used in the
   CMOS to indicate C:,A: vs A:,C: but I did find that in all cases here,
   setting bit 1 would take it from A:,C: to C:,A:

   The code that does this is included below.  I recommend you check the
   details of how your BIOSes store this info and modify the program
   appropriately if needed.  It may be kept at a different offset.  It may
   be a completely different method and the only thing you can use is the
   concept.  I'd be interested to know your results (which BIOSes etc)

   In any event, I'd backup the CMOS of you test machine before playing,
   if I were you.

   This was my first C program *ever*, please be kind ;-)   :

/* setcmos.c */

/* v1.20 (97/09/29 - lma)
   Note: this needs to be compiled with gcc's optimization enabled for the
   inline macro code to be compiled in.  i.e. :
   gcc setcmos.c -O -s setcmos

#include <unistd.h>
#include <stdio.h>
#include <asm/io.h>
static unsigned short cmos_ctl_addr = 0x70;
static unsigned short cmos_data_addr = 0x71;
static unsigned short cmos_drvseq_reg = 0x3c;

static inline unsigned char 
cmos_read(unsigned char reg) {
  register unsigned char ret;
  __asm__ volatile ("cli");
  /* & 0x7f ensures that we are not disabling NMI while we read.
     Setting on Bit 7 here would disable NMI
  outb(reg & 0x7f, cmos_ctl_addr);
  ret = inb(cmos_data_addr);
  __asm__ volatile ("sti");
  return ret;

static inline void
cmos_write(unsigned char reg, unsigned char val) {
  outb(reg & 0x7f, cmos_ctl_addr);
  outb(val, cmos_data_addr);

main() {
if (iopl(3) != 0 ) {
  fprintf(stderr,"setcmos needs to be run as root.\n");
 else {
  /* Set bit 1 in CMOS register 0x3C to set BIOS to boot C:,A: */
  cmos_write(cmos_drvseq_reg, cmos_read(cmos_drvseq_reg) | 1);
  printf("CMOS set to boot C:,A:\n");


Louis Mandelstam              Tel +27 83 227-0712   Symphony  /|\   /|\
Linux systems integration       Research {   } {   }
Johannesburg, South Africa    mailto:louis at (Pty)Ltd {___} {___}

More information about the samba mailing list