changeset 2274:16ea61a1d5d4

* cdl/io_disk.cdl: Made debugging CDL controlled. * src/disk.c: Added support to allow non-CHS disk devices to use LBA information in MBR.
author asl
date Mon, 21 Aug 2006 21:10:31 +0000
parents 4a81fad4d2b4
children bd5fe26e87c5
files packages/io/disk/current/ChangeLog packages/io/disk/current/cdl/io_disk.cdl packages/io/disk/current/src/disk.c
diffstat 3 files changed, 54 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/packages/io/disk/current/ChangeLog
+++ b/packages/io/disk/current/ChangeLog
@@ -1,3 +1,9 @@
+2006-08-18  Andy Jackson  <andy@xylanta.com>
+
+	* cdl/io_disk.cdl: Made debugging CDL controlled. 
+	* src/disk.c: Added support to allow non-CHS disk devices to 
+	use LBA information in MBR.
+
 2005-12-02  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* src/disk.c: Add comments that bread/bwrite take the position and
--- a/packages/io/disk/current/cdl/io_disk.cdl
+++ b/packages/io/disk/current/cdl/io_disk.cdl
@@ -62,12 +62,12 @@ cdl_package CYGPKG_IO_DISK {
     compile       -library=libextras.a disk.c
  
     define_proc {
-	puts $::cdl_header "/***** proc output start *****/"
-	puts $::cdl_header "#include <pkgconf/system.h>"
-	puts $::cdl_header "#ifdef CYGDAT_IO_DISK_DEVICE_HEADER"
-	puts $::cdl_header "# include CYGDAT_IO_DISK_DEVICE_HEADER"
-	puts $::cdl_header "#endif "
-	puts $::cdl_header "/****** proc output end ******/"
+        puts $::cdl_header "/***** proc output start *****/"
+        puts $::cdl_header "#include <pkgconf/system.h>"
+        puts $::cdl_header "#ifdef CYGDAT_IO_DISK_DEVICE_HEADER"
+        puts $::cdl_header "# include CYGDAT_IO_DISK_DEVICE_HEADER"
+        puts $::cdl_header "#endif "
+        puts $::cdl_header "/****** proc output end ******/"
     }
 
     cdl_component CYGPKG_IO_DISK_DEVICES {
@@ -76,16 +76,25 @@ cdl_package CYGPKG_IO_DISK {
         default_value 1
         description   "
             This option enables the hardware disk drivers
-	        for the current platform."
+            for the current platform."
+    }
+
+    cdl_component CYGDBG_IO_DISK_DEBUG {
+        display       "Enable debugging output"
+        flavor        bool
+        default_value 0
+        description   "
+            This option enables debugging information from
+            the disk driver package."
     }
 
     cdl_component CYGPKG_IO_DISK_OPTIONS {
         display "Disk device driver build options"
         flavor  none
         description   "
-	        Package specific build options including control over
-	        compiler flags used only in building this package,
-	        and details of which tests are built."
+                Package specific build options including control over
+                compiler flags used only in building this package,
+                and details of which tests are built."
 
 
         cdl_option CYGPKG_IO_DISK_CFLAGS_ADD {
--- a/packages/io/disk/current/src/disk.c
+++ b/packages/io/disk/current/src/disk.c
@@ -58,7 +58,9 @@
 
 // ---------------------------------------------------------------------------
 
-//#define DEBUG 1
+#ifdef CYGDBG_IO_DISK_DEBUG
+#define DEBUG 1
+#endif
 
 #ifdef DEBUG
 # define D(_args_) diag_printf _args_
@@ -160,18 +162,37 @@ read_partition(cyg_uint8            *dat
                cyg_disk_info_t      *info,
                cyg_disk_partition_t *part)
 {
+    cyg_disk_identify_t *ident = &info->ident;
     cyg_uint16 c, h, s;
 
+    // Retrieve basic information
     part->type  = data[4];
     part->state = data[0];
-
-    READ_CHS(&data[1], c, h, s);
-    CHS_TO_LBA(&info->ident, c, h, s, part->start);
+    READ_DWORD(&data[12], part->size);
 
-    READ_CHS(&data[5], c, h, s);
-    CHS_TO_LBA(&info->ident, c, h, s, part->end);
-    
-    READ_DWORD(&data[12], part->size);
+    // If disk doesn't have cylinders/heads, use LBA data rather than CHS
+    if (ident->cylinders_num == 0 && ident->heads_num == 0 &&
+        ident->sectors_num== 0)
+    {
+        // Use LBA data to determine disk size
+        READ_DWORD(&data[8], part->start);
+        part->end = (part->start + part->size) - 1;
+        D(("LBA partition data (%d,%d,%d)\n", 
+           part->start, part->end, part->size));
+    }
+    else
+    {
+        // Use CHS data to determine disk size
+        READ_CHS(&data[1], c, h, s);
+        D(("partition start CHS %d,%d,%d\n", c, h, s));
+        CHS_TO_LBA(ident, c, h, s, part->start);
+
+        READ_CHS(&data[5], c, h, s);
+        D(("partition end CHS %d,%d,%d\n", c, h, s));
+        CHS_TO_LBA(ident, c, h, s, part->end);
+        D(("CHS partition data (%d,%d,%d)\n", 
+           part->start, part->end, part->size));
+    }
 }
 
 //