Skip to content

Commit

Permalink
Move BlockDevice classes inside mbed namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
deepikabhavnani committed Aug 3, 2018
1 parent 546dafb commit e36cd00
Show file tree
Hide file tree
Showing 27 changed files with 122 additions and 30 deletions.
2 changes: 1 addition & 1 deletion features/filesystem/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "platform/FileHandle.h"
#include "platform/DirHandle.h"
#include "platform/FileSystemLike.h"
#include "BlockDevice.h"
#include "bd/BlockDevice.h"

namespace mbed {
/** \addtogroup filesystem */
Expand Down
6 changes: 6 additions & 0 deletions features/filesystem/bd/BlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
#ifndef MBED_BLOCK_DEVICE_H
#define MBED_BLOCK_DEVICE_H

#include "platform/platform.h"
#include <stdint.h>

namespace mbed {
/** \addtogroup filesystem */
/** @{*/

/** Enum of standard error codes
*
Expand Down Expand Up @@ -219,5 +223,7 @@ class BlockDevice
}
};

/** @}*/
} // namespace mbed

#endif
4 changes: 4 additions & 0 deletions features/filesystem/bd/BufferedBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <algorithm>
#include <string.h>

namespace mbed {

static inline uint32_t align_down(bd_size_t val, bd_size_t size)
{
return val / size * size;
Expand Down Expand Up @@ -239,3 +241,5 @@ bd_size_t BufferedBlockDevice::size() const
{
return _bd->size();
}

} // namespace mbed
5 changes: 5 additions & 0 deletions features/filesystem/bd/BufferedBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include "BlockDevice.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/

/** Block device for allowing minimal read and program sizes (of 1) for the underlying BD,
* using a buffer on the heap.
Expand Down Expand Up @@ -163,5 +166,7 @@ class BufferedBlockDevice : public BlockDevice {

};

/** @}*/
} // namespace mbed

#endif
6 changes: 5 additions & 1 deletion features/filesystem/bd/ChainingBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
*/

#include "ChainingBlockDevice.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_assert.h"

namespace mbed {

ChainingBlockDevice::ChainingBlockDevice(BlockDevice **bds, size_t bd_count)
: _bds(bds), _bd_count(bd_count)
Expand Down Expand Up @@ -249,3 +251,5 @@ bd_size_t ChainingBlockDevice::size() const
{
return _size;
}

} // namespace mbed
6 changes: 5 additions & 1 deletion features/filesystem/bd/ChainingBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#define MBED_CHAINING_BLOCK_DEVICE_H

#include "BlockDevice.h"
#include "mbed.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/

/** Block device for chaining multiple block devices
* with the similar block sizes at sequential addresses
Expand Down Expand Up @@ -178,5 +180,7 @@ class ChainingBlockDevice : public BlockDevice
uint32_t _init_ref_count;
};

/** @}*/
} // namespace mbed

#endif
7 changes: 5 additions & 2 deletions features/filesystem/bd/ExhaustibleBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/

#include "ExhaustibleBlockDevice.h"
#include "mbed.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_assert.h"

namespace mbed {

ExhaustibleBlockDevice::ExhaustibleBlockDevice(BlockDevice *bd, uint32_t erase_cycles)
: _bd(bd), _erase_array(NULL), _erase_cycles(erase_cycles), _init_ref_count(0)
Expand Down Expand Up @@ -141,3 +142,5 @@ bd_size_t ExhaustibleBlockDevice::size() const
{
return _bd->size();
}

} // namespace mbed
5 changes: 5 additions & 0 deletions features/filesystem/bd/ExhaustibleBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include "BlockDevice.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/

/** Heap backed block device which simulates failures
*
Expand Down Expand Up @@ -157,5 +160,7 @@ class ExhaustibleBlockDevice : public BlockDevice
uint32_t _init_ref_count;
};

/** @}*/
} // namespace mbed

#endif
9 changes: 7 additions & 2 deletions features/filesystem/bd/FlashSimBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
*/

#include "FlashSimBlockDevice.h"
#include "mbed_assert.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_assert.h"

#include <algorithm>
#include <stdlib.h>
#include <string.h>

namespace mbed {

static const bd_size_t min_blank_buf_size = 32;

static inline uint32_t align_up(bd_size_t val, bd_size_t size)
Expand Down Expand Up @@ -160,3 +163,5 @@ int FlashSimBlockDevice::get_erase_value() const
{
return _erase_value;
}

} // namespace mbed
7 changes: 7 additions & 0 deletions features/filesystem/bd/FlashSimBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

#include "BlockDevice.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/

enum {
BD_ERROR_NOT_ERASED = -3201,
};
Expand Down Expand Up @@ -138,4 +142,7 @@ class FlashSimBlockDevice : public BlockDevice {
uint32_t _init_ref_count;
};

/** @}*/
} // namespace mbed

#endif
6 changes: 5 additions & 1 deletion features/filesystem/bd/HeapBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
*/

#include "HeapBlockDevice.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_assert.h"
#include <stdlib.h>

namespace mbed {

HeapBlockDevice::HeapBlockDevice(bd_size_t size, bd_size_t block)
: _read_size(block), _program_size(block), _erase_size(block)
Expand Down Expand Up @@ -166,3 +169,4 @@ int HeapBlockDevice::erase(bd_addr_t addr, bd_size_t size)
return 0;
}

} // namespace mbed
8 changes: 7 additions & 1 deletion features/filesystem/bd/HeapBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
#define MBED_MEM_BLOCK_DEVICE_H

