[syslinux] COM32 BIOS Question

ganapathy murali krishnan gmurali at cs.uchicago.edu
Thu Apr 24 17:09:04 PDT 2003


This may be more of a BIOS question, but this is related to some COM32 
code I am trying to write. First of all, the COM32 stuff is great.

I am trying to read sectors 6 thru 9 from /dev/hda into a buffer,
and this is the code I have written. For some reason, it seems to be
reading something completely different (as confirmed by reading using
"dd if=/dev/hda of=file bs=512 count=1 skip=6").

The checkstatus function says there was no problem executing the system 
call. Is there is any nice way to debug COM32 code?

NUM_SECT=4, SECT_START=6 and BUFSIZE=512*NUM_SECT.

-- code snippet --
   /* From Ralph Browns Interrupt List:
      AH = 02h
      AL = number of sectors to read (must be nonzero)
      CH = low eight bits of cylinder number
      CL = sector number 1-63 (bits 0-5)
      high two bits of cylinder (bits 6-7, hard disk only)
      DH = head number
      DL = drive number (bit 7 set for hard disk)
      ES:BX -> data buffer

      return: CF = 1 for error
              AH = status
   */
   memset(&inreg, 0, sizeof inreg);
   inreg.eax.b[0] = NUM_SECT;
   inreg.eax.b[1] = 0x02;
   inreg.ecx.b[0] = SECT_START;
   inreg.ecx.b[1] = 0x00;
   inreg.edx.b[0] = 0x80;
   inreg.edx.b[1] = 0x00;
   inreg.ebx.w[0] = OFFS(__com32.cs_bounce);
   inreg.es       = SEG(__com32.cs_bounce);
   /* ES:BX = cs_bounce */
   __com32.cs_syscall(0x13, &inreg, &outreg);

   /* Error handling here */
   if (outreg.eax.b[1] > 0) {
      print(badread,sizeof badread);
      //badread is the string "read error occurred. Code="
      printnum(outreg.eax.b[1]); //prints the number
      printchar('\r'); //prints the charecter
      printchar('\n');
   }

   /* Read data out from the low memory buffer*/
   memcpy(buffer,__com32.cs_bounce,BUFSIZE);

-- end of snippet ---



More information about the Syslinux mailing list