kernel: increase stack size to 12 kB on SH4 fx-9860G

BFile calls on the G-III series can overflow an 8 kB stack, overriding
the VBR which is located just before (!).
This commit is contained in:
Lephe 2021-12-05 21:15:41 +01:00
parent b7173a5109
commit 86fad757e1
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

View file

@ -39,15 +39,18 @@ void kinit(void)
#ifdef FX9860G
/* On fx-9860G, VBR is loaded at the end of the user RAM. On SH4, the
end of the user RAM hosts the stack, for which we leave 8 kB
(0x2000 bytes). The VBR space takes about 0x600 bytes on SH3 due to
end of the user RAM hosts the stack, for which we leave 12 kB
(0x3000 bytes). The VBR space takes about 0x600 bytes on SH3 due to
the compact scheme, while it uses about 0x1100 bytes for the whole
expanded region. */
uint32_t uram_end = (uint32_t)mmu_uram() + mmu_uram_size();
if(isSH4()) uram_end -= 0x2000;
uram_end -= (isSH3() ? 0x600 : 0x1100);
/* Stack space on SH4. 12 kB is a lot, but BFile is known to overflow
from the previous 8 kB design */
if(isSH4()) uram_end -= 0x3000;
/* VBR is advanced 0x100 bytes because of an unused gap */
uram_end -= (isSH3() ? 0x600 : 0x1100);
VBR = uram_end - 0x100;
#endif /* FX9860G */