Re: PPC Write to memory in Linux




"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

.



Relevant Pages

  • Re: C++ in the kernel
    ... M68K based STB with only 1.5 MB or flash and 1.5MB of RAM and no disks. ... What we got for that one engineers effort was a development environment ... STL is surprisingly damn useful. ... STL chunking of memory needs to be looked at, ...
    (freebsd-arch)
  • Re: Cobol data protection? Get a dog...
    ... I use win32 APIs to LOCK the memory heaps? ... This problem is universal and is not restricted to a COBOL caller. ... The submodule needs an address to do damage. ... You use the phrase 'open environment' I will let you define that so folks can ...
    (comp.lang.cobol)
  • VMWare ESX and FBSD 7.2 AMD64 guest
    ... two processors, and 8GB of memory. ... running with the exact same environment. ... I'd appreciate any feedback on tweaks that I can make (either to VMWare, ... or FreeBSD itself) to make the virtualized environment much more efficient. ...
    (freebsd-questions)
  • Re: Cool visual illusion
    ... > the environment which is important to a machine ... states (memory). ... product of our histories is a load of crock. ... It could be said that learning itself is a reward. ...
    (comp.ai.philosophy)
  • Re: Levicorpus -- SPOILERS
    ... I never assumed that the term "Snape's worst memory" ... Troels Forchhammer ... 'She complicates this whole business, ...
    (alt.fan.harry-potter)