1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-23 18:06:20 +04:00

Added syscall_block_read and syscall_fs_read.

This commit is contained in:
Stephen Marz 2020-04-24 18:56:32 -04:00
parent 8081863709
commit 8ae5ebb085
3 changed files with 13 additions and 14 deletions

View File

@ -6,7 +6,7 @@
use crate::{fs::{Descriptor, FileSystem, FsError, Stat},
kmem::{kfree, kmalloc, talloc, tfree},
process::{add_kernel_process_args, set_waiting},
syscall::syscall_exit};
syscall::{syscall_exit, syscall_block_read}};
use alloc::string::String;
use core::{mem::size_of, ptr::null_mut};
@ -229,12 +229,7 @@ impl FileSystem for MinixFileSystem {
}
pub fn syc_read(desc: &Descriptor, buffer: *mut u8, size: u32, offset: u32) {
extern "C" {
fn make_syscall(sysno: usize, bdev: usize, buffer: usize, size: usize, offset: usize);
}
unsafe {
make_syscall(180, desc.blockdev as usize, buffer as usize, size as usize, offset as usize);
}
syscall_block_read(desc.blockdev, buffer, size, offset);
}
struct ProcArgs {

View File

@ -97,6 +97,14 @@ pub fn syscall_exit() {
let _ = do_make_syscall(93, 0, 0, 0, 0, 0, 0);
}
pub fn syscall_fs_read(dev: usize, buffer: *mut u8, size: u32, offset: u32) -> usize {
do_make_syscall(63, 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) -> usize {
do_make_syscall(180, dev, buffer as usize, size as usize, offset as usize, 0, 0)
}
// These system call numbers come from libgloss so that we can use newlib
// for our system calls.
// Libgloss wants the system call number in A7 and arguments in A0..A6

View File

@ -1,15 +1,13 @@
// test.rs
extern "C" {
fn make_syscall(sysno: usize, arg0: usize, arg1: usize, arg2: usize, arg3: usize);
}
use crate::syscall::{syscall_fs_read, syscall_exit};
pub fn test_block() {
// Let's test the block driver!
let buffer = crate::kmem::kmalloc(1024);
println!("Started test block process, buffer is at {:p}.", buffer);
unsafe {
make_syscall(63, 8, buffer as usize, 1024, 1024);
syscall_fs_read(8, buffer, 0, 1024);
for i in 0..32 {
print!("{:02x} ", buffer.add(i).read());
if (i+1) % 16 == 0 {
@ -20,7 +18,5 @@ pub fn test_block() {
println!();
crate::kmem::kfree(buffer);
println!("Test block finished");
unsafe {
make_syscall(93, 0, 0, 0, 0);
}
syscall_exit();
}