it compiles

This commit is contained in:
Jack Halford 2018-02-09 17:36:36 +01:00
parent 698a859b7c
commit c2df8effbe
3 changed files with 41 additions and 1 deletions

View file

@ -54,7 +54,7 @@ $(iso): $(kernel) $(grub.cfg) Makefile
run: $(iso) Makefile run: $(iso) Makefile
@tmux info >&- || { echo -e "\033[38;5;16m ~~ NOT IN A VALID TMUX SESSION ~~\033[0m" ; exit 1; } @tmux info >&- || { echo -e "\033[38;5;16m ~~ NOT IN A VALID TMUX SESSION ~~\033[0m" ; exit 1; }
tmux new-window 'tmux split-window -h "$(MONITOR)"; tmux split-window -fv "$(GDB)"; tmux select-pane -t 1; tmux resize-pane -x 80 -y 25; $(KERNEL_RUN)' @tmux new-window 'tmux split-window -h "$(MONITOR)"; tmux split-window -fv "$(GDB)"; tmux select-pane -t 1; tmux resize-pane -x 80 -y 25; $(KERNEL_RUN)'
@# @$(QEMU) -curses -cdrom $(iso) @# @$(QEMU) -curses -cdrom $(iso)
clean: clean:

39
kernel-rs/src/cpuio.rs Normal file
View file

@ -0,0 +1,39 @@
//! Rust wrappers around the x86-family I/O instructions.
/// Read a `u8`-sized value from `port`.
pub unsafe fn inb(port: u16) -> u8 {
// The registers for the `in` and `out` instructions are always the
// same: `a` for value, and `d` for the port address.
let result: u8;
asm!("inb %dx, %al" : "={al}"(result) : "{dx}"(port) :: "volatile");
result
}
/// Write a `u8`-sized `value` to `port`.
pub unsafe fn outb(value: u8, port: u16) {
asm!("outb %al, %dx" :: "{dx}"(port), "{al}"(value) :: "volatile");
}
/// Read a `u16`-sized value from `port`.
pub unsafe fn inw(port: u16) -> u16 {
let result: u16;
asm!("inw %dx, %ax" : "={ax}"(result) : "{dx}"(port) :: "volatile");
result
}
/// Write a `u8`-sized `value` to `port`.
pub unsafe fn outw(value: u16, port: u16) {
asm!("outw %ax, %dx" :: "{dx}"(port), "{ax}"(value) :: "volatile");
}
/// Read a `u32`-sized value from `port`.
pub unsafe fn inl(port: u16) -> u32 {
let result: u32;
asm!("inl %dx, %eax" : "={eax}"(result) : "{dx}"(port) :: "volatile");
result
}
/// Write a `u32`-sized `value` to `port`.
pub unsafe fn outl(value: u32, port: u16) {
asm!("outl %eax, %dx" :: "{dx}"(port), "{eax}"(value) :: "volatile");
}

View file

@ -0,0 +1 @@
pub static KEY_CODE_TO_ASCII: [u8; 59] = *b"??1234567890-=??qwertyuiop[]\n?asdfghjkl;'`?\\zxcvbnm,./?*? ?";