From: "Guillaume Laurès" <guillaume.laures@noos.fr>
To: linuxppc-dev@lists.linuxppc.org
Subject: Re: another endianness issue...
Date: Sun, 24 Jun 2001 15:59:23 +0200 [thread overview]
Message-ID: <3B35F23B.5030003@noos.fr> (raw)
In-Reply-To: v04220800b75a8da0ed9d@[10.0.0.42]
Timothy A. Seufert wrote:
> Kill the struct definition, and replace it with a bunch of accessor
> macros that mask-and-shift. When moving the register value to or
> from the hardware, use le32_to_cpu() and cpu_to_le32() as appropriate.
Okay, so as this are my first steps in kernel programming, let's take an
example :-)
Somewhere at the beginning of the driver we have something like this:
while (DAC960_LA_InitializationInProgressP(BaseAddress))
{blabla}
DAC960_LA_InitializationInProgressP() is defined as follows in the .h:
static inline
boolean DAC960_BA_InitializationInProgressP(void *ControllerBaseAddress)
{
DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
InboundDoorBellRegister.All =
readb(ControllerBaseAddress + DAC960_BA_InboundDoorBellRegisterOffset);
return !InboundDoorBellRegister.Read.InitializationNotInProgress;
}
and, for the record, the DAC960_BA_InboundDoorBellRegister_T is
something like this:
typedef union DAC960_BA_InboundDoorBellRegister
{
unsigned char All;
struct {
boolean HardwareMailboxNewCommand:1; /* Bit 0 */
boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
boolean GenerateInterrupt:1; /* Bit 2 */
boolean ControllerReset:1; /* Bit 3 */
boolean MemoryMailboxNewCommand:1; /* Bit 4 */
unsigned char :3; /* Bits 5-7 */
} Write;
struct {
boolean HardwareMailboxEmpty:1; /* Bit 0 */
boolean InitializationNotInProgress:1; /* Bit 1 */
unsigned char :6; /* Bits 2-7 */
} Read;
}
DAC960_BA_InboundDoorBellRegister_T;
What would I do now is modify DAC960_LA_InitializationInProgressP() as
follows:
static inline
boolean DAC960_BA_InitializationInProgressP(void *ControllerBaseAddress)
{
unsigned long InboundDoorBellRegister =
le32_to_cpu(ControllerBaseAddress +
DAC960_BA_InboundDoorBellRegisterOffset);
return (boolean) !(InboundDoorBellRegister & 0x0002);
}
Is it correct ?
And where can I find the cpu_to_le32() and le32_to_cpu() declaration or
a guide on how to use them ?
Thanks
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next prev parent reply other threads:[~2001-06-24 13:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3B2E747A.6090607@noos.fr>
[not found] ` <01061823464800.00690@reality.internal>
[not found] ` <3B2F0871.2070304@noos.fr>
[not found] ` <0106192003070C.00609@reality.internal>
2001-06-22 17:12 ` getting the 8600 to boot 2.4.5 Guillaume Laurès
2001-06-24 9:54 ` Michel Lanners
2001-06-24 11:39 ` Takashi Oe
2001-06-23 9:29 ` another endianness issue Guillaume Laurès
2001-06-23 18:19 ` Timothy A. Seufert
2001-06-23 18:33 ` Hollis
2001-06-23 23:22 ` Benjamin Herrenschmidt
2001-06-24 13:59 ` Guillaume Laurès [this message]
2001-06-24 14:50 ` Benjamin Herrenschmidt
2001-06-24 14:52 ` Geert Uytterhoeven
2001-06-24 22:49 ` Dan Malek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3B35F23B.5030003@noos.fr \
--to=guillaume.laures@noos.fr \
--cc=linuxppc-dev@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).