qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Character order of ATA identity
@ 2015-04-16 18:07 乔天香
  2015-04-17 22:45 ` John Snow
  0 siblings, 1 reply; 2+ messages in thread
From: 乔天香 @ 2015-04-16 18:07 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]

Hi, all

I'm learning operating system and trying to write a little toy kernel.
Before doing disk I/O, I issued the *ATA identify* command to obtain
information about the master device on the primary channel. When I ran my
code with QEMU, I found it gives some ASCII string fields in a wrong byte
order, for example, the model name is given as:

    EQUMH RADDSI K

but actually it should be

    QEMU HARDDISK

So I referred to the source code file `hw/ide/core.c` and found a function
doing this:


  61 static void padstr(char *str, const char *src, int len)
  62 {
  63     int i, v;
  64     for(i = 0; i < len; i++) {
  65         if (*src)
  66             v = *src++;
  67         else
  68             v = ' ';
  69         str[i^1] = v;
  70     }
  71 }


And it is called like:

     112     padstr((char *)(p + 27), s->drive_model_str, 40); /* model */

Now I'm wondering why it does this "byte swapping"? I read the ATA
specification about this *ATA identify* command and didn't find anything
related to byte order. Is it required by hardware?

Thanks for your kind help.

[-- Attachment #2: Type: text/html, Size: 2188 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-17 23:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-16 18:07 [Qemu-devel] Character order of ATA identity 乔天香
2015-04-17 22:45 ` John Snow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).