Skip to content

Instantly share code, notes, and snippets.

@RKennedy9064
RKennedy9064 / interrupt.rs
Created May 3, 2020 00:36
Code for async mouse task
extern "x86-interrupt" fn mouse_interrupt_handler(_stack_frame: &mut InterruptStackFrame) {
let mut port = PortReadOnly::new(0x60);
let packet = unsafe { port.read() };
crate::task::mouse::add_mouse_packet(packet);
unsafe {
PICS.lock()
.notify_end_of_interrupt(InterruptIndex::Mouse.into());
}
}
@RKennedy9064
RKennedy9064 / interrupts.rs
Created April 22, 2020 00:10
Basic mouse input
// Add new interrupt to the idt
idt[InterruptIndex::Mouse.into()].set_handler_fn(mouse_interrupt_handler);
// Basic example interrupt handler
extern "x86-interrupt" fn mouse_interrupt_handler(_stack_frame: &mut InterruptStackFrame) {
let mut port = PortReadOnly::new(0x60);
let packet = unsafe { port.read() };
MOUSE.lock().process_packets(packet);
unsafe {
mod vga;
mod vga_configurations;
mod vga_fonts;
mod vga_registers;
pub use vga::VideoMode;
pub use vga::VGA;
use std::{
borrow::BorrowMut,
error::Error
};
use winapi::{
shared::{
basetsd::{DWORD_PTR, UINT_PTR},
minwindef::{LPARAM, LRESULT, UINT, WPARAM},
windef::HWND
@RKennedy9064
RKennedy9064 / instructions-port.rs
Created March 19, 2019 05:12
A basic implementation of moving separating PortReadWrite into 2 traits and making PortReadWrite a combination of those traits.
use core::marker::PhantomData;
pub use crate::structures::port::{PortRead, PortWrite, PortReadWrite};
impl PortRead for u8 {
#[inline]
unsafe fn read_from_port(port: u16) -> u8 {
let value: u8;
asm!("inb %dx, %al" : "={al}"(value) : "{dx}"(port) :: "volatile");
value