?? partition.h
字號:
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef PARTITION_H
#define PARTITION_H
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/***********原來的partition_config.h上的**********
* 最多分區個數
**************************************************/
#define PARTITION_COUNT 1
/*************************************************
* 標志:分區未格式化
**************************************************/
#define PARTITION_TYPE_FREE 0x00
/*************************************************
* 標志:分區為FAT12文件系統
**************************************************/
#define PARTITION_TYPE_FAT12 0x01
/*************************************************
* 標志:分區為FAT16文件系統 最大支持32M
**************************************************/
#define PARTITION_TYPE_FAT16_32MB 0x04
/*************************************************
* 標志:分區為擴展分區
**************************************************/
#define PARTITION_TYPE_EXTENDED 0x05
/*************************************************
* 標志:分區為FAT16文件系統
**************************************************/
#define PARTITION_TYPE_FAT16 0x06
/*************************************************
* 標志:分區為FAT32文件系統
**************************************************/
#define PARTITION_TYPE_FAT32 0x0b
/*************************************************
* 標志:分區為FAT32文件系統 (帶LBA)
**************************************************/
#define PARTITION_TYPE_FAT32_LBA 0x0c
/*************************************************
* 標志:分區為FAT16文件系統 (帶LBA)
**************************************************/
#define PARTITION_TYPE_FAT16_LBA 0x0e
/*************************************************
* 標志:分區為擴展分區 (帶LBA)
**************************************************/
#define PARTITION_TYPE_EXTENDED_LBA 0x0f
/*************************************************
* 標志:未知分區格式
**************************************************/
#define PARTITION_TYPE_UNKNOWN 0xff
/*************************************************
* 定義一個 從分區讀取數據的函數指針類
* 參數:
* 輸入 offset:偏移地址
* length: 讀取字節個數
* 輸出 buffer:數據存放緩存首地址
**************************************************/
typedef u8 (*device_read_t)(u32 offset, u8* buffer, u16 length);
/**
* A function pointer passed to a \c device_read_interval_t.
*
* \param[in] buffer The buffer which contains the data just read.
* \param[in] offset The offset from which the data in \c buffer was read.
* \param[in] p An opaque pointer.
* \see device_read_interval_t
*/
typedef u8 (*device_read_callback_t)(u8* buffer, u32 offset, void* p);
/**
* A function pointer used to continuously read units of \c interval bytes
* and call a callback function.
*
* This function starts reading at the specified offset. Every \c interval bytes,
* it calls the callback function with the associated data buffer.
*
* By returning zero, the callback may stop reading.
*
* \param[in] offset Offset from which to start reading.
* \param[in] buffer Pointer to a buffer which is at least interval bytes in size.
* \param[in] interval Number of bytes to read before calling the callback function.
* \param[in] length Number of bytes to read altogether.
* \param[in] callback The function to call every interval bytes.
* \param[in] p An opaque pointer directly passed to the callback function.
* \returns 0 on failure, 1 on success
* \see device_read_t
*/
typedef u8 (*device_read_interval_t)(u32 offset, u8* buffer, u16 interval, u16 length, device_read_callback_t callback, void* p);
/**
* A function pointer used to write to the partition.
*
* \param[in] offset The offset on the device where to start writing.
* \param[in] buffer The buffer which to write.
* \param[in] length The count of bytes to write.
*/
typedef u8 (*device_write_t)(u32 offset, const u8* buffer, u16 length);
/**
* A function pointer passed to a \c device_write_interval_t.
*
* \param[in] buffer The buffer which receives the data to write.
* \param[in] offset The offset to which the data in \c buffer will be written.
* \param[in] p An opaque pointer.
* \returns The number of bytes put into \c buffer
* \see device_write_interval_t
*/
typedef u16 (*device_write_callback_t)(u8* buffer, u32 offset, void* p);
/**
* A function pointer used to continuously write a data stream obtained from
* a callback function.
*
* This function starts writing at the specified offset. To obtain the
* next bytes to write, it calls the callback function. The callback fills the
* provided data buffer and returns the number of bytes it has put into the buffer.
*
* By returning zero, the callback may stop writing.
*
* \param[in] offset Offset where to start writing.
* \param[in] buffer Pointer to a buffer which is used for the callback function.
* \param[in] length Number of bytes to write in total. May be zero for endless writes.
* \param[in] callback The function used to obtain the bytes to write.
* \param[in] p An opaque pointer directly passed to the callback function.
* \returns 0 on failure, 1 on success
* \see device_write_t
*/
typedef u8 (*device_write_interval_t)(u32 offset, u8* buffer, u16 length, device_write_callback_t callback, void* p);
/**
* Describes a partition.
*/
struct Partition_Struct
{
/**
* The function which reads data from the partition.
*
* \note The offset given to this function is relative to the whole disk,
* not to the start of the partition.
*/
device_read_t device_read;
/**
* The function which repeatedly reads a constant amount of data from the partition.
*
* \note The offset given to this function is relative to the whole disk,
* not to the start of the partition.
*/
device_read_interval_t device_read_interval;
/**
* The function which writes data to the partition.
*
* \note The offset given to this function is relative to the whole disk,
* not to the start of the partition.
*/
device_write_t device_write;
/**
* The function which repeatedly writes data to the partition.
*
* \note The offset given to this function is relative to the whole disk,
* not to the start of the partition.
*/
device_write_interval_t device_write_interval;
/**
* The type of the partition.
*
* Compare this value to the PARTITION_TYPE_* constants.
*/
u8 type;
/**
* The offset in bytes on the disk where this partition starts.
*/
u32 offset;
/**
* The length in bytes of this partition.
*/
u32 length;
};
struct Partition_Struct* partition_open(device_read_t device_read, device_read_interval_t device_read_interval, device_write_t device_write, device_write_interval_t device_write_interval, s8 index);
u8 partition_close(struct Partition_Struct* partition);
#endif /* PARTITION_H */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -