Skip to content

Commit 88b631b

Browse files
jonathanpallantthejpster
authored andcommitted
Change mem to lshw.
1 parent 5549b91 commit 88b631b

File tree

1 file changed

+81
-13
lines changed

1 file changed

+81
-13
lines changed

src/lib.rs

Lines changed: 81 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ static OS_MENU: menu::Menu<Ctx> = menu::Menu {
4242
items: &[
4343
&menu::Item {
4444
item_type: menu::ItemType::Callback {
45-
function: cmd_mem,
45+
function: cmd_lshw,
4646
parameters: &[],
4747
},
48-
command: "mem",
49-
help: Some("Show memory regions"),
48+
command: "lshw",
49+
help: Some("List all the hardware"),
5050
},
5151
&menu::Item {
5252
item_type: menu::ItemType::Callback {
@@ -309,22 +309,90 @@ pub extern "C" fn main(api: *const bios::Api) -> ! {
309309
}
310310
}
311311

312-
/// Called when the "mem" command is executed.
313-
fn cmd_mem(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _context: &mut Ctx) {
314-
println!("Memory Regions:");
315-
let mut found = false;
312+
/// Called when the "lshw" command is executed.
313+
fn cmd_lshw(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _context: &mut Ctx) {
316314
let api = API.get();
317-
for region_idx in 0..=255 {
315+
let mut found = false;
316+
317+
println!("Memory regions:");
318+
for region_idx in 0..=255u8 {
318319
if let bios::Option::Some(region) = (api.memory_get_region)(region_idx) {
319-
println!("Region {}: {}", region_idx, region);
320+
println!(" {}: {}", region_idx, region);
321+
found = true;
322+
}
323+
}
324+
if !found {
325+
println!(" None");
326+
}
327+
328+
println!();
329+
found = false;
330+
331+
println!("Serial Devices:");
332+
for dev_idx in 0..=255u8 {
333+
if let bios::Option::Some(device_info) = (api.serial_get_info)(dev_idx) {
334+
println!(" {}: {:?}", dev_idx, device_info);
335+
found = true;
336+
}
337+
}
338+
if !found {
339+
println!(" None");
340+
}
341+
342+
println!();
343+
found = false;
344+
345+
println!("Block Devices:");
346+
for dev_idx in 0..=255u8 {
347+
if let bios::Option::Some(device_info) = (api.block_dev_get_info)(dev_idx) {
348+
println!(" {}: {:?}", dev_idx, device_info);
349+
found = true;
350+
}
351+
}
352+
if !found {
353+
println!(" None");
354+
}
355+
356+
println!();
357+
found = false;
358+
359+
println!("I2C Buses:");
360+
for dev_idx in 0..=255u8 {
361+
if let bios::Option::Some(device_info) = (api.i2c_bus_get_info)(dev_idx) {
362+
println!(" {}: {:?}", dev_idx, device_info);
363+
found = true;
364+
}
365+
}
366+
if !found {
367+
println!(" None");
368+
}
369+
370+
println!();
371+
found = false;
372+
373+
println!("Neotron Bus Devices:");
374+
for dev_idx in 0..=255u8 {
375+
if let bios::Option::Some(device_info) = (api.bus_get_info)(dev_idx) {
376+
println!(" {}: {:?}", dev_idx, device_info);
377+
found = true;
378+
}
379+
}
380+
if !found {
381+
println!(" None");
382+
}
383+
384+
println!();
385+
found = false;
386+
387+
println!("Audio Mixers:");
388+
for dev_idx in 0..=255u8 {
389+
if let bios::Result::Ok(device_info) = (api.audio_mixer_channel_get_info)(dev_idx) {
390+
println!(" {}: {:?}", dev_idx, device_info);
320391
found = true;
321-
} else {
322-
// Ran out of regions (we assume they are consecutive)
323-
break;
324392
}
325393
}
326394
if !found {
327-
println!("None.");
395+
println!(" None");
328396
}
329397
}
330398

0 commit comments

Comments
 (0)