Nicolas Borla
/
BBR_1Ebene
BBR 1 Ebene
mbed-os/features/filesystem/bd/ReadOnlyBlockDevice.cpp@0:fbdae7e6d805, 2018-05-14 (annotated)
- Committer:
- borlanic
- Date:
- Mon May 14 11:29:06 2018 +0000
- Revision:
- 0:fbdae7e6d805
BBR
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
borlanic | 0:fbdae7e6d805 | 1 | /* mbed Microcontroller Library |
borlanic | 0:fbdae7e6d805 | 2 | * Copyright (c) 2017-2017 ARM Limited |
borlanic | 0:fbdae7e6d805 | 3 | * |
borlanic | 0:fbdae7e6d805 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
borlanic | 0:fbdae7e6d805 | 5 | * of this software and associated documentation files (the "Software"), to deal |
borlanic | 0:fbdae7e6d805 | 6 | * in the Software without restriction, including without limitation the rights |
borlanic | 0:fbdae7e6d805 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
borlanic | 0:fbdae7e6d805 | 8 | * copies of the Software, and to permit persons to whom the Software is |
borlanic | 0:fbdae7e6d805 | 9 | * furnished to do so, subject to the following conditions: |
borlanic | 0:fbdae7e6d805 | 10 | * |
borlanic | 0:fbdae7e6d805 | 11 | * The above copyright notice and this permission notice shall be included in |
borlanic | 0:fbdae7e6d805 | 12 | * all copies or substantial portions of the Software. |
borlanic | 0:fbdae7e6d805 | 13 | * |
borlanic | 0:fbdae7e6d805 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
borlanic | 0:fbdae7e6d805 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
borlanic | 0:fbdae7e6d805 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
borlanic | 0:fbdae7e6d805 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
borlanic | 0:fbdae7e6d805 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
borlanic | 0:fbdae7e6d805 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
borlanic | 0:fbdae7e6d805 | 20 | * SOFTWARE. |
borlanic | 0:fbdae7e6d805 | 21 | */ |
borlanic | 0:fbdae7e6d805 | 22 | |
borlanic | 0:fbdae7e6d805 | 23 | #include "ReadOnlyBlockDevice.h" |
borlanic | 0:fbdae7e6d805 | 24 | #include "mbed_error.h" |
borlanic | 0:fbdae7e6d805 | 25 | |
borlanic | 0:fbdae7e6d805 | 26 | |
borlanic | 0:fbdae7e6d805 | 27 | ReadOnlyBlockDevice::ReadOnlyBlockDevice(BlockDevice *bd) |
borlanic | 0:fbdae7e6d805 | 28 | : _bd(bd) |
borlanic | 0:fbdae7e6d805 | 29 | { |
borlanic | 0:fbdae7e6d805 | 30 | // Does nothing |
borlanic | 0:fbdae7e6d805 | 31 | } |
borlanic | 0:fbdae7e6d805 | 32 | |
borlanic | 0:fbdae7e6d805 | 33 | ReadOnlyBlockDevice::~ReadOnlyBlockDevice() |
borlanic | 0:fbdae7e6d805 | 34 | { |
borlanic | 0:fbdae7e6d805 | 35 | // Does nothing |
borlanic | 0:fbdae7e6d805 | 36 | } |
borlanic | 0:fbdae7e6d805 | 37 | |
borlanic | 0:fbdae7e6d805 | 38 | int ReadOnlyBlockDevice::init() |
borlanic | 0:fbdae7e6d805 | 39 | { |
borlanic | 0:fbdae7e6d805 | 40 | return _bd->init(); |
borlanic | 0:fbdae7e6d805 | 41 | } |
borlanic | 0:fbdae7e6d805 | 42 | |
borlanic | 0:fbdae7e6d805 | 43 | int ReadOnlyBlockDevice::deinit() |
borlanic | 0:fbdae7e6d805 | 44 | { |
borlanic | 0:fbdae7e6d805 | 45 | return _bd->deinit(); |
borlanic | 0:fbdae7e6d805 | 46 | } |
borlanic | 0:fbdae7e6d805 | 47 | |
borlanic | 0:fbdae7e6d805 | 48 | int ReadOnlyBlockDevice::sync() |
borlanic | 0:fbdae7e6d805 | 49 | { |
borlanic | 0:fbdae7e6d805 | 50 | return _bd->sync(); |
borlanic | 0:fbdae7e6d805 | 51 | } |
borlanic | 0:fbdae7e6d805 | 52 | |
borlanic | 0:fbdae7e6d805 | 53 | int ReadOnlyBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) |
borlanic | 0:fbdae7e6d805 | 54 | { |
borlanic | 0:fbdae7e6d805 | 55 | return _bd->read(buffer, addr, size); |
borlanic | 0:fbdae7e6d805 | 56 | } |
borlanic | 0:fbdae7e6d805 | 57 | |
borlanic | 0:fbdae7e6d805 | 58 | int ReadOnlyBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size) |
borlanic | 0:fbdae7e6d805 | 59 | { |
borlanic | 0:fbdae7e6d805 | 60 | error("ReadOnlyBlockDevice::program() not allowed"); |
borlanic | 0:fbdae7e6d805 | 61 | return 0; |
borlanic | 0:fbdae7e6d805 | 62 | } |
borlanic | 0:fbdae7e6d805 | 63 | |
borlanic | 0:fbdae7e6d805 | 64 | int ReadOnlyBlockDevice::erase(bd_addr_t addr, bd_size_t size) |
borlanic | 0:fbdae7e6d805 | 65 | { |
borlanic | 0:fbdae7e6d805 | 66 | error("ReadOnlyBlockDevice::erase() not allowed"); |
borlanic | 0:fbdae7e6d805 | 67 | return 0; |
borlanic | 0:fbdae7e6d805 | 68 | } |
borlanic | 0:fbdae7e6d805 | 69 | |
borlanic | 0:fbdae7e6d805 | 70 | bd_size_t ReadOnlyBlockDevice::get_read_size() const |
borlanic | 0:fbdae7e6d805 | 71 | { |
borlanic | 0:fbdae7e6d805 | 72 | return _bd->get_read_size(); |
borlanic | 0:fbdae7e6d805 | 73 | } |
borlanic | 0:fbdae7e6d805 | 74 | |
borlanic | 0:fbdae7e6d805 | 75 | bd_size_t ReadOnlyBlockDevice::get_program_size() const |
borlanic | 0:fbdae7e6d805 | 76 | { |
borlanic | 0:fbdae7e6d805 | 77 | return _bd->get_program_size(); |
borlanic | 0:fbdae7e6d805 | 78 | } |
borlanic | 0:fbdae7e6d805 | 79 | |
borlanic | 0:fbdae7e6d805 | 80 | bd_size_t ReadOnlyBlockDevice::get_erase_size() const |
borlanic | 0:fbdae7e6d805 | 81 | { |
borlanic | 0:fbdae7e6d805 | 82 | return _bd->get_erase_size(); |
borlanic | 0:fbdae7e6d805 | 83 | } |
borlanic | 0:fbdae7e6d805 | 84 | |
borlanic | 0:fbdae7e6d805 | 85 | bd_size_t ReadOnlyBlockDevice::get_erase_size(bd_addr_t addr) const |
borlanic | 0:fbdae7e6d805 | 86 | { |
borlanic | 0:fbdae7e6d805 | 87 | return _bd->get_erase_size(addr); |
borlanic | 0:fbdae7e6d805 | 88 | } |
borlanic | 0:fbdae7e6d805 | 89 | |
borlanic | 0:fbdae7e6d805 | 90 | int ReadOnlyBlockDevice::get_erase_value() const |
borlanic | 0:fbdae7e6d805 | 91 | { |
borlanic | 0:fbdae7e6d805 | 92 | return _bd->get_erase_value(); |
borlanic | 0:fbdae7e6d805 | 93 | } |
borlanic | 0:fbdae7e6d805 | 94 | |
borlanic | 0:fbdae7e6d805 | 95 | bd_size_t ReadOnlyBlockDevice::size() const |
borlanic | 0:fbdae7e6d805 | 96 | { |
borlanic | 0:fbdae7e6d805 | 97 | return _bd->size(); |
borlanic | 0:fbdae7e6d805 | 98 | } |