Overview   API Reference  

block_driver.hpp

00001 #if !defined(__BLOCK_DRIVER_HPP__)
00002 #define __BLOCK_DRIVER_HPP__
00003 
00004 //
00005 // local includes
00006 //
00007 #include "core/drivers/drivers.hpp"
00008 
00012 struct block_driver_constants
00013 {
00014     static const l4_sector_t MIN_SECTOR_NUMBER = 1024;
00015     static const uint16_t    SECTOR_SIZE       = 512;
00016 
00017     static_assert(is_unsigned<l4_sector_t>::conforms,
00018                   "l4_sector_t must be an unsigned integer");
00019 
00020     //
00021     // keep in sync with ata_drive::state_flags_constants
00022     //
00023     enum state_flags_constants
00024     {
00026         READONLY    = 0x01,
00028         FLUSHABLE   = 0x02,
00030         READY       = 0x04,
00031 
00033         ALL_MASK    = READONLY | FLUSHABLE | READY
00034     };
00035 
00036     typedef bitmask<uint_value_t<ALL_MASK>::least> state_flags;
00037     static_assert(integer_traits<state_flags::word_type>::const_max >= ALL_MASK,
00038                   "state_flags's max value is too small");
00039 };
00040 
00044 struct block_driver : public block_driver_constants
00045 {
00049     virtual inline ~block_driver(void)
00050     {}
00051 
00055     virtual const char *name(void) const = 0;
00056 
00060     virtual bool is(state_flags flags) const = 0;
00061 
00065     virtual const state_flags state(void) const = 0;
00066 
00071     virtual int reset(void) = 0;
00072 
00073     //
00074     // medium functions
00075     //
00079     virtual l4_sector_t sectors(void) const = 0;
00080 
00086     virtual int read_sectors(uint8_t *buffer, l4_sector_t sector, l4_sector_t number) = 0;
00087 
00093     virtual int write_sectors(uint8_t *buffer, l4_sector_t sector, l4_sector_t number) = 0;
00094 
00100     virtual int flush_sectors(void) = 0;
00101 };
00102 
00103 #endif
00104 
00105 // ***** end of source ***** //
00106 

L4vmm Reference Manual, written by Mario Schwalbe  © 2006-2008