|
| 1 | +//! # Block Devices |
| 2 | +//! |
| 3 | +//! Block Device related types. |
| 4 | +//! |
| 5 | +//! Note that all types in this file *must* be `#[repr(C)]` and ABI stable. |
| 6 | +
|
| 7 | +// Copyright (C) The Neotron Developers, 2019-2022 |
| 8 | +// |
| 9 | +// This program is free software: you can redistribute it and/or modify |
| 10 | +// it under the terms of the GNU General Public License as published by |
| 11 | +// the Free Software Foundation, either version 3 of the License, or |
| 12 | +// at your option) any later version. |
| 13 | +// |
| 14 | +// This program is distributed in the hope that it will be useful, |
| 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | +// GNU General Public License for more details. |
| 18 | +// |
| 19 | +// You should have received a copy of the GNU General Public License |
| 20 | +// along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 21 | + |
| 22 | +// ============================================================================ |
| 23 | +// Imports |
| 24 | +// ============================================================================ |
| 25 | + |
| 26 | +// None |
| 27 | + |
| 28 | +// ============================================================================ |
| 29 | +// Constants |
| 30 | +// ============================================================================ |
| 31 | + |
| 32 | +// None |
| 33 | + |
| 34 | +// ============================================================================ |
| 35 | +// Types |
| 36 | +// ============================================================================ |
| 37 | + |
| 38 | +/// The types of block device we support. |
| 39 | +#[repr(C)] |
| 40 | +#[derive(Clone, PartialEq, Eq, Debug)] |
| 41 | +pub enum DeviceType { |
| 42 | + /// An *SD* Card |
| 43 | + SecureDigitalCard, |
| 44 | + /// A Hard Drive |
| 45 | + HardDiskDrive, |
| 46 | + /// A floppy disk in a floppy disk drive |
| 47 | + FloppyDiskDrive, |
| 48 | + /// A compact flash card |
| 49 | + CompactFlashCard, |
| 50 | +} |
| 51 | + |
| 52 | +/// Information about a block device. |
| 53 | +#[repr(C)] |
| 54 | +#[derive(Clone, PartialEq, Eq, Debug)] |
| 55 | +pub struct DeviceInfo { |
| 56 | + /// Some human-readable name for this serial device (e.g. `SdCard0` or |
| 57 | + /// `CF1`) |
| 58 | + pub name: crate::ApiString<'static>, |
| 59 | + /// The kind of block device this is. |
| 60 | + pub device_type: DeviceType, |
| 61 | + /// The size of an addressable block, in bytes. |
| 62 | + pub block_size: u32, |
| 63 | + /// The total number of addressable blocks. |
| 64 | + pub num_blocks: u64, |
| 65 | + /// Can this device be ejected? |
| 66 | + pub ejectable: bool, |
| 67 | + /// Can this device be removed? |
| 68 | + pub removable: bool, |
| 69 | + /// Does this have media in it right now? |
| 70 | + pub media_present: bool, |
| 71 | + /// Is this media read-only? |
| 72 | + pub read_only: bool, |
| 73 | +} |
| 74 | + |
| 75 | +// ============================================================================ |
| 76 | +// Impls |
| 77 | +// ============================================================================ |
| 78 | + |
| 79 | +// None |
| 80 | + |
| 81 | +// ============================================================================ |
| 82 | +// End of File |
| 83 | +// ============================================================================ |
0 commit comments