mirror of
https://github.com/sgmarz/osblog.git
synced 2024-11-24 02:16:19 +04:00
Change test and added comments
This commit is contained in:
parent
080a529f01
commit
0de9b23b17
@ -186,6 +186,7 @@ impl FileSystem for MinixFileSystem {
|
||||
};
|
||||
let mut bytes_read = 0u32;
|
||||
let mut block_buffer = BlockBuffer::new(BLOCK_SIZE);
|
||||
|
||||
// ////////////////////////////////////////////
|
||||
// // DIRECT ZONES
|
||||
// ////////////////////////////////////////////
|
||||
@ -209,7 +210,6 @@ impl FileSystem for MinixFileSystem {
|
||||
continue;
|
||||
}
|
||||
let zone_offset = zone_num * BLOCK_SIZE;
|
||||
println!("Zone #{} -> #{} -> {}", i, zone_num, zone_offset);
|
||||
syc_read(desc, block_buffer.get_mut(), BLOCK_SIZE, zone_offset);
|
||||
|
||||
let read_this_many = if BLOCK_SIZE - offset_byte > bytes_left {
|
||||
@ -231,7 +231,6 @@ impl FileSystem for MinixFileSystem {
|
||||
if bytes_left == 0 {
|
||||
return bytes_read;
|
||||
}
|
||||
println!("Bytes left = {}", bytes_left);
|
||||
}
|
||||
blocks_seen += 1;
|
||||
}
|
||||
@ -239,7 +238,8 @@ impl FileSystem for MinixFileSystem {
|
||||
// // SINGLY INDIRECT ZONES
|
||||
// ////////////////////////////////////////////
|
||||
// Each indirect zone is a list of pointers, each 4 bytes. These then
|
||||
// point to zones where the data can be found.
|
||||
// point to zones where the data can be found. Just like with the direct zones,
|
||||
// we need to make sure the zone isn't 0. A zone of 0 means skip it.
|
||||
if inode.zones[7] != 0 {
|
||||
let mut indirect_buffer = BlockBuffer::new(BLOCK_SIZE);
|
||||
syc_read(desc, indirect_buffer.get_mut(), BLOCK_SIZE, BLOCK_SIZE * inode.zones[7]);
|
||||
@ -268,7 +268,6 @@ impl FileSystem for MinixFileSystem {
|
||||
);
|
||||
bytes_read += read_this_many;
|
||||
bytes_left -= read_this_many;
|
||||
println!("Bytes left = {}", bytes_left);
|
||||
offset_byte = 0;
|
||||
if bytes_left == 0 {
|
||||
return bytes_read;
|
||||
@ -305,8 +304,8 @@ impl FileSystem for MinixFileSystem {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn syc_read(desc: &Descriptor, buffer: *mut u8, size: u32, offset: u32) {
|
||||
syscall_block_read(desc.blockdev, buffer, size, offset);
|
||||
pub fn syc_read(desc: &Descriptor, buffer: *mut u8, size: u32, offset: u32) -> u8 {
|
||||
syscall_block_read(desc.blockdev, buffer, size, offset)
|
||||
}
|
||||
|
||||
struct ProcArgs {
|
||||
|
@ -98,8 +98,8 @@ pub fn syscall_fs_read(dev: usize, inode: u32, buffer: *mut u8, size: u32, offse
|
||||
do_make_syscall(63, dev, inode as usize, buffer as usize, size as usize, offset as usize, 0)
|
||||
}
|
||||
|
||||
pub fn syscall_block_read(dev: usize, buffer: *mut u8, size: u32, offset: u32) -> usize {
|
||||
do_make_syscall(180, dev, buffer as usize, size as usize, offset as usize, 0, 0)
|
||||
pub fn syscall_block_read(dev: usize, buffer: *mut u8, size: u32, offset: u32) -> u8 {
|
||||
do_make_syscall(180, dev, buffer as usize, size as usize, offset as usize, 0, 0) as u8
|
||||
}
|
||||
|
||||
// These system call numbers come from libgloss so that we can use newlib
|
||||
|
@ -1,14 +1,15 @@
|
||||
// test.rs
|
||||
|
||||
use crate::syscall::syscall_fs_read;
|
||||
use crate::{kmem::{kfree, kmalloc},
|
||||
syscall::syscall_fs_read};
|
||||
|
||||
pub fn test_block() {
|
||||
// Let's test the block driver!
|
||||
let bytes_to_read = 1024 * 14;
|
||||
let buffer = crate::kmem::kmalloc(bytes_to_read);
|
||||
println!("Started test block process, buffer is at {:p}.", buffer);
|
||||
let bytes_to_read = 1024 * 50;
|
||||
let buffer = kmalloc(bytes_to_read);
|
||||
unsafe {
|
||||
syscall_fs_read(8, 5, buffer, bytes_to_read as u32, 0);
|
||||
let bytes_read = syscall_fs_read(8, 5, buffer, bytes_to_read as u32, 0);
|
||||
println!("FS Read returned {} bytes", bytes_read);
|
||||
for i in 0..16 * 4 {
|
||||
print!("{:02x} ", buffer.add(i).read());
|
||||
if (i + 1) % 16 == 0 {
|
||||
@ -17,6 +18,5 @@ pub fn test_block() {
|
||||
}
|
||||
}
|
||||
println!();
|
||||
crate::kmem::kfree(buffer);
|
||||
println!("Test block finished");
|
||||
kfree(buffer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user