+ Added sd card handling to libogc

git-svn-id: trunk@17002 -
This commit is contained in:
Legolas 2011-02-25 21:36:57 +00:00
parent b8e9fd5c00
commit 08fdb5af54
7 changed files with 137 additions and 5 deletions

5
.gitattributes vendored
View File

@ -4560,6 +4560,11 @@ packages/libogcfpc/src/ogc/video.inc svneol=native#text/plain
packages/libogcfpc/src/ogc/video_types.inc svneol=native#text/plain
packages/libogcfpc/src/ogc/wiilaunch.inc svneol=native#text/plain
packages/libogcfpc/src/ogcsys.inc svneol=native#text/plain
packages/libogcfpc/src/sdcard/card_buf.inc svneol=native#text/plain
packages/libogcfpc/src/sdcard/card_cmn.inc svneol=native#text/plain
packages/libogcfpc/src/sdcard/card_io.inc svneol=native#text/plain
packages/libogcfpc/src/sdcard/gcsd.inc svneol=native#text/plain
packages/libogcfpc/src/sdcard/wiisd_io.inc svneol=native#text/plain
packages/libogcfpc/src/wiikeyboard/keyboard.inc svneol=native#text/plain
packages/libogcfpc/src/wiikeyboard/usbkeyboard.inc svneol=native#text/plain
packages/libogcfpc/src/wiikeyboard/wsksymdef.inc svneol=native#text/plain

View File

@ -37,7 +37,6 @@
{$include ogc/lwp_messages.inc}
{$include ogc/lwp_mutex.inc}
{ $include ogc/lwp_queue.inc}
{$include ogc/lwp_sema.inc}
{$include ogc/lwp_stack.inc}
{$include ogc/lwp_states.inc}
@ -63,11 +62,13 @@
{$include ogc/video_types.inc}
{$include ogc/texconv.inc}
{$ifdef HW_RVL}
{ $include ogc/machine/asm.inc}
{ $include ogc/machine/processor.inc}
{ $include ogc/machine/spinlock.inc}
{$include sdcard/card_buf.inc}
{$include sdcard/card_cmn.inc}
{$include sdcard/card_io.inc}
{$include sdcard/wiisd_io.inc}
{$ifdef HW_RVL}
{$include ogc/ipc.inc}
{$include ogc/es.inc}
{$include ogc/stm.inc}

View File

@ -0,0 +1,8 @@
{$IFDEF OGC_INTERFACE}
procedure sdgecko_initBufferPool; cdecl; external;
function sdgecko_allocBuffer: pcuint8; cdecl; external;
procedure sdgecko_freeBuffer(buf: pcuint8); cdecl; external;
{$ENDIF}

View File

@ -0,0 +1,53 @@
{$IFDEF OGC_INTERFACE}
const
CARDIO_ERROR_READY = 0;
CARDIO_ERROR_BUSY = - 1;
CARDIO_ERROR_WRONGDEVICE = - 2;
CARDIO_ERROR_NOCARD = - 3;
CARDIO_ERROR_IDLE = - 4;
CARDIO_ERROR_IOERROR = - 5;
CARDIO_ERROR_IOTIMEOUT = - 6;
CARDIO_ERROR_NOTPERMITTED = - 107;
CARDIO_ERROR_ROOTENTRY = - 108;
CARDIO_ERROR_OUTOFROOTENTRY = - 109;
CARDIO_ERROR_FILEEXIST = - 110;
CARDIO_ERROR_NOEMPTYCLUSTER = - 111;
CARDIO_ERROR_EOF = - 112;
CARDIO_ERROR_SYSTEMPARAM = - 113;
CARDIO_ERROR_FILEOPENED = - 114;
CARDIO_ERROR_FILENOTOPENED = - 115;
CARDIO_ERROR_FILENAMETOOLONG = - 116;
CARDIO_ERROR_INVALIDNAME = - 117;
CARDIO_ERROR_NOLONGNAME = - 118;
CARDIO_ERROR_INCORRECTFAT = - 119;
CARDIO_ERROR_NOTFOUND = - 120;
CARDIO_ERROR_OUTOFMEMORY = - 121;
CARDIO_ERROR_INVALIDFAT = - 122;
CARDIO_ERROR_INVALIDMBR = - 123;
CARDIO_ERROR_INVALIDPBR = - 124;
CARDIO_ERROR_NOEMPTYBLOCK = - 125;
CARDIO_ERROR_INTERNAL = - 126;
CARDIO_ERROR_INVALIDPARAM = - 127;
CARDIO_ERROR_FATALERROR = - 128;
MAX_DRIVE = 2;
SECTOR_SIZE = 512;
NOT_INITIALIZED = 0;
INITIALIZING = 1;
INITIALIZED = 2;
type
_dev_info = record
CpV : cuint32;
HpC : cuint32;
SpH : cuint32;
allS : cuint32;
szS : cuint32;
PBpV : cuint32;
LBpV : cuint32;
SpB : cuint32;
PpB : cuint32;
szP : cuint32;
end;
DEV_INFO = _dev_info;
PDEV_INFO = ^_dev_info;
{$ENDIF}

