Fix function collision
All checks were successful
Continuous Integration / Clippy (push) Successful in 6m18s
Continuous Integration / Check (push) Successful in 1m0s

This commit is contained in:
August 2026-11-10 03:07:45 +00:00
parent 383642e4d1
commit d95ac44304
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw
8 changed files with 30 additions and 52 deletions

View File

@ -1,7 +1,6 @@
// Copyright (c) 2025 shibedrill // Copyright (c) 2025 shibedrill
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
use intbits::Bits;
use x86_64::registers::control::EferFlags; use x86_64::registers::control::EferFlags;
use crate::arch::x86_64::cpuid::*; use crate::arch::x86_64::cpuid::*;
@ -24,10 +23,7 @@ pub fn amd_v_supported() -> bool {
#[allow(dead_code)] #[allow(dead_code)]
pub fn enable_svm() { pub fn enable_svm() {
let mut efer = x86_64::registers::model_specific::Efer::read().bits(); let mut efer: u64 = x86_64::registers::model_specific::Efer::read().bits();
efer.set_bit(12, true); intbits::Bits::set_bit(&mut efer, 12,true);
// I'm not sure why this is here. But clearly there was a reason for it.
// So now I'm scared to touch it...
assert!(efer.bit(12));
unsafe { x86_64::registers::model_specific::Efer::write(EferFlags::from_bits_retain(efer)) }; unsafe { x86_64::registers::model_specific::Efer::write(EferFlags::from_bits_retain(efer)) };
} }

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
use core::arch::asm; use core::arch::asm;
use intbits::Bits;
pub fn nop() { pub fn nop() {
::x86_64::instructions::nop(); ::x86_64::instructions::nop();
@ -18,7 +17,7 @@ pub fn long_mode() -> bool {
out("edx") output, out("edx") output,
) )
} }
output.bit(29) intbits::Bits::bit(output, 29)
} }
pub fn ltr(selector: u16) { pub fn ltr(selector: u16) {

View File

@ -4,11 +4,11 @@
use core::arch::asm; use core::arch::asm;
use core::ptr::{addr_of, addr_of_mut}; use core::ptr::{addr_of, addr_of_mut};
use intbits::Bits;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use x86_64::structures::gdt; use x86_64::structures::gdt;
use x86_64::structures::gdt::*; use x86_64::structures::gdt::*;
use x86_64::structures::tss::TaskStateSegment; use x86_64::structures::tss::TaskStateSegment;
use intbits::Bits;
use crate::log::*; use crate::log::*;
use crate::memory::alloc::format; use crate::memory::alloc::format;
@ -24,10 +24,10 @@ impl ModifyFlags for Descriptor {
fn set_flags(self, flags: DescriptorFlags) -> Descriptor { fn set_flags(self, flags: DescriptorFlags) -> Descriptor {
match self { match self {
Descriptor::UserSegment(a) => { Descriptor::UserSegment(a) => {
Descriptor::UserSegment(a.with_bits(52..=55, flags.bits().bits(0..=3))) Descriptor::UserSegment(intbits::Bits::with_bits(a, 52..=55, intbits::Bits::bits(flags.bits(), 0..=3)))
} }
Descriptor::SystemSegment(a, b) => { Descriptor::SystemSegment(a, b) => {
Descriptor::SystemSegment(a.with_bits(52..=55, flags.bits().bits(0..=3)), b) Descriptor::SystemSegment(intbits::Bits::with_bits(a, 52..=55, intbits::Bits::bits(flags.bits(), 0..=3)), b)
} }
} }
} }
@ -187,8 +187,8 @@ impl TryFrom<&gdt::Entry> for SegmentType {
type Error = (); type Error = ();
fn try_from(value: &gdt::Entry) -> Result<Self, ()> { fn try_from(value: &gdt::Entry) -> Result<Self, ()> {
let flags = x86_64::structures::gdt::DescriptorFlags::from_bits_retain(value.raw()); let flags = x86_64::structures::gdt::DescriptorFlags::from_bits_retain(value.raw());
if value.access().bit(4) { if intbits::Bits::bit(value.access(), 4) {
if value.access().bit(3) { if intbits::Bits::bit(value.access(), 3) {
Ok(SegmentType::Code) Ok(SegmentType::Code)
} else { } else {
Ok(SegmentType::Data) Ok(SegmentType::Data)

View File

@ -215,11 +215,11 @@ impl SerialPort {
} }
fn get_dlab(&mut self) -> bool { fn get_dlab(&mut self) -> bool {
self.get_line_control().bit(7) intbits::Bits::bit(self.get_line_control(), 7)
} }
fn set_dlab(&mut self, dlab: bool) { fn set_dlab(&mut self, dlab: bool) {
let mut new_lcr = unsafe { self.line_control.read() }; let mut new_lcr = unsafe { self.line_control.read() };
new_lcr.set_bit(7, dlab); intbits::Bits::set_bit(&mut new_lcr, 7, dlab);
unsafe { self.line_control.write(new_lcr) }; unsafe { self.line_control.write(new_lcr) };
} }
@ -270,7 +270,7 @@ impl SerialPort {
/// A value of True means 2 bits will be sent. /// A value of True means 2 bits will be sent.
/// If the character length is 5 bits, a value of True means 1.5 bits will be sent. /// If the character length is 5 bits, a value of True means 1.5 bits will be sent.
pub fn get_stop_bits(&mut self) -> bool { pub fn get_stop_bits(&mut self) -> bool {
self.get_line_control().bit(2) intbits::Bits::bit(self.get_line_control(), 2)
} }
/// Set the number of bits sent after each character. /// Set the number of bits sent after each character.
/// A value of False means only 1 bit will be sent. /// A value of False means only 1 bit will be sent.
@ -278,7 +278,7 @@ impl SerialPort {
/// If the character length is 5 bits, a value of True means 1.5 bits will be sent. /// If the character length is 5 bits, a value of True means 1.5 bits will be sent.
pub fn set_stop_bits(&mut self, bit: bool) { pub fn set_stop_bits(&mut self, bit: bool) {
let mut new_value = self.get_line_control(); let mut new_value = self.get_line_control();
new_value.set_bit(2, bit); intbits::Bits::set_bit(&mut new_value, 2, bit);
self.set_line_control(new_value); self.set_line_control(new_value);
} }
@ -309,32 +309,32 @@ impl SerialPort {
/// Clear the transmitter FIFO. /// Clear the transmitter FIFO.
pub fn clear_tx_fifo(&mut self) { pub fn clear_tx_fifo(&mut self) {
let mut new_value = self.fifo_register; let mut new_value = self.fifo_register;
new_value.set_bit(2, true); intbits::Bits::set_bit(&mut new_value, 2, true);
self.set_fifo_control(new_value); self.set_fifo_control(new_value);
} }
/// Clear the receiver FIFO. /// Clear the receiver FIFO.
pub fn clear_rx_fifo(&mut self) { pub fn clear_rx_fifo(&mut self) {
let mut new_value = self.fifo_register; let mut new_value = self.fifo_register;
new_value.set_bit(1, true); intbits::Bits::set_bit(&mut new_value, 1, true);
self.set_fifo_control(new_value); self.set_fifo_control(new_value);
} }
/// Enable or disable FIFOs. /// Enable or disable FIFOs.
pub fn set_fifo_enable(&mut self, enable: bool) { pub fn set_fifo_enable(&mut self, enable: bool) {
self.fifo_register.set_bit(0, enable); intbits::Bits::set_bit(&mut self.fifo_register, 0, enable);
self.set_fifo_control(self.fifo_register); self.set_fifo_control(self.fifo_register);
} }
/// Get whether FIFOs were enabled using this API. /// Get whether FIFOs were enabled using this API.
pub fn get_fifo_enable(&mut self) -> bool { pub fn get_fifo_enable(&mut self) -> bool {
self.fifo_register.bit(0) intbits::Bits::bit(self.fifo_register, 0)
} }
/// Set the DMA mode of the serial controller. /// Set the DMA mode of the serial controller.
pub fn set_dma_mode(&mut self, enable: bool) { pub fn set_dma_mode(&mut self, enable: bool) {
self.fifo_register.set_bit(3, enable); intbits::Bits::set_bit(&mut self.fifo_register, 3, enable);
self.set_fifo_control(self.fifo_register); self.set_fifo_control(self.fifo_register);
} }
/// Get whether DMA mode was enabled using this API. /// Get whether DMA mode was enabled using this API.
pub fn get_dma_mode(&mut self) -> bool { pub fn get_dma_mode(&mut self) -> bool {
self.fifo_register.bit(3) intbits::Bits::bit(self.fifo_register, 3)
} }
/// Get the Interrupt Trigger Level. /// Get the Interrupt Trigger Level.
pub fn get_interrupt_trigger_level(&mut self) -> TriggerLevel { pub fn get_interrupt_trigger_level(&mut self) -> TriggerLevel {
@ -356,7 +356,7 @@ impl SerialPort {
} }
/// Get whether a timeout interrupt is pending. Only used on UART 16550 chips, otherwise reserved. /// Get whether a timeout interrupt is pending. Only used on UART 16550 chips, otherwise reserved.
pub fn get_timeout_pending(&mut self) -> bool { pub fn get_timeout_pending(&mut self) -> bool {
self.get_interrupt_id().bit(3) intbits::Bits::bit(self.get_interrupt_id(), 3)
} }
/// Get the Interrupt State of the controller. /// Get the Interrupt State of the controller.
pub fn get_interrupt_state(&mut self) -> InterruptState { pub fn get_interrupt_state(&mut self) -> InterruptState {
@ -364,7 +364,7 @@ impl SerialPort {
} }
/// Get whether an interrupt is pending. /// Get whether an interrupt is pending.
pub fn get_interrupt_pending(&mut self) -> bool { pub fn get_interrupt_pending(&mut self) -> bool {
!self.get_interrupt_id().bit(0) !intbits::Bits::bit(self.get_interrupt_id(), 0)
} }
/// Set the Modem Control register flags. /// Set the Modem Control register flags.

View File

@ -1,37 +1,30 @@
use lazy_static::lazy_static;
use spin::mutex::Mutex;
use x86_64::{ use x86_64::{
VirtAddr, VirtAddr,
registers::{rflags::RFlags, segmentation::Segment}, registers::{rflags::RFlags, segmentation::Segment},
structures::idt::InterruptStackFrameValue, structures::idt::InterruptStackFrameValue,
}; };
use lazy_static::lazy_static;
use spin::mutex::Mutex;
use crate::{ use crate::{
arch::{ arch::{
asm::ltr, asm::ltr,
x86_64::{ x86_64::{gdt::SELECTORS, interrupts::IDT, serial::SerialPort},
gdt::SELECTORS,
interrupts::IDT,
serial::SerialPort,
},
}, },
boot::params::PARAMS,
log::{LOGGER, LogLevel}, log::{LOGGER, LogLevel},
log_info, log_info, log_trace,
log_trace, memory::alloc::boxed::Box,
memory::alloc::format, memory::alloc::format,
memory::alloc::vec, memory::alloc::vec,
memory::alloc::boxed::Box,
boot::params::PARAMS,
}; };
lazy_static! { lazy_static! {
pub static ref SERIAL_3F8: Mutex<SerialPort> = Mutex::new( pub static ref SERIAL_3F8: Mutex<SerialPort> =
SerialPort::try_from_port(0x3f8).expect("Could not create port") Mutex::new(SerialPort::try_from_port(0x3f8).expect("Could not create port"));
);
} }
pub fn init() -> Result<(), ()> { pub fn init() -> Result<(), ()> {
// Set up logging level from params // Set up logging level from params
// Nothing we can do here if this fails since no log subscribers are initialized yet // Nothing we can do here if this fails since no log subscribers are initialized yet
if let Some(level) = PARAMS.get("-loglevel") if let Some(level) = PARAMS.get("-loglevel")

View File

@ -19,7 +19,7 @@ pub enum ResourceIdentifier<'a> {
} }
// TODO: Figure out representation for kernel objects // TODO: Figure out representation for kernel objects
// We can figure this out, all we need is a way to opaquely // We can figure this out, all we need is a way to opaquely
// reference a page using a fat pointer. // reference a page using a fat pointer.
pub struct PageCap { pub struct PageCap {

View File

@ -35,15 +35,6 @@ pub fn kernel_version_string() -> String {
) )
} }
pub static ASCII_LOGO: [&str; 6] = [
" _ __ ",
" ____ _(_) /___ _",
" / __ `/ / / __ `/",
"/ /_/ / / / /_/ / ",
"\\__, /_/_/\\__,_/ ",
"/___/ ",
];
// FUCKING ADD CONST UNWRAP!!! // FUCKING ADD CONST UNWRAP!!!
pub static KERNEL_VERSION_MAJOR: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_MAJOR"), 10) pub static KERNEL_VERSION_MAJOR: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_MAJOR"), 10)
{ {
@ -52,6 +43,7 @@ pub static KERNEL_VERSION_MAJOR: u8 = match u8::from_str_radix(env!("CARGO_PKG_V
panic!("Invalid major version number ") panic!("Invalid major version number ")
} }
}; };
pub static KERNEL_VERSION_MINOR: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_MINOR"), 10) pub static KERNEL_VERSION_MINOR: u8 = match u8::from_str_radix(env!("CARGO_PKG_VERSION_MINOR"), 10)
{ {
Ok(ver) => ver, Ok(ver) => ver,

View File

@ -24,7 +24,6 @@ use memory::alloc::format;
use params::*; use params::*;
use x86_64::VirtAddr; use x86_64::VirtAddr;
use crate::boot::modules::MODULE_RESPONSE; use crate::boot::modules::MODULE_RESPONSE;
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
@ -49,7 +48,6 @@ unsafe extern "C" fn main() -> ! {
EXECUTABLE_FILE_RESPONSE.executable_file().cmdline() EXECUTABLE_FILE_RESPONSE.executable_file().cmdline()
); );
log_info!("Booting gila version {}", kernel_version_string()); log_info!("Booting gila version {}", kernel_version_string());
log_info!("Trans rights!"); log_info!("Trans rights!");
// TODO: Figure out a way to specify log categories // TODO: Figure out a way to specify log categories