Mercurial > pihelp
comparison sd_raw.h @ 30:320c8cc7df5a
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 27 Jun 2013 00:12:01 +0800 |
parents | 5f9a40d6991b |
children | 9e888708f33d |
comparison
equal
deleted
inserted
replaced
29:22badb6239e0 | 30:320c8cc7df5a |
---|---|
1 | |
2 /* | |
3 * Copyright (c) 2006-2012 by Roland Riegel <[email protected]> | |
4 * | |
5 * This file is free software; you can redistribute it and/or modify | |
6 * it under the terms of either the GNU General Public License version 2 | |
7 * or the GNU Lesser General Public License version 2.1, both as | |
8 * published by the Free Software Foundation. | |
9 */ | |
10 | |
11 #ifndef SD_RAW_H | |
12 #define SD_RAW_H | |
13 | |
14 #include <stdint.h> | |
15 #include "sd_raw_config.h" | |
16 | |
17 #ifdef __cplusplus | |
18 extern "C" | |
19 { | |
20 #endif | |
21 | |
22 /** | |
23 * \addtogroup sd_raw | |
24 * | |
25 * @{ | |
26 */ | |
27 /** | |
28 * \file | |
29 * MMC/SD/SDHC raw access header (license: GPLv2 or LGPLv2.1) | |
30 * | |
31 * \author Roland Riegel | |
32 */ | |
33 | |
34 /** | |
35 * The card's layout is harddisk-like, which means it contains | |
36 * a master boot record with a partition table. | |
37 */ | |
38 #define SD_RAW_FORMAT_HARDDISK 0 | |
39 /** | |
40 * The card contains a single filesystem and no partition table. | |
41 */ | |
42 #define SD_RAW_FORMAT_SUPERFLOPPY 1 | |
43 /** | |
44 * The card's layout follows the Universal File Format. | |
45 */ | |
46 #define SD_RAW_FORMAT_UNIVERSAL 2 | |
47 /** | |
48 * The card's layout is unknown. | |
49 */ | |
50 #define SD_RAW_FORMAT_UNKNOWN 3 | |
51 | |
52 /** | |
53 * This struct is used by sd_raw_get_info() to return | |
54 * manufacturing and status information of the card. | |
55 */ | |
56 struct sd_raw_info | |
57 { | |
58 /** | |
59 * A manufacturer code globally assigned by the SD card organization. | |
60 */ | |
61 uint8_t manufacturer; | |
62 /** | |
63 * A string describing the card's OEM or content, globally assigned by the SD card organization. | |
64 */ | |
65 uint8_t oem[3]; | |
66 /** | |
67 * A product name. | |
68 */ | |
69 uint8_t product[6]; | |
70 /** | |
71 * The card's revision, coded in packed BCD. | |
72 * | |
73 * For example, the revision value \c 0x32 means "3.2". | |
74 */ | |
75 uint8_t revision; | |
76 /** | |
77 * A serial number assigned by the manufacturer. | |
78 */ | |
79 uint32_t serial; | |
80 /** | |
81 * The year of manufacturing. | |
82 * | |
83 * A value of zero means year 2000. | |
84 */ | |
85 uint8_t manufacturing_year; | |
86 /** | |
87 * The month of manufacturing. | |
88 */ | |
89 uint8_t manufacturing_month; | |
90 /** | |
91 * The card's total capacity in bytes. | |
92 */ | |
93 offset_t capacity; | |
94 /** | |
95 * Defines wether the card's content is original or copied. | |
96 * | |
97 * A value of \c 0 means original, \c 1 means copied. | |
98 */ | |
99 uint8_t flag_copy; | |
100 /** | |
101 * Defines wether the card's content is write-protected. | |
102 * | |
103 * \note This is an internal flag and does not represent the | |
104 * state of the card's mechanical write-protect switch. | |
105 */ | |
106 uint8_t flag_write_protect; | |
107 /** | |
108 * Defines wether the card's content is temporarily write-protected. | |
109 * | |
110 * \note This is an internal flag and does not represent the | |
111 * state of the card's mechanical write-protect switch. | |
112 */ | |
113 uint8_t flag_write_protect_temp; | |
114 /** | |
115 * The card's data layout. | |
116 * | |
117 * See the \c SD_RAW_FORMAT_* constants for details. | |
118 * | |
119 * \note This value is not guaranteed to match reality. | |
120 */ | |
121 uint8_t format; | |
122 }; | |
123 | |
124 typedef uint8_t (*sd_raw_read_interval_handler_t)(uint8_t* buffer, offset_t offset, void* p); | |
125 typedef uintptr_t (*sd_raw_write_interval_handler_t)(uint8_t* buffer, offset_t offset, void* p); | |
126 | |
127 uint8_t sd_raw_init(); | |
128 uint8_t sd_raw_available(); | |
129 uint8_t sd_raw_locked(); | |
130 | |
131 uint8_t sd_raw_read(offset_t offset, uint8_t* buffer, uintptr_t length); | |
132 uint8_t sd_raw_read_interval(offset_t offset, uint8_t* buffer, uintptr_t interval, uintptr_t length, sd_raw_read_interval_handler_t callback, void* p); | |
133 uint8_t sd_raw_write(offset_t offset, const uint8_t* buffer, uintptr_t length); | |
134 uint8_t sd_raw_write_interval(offset_t offset, uint8_t* buffer, uintptr_t length, sd_raw_write_interval_handler_t callback, void* p); | |
135 uint8_t sd_raw_sync(); | |
136 | |
137 uint8_t sd_raw_get_info(struct sd_raw_info* info); | |
138 | |
139 /** | |
140 * @} | |
141 */ | |
142 | |
143 #ifdef __cplusplus | |
144 } | |
145 #endif | |
146 | |
147 #endif | |
148 |