-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
503 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use std::env; | ||
|
||
fn main() { | ||
let mut input = std::fs::read_to_string("src/setup_process_stack.s").unwrap(); | ||
let replacement= match env::var("OPT_LEVEL").unwrap().as_ref() { | ||
"0" => "0x40", // Debug build | ||
"3" => "0x90", // Release build | ||
opt_lvl => panic!("Wtf is this opt level: {}", opt_lvl), | ||
}; | ||
|
||
std::fs::write("src/setup_process_stack.s.out", | ||
input.replace("<RSP_SUB_VAL>", replacement)).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::kernel::Pid; | ||
use crate::println; | ||
use crate::registers::Registers; | ||
use crate::kernel::Process; | ||
|
||
// pub fn save_state(old_process: &mut Process) { | ||
// | ||
// } | ||
// | ||
// pub fn context_switch(new_process: &mut Process, old_pid: Option<&mut Process>, old_registers: Option<Registers>) { | ||
// if let Some(old_pid) = old_pid { | ||
// let rax: u64 = 0; | ||
// let rcx: u64 = 0; | ||
// let rdx: u64 = 0; | ||
// let rbx: u64 = 0; | ||
// let rsp: u64 = 0; | ||
// let rbp: u64 = 0; | ||
// let rsi: u64 = 0; | ||
// let rdi: u64 = 0; | ||
// | ||
// unsafe { | ||
// llvm_asm!("mov %rdi, $0" : "=r" (rdi)); | ||
// llvm_asm!("mov %rax, $0" : "=r" (rax)); | ||
// llvm_asm!("mov %rdx, $0" : "=r" (rdx)); | ||
// llvm_asm!("mov %rcx, $0" : "=r" (rcx)); | ||
// llvm_asm!("mov %rsi, $0" : "=r" (rsi)); | ||
// llvm_asm!("mov %rsp, $0" : "=r" (rsp)); | ||
// llvm_asm!("mov %rbx, $0" : "=r" (rbx)); | ||
// llvm_asm!("mov %rbp, $0" : "=r" (rbp)); | ||
// } | ||
// | ||
// let regs = Registers { | ||
// rax, | ||
// rcx, | ||
// rdx, | ||
// rbx, | ||
// rsp, | ||
// rbp, | ||
// rsi, | ||
// rdi | ||
// }; | ||
// | ||
// println!("DOES THIS WORK: {:?}", regs); | ||
// old_pid.set_regs(regs); | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use crate::println; | ||
|
||
#[inline(always)] | ||
pub fn print_stack_pointer() { | ||
let other: usize; | ||
unsafe { | ||
llvm_asm!( " | ||
mov %rsp, $0 | ||
": "={rsp}"(other): : | ||
: "volatile"); | ||
} | ||
println!("{:x}", other); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.