File tree 2 files changed +4
-20
lines changed
2 files changed +4
-20
lines changed Original file line number Diff line number Diff line change 2
2
#![ no_main]
3
3
#![ warn( unsafe_op_in_unsafe_fn) ]
4
4
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 ;
10
7
11
8
global_asm ! ( include_str!( "boot.s" ) ) ;
12
9
@@ -31,12 +28,10 @@ fn second_stage_start() -> *const () {
31
28
#[ no_mangle]
32
29
pub extern "C" fn first_stage ( disk_number : u16 ) {
33
30
// read partition table and look for second stage partition
34
- print_char ( b'1' ) ;
35
31
let partition_table = unsafe { slice:: from_raw_parts ( partition_table_raw ( ) , 16 * 4 ) } ;
36
32
let second_stage_partition = mbr:: get_partition ( partition_table, 0 ) ;
37
33
38
34
// load second stage partition into memory
39
- print_char ( b'2' ) ;
40
35
let entry_point_address = second_stage_start ( ) as u32 ;
41
36
42
37
let mut start_lba = second_stage_partition. logical_block_address . into ( ) ;
@@ -65,18 +60,12 @@ pub extern "C" fn first_stage(disk_number: u16) {
65
60
}
66
61
67
62
// jump to second stage
68
- print_char ( b'3' ) ;
69
63
let second_stage_entry_point: extern "C" fn (
70
64
disk_number : u16 ,
71
65
partition_table_start : * const u8 ,
72
66
) = unsafe { core:: mem:: transmute ( entry_point_address as * const ( ) ) } ;
73
67
let partition_table_start = unsafe { partition_table_raw ( ) } ;
74
68
second_stage_entry_point ( disk_number, partition_table_start) ;
75
- for _ in 0 ..10 {
76
- print_char ( b'R' ) ;
77
- }
78
69
79
- loop {
80
- unsafe { asm ! ( "hlt" ) }
81
- }
70
+ fail:: fail ( b'R' ) ;
82
71
}
Original file line number Diff line number Diff line change 1
- use super :: fail:: { fail , UnwrapOrFail } ;
1
+ use super :: fail:: UnwrapOrFail ;
2
2
3
3
pub ( crate ) fn get_partition ( partitions_raw : & [ u8 ] , index : usize ) -> PartitionTableEntry {
4
- const PARTITIONS_AREA_SIZE : usize = 16 * 4 ;
5
4
const ENTRY_SIZE : usize = 16 ;
6
5
7
- if partitions_raw. len ( ) < PARTITIONS_AREA_SIZE {
8
- fail ( b'a' ) ;
9
- }
10
-
11
6
let offset = index * ENTRY_SIZE ;
12
7
let buffer = partitions_raw. get ( offset..) . unwrap_or_fail ( b'c' ) ;
13
8
You can’t perform that action at this time.
0 commit comments