gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Writing a Multiboot loader

#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:
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
   }
}

#11073 - tepples - Thu Sep 25, 2003 2:42 pm

downtou.cjb.net had multiboot code before it died. I wrote my own working multiboot code based on its concepts. It's not polished enough to be put on my main web site, but here's the code anyway.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#11074 - Lord Graga - Thu Sep 25, 2003 2:48 pm

I am not making a program that sends data to another GBA, but a program that works like a menu! (Like Pogoshell, but more simple)

#11075 - tepples - Thu Sep 25, 2003 3:50 pm

in that case, you want a .mb menu. I've made one of those too.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.