Skip to content

Commit ddc0405

Browse files
Merge branch 'release/v0.7.0'
2 parents de80681 + 75265fb commit ddc0405

File tree

12 files changed

+1733
-106
lines changed

12 files changed

+1733
-106
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
[package]
22
name = "neotron-common-bios"
3-
version = "0.4.0"
3+
version = "0.7.0"
44
authors = ["Jonathan 'theJPster' Pallant <[email protected]>"]
55
edition = "2018"
66
description = "Common BIOS code and API for all Neotron systems."
77
license = "GPL-3.0-or-later"
8+
repository = "https://github.com/neotron-compute/neotron-common-bios.git"
9+
homepage = "https://github.com/neotron-compute/neotron-common-bios"
10+
readme = "README.md"
811

912
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1013

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,42 @@ dual licensed as above, without any additional terms or conditions.
4141

4242
### Unreleased Changes
4343

44-
* None
44+
### v0.7.0
45+
46+
* Change `time_get` to `time_clock_get`
47+
* Change `time_set` to `time_clock_set`
48+
* Add `time_ticks_get` and `time_ticks_per_second`
49+
* Add `bus_interrupt_status`
50+
* Remove `delay`
51+
* Add back in the `block_XXX` API for reading/writing Block Devices.
52+
* Add idle function.
53+
* `memory_get_region` returns `Option`, not `Result`
54+
* Fix epoch used in conversion to chrono timestamp.
55+
56+
### v0.6.1
57+
58+
* No changes - v0.6.0 release was incorrect so re-releasing
59+
60+
### v0.6.0
61+
62+
* Removed 'block_X' APIs
63+
* Added 'bus_X' APIs
64+
* Added 'audio_X' APIs
65+
* Added 'i2c_X' APIs
66+
* Added 'video_get/set_palette' APIs
67+
* Added 'delay' API
68+
69+
### v0.5.0
70+
71+
* Added `serial_read` API
72+
* Added `video_mode_needs_vram` API
73+
* Added `hid_get_event` API
74+
* Added `hid_set_leds` API
75+
* Added `video_wait_for_line` API
76+
* Added `block_dev_get_info` API
77+
* Added `block_write` API
78+
* Added `block_read` API
79+
* Added `block_verify` API
4580

4681
### v0.4.0
4782

src/audio.rs

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
//! # Audio
2+
//!
3+
//! Audio related types.
4+
//!
5+
//! Note that all types in this file that are exported in the `Api` structure
6+
//! *must* be `#[repr(C)]` and ABI stable.
7+
8+
// Copyright (C) The Neotron Developers, 2019-2022
9+
//
10+
// This program is free software: you can redistribute it and/or modify
11+
// it under the terms of the GNU General Public License as published by
12+
// the Free Software Foundation, either version 3 of the License, or
13+
// at your option) any later version.
14+
//
15+
// This program is distributed in the hope that it will be useful,
16+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
// GNU General Public License for more details.
19+
//
20+
// You should have received a copy of the GNU General Public License
21+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
23+
// ============================================================================
24+
// Imports
25+
// ============================================================================
26+
27+
// None
28+
29+
// ============================================================================
30+
// Constants
31+
// ============================================================================
32+
33+
// None
34+
35+
// ============================================================================
36+
// Types
37+
// ============================================================================
38+
39+
/// Defines the format of each sample (mono, stereo, 8-bit, 16-bit, etc).
40+
#[repr(u8)]
41+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
42+
pub enum SampleFormat {
43+
/// 8-bit, signed, mono samples.
44+
EightBitMono,
45+
/// 8-bit, signed, mono samples. Left, then Right.
46+
EightBitStereo,
47+
/// 16-bit, signed, mono samples. Little-endian.
48+
SixteenBitMono,
49+
/// 16-bit, signed, stereo samples. Little-endian. Left, then Right.
50+
SixteenBitStereo,
51+
}
52+
53+
/// Configuration for an Audio Output or Input
54+
#[repr(C)]
55+
#[derive(Debug, Clone, PartialEq, Eq)]
56+
pub struct Config {
57+
/// What format are the samples
58+
pub sample_format: SampleFormat,
59+
/// How many samples are there per second (e.g. 48,000)?
60+
///
61+
/// Supported values are likely to include some of the following:
62+
///
63+
/// * 8,000 Hz (Telephone/Voice)
64+
/// * 11,025 Hz (CD Audio / 4)
65+
/// * 16,000 Hz (DVD Audio / 3)
66+
/// * 22,050 Hz (CD Audio / 2)
67+
/// * 24,000 Hz (DVD Audio / 2)
68+
/// * 44,100 Hz (CD Audio)
69+
/// * 48,000 Hz (DVD Audio)
70+
pub sample_rate_hz: u32,
71+
}
72+
73+
/// Describes the direction audio is flowing, for a given Audio Mixer Channel.
74+
#[repr(u8)]
75+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
76+
pub enum Direction {
77+
/// Audio In, e.g. Line-In
78+
Input,
79+
/// Audio Out, e.g. Headphone Out
80+
Output,
81+
/// Internal audio loop-back from an Input to an Output, e.g. Side-tone
82+
Loopback,
83+
}
84+
85+
/// Describes an Audio Mixer Channel.
86+
///
87+
/// For example "Line In", or "PCM Output"
88+
#[repr(C)]
89+
#[derive(Debug, Clone, PartialEq, Eq)]
90+
pub struct MixerChannelInfo {
91+
/// The name of this Audio Mixer Channel (e.g. `Line In`)
92+
pub name: crate::ApiString<'static>,
93+
/// Is this an Input or an Output?
94+
pub direction: Direction,
95+
/// What value of `current_level` gives the loudest audio? All values
96+
/// equal to, or above, this value will be equally and maximally loud.
97+
pub max_level: u8,
98+
/// What is the current volume level for this Audio Mixer Channel, on a
99+
/// scale of `0` to `max_level`. A value of `0` mutes the channel.
100+
pub current_level: u8,
101+
}
102+
103+
// ============================================================================
104+
// Impls
105+
// ============================================================================
106+
107+
// None
108+
109+
// ============================================================================
110+
// End of File
111+
// ============================================================================

