File tree Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Original file line number Diff line number Diff line change 22#![ no_main]
33#![ warn( unsafe_op_in_unsafe_fn) ]
44
5- use core:: {
6- arch:: { asm, global_asm} ,
7- slice,
8- } ;
9- use fail:: { print_char, UnwrapOrFail } ;
5+ use core:: { arch:: global_asm, slice} ;
6+ use fail:: UnwrapOrFail ;
107
118global_asm ! ( include_str!( "boot.s" ) ) ;
129
@@ -31,12 +28,10 @@ fn second_stage_start() -> *const () {
3128#[ no_mangle]
3229pub extern "C" fn first_stage ( disk_number : u16 ) {
3330 // read partition table and look for second stage partition
34- print_char ( b'1' ) ;
3531 let partition_table = unsafe { slice:: from_raw_parts ( partition_table_raw ( ) , 16 * 4 ) } ;
3632 let second_stage_partition = mbr:: get_partition ( partition_table, 0 ) ;
3733
3834 // load second stage partition into memory
39- print_char ( b'2' ) ;
4035 let entry_point_address = second_stage_start ( ) as u32 ;
4136
4237 let mut start_lba = second_stage_partition. logical_block_address . into ( ) ;
@@ -65,18 +60,12 @@ pub extern "C" fn first_stage(disk_number: u16) {
6560 }
6661
6762 // jump to second stage
68- print_char ( b'3' ) ;
6963 let second_stage_entry_point: extern "C" fn (
7064 disk_number : u16 ,
7165 partition_table_start : * const u8 ,
7266 ) = unsafe { core:: mem:: transmute ( entry_point_address as * const ( ) ) } ;
7367 let partition_table_start = unsafe { partition_table_raw ( ) } ;
7468 second_stage_entry_point ( disk_number, partition_table_start) ;
75- for _ in 0 ..10 {
76- print_char ( b'R' ) ;
77- }
7869
79- loop {
80- unsafe { asm ! ( "hlt" ) }
81- }
70+ fail:: fail ( b'R' ) ;
8271}
Original file line number Diff line number Diff line change 1- use super :: fail:: { fail , UnwrapOrFail } ;
1+ use super :: fail:: UnwrapOrFail ;
22
33pub ( crate ) fn get_partition ( partitions_raw : & [ u8 ] , index : usize ) -> PartitionTableEntry {
4- const PARTITIONS_AREA_SIZE : usize = 16 * 4 ;
54 const ENTRY_SIZE : usize = 16 ;
65
7- if partitions_raw. len ( ) < PARTITIONS_AREA_SIZE {
8- fail ( b'a' ) ;
9- }
10-
116 let offset = index * ENTRY_SIZE ;
127 let buffer = partitions_raw. get ( offset..) . unwrap_or_fail ( b'c' ) ;
138
You can’t perform that action at this time.
0 commit comments