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 > IRQ stack

#103827 - dushan42 - Sun Sep 24, 2006 9:12 pm

Hi!

I've been trying to account for every single byte of my IWRAM usage and I've noticed that the IRQ stack (as defined in the standard Jeff Frohwein link script) starts 0x60 bytes below the top of IWRAM:

Code:
__sp_irq          = __iwram_top - 0x60;


What is this mysterious region between $03007fa0 and $03007ffc for?

I've noticed in VisualBoyAdvance that invoking some software interrupts (e.g. swi 0x06 - integer division) scribbles over some of the area ($03007fd0 - $03007fe0). Any ideas why?

#103841 - poslundc - Sun Sep 24, 2006 10:44 pm

According to GBATEK on interrupt control:

Quote:
Default memory usage at 03007FXX (and mirrored to 03FFFFXX)

Addr. Size Expl.
7FFCh 4 Pointer to user IRQ handler (32bit ARM code)
7FF8h 4 Interrupt Check Flag (for IntrWait/VBlankIntrWait functions)
7FF4h 4 Allocated Area
7FF0h 4 Pointer to Sound Buffer
7FE0h 16 Allocated Area
7FA0h 64 Default area for SP_svc Supervisor Stack (4 words/time)
7F00h 160 Default area for SP_irq Interrupt Stack (6 words/time)

Memory below 7F00h is free for User Stack and user data. The three stack pointers are initially initialized at the TOP of the respective areas:

SP_svc=03007FE0h
SP_irq=03007FA0h
SP_usr=03007F00h



So the non-specific answer to your question is that the area is reserved for BIOS activity from SWI calls.

Dan.

#103852 - dushan42 - Sun Sep 24, 2006 11:44 pm

Good old RTFM :) - thanks for pointing me to GBATEK.