inout_port-rs

Crates.ioinout_port-rs
lib.rsinout_port-rs
version0.1.1
sourcesrc
created_at2023-11-28 07:38:33.079188
updated_at2023-11-28 07:44:46.23996
descriptioninb/outb port in freestanding Rust
homepagehttps://gitlab.com/hwoy/inout_port-rs
repository
max_upload_size
id1051681
size9,328
Watthanachai Dueanklang (hwoy)

documentation

https://docs.rs/inout_port-rs

README

inout_port-rs

inb/outb port in freestanding Rust.

How to use

cargo add inout_port-rs

Example

#![no_std]
#![no_main]

extern crate inout_port_rs;

#[no_mangle]
pub extern "C" fn _start() -> !
{
	_ = main();
	loop {}
}

use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}

#[derive(Copy, Clone)]
#[repr(C, packed)]
struct __LowHigh {
    l: u8,
    h: u8,
}

#[derive(Copy, Clone)]
union __Cursor {
    value: u16,
    lh: __LowHigh,
}
fn set_cursor(y: usize, x: usize) {
    let cursor = __Cursor {
        value: (y * 80 + x) as u16,
    };
    unsafe {
        inout_port_rs::outb(0xe, 0x3d4);
        inout_port_rs::outb(cursor.lh.h, 0x3d5);
        inout_port_rs::outb(0xf, 0x3d4);
        inout_port_rs::outb(cursor.lh.l, 0x3d5);
    }
}
fn main() {
	set_cursor(0,0);
}

Contact me

Commit count: 0

cargo fmt