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 > How to tell if a given DLDI driver is for a slot-2 card

#141143 - simonjhall - Sat Sep 22, 2007 2:43 pm

Is there any way to find out from a dldi driver which slot its card lives in?
Can you get a string back from the driver which you can match against "Supercard", "M3" etc? Or is there some isSlotTwo() function?

EDIT: btw I mean doing this at run time, not before patching
_________________
Big thanks to everyone who donated for Quake2

#141154 - tepples - Sat Sep 22, 2007 6:35 pm

Last time I asked Chishm about this, back in the pak-swapping topic that I made before I made RAC, he told me something like this: If diropen tells you that "fat1:/" is mounted, then a SLOT-1 card is present and mounted at "fat:/". Otherwise, "fat:/" is a SLOT-2 card if anything.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#141197 - chishm - Sun Sep 23, 2007 3:44 am

The dev_t field of the stat struct returned by fstat() and stat() will contain a 32 bit value that should be unique to each type of card, taken from the ioType field of the driver's header. This value can be cast to a char[4] and displayed as a simple identifier. For example, the GBAMP CF version 2 has the identifier MPCF, whereas the M3 SD has M3SD. This will also work for the built-in (i.e. not DLDI) drivers.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#141228 - simonjhall - Sun Sep 23, 2007 10:03 am

Ah cool. Wouldn't that then require me to match the string against a list of pre-known driver names, to figure out which ones are in the bottom slot?

In the end I wrote a dash of code to find the dldi section's magic number, move up 0x64 bytes then pick out the driver info (eg can read / write, slot no etc) but I'm wondering how compatible this will be if you ever change the header format...
_________________
Big thanks to everyone who donated for Quake2

#141345 - chishm - Mon Sep 24, 2007 9:24 am

You can match the identifier of fat:/ to the one of fat2:/. If they match, then the card in SLOT-2 was set as the default. If it doesn't match, or if fat2:/ doesn't exist, then it wasn't set as default.

Basically, fat:/ is fat0:/ is the default, fat1:/ is always the card in SLOT-1 and fat2:/ is always the cart in SLOT-2.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#141346 - simonjhall - Mon Sep 24, 2007 9:51 am

Ah, that sounds easy - thanks very much!
Btw what's with the deep message in the sig? ;-)
_________________
Big thanks to everyone who donated for Quake2

#141347 - chishm - Mon Sep 24, 2007 10:38 am

The poetic results of a neural network.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com