11
11
#include "sdmmc/sdmmc.h"
12
12
#include "../crypto.h"
13
13
14
+ /* Definitions of physical drive number for each media */
15
+ #define SDCARD 0
16
+ #define CTRNAND 1
14
17
15
18
/*-----------------------------------------------------------------------*/
16
19
/* Get Drive Status */
@@ -31,12 +34,20 @@ DSTATUS disk_status (
31
34
/*-----------------------------------------------------------------------*/
32
35
33
36
DSTATUS disk_initialize (
34
- __attribute__((unused ))
35
37
BYTE pdrv /* Physical drive nmuber to identify the drive */
36
38
)
37
39
{
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
+
40
51
return RES_OK ;
41
52
}
42
53
@@ -47,18 +58,25 @@ DSTATUS disk_initialize (
47
58
/*-----------------------------------------------------------------------*/
48
59
49
60
DRESULT disk_read (
50
- __attribute__((unused ))
51
61
BYTE pdrv , /* Physical drive nmuber to identify the drive */
52
62
BYTE * buff , /* Data buffer to store read data */
53
63
DWORD sector , /* Sector address in LBA */
54
64
UINT count /* Number of sectors to read */
55
65
)
56
66
{
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 ;
62
80
}
63
81
64
82
@@ -71,16 +89,15 @@ DRESULT disk_read (
71
89
DRESULT disk_write (
72
90
__attribute__((unused ))
73
91
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 ))
75
95
DWORD sector , /* Sector address in LBA */
96
+ __attribute__((unused ))
76
97
UINT count /* Number of sectors to write */
77
98
)
78
99
{
79
- if (sdmmc_sdcard_writesectors (sector , count , (BYTE * )buff )) {
80
- return RES_PARERR ;
81
- }
82
-
83
- return RES_OK ;
100
+ return RES_OK ;
84
101
}
85
102
#endif
86
103
@@ -100,20 +117,6 @@ DRESULT disk_ioctl (
100
117
void * buff /* Buffer to send/receive control data */
101
118
)
102
119
{
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
- }
117
120
return RES_PARERR ;
118
121
}
119
122
#endif
0 commit comments