View File

@ -0,0 +1,47 @@
{$IFDEF OGC_INTERFACE}
const
MAX_MI_NUM = 1;
MAX_DI_NUM = 5;
PAGE_SIZE256 = 256;
PAGE_SIZE512 = 512;
(* CID Register *)
{$define MANUFACTURER_ID(drv_no) := (cuint8(g_CID[drv_no][0]))}
(* CSD Register *)
{$define READ_BL_LEN(drv_no) := (cuint8(g_CSD[drv_no][5] and $0f))}
{$define WRITE_BL_LEN(drv_no) := (cuint8((g_CSD[drv_no][12] and $03) shl 2) or ((g_CSD[drv_no][13] shr 6) and $03))}
{$define C_SIZE(drv_no) := (cuint16(((g_CSD[drv_no][6] and $03) shl 10) or (g_CSD[drv_no][7] shl 2) or ((g_CSD[drv_no][8] shr 6) and $03)))}
{$define C_SIZE_MULT(drv_no) := (cuint8((g_CSD[drv_no][9] and $03) shl 1) or ((g_CSD[drv_no][10] shr 7) and $01))}
var
g_CSD : array [0..15] of cuint8; external;
g_CID : array [0..15] of cuint8; external;
g_mCode : array [0..MAX_MI_NUM-1] of cuint8; external;
g_dCode : array [0..MAX_DI_NUM-1] of cuint16; external;
procedure sdgecko_initIODefault; cdecl; external;
function sdgecko_initIO(drv_no: cint32): cint32; cdecl; external;
function sdgecko_preIO(drv_no: cint32): cint32; cdecl; external;
function sdgecko_readCID(drv_no: cint32): cint32; cdecl; external;
function sdgecko_readCSD(drv_no: cint32): cint32; cdecl; external;
function sdgecko_readStatus(drv_no: cint32): cint32; cdecl; external;
function sdgecko_readSectors(drv_no: cint32; sector_no, num_sectors: cuint32;
buf: pointer): cint32; cdecl; external;
function sdgecko_writeSector(drv_no: cint32; sector_no: cuint32; buf: pointer;
len: cuint32): cint32; cdecl; external;
function sdgecko_writeSectors(drv_no: cint32; sector_no, num_sectors: cuint32;
buf: pointer): cint32; cdecl; external;
function sdgecko_doUnmount(drv_no: cint32): cint32; cdecl; external;
procedure sdgecko_insertedCB(drv_no: cint32); cdecl; external;
procedure sdgecko_ejectedCB(drv_no: cint32); cdecl; external;
{$ENDIF}

View File

@ -0,0 +1,10 @@
{$IFDEF OGC_INTERFACE}
const
DEVICE_TYPE_GC_SD = ((Ord('G') shl 2) or (Ord('C') shl 16) or (Ord('S') shl 8) or Ord('D'));
var
__io_gcsda : DISC_INTERFACE; external;
__io_gcsdb : DISC_INTERFACE; external;
{$ENDIF}

View File

@ -0,0 +1,8 @@
{$IFDEF OGC_INTERFACE}
const
DEVICE_TYPE_WII_SD = ((Ord('W') shl 2) or (Ord('I') shl 16) or (Ord('S') shl 8) or Ord('D'));
var
__io_wiisd : DISC_INTERFACE; external;
{$ENDIF}