mirror of
https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials.git
synced 2024-11-17 21:25:52 +00:00
2e72a8408f
This update significantly decouples the generic kernel code from the BSP code. Prior to this patch, the BSP had way too much business logic that should have always been the generic kernel's concern.
38 lines
907 B
Rust
38 lines
907 B
Rust
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
//
|
|
// Copyright (c) 2019-2022 Andre Richter <andre.o.richter@gmail.com>
|
|
|
|
//! Console sanity tests - RX, TX and statistics.
|
|
|
|
#![feature(format_args_nl)]
|
|
#![no_main]
|
|
#![no_std]
|
|
|
|
/// Console tests should time out on the I/O harness in case of panic.
|
|
mod panic_wait_forever;
|
|
|
|
use libkernel::{bsp, console, cpu, exception, print};
|
|
|
|
#[no_mangle]
|
|
unsafe fn kernel_init() -> ! {
|
|
use console::console;
|
|
|
|
exception::handling_init();
|
|
bsp::driver::qemu_bring_up_console();
|
|
|
|
// Handshake
|
|
assert_eq!(console().read_char(), 'A');
|
|
assert_eq!(console().read_char(), 'B');
|
|
assert_eq!(console().read_char(), 'C');
|
|
print!("OK1234");
|
|
|
|
// 6
|
|
print!("{}", console().chars_written());
|
|
|
|
// 3
|
|
print!("{}", console().chars_read());
|
|
|
|
// The QEMU process running this test will be closed by the I/O test harness.
|
|
cpu::wait_forever();
|
|
}
|