From 425f8c9ad5d3f0bb9325f007481a4a9a301e9d55 Mon Sep 17 00:00:00 2001 From: Samarth Patel Date: Thu, 12 Mar 2026 09:31:23 +0530 Subject: [PATCH] Unused dead code --- src/console.rs | 79 -------------------------------------------------- src/main.rs | 1 - src/x86.rs | 29 ------------------ x86.h | 18 ------------ 4 files changed, 127 deletions(-) diff --git a/src/console.rs b/src/console.rs index 2130c70..66fbc22 100644 --- a/src/console.rs +++ b/src/console.rs @@ -3,78 +3,6 @@ use core::fmt::*; // Console output. // Output is written to the screen and serial port. -// fn printint(xx: i32, base: u32, sign: bool) { -// let digits = "0123456789abcdef"; -// let mut buf = Vec::with_capacity(16); -// let mut x: u32; - -// if sign && xx < 0 { -// x = -xx as u32; -// } else { -// x = xx as u32; -// } - -// loop { -// buf.push(digits.chars().nth((x % base) as usize).unwrap()); -// x /= base; -// if x == 0 { -// break; -// } -// } - -// if sign && xx < 0 { -// buf.push('-'); -// } - -// // Print in reverse order (since we added digits from least to most significant) -// for &c in buf.iter().rev() { -// consputc(c); -// } -// } - -// pub fn cprintf(fmt: &str, args: &[u32]) { -// let mut argp = args.iter(); -// let mut i = 0; -// let mut fmt_chars = fmt.chars(); - -// while let Some(c) = fmt_chars.next() { -// if c != '%' { -// consputc(c); -// continue; -// } - -// match fmt_chars.next() { -// Some('d') => { -// if let Some(&val) = argp.next() { -// printint(val as i32, 10, true); -// } -// } -// Some('x') | Some('p') => { -// if let Some(&val) = argp.next() { -// printint(val as i32, 16, false); -// } -// } -// Some('s') => { -// if let Some(&val) = argp.next() { -// let s = unsafe { std::ffi::CStr::from_ptr(val as *const i8) }; -// let s = s.to_str().unwrap_or("(null)"); -// for c in s.chars() { -// consputc(c); -// } -// } -// } -// Some('%') => { -// consputc('%'); -// } -// Some(_) => { -// // Print unknown % sequence -// consputc('%'); -// consputc(c); -// } -// None => break, -// } -// } -// } pub struct Console {} impl Write for Console { @@ -95,13 +23,6 @@ macro_rules! println { }); } -// #[macro_export] -// macro_rules! println { -// ($($arg:tt)*) => ({ -// let _ = cprintf($($arg)*); -// }); -// } - const BACKSPACE: char = '\x08'; fn consputc(c: char) { diff --git a/src/main.rs b/src/main.rs index 67609f6..3b9c4bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,6 @@ mod x86; mod uart; mod console; -use core::fmt::*; use core::panic::PanicInfo; use uart::*; diff --git a/src/x86.rs b/src/x86.rs index b8e3460..16d8947 100644 --- a/src/x86.rs +++ b/src/x86.rs @@ -19,16 +19,6 @@ pub unsafe fn outb(port: u16 , value: u8) { options(nomem, nostack) ); } -pub unsafe fn inw(port: u16) -> u16 { - let result: u16; - asm!( - "in ax, dx", - in("dx") port, - out("ax") result, - options(nomem, nostack) - ); - result -} pub unsafe fn outw(port: u16 , value: u16) { asm!( "out dx, ax", @@ -37,22 +27,3 @@ pub unsafe fn outw(port: u16 , value: u16) { options(nomem, nostack) ); } -pub unsafe fn inl(port: u16) -> u32 { - let result: u32; - asm!( - "in eax, dx", - in("dx") port, - out("eax") result, - options(nomem, nostack) - ); - - result -} -pub unsafe fn outl(port: u16 , value: u32) { - asm!( - "out dx, eax", - in("dx") port, - in("eax") value, - options(nomem, nostack) - ); -} \ No newline at end of file diff --git a/x86.h b/x86.h index 9b2984f..765ee17 100644 --- a/x86.h +++ b/x86.h @@ -30,15 +30,6 @@ outw(ushort port, ushort data) asm volatile("out %0,%1" : : "a" (data), "d" (port)); } -static inline void -outsl(int port, const void *addr, int cnt) -{ - asm volatile("cld; rep outsl" : - "=S" (addr), "=c" (cnt) : - "d" (port), "0" (addr), "1" (cnt) : - "cc"); -} - static inline void stosb(void *addr, int data, int cnt) { @@ -47,12 +38,3 @@ stosb(void *addr, int data, int cnt) "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } - -static inline void -stosl(void *addr, int data, int cnt) -{ - asm volatile("cld; rep stosl" : - "=D" (addr), "=c" (cnt) : - "0" (addr), "1" (cnt), "a" (data) : - "memory", "cc"); -} \ No newline at end of file