@@ -45,14 +45,21 @@ pub fn init_logger(framebuffer: &'static mut [u8], info: FrameBufferInfo) {
45
45
/// Required system information that should be queried from the BIOS or UEFI firmware.
46
46
#[ derive( Debug , Copy , Clone ) ]
47
47
pub 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 > ,
52
50
/// Address of the _Root System Description Pointer_ structure of the ACPI standard.
53
51
pub rsdp_addr : Option < PhysAddr > ,
54
52
}
55
53
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
+
56
63
pub struct Kernel < ' a > {
57
64
pub elf : ElfFile < ' a > ,
58
65
pub config : BootloaderConfig ,
@@ -100,8 +107,7 @@ where
100
107
kernel,
101
108
& mut frame_allocator,
102
109
& mut page_tables,
103
- system_info. framebuffer_addr ,
104
- system_info. framebuffer_info . byte_len ,
110
+ system_info. framebuffer . as_ref ( ) ,
105
111
& config,
106
112
) ;
107
113
let boot_info = create_boot_info (
@@ -132,8 +138,7 @@ pub fn set_up_mappings<I, D>(
132
138
kernel : Kernel ,
133
139
frame_allocator : & mut LegacyFrameAllocator < I , D > ,
134
140
page_tables : & mut PageTables ,
135
- framebuffer_addr : PhysAddr ,
136
- framebuffer_size : usize ,
141
+ framebuffer : Option < & RawFrameBufferInfo > ,
137
142
config : & BootloaderConfig ,
138
143
) -> Mappings
139
144
where
@@ -145,7 +150,7 @@ where
145
150
let mut used_entries = UsedLevel4Entries :: new (
146
151
frame_allocator. max_phys_addr ( ) ,
147
152
frame_allocator. len ( ) ,
148
- framebuffer_size ,
153
+ framebuffer ,
149
154
config,
150
155
) ;
151
156
@@ -220,15 +225,15 @@ where
220
225
}
221
226
222
227
// map framebuffer
223
- let framebuffer_virt_addr = {
228
+ let framebuffer_virt_addr = if let Some ( framebuffer ) = framebuffer {
224
229
log:: info!( "Map framebuffer" ) ;
225
230
226
- let framebuffer_start_frame: PhysFrame = PhysFrame :: containing_address ( framebuffer_addr ) ;
231
+ let framebuffer_start_frame: PhysFrame = PhysFrame :: containing_address ( framebuffer . addr ) ;
227
232
let framebuffer_end_frame =
228
- PhysFrame :: containing_address ( framebuffer_addr + framebuffer_size - 1u64 ) ;
233
+ PhysFrame :: containing_address ( framebuffer . addr + framebuffer . info . byte_len - 1u64 ) ;
229
234
let start_page = Page :: from_start_address ( mapping_addr (
230
235
config. mappings . framebuffer ,
231
- u64:: from_usize ( framebuffer_size ) ,
236
+ u64:: from_usize ( framebuffer . info . byte_len ) ,
232
237
Size4KiB :: SIZE ,
233
238
& mut used_entries,
234
239
) )
@@ -248,6 +253,8 @@ where
248
253
}
249
254
let framebuffer_virt_addr = start_page. start_address ( ) ;
250
255
Some ( framebuffer_virt_addr)
256
+ } else {
257
+ None
251
258
} ;
252
259
253
260
let physical_memory_offset = if let Some ( mapping) = config. mappings . physical_memory {
@@ -440,7 +447,7 @@ where
440
447
let mut info = BootInfo :: new ( memory_regions. into ( ) ) ;
441
448
info. framebuffer = mappings
442
449
. 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 ) )
444
451
. into ( ) ;
445
452
info. physical_memory_offset = mappings. physical_memory_offset . map ( VirtAddr :: as_u64) . into ( ) ;
446
453
info. recursive_index = mappings. recursive_index . map ( Into :: into) . into ( ) ;
0 commit comments