I am using the gcc cross compiler on a windows machine for an ARM CortexA9 for a bare metal application. For direct memory mapping I need to access the address 0x8000_0000. I use the following C-Code:
#define PORTBASE_A 0x80000000
unsigned int volatile * const portA = (unsigned int *) PORTBASE_A;
#define PORTBASE_B 0x70000000
unsigned int volatile * const portB = (unsigned int *) PORTBASE_B;
#define PORTBASE_C 0x080000000
unsigned int volatile * const portC = (unsigned int *) PORTBASE_C;
printf("Portbase_A %p \n",(unsigned int *) portA); // Portbase_A 0xffffffff80000000
printf("Portbase_B %p \n",(unsigned int *) portB); // Portbase_B 0x70000000
printf("Portbase_C %p \n",(unsigned int *) portC); // Portbase_C 0xffffffff80000000
printf("%d\n", sizeof(unsigned int *)); //4
Using printf("Portbase_A %p \n",(unsigned int *) portA);
leads to the output
Portbase_A 0xffffffff80000000
.
Question
Why do I get 64bit address (0xffffffff80000000) despite the fact that my target machine is a 32-bit machine. I realise that in 0x8000_0000 the leading bit is a one, but why does this result in a 1-padding of 32 leading bits? Is this some sort of an artefact due to cross compilling?
Many thanks for replies.
For completeness this is a visualization of my scatter-file. scatter-file visualisation