clean
[libfat.git] / source / disc.h
blob5c955f90aea9a8ba96c6edb871b513d09356a940
1 /*
2 disc.h
3 Interface to the low level disc functions. Used by the higher level
4 file system code.
6 Copyright (c) 2006 Michael "Chishm" Chisholm
8 Redistribution and use in source and binary forms, with or without modification,
9 are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 3. The name of the author may not be used to endorse or promote products derived
17 from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
22 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef _DISC_H
30 #define _DISC_H
32 #include "common.h"
35 A list of all default devices to try at startup,
36 terminated by a {NULL,NULL} entry.
38 typedef struct {
39 const char* name;
40 const DISC_INTERFACE* (*getInterface)(void);
41 } INTERFACE_ID;
42 extern const INTERFACE_ID _FAT_disc_interfaces[];
45 Check if a disc is inserted
46 Return true if a disc is inserted and ready, false otherwise
48 static inline bool _FAT_disc_isInserted (const DISC_INTERFACE* disc) {
49 return disc->isInserted();
53 Read numSectors sectors from a disc, starting at sector.
54 numSectors is between 1 and LIMIT_SECTORS if LIMIT_SECTORS is defined,
55 else it is at least 1
56 sector is 0 or greater
57 buffer is a pointer to the memory to fill
59 static inline bool _FAT_disc_readSectors (const DISC_INTERFACE* disc, sec_t sector, sec_t numSectors, void* buffer) {
60 return disc->readSectors (sector, numSectors, buffer);
64 Write numSectors sectors to a disc, starting at sector.
65 numSectors is between 1 and LIMIT_SECTORS if LIMIT_SECTORS is defined,
66 else it is at least 1
67 sector is 0 or greater
68 buffer is a pointer to the memory to read from
70 static inline bool _FAT_disc_writeSectors (const DISC_INTERFACE* disc, sec_t sector, sec_t numSectors, const void* buffer) {
71 return disc->writeSectors (sector, numSectors, buffer);
75 Reset the card back to a ready state
77 static inline bool _FAT_disc_clearStatus (const DISC_INTERFACE* disc) {
78 return disc->clearStatus();
82 Initialise the disc to a state ready for data reading or writing
84 static inline bool _FAT_disc_startup (const DISC_INTERFACE* disc) {
85 return disc->startup();
89 Put the disc in a state ready for power down.
90 Complete any pending writes and disable the disc if necessary
92 static inline bool _FAT_disc_shutdown (const DISC_INTERFACE* disc) {
93 return disc->shutdown();
97 Return a 32 bit value unique to each type of interface
99 static inline uint32_t _FAT_disc_hostType (const DISC_INTERFACE* disc) {
100 return disc->ioType;
104 Return a 32 bit value that specifies the capabilities of the disc
106 static inline uint32_t _FAT_disc_features (const DISC_INTERFACE* disc) {
107 return disc->features;
110 #endif // _DISC_H