src/block_dev.rs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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 block 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+
/// Uniquely represents a block on a block device.
76+
#[repr(C)]
77+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
78+
pub struct BlockIdx(pub u64);
79+
80+
// ============================================================================
81+
// Impls
82+
// ============================================================================
83+
84+
// None
85+
86+
// ============================================================================
87+
// End of File
88+
// ============================================================================

src/bus.rs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//! # Neotron Bus
2+
//!
3+
//! Neotron Bus related types.
4+
//!
5+
//! Note that all types in this file that are exported in the `Api` structure
6+
//! *must* be `#[repr(C)]` and ABI stable.
7+
8+
// Copyright (C) The Neotron Developers, 2019-2022
9+
//
10+
// This program is free software: you can redistribute it and/or modify
11+
// it under the terms of the GNU General Public License as published by
12+
// the Free Software Foundation, either version 3 of the License, or
13+
// at your option) any later version.
14+
//
15+
// This program is distributed in the hope that it will be useful,
16+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
// GNU General Public License for more details.
19+
//
20+
// You should have received a copy of the GNU General Public License
21+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
23+
// ============================================================================
24+
// Imports
25+
// ============================================================================
26+
27+
// None
28+
29+
// ============================================================================
30+
// Constants
31+
// ============================================================================
32+
33+
// None
34+
35+
// ============================================================================
36+
// Types
37+
// ============================================================================
38+
39+
/// The kinds of Peripheral you can put on a Neotron Bus
40+
#[repr(u8)]
41+
#[derive(Debug, Clone, Eq, PartialEq)]
42+
pub enum PeripheralKind {
43+
/// A Neotron Bus Slot. The OS will need to read the EEPROM at address
44+
/// `0x50 + slot_id` to find out what is fitted (if anything).
45+
Slot,
46+
/// A hard-wired SD/MMC Card slot wired for SPI Mode. The interrupt pin is
47+
/// wired to "Card Detect" with a pull-up, so the line goes low when a
48+
/// card is inserted and goes high when the card is removed.
49+
SdCard,
50+
/// This Peripheral ID is reserved for the BIOS to use.
51+
Reserved,
52+
}
53+
54+
/// Describes a Neotron Bus Peripheral
55+
#[repr(C)]
56+
#[derive(Debug, Clone, Eq, PartialEq)]
57+
pub struct PeripheralInfo {
58+
/// A name, such as `slot0`
59+
pub name: crate::ApiString<'static>,
60+
/// The kind of peripheral
61+
pub kind: PeripheralKind,
62+
}
63+
64+
// ============================================================================
65+
// Impls
66+
// ============================================================================
67+
68+
// None
69+
70+
// ============================================================================
71+
// End of File
72+
// ============================================================================

0 commit comments

Comments
 (0)