mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 21:52:48 +00:00
potentially fix non-working FIRM builds, remove duplicated cycle wait functions
the sdmmc wait function is exactly the same as the one in the bootrom and worked as a drop in replacement
This commit is contained in:
parent
f835469e19
commit
f96daa407a
2
Makefile
2
Makefile
@ -38,7 +38,7 @@ export CFLAGS := -DDBUILTS="\"$(DBUILTS)\"" -DDBUILTL="\"$(DBUILTL)\"" -DVERSIO
|
|||||||
-g -Os -Wall -Wextra -Wcast-align -Wformat=2 -Wno-main \
|
-g -Os -Wall -Wextra -Wcast-align -Wformat=2 -Wno-main \
|
||||||
-fomit-frame-pointer -ffast-math -std=gnu11 -MMD -MP \
|
-fomit-frame-pointer -ffast-math -std=gnu11 -MMD -MP \
|
||||||
-Wno-unused-function -Wno-format-truncation $(INCLUDE) -ffunction-sections -fdata-sections
|
-Wno-unused-function -Wno-format-truncation $(INCLUDE) -ffunction-sections -fdata-sections
|
||||||
export LDFLAGS := -Tlink.ld -nostartfiles -Wl,--gc-sections,-z,max-page-size=512
|
export LDFLAGS := -Tlink.ld -nostartfiles -Wl,--gc-sections,-z,max-page-size=4096
|
||||||
ELF := arm9/arm9.elf arm11/arm11.elf
|
ELF := arm9/arm9.elf arm11/arm11.elf
|
||||||
|
|
||||||
.PHONY: all firm vram0 elf release clean
|
.PHONY: all firm vram0 elf release clean
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "command_ak2i.h"
|
#include "command_ak2i.h"
|
||||||
#include "protocol_ntr.h"
|
#include "protocol_ntr.h"
|
||||||
#include "card_ntr.h"
|
#include "card_ntr.h"
|
||||||
#include "delay.h"
|
|
||||||
|
|
||||||
u32 AK2I_CmdGetHardwareVersion(void)
|
u32 AK2I_CmdGetHardwareVersion(void)
|
||||||
{
|
{
|
||||||
|
@ -5,18 +5,18 @@
|
|||||||
// modifyed by osilloscopion (2 Jul 2016)
|
// modifyed by osilloscopion (2 Jul 2016)
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <arm.h>
|
||||||
|
|
||||||
#include "command_ntr.h"
|
#include "command_ntr.h"
|
||||||
#include "protocol_ntr.h"
|
#include "protocol_ntr.h"
|
||||||
#include "card_ntr.h"
|
#include "card_ntr.h"
|
||||||
#include "delay.h"
|
|
||||||
|
|
||||||
|
|
||||||
u32 ReadDataFlags = 0;
|
u32 ReadDataFlags = 0;
|
||||||
|
|
||||||
void NTR_CmdReset(void)
|
void NTR_CmdReset(void)
|
||||||
{
|
{
|
||||||
cardReset ();
|
cardReset ();
|
||||||
ioDelay2(0xF000);
|
ARM_WaitCycles(0xF000 * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 NTR_CmdGetCartId(void)
|
u32 NTR_CmdGetCartId(void)
|
||||||
@ -34,7 +34,7 @@ void NTR_CmdReadHeader (u8* buffer)
|
|||||||
{
|
{
|
||||||
REG_NTRCARDROMCNT=0;
|
REG_NTRCARDROMCNT=0;
|
||||||
REG_NTRCARDMCNT=0;
|
REG_NTRCARDMCNT=0;
|
||||||
ioDelay2(167550);
|
ARM_WaitCycles(167550 * 4);
|
||||||
REG_NTRCARDMCNT=NTRCARD_CR1_ENABLE|NTRCARD_CR1_IRQ;
|
REG_NTRCARDMCNT=NTRCARD_CR1_ENABLE|NTRCARD_CR1_IRQ;
|
||||||
REG_NTRCARDROMCNT=NTRCARD_nRESET|NTRCARD_SEC_SEED;
|
REG_NTRCARDROMCNT=NTRCARD_nRESET|NTRCARD_SEC_SEED;
|
||||||
while(REG_NTRCARDROMCNT&NTRCARD_BUSY) ;
|
while(REG_NTRCARDROMCNT&NTRCARD_BUSY) ;
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
// Copyright 2014 Normmatt
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
void ioDelay(u32 us);
|
|
||||||
void ioDelay2(u32 us);
|
|
@ -1,27 +0,0 @@
|
|||||||
// Copyright 2014 Normmatt
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
.arm
|
|
||||||
.global ioDelay
|
|
||||||
.type ioDelay STT_FUNC
|
|
||||||
|
|
||||||
@ioDelay ( u32 us )
|
|
||||||
ioDelay:
|
|
||||||
ldr r1, =0x18000000 @ VRAM
|
|
||||||
1:
|
|
||||||
@ Loop doing uncached reads from VRAM to make loop timing more reliable
|
|
||||||
ldr r2, [r1]
|
|
||||||
subs r0, #1
|
|
||||||
bgt 1b
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
.global ioDelay2
|
|
||||||
.type ioDelay2 STT_FUNC
|
|
||||||
|
|
||||||
@ioDelay2 ( u32 us )
|
|
||||||
ioDelay2:
|
|
||||||
1:
|
|
||||||
subs r0, #1
|
|
||||||
bgt 1b
|
|
||||||
bx lr
|
|
@ -7,8 +7,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <arm.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "delay.h"
|
|
||||||
|
|
||||||
#define u8 uint8_t
|
#define u8 uint8_t
|
||||||
#define u16 uint16_t
|
#define u16 uint16_t
|
||||||
@ -85,7 +85,7 @@
|
|||||||
#define CARD_SPICNTH_ENABLE (1<<7) // in byte 1, i.e. 0x8000
|
#define CARD_SPICNTH_ENABLE (1<<7) // in byte 1, i.e. 0x8000
|
||||||
#define CARD_SPICNTH_IRQ (1<<6) // in byte 1, i.e. 0x4000
|
#define CARD_SPICNTH_IRQ (1<<6) // in byte 1, i.e. 0x4000
|
||||||
|
|
||||||
#define swiDelay(n) ioDelay(n)
|
#define swiDelay(n) ARM_WaitCycles((n) * 8)
|
||||||
|
|
||||||
#define DMA_SRC(n) (*(vu32*)(0x10002004 + (n * 0x1c)))
|
#define DMA_SRC(n) (*(vu32*)(0x10002004 + (n * 0x1c)))
|
||||||
#define DMA_DEST(n) (*(vu32*)(0x10002008 + (n * 0x1c)))
|
#define DMA_DEST(n) (*(vu32*)(0x10002008 + (n * 0x1c)))
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <arm.h>
|
||||||
|
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
@ -14,7 +16,6 @@
|
|||||||
#include "protocol_ntr.h"
|
#include "protocol_ntr.h"
|
||||||
#include "command_ctr.h"
|
#include "command_ctr.h"
|
||||||
#include "command_ntr.h"
|
#include "command_ntr.h"
|
||||||
#include "delay.h"
|
|
||||||
|
|
||||||
// could have been done better, but meh...
|
// could have been done better, but meh...
|
||||||
#define REG_AESCNT (*(vu32*)0x10009000)
|
#define REG_AESCNT (*(vu32*)0x10009000)
|
||||||
@ -177,7 +178,7 @@ void Cart_Secure_Init(u32 *buf, u32 *out)
|
|||||||
// if (!mac_valid)
|
// if (!mac_valid)
|
||||||
// ClearScreen(bottomScreen, RGB(255, 0, 0));
|
// ClearScreen(bottomScreen, RGB(255, 0, 0));
|
||||||
|
|
||||||
ioDelay(0xF0000);
|
ARM_WaitCycles(0xF0000 * 8);
|
||||||
|
|
||||||
CTR_SetSecKey(A0_Response);
|
CTR_SetSecKey(A0_Response);
|
||||||
CTR_SetSecSeed(out, true);
|
CTR_SetSecSeed(out, true);
|
||||||
@ -207,7 +208,7 @@ void Cart_Secure_Init(u32 *buf, u32 *out)
|
|||||||
|
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
CTR_SendCommand(A2_cmd, 4, 1, 0x701002C, &test);
|
CTR_SendCommand(A2_cmd, 4, 1, 0x701002C, &test);
|
||||||
ioDelay(0xF0000);
|
ARM_WaitCycles(0xF0000 * 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <arm.h>
|
||||||
|
|
||||||
#include "protocol_ctr.h"
|
#include "protocol_ctr.h"
|
||||||
|
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "delay.h"
|
|
||||||
#ifdef VERBOSE_COMMANDS
|
#ifdef VERBOSE_COMMANDS
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#endif
|
#endif
|
||||||
@ -143,7 +144,7 @@ void CTR_SendCommand(const u32 command[4], u32 pageSize, u32 blocks, u32 latency
|
|||||||
// so we have to wait next data ready
|
// so we have to wait next data ready
|
||||||
do { cardCtrl = REG_CTRCARDCNT; } while(!(cardCtrl & CTRCARD_DATA_READY));
|
do { cardCtrl = REG_CTRCARDCNT; } while(!(cardCtrl & CTRCARD_DATA_READY));
|
||||||
// and this tiny delay is necessary
|
// and this tiny delay is necessary
|
||||||
ioDelay(33);
|
ARM_WaitCycles(33 * 8);
|
||||||
// pull ROM CS high
|
// pull ROM CS high
|
||||||
REG_CTRCARDCNT = 0x10000000;
|
REG_CTRCARDCNT = 0x10000000;
|
||||||
REG_CTRCARDCNT = CTRKEY_PARAM | CTRCARD_ACTIVATE | CTRCARD_nRESET;
|
REG_CTRCARDCNT = CTRKEY_PARAM | CTRCARD_ACTIVATE | CTRCARD_nRESET;
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "card_ntr.h"
|
#include "card_ntr.h"
|
||||||
// #include "draw.h"
|
// #include "draw.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "delay.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define BSWAP32(val) ((((val >> 24) & 0xFF)) | (((val >> 16) & 0xFF) << 8) | (((val >> 8) & 0xFF) << 16) | ((val & 0xFF) << 24))
|
#define BSWAP32(val) ((((val >> 24) & 0xFF)) | (((val >> 16) & 0xFF) << 8) | (((val >> 8) & 0xFF) << 16) | ((val & 0xFF) << 24))
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
* along with this program. If not, see http://www.gnu.org/licenses/.
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <arm.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "wait.h"
|
|
||||||
#include "sdmmc.h"
|
#include "sdmmc.h"
|
||||||
|
|
||||||
#define DATA32_SUPPORT
|
#define DATA32_SUPPORT
|
||||||
@ -469,7 +469,7 @@ int SD_Init()
|
|||||||
|
|
||||||
// We need to send at least 74 clock pulses.
|
// We need to send at least 74 clock pulses.
|
||||||
set_target(&handleSD);
|
set_target(&handleSD);
|
||||||
wait(2 * 128 * 74);
|
ARM_WaitCycles(2 * 128 * 74);
|
||||||
|
|
||||||
sdmmc_send_command(&handleSD,0,0);
|
sdmmc_send_command(&handleSD,0,0);
|
||||||
sdmmc_send_command(&handleSD,0x10408,0x1AA);
|
sdmmc_send_command(&handleSD,0x10408,0x1AA);
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
void wait(u32 cycles);
|
|
@ -1,10 +0,0 @@
|
|||||||
.text
|
|
||||||
.arm
|
|
||||||
.align 4
|
|
||||||
|
|
||||||
.global wait
|
|
||||||
.type wait, %function
|
|
||||||
wait:
|
|
||||||
subs r0, r0, #4
|
|
||||||
bcs wait
|
|
||||||
bx lr
|
|
Loading…
x
Reference in New Issue
Block a user