Mercurial > ecos-v3_0-branch
changeset 1777:5229788b26d4
RedBoot IDE tweaks
| author | msalter |
|---|---|
| date | Mon, 27 Sep 2004 18:43:27 +0000 |
| parents | 11a294ddab36 |
| children | 5eec99b3cbea |
| files | packages/redboot/current/ChangeLog packages/redboot/current/src/fs/disk.c |
| diffstat | 2 files changed, 27 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,9 @@ +2004-09-27 Mark Salter <msalter@redhat.com> + + * src/fs/ide.c (ide_presence_detect): New function. + * src/fs/disk.c (u32_unaligned): New function to read unaligned words. + (find_dos_partitions): Use u32_unaligned instead of memcpy. + 2004-9-25 Andrew Lunn <andrew.lunn@ascom.ch> * doc/redboot_install.sgml: Added installation information for the
--- a/packages/redboot/current/src/fs/disk.c +++ b/packages/redboot/current/src/fs/disk.c @@ -8,7 +8,7 @@ //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. -// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Red Hat, Inc. // Copyright (C) 2002 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under @@ -74,6 +74,20 @@ RedBoot_cmd("disks", static disk_t disk_table[CYGNUM_REDBOOT_MAX_DISKS]; static int disk_count = 0; +static inline cyg_uint32 +u32_unaligned(void *p) +{ + cyg_uint32 val; + char *d = (char *)&val; + char *s = p; + int i; + + for (i = 0; i < 4; i++) + *d++ = *s++; + + return val; +} + static int find_dos_partitions(disk_t *d, cyg_uint8 *mbr) { @@ -86,11 +100,8 @@ find_dos_partitions(disk_t *d, cyg_uint8 // Look for primary partitions for (i = 0; i < 4 && i < CYGNUM_REDBOOT_MAX_PARTITIONS; i++) { - // Have to use memcpy because of alignment - memcpy(&tmp, p->start_sect, 4); - s = SWAB_LE32(tmp); - memcpy(&tmp, p->nr_sects, 4); - n = SWAB_LE32(tmp); + s = SWAB_LE32(u32_unaligned(p->start_sect)); + n = SWAB_LE32(u32_unaligned(p->nr_sects)); if (s && n) { ++found; @@ -129,11 +140,8 @@ find_dos_partitions(disk_t *d, cyg_uint8 p = (struct mbr_partition *)((char *)buf + MBR_PTABLE_OFFSET); - // Have to use memcpy because of alignment - memcpy(&tmp, p->start_sect, 4); - s = SWAB_LE32(tmp); - memcpy(&tmp, p->nr_sects, 4); - n = SWAB_LE32(tmp); + s = SWAB_LE32(u32_unaligned(p->start_sect)); + n = SWAB_LE32(u32_unaligned(p->nr_sects)); if (s && n) { ++found; @@ -145,10 +153,8 @@ find_dos_partitions(disk_t *d, cyg_uint8 } ++p; - memcpy(&tmp, p->start_sect, 4); - s = SWAB_LE32(tmp); - memcpy(&tmp, p->nr_sects, 4); - n = SWAB_LE32(tmp); + s = SWAB_LE32(u32_unaligned(p->start_sect)); + n = SWAB_LE32(u32_unaligned(p->nr_sects)); // more extended partitions? if (p->sys_ind != SYSTYPE_EXTENDED || !s || !n)