#include "BlockDevice.h"
#include "mbed.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/



/** Lazily allocated heap-backed block device
Expand Down Expand Up @@ -153,5 +157,7 @@ class HeapBlockDevice : public BlockDevice
uint32_t _init_ref_count;
};

/** @}*/
} // namespace mbed

#endif
6 changes: 5 additions & 1 deletion features/filesystem/bd/MBRBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*/

#include "MBRBlockDevice.h"
#include "mbed_critical.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_assert.h"
#include <algorithm>

namespace mbed {

// On disk structures, all entries are little endian
MBED_PACKED(struct) mbr_entry {
Expand Down Expand Up @@ -340,3 +342,5 @@ int MBRBlockDevice::get_partition_number() const
{
return _part;
}

} // namespace mbed
6 changes: 5 additions & 1 deletion features/filesystem/bd/MBRBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#define MBED_MBR_BLOCK_DEVICE_H

#include "BlockDevice.h"
#include "mbed.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/

/** Additional error codes used for MBR records
*/
Expand Down Expand Up @@ -255,5 +257,7 @@ class MBRBlockDevice : public BlockDevice
uint32_t _init_ref_count;
};

/** @}*/
} // namespace mbed

#endif
4 changes: 3 additions & 1 deletion features/filesystem/bd/ObservingBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#include "ObservingBlockDevice.h"
#include "ReadOnlyBlockDevice.h"
#include "mbed.h"

namespace mbed {

ObservingBlockDevice::ObservingBlockDevice(BlockDevice *bd)
: _bd(bd)
Expand Down Expand Up @@ -110,3 +110,5 @@ bd_size_t ObservingBlockDevice::size() const
{
return _bd->size();
}

} // namespace mbed
6 changes: 5 additions & 1 deletion features/filesystem/bd/ObservingBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "PlatformMutex.h"
#include "Callback.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/

class ObservingBlockDevice : public BlockDevice
{
Expand Down Expand Up @@ -141,6 +144,7 @@ class ObservingBlockDevice : public BlockDevice
mbed::Callback<void(BlockDevice *)> _change;
};


/** @}*/
} // namespace mbed

#endif
3 changes: 3 additions & 0 deletions features/filesystem/bd/ProfilingBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "ProfilingBlockDevice.h"

namespace mbed {

ProfilingBlockDevice::ProfilingBlockDevice(BlockDevice *bd)
: _bd(bd)
Expand Down Expand Up @@ -118,3 +119,5 @@ bd_size_t ProfilingBlockDevice::get_erase_count() const
{
return _erase_count;
}

} // namespace mbed
6 changes: 5 additions & 1 deletion features/filesystem/bd/ProfilingBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#define MBED_PROFILING_BLOCK_DEVICE_H

#include "BlockDevice.h"
#include "mbed.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/

/** Block device for measuring storage operations of another block device
*
Expand Down Expand Up @@ -182,5 +184,7 @@ class ProfilingBlockDevice : public BlockDevice
bd_size_t _erase_count;
};

/** @}*/
} // namespace mbed

#endif
5 changes: 4 additions & 1 deletion features/filesystem/bd/ReadOnlyBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
*/

#include "ReadOnlyBlockDevice.h"
#include "mbed_error.h"
#include "platform/mbed_error.h"

namespace mbed {

ReadOnlyBlockDevice::ReadOnlyBlockDevice(BlockDevice *bd)
: _bd(bd)
Expand Down Expand Up @@ -96,3 +97,5 @@ bd_size_t ReadOnlyBlockDevice::size() const
{
return _bd->size();
}

} // namespace mbed
6 changes: 5 additions & 1 deletion features/filesystem/bd/ReadOnlyBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include "BlockDevice.h"
#include "PlatformMutex.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/

class ReadOnlyBlockDevice : public BlockDevice
{
Expand Down Expand Up @@ -133,6 +136,7 @@ class ReadOnlyBlockDevice : public BlockDevice
BlockDevice *_bd;
};


/** @}*/
} // namespace mbed

#endif
4 changes: 4 additions & 0 deletions features/filesystem/bd/SlicingBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

#include "SlicingBlockDevice.h"
#include "platform/mbed_assert.h"

namespace mbed {

SlicingBlockDevice::SlicingBlockDevice(BlockDevice *bd, bd_addr_t start, bd_addr_t stop)
: _bd(bd)
Expand Down Expand Up @@ -116,3 +118,5 @@ bd_size_t SlicingBlockDevice::size() const
{
return _stop - _start;
}

} // namespace mbed
7 changes: 6 additions & 1 deletion features/filesystem/bd/SlicingBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
#define MBED_SLICING_BLOCK_DEVICE_H

#include "BlockDevice.h"
#include "mbed.h"

namespace mbed {
/** \addtogroup filesystem */
/** @{*/


/** Block device for mapping to a slice of another block device
Expand Down Expand Up @@ -167,5 +170,7 @@ class SlicingBlockDevice : public BlockDevice
bd_size_t _stop;
};

/** @}*/
} // namespace mbed

#endif
Loading

0 comments on commit e36cd00

Please sign in to comment.