I am doing a code, a SO, in c++.. all is everything ok, but the run code loaded in memory its a pain in the neck, not working...
I am loading simple code, in memory location 0x00800000 (inside ram memory of 512MB)...
the code loaded is here:
Code: Select all
00000000 <_start>:
0: e92d4010 push {r4, lr}
4: eb000002 bl 14 <mainprog>
8: e8bd8010 pop {r4, pc}
c: e12fff1e bx lr
00000010 <dummy>:
10: e12fff1e bx lr
00000014 <mainprog>:
14: e12fff1e bx lr
I do the EXACT code, in c function inside de OS, exact, below:
Code: Select all
void newOS::appcod(void)
{
asm (
"push {r4, lr};"
"bl mainprogappcod;"
"pop {r4, pc};"
"bx lr;"
"dummyappcod:"
"bx lr;"
"mainprogappcod:"
"bx lr;"
);
}
The code inside OS, run without problem, fine, but the code loaded at 0x00800000, that is the SAME, not work, crash, halt the system... why?
the routine that i am using to call the code loade is below:
Code: Select all
uint32_t addr = 0x00800000;
appcod(); // to demonstrate that exact adm code, with the exact arm code works inside OS as function
addr = (uint32_t)pi_phys_to_user((void*) addr);
printf("0x%08X\n", addr); // demonstre that is 0x00800000
{
typedef void func_t(void);
func_t* progrun = (func_t*)(void*) addr;
progrun();
}
EDIT 1: I try to load at other address (like 0x00020000), and the loaded program not work too... crash... what i not uderstand is why the same asm code generating the same arm code, only in the diferent locations, not work... that is insane for me... I worked with 68000, z80, pic (16f, 18f, 32f) and this is not happens, cpu code is cpu code....
EDIT 2: The code that i loading at 0x00800000 is a bin file, just the same code generated in function inside c function, the contens is below:
Code: Select all
1040 2de9 0200 00eb 1080 bde8 1eff 2fe1
1eff 2fe1 1eff 2fe1 6530 a0e3 0130 53e2
fdff ff1a 1eff 2fe1 2f75 7372 2f6c 6962
2f6c 642e 736f 2e31 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0300 0100 0000 0000
0100 0000 0200 0000 0000 0000 0000 0000
0000 0000 0400 0000 6000 0000 0500 0000
5c00 0000 0600 0000 3c00 0000 0a00 0000
0100 0000 0b00 0000 1000 0000 1500 0000
0000 0000 fbff ff6f 0000 0008 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 7400 0000
0000 0000 0000 0000
Moacir Jr.