Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
Add comments and fix formatting (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparkles-Laurel authored Sep 26, 2023
1 parent 20bf6dd commit 843c16b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/read_mbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn read_disk_sector(buffer: &mut [u8], sector: u32) {
let dh = 0; // DH = 0 (Head number)
let dl = 0x80; // DL = 0x80 (Drive number: 0x80 for first hard disk)

unsafe {
unsafe { // invoke the interrupt to read from the disk sector.
asm!(
"int 0x13",
in("ah") ah,
Expand All @@ -57,9 +57,11 @@ fn read_disk_sector(buffer: &mut [u8], sector: u32) {
}

fn fetch_bootable_partitions(sector: u32) {
// read the mbr partitioning table
let mut mbr_buffer: [u8; 512] = [0; 512];
read_disk_sector(&mut mbr_buffer, sector);

// fetch the list of bootable partitions
let mut partition_entries: Vec<PartitionEntry> = Vec::new();
let mut bootable_parts: Vec<PartitionEntry> = Vec::new();
for i in 0..4 {
Expand All @@ -71,8 +73,8 @@ fn fetch_bootable_partitions(sector: u32) {

for (i, entry) in partition_entries.iter().enumerate() {
if entry.bootable == 0x80 {
bootable_parts.push(entry)
}
bootable_parts.push(entry)
}
}

bootable_parts
Expand Down

0 comments on commit 843c16b

Please sign in to comment.