diff options
| author | bors <bors@rust-lang.org> | 2023-10-02 00:03:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-02 00:03:52 +0000 |
| commit | 79bfd93d5a9cf73d312b72158c1d2289453c18c7 (patch) | |
| tree | 73801f2f536d328816d27ecfeb4d7261bc2396f4 /src | |
| parent | e0d7ed1f453fb54578cc96dfea859b0e7be15016 (diff) | |
| parent | 3f4a289016ed2c7ae351dd77c309ca17ecc1f87a (diff) | |
Auto merge of #116207 - Ayush1325:uefi_stdio, r=Mark-Simulacrum
Stdio support for UEFI - Uses Simple Text Output Protocol and Simple Text Input Protocol - Reading is done one character at a time - Writing is done with max 4096 characters # Quirks ## Output Newline - UEFI uses CRLF for newline. So when running the application in UEFI shell (qemu VGA), the output of `println` looks weird. - However, since the UEFI shell supports piping output, I am unsure if doing any output post-processing is a good idea. UEFI shell `cat` command seems to work fine with just LF. ## Input Newline - `Stdin.read_line()` method is broken in UEFI shell. Pressing enter seems to be read as CR, which means LF is never encountered. - Works fine with input redirection from file. CC `@dvdhrm`
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/rustc/src/platform-support/unknown-uefi.md | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/doc/rustc/src/platform-support/unknown-uefi.md b/src/doc/rustc/src/platform-support/unknown-uefi.md index 68cd7fae319..370939520dc 100644 --- a/src/doc/rustc/src/platform-support/unknown-uefi.md +++ b/src/doc/rustc/src/platform-support/unknown-uefi.md @@ -265,9 +265,12 @@ cargo build --target x86_64-unknown-uefi -Zbuild-std=std,panic_abort #### os_str - While the strings in UEFI should be valid UCS-2, in practice, many implementations just do not care and use UTF-16 strings. - Thus, the current implementation supports full UTF-16 strings. +#### stdio +- Uses `Simple Text Input Protocol` and `Simple Text Output Protocol`. +- Note: UEFI uses CRLF for new line. This means Enter key is registered as CR instead of LF. ## Example: Hello World With std -The following code features a valid UEFI application, including stdio and `alloc` (`OsString` and `Vec`): +The following code features a valid UEFI application, including `stdio` and `alloc` (`OsString` and `Vec`): This example can be compiled as binary crate via `cargo` using the toolchain compiled from the above source (named custom): @@ -286,6 +289,9 @@ use std::{ }; pub fn main() { + println!("Starting Rust Application..."); + + // Use System Table Directly let st = env::system_table().as_ptr() as *mut efi::SystemTable; let mut s: Vec<u16> = OsString::from("Hello World!\n").encode_wide().collect(); s.push(0); |
