Date: Sat, 16 Dec 1995 10:43:56 +1100 From: Bruce Evans <bde@zeta.org.au> To: bde@zeta.org.au, davidg@Root.COM Cc: CVS-committers@freefall.freebsd.org, cvs-sys@freefall.freebsd.org Subject: Re: cvs commit: src/sys/i386/isa if_ed.c Message-ID: <199512152343.KAA04105@godzilla.zeta.org.au>
index | next in thread | raw e-mail
>>In this case, I think the casts only work because the hardware ignores >>some bits in the address (bits 14-15 of 0-31 for 16K cards and bits >>13-15 for 8K cards?). Conversions of the form >> >> (int)(buf - base) >> ((int)buf) & 0x3fff >> >>would be more obviously correct, but might be slower. > That's not quite correct. The offset within the NIC memory segment is a 16 >bit number but is written out a byte at a time. The fact that only the lower >two bytes are written out *implies* a masking of the upper bits. This is both >intended and correct. I chose to fix the problem the way I did to avoid Yes, the top 16 bits are masked by not writing out the bytes for them. Bits 14-15 aren't masked. Consider a board with 16K of memory address 0xd4000. Then address 0xd4000 corresponds to offset 0 but offset 0x4000 is written out. This apparently works because bits 14-15 are ignored by the h/w. It wouldn't work for a board with 32K of memory at address 0xd4000 but this is unlikely to be supported since it would take a gate or two more to decode. It wouldn't work if the board used bits 14-15 for something else. To determine the correctnes of the cast, you have to look at the manuals for all supported boards (a growing list :-) and and see if those bits are specified as "don't care". >casting a pointer to a short (which I think is indeed incorrect). It's no worse than casting to int. The result is implementation defined. An unreasonable implementation might always convert to 0... > This driver is highly i386-specific and I'm not trying to generalize it. ... but you can reasonably assume the reasonable gcc i386 implementation in device drivers. Brucehome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199512152343.KAA04105>
