Skip to content

Commit 6da079f

Browse files
committed
Update to latest common crate.
1 parent 247ab45 commit 6da079f

File tree

6 files changed

+49
-79
lines changed

6 files changed

+49
-79
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ panic = "abort"
4141
panic = "abort"
4242

4343
[dependencies]
44-
neotron-common-bios = "0.11.1"
44+
neotron-common-bios = { git = "https://github.com/neotron-compute/neotron-common-bios" }
4545
pc-keyboard = "0.7"
4646
r0 = "1.0"
4747
heapless = "0.7"

src/commands/hardware.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,11 @@ fn lsbus(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx:
152152
osprintln!("Neotron Bus Devices:");
153153
for dev_idx in 0..=255u8 {
154154
if let bios::FfiOption::Some(device_info) = (api.bus_get_info)(dev_idx) {
155-
let kind = match device_info.kind {
156-
bios::bus::PeripheralKind::Slot => "Slot",
157-
bios::bus::PeripheralKind::SdCard => "SdCard",
158-
bios::bus::PeripheralKind::Reserved => "Reserved",
155+
let kind = match device_info.kind.make_safe() {
156+
Ok(bios::bus::PeripheralKind::Slot) => "Slot",
157+
Ok(bios::bus::PeripheralKind::SdCard) => "SdCard",
158+
Ok(bios::bus::PeripheralKind::Reserved) => "Reserved",
159+
_ => "Unknown",
159160
};
160161
osprintln!("\t{}: {} ({})", dev_idx, device_info.name, kind);
161162
found = true;
@@ -205,11 +206,12 @@ fn lsuart(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx
205206
osprintln!("UART Devices:");
206207
for dev_idx in 0..=255u8 {
207208
if let bios::FfiOption::Some(device_info) = (api.serial_get_info)(dev_idx) {
208-
let device_type = match device_info.device_type {
209-
bios::serial::DeviceType::Rs232 => "RS232",
210-
bios::serial::DeviceType::TtlUart => "TTL",
211-
bios::serial::DeviceType::UsbCdc => "USB",
212-
bios::serial::DeviceType::Midi => "MIDI",
209+
let device_type = match device_info.device_type.make_safe() {
210+
Ok(bios::serial::DeviceType::Rs232) => "RS232",
211+
Ok(bios::serial::DeviceType::TtlUart) => "TTL",
212+
Ok(bios::serial::DeviceType::UsbCdc) => "USB",
213+
Ok(bios::serial::DeviceType::Midi) => "MIDI",
214+
_ => "Unknown",
213215
};
214216
osprintln!("\t{}: {} ({})", dev_idx, device_info.name, device_type);
215217
found = true;
@@ -225,13 +227,13 @@ fn shutdown(_menu: &menu::Menu<Ctx>, item: &menu::Item<Ctx>, args: &[&str], _ctx
225227
let api = API.get();
226228
if let Ok(Some(_)) = menu::argument_finder(item, args, "reboot") {
227229
osprintln!("Rebooting...");
228-
(api.power_control)(bios::PowerMode::Reset);
230+
(api.power_control)(bios::PowerMode::Reset.make_ffi_safe());
229231
} else if let Ok(Some(_)) = menu::argument_finder(item, args, "bootloader") {
230232
osprintln!("Rebooting into bootloader...");
231-
(api.power_control)(bios::PowerMode::Bootloader);
233+
(api.power_control)(bios::PowerMode::Bootloader.make_ffi_safe());
232234
} else {
233235
osprintln!("Shutting down...");
234-
(api.power_control)(bios::PowerMode::Off);
236+
(api.power_control)(bios::PowerMode::Off.make_ffi_safe());
235237
}
236238
}
237239

src/commands/sound.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ fn mixer(_menu: &menu::Menu<Ctx>, item: &menu::Item<Ctx>, args: &[&str], _ctx: &
8888
for mixer_id in 0u8..=255u8 {
8989
match (api.audio_mixer_channel_get_info)(mixer_id) {
9090
bios::FfiOption::Some(mixer_info) => {
91-
let dir_str = match mixer_info.direction {
92-
bios::audio::Direction::Input => "In",
93-
bios::audio::Direction::Loopback => "Loop",
94-
bios::audio::Direction::Output => "Out",
91+
let dir_str = match mixer_info.direction.make_safe() {
92+
Ok(bios::audio::Direction::Input) => "In",
93+
Ok(bios::audio::Direction::Loopback) => "Loop",
94+
Ok(bios::audio::Direction::Output) => "Out",
95+
_ => "??",
9596
};
9697
if (Some(mixer_id) == mixer_int)
9798
|| selected_mixer

src/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ impl Config {
5555
0,
5656
bios::serial::Config {
5757
data_rate_bps: self.serial_baud,
58-
data_bits: bios::serial::DataBits::Eight,
59-
stop_bits: bios::serial::StopBits::One,
60-
parity: bios::serial::Parity::None,
61-
handshaking: bios::serial::Handshaking::None,
58+
data_bits: bios::serial::DataBits::Eight.make_ffi_safe(),
59+
stop_bits: bios::serial::StopBits::One.make_ffi_safe(),
60+
parity: bios::serial::Parity::None.make_ffi_safe(),
61+
handshaking: bios::serial::Handshaking::None.make_ffi_safe(),
6262
},
6363
))
6464
} else {

src/vgaconsole.rs

Lines changed: 24 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ pub struct VgaConsole {
4747
impl VgaConsole {
4848
/// White on Black
4949
const DEFAULT_ATTR: Attr = Attr::new(
50-
TextForegroundColour::LIGHT_GRAY,
51-
TextBackgroundColour::BLACK,
50+
TextForegroundColour::LightGray,
51+
TextBackgroundColour::Black,
5252
false,
5353
);
5454

@@ -127,8 +127,8 @@ struct ConsoleInner {
127127

128128
impl ConsoleInner {
129129
const DEFAULT_ATTR: Attr = Attr::new(
130-
TextForegroundColour::LIGHT_GRAY,
131-
TextBackgroundColour::BLACK,
130+
TextForegroundColour::LightGray,
131+
TextBackgroundColour::Black,
132132
false,
133133
);
134134

@@ -239,13 +239,9 @@ impl ConsoleInner {
239239
let offset = ((row * self.width) + col) * 2;
240240
unsafe { core::ptr::write_volatile(self.addr.offset(offset), glyph) };
241241
let attr = if self.reverse {
242-
let new_fg = self.attr.bg().as_u8();
243-
let new_bg = self.attr.fg().as_u8();
244-
Attr::new(
245-
unsafe { TextForegroundColour::new_unchecked(new_fg) },
246-
unsafe { TextBackgroundColour::new_unchecked(new_bg & 0x07) },
247-
false,
248-
)
242+
let new_fg = self.attr.bg().make_foreground();
243+
let new_bg = self.attr.fg().make_background();
244+
Attr::new(new_fg, new_bg, false)
249245
} else {
250246
self.attr
251247
};
@@ -566,53 +562,53 @@ impl vte::Perform for ConsoleInner {
566562
}
567563
// Foreground
568564
30 => {
569-
self.attr.set_fg(TextForegroundColour::BLACK);
565+
self.attr.set_fg(TextForegroundColour::Black);
570566
}
571567
31 => {
572-
self.attr.set_fg(TextForegroundColour::RED);
568+
self.attr.set_fg(TextForegroundColour::Red);
573569
}
574570
32 => {
575-
self.attr.set_fg(TextForegroundColour::GREEN);
571+
self.attr.set_fg(TextForegroundColour::Green);
576572
}
577573
33 => {
578-
self.attr.set_fg(TextForegroundColour::BROWN);
574+
self.attr.set_fg(TextForegroundColour::Brown);
579575
}
580576
34 => {
581-
self.attr.set_fg(TextForegroundColour::BLUE);
577+
self.attr.set_fg(TextForegroundColour::Blue);
582578
}
583579
35 => {
584-
self.attr.set_fg(TextForegroundColour::MAGENTA);
580+
self.attr.set_fg(TextForegroundColour::Magenta);
585581
}
586582
36 => {
587-
self.attr.set_fg(TextForegroundColour::CYAN);
583+
self.attr.set_fg(TextForegroundColour::Cyan);
588584
}
589585
37 | 39 => {
590-
self.attr.set_fg(TextForegroundColour::LIGHT_GRAY);
586+
self.attr.set_fg(TextForegroundColour::LightGray);
591587
}
592588
// Background
593589
40 => {
594-
self.attr.set_bg(TextBackgroundColour::BLACK);
590+
self.attr.set_bg(TextBackgroundColour::Black);
595591
}
596592
41 => {
597-
self.attr.set_bg(TextBackgroundColour::RED);
593+
self.attr.set_bg(TextBackgroundColour::Red);
598594
}
599595
42 => {
600-
self.attr.set_bg(TextBackgroundColour::GREEN);
596+
self.attr.set_bg(TextBackgroundColour::Green);
601597
}
602598
43 => {
603-
self.attr.set_bg(TextBackgroundColour::BROWN);
599+
self.attr.set_bg(TextBackgroundColour::Brown);
604600
}
605601
44 => {
606-
self.attr.set_bg(TextBackgroundColour::BLUE);
602+
self.attr.set_bg(TextBackgroundColour::Blue);
607603
}
608604
45 => {
609-
self.attr.set_bg(TextBackgroundColour::MAGENTA);
605+
self.attr.set_bg(TextBackgroundColour::Magenta);
610606
}
611607
46 => {
612-
self.attr.set_bg(TextBackgroundColour::CYAN);
608+
self.attr.set_bg(TextBackgroundColour::Cyan);
613609
}
614610
47 | 49 => {
615-
self.attr.set_bg(TextBackgroundColour::LIGHT_GRAY);
611+
self.attr.set_bg(TextBackgroundColour::LightGray);
616612
}
617613
_ => {
618614
// Ignore unknown code
@@ -623,35 +619,7 @@ impl vte::Perform for ConsoleInner {
623619
// last, because they might set the colour first and set the
624620
// bright bit afterwards.
625621
if self.bright {
626-
match self.attr.fg() {
627-
TextForegroundColour::BLACK => {
628-
self.attr.set_fg(TextForegroundColour::DARK_GRAY);
629-
}
630-
TextForegroundColour::RED => {
631-
self.attr.set_fg(TextForegroundColour::LIGHT_RED);
632-
}
633-
TextForegroundColour::GREEN => {
634-
self.attr.set_fg(TextForegroundColour::LIGHT_GREEN);
635-
}
636-
TextForegroundColour::BROWN => {
637-
self.attr.set_fg(TextForegroundColour::YELLOW);
638-
}
639-
TextForegroundColour::BLUE => {
640-
self.attr.set_fg(TextForegroundColour::LIGHT_BLUE);
641-
}
642-
TextForegroundColour::MAGENTA => {
643-
self.attr.set_fg(TextForegroundColour::PINK);
644-
}
645-
TextForegroundColour::CYAN => {
646-
self.attr.set_fg(TextForegroundColour::LIGHT_CYAN);
647-
}
648-
TextForegroundColour::LIGHT_GRAY => {
649-
self.attr.set_fg(TextForegroundColour::WHITE);
650-
}
651-
_ => {
652-
// Do nothing
653-
}
654-
}
622+
self.attr.set_fg(self.attr.fg().brighten())
655623
}
656624
}
657625
'A' => {

0 commit comments

Comments
 (0)