From 174d92a09a250c64451d8340219a89593172b056 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 16 Jul 2010 16:33:39 -0700 Subject: [PATCH] diskio: expand most fields; cache the number of total tracks Expand most fields in struct disk to 32 bits -- it makes the code smaller in general, and struct disk is not a common data element. Add a field for the number of tracks (number of heads*sectors). Signed-off-by: H. Peter Anvin --- core/fs/diskio.c | 3 ++- core/include/disk.h | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/fs/diskio.c b/core/fs/diskio.c index 51f2f39..55a9df4 100644 --- a/core/fs/diskio.c +++ b/core/fs/diskio.c @@ -11,7 +11,7 @@ static inline sector_t chs_max(const struct disk *disk) { - return (disk->h * disk->s) << 10; + return disk->t << 10; } static int chs_rdwr_sectors(struct disk *disk, void *buf, @@ -393,6 +393,7 @@ struct disk *disk_init(uint8_t devno, bool cdrom, sector_t part_start, disk.sector_size = sector_size; disk.sector_shift = ilog2(sector_size); disk.part_start = part_start; + disk.t = disk.h * disk.s; disk.rdwr_sectors = ebios ? edd_rdwr_sectors : chs_rdwr_sectors; if (!MaxTransfer || MaxTransfer > hard_max_transfer) diff --git a/core/include/disk.h b/core/include/disk.h index df0476a..f433fa9 100644 --- a/core/include/disk.h +++ b/core/include/disk.h @@ -13,17 +13,16 @@ typedef uint64_t block_t; * contains the I/O function. */ struct disk { - uint8_t disk_number; /* in BIOS style */ - uint8_t type; /* CHS or EDD */ - uint16_t sector_size; /* gener512B or 2048B */ - uint8_t sector_shift; + unsigned int disk_number; /* in BIOS style */ + unsigned int type; /* CHS or EDD */ + unsigned int sector_size; /* gener512B or 2048B */ + unsigned int sector_shift; - uint8_t h, s; /* CHS geometry */ - uint8_t pad; + unsigned int h, s; /* CHS geometry */ + unsigned int t; /* h*s */ + uint32_t maxtransfer; /* Max sectors per transfer */ sector_t part_start; /* the start address of this partition(in sectors) */ - - uint32_t maxtransfer; /* Max sectors per transfer */ int (*rdwr_sectors)(struct disk *, void *, sector_t, size_t, bool); }; -- 2.7.4