Fiddling with multiboot modules (and some bug searching in ATA code)
authorJohn Hodge <[email protected]>
Mon, 5 Jul 2010 16:35:49 +0000 (00:35 +0800)
committerJohn Hodge <[email protected]>
Mon, 5 Jul 2010 16:35:49 +0000 (00:35 +0800)
Kernel/arch/x86/main.c
Kernel/include/mboot.h
Modules/Storage/ATA/main.c

index 3ea4f3f..3a45637 100644 (file)
@@ -98,7 +98,10 @@ int kmain(Uint MbMagic, void *MbInfoPtr)
        for( i = 0; i < mbInfo->ModuleCount; i ++ )
        {
                 int    ofs;
-               
+       
+               Log_Log("Arch", "Multiboot Module at 0x%08x, 0x%08x bytes (String at 0x%08x)",
+                       mods[i].Start, mods[i].End-mods[i].Start, mods[i].String);
+       
                // Always HW map the module data
                gaArch_BootModules[i].Size = mods[i].End - mods[i].Start;
                
@@ -112,8 +115,7 @@ int kmain(Uint MbMagic, void *MbInfoPtr)
                {
                        // Assumes the string is < 4096 bytes long)
                        gaArch_BootModules[i].ArgString = (void*)(
-                               MM_MapHWPages((tVAddr)mods[i].String, 2)
-                               + ((tVAddr)mods[i].String&0xFFF)
+                               MM_MapHWPages(mods[i].String, 2) + (mods[i].String&0xFFF)
                                );
                }
                else
index 6d5e6a4..c7f33dd 100644 (file)
@@ -24,7 +24,7 @@ typedef struct {
 typedef struct {
        Uint32  Start;
        Uint32  End;
-       char    *String;
+       Uint32  String;
        Uint32  Resvd;
 } tMBoot_Module;
 
index 8dc9f2a..f4130b0 100644 (file)
@@ -12,9 +12,6 @@
 #include <tpl_drv_disk.h>
 #include "common.h"
 
-// --- Flags ---
-#define START_BEFORE_CMD       0
-
 // === STRUCTURES ===
 typedef struct
 {
@@ -96,7 +93,7 @@ Uint8 *gATA_BusMasterBasePtr = 0;
  int   gATA_IRQPri = 14;
  int   gATA_IRQSec = 15;
  int   giaATA_ControllerLock[2] = {0}; //!< Spinlocks for each controller
-Uint8  gATA_Buffers[2][4096] __attribute__ ((section(".padata")));
+Uint8  gATA_Buffers[2][(MAX_DMA_SECTORS+0xFFF)&~0xFFF] __attribute__ ((section(".padata")));
 volatile int   gaATA_IRQs[2] = {0};
 tPRDT_Ent      gATA_PRDTs[2] = {
        {0, 512, IDE_PRDT_LAST},
@@ -288,15 +285,24 @@ int ATA_ScanDisk(int Disk)
 
        LOG("gATA_Disks[ Disk ].Sectors = 0x%x", gATA_Disks[ Disk ].Sectors);
 
-       if( gATA_Disks[ Disk ].Sectors / (2048*1024) )
-               Log("Disk %i: 0x%llx Sectors (%i GiB)", Disk,
-                       gATA_Disks[ Disk ].Sectors, gATA_Disks[ Disk ].Sectors / (2048*1024));
-       else if( gATA_Disks[ Disk ].Sectors / 2048 )
-               Log("Disk %i: 0x%llx Sectors (%i MiB)", Disk,
-                       gATA_Disks[ Disk ].Sectors, gATA_Disks[ Disk ].Sectors / 2048);
-       else
-               Log("Disk %i: 0x%llx Sectors (%i KiB)", Disk,
-                       gATA_Disks[ Disk ].Sectors, gATA_Disks[ Disk ].Sectors / 2);
+       {
+               Uint64  val = gATA_Disks[ Disk ].Sectors / 2;
+               char    *units = "KiB";
+               if( val > 4*1024 ) {
+                       val /= 1024;
+                       units = "MiB";
+               }
+               else if( val > 4*1024 ) {
+                       val /= 1024;
+                       units = "GiB";
+               }
+               else if( val > 4*1024 ) {
+                       val /= 1024;
+                       units = "TiB";
+               }
+               Log_Log("ATA", "Disk %i: 0x%llx Sectors (%i %s)", Disk,
+                       gATA_Disks[ Disk ].Sectors, val, units);
+       }
 
        // Create Name
        gATA_Disks[ Disk ].Name[0] = 'A'+Disk;
@@ -660,6 +666,9 @@ int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
        // Complete Transfer
        ATA_int_BusMasterWriteByte( cont << 3, 8 );     // Read and stop
 
+       val = inb(base+0x7);
+       LOG("Status byte = 0x%02x", val);
+
        LOG("Transfer Completed & Acknowledged");
 
        // Copy to destination buffer

UCC git Repository :: git.ucc.asn.au