#x86 #ata #read #disk #block #write #size

x86_ata

一个简单、糟糕的 x86 ATA Crate

1 个不稳定版本

0.1.0 2021年8月19日

#1418文件系统

MIT 许可证

14KB
284

x86_ATA


概述

  • 24 位 LBA 模式
  • 使用 PIO 模式

示例

// Read A Single block from a disk
pub fn read_single() {
    use x86_ata::{init, ATA_BLOCK_SIZE, read};
    // 1. Initialise ATA Subsystem. (Perform Once, on boot)
    init().expect("Failed To Start ATA...");
    
    // 2. Create a temporary buffer of size 512.
    let mut buffer: [u8;ATA_BLOCK_SIZE] = [0; ATA_BLOCK_SIZE];

    // 3. Pass the buffer over to the Subsystem, to be filled.
    read(0, 0, 0, &mut buffer);
}


// Write A Single block onto a disk
pub fn write_single() {
    use x86_ata::{init, ATA_BLOCK_SIZE, write};
    // 1. Initialise ATA Subsystem. (Perform Once, on boot)
    init().expect("Failed To Start ATA...");
    
    // 2. Create a buffer of size 512, filled with the data to be written.
    let buffer: [u8;ATA_BLOCK_SIZE] = [0; ATA_BLOCK_SIZE];

    // 3. Pass the buffer over to the Subsystem, to be filled.
    write(0, 0, 0, &buffer);
}

依赖项

~0.8–1MB
~21K SLoC