pub fn read_to_buffer(&self, lba: usize, total: usize, buffer: &mut [u16]) {
        // Prepare to read
        unsafe {
            io::outb(0x1f6, ((lba >> 24) | 0xe0) as u8); // Send drive and head numbers
            io::outb(0x1f2, total as u8); // Send number of sectors
            io::outb(0x1f3, (lba & 0xff) as u8); // Send bits 0-7 of LBA
            io::outb(0x1f4, (lba >> 8) as u8); // Send bits 8-15 of LBA
            io::outb(0x1f5, (lba >> 16) as u8); // Send bits 16-23 of LBA
            io::outb(0x1f7, 0x20); // Command port
        };

        for i in 0..total {
            // Wait until ready
            let mut byte = unsafe { io::inb(0x1f7) };
            while (byte & 0x08) != 0 {
                byte = unsafe { io::inb(0x1f7) };
            }

            // Read from disk
            for j in 0..self.sector_size {
                buffer[i * self.sector_size + j] = unsafe { io::inw(0x1f0) };
            }
        }
    }
/// Reads `total` sectors, starting from `lba` and reading into the provided buffer.
Reads `total` sectors, starting from `lba` and reading into the provided buffer.
Reads ` total ` sectors starting from ` lba ` and reading into the provided buffer .
pub fn read_to_buffer(&self, lba: usize, total: usize, buffer: &mut [u16]) {
        // Prepare to read
        unsafe {
            io::outb(0x1f6, ((lba >> 24) | 0xe0) as u8); // Send drive and head numbers
            io::outb(0x1f2, total as u8); // Send number of sectors
            io::outb(0x1f3, (lba & 0xff) as u8); // Send bits 0-7 of LBA
            io::outb(0x1f4, (lba >> 8) as u8); // Send bits 8-15 of LBA
            io::outb(0x1f5, (lba >> 16) as u8); // Send bits 16-23 of LBA
            io::outb(0x1f7, 0x20); // Command port
        };
        for i in 0..total {
            // Wait until ready
            let mut byte = unsafe { io::inb(0x1f7) };
            while (byte & 0x08) != 0 {
                byte = unsafe { io::inb(0x1f7) };
            }
            // Read from disk
            for j in 0..self.sector_size {
                buffer[i * self.sector_size + j] = unsafe { io::inw(0x1f0) };
            }
        }
    }
pub fn read_to_buffer ( & self , lba : usize , total : usize , buffer : & mut [ u16 ] ) { // Prepare to read unsafe { io :: outb ( 0x1f6 , ( ( lba >> 24 ) | 0xe0 ) as u8 ) ; // Send drive and head numbers io :: outb ( 0x1f2 , total as u8 ) ; // Send number of sectors io :: outb ( 0x1f3 , ( lba & 0xff ) as u8 ) ; // Send bits 0-7 of LBA io :: outb ( 0x1f4 , ( lba >> 8 ) as u8 ) ; // Send bits 8-15 of LBA io :: outb ( 0x1f5 , ( lba >> 16 ) as u8 ) ; // Send bits 16-23 of LBA io :: outb ( 0x1f7 , 0x20 ) ; // Command port } ; for i in 0 .. total { // Wait until ready let mut byte = unsafe { io :: inb ( 0x1f7 ) } ; while ( byte & 0x08 ) != 0 { byte = unsafe { io :: inb ( 0x1f7 ) } ; } // Read from disk for j in 0 .. self . sector_size { buffer [ i * self . sector_size + j ] = unsafe { io :: inw ( 0x1f0 ) } ; } } }
Reads `total` sectors, starting from `lba` and reading into the provided buffer.
Reads ` total ` sectors starting from ` lba ` and reading into the provided buffer .
&self
lba
usize
total
usize
buffer
&mut [u16]
&self
lba
usize
total
usize
buffer
&mut [u16]