Skip to content

Commit

Permalink
don't export unneeded symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Nov 10, 2024
1 parent 1cd33b6 commit 71521e3
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 32 deletions.
13 changes: 8 additions & 5 deletions src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ pub mod x86;

// Export our platform-specific modules.
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
pub use self::x86::kernel::{init, processor};
pub use self::x86::kernel::init;

#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
pub(crate) use self::x86::kernel::processor;

#[cfg(all(target_arch = "x86", feature = "vga"))]
pub use self::x86::kernel::vga;
pub(crate) use self::x86::kernel::vga;

#[cfg(not(all(target_arch = "x86", feature = "vga")))]
pub use self::x86::kernel::serial;
pub(crate) use self::x86::kernel::serial;

// Export our platform-specific modules.
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
pub use self::x86::kernel::switch::switch;
pub(crate) use self::x86::kernel::switch::switch;

// Export our platform-specific modules.
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
pub use self::x86::mm;
pub(crate) use self::x86::mm;
4 changes: 2 additions & 2 deletions src/arch/x86/kernel/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod processor;
pub(crate) mod processor;
#[cfg(not(all(target_arch = "x86", feature = "vga")))]
pub mod serial;
pub(crate) mod serial;
#[cfg(target_arch = "x86_64")]
mod start;
pub(crate) mod switch;
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86/kernel/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) fn halt() {

#[allow(unused_variables)]
#[no_mangle]
pub extern "C" fn shutdown(error_code: i32) -> ! {
pub(crate) extern "C" fn shutdown(error_code: i32) -> ! {
#[cfg(feature = "qemu-exit")]
{
let code = if error_code == 0 { 5 } else { 1 };
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86/kernel/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use spin::Mutex;
use x86::io::*;

/// A COM serial port.
pub struct ComPort {
pub(crate) struct ComPort {
/// COM ports are identified by the base address of their associated
/// I/O registers.
base_addr: u16,
Expand Down Expand Up @@ -32,4 +32,4 @@ impl fmt::Write for ComPort {
}

/// Our primary serial port.
pub static COM1: Mutex<ComPort> = Mutex::new(ComPort::new(0x3F8));
pub(crate) static COM1: Mutex<ComPort> = Mutex::new(ComPort::new(0x3F8));
4 changes: 2 additions & 2 deletions src/arch/x86/kernel/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ macro_rules! restore_context {
/// context. `old_stack` is a pointer, where the address to the old
/// stack is stored. `new_stack` provides the stack pointer of the
/// next task.
pub unsafe extern "C" fn switch(_old_stack: *mut usize, _new_stack: usize) {
pub(crate) unsafe extern "C" fn switch(_old_stack: *mut usize, _new_stack: usize) {
// rdi = old_stack => the address to store the old rsp
// rsi = new_stack => stack pointer of the new task

Expand All @@ -86,7 +86,7 @@ pub unsafe extern "C" fn switch(_old_stack: *mut usize, _new_stack: usize) {
/// context. `old_stack` is a pointer, where the address to the old
/// stack is stored. `new_stack` provides the stack pointer of the
/// next task.
pub unsafe extern "C" fn switch(_old_stack: *mut usize, _new_stack: usize) {
pub(crate) unsafe extern "C" fn switch(_old_stack: *mut usize, _new_stack: usize) {
asm!(
// store all registers
"pushfd",
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86/mm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use x86::bits32::paging::VAddr as VirtAddr;
pub use x86::bits64::paging::VAddr as VirtAddr;

#[derive(Copy, Clone)]
pub struct BootStack {
pub(crate) struct BootStack {
start: VirtAddr,
end: VirtAddr,
}
Expand Down
4 changes: 2 additions & 2 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ pub enum LogLevel {
}

/// Data structures to filter kernel messages
pub struct KernelLogger {
pub(crate) struct KernelLogger {
pub log_level: LogLevel,
}

/// default logger to handle kernel messages
pub const LOGGER: KernelLogger = KernelLogger {
pub(crate) const LOGGER: KernelLogger = KernelLogger {
log_level: LogLevel::INFO,
};

Expand Down
2 changes: 0 additions & 2 deletions src/mm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#[cfg(not(test))]
use alloc::alloc::Layout;

pub fn init() {}

#[cfg(not(test))]
#[alloc_error_handler]
pub fn rust_oom(layout: Layout) -> ! {
Expand Down
11 changes: 6 additions & 5 deletions src/scheduler/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use core::sync::atomic::{AtomicU32, Ordering};
static NO_TASKS: AtomicU32 = AtomicU32::new(0);
static TID_COUNTER: AtomicU32 = AtomicU32::new(0);

pub struct Scheduler {
pub(crate) struct Scheduler {
/// task id which is currently running
current_task: Rc<RefCell<Task>>,
/// task id of the idle task
Expand Down Expand Up @@ -94,15 +94,15 @@ impl Scheduler {
self.current_task.borrow().id
}

// determine the next task, which is ready and priority is a greater than or equal to prio
/// determine the next task, which is ready and priority is a greater than or equal to prio
fn get_next_task(&mut self, prio: TaskPriority) -> Option<Rc<RefCell<Task>>> {
let i = lsb(self.prio_bitmap);
let mut task = None;

if i <= prio.into().into() {
task = self.ready_queues[i].pop();

// clear bitmap entry for the priority i if the queus is empty
// clear bitmap entry for the priority i if the queues is empty
if self.ready_queues[i].is_empty() {
self.prio_bitmap &= !(1 << i);
}
Expand All @@ -112,12 +112,13 @@ impl Scheduler {
}

pub fn schedule(&mut self) {
info!("Schedule");
// do we have finished tasks? => drop tasks => deallocate implicitly the stack
while let Some(id) = self.finished_tasks.pop_front() {
if self.tasks.remove(&id).is_none() {
info!("Unable to drop task {}", id);
warn!("Unable to drop task {}", id);
} else {
debug!("Unable to drop task {}", id);
debug!("Drop task {}", id);
}
}

Expand Down
14 changes: 4 additions & 10 deletions src/scheduler/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ pub const HIGH_PRIORITY: TaskPriority = TaskPriority::from(0);
pub const NORMAL_PRIORITY: TaskPriority = TaskPriority::from(24);
pub const LOW_PRIORITY: TaskPriority = TaskPriority::from(NO_PRIORITIES as u8 - 1);

pub trait Stack {
pub(crate) trait Stack {
fn top(&self) -> VirtAddr;
fn bottom(&self) -> VirtAddr;
}

#[derive(Copy, Clone)]
#[repr(align(64))]
#[repr(C)]
pub struct TaskStack {
pub(crate) struct TaskStack {
buffer: [u8; STACK_SIZE],
}

Expand Down Expand Up @@ -99,17 +99,11 @@ impl Default for TaskStack {
}

#[derive(Default)]
pub struct TaskQueue {
pub(crate) struct TaskQueue {
queue: VecDeque<Rc<RefCell<Task>>>,
}

impl TaskQueue {
pub fn new() -> TaskQueue {
TaskQueue {
queue: Default::default(),
}
}

/// Add a task to the queue
pub fn push(&mut self, task: Rc<RefCell<Task>>) {
self.queue.push_back(task);
Expand All @@ -128,7 +122,7 @@ impl TaskQueue {

/// A task control block, which identifies either a process or a thread
#[repr(align(64))]
pub struct Task {
pub(crate) struct Task {
/// The ID of this context
pub id: TaskId,
/// Task Priority
Expand Down

0 comments on commit 71521e3

Please sign in to comment.