diff options
| author | Legolas <Legolas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-02-25 21:36:57 +0000 |
|---|---|---|
| committer | Legolas <Legolas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-02-25 21:36:57 +0000 |
| commit | f8489edd8bec702f1a3217be868643fcd3a623b8 (patch) | |
| tree | 274656530a7a0d96475ddd13b422bd4ddc7b2f65 /packages/libogcfpc/src | |
| parent | 070e933d09eac70901486984519cbb3697898f92 (diff) | |
| download | fpc-f8489edd8bec702f1a3217be868643fcd3a623b8.tar.gz | |
+ Added sd card handling to libogc
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@17002 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/libogcfpc/src')
| -rw-r--r-- | packages/libogcfpc/src/gccore.inc | 11 | ||||
| -rw-r--r-- | packages/libogcfpc/src/sdcard/card_buf.inc | 8 | ||||
| -rw-r--r-- | packages/libogcfpc/src/sdcard/card_cmn.inc | 53 | ||||
| -rw-r--r-- | packages/libogcfpc/src/sdcard/card_io.inc | 47 | ||||
| -rw-r--r-- | packages/libogcfpc/src/sdcard/gcsd.inc | 10 | ||||
| -rw-r--r-- | packages/libogcfpc/src/sdcard/wiisd_io.inc | 8 |
6 files changed, 132 insertions, 5 deletions
diff --git a/packages/libogcfpc/src/gccore.inc b/packages/libogcfpc/src/gccore.inc index 799af26f43..551de3e633 100644 --- a/packages/libogcfpc/src/gccore.inc +++ b/packages/libogcfpc/src/gccore.inc @@ -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} diff --git a/packages/libogcfpc/src/sdcard/card_buf.inc b/packages/libogcfpc/src/sdcard/card_buf.inc new file mode 100644 index 0000000000..393e88795a --- /dev/null +++ b/packages/libogcfpc/src/sdcard/card_buf.inc @@ -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} + + + diff --git a/packages/libogcfpc/src/sdcard/card_cmn.inc b/packages/libogcfpc/src/sdcard/card_cmn.inc new file mode 100644 index 0000000000..54820d4c13 --- /dev/null +++ b/packages/libogcfpc/src/sdcard/card_cmn.inc @@ -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} diff --git a/packages/libogcfpc/src/sdcard/card_io.inc b/packages/libogcfpc/src/sdcard/card_io.inc new file mode 100644 index 0000000000..eff81375d5 --- /dev/null +++ b/packages/libogcfpc/src/sdcard/card_io.inc @@ -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} + + + + diff --git a/packages/libogcfpc/src/sdcard/gcsd.inc b/packages/libogcfpc/src/sdcard/gcsd.inc new file mode 100644 index 0000000000..0c417aa516 --- /dev/null +++ b/packages/libogcfpc/src/sdcard/gcsd.inc @@ -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} + diff --git a/packages/libogcfpc/src/sdcard/wiisd_io.inc b/packages/libogcfpc/src/sdcard/wiisd_io.inc new file mode 100644 index 0000000000..8a3c606aee --- /dev/null +++ b/packages/libogcfpc/src/sdcard/wiisd_io.inc @@ -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} + |
