diff --git a/include/arm11/hardware/hardware.h b/include/arm11/hardware/hardware.h deleted file mode 100644 index 9fa3d6b..0000000 --- a/include/arm11/hardware/hardware.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -/* - * This file is part of fastboot 3DS - * Copyright (C) 2017 derrek, profi200 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - - -void hardwareInit(void); -//void hardwareDeinit(void); diff --git a/include/arm9/hardware/hardware.h b/include/arm9/hardware/hardware.h deleted file mode 100644 index 9fa3d6b..0000000 --- a/include/arm9/hardware/hardware.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -/* - * This file is part of fastboot 3DS - * Copyright (C) 2017 derrek, profi200 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - - -void hardwareInit(void); -//void hardwareDeinit(void); diff --git a/source/arm11/hardware/hardware.c b/source/arm11/hardware/hardware.c deleted file mode 100644 index 53c11dc..0000000 --- a/source/arm11/hardware/hardware.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of fastboot 3DS - * Copyright (C) 2017 derrek, profi200 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "types.h" -#include "arm11/start.h" -#include "arm11/hardware/interrupt.h" -#include "arm11/hardware/timer.h" -#include "arm11/hardware/i2c.h" -#include "hardware/pxi.h" -#include "arm11/hardware/hid.h" - - - -void hardwareInit(void) -{ - IRQ_init(); - TIMER_init(); - - if(!getCpuId()) - { - I2C_init(); - hidInit(); - PXI_init(); - } - else - { - // We don't need core 1 yet so back it goes into boot11. - deinitCpu(); - ((void (*)(void))0x0001004C)(); - } - - leaveCriticalSection(0); // Enables interrupts -} - -/*void hardwareDeinit(void) -{ -}*/ diff --git a/source/arm11/main.c b/source/arm11/main.c index 0cf912e..8f0365a 100644 --- a/source/arm11/main.c +++ b/source/arm11/main.c @@ -18,7 +18,6 @@ #include #include "types.h" -#include "arm11/hardware/hardware.h" #include "arm11/hardware/hid.h" #include "arm11/menu/bootslot.h" #include "arm11/menu/menu.h" @@ -49,8 +48,7 @@ char* err_string = NULL; - // init hardware / filesystem / load config - hardwareInit(); + // filesystem / load config fsMountSdmc(); fsMountNandFilesystems(); loadConfigFile(); diff --git a/source/arm11/start.s b/source/arm11/start.s index a8ddf28..191eef5 100644 --- a/source/arm11/start.s +++ b/source/arm11/start.s @@ -46,6 +46,7 @@ .extern fake_heap_end .extern setupMmu .extern __libc_init_array +.extern systemInit .extern main .section ".crt0", "ax" @@ -145,6 +146,7 @@ clrex cpsie a + blx systemInit mov r0, #0 @ argc mov r1, #0 @ argv blx main diff --git a/source/arm11/system.c b/source/arm11/system.c new file mode 100644 index 0000000..aac1e91 --- /dev/null +++ b/source/arm11/system.c @@ -0,0 +1,48 @@ +/* + * This file is part of fastboot 3DS + * Copyright (C) 2017 derrek, profi200 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "types.h" +#include "arm11/start.h" +#include "arm11/hardware/interrupt.h" +#include "arm11/hardware/timer.h" +#include "arm11/hardware/i2c.h" +#include "hardware/pxi.h" +#include "arm11/hardware/hid.h" + + + +void systemInit(void) +{ + IRQ_init(); + TIMER_init(); + + if(!getCpuId()) + { + I2C_init(); + hidInit(); + PXI_init(); + } + else + { + // We don't need core 1 yet so back it goes into boot11. + deinitCpu(); + ((void (*)(void))0x0001004C)(); + } + + leaveCriticalSection(0); // Enables interrupts +} diff --git a/source/arm9/hardware/hardware.c b/source/arm9/hardware/hardware.c deleted file mode 100644 index ff58c3c..0000000 --- a/source/arm9/hardware/hardware.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of fastboot 3DS - * Copyright (C) 2017 derrek, profi200 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "types.h" -#include "arm9/hardware/interrupt.h" -#include "arm9/hardware/ndma.h" -#include "arm9/hardware/timer.h" -#include "hardware/pxi.h" -#include "arm9/hardware/crypto.h" - - - -void hardwareInit(void) -{ - IRQ_init(); - NDMA_init(); - TIMER_init(); - PXI_init(); - AES_init(); - RSA_init(); - - leaveCriticalSection(0); // Enables interrupts -} - -/*void hardwareDeinit(void) -{ -}*/ diff --git a/source/arm9/main.c b/source/arm9/main.c index 2f52622..5885cff 100644 --- a/source/arm9/main.c +++ b/source/arm9/main.c @@ -18,7 +18,6 @@ #include "types.h" #include "mem_map.h" -#include "arm9/hardware/hardware.h" #include "arm9/debug.h" #include "arm9/hardware/interrupt.h" #include "arm9/firm.h" @@ -30,7 +29,6 @@ int main(void) { - hardwareInit(); debugHashCodeRoData(); while(!g_startFirmLaunch) __wfi(); diff --git a/source/arm9/start.s b/source/arm9/start.s index 372abf0..d4d72d7 100644 --- a/source/arm9/start.s +++ b/source/arm9/start.s @@ -41,6 +41,7 @@ .extern fake_heap_start .extern fake_heap_end .extern __libc_init_array +.extern systemInit .extern main .extern irqHandler .extern undefInstrHandler @@ -109,6 +110,7 @@ str r0, [r1] blx __libc_init_array @ Initialize ctors and dtors + blx systemInit mov r0, #0 @ argc mov r1, #0 @ argv blx main diff --git a/source/arm9/system.c b/source/arm9/system.c new file mode 100644 index 0000000..d356002 --- /dev/null +++ b/source/arm9/system.c @@ -0,0 +1,38 @@ +/* + * This file is part of fastboot 3DS + * Copyright (C) 2017 derrek, profi200 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "types.h" +#include "arm9/hardware/interrupt.h" +#include "arm9/hardware/ndma.h" +#include "arm9/hardware/timer.h" +#include "hardware/pxi.h" +#include "arm9/hardware/crypto.h" + + + +void systemInit(void) +{ + IRQ_init(); + NDMA_init(); + TIMER_init(); + PXI_init(); + AES_init(); + RSA_init(); + + leaveCriticalSection(0); // Enables interrupts +}