Re: PPC Write to memory in Linux
- From: "Rod Pemberton" <do_not_have@xxxxxxxxxxxxx>
- Date: Thu, 11 Oct 2007 18:08:10 -0400
"John" <janzon@xxxxxxxxx> wrote in message
news:1192104713.109395.187190@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 11 Okt, 11:55, John <jan...@xxxxxxxxx> wrote:
Just a thought... Will this be messy to make in user mode? I mean
since
a user mode program is running in it own address space, it complicates
access to memory mapped registers.
I seem to be the only one involved in this discussion, but here we go:
The problem is that you need the IMMR base address so your offsets
from the processor manual makes sense. If you could get hold on it
in userland, and (as root) be allowed to write to it, you could do
something like
int* IMMR_base = ????;
void write_to_addr(int offset, int value) {
int* ptr=IMMR_base;
*(ptr+offset) = value;
}
Any ideas of how to set IMMR_base?
to address such as 0x1404 (Port A 32-bit data register
(You're asking in an assembly group, but I'll take it comp.lang.c redirected
you here since they don't like such questions... ;-) I'm serious. They
don't like such C questions. It's a tragedy. The largest group of C
programmers anywhere around and they won't deal with environment specific C
questions...)
I have no experience with "PowerPC MPC8323 processor". You're asking about
an environment specific extension to C. Specifically, you're asking how to
adjust a C pointer value to access a specific memory address. You can do
this for some compilers but not all. Some of them will require you to use
environment specific or OS calls. Anyway, the code could be very simple
ANSI C or require something specific for your environment. It could be as
simple as:
1) int* IMMR_base = (int *)0x1404;
or
2) #define IMMR_base 0x1404UL
/*...code snipped */
int* ptr=(int *)IMMR_base;
but then, you probably wouldn't be asking about just a missing cast... ;)
I can show you how it's done for other environments *unrelated* to yours.
Only the first is somewhat portable as ANSI C. I'm showing the others for
the *concepts* behind them, but the code is *useless* to you.
1) this example has the physical addresses and virtual addresses the same:
char *scrn2;
scrn2=(char *)0xB8004;
2) this example requires memory addresses to be adjusted by a base address
from their pointer value:
unsigned long address;
unsigned char *stack;
__dpmi_get_segment_base_address(_my_ds(), &base);
address = 0x10000000UL;
stack = (unsigned long *)(address-base);
3) this example requires special functions to access an address:
_farpokew(_dos_ds,0x472,0x0);
4) this example requires special functions to compose an address:
char __far *scrn;
scrn = MK_FP(0xB800,2);
5) this example requires a compiler specific operator ':>' (not ISO C
compliant):
__segment screen;
char __based( void ) * scrptr;
*(screen:>scrptr)='A';
HTH,
Rod Pemberton
.
- Follow-Ups:
- Re: PPC Write to memory in Linux
- From: John
- Re: PPC Write to memory in Linux
- References:
- PPC Write to memory in Linux
- From: John
- Re: PPC Write to memory in Linux
- From: John
- Re: PPC Write to memory in Linux
- From: John
- PPC Write to memory in Linux
- Prev by Date: Re: What Assembly Language Should I Use?
- Next by Date: Re: What Assembly Language Should I Use?
- Previous by thread: Re: PPC Write to memory in Linux
- Next by thread: Re: PPC Write to memory in Linux
- Index(es):
Relevant Pages
|