Feeling kind of stupid about pointers

P

PullnOutHair

I know that I should know how to do this, but for some reason it is
escapeing me right now and I was hoping someone here could help. I
need to setup a pointer to the memory location 0x30000000. I am
working on a linux system that has hardware inputs remapped to that
address and I have to read them. I am just drawing a blank on how to
actually assign the address of a pointer to point to.
 
R

red floyd

PullnOutHair said:
I know that I should know how to do this, but for some reason it is
escapeing me right now and I was hoping someone here could help. I
need to setup a pointer to the memory location 0x30000000. I am
working on a linux system that has hardware inputs remapped to that
address and I have to read them. I am just drawing a blank on how to
actually assign the address of a pointer to point to.

You don't do it in userland. That said.


assert(sizeof(void*) >= sizeof(unsigned long))
void* ptr = reinterpret_cast<void*>(0x30000000UL);
 
I

Ioannis Vranos

PullnOutHair said:
I know that I should know how to do this, but for some reason it is
escapeing me right now and I was hoping someone here could help. I
need to setup a pointer to the memory location 0x30000000. I am
working on a linux system that has hardware inputs remapped to that
address and I have to read them. I am just drawing a blank on how to
actually assign the address of a pointer to point to.



Assuming that the platform will allow you, and assuming the pointer is
of type whatever, you can do:



whatever *p = reinterpret_cast<whatever *>(0x30000000);






Regards,

Ioannis Vranos

http://www23.brinkster.com/noicys
 
R

red floyd

JKop said:
Ioannis Vranos posted:


Should the "volatile" keyword be in there at all?

-JKop

Depends on whether it's data that can change out from underneath him.

My favorite variant of this (embedded system, C, not C++) was:

const volatile unsigned long * const PREGISTER =
(const volatile unsigned long *) 0xC0000000L;

It was a read-only memory mapped register.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top