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.

DS development > Can DLDI drivers corrupt/allocate memory?

#149532 - simonjhall - Mon Jan 21, 2008 8:19 pm

Sup.
I've noticed that some people can't seem to run stuff I've written when they patch their binaries with certain DLDI drivers. I can't replicate these issues myself but they do seem to be replicatable problems. For instance with QDS r3 some people 'ran out of memory' directly after the fat driver has been initialised and the game heap allocated.
Since the heap should be exactly the same size regardless of the patch applied (right?), this shouldn't happen. When tried on a different flash card and a different driver the game runs fine.
I'm also getting similar problems with a certain other flash card with Q2 where if that DLDI driver is used (in this case a neoflash card) the game can't allocate enough memory.

Has anyone else seen problems like this?
Drivers can't call malloc, can they? Does fatInit allocate a different amount of memory based on a result from the driver?

Btw: having a look in the neoflash code they're using globals by just pulling addresses out of the air, eg at the top of the main source. Hmm.
_________________
Big thanks to everyone who donated for Quake2

#149536 - Lazy1 - Mon Jan 21, 2008 8:46 pm

I notice that wolfenstein displays garbled graphics, crashes and probably both if the DLDI driver does not support unaligned reads.
Not sure if that's your problem though.

#149543 - simonjhall - Mon Jan 21, 2008 10:01 pm

Yeah probably unrelated. But on that note, any idea of what alignments fail? I'd imagine anything with less than word alignment if the code uses a loops that copy 32 bits at a time, or less than halfword alignment if DMA is in use.
Any drivers that stick in your mind?
_________________
Big thanks to everyone who donated for Quake2

#149581 - chishm - Tue Jan 22, 2008 9:57 am

Drivers can't allocate memory on the heap at all - there is no malloc available to DLDI drivers. They can only use stack and the memory within their allocated space. Check to make sure you aren't running out of stack.

You may be having problems with the flash card's NDS loader as well - I'd check by using WMB or the other slot to load the NDS and see if that works. This requires a DLDI that doesn't really on the flash card to init the memory card, unfortunately.

I know that at least one card (the CycloDS) used to patch its own driver into the NDS by putting it at the end of EXRAM. This was before DLDI, however, and shouldn't be happening now.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#149608 - simonjhall - Tue Jan 22, 2008 7:46 pm

Okey doke. I'll have to get someone who has these problems to do more detailed testing for me...
_________________
Big thanks to everyone who donated for Quake2

#149615 - ingramb - Tue Jan 22, 2008 8:37 pm

The ninjapass x9 dldi driver used to have very large (+4kb) data allocated on the stack. This caused big problems for me with lots of data inside the dtcm. I contacted the author, and he fixed the problem, but it's possible other dldi drivers could have similar issues.

Anyway, it's a way for certain dldi drivers to mess up your program.