: Fix rombios to correctly report size of disks >16GB
PATCH 1/1 : Fix rombios to correctly report size of disks >16GB
Cosmetic patch for rombios to display the correct sizes of disks larger than 16GB - a problem caused by needlessly casting sizeinmb variable down to 16bits.
tools/firmware/rombios/rombios.c +2 -2
@@ -2856,9 +2856,9 @@ void ata_detect( )printf ("ata%d %s: " ,channel,slave?" slave" :"master" ); i=0 ;while (c=read_byte (get_SS (),model+i++))printf ("%c" ,c);if (sizeinmb < (1UL <<16 )) -printf (" ATA-%d Hard-Disk (%4u MBytes)\n" , version, (Bit16u )sizeinmb); +printf (" ATA-%d Hard-Disk (%4u MBytes)\n" , version, sizeinmb);else -printf (" ATA-%d Hard-Disk (%4u GBytes)\n" , version, (Bit16u)(sizeinmb>>10 )); +printf (" ATA-%d Hard-Disk (%4u GBytes)\n" , version, (sizeinmb>>10 ));break ;case ATA_TYPE_ATAPI :printf ("ata%d %s: " ,channel,slave?" slave" :"master" );
Quoted 3 lines · Gianni Tedesco
Cosmetic patch for rombios to display the correct sizes of disks larger than 16GB - a problem caused by needlessly casting sizeinmb variable down to 16bits.
For say a 17GB drive sizeinmb=17000 which can be represented with fewer than 16 bits. I don't see how the code as it is will ever print the wrong thing, except for drives bigger than 64TB! Also I'm not sure but I think the integer size here may be 16 bits, and the %u format specifier would only print 16-bit values in that case anyway.
-- Keir
Quoted 27 lines
Signed-off-by Gianni Tedesco <[email protected]>diff -r
01917c0da12atools/firmware/rombios/rombios.ctools/firmware/rombios/rombios.c Thu Jul 22 18:40:26 2010 +0100 renamed from tools/firmware/rombios/rombios.c Thu Jul 22 13:49:40 2010 +0100 +2
-2@@ -2856,9 +2856,9 @@ void ata_detect( ) printf("ata%d %s: ",channel,slave?" slave":"master"); i=0; while(c=read_byte(get_SS(),model+i++)) printf("%c",c); if (sizeinmb < (1UL<<16)) - printf(" ATA-%d Hard-Disk (%4u MBytes)\n", version, (Bit16u)sizeinmb); + printf(" ATA-%d Hard-Disk (%4u MBytes)\n", version, sizeinmb); else - printf(" ATA-%d Hard-Disk (%4u GBytes)\n", version, (Bit16u)(sizeinmb>>10)); + printf(" ATA-%d Hard-Disk (%4u GBytes)\n", version, (sizeinmb>>10));break; case ATA_TYPE_ATAPI: printf("ata%d %s: ",channel,slave?" slave":"master");_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 9 lines · Keir Fraser
Quoted 3 lines · Gianni Tedesco
Cosmetic patch for rombios to display the correct sizes of disks larger than 16GB - a problem caused by needlessly casting sizeinmb variable down to 16bits.
For say a 17GB drive sizeinmb=17000 which can be represented with fewer than 16 bits. I don't see how the code as it is will ever print the wrong thing, except for drives bigger than 64TB!
Actually you are right then wrong, the patch is mis-titled, it's 64GB. (in fact 65,535 MB).
Quoted 3 lines
Also I'm not sure but I think the
integer size here may be 16 bits, and the %u format specifier would only print 16-bit values in that case anyway.
I tested it and it works as advertised (modulo 16 -> 64)....
Gianni
Quoted 11 lines · Gianni Tedesco
Quoted 9 lines · Keir Fraser
Quoted 3 lines · Gianni Tedesco
Cosmetic patch for rombios to display the correct sizes of disks larger than 16GB - a problem caused by needlessly casting sizeinmb variable down to 16bits.
For say a 17GB drive sizeinmb=17000 which can be represented with fewer than 16 bits. I don't see how the code as it is will ever print the wrong thing, except for drives bigger than 64TB!
Quoted 8 lines
Actually you are right then wrong, the patch is mis-titled, it's 64GB. (in fact 65,535 MB).
Quoted 3 lines
Also I'm not sure but I think the
integer size here may be 16 bits, and the %u format specifier would only print 16-bit values in that case anyway.I tested it and it works as advertised (modulo 16 -> 64)....
BTW. the reason for that is printf() and integer definition doesn't change regardless of whether gcc is compiling for 16 or 32 bit mode but just changes the logic wrt operand-size insn prefix
Gianni
Quoted 9 lines · On 23/07/2010 09:14, "Gianni Tedesco (3P)" <[email protected]> wrote:
Quoted 5 lines
Quoted 3 lines
Also I'm not sure but I think the
integer size here may be 16 bits, and the %u format specifier would only print 16-bit values in that case anyway.I tested it and it works as advertised (modulo 16 -> 64)....
BTW. the reason for that is
printf()and integer definition doesn't change regardless of whether gcc is compiling for 16 or 32 bit mode but just changes the logic wrt operand-size insn prefix
This isn't compiled with gcc, but with bcc from the dev86 toolchain. Hacking sizeinmb to be 67UL<<10, I find that 67GB is printed which is correct. That's with the latest dev86 (which is still very old!) v0.16.17.
-- Keir
Quoted 4 lines · On 23/07/2010 09:07, "Gianni Tedesco (3P)" <[email protected]> wrote:
Quoted 3 lines
For say a 17GB drive sizeinmb=17000 which can be represented with fewer than 16 bits. I don't see how the code as it is will ever print the wrong thing, except for drives bigger than 64TB!
Quoted 8 lines
Actually you are right then wrong, the patch is mis-titled, it's 64GB. (in fact 65,535 MB).
Quoted 3 lines
Also I'm not sure but I think the
integer size here may be 16 bits, and the %u format specifier would only print 16-bit values in that case anyway.I tested it and it works as advertised (modulo 16 -> 64)....
64GB == 65536MB > 1UL<<16, hence we should print the size in GB, and shift right 10 before casting. Hence should still print correctly. Is this another example where the bcc compiler is broken?
-- Keir
Quoted 14 lines · Keir Fraser
Quoted 11 lines · On 23/07/2010 09:07, "Gianni Tedesco (3P)" <[email protected]> wrote:
Quoted 3 lines
For say a 17GB drive sizeinmb=17000 which can be represented with fewer than 16 bits. I don't see how the code as it is will ever print the wrong thing, except for drives bigger than 64TB!
Actually you are right then wrong, the patch is mis-titled, it's 64GB. (in fact 65,535 MB).
Quoted 3 lines
Also I'm not sure but I think the
integer size here may be 16 bits, and the %u format specifier would only print 16-bit values in that case anyway.
Quoted 5 lines
Quoted 1 line
I tested it and it works as advertised (modulo 16 -> 64)....
64GB == 65536MB > 1UL<<16, hence we should print the size in GB, and shift right 10 before casting. Hence should still print correctly. Is this another example where the bcc compiler is broken?
Argh, ignore me, you are right - I was mindlessly sending off my patch-queue against xenserver in which there are no brackets on the bit-shift! :)
Sorry for the noise