@ -66,6 +66,7 @@
use super ::consts ::* ;
use super ::TrapFrame ;
use log ::* ;
global_asm! ( include_str! ( " trap.asm " ) ) ;
global_asm! ( include_str! ( " vector.asm " ) ) ;
@ -82,7 +83,7 @@ pub extern fn rust_trap(tf: &mut TrapFrame) {
let irq = tf . trap_num as u8 - T_IRQ0 ;
super ::ack ( irq ) ; // must ack before switching
match irq {
IRQ_TIMER = > ::trap ::timer ( ) ,
IRQ_TIMER = > crate ::trap ::timer ( ) ,
IRQ_KBD = > keyboard ( ) ,
IRQ_COM1 = > com1 ( ) ,
IRQ_COM2 = > com2 ( ) ,
@ -112,7 +113,7 @@ fn page_fault(tf: &mut TrapFrame) {
let addr : usize ;
unsafe { asm! ( " mov %cr2, $0 " : " =r " ( addr ) ) ; }
if ::memory ::page_fault_handler ( addr ) {
if crate ::memory ::page_fault_handler ( addr ) {
return ;
}
error! ( " \n EXCEPTION: Page Fault @ {:#x}, code: {:#x} " , addr , tf . error_code ) ;
@ -120,21 +121,21 @@ fn page_fault(tf: &mut TrapFrame) {
}
fn keyboard ( ) {
use arch ::driver ::keyboard ;
use crate ::arch ::driver ::keyboard ;
trace! ( " \n Interupt: Keyboard " ) ;
if let Some ( c ) = keyboard ::receive ( ) {
::trap ::serial ( c ) ;
crate ::trap ::serial ( c ) ;
}
}
fn com1 ( ) {
use arch ::driver ::serial ::* ;
use crate ::arch ::driver ::serial ::* ;
trace! ( " \n Interupt: COM1 " ) ;
::trap ::serial ( COM1 . lock ( ) . receive ( ) as char ) ;
crate ::trap ::serial ( COM1 . lock ( ) . receive ( ) as char ) ;
}
fn com2 ( ) {
use arch ::driver ::serial ::* ;
use crate ::arch ::driver ::serial ::* ;
trace! ( " \n Interupt: COM2 " ) ;
COM2 . lock ( ) . receive ( ) ;
}
@ -144,7 +145,7 @@ fn ide() {
}
fn to_user ( tf : & mut TrapFrame ) {
use arch ::gdt ;
use crate ::arch ::gdt ;
info! ( " \n Interupt: To User " ) ;
tf . cs = gdt ::UCODE_SELECTOR . 0 as usize ;
tf . ss = gdt ::UDATA_SELECTOR . 0 as usize ;
@ -152,7 +153,7 @@ fn to_user(tf: &mut TrapFrame) {
}
fn to_kernel ( tf : & mut TrapFrame ) {
use arch ::gdt ;
use crate ::arch ::gdt ;
info! ( " \n Interupt: To Kernel " ) ;
tf . cs = gdt ::KCODE_SELECTOR . 0 as usize ;
tf . ss = gdt ::KDATA_SELECTOR . 0 as usize ;
@ -160,25 +161,23 @@ fn to_kernel(tf: &mut TrapFrame) {
fn syscall ( tf : & mut TrapFrame ) {
trace! ( " \n Interupt: Syscall {:#x?} " , tf . rax ) ;
use syscall ::syscall ;
let ret = syscall ( tf . rax , [ tf . rdi , tf . rsi , tf . rdx , tf . rcx , tf . r8 , tf . r9 ] , tf ) ;
let ret = crate ::syscall ::syscall ( tf . rax , [ tf . rdi , tf . rsi , tf . rdx , tf . rcx , tf . r8 , tf . r9 ] , tf ) ;
tf . rax = ret as usize ;
}
fn syscall32 ( tf : & mut TrapFrame ) {
trace! ( " \n Interupt: Syscall {:#x?} " , tf . rax ) ;
use syscall ::syscall ;
let ret = syscall ( tf . rax , [ tf . rdx , tf . rcx , tf . rbx , tf . rdi , tf . rsi , 0 ] , tf ) ;
let ret = crate ::syscall ::syscall ( tf . rax , [ tf . rdx , tf . rcx , tf . rbx , tf . rdi , tf . rsi , 0 ] , tf ) ;
tf . rax = ret as usize ;
}
fn error ( tf : & TrapFrame ) {
::trap ::error ( tf ) ;
crate ::trap ::error ( tf ) ;
}
#[ no_mangle ]
pub extern fn set_return_rsp ( tf : & TrapFrame ) {
use arch ::gdt ::Cpu ;
use crate ::arch ::gdt ::Cpu ;
use core ::mem ::size_of ;
if tf . cs & 0x3 = = 3 {
Cpu ::current ( ) . set_ring0_rsp ( tf as * const _ as usize + size_of ::< TrapFrame > ( ) ) ;