# HG changeset patch # User asl # Date 1156194631 0 # Node ID 16ea61a1d5d4ca0c56c35724235becadf9e317a5 # Parent 4a81fad4d2b4c039c953327290b8d67a3fa1692c * 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. diff --git a/packages/io/disk/current/ChangeLog b/packages/io/disk/current/ChangeLog --- a/packages/io/disk/current/ChangeLog +++ b/packages/io/disk/current/ChangeLog @@ -1,3 +1,9 @@ +2006-08-18 Andy Jackson + + * 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 * src/disk.c: Add comments that bread/bwrite take the position and diff --git a/packages/io/disk/current/cdl/io_disk.cdl b/packages/io/disk/current/cdl/io_disk.cdl --- 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 " - 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 " + 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 { diff --git a/packages/io/disk/current/src/disk.c b/packages/io/disk/current/src/disk.c --- 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)); + } } //