* [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive()
@ 2006-02-25 18:29 Umamaheswararao Karyampudi
2006-03-01 18:47 ` Joseph Stewart
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Umamaheswararao Karyampudi @ 2006-02-25 18:29 UTC (permalink / raw)
To: qemu-devel
Hi,
I am using QEMU in one of my research projects. I
landed in a problem where I see bogus numbers being
printed when I printed the packet/each word that is
received from ne2000.
In ne2000_receive(), I copied the packet received to a
static char [] and printed the packet using
static void print_packet(char *s, int len)
{
int i,j;
for (i=0;i<len;i++) {
if (i%20 == 0)
printf("\n");
printf("%02x ", s[i]);
}
printf("\n");
}
And some bytes it prints as fffffffff<last byte>
instead of just the last byte.
For eg:
52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
00 ffffff80 00 00
40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe
fffffffe ffffffc0 ffffffa8 ff
Similarly in ne2000_asic_ioport_read(), I print each
word that is read from NetDriverState.s->mem using the
following -
printf("\n %02x %02x", (char)(ret &0xff), (char) (
(ret >> 8) && 0xff));
And occasionally I see the 4 bytes printed instead of
1 byte for each value.
Any reason why it happens? Also,
ne2000_asic_ioport_read(), reads 6 bytes before
reading actual packet? I can think of 4 bytes for CRC
but not for the remaining 2 bytes - eg - If pak is -
52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
00 ffffff80 00 00
40 00 40 01 ffffffbc 2b
In asic_ioport_read() -
rdw 01 59
rdw 92 00
rdw 52 54
rdw 52 54
rdw 00 12
rdw 34 56
Anyhelp is greatly appreciated.
Thanks
Uma
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive()
2006-02-25 18:29 [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive() Umamaheswararao Karyampudi
@ 2006-03-01 18:47 ` Joseph Stewart
2006-03-01 23:22 ` Chris Wilson
2006-03-02 10:40 ` Alessandro Iurlano
2 siblings, 0 replies; 9+ messages in thread
From: Joseph Stewart @ 2006-03-01 18:47 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2139 bytes --]
Change the function argument from signed to unsigned and see it printf
handles prints the values correctly. I.E.
static void print_packet(unsigned char *s, int len) ...
-joe
On 2/25/06, Umamaheswararao Karyampudi <kumrao2003@yahoo.com> wrote:
>
> Hi,
> I am using QEMU in one of my research projects. I
> landed in a problem where I see bogus numbers being
> printed when I printed the packet/each word that is
> received from ne2000.
>
> In ne2000_receive(), I copied the packet received to a
> static char [] and printed the packet using
> static void print_packet(char *s, int len)
> {
> int i,j;
> for (i=0;i<len;i++) {
> if (i%20 == 0)
> printf("\n");
> printf("%02x ", s[i]);
> }
> printf("\n");
> }
> And some bytes it prints as fffffffff<last byte>
> instead of just the last byte.
> For eg:
> 52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
> 00 ffffff80 00 00
> 40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe
> fffffffe ffffffc0 ffffffa8 ff
>
> Similarly in ne2000_asic_ioport_read(), I print each
> word that is read from NetDriverState.s->mem using the
> following -
> printf("\n %02x %02x", (char)(ret &0xff), (char) (
> (ret >> 8) && 0xff));
> And occasionally I see the 4 bytes printed instead of
> 1 byte for each value.
>
> Any reason why it happens? Also,
> ne2000_asic_ioport_read(), reads 6 bytes before
> reading actual packet? I can think of 4 bytes for CRC
> but not for the remaining 2 bytes - eg - If pak is -
> 52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
> 00 ffffff80 00 00
> 40 00 40 01 ffffffbc 2b
> In asic_ioport_read() -
> rdw 01 59
> rdw 92 00
> rdw 52 54
> rdw 52 54
> rdw 00 12
> rdw 34 56
>
> Anyhelp is greatly appreciated.
>
> Thanks
> Uma
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>
[-- Attachment #2: Type: text/html, Size: 2871 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive()
2006-02-25 18:29 [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive() Umamaheswararao Karyampudi
2006-03-01 18:47 ` Joseph Stewart
@ 2006-03-01 23:22 ` Chris Wilson
2006-03-02 10:40 ` Alessandro Iurlano
2 siblings, 0 replies; 9+ messages in thread
From: Chris Wilson @ 2006-03-01 23:22 UTC (permalink / raw)
To: qemu-devel
Hi Umamaheswararao,
> In ne2000_receive(), I copied the packet received to a
> static char [] and printed the packet using
> static void print_packet(char *s, int len)
> {
> int i,j;
> for (i=0;i<len;i++) {
> if (i%20 == 0)
> printf("\n");
> printf("%02x ", s[i]);
> }
> printf("\n");
> }
> And some bytes it prints as fffffffff<last byte>
> instead of just the last byte.
> For eg:
> 52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
> 00 ffffff80 00 00
> 40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe
> fffffffe ffffffc0 ffffffa8 ff
You are using signed chars, and they are being sign-extended to signed
ints, which fills the remaining (upper) bits with 1's. When formatted as
hex, they no longer fit into two characters, because the upper bits are
not zeroes. So printf prints the full 32 bits.
Try using "unsigned char *s" in the prototype instead of just "char *s"
and see if that helps.
Cheers, Chris.
--
_ ___ __ _
/ __/ / ,__(_)_ | Chris Wilson <0000 at qwirx.com> - Cambs UK |
/ (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Perl/SQL/HTML Developer |
\ _/_/_/_//_/___/ | We are GNU-free your mind-and your software |
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive()
2006-02-25 18:29 [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive() Umamaheswararao Karyampudi
2006-03-01 18:47 ` Joseph Stewart
2006-03-01 23:22 ` Chris Wilson
@ 2006-03-02 10:40 ` Alessandro Iurlano
2 siblings, 0 replies; 9+ messages in thread
From: Alessandro Iurlano @ 2006-03-02 10:40 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 807 bytes --]
Il giorno sab, 25/02/2006 alle 10.29 -0800, Umamaheswararao Karyampudi
ha scritto:
> In ne2000_receive(), I copied the packet received to a
> static char [] and printed the packet using
> static void print_packet(char *s, int len)
> {
> int i,j;
> for (i=0;i<len;i++) {
> if (i%20 == 0)
> printf("\n");
> printf("%02x ", s[i]);
> }
> printf("\n");
> }
> And some bytes it prints as fffffffff<last byte>
> instead of just the last byte.
> For eg:
> 52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
> 00 ffffff80 00 00
> 40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe
> fffffffe ffffffc0 ffffffa8 ff
>
Maybe it's just a sign problem. Try declaring the s[] buffer as unsigned
char instead of just char.
Hope this helps,
Alessandro
[-- Attachment #2: Questa parte del messaggio è firmata --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive()
@ 2006-03-01 10:06 carlo.andreoli
2006-03-03 22:33 ` Umamaheswararao Karyampudi
0 siblings, 1 reply; 9+ messages in thread
From: carlo.andreoli @ 2006-03-01 10:06 UTC (permalink / raw)
To: qemu-devel
Regarding the bogus numbers occasionally printed, you can see that the
leading
ffs are printed when the character has its bit7 set to 1. This occurs
because in
printf("%02x ", s[i]);
the expected argument for %02x is an integer, and since the actual
argument is
a (signed) character, the compiler promotes it to an integer extending
the sign bit.
You can simply write instead
printf("%02x ", (unsigned char)s[i]);
and the problem should disappear, since in this case the promotion to
an integer
adds non-significative 0s that are ignored when printig
Carlo
----Messaggio originale----
Da: kumrao2003@yahoo.com
Data: 25/02/2006 19.29
A: <qemu-devel@nongnu.org>
Ogg: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/
ne2000_receive()
Hi,
I am using QEMU in one of my research projects. I
landed in a problem where I see bogus numbers being
printed when I printed the packet/each word that is
received from ne2000.
In ne2000_receive(), I copied the packet received to a
static char [] and printed the packet using
static void print_packet(char *s, int len)
{
int i,j;
for (i=0;i<len;i++) {
if (i%20 == 0)
printf("\n");
printf("%02x ", s[i]);
}
printf("\n");
}
And some bytes it prints as fffffffff<last byte>
instead of just the last byte.
For eg:
52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
00 ffffff80 00 00
40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe
fffffffe ffffffc0 ffffffa8 ff
Tiscali ADSL 4 Mega Flat
Naviga senza limiti con l'unica Adsl a 4 Mega di velocità a soli 19,95 € al mese!
Attivala subito e hai GRATIS 2 MESI e l'ATTIVAZIONE.
http://abbonati.tiscali.it/banner/middlepagetracking.html?c=webmailadsl&r=http://abbonati.tiscali.it/adsl/sa/4flat_tc/&a=webmail&z=webmail&t=14
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive()
2006-03-01 10:06 carlo.andreoli
@ 2006-03-03 22:33 ` Umamaheswararao Karyampudi
0 siblings, 0 replies; 9+ messages in thread
From: Umamaheswararao Karyampudi @ 2006-03-03 22:33 UTC (permalink / raw)
To: carlo.andreoli@tiscali.it, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2154 bytes --]
Thanks Carlo. Now it works after changing it to . and Thanks all for the replies.
Uma
"carlo.andreoli@tiscali.it" <carlo.andreoli@tiscali.it> wrote: Regarding the bogus numbers occasionally printed, you can see that the
leading
ffs are printed when the character has its bit7 set to 1. This occurs
because in
printf("%02x ", s[i]);
the expected argument for %02x is an integer, and since the actual
argument is
a (signed) character, the compiler promotes it to an integer extending
the sign bit.
You can simply write instead
printf("%02x ", (unsigned char)s[i]);
and the problem should disappear, since in this case the promotion to
an integer
adds non-significative 0s that are ignored when printig
Carlo
----Messaggio originale----
Da: kumrao2003@yahoo.com
Data: 25/02/2006 19.29
A:
Ogg: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/
ne2000_receive()
Hi,
I am using QEMU in one of my research projects. I
landed in a problem where I see bogus numbers being
printed when I printed the packet/each word that is
received from ne2000.
In ne2000_receive(), I copied the packet received to a
static char [] and printed the packet using
static void print_packet(char *s, int len)
{
int i,j;
for (i=0;i
if (i%20 == 0)
printf("\n");
printf("%02x ", s[i]);
}
printf("\n");
}
And some bytes it prints as fffffffff
instead of just the last byte.
For eg:
52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
00 ffffff80 00 00
40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe
fffffffe ffffffc0 ffffffa8 ff
Tiscali ADSL 4 Mega Flat
Naviga senza limiti con l'unica Adsl a 4 Mega di velocità a soli 19,95 ⬠al mese!
Attivala subito e hai GRATIS 2 MESI e l'ATTIVAZIONE.
http://abbonati.tiscali.it/banner/middlepagetracking.html?c=webmailadsl&r=http://abbonati.tiscali.it/adsl/sa/4flat_tc/&a=webmail&z=webmail&t=14
_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel
---------------------------------
Yahoo! Mail
Use Photomail to share photos without annoying attachments.
[-- Attachment #2: Type: text/html, Size: 2700 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive()
@ 2006-02-26 18:01 Umamaheswararao Karyampudi
2006-03-03 19:28 ` Brian Wheeler
0 siblings, 1 reply; 9+ messages in thread
From: Umamaheswararao Karyampudi @ 2006-02-26 18:01 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1547 bytes --]
Hi,
I am using QEMU in one of my research projects. I
landed in a problem where I see bogus numbers being
printed when I printed the packet/each word that is
received from ne2000.
In ne2000_receive(), I copied the packet received to a
static char [] and printed the packet using
static void print_packet(char *s, int len)
{
int i,j;
for (i=0;i<len;i++) {
if (i%20 == 0)
printf("\n");
printf("%02x ", s[i]);
}
printf("\n");
}
And some bytes it prints as fffffffff<last byte>
instead of just the last byte.
For eg:
52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
00 ffffff80 00 00
40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe
fffffffe ffffffc0 ffffffa8 ff
Similarly in ne2000_asic_ioport_read(), I print each
word that is read from NetDriverState.s->mem using the
following -
printf("\n %02x %02x", (char)(ret &0xff), (char) (
(ret >> 8) && 0xff));
And occasionally I see the 4 bytes printed instead of
1 byte for each value.
Any reason why it happens? Also,
ne2000_asic_ioport_read(), reads 6 bytes before
reading actual packet? I can think of 4 bytes for CRC
but not for the remaining 2 bytes - eg - If pak is -
52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
00 ffffff80 00 00
40 00 40 01 ffffffbc 2b
In asic_ioport_read() -
rdw 01 59
rdw 92 00
rdw 52 54
rdw 52 54
rdw 00 12
rdw 34 56
Anyhelp is greatly appreciated.
Thanks
Uma
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[-- Attachment #2: Type: text/html, Size: 1772 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive()
2006-02-26 18:01 Umamaheswararao Karyampudi
@ 2006-03-03 19:28 ` Brian Wheeler
0 siblings, 0 replies; 9+ messages in thread
From: Brian Wheeler @ 2006-03-03 19:28 UTC (permalink / raw)
To: qemu-devel
On Sun, 2006-02-26 at 10:01 -0800, Umamaheswararao Karyampudi wrote:
> Hi,
> I am using QEMU in one of my research projects. I
> landed in a problem where I see bogus numbers being
> printed when I printed the packet/each word that is
> received from ne2000.
>
> In ne2000_receive(), I copied the packet received to a
> static char [] and printed the packet using
> static void print_packet(char *s, int len)
> {
> int i,j;
> for (i=0;i<len;i++) {
> if (i%20 == 0)
> printf("\n");
> printf("%02x ", s[i]);
> }
> printf("\n");
> }
> And some bytes it prints as fffffffff<last byte>
> instead of just the last byte.
> For eg:
> 52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00
> 00 ffffff80 00 00
> 40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe
> fffffffe ffffffc0 ffffffa8 ff
>
Just guessing, but is it a signed/unsigned thing? All of the ffffffxx
values are above 0x7f...
Brian
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive()
@ 2006-02-25 4:13 Umamaheswararao Karyampudi
0 siblings, 0 replies; 9+ messages in thread
From: Umamaheswararao Karyampudi @ 2006-02-25 4:13 UTC (permalink / raw)
To: qemu-devel; +Cc: umak
[-- Attachment #1: Type: text/plain, Size: 1507 bytes --]
Hi,
I am using QEMU in one of my research projects. I landed in a problem where I see bogus numbers being printed when I printed the packet/each word that is received from ne2000.
In ne2000_receive(), I copied the packet received to a static char [] and printed the packet using
static void print_packet(char *s, int len)
{
int i,j;
for (i=0;i<len;i++) {
if (i%20 == 0)
printf("\n");
printf("%02x ", s[i]);
}
printf("\n");
}
And some bytes it prints as fffffffff<last byte> instead of just the last byte.
For eg:
52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00 00 ffffff80 00 00
40 00 40 01 ffffffbc 2b ffffffc0 ffffffa8 fffffffe fffffffe ffffffc0 ffffffa8 ff
Similarly in ne2000_asic_ioport_read(), I print each word that is read from NetDriverState.s->mem using the following -
printf("\n %02x %02x", (char)(ret &0xff), (char) ( (ret >> 8) && 0xff));
And occasionally I see the 4 bytes printed instead of 1 byte for each value.
Any reason why it happens? Also, ne2000_asic_ioport_read(), reads 6 bytes before reading actual packet? I can think of 4 bytes for CRC but not for the remaining 2 bytes - eg - If pak is -
52 54 00 12 34 56 00 ffffffff 4f 0a 46 05 08 00 45 00 00 ffffff80 00 00
40 00 40 01 ffffffbc 2b
In asic_ioport_read() -
rdw 01 59
rdw 92 00
rdw 52 54
rdw 52 54
rdw 00 12
rdw 34 56
Anyhelp is greatly appreciated.
Thanks
Uma
---------------------------------
Yahoo! Mail
Use Photomail to share photos without annoying attachments.
[-- Attachment #2: Type: text/html, Size: 1904 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-03-04 17:19 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-25 18:29 [Qemu-devel] Printing bogus values in ne2000_asic_ioport_read()/ ne2000_receive() Umamaheswararao Karyampudi
2006-03-01 18:47 ` Joseph Stewart
2006-03-01 23:22 ` Chris Wilson
2006-03-02 10:40 ` Alessandro Iurlano
-- strict thread matches above, loose matches on Subject: below --
2006-03-01 10:06 carlo.andreoli
2006-03-03 22:33 ` Umamaheswararao Karyampudi
2006-02-26 18:01 Umamaheswararao Karyampudi
2006-03-03 19:28 ` Brian Wheeler
2006-02-25 4:13 Umamaheswararao Karyampudi
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).