Skip to content

Commit 058ddd2

Browse files
authored
Merge pull request #8 from Neotron-Compute/api_updates
API updates
2 parents 11da1f9 + 09a5684 commit 058ddd2

File tree

6 files changed

+706
-54
lines changed

6 files changed

+706
-54
lines changed

src/block_dev.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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 kinds of block device we support.
39+
#[repr(C)]
40+
#[derive(Clone, PartialEq, Eq, Debug)]
41+
pub enum Kind {
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+
/// The kind of block device this is.
57+
kind: Kind,
58+
/// The size of an addressable block, in bytes.
59+
block_size: u32,
60+
/// The total number of addressable blocks.
61+
num_blocks: u64,
62+
/// Can this device be ejected?
63+
ejectable: bool,
64+
/// Can this device be removed?
65+
removable: bool,
66+
/// Does this have media in it right now?
67+
media_present: bool,
68+
/// Is this media read-only?
69+
read_only: bool,
70+
}
71+
72+
// ============================================================================
73+
// Impls
74+
// ============================================================================
75+
76+
// None
77+
78+
// ============================================================================
79+
// End of File
80+
// ============================================================================

0 commit comments

Comments
 (0)