20 #ifndef MBED_BLOCK_DEVICE_H    21 #define MBED_BLOCK_DEVICE_H    33     BD_ERROR_DEVICE_ERROR       = -4001, 
    38 typedef uint64_t bd_addr_t;
    42 typedef uint64_t bd_size_t;
    70     virtual int init() = 0;
    96     virtual int read(
void *buffer, bd_addr_t addr, bd_size_t 
size) = 0;
   109     virtual int program(
const void *buffer, bd_addr_t addr, bd_size_t size) = 0;
   120     virtual int erase(bd_addr_t addr, bd_size_t size)
   136     virtual int trim(bd_addr_t addr, bd_size_t size)
   193     virtual bd_size_t 
size() 
const = 0;
   206                    addr + size <= this->
size());
   220                    addr + size <= this->
size());
   234                    addr + size <= this->
size());
   241     virtual const char *
get_type() 
const = 0;
   247 #ifndef MBED_NO_GLOBAL_USING_DIRECTIVE   249 using mbed::bd_addr_t;
   250 using mbed::bd_size_t;
   251 using mbed::BD_ERROR_OK;
   252 using mbed::BD_ERROR_DEVICE_ERROR;
 virtual const char * get_type() const  =0
Get the BlockDevice class type. 
virtual int deinit()=0
Deinitialize a block device. 
virtual bool is_valid_read(bd_addr_t addr, bd_size_t size) const 
Convenience function for checking block read validity. 
virtual bd_size_t get_read_size() const  =0
Get the size of a readable block. 
A hardware device capable of writing and reading blocks. 
virtual int init()=0
Initialize a block device. 
virtual bd_size_t size() const  =0
Get the total size of the underlying device. 
virtual bd_size_t get_program_size() const  =0
Get the size of a programmable block. 
virtual int program(const void *buffer, bd_addr_t addr, bd_size_t size)=0
Program blocks to a block device. 
virtual bool is_valid_program(bd_addr_t addr, bd_size_t size) const 
Convenience function for checking block program validity. 
virtual bd_size_t get_erase_size(bd_addr_t addr) const 
Get the size of an erasable block given address. 
virtual int get_erase_value() const 
Get the value of storage when erased. 
virtual int sync()
Ensure data on storage is in sync with the driver. 
virtual bool is_valid_erase(bd_addr_t addr, bd_size_t size) const 
Convenience function for checking block erase validity. 
virtual int erase(bd_addr_t addr, bd_size_t size)
Erase blocks on a block device. 
static BlockDevice * get_default_instance()
Return the default block device. 
virtual int trim(bd_addr_t addr, bd_size_t size)
Mark blocks as no longer in use. 
virtual int read(void *buffer, bd_addr_t addr, bd_size_t size)=0
Read blocks from a block device. 
virtual ~BlockDevice()
Lifetime of a block device. 
virtual bd_size_t get_erase_size() const 
Get the size of an erasable block.