Skip to content

Commit

Permalink
Remove unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Jan 24, 2024
1 parent c4ca388 commit eb9dac2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 126 deletions.
36 changes: 0 additions & 36 deletions bootloader/source/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,6 @@ extern unsigned long argSize;
extern unsigned long dsiSD;
extern unsigned long dsiMode;

/*-------------------------------------------------------------------------
passArgs_ARM7
Copies the command line arguments to the end of the ARM9 binary,
then sets a flag in memory for the loaded NDS to use
--------------------------------------------------------------------------*/
void passArgs_ARM7 (void) {
u32 ARM9_DST = *((u32*)(NDS_HEAD + 0x028));
u32 ARM9_LEN = *((u32*)(NDS_HEAD + 0x02C));
u32* argSrc;
u32* argDst;

if (!argStart || !argSize) return;

if ( ARM9_DST == 0 && ARM9_LEN == 0) {
ARM9_DST = *((u32*)(NDS_HEAD + 0x038));
ARM9_LEN = *((u32*)(NDS_HEAD + 0x03C));
}

argSrc = (u32*)(argStart + (int)&_start);

argDst = (u32*)((ARM9_DST + ARM9_LEN + 3) & ~3); // Word aligned

memcpy(argDst, argSrc, argSize);

__system_argv->argvMagic = ARGV_MAGIC;
__system_argv->commandLine = (char*)argDst;
__system_argv->length = argSize;
}

/*-------------------------------------------------------------------------
resetMemory_ARM7
Clears all of the NDS's RAM that is visible to the ARM7
Expand Down Expand Up @@ -224,10 +195,6 @@ int main (void) {
{
return -1;
}
if ((fileCluster < CLUSTER_FIRST) || (fileCluster >= CLUSTER_EOF)) /* Invalid file cluster specified */
{
fileCluster = getBootFileCluster(bootName);
}
if (fileCluster == CLUSTER_FREE)
{
return -1;
Expand Down Expand Up @@ -255,9 +222,6 @@ int main (void) {
// Load the NDS file
loadBinary_ARM7(fileCluster);

// Pass command line arguments to loaded program
passArgs_ARM7();

// Reset SDMC. Required to get bootloader to init things correctly.
sdmmc_controller_init();
*(vu16*)(SDMMC_BASE + REG_SDDATACTL32) &= 0xFFFDu;
Expand Down
90 changes: 0 additions & 90 deletions bootloader/source/fat.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,96 +405,6 @@ bool FAT_InitFiles (bool initCard)
}


/*-----------------------------------------------------------------
getBootFileCluster
-----------------------------------------------------------------*/
u32 getBootFileCluster (const char* bootName)
{
DIR_ENT dir;
int firstSector = 0;
bool notFound = false;
bool found = false;
// int maxSectors;
u32 wrkDirCluster = discRootDirClus;
u32 wrkDirSector = 0;
int wrkDirOffset = 0;
int nameOffset;

dir.startCluster = CLUSTER_FREE; // default to no file found
dir.startClusterHigh = CLUSTER_FREE;


// Check if fat has been initialised
if (discBytePerSec == 0)
{
return (CLUSTER_FREE);
}

char *ptr = (char*)bootName;
while (*ptr != '.') ptr++;
int namelen = ptr - bootName;

// maxSectors = (wrkDirCluster == FAT16_ROOT_DIR_CLUSTER ? (discData - discRootDir) : discSecPerClus);
// Scan Dir for correct entry
firstSector = discRootDir;
CARD_ReadSector (firstSector + wrkDirSector, globalBuffer);
found = false;
notFound = false;
wrkDirOffset = -1; // Start at entry zero, Compensating for increment
while (!found && !notFound) {
wrkDirOffset++;
if (wrkDirOffset == BYTES_PER_SECTOR / sizeof (DIR_ENT))
{
wrkDirOffset = 0;
wrkDirSector++;
if ((wrkDirSector == discSecPerClus) && (wrkDirCluster != FAT16_ROOT_DIR_CLUSTER))
{
wrkDirSector = 0;
wrkDirCluster = FAT_NextCluster(wrkDirCluster);
if (wrkDirCluster == CLUSTER_EOF)
{
notFound = true;
}
firstSector = FAT_ClustToSect(wrkDirCluster);
}
else if ((wrkDirCluster == FAT16_ROOT_DIR_CLUSTER) && (wrkDirSector == (discData - discRootDir)))
{
notFound = true; // Got to end of root dir
}
CARD_ReadSector (firstSector + wrkDirSector, globalBuffer);
}
dir = ((DIR_ENT*) globalBuffer)[wrkDirOffset];
found = true;
if ((dir.attrib & ATTRIB_DIR) || (dir.attrib & ATTRIB_VOL))
{
found = false;
}
if(namelen<8 && dir.name[namelen]!=0x20) found = false;
for (nameOffset = 0; nameOffset < namelen && found; nameOffset++)
{
if (ucase(dir.name[nameOffset]) != bootName[nameOffset])
found = false;
}
for (nameOffset = 0; nameOffset < 3 && found; nameOffset++)
{
if (ucase(dir.ext[nameOffset]) != bootName[nameOffset+namelen+1])
found = false;
}
if (dir.name[0] == FILE_LAST)
{
notFound = true;
}
}

// If no file is found, return CLUSTER_FREE
if (notFound)
{
return CLUSTER_FREE;
}

return (dir.startCluster | (dir.startClusterHigh << 16));
}

/*-----------------------------------------------------------------
fileRead(buffer, cluster, startOffset, length)
-----------------------------------------------------------------*/
Expand Down

0 comments on commit eb9dac2

Please sign in to comment.