Skip to content

Commit d07e6ad

Browse files
authored
Merge pull request #27 from samueldr/feature/initrd-support
Add basic initrd support
2 parents 4098b02 + af406f4 commit d07e6ad

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

arm9/include/fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ const char* GetWorkDir();
1313
/** Checks if there is enough space free on the SD card **/
1414
bool DebugCheckFreeSpace(size_t required);
1515

16+
/** Checks path exists */
17+
bool FileExists(const char* path);
18+
1619
/** Opens existing files */
1720
bool FileOpen(const char* path);
1821
bool DebugFileOpen(const char* path);

arm9/source/fs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ bool DebugCheckFreeSpace(size_t required)
4848
return true;
4949
}
5050

51+
bool FileExists(const char* path)
52+
{
53+
FILINFO fno;
54+
55+
return f_stat(path, &fno) == FR_OK;
56+
}
57+
58+
5159
bool FileOpen(const char* path)
5260
{
5361
unsigned flags = FA_READ | FA_WRITE | FA_OPEN_EXISTING;

arm9/source/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ int main(int argc, char *argv[])
7474
goto error;
7575
}
7676

77+
if (FileExists(INITRAMFS_FILENAME)) {
78+
if (!load_file(INITRAMFS_FILENAME, INITRAMFS_ADDR)) {
79+
Debug("Failed to load " INITRAMFS_FILENAME);
80+
goto error;
81+
}
82+
}
83+
else {
84+
Debug("Note: initramfs file not present (" INITRAMFS_FILENAME ")");
85+
}
86+
7787
dtb_filename = is_lgr() ? KTR_DTB_FILENAME : CTR_DTB_FILENAME;
7888
if (!load_file(dtb_filename, DTB_ADDR)) {
7989
Debug("Failed to load %s", dtb_filename);

common/linux_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/* Linux settings */
22
#define DTB_ADDR (0x20000000)
33
#define ZIMAGE_ADDR (0x20008000)
4+
#define INITRAMFS_ADDR (0x27800000)
45
#define MACHINE_NUMBER (0xFFFFFFFF)
56
#define ARM9LINUXFW_ADDR (0x08080000)
67
#define SYNC_ADDR (0x1FFFFFF0)
78

89
#define LINUXIMAGE_FILENAME "linux/zImage"
10+
#define INITRAMFS_FILENAME "linux/initramfs.cpio.gz"
911
#define CTR_DTB_FILENAME "linux/nintendo3ds_ctr.dtb"
1012
#define KTR_DTB_FILENAME "linux/nintendo3ds_ktr.dtb"
1113
#define ARM9LINUXFW_FILENAME "linux/arm9linuxfw.bin"

0 commit comments

Comments
 (0)