Skip to content

Commit

Permalink
kernel/storage: Implement simple block device management; device/ide:…
Browse files Browse the repository at this point in the history
… Refactor and document driver
  • Loading branch information
fruhland committed Dec 11, 2024
1 parent 1cc7f71 commit b525570
Show file tree
Hide file tree
Showing 3 changed files with 335 additions and 246 deletions.
24 changes: 24 additions & 0 deletions os/kernel/src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,30 @@ pub extern "C" fn start(multiboot2_magic: u32, multiboot2_addr: *const BootInfor
// Initialize network stack
network::init();

let drive = storage::block_device("ata0").unwrap();
let mut buffer = [0; 8192];

// Fill buffer with some data
for i in 0..8192 {
buffer[i] = i as u8;
}
// Write data to the third sector of the drive
drive.write(3, 16, &mut buffer);

// Fill buffer with zeroes
for i in 0..8192 {
buffer[i] = 0;
}
// Read data from the third sector of the drive
drive.read(3, 16, &mut buffer);

// Check integrity of read data
for i in 0..8192 {
if buffer[i] != (i as u8) {
panic!("Data integrity check failed!");
}
}

// Set up network interface for emulated QEMU network (IP: 10.0.2.15, Gateway: 10.0.2.2)
if let Some(rtl8139) = rtl8139() && qemu_cfg::is_available() {
let time = timer.systime_ms();
Expand Down
Loading

0 comments on commit b525570

Please sign in to comment.