@@ -45,14 +45,21 @@ pub fn init_logger(framebuffer: &'static mut [u8], info: FrameBufferInfo) {
4545/// Required system information that should be queried from the BIOS or UEFI firmware.
4646#[ derive( Debug , Copy , Clone ) ]
4747pub struct SystemInfo {
48- /// Start address of the pixel-based framebuffer.
49- pub framebuffer_addr : PhysAddr ,
50- /// Information about the framebuffer, including layout and pixel format.
51- pub framebuffer_info : FrameBufferInfo ,
48+ /// Information about the (still unmapped) framebuffer.
49+ pub framebuffer : Option < RawFrameBufferInfo > ,
5250 /// Address of the _Root System Description Pointer_ structure of the ACPI standard.
5351 pub rsdp_addr : Option < PhysAddr > ,
5452}
5553
54+ /// The physical address of the framebuffer and information about the framebuffer.
55+ #[ derive( Debug , Copy , Clone ) ]
56+ pub struct RawFrameBufferInfo {
57+ /// Start address of the pixel-based framebuffer.
58+ pub addr : PhysAddr ,
59+ /// Information about the framebuffer, including layout and pixel format.
60+ pub info : FrameBufferInfo ,
61+ }
62+
5663pub struct Kernel < ' a > {
5764 pub elf : ElfFile < ' a > ,
5865 pub config : BootloaderConfig ,
@@ -100,8 +107,7 @@ where
100107 kernel,
101108 & mut frame_allocator,
102109 & mut page_tables,
103- system_info. framebuffer_addr ,
104- system_info. framebuffer_info . byte_len ,
110+ system_info. framebuffer . as_ref ( ) ,
105111 & config,
106112 ) ;
107113 let boot_info = create_boot_info (
@@ -132,8 +138,7 @@ pub fn set_up_mappings<I, D>(
132138 kernel : Kernel ,
133139 frame_allocator : & mut LegacyFrameAllocator < I , D > ,
134140 page_tables : & mut PageTables ,
135- framebuffer_addr : PhysAddr ,
136- framebuffer_size : usize ,
141+ framebuffer : Option < & RawFrameBufferInfo > ,
137142 config : & BootloaderConfig ,
138143) -> Mappings
139144where
@@ -145,7 +150,7 @@ where
145150 let mut used_entries = UsedLevel4Entries :: new (
146151 frame_allocator. max_phys_addr ( ) ,
147152 frame_allocator. len ( ) ,
148- framebuffer_size ,
153+ framebuffer ,
149154 config,
150155 ) ;
151156
@@ -220,15 +225,15 @@ where
220225 }
221226
222227 // map framebuffer
223- let framebuffer_virt_addr = {
228+ let framebuffer_virt_addr = if let Some ( framebuffer ) = framebuffer {
224229 log:: info!( "Map framebuffer" ) ;
225230
226- let framebuffer_start_frame: PhysFrame = PhysFrame :: containing_address ( framebuffer_addr ) ;
231+ let framebuffer_start_frame: PhysFrame = PhysFrame :: containing_address ( framebuffer . addr ) ;
227232 let framebuffer_end_frame =
228- PhysFrame :: containing_address ( framebuffer_addr + framebuffer_size - 1u64 ) ;
233+ PhysFrame :: containing_address ( framebuffer . addr + framebuffer . info . byte_len - 1u64 ) ;
229234 let start_page = Page :: from_start_address ( mapping_addr (
230235 config. mappings . framebuffer ,
231- u64:: from_usize ( framebuffer_size ) ,
236+ u64:: from_usize ( framebuffer . info . byte_len ) ,
232237 Size4KiB :: SIZE ,
233238 & mut used_entries,
234239 ) )
@@ -248,6 +253,8 @@ where
248253 }
249254 let framebuffer_virt_addr = start_page. start_address ( ) ;
250255 Some ( framebuffer_virt_addr)
256+ } else {
257+ None
251258 } ;
252259
253260 let physical_memory_offset = if let Some ( mapping) = config. mappings . physical_memory {
@@ -440,7 +447,7 @@ where
440447 let mut info = BootInfo :: new ( memory_regions. into ( ) ) ;
441448 info. framebuffer = mappings
442449 . framebuffer
443- . map ( |addr| FrameBuffer :: new ( addr. as_u64 ( ) , system_info. framebuffer_info ) )
450+ . map ( |addr| FrameBuffer :: new ( addr. as_u64 ( ) , system_info. framebuffer . expect ( "there shouldn't be a mapping for the framebuffer if there is not framebuffer" ) . info ) )
444451 . into ( ) ;
445452 info. physical_memory_offset = mappings. physical_memory_offset . map ( VirtAddr :: as_u64) . into ( ) ;
446453 info. recursive_index = mappings. recursive_index . map ( Into :: into) . into ( ) ;
0 commit comments