Fixed bug in LBA code.
authorBrian Palmer <brianp@sginet.com>
Tue, 12 Mar 2002 19:55:08 +0000 (19:55 +0000)
committerBrian Palmer <brianp@sginet.com>
Tue, 12 Mar 2002 19:55:08 +0000 (19:55 +0000)
svn path=/trunk/; revision=2705

freeldr/freeldr/arch/i386/disk.S
freeldr/freeldr/debug.c
freeldr/freeldr/disk/disk.c
freeldr/freeldr/disk/partition.c
freeldr/freeldr/fs/fat.c

index f8ccf55..4ea859c 100644 (file)
@@ -159,10 +159,10 @@ _packet_reserved:
        .byte   0
 _packet_sector_count:
        .word   0
-_packet_transfer_buffer_segment:
-       .word   0
 _packet_transfer_buffer_offset:
        .word   0
+_packet_transfer_buffer_segment:
+       .word   0
 _packet_lba_sector_number:
        .quad   0
 _packet_64bit_flat_address:
@@ -208,11 +208,10 @@ EXTERN(_BiosInt13ReadExtended)
 
 _int13_extended_read:
        movb    _int13_extended_drive,%dl                               // Get the drive
-       movb    $42,%ah                                                                 // BIOS int 0x13, function 42h - IBM/MS INT 13 Extensions - EXTENDED READ
+       movb    $0x42,%ah                                                               // BIOS int 0x13, function 42h - IBM/MS INT 13 Extensions - EXTENDED READ
        movw    $_disk_address_packet,%si                               // DS:SI -> disk address packet
        int             $0x13                                                                   // Read sectors
 
-       movb    $1,%al                                                                  // Set the return value to be one (will be set to zero later if needed)
        jc              _int13_extended_error                                   // Jump if error (CF = 1 on error)
 
        movl    _int13_extended_sector_count,%eax               // Get the sector count in eax
@@ -252,7 +251,6 @@ _int13_extended_done:
        .code32
 
        movl    _int13_extended_retval,%eax                             // Get return value
-       //movl  $1,%eax
 
        pop             %edx
        pop             %ecx
index 9f93e05..77cedc5 100644 (file)
 
 #ifdef DEBUG
 
+//ULONG        DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
+//                                              DPRINT_UI | DPRINT_DISK | DPRINT_CACHE;
 ULONG  DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
-                                                DPRINT_UI | DPRINT_DISK | DPRINT_CACHE;
+                                                DPRINT_UI | DPRINT_DISK;
 //ULONG        DebugPrintMask = DPRINT_CACHE;
 
 #define        SCREEN                          0
