1 | /* |
---|
2 | io_sccf.c based on |
---|
3 | |
---|
4 | compact_flash.c |
---|
5 | By chishm (Michael Chisholm) |
---|
6 | |
---|
7 | Hardware Routines for reading a compact flash card |
---|
8 | using the Super Card CF |
---|
9 | |
---|
10 | CF routines modified with help from Darkfader |
---|
11 | |
---|
12 | Copyright (c) 2006 Michael "Chishm" Chisholm |
---|
13 | |
---|
14 | Redistribution and use in source and binary forms, with or without modification, |
---|
15 | are permitted provided that the following conditions are met: |
---|
16 | |
---|
17 | 1. Redistributions of source code must retain the above copyright notice, |
---|
18 | this list of conditions and the following disclaimer. |
---|
19 | 2. Redistributions in binary form must reproduce the above copyright notice, |
---|
20 | this list of conditions and the following disclaimer in the documentation and/or |
---|
21 | other materials provided with the distribution. |
---|
22 | 3. The name of the author may not be used to endorse or promote products derived |
---|
23 | from this software without specific prior written permission. |
---|
24 | |
---|
25 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
26 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
---|
27 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE |
---|
28 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
---|
30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
31 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
---|
33 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
34 | */ |
---|
35 | |
---|
36 | |
---|
37 | #include "io_sccf.h" |
---|
38 | #include "io_sc_common.h" |
---|
39 | #include "io_cf_common.h" |
---|
40 | |
---|
41 | //--------------------------------------------------------------- |
---|
42 | // SC CF Addresses |
---|
43 | #define REG_SCCF_STS ((vu16*)0x098C0000) // Status of the CF Card / Device control |
---|
44 | #define REG_SCCF_CMD ((vu16*)0x090E0000) // Commands sent to control chip and status return |
---|
45 | #define REG_SCCF_ERR ((vu16*)0x09020000) // Errors / Features |
---|
46 | |
---|
47 | #define REG_SCCF_SEC ((vu16*)0x09040000) // Number of sector to transfer |
---|
48 | #define REG_SCCF_LBA1 ((vu16*)0x09060000) // 1st byte of sector address |
---|
49 | #define REG_SCCF_LBA2 ((vu16*)0x09080000) // 2nd byte of sector address |
---|
50 | #define REG_SCCF_LBA3 ((vu16*)0x090A0000) // 3rd byte of sector address |
---|
51 | #define REG_SCCF_LBA4 ((vu16*)0x090C0000) // last nibble of sector address | 0xE0 |
---|
52 | |
---|
53 | #define REG_SCCF_DATA ((vu16*)0x09000000) // Pointer to buffer of CF data transered from card |
---|
54 | |
---|
55 | static const CF_REGISTERS _SCCF_Registers = { |
---|
56 | REG_SCCF_DATA, |
---|
57 | REG_SCCF_STS, |
---|
58 | REG_SCCF_CMD, |
---|
59 | REG_SCCF_ERR, |
---|
60 | REG_SCCF_SEC, |
---|
61 | REG_SCCF_LBA1, |
---|
62 | REG_SCCF_LBA2, |
---|
63 | REG_SCCF_LBA3, |
---|
64 | REG_SCCF_LBA4 |
---|
65 | }; |
---|
66 | |
---|
67 | |
---|
68 | static bool _SCCF_startup(void) { |
---|
69 | _SC_changeMode (SC_MODE_MEDIA); |
---|
70 | return _CF_startup(&_SCCF_Registers); |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | const IO_INTERFACE _io_sccf = { |
---|
75 | DEVICE_TYPE_SCCF, |
---|
76 | FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_SLOT_GBA, |
---|
77 | (FN_MEDIUM_STARTUP)&_SCCF_startup, |
---|
78 | (FN_MEDIUM_ISINSERTED)&_CF_isInserted, |
---|
79 | (FN_MEDIUM_READSECTORS)&_CF_readSectors, |
---|
80 | (FN_MEDIUM_WRITESECTORS)&_CF_writeSectors, |
---|
81 | (FN_MEDIUM_CLEARSTATUS)&_CF_clearStatus, |
---|
82 | (FN_MEDIUM_SHUTDOWN)&_CF_shutdown |
---|
83 | } ; |
---|