1 | /* |
---|
2 | disc_io.h |
---|
3 | Interface template for low level disc functions. |
---|
4 | |
---|
5 | Copyright (c) 2006 Michael "Chishm" Chisholm |
---|
6 | |
---|
7 | Redistribution and use in source and binary forms, with or without modification, |
---|
8 | are permitted provided that the following conditions are met: |
---|
9 | |
---|
10 | 1. Redistributions of source code must retain the above copyright notice, |
---|
11 | this list of conditions and the following disclaimer. |
---|
12 | 2. Redistributions in binary form must reproduce the above copyright notice, |
---|
13 | this list of conditions and the following disclaimer in the documentation and/or |
---|
14 | other materials provided with the distribution. |
---|
15 | 3. The name of the author may not be used to endorse or promote products derived |
---|
16 | from this software without specific prior written permission. |
---|
17 | |
---|
18 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
19 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
---|
20 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE |
---|
21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
---|
23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
---|
26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
27 | |
---|
28 | 2006-07-11 - Chishm |
---|
29 | * Original release |
---|
30 | |
---|
31 | 2006-07-16 - Chishm |
---|
32 | * Renamed _CF_USE_DMA to _IO_USE_DMA |
---|
33 | * Renamed _CF_ALLOW_UNALIGNED to _IO_ALLOW_UNALIGNED |
---|
34 | */ |
---|
35 | |
---|
36 | #ifndef _DISC_IO_H |
---|
37 | #define _DISC_IO_H |
---|
38 | |
---|
39 | #include "../common.h" |
---|
40 | |
---|
41 | //---------------------------------------------------------------------- |
---|
42 | // Customisable features |
---|
43 | |
---|
44 | // Use DMA to read the card, remove this line to use normal reads/writes |
---|
45 | // #define _IO_USE_DMA |
---|
46 | |
---|
47 | // Allow buffers not alligned to 16 bits when reading files. |
---|
48 | // Note that this will slow down access speed, so only use if you have to. |
---|
49 | // It is also incompatible with DMA |
---|
50 | #define _IO_ALLOW_UNALIGNED |
---|
51 | |
---|
52 | #if defined _IO_USE_DMA && defined _IO_ALLOW_UNALIGNED |
---|
53 | #error "You cannot use both DMA and unaligned memory" |
---|
54 | #endif |
---|
55 | |
---|
56 | #define FEATURE_MEDIUM_CANREAD 0x00000001 |
---|
57 | #define FEATURE_MEDIUM_CANWRITE 0x00000002 |
---|
58 | #define FEATURE_SLOT_GBA 0x00000010 |
---|
59 | #define FEATURE_SLOT_NDS 0x00000020 |
---|
60 | |
---|
61 | typedef bool (* FN_MEDIUM_STARTUP)(void) ; |
---|
62 | typedef bool (* FN_MEDIUM_ISINSERTED)(void) ; |
---|
63 | typedef bool (* FN_MEDIUM_READSECTORS)(u32 sector, u32 numSectors, void* buffer) ; |
---|
64 | typedef bool (* FN_MEDIUM_WRITESECTORS)(u32 sector, u32 numSectors, const void* buffer) ; |
---|
65 | typedef bool (* FN_MEDIUM_CLEARSTATUS)(void) ; |
---|
66 | typedef bool (* FN_MEDIUM_SHUTDOWN)(void) ; |
---|
67 | |
---|
68 | struct IO_INTERFACE_STRUCT { |
---|
69 | unsigned long ioType ; |
---|
70 | unsigned long features ; |
---|
71 | FN_MEDIUM_STARTUP fn_startup ; |
---|
72 | FN_MEDIUM_ISINSERTED fn_isInserted ; |
---|
73 | FN_MEDIUM_READSECTORS fn_readSectors ; |
---|
74 | FN_MEDIUM_WRITESECTORS fn_writeSectors ; |
---|
75 | FN_MEDIUM_CLEARSTATUS fn_clearStatus ; |
---|
76 | FN_MEDIUM_SHUTDOWN fn_shutdown ; |
---|
77 | } ; |
---|
78 | |
---|
79 | typedef struct IO_INTERFACE_STRUCT IO_INTERFACE ; |
---|
80 | |
---|
81 | #endif // define _DISC_IO_H |
---|