@@ -65,11 +67,11 @@ VOID DebugPrintChar(UCHAR Character)
 
        if (DebugPort == RS232)
        {
-               Rs232PortPutByte(Character);
                if (Character == '\n')
                {
                        Rs232PortPutByte('\r');
                }
+               Rs232PortPutByte(Character);
        }
        else if (DebugPort == BOCHS)
        {
index eafe878..f9da77e 100644 (file)
@@ -58,7 +58,7 @@ BOOL DiskReadLogicalSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorC
        GEOMETRY        DriveGeometry;
        ULONG           NumberOfSectorsToRead;
 
-       DbgPrint((DPRINT_DISK, "ReadLogicalSector() DriveNumber: 0x%x SectorNumber: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, Buffer));
+       DbgPrint((DPRINT_DISK, "ReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, SectorCount, Buffer));
 
        //
        // Check to see if it is a fixed disk drive
index 89cf40a..ad9aa2d 100644 (file)
@@ -22,6 +22,7 @@
 #include <rtl.h>
 #include <mm.h>
 #include <debug.h>
+#include <arch.h>
 
 
 
@@ -192,10 +193,11 @@ BOOL DiskReadBootRecord(ULONG DriveNumber, ULONG LogicalSectorNumber, PMASTER_BO
        ULONG   Index;
 
        // Read master boot record
-       if (!DiskReadLogicalSectors(DriveNumber, LogicalSectorNumber, 1, BootRecord))
+       if (!DiskReadLogicalSectors(DriveNumber, LogicalSectorNumber, 1, (PVOID)DISKREADBUFFER))
        {
                return FALSE;
        }
+       RtlCopyMemory(BootRecord, (PVOID)DISKREADBUFFER, sizeof(MASTER_BOOT_RECORD));
 
 
 #ifdef DEBUG
index 0665eb8..c11be24 100644 (file)
@@ -284,35 +284,10 @@ PVOID FatBufferDirectory(UINT32 DirectoryStartCluster, PUINT32 EntryCountPointer
        //
        if ((RootDirectory) && (FatType != FAT32))
        {
-               DbgPrint((DPRINT_FILESYSTEM, "We are here.\n"));
-               /*DbgPrint((DPRINT_FILESYSTEM, "sizeof(FAT_BOOTSECTOR) = 0x%x.\n", sizeof(FAT_BOOTSECTOR)));
-
-               DbgPrint((DPRINT_FILESYSTEM, "JumpBoot: 0x%x 0x%x 0x%x\n", FatVolumeBootSector->JumpBoot[0], FatVolumeBootSector->JumpBoot[1], FatVolumeBootSector->JumpBoot[2]));
-               DbgPrint((DPRINT_FILESYSTEM, "OemName: %c%c%c%c%c%c%c%c\n", FatVolumeBootSector->OemName[0], FatVolumeBootSector->OemName[1], FatVolumeBootSector->OemName[2], FatVolumeBootSector->OemName[3], FatVolumeBootSector->OemName[4], FatVolumeBootSector->OemName[5], FatVolumeBootSector->OemName[6], FatVolumeBootSector->OemName[7]));*/
-               DbgPrint((DPRINT_FILESYSTEM, "BytesPerSector: %d\n", FatVolumeBootSector->BytesPerSector));
-               DbgPrint((DPRINT_FILESYSTEM, "SectorsPerCluster: %d\n", FatVolumeBootSector->SectorsPerCluster));
-               DbgPrint((DPRINT_FILESYSTEM, "ReservedSectors: %d\n", FatVolumeBootSector->ReservedSectors));
-               DbgPrint((DPRINT_FILESYSTEM, "NumberOfFats: %d\n", FatVolumeBootSector->NumberOfFats));
-               DbgPrint((DPRINT_FILESYSTEM, "RootDirEntries: %d\n", FatVolumeBootSector->RootDirEntries));
-               DbgPrint((DPRINT_FILESYSTEM, "TotalSectors: %d\n", FatVolumeBootSector->TotalSectors));
-               DbgPrint((DPRINT_FILESYSTEM, "MediaDescriptor: 0x%x\n", FatVolumeBootSector->MediaDescriptor));
-               DbgPrint((DPRINT_FILESYSTEM, "SectorsPerFat: %d\n", FatVolumeBootSector->SectorsPerFat));
-               DbgPrint((DPRINT_FILESYSTEM, "SectorsPerTrack: %d\n", FatVolumeBootSector->SectorsPerTrack));
-               DbgPrint((DPRINT_FILESYSTEM, "NumberOfHeads: %d\n", FatVolumeBootSector->NumberOfHeads));
-               DbgPrint((DPRINT_FILESYSTEM, "HiddenSectors: %d\n", FatVolumeBootSector->HiddenSectors));
-               DbgPrint((DPRINT_FILESYSTEM, "TotalSectorsBig: %d\n", FatVolumeBootSector->TotalSectorsBig));
-               DbgPrint((DPRINT_FILESYSTEM, "DriveNumber: 0x%x\n", FatVolumeBootSector->DriveNumber));
-               DbgPrint((DPRINT_FILESYSTEM, "Reserved1: 0x%x\n", FatVolumeBootSector->Reserved1));
-               DbgPrint((DPRINT_FILESYSTEM, "BootSignature: 0x%x\n", FatVolumeBootSector->BootSignature));
-               DbgPrint((DPRINT_FILESYSTEM, "VolumeSerialNumber: 0x%x\n", FatVolumeBootSector->VolumeSerialNumber));
-               /*DbgPrint((DPRINT_FILESYSTEM, "VolumeLabel: %c%c%c%c%c%c%c%c%c%c%c\n", FatVolumeBootSector->VolumeLabel[0], FatVolumeBootSector->VolumeLabel[1], FatVolumeBootSector->VolumeLabel[2], FatVolumeBootSector->VolumeLabel[3], FatVolumeBootSector->VolumeLabel[4], FatVolumeBootSector->VolumeLabel[5], FatVolumeBootSector->VolumeLabel[6], FatVolumeBootSector->VolumeLabel[7], FatVolumeBootSector->VolumeLabel[8], FatVolumeBootSector->VolumeLabel[9], FatVolumeBootSector->VolumeLabel[10]));
-               DbgPrint((DPRINT_FILESYSTEM, "FileSystemType: %c%c%c%c%c%c%c%c\n", FatVolumeBootSector->FileSystemType[0], FatVolumeBootSector->FileSystemType[1], FatVolumeBootSector->FileSystemType[2], FatVolumeBootSector->FileSystemType[3], FatVolumeBootSector->FileSystemType[4], FatVolumeBootSector->FileSystemType[5], FatVolumeBootSector->FileSystemType[6], FatVolumeBootSector->FileSystemType[7]));*/
-               DbgPrint((DPRINT_FILESYSTEM, "BootSectorMagic: 0x%x\n", FatVolumeBootSector->BootSectorMagic));
                DirectorySize = ROUND_UP((FatVolumeBootSector->RootDirEntries * 32), FatVolumeBootSector->BytesPerSector);
        }
        else
        {
-               DbgPrint((DPRINT_FILESYSTEM, "No we are here.\n"));
                if (RootDirectory)
                {
                        DirectorySize = (FatCountClustersInChain(Fat32VolumeBootSector->RootDirStartCluster) * Fat32VolumeBootSector->SectorsPerCluster) * Fat32VolumeBootSector->BytesPerSector;