Skip to content

Commit 3fcd257

Browse files
committed
Temporarily revert "full A9NC support" because that borked SDless boot
This reverts commit 8e5cca1.
1 parent 8e5cca1 commit 3fcd257

File tree

5 files changed

+451
-757
lines changed

5 files changed

+451
-757
lines changed

payload_stage2/source/fatfs/diskio.c

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include "sdmmc/sdmmc.h"
1212
#include "../crypto.h"
1313

14+
/* Definitions of physical drive number for each media */
15+
#define SDCARD 0
16+
#define CTRNAND 1
1417

1518
/*-----------------------------------------------------------------------*/
1619
/* Get Drive Status */
@@ -31,12 +34,20 @@ DSTATUS disk_status (
3134
/*-----------------------------------------------------------------------*/
3235

3336
DSTATUS disk_initialize (
34-
__attribute__((unused))
3537
BYTE pdrv /* Physical drive nmuber to identify the drive */
3638
)
3739
{
38-
if (!sdmmc_sdcard_init())
39-
return RES_PARERR;
40+
static u32 sdmmcInited = 0;
41+
42+
if(!sdmmcInited)
43+
{
44+
sdmmc_sdcard_init();
45+
sdmmcInited = 1;
46+
}
47+
48+
if(pdrv == CTRNAND)
49+
ctrNandInit();
50+
4051
return RES_OK;
4152
}
4253

@@ -47,18 +58,25 @@ DSTATUS disk_initialize (
4758
/*-----------------------------------------------------------------------*/
4859

4960
DRESULT disk_read (
50-
__attribute__((unused))
5161
BYTE pdrv, /* Physical drive nmuber to identify the drive */
5262
BYTE *buff, /* Data buffer to store read data */
5363
DWORD sector, /* Sector address in LBA */
5464
UINT count /* Number of sectors to read */
5565
)
5666
{
57-
if (sdmmc_sdcard_readsectors(sector, count, buff)) {
58-
return RES_PARERR;
59-
}
60-
61-
return RES_OK;
67+
switch(pdrv)
68+
{
69+
case SDCARD:
70+
if(sdmmc_sdcard_readsectors(sector, count, (BYTE *)buff))
71+
return RES_PARERR;
72+
break;
73+
case CTRNAND:
74+
if(ctrNandRead(sector, count, (BYTE *)buff))
75+
return RES_PARERR;
76+
break;
77+
}
78+
79+
return RES_OK;
6280
}
6381

6482

@@ -71,16 +89,15 @@ DRESULT disk_read (
7189
DRESULT disk_write (
7290
__attribute__((unused))
7391
BYTE pdrv, /* Physical drive nmuber to identify the drive */
74-
const BYTE *buff, /* Data to be written */
92+
__attribute__((unused))
93+
const BYTE *buff, /* Data to be written */
94+
__attribute__((unused))
7595
DWORD sector, /* Sector address in LBA */
96+
__attribute__((unused))
7697
UINT count /* Number of sectors to write */
7798
)
7899
{
79-
if (sdmmc_sdcard_writesectors(sector, count, (BYTE *)buff)) {
80-
return RES_PARERR;
81-
}
82-
83-
return RES_OK;
100+
return RES_OK;
84101
}
85102
#endif
86103

@@ -100,20 +117,6 @@ DRESULT disk_ioctl (
100117
void *buff /* Buffer to send/receive control data */
101118
)
102119
{
103-
switch (cmd) {
104-
case GET_SECTOR_SIZE:
105-
*((DWORD*) buff) = 0x200;
106-
return RES_OK;
107-
case GET_SECTOR_COUNT:
108-
*((DWORD*) buff) = getMMCDevice(1)->total_size;
109-
return RES_OK;
110-
case GET_BLOCK_SIZE:
111-
*((DWORD*) buff) = 0x2000;
112-
return RES_OK;
113-
case CTRL_SYNC:
114-
// nothing to do here - the disk_write function handles that
115-
return RES_OK;
116-
}
117120
return RES_PARERR;
118121
}
119122
#endif
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
// Copyright 2014 Normmatt
2+
// Licensed under GPLv2 or any later version
3+
// Refer to the license.txt file included.
4+
15
.arm
2-
.global waitcycles
3-
.type waitcycles STT_FUNC
6+
.global ioDelay
7+
.type ioDelay STT_FUNC
48

5-
@waitcycles ( u32 us )
6-
waitcycles:
7-
PUSH {R0-R2,LR}
8-
STR R0, [SP,#4]
9-
waitcycles_loop:
10-
LDR R3, [SP,#4]
11-
SUBS R2, R3, #1
12-
STR R2, [SP,#4]
13-
CMP R3, #0
14-
BNE waitcycles_loop
15-
POP {R0-R2,PC}
9+
@ioDelay ( u32 us )
10+
ioDelay:
11+
ldr r1, =0x18000000 @ VRAM
12+
1:
13+
@ Loop doing uncached reads from VRAM to make loop timing more reliable
14+
ldr r2, [r1]
15+
subs r0, #1
16+
bgt 1b
17+
bx lr

0 commit comments

Comments
 (0)