summaryrefslogtreecommitdiffstats
path: root/shell/src/lib.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-07-31 02:58:31 +0200
committersalmonik <salmonik@tuta.io>2026-07-31 02:58:31 +0200
commit6a5c32fa6ae8ec34e3e5b44d7e5a78ded8fe729b (patch)
treeed59a5bd59a94b3a731b28c68c507f18afc44b0b /shell/src/lib.rs
parentauto-version all strings from Cargo.toml via env!("CARGO_PKG_VERSION") (diff)
downloadrs-dos-6a5c32fa6ae8ec34e3e5b44d7e5a78ded8fe729b.tar.gz
rs-dos-6a5c32fa6ae8ec34e3e5b44d7e5a78ded8fe729b.zip
restructure: rsnix kernel + shell crate + rsdos entry point
Architecture: rs-dos/ (workspace root, was raisernics/) ├── rsnix/ — kernel lib crate (uefi, serial, gop, ps2, interrupts, memory) ├── shell/ — shell lib crate (prompt, commands, line input) ├── rsdos/ — binary crate (efi_main, init, panic handler) └── rsboot/ — future git submodule No functional changes — boots to shell prompt identically. Version auto-pulled from Cargo.toml via env!("CARGO_PKG_VERSION").
Diffstat (limited to '')
-rw-r--r--shell/src/lib.rs (renamed from src/shell.rs)42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/shell.rs b/shell/src/lib.rs
index 8e4cb62..bdd79c6 100644
--- a/src/shell.rs
+++ b/shell/src/lib.rs
@@ -1,14 +1,24 @@
1#![no_std]
2
3extern crate alloc;
4
1/// Minimal command shell — reads from PS/2 keyboard, writes to GOP + serial. 5/// Minimal command shell — reads from PS/2 keyboard, writes to GOP + serial.
2use crate::ps2::{self, KeyEvent}; 6use rsnix::ps2::{self, KeyEvent};
3use crate::{gop_print, gop_println, serial_print, serial_println}; 7use rsnix::{gop_print, gop_println, serial_print, serial_println};
4 8
5/// Maximum input line length. 9/// Maximum input line length.
6const LINE_BUF_SIZE: usize = 256; 10const LINE_BUF_SIZE: usize = 256;
7 11
8/// Run the shell forever. 12/// Run the shell forever.
9pub fn run() -> ! { 13pub fn run() -> ! {
10 gop_println!("raisernics v{} — type 'help' for commands", env!("CARGO_PKG_VERSION")); 14 gop_println!(
11 serial_println!("========== raisernics v{} ==========", env!("CARGO_PKG_VERSION")); 15 "rs-dos v{} — type 'help' for commands",
16 env!("CARGO_PKG_VERSION")
17 );
18 serial_println!(
19 "========== rs-dos v{} ==========",
20 env!("CARGO_PKG_VERSION")
21 );
12 22
13 loop { 23 loop {
14 // Print prompt 24 // Print prompt
@@ -53,32 +63,32 @@ fn read_line() -> heapless_str::String<LINE_BUF_SIZE> {
53 loop { 63 loop {
54 match ps2::poll_key() { 64 match ps2::poll_key() {
55 KeyEvent::Enter => { 65 KeyEvent::Enter => {
56 crate::gop::put_char('\n'); 66 rsnix::gop::put_char('\n');
57 crate::serial::write_str("\r\n"); 67 rsnix::serial::write_str("\r\n");
58 return buf; 68 return buf;
59 } 69 }
60 KeyEvent::Char(c) if c.is_ascii_graphic() || c == ' ' => { 70 KeyEvent::Char(c) if c.is_ascii_graphic() || c == ' ' => {
61 if buf.push(c).is_ok() { 71 if buf.push(c).is_ok() {
62 crate::gop::put_char(c); 72 rsnix::gop::put_char(c);
63 // Echo to serial too 73 // Echo to serial too
64 let mut s = [0u8; 4]; 74 let mut s = [0u8; 4];
65 let s = c.encode_utf8(&mut s); 75 let s = c.encode_utf8(&mut s);
66 crate::serial::write_str(s); 76 rsnix::serial::write_str(s);
67 } 77 }
68 } 78 }
69 KeyEvent::Backspace => { 79 KeyEvent::Backspace => {
70 if buf.pop().is_some() { 80 if buf.pop().is_some() {
71 // GOP backspace: move cursor back and erase 81 // GOP backspace: move cursor back and erase
72 crate::gop::put_char('\x08'); 82 rsnix::gop::put_char('\x08');
73 // Serial backspace: send BS SP BS (standard terminal protocol) 83 // Serial backspace: send BS SP BS (standard terminal protocol)
74 crate::serial::write_str("\x08 \x08"); 84 rsnix::serial::write_str("\x08 \x08");
75 } 85 }
76 } 86 }
77 KeyEvent::Tab => { 87 KeyEvent::Tab => {
78 for _ in 0..4 { 88 for _ in 0..4 {
79 if buf.push(' ').is_ok() { 89 if buf.push(' ').is_ok() {
80 crate::gop::put_char(' '); 90 rsnix::gop::put_char(' ');
81 crate::serial::write_str(" "); 91 rsnix::serial::write_str(" ");
82 } 92 }
83 } 93 }
84 } 94 }
@@ -120,14 +130,14 @@ fn cmd_echo(args: &str) {
120} 130}
121 131
122fn cmd_clear() { 132fn cmd_clear() {
123 crate::gop::clear_screen(); 133 rsnix::gop::clear_screen();
124} 134}
125 135
126fn cmd_info() { 136fn cmd_info() {
127 // Test that the global allocator works: build a String on the heap 137 // Test that the global allocator works: build a String on the heap
128 let mut s = alloc::string::String::from("raisernics v"); 138 let mut s = alloc::string::String::from("rs-dos v");
129 s.push_str(env!("CARGO_PKG_VERSION")); 139 s.push_str(env!("CARGO_PKG_VERSION"));
130 s.push_str(" — RNG custom kernel"); 140 s.push_str(" — rsnix kernel");
131 gop_println!("{}", s); 141 gop_println!("{}", s);
132 gop_println!("arch: x86_64, freestanding, no userspace"); 142 gop_println!("arch: x86_64, freestanding, no userspace");
133 serial_println!("{}", s); 143 serial_println!("{}", s);
@@ -136,7 +146,7 @@ fn cmd_info() {
136} 146}
137 147
138fn cmd_mem() { 148fn cmd_mem() {
139 let (map, key) = crate::memory::get_map(); 149 let (map, key) = rsnix::memory::get_map();
140 150
141 let mut total_kb = 0u64; 151 let mut total_kb = 0u64;
142 let mut conventional_kb = 0u64; 152 let mut conventional_kb = 0u64;