Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


*** empty log message ***
[palacios.git] / palacios / src / vmboot / rombios / rombios.c
index 697180c..0b9f3da 100644 (file)
@@ -1,6 +1,6 @@
 //  -*- fundamental -*-
 /////////////////////////////////////////////////////////////////////////
-// $Id: rombios.c,v 1.4 2008/05/11 23:26:05 pdinda Exp $
+// $Id: rombios.c,v 1.11 2008/07/07 23:56:54 pdinda Exp $
 /////////////////////////////////////////////////////////////////////////
 //
 //  Copyright (C) 2002  MandrakeSoft S.A.
 
 #define DEBUG_ROMBIOS      1
 
-#define DEBUG_ATA          1
+#define DEBUG_ATA          0
 #define DEBUG_INT13_HD     0
 #define DEBUG_INT13_CD     0
 #define DEBUG_INT13_ET     0
@@ -945,10 +945,10 @@ Bit16u cdrom_boot();
 
 #endif // BX_ELTORITO_BOOT
 
-static char bios_cvs_version_string[] = "$Revision: 1.4 $";
-static char bios_date_string[] = "$Date: 2008/05/11 23:26:05 $";
+static char bios_cvs_version_string[] = "$Revision: 1.11 $";
+static char bios_date_string[] = "$Date: 2008/07/07 23:56:54 $";
 
-static char CVSID[] = "$Id: rombios.c,v 1.4 2008/05/11 23:26:05 pdinda Exp $";
+static char CVSID[] = "$Id: rombios.c,v 1.11 2008/07/07 23:56:54 pdinda Exp $";
 
 /* Offset to skip the CVS $Id: prefix */ 
 #define bios_version_string  (CVSID + 4)
@@ -1400,12 +1400,13 @@ ASM_END
 }
 
 //  Bit16u
-//get_DS()
-//{
-//ASM_START
-//  mov  ax, ds
-//ASM_END
-//}
+get_DS()
+{
+ASM_START
+  mov  ax, ds
+ASM_END
+}
+
 //
 //  void
 //set_DS(ds_selector)
@@ -1680,9 +1681,11 @@ keyboard_init()
     while ( (inb(0x64) & 0x02) && (--max>0)) outb(0x80, 0x00); 
 
     /* flush incoming keys */
