From: Eugene Surovegin <ebs@ebshome.net>
To: linuxppc-embedded@lists.linuxppc.org
Subject: [RFC] "indirect" DCR access (40x, BookE)
Date: Thu, 11 Mar 2004 17:48:00 -0800 [thread overview]
Message-ID: <20040312014800.GA25455@gate.ebshome.net> (raw)
Hello all!
As some people know using DCR is sometimes PITA ;-).
The reason is simple, DCR number is encoded in instruction itself, so
one cannot write code like:
for (i = 0; i < LAST_REG; ++i)
mtdcr(DCR_XXX_BASE + i, 0);
Because of this limitation we have to use a lot of ugly #ifdefs and/or
explicit switch/if statements when accessing DCR from device drivers
(see for example include/asm-ppc/ppc405-dma.h,
drivers/net/ibm_emac/ibm_ocp_mal.c (2.4 tree), etc)
There is a simple solution for this problem (I'm sure everybody
thought of this one, but just didn't have time to code it :).
This approach trades space (16K of code) for convenience.
Here is the short snippet which demonstrates the idea (full patch is
quite big and can be found at http://kernel.ebshome.net/dcr-2.6.diff):
#define DCR_ACCESS_PROLOG(table) \
rlwinm r3,r3,4,18,27; \
lis r5,table@h; \
ori r5,r5,table@l; \
add r3,r3,r5; \
mtctr r3; \
bctr
_GLOBAL(__mfdcr)
DCR_ACCESS_PROLOG(__mfdcr_table)
_GLOBAL(__mtdcr)
DCR_ACCESS_PROLOG(__mtdcr_table)
__mfdcr_table:
mfdcr r3,0; blr
__mtdcr_table:
mtdcr 0,r4; blr
mfdcr r3,1; blr
mtdcr 1,r4; blr
mfdcr r3,2; blr
mtdcr 2,r4; blr
mfdcr r3,3; blr
....
I grouped reading & writing of the same DCR together to make these
functions more cache friendly. I'm not sure about the names, though
:).
This patch is against 2.6, I can easily make for 2.4 as well if there
is an interest.
Please note, I'm not proposing _removing_ current "mfdcr/mtdcr"
macros, they have their use. These "indirect" versions can be used in
some drivers to get more clean and readable code.
Comments, suggestions are welcome.
Thanks,
Eugene
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
next reply other threads:[~2004-03-12 1:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-12 1:48 Eugene Surovegin [this message]
2004-03-12 2:46 ` [RFC] "indirect" DCR access (40x, BookE) Dan Malek
2004-03-12 3:05 ` Eugene Surovegin
2004-03-12 4:44 ` Stephen Williams
2004-03-12 4:54 ` Eugene Surovegin
2004-03-12 14:25 ` Kumar Gala
2004-03-12 14:53 ` Chuck Meade
2004-03-12 16:20 ` Eugene Surovegin
2004-03-12 18:01 ` Dan Malek
2004-03-19 4:00 ` Benjamin Herrenschmidt
2004-03-23 2:47 ` Eugene Surovegin
2004-04-01 5:36 ` Kumar Gala
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=20040312014800.GA25455@gate.ebshome.net \
--to=ebs@ebshome.net \
--cc=linuxppc-embedded@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).