3 * Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
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.
15 #include "sd_raw_config.h"
29 * MMC/SD/SDHC raw access header (license: GPLv2 or LGPLv2.1)
31 * \author Roland Riegel
35 * The card's layout is harddisk-like, which means it contains
36 * a master boot record with a partition table.
38 #define SD_RAW_FORMAT_HARDDISK 0
40 * The card contains a single filesystem and no partition table.
42 #define SD_RAW_FORMAT_SUPERFLOPPY 1
44 * The card's layout follows the Universal File Format.
46 #define SD_RAW_FORMAT_UNIVERSAL 2
48 * The card's layout is unknown.
50 #define SD_RAW_FORMAT_UNKNOWN 3
53 * This struct is used by sd_raw_get_info() to return
54 * manufacturing and status information of the card.
59 * A manufacturer code globally assigned by the SD card organization.
63 * A string describing the card's OEM or content, globally assigned by the SD card organization.
71 * The card's revision, coded in packed BCD.
73 * For example, the revision value \c 0x32 means "3.2".
77 * A serial number assigned by the manufacturer.
81 * The year of manufacturing.
83 * A value of zero means year 2000.
85 uint8_t manufacturing_year;
87 * The month of manufacturing.
89 uint8_t manufacturing_month;
91 * The card's total capacity in bytes.
95 * Defines wether the card's content is original or copied.
97 * A value of \c 0 means original, \c 1 means copied.
101 * Defines wether the card's content is write-protected.
103 * \note This is an internal flag and does not represent the
104 * state of the card's mechanical write-protect switch.
106 uint8_t flag_write_protect;
108 * Defines wether the card's content is temporarily write-protected.
110 * \note This is an internal flag and does not represent the
111 * state of the card's mechanical write-protect switch.
113 uint8_t flag_write_protect_temp;
115 * The card's data layout.
117 * See the \c SD_RAW_FORMAT_* constants for details.
119 * \note This value is not guaranteed to match reality.
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);
127 uint8_t sd_raw_init(void);
128 uint8_t sd_raw_available(void);
129 uint8_t sd_raw_locked(void);
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(void);
137 uint8_t sd_raw_get_info(struct sd_raw_info* info);