-    max=0x2000;
+    // temporarily chaged for debug -PAD
+    //    max=0x2000;  
+    max=10;
     while (--max > 0) {
-        outb(0x80, 0x00);
+        outb(0x80, 0x01);
         if (inb(0x64) & 0x01) {
             inb(0x60);
             max = 0x2000;
@@ -1700,12 +1703,12 @@ keyboard_init()
 
     /* Wait until buffer is empty */
     max=0xffff;
-    while ( (inb(0x64) & 0x02) && (--max>0)) outb(0x80, 0x00);
+    while ( (inb(0x64) & 0x02) && (--max>0)) outb(0x80, 0x02);
     if (max==0x0) keyboard_panic(00);
 
     /* Wait for data */
     max=0xffff;
-    while ( ((inb(0x64) & 0x01) == 0) && (--max>0) ) outb(0x80, 0x01);
+    while ( ((inb(0x64) & 0x01) == 0) && (--max>0) ) outb(0x80, 0x03);
     if (max==0x0) keyboard_panic(01);
 
     /* read self-test result, 0x55 should be returned from 0x60 */
@@ -2892,21 +2895,22 @@ Bit32u length;
   if (status & ATA_CB_STAT_BSY) return 2;
 #endif
 
-  // select master or slave
-  outb(iobase1 + ATA_CB_DH, slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0);
 
   // set "noninterruptable"
   outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
 
-  outb(iobase1 + ATA_CB_FR, 0x00);
-  outb(iobase1 + ATA_CB_SC, 0x00);
-  outb(iobase1 + ATA_CB_SN, 0x00);
+  //outb(iobase1 + ATA_CB_FR, 0x00);
+  //outb(iobase1 + ATA_CB_SC, 0x00);
+  //outb(iobase1 + ATA_CB_SN, 0x00);
 
   // Set cylinders ?? - Why?  And why not sector
   // This is all embedded in cmd_packet, anyway...
   outb(iobase1 + ATA_CB_CL, 0xfff0 & 0x00ff);
   outb(iobase1 + ATA_CB_CH, 0xfff0 >> 8);
 
+  // select master or slave
+  outb(iobase1 + ATA_CB_DH, slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0);
+
   // Tell it we are sending a command packet
   outb(iobase1 + ATA_CB_CMD, ATA_CMD_PACKET);
 
@@ -2920,13 +2924,13 @@ Bit32u length;
 #endif
 
   // Device should ok to receive command
-  // what until we get
+  // wait until we get
   while (1) {
 
     status = inb(iobase1 + ATA_CB_STAT);
 
 #if PDINDA
-    if (!(status & ATA_CB_STAT_BSY) && (status & ATA_CB_STAT_DRQ))  break;
+    if (!(status & ATA_CB_STAT_BSY))  break;
 #else       
     // Shouldn't this be ATA_CB_STAT_RDY?  -PAD - NO, it's OK
     if ( !(status & ATA_CB_STAT_BSY) ) break;
@@ -2968,7 +2972,7 @@ ASM_START
 ASM_END
 
   // issue read of alternative status - claimed to be in spec
-  inb(iobase2+ATA_CB_ASTAT);
+  //inb(iobase2+ATA_CB_ASTAT);
 
 
   if (inout == ATA_DATA_NO) {
@@ -2980,7 +2984,7 @@ ASM_END
     do {
       status=inb(iobase1+ATA_CB_STAT);
       BX_DEBUG_ATA("ata_cmd_packet: wait (%2x)\n",status);
-    } while ((status & ATA_CB_STAT_BSY) && !(status & ATA_CB_STAT_RDY));
+    } while ((status & ATA_CB_STAT_BSY));
     
     while (1) {
       
@@ -4165,10 +4169,13 @@ ASM_END
          case 0x20: // coded by osmaker aka K.J.
             if(regs.u.r32.edx == 0x534D4150) /* SMAP */
             {
-#ifdef HVMASSIST
+#if defined(HVMASSIST) && 0
                if ((regs.u.r16.bx / 0x14) * 0x14 == regs.u.r16.bx) {
+
                    Bit16u e820_table_size = read_word(0xe000, 0x8) * 0x14;
 
+                    BX_DEBUG_INT15("OK bx=%x\n",regs.u.r16.bx);
+
                    if (regs.u.r16.bx + 0x14 <= e820_table_size) {
                        memcpyb(ES, regs.u.r16.di,
                                0xe000, 0x10 + regs.u.r16.bx, 0x14);
@@ -6769,16 +6776,15 @@ int13_diskette_function(DS, ES, DI, SI, BP, ELDX, BX, DX, CX, AX, IP, CS, FLAGS)
   Bit8u  drive_type, num_floppies, ah;
   Bit16u es, last_addr;
 
-  printf("In int13_diskette\n");
 
-  BX_DEBUG_INT13_FL("int13_diskette: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", AX, BX, CX, DX, ES);
-  // BX_DEBUG_INT13_FL("int13_diskette: SS=%04x DS=%04x ES=%04x DI=%04x SI=%04x\n",get_SS(), get_DS(), ES, DI, SI);
+  //printf("int13_diskette: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", AX, BX, CX, DX, ES);
+  BX_DEBUG_INT13_FL("int13_diskette: SS=%04x DS=%04x ES=%04x DI=%04x SI=%04x\n",get_SS(),get_DS(), ES, DI, SI);
 
   ah = GET_AH();
 
   switch ( ah ) {
     case 0x00: // diskette controller reset
-BX_DEBUG_INT13_FL("floppy f00\n");
+      BX_DEBUG_INT13_FL("floppy f00\n");
       drive = GET_ELDL();
       if (drive > 1) {
         SET_AH(1); // invalid param
@@ -7771,6 +7777,8 @@ ASM_END
   print_boot_device(0, bootdrv);
 #endif // BX_ELTORITO_BOOT
 
+  BX_DEBUG("boot to %x\n", (((Bit32u)bootdrv) << 16) + bootseg);
+
   // return the boot segment
   return (((Bit32u)bootdrv) << 16) + bootseg;
 }
@@ -8298,7 +8306,9 @@ boot_setup:
   mov [bp],  ax      ;; set bp to zero
   mov ax,    #0xaa55 ;; set ok flag
 
+
   pop bp
+
   iret               ;; Beam me up Scotty
 
 ;----------
@@ -8835,7 +8845,7 @@ int76_handler:
   mov   ds, ax
   mov   0x008E, #0xff
   call  eoi_both_pics
-  pop   ds
+  pop   ds  
   pop   ax
   iret
 
@@ -9501,6 +9511,7 @@ rom_scan_loop:
   jne  rom_scan_increment
   call rom_checksum
   jnz  rom_scan_increment
+
   mov  al, [2]  ;; change increment to ROM length in 512-byte blocks
 
   ;; We want our increment in 512-byte quantities, rounded to