File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,8 +34,6 @@ pub mod level_4_entries;
3434pub mod load_kernel;
3535/// Provides a logger that logs output as text in various formats.
3636pub mod logger;
37- /// Provides a type that logs output as text to a Serial Being port.
38- pub mod serial;
3937
4038const PAGE_SIZE : u64 = 4096 ;
4139
Original file line number Diff line number Diff line change 1- use crate :: { framebuffer:: FrameBufferWriter , serial :: SerialPort } ;
1+ use crate :: framebuffer:: FrameBufferWriter ;
22use bootloader_api:: info:: FrameBufferInfo ;
33use conquer_once:: spin:: OnceCell ;
44use core:: fmt:: Write ;
55use spinning_top:: Spinlock ;
6+ use uart_16550:: backend:: PioBackend ;
7+ use uart_16550:: { Config , Uart16550Tty } ;
68
79/// The global logger instance used for the `log` crate.
810pub static LOGGER : OnceCell < LockedLogger > = OnceCell :: uninit ( ) ;
911
1012/// A logger instance protected by a spinlock.
1113pub struct LockedLogger {
1214 framebuffer : Option < Spinlock < FrameBufferWriter > > ,
13- serial : Option < Spinlock < SerialPort > > ,
15+ serial : Option < Spinlock < Uart16550Tty < PioBackend > > > ,
1416}
1517
1618impl LockedLogger {
@@ -27,7 +29,17 @@ impl LockedLogger {
2729 } ;
2830
2931 let serial = match serial_logger_status {
30- true => Some ( Spinlock :: new ( unsafe { SerialPort :: init ( ) } ) ) ,
32+ true => {
33+ // SAFETY: We have exclusive access to the device.
34+ //
35+ // This returns `None` if the config is invalid or the self-test fails.
36+ // We do not panic here because we want to continue booting.
37+ unsafe {
38+ Uart16550Tty :: new_port ( 0x3f8 , Config :: default ( ) )
39+ . ok ( )
40+ . map ( Spinlock :: new)
41+ }
42+ }
3143 false => None ,
3244 } ;
3345
You can’t perform that action at this time.
0 commit comments