Skip to content

Commit e4ef7b2

Browse files
committed
API updates - serial read, HID, block devices.
1 parent 11da1f9 commit e4ef7b2

File tree

4 files changed

+642
-2
lines changed

4 files changed

+642
-2
lines changed

src/block_dev.rs

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

0 commit comments

Comments
 (0)