# HG changeset patch # User John Tsiombikas # Date 1323171339 -7200 # Node ID 4db99a52863eb4737a6ecd25b1a2fad85e58d98a # Parent 2dda077c1d38c71492ad07dc1993779ca83d1bc2 fixed the "endianess" of the text messages in the ATA identify info block. this is the first time I've seen wrong byteorder in ascii text, the ATA committee should be commended. diff -r 2dda077c1d38 -r 4db99a52863e src/ata.c --- a/src/ata.c Tue Dec 06 12:59:38 2011 +0200 +++ b/src/ata.c Tue Dec 06 13:35:39 2011 +0200 @@ -55,6 +55,7 @@ static inline void write_reg8(struct device *dev, int reg, uint8_t val); static inline void write_reg16(struct device *dev, int reg, uint16_t val); static void ata_intr(int inum); +static void *atastr(void *res, void *src, int n); static char *size_str(uint64_t nsect, char *buf); /* last drive selected on each bus */ @@ -125,13 +126,8 @@ read_data(dev, info); /* print model and serial */ - memcpy(textbuf, info + 27, 40); - textbuf[40] = 0; - printf("- found ata drive (%d,%d): %s\n", dev->iface, dev->id, textbuf); - - memcpy(textbuf, info + 10, 20); - textbuf[20] = 0; - printf(" s/n: %s\n", textbuf); + printf("- found ata drive (%d,%d): %s\n", dev->iface, dev->id, atastr(textbuf, info + 27, 40)); + printf(" s/n: %s\n", atastr(textbuf, info + 10, 20)); dev->nsect_lba = *(uint32_t*)(info + 60); dev->nsect_lba48 = *(uint64_t*)(info + 100) & 0xffffffffffffull; @@ -231,6 +227,20 @@ printf("ATA interrupt\n"); } +static void *atastr(void *res, void *src, int n) +{ + int i; + uint16_t *sptr = (uint16_t*)src; + char *dptr = res; + + for(i=0; i> 8; + *dptr++ = *sptr++ & 0xff; + } + *dptr = 0; + return res; +} + static char *size_str(uint64_t nsect, char *buf) { static const char *suffix[] = {"kb", "mb", "gb", "tb", "pb", 0};