#11069 - Lord Graga - Thu Sep 25, 2003 12:51 pm
Hey all, I am curently trying to write a multiboot loader (for fun ;)
It is a simple menu, but the current version just says the named of the image, and tries to load it.
The theory is based on this quote from the Cowbite specs:
So my procedure is:
- Load the MB image into 0x2000000
- Set 0x3007FFA to 1
- Do a softreset
But somehow, it does not seem to to work (tried both on real GBA and EMU). My explanaition could be:
The branch opcode has 3 bytes to tell CPU where to branch. As neither 0x2000000 or 0x8000000 could be written with 3 bytes, then the CPU adds 0x08 or 0x02 to the start of the instruction, based on the content of 0x3007FFA (Cowbite). However, this does NOT seem to work as it should, is that a bug in the GBA firmware?
Anyway, here is my code:
It is a simple menu, but the current version just says the named of the image, and tries to load it.
The theory is based on this quote from the Cowbite specs:
Quote: |
0x00: SoftReset
Resets the GBA and runs the code at address 0x2000000 or 0x8000000 depending on the contents of 0x3007ffa (0 means 0x8000000 and anything else means 0x2000000). |
So my procedure is:
- Load the MB image into 0x2000000
- Set 0x3007FFA to 1
- Do a softreset
But somehow, it does not seem to to work (tried both on real GBA and EMU). My explanaition could be:
The branch opcode has 3 bytes to tell CPU where to branch. As neither 0x2000000 or 0x8000000 could be written with 3 bytes, then the CPU adds 0x08 or 0x02 to the start of the instruction, based on the content of 0x3007FFA (Cowbite). However, this does NOT seem to work as it should, is that a bug in the GBA firmware?
Anyway, here is my code:
Code: |
void Run(void)
{ u32 i; Write("starting image transfer!",100); for(i=0;i<0xFFFF;i++) *(u16*)(0x2000000+i) = *(u16*)(0x8008000+i); Write("done, starting sleep...",110); for(i=0;i<120;i++) { while(*((volatile unsigned short*)0x04000004) & (1<<0)); while(!((*((volatile unsigned short*)0x04000004) & (1<<0)))); } Write("resetting",120); *(u8*)(0x3007FFA) = 0x1; __asm { swi 0x00 } } |