problems using HD_TYPE to avoid using BIOS

problems using HD_TYPE to avoid using BIOS

Post by Daniel Aaron Supernaw-Iss » Sat, 17 Apr 1993 15:14:37

hey all.  This is yet another post requesting help on the same old saga
of getting my mfm and ide to coexist.   Numerous people sent me email
suggesting that I hard code my drives geometry using the HD_TYPE macro
defined in config.h and take my ide off my cmos.  This seems like a
resonable idea.  I tried this and found that the image I generated
still used the bios so I was hosed.  I confirmed that it was using the
bios by noticing the following:  When I originally booted up with the mfm
in and the ide not specified the system got a kernel panic telling me that
it couldn't mount root.  When I removed the mfm and left the rest alone, I
got the same error.  When I reset my cmos and put my ide back on it, the
kernel came up fine.  strange.  I could be using the HD_TYPE macro incorrectly.
oh, before I forget, yes I did comment out the line #undefing HD_TYPE.  My
ide disk has 8 heads, 33 sectors and 776 cylinders, the landing zone is 776.
My mfm *I THINK* has the following geometry: 4 heads, 17 sectors 615 cylinders,
wpcom 128 and a landing zone of 638.  <- I got these because the only
documentation on my mfm says that on a compaq (not that I have one) it should
be listed in the cmos as a type 2.  So I called compaq and asked about the
geometry of a type 2 disk.  I'm pretty hosed.  Any help is greatly appreciated.
I'm using the 0.99pl8 kernel.  Thanks in advance.

Daniel Supernaw-Issen

Linux or Die!


problems using HD_TYPE to avoid using BIOS

Post by John Paul Morris » Fri, 23 Apr 1993 05:46:12

I was wondering a bit about how the kernel checks the drive, and the
hardcoded HD_TYPE option seems interesting, at least for IDE drives
(maybe SCSI as well).

we upgraded drives by installing linux on a temporary machine, (to
leave the original system intact), then swapped the drive out. we lost
the CMOS along the way, and we needed to find the drive type. Luck had
it that someone has written a (DOS) program to sniff your IDE drive
for it's proper drive type. I wonder if this could be added to the
kernel. trhe program reports what the BIOS thinks the drive setting
are, and it reports what the drive says it is. Sometimes you set your
CMOS settings to something odd deliberately, because the drive remaps
itself (but IDE drives dont always do it well), but this is usually to
overcome some bogus limitation of DOS or the BIOS, which wouldnt be
needed with Linux. (I'm reasonably sure that this feature isnt already
in the kernel. if it is, then I'm quite impressed)

here is the DOS source (it's mostly output formating..this code would
take 10 lines or so of assembly)

** DUG_IDE : Provides IDE disk info on both drives in the system
**           Version 1.0
** Copyright (c) 12 Jan 1993 by Doug Merrett - All rights reserved
** Postal Address: PO Box 432
**                 Stones Corner  Q  4120
**                 Australia

** You may distribute freely, but no modifications without mailing me a copy.
** No profit can be made for distribution.  Blah Blah Blah etc.

/* Used by JPI for clrscr */
#define _JPI_WIN_

#include <stdlib.h>
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <bios.h>

char *getascii (unsigned int in_data [], int off_start, int off_end);

void main (void)
  unsigned int dd [256]; /* DiskData */
  unsigned int dd_off;   /* DiskData offset */
  unsigned int loop;     /* Loop variable */
  int num_drv;           /* Number of Hard disks */

  union REGS registers;  /* Used for Interrupt for BIOS data */

  unsigned int bios_cyl [2], bios_head [2], bios_sec [2];  /* Cylinders, Heads, Sectors */

  clrscr ();

  fprintf (stderr, "** DUG_IDE : Provides IDE disk info on both drives in the system\n");
  fprintf (stderr, "** Version 1.0\n");
  fprintf (stderr, "**\n");
  fprintf (stderr, "** Copyright (c) 12 Jan 1993 by Doug Merrett - All rights reserved\n");
  fprintf (stderr, "**\n");
  fprintf (stderr, "** Postal Address: PO Box 432\n");
  fprintf (stderr, "**                 Stones Corner  Q  4120\n");
  fprintf (stderr, "**                 Australia\n");
  fprintf (stderr, "**\n");

  fprintf (stderr, "**\n");
  fprintf (stderr, "** You may distribute freely, but no modifications without mailing me a copy.\n");
  fprintf (stderr, "** No profit can be made for distribution.  Blah Blah Blah etc.\n\n");
  fprintf (stderr, "Press any key to accept above limitations");
  getch ();

  /* How many disk drives & parameters */
  num_drv = peekb (0x40, 0x75);  /* BIOS Data area, Number of Hard disks */
                                 /* Byte at Segment 40H Offset 75H */

  for (loop = 0; loop < num_drv; loop++)  /* Loop through drives */
      /* Get IDE Drive info */

      while (inp (0x1F7) != 0x50)  /* Wait for controller not busy */

      outp (0x1F6, (loop == 0 ? 0xA0 : 0xB0)); /* Get first/second drive */

      outp (0x1F7, 0xEC);          /* Get drive info data */

      while (inp (0x1F7) != 0x58)  /* Wait for data ready */

      for (dd_off = 0; dd_off != 256; dd_off++) /* Read "sector" */
        dd [dd_off] = inpw (0x1F0);

      /* Get BIOS drive info */
      registers.h.ah = 0x8;            /* Get drive info */
      registers.h.dl = 0x80 + loop;    /* Drive is 80H for Disk 0, 81H for Disk 1 */
      int86 (0x13, &registers, &registers);
      if (! registers.x.cflag)   /* All OK if carry not set */
          bios_head [loop] = registers.h.dh + 1; /* Heads are from 0 */
          bios_sec [loop] = & 0x3F; /* sec is bits 5 - 0 */
          bios_cyl [loop] = (( & 0xC0) << 2) + + 2; /* +1 because starts from 0 and +1 for FDISK leaving one out */

      clrscr ();

      fprintf (stdout, "DRIVE %d:\n", loop);
      fprintf (stdout, "Model Number______________________: %s\n", getascii (dd, 27, 46));
      fprintf (stdout, "Serial Number_____________________: %s\n", getascii (dd, 10, 19));
      fprintf (stdout, "Controller Revision Number________: %s\n\n", getascii (dd, 23, 26));
      fprintf (stdout, "Able to do Double Word Transfer___: %6s\n", (dd [48] == 0 ? "No" : "Yes"));
      fprintf (stdout, "Controller type___________________:   %04X\n", dd [20]);
      fprintf (stdout, "Controller buffer size (bytes)____: %6u\n", dd [21] * 512);
      fprintf (stdout, "Number of ECC bytes transferred___: %6u\n", dd [22]);
      fprintf (stdout, "Number of sectors per interrupt___: %6u\n\n", dd [47]);
      fprintf (stdout, "Hard Disk Reports\n");
      fprintf (stdout, "Number of Cylinders (Fixed)_______: %6u\n", dd [1]);
      fprintf (stdout, "Number of Heads___________________: %6u\n", dd [3]);
      fprintf (stdout, "Number of Sectors per Track_______: %6u\n\n", dd [6]);
      fprintf (stdout, "BIOS Reports\n");
      fprintf (stdout, "Number of Cylinders_______________: %6u\n", bios_cyl [loop]);
      fprintf (stdout, "Number of Heads___________________: %6u\n", bios_head [loop]);
      fprintf (stdout, "Number of Sectors per Track_______: %6u\n\n", bios_sec [loop]);

      if (! loop)
          fprintf (stdout, "Press a key");
          getch ();


char *getascii (unsigned int in_data [], int off_start, int off_end)
  static char ret_val [255];
  int loop, loop1;

  for (loop = off_start, loop1 = 0; loop <= off_end; loop++)
      ret_val [loop1++] = (char) (in_data [loop] / 256);  /* Get High byte */
      ret_val [loop1++] = (char) (in_data [loop] % 256);  /* Get Low byte */
  ret_val [loop1] = '\0';  /* Make sure it ends in a NULL character */
  return (ret_val);



 John Paul Morrison                     |
 University of British Columbia, Canada | Hey hey!! Ho ho!!
 Electrical Engineering                 | Tax & spend liberals



1. How to avoid X configuration when using Jumpstart (x86)?

All right, so I've managed to pretty much get everything hands-off
with regards to a jumpstart install, down to one last problem. When
the system I'm installing reboots at the end of the install, it always
reboots into kdmconfig, forcing me to hit F4 (Well, Esc-4 actually) to
get it to continue. (Note: This is NOT the "Warning, your x
configuration may not be correct!" message that only stays for 30
seconds. This is also NOT the configuration assistant.)

I'm figuring there must be a file somewhere that either gets touched a
la /reconfigure, or there's a file somewhere that gets created, that
tells kdmconfig to execute on boot. I'm guessing the former because I
never have to actually go through the config, just F4 out of the first
screen and I never see it again.These are headless stations, so I
don't care if X works or not. Anyone have any idea?

The other small annoyance is I try to use dtconfig to shut off desktop
login in the finish script (i.e. /a/usr/dt/bin/dtconfig -d) but it
doesn't 'stick' -- My guess is it tries to create a file and does so,
but doesn't create it under /a, so when he reboots and root is mounted
in the proper place the file's not there. No big deal, but thought I'd
comment in case anyone knows that one.

2. REQ: X-based thumbnail viewer/manager apps?

3. How can I avoid my process being killed while using as much memory as I can.

4. hardware trouble!

5. How to avoid changes the file date when using cp (edi)

6. ? Setup sol7 Sparc remot print to NT Print server

7. How can I avoid using temp files in Korn Shell?

8. rsh + rlogin without password (.rhosts) -> NOT WORKING

9. Using RPCs: How to avoid deadlocks with FRPCs?

10. Using EXPORT_SYMBOL() while avoiding versioning stuff...

11. Avoid large reads using parport_read() ?

12. How to avoid code bloat when using STL map templates

13. PATCH - avoid 'defined but not used' warning in xor.h on i386