From 4d1e33453da27fe61a5ce42c204e152b406b66f9 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 6 Jul 2010 00:35:49 +0800 Subject: [PATCH] Fiddling with multiboot modules (and some bug searching in ATA code) --- Kernel/arch/x86/main.c | 8 +++++--- Kernel/include/mboot.h | 2 +- Modules/Storage/ATA/main.c | 35 ++++++++++++++++++++++------------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Kernel/arch/x86/main.c b/Kernel/arch/x86/main.c index 3ea4f3f3..3a45637c 100644 --- a/Kernel/arch/x86/main.c +++ b/Kernel/arch/x86/main.c @@ -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 diff --git a/Kernel/include/mboot.h b/Kernel/include/mboot.h index 6d5e6a4b..c7f33ddb 100644 --- a/Kernel/include/mboot.h +++ b/Kernel/include/mboot.h @@ -24,7 +24,7 @@ typedef struct { typedef struct { Uint32 Start; Uint32 End; - char *String; + Uint32 String; Uint32 Resvd; } tMBoot_Module; diff --git a/Modules/Storage/ATA/main.c b/Modules/Storage/ATA/main.c index 8dc9f2a6..f4130b04 100644 --- a/Modules/Storage/ATA/main.c +++ b/Modules/Storage/ATA/main.c @@ -12,9 +12,6 @@ #include #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 -- 2.20.1