Skip to content

Commit

Permalink
Temporarily revert "full A9NC support" because that borked SDless boot
Browse files Browse the repository at this point in the history
This reverts commit 8e5cca1.
  • Loading branch information
RShadowhand committed Jun 22, 2016
1 parent 8e5cca1 commit 3fcd257
Show file tree
Hide file tree
Showing 5 changed files with 451 additions and 757 deletions.
61 changes: 32 additions & 29 deletions payload_stage2/source/fatfs/diskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "sdmmc/sdmmc.h"
#include "../crypto.h"

/* Definitions of physical drive number for each media */
#define SDCARD 0
#define CTRNAND 1

/*-----------------------------------------------------------------------*/
/* Get Drive Status */
Expand All @@ -31,12 +34,20 @@ DSTATUS disk_status (
/*-----------------------------------------------------------------------*/

DSTATUS disk_initialize (
__attribute__((unused))
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
if (!sdmmc_sdcard_init())
return RES_PARERR;
static u32 sdmmcInited = 0;

if(!sdmmcInited)
{
sdmmc_sdcard_init();
sdmmcInited = 1;
}

if(pdrv == CTRNAND)
ctrNandInit();

return RES_OK;
}

Expand All @@ -47,18 +58,25 @@ DSTATUS disk_initialize (
/*-----------------------------------------------------------------------*/

DRESULT disk_read (
__attribute__((unused))
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to read */
)
{
if (sdmmc_sdcard_readsectors(sector, count, buff)) {
return RES_PARERR;
}

return RES_OK;
switch(pdrv)
{
case SDCARD:
if(sdmmc_sdcard_readsectors(sector, count, (BYTE *)buff))
return RES_PARERR;
break;
case CTRNAND:
if(ctrNandRead(sector, count, (BYTE *)buff))
return RES_PARERR;
break;
}

return RES_OK;
}


Expand All @@ -71,16 +89,15 @@ DRESULT disk_read (
DRESULT disk_write (
__attribute__((unused))
BYTE pdrv, /* Physical drive nmuber to identify the drive */
const BYTE *buff, /* Data to be written */
__attribute__((unused))
const BYTE *buff, /* Data to be written */
__attribute__((unused))
DWORD sector, /* Sector address in LBA */
__attribute__((unused))
UINT count /* Number of sectors to write */
)
{
if (sdmmc_sdcard_writesectors(sector, count, (BYTE *)buff)) {
return RES_PARERR;
}

return RES_OK;
return RES_OK;
}
#endif

Expand All @@ -100,20 +117,6 @@ DRESULT disk_ioctl (
void *buff /* Buffer to send/receive control data */
)
{
switch (cmd) {
case GET_SECTOR_SIZE:
*((DWORD*) buff) = 0x200;
return RES_OK;
case GET_SECTOR_COUNT:
*((DWORD*) buff) = getMMCDevice(1)->total_size;
return RES_OK;
case GET_BLOCK_SIZE:
*((DWORD*) buff) = 0x2000;
return RES_OK;
case CTRL_SYNC:
// nothing to do here - the disk_write function handles that
return RES_OK;
}
return RES_PARERR;
}
#endif
28 changes: 15 additions & 13 deletions payload_stage2/source/fatfs/sdmmc/delay.s
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Copyright 2014 Normmatt
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

.arm
.global waitcycles
.type waitcycles STT_FUNC
.global ioDelay
.type ioDelay STT_FUNC

@waitcycles ( u32 us )
waitcycles:
PUSH {R0-R2,LR}
STR R0, [SP,#4]
waitcycles_loop:
LDR R3, [SP,#4]
SUBS R2, R3, #1
STR R2, [SP,#4]
CMP R3, #0
BNE waitcycles_loop
POP {R0-R2,PC}
@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
Loading

0 comments on commit 3fcd257

Please sign in to comment.