Skip to content

Commit

Permalink
Fix nightly compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalmiel committed Mar 23, 2024
1 parent 7852c87 commit da4c893
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 32 deletions.
1 change: 1 addition & 0 deletions cykusz-rs/src/arch/x86_64/acpi/rsdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub enum Address {
trait Header {
fn signature(&'static self) -> &'static [u8; 8];
fn rsdt_address(&'static self) -> MappedAddr;
#[allow(dead_code)]
fn revision(&'static self) -> u8;
}

Expand Down
11 changes: 6 additions & 5 deletions cykusz-rs/src/arch/x86_64/gdt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use core::ptr::addr_of;
use crate::arch::raw::descriptor as dsc;
use crate::arch::raw::gdt;
use crate::arch::raw::segmentation as sgm;
Expand Down Expand Up @@ -61,7 +62,7 @@ pub const fn ring3_ds() -> sgm::SegmentSelector {
pub fn early_init() {
unsafe {
INIT_GDTR.init(&INIT_GDT[..]);
dsc::lgdt(&INIT_GDTR);
dsc::lgdt(addr_of!(INIT_GDTR));

sgm::set_cs(ring0_cs());
sgm::load_ds(ring0_ds());
Expand All @@ -87,27 +88,27 @@ fn init_tss(stack_top: VirtAddr, fs_base: u64) {
let gdt_low = &mut GDT[5];
//logln!("here {:p}", gdt_low as *mut _);

gdt_low.set_offset(&TSS as *const _ as u32);
gdt_low.set_offset(addr_of!(TSS) as u32);
gdt_low.set_limit(::core::mem::size_of::<TaskStateSegment>() as u32);
}

{
let gdt_high = &mut GDT[6];
gdt_high.set_raw((&TSS as *const _ as u64) >> 32);
gdt_high.set_raw((addr_of!(TSS) as u64) >> 32);
}

dsc::load_tr(&sgm::SegmentSelector::from_raw(5 << 3));

use crate::arch::raw::msr;
msr::wrmsr(msr::IA32_KERNEL_GS_BASE, &TSS as *const _ as u64);
msr::wrmsr(msr::IA32_KERNEL_GS_BASE, addr_of!(TSS) as u64);
}
}

//TLS available
pub fn init(stack_top: VirtAddr, fs_base: u64) {
unsafe {
GDTR.init(&GDT[..]);
dsc::lgdt(&GDTR);
dsc::lgdt(addr_of!(GDTR));

sgm::set_cs(ring0_cs());
sgm::load_ds(ring0_ds());
Expand Down
2 changes: 0 additions & 2 deletions cykusz-rs/src/arch/x86_64/mm/virt/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use core::marker::PhantomData;

use crate::arch::mm::virt::entry::Entry;
use crate::arch::x86_64::mm::phys::PhysPage;
use crate::kernel::mm::virt;
use crate::kernel::mm::Frame;
use crate::kernel::mm::*;
use crate::kernel::sync::SpinGuard;

Expand Down
2 changes: 1 addition & 1 deletion cykusz-rs/src/arch/x86_64/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ macro_rules! logln {
#[allow(unused)]
macro_rules! log {
($($arg:tt)*) => ({
crate::arch::output::log_fmt_disabled(format_args!($($arg)*)).unwrap();
crate::arch::output::log_fmt(format_args!($($arg)*)).unwrap();
});
}
#[macro_export]
Expand Down
2 changes: 1 addition & 1 deletion cykusz-rs/src/arch/x86_64/raw/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub unsafe fn lidt(idt: &DescriptorTablePointer<idt::IdtEntry>) {
asm!("lidt [{0}]", in(reg) idt);
}

pub unsafe fn lgdt(gdt: &DescriptorTablePointer<gdt::GdtEntry>) {
pub unsafe fn lgdt(gdt: *const DescriptorTablePointer<gdt::GdtEntry>) {
asm!("lgdt [{0}]", in(reg) gdt);
}

Expand Down
4 changes: 3 additions & 1 deletion cykusz-rs/src/drivers/multiboot2/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::ptr::addr_of;
use crate::drivers::multiboot2::framebuffer_info::FramebufferInfo;
use crate::kernel::mm::{MappedAddr, PhysAddr, VirtAddr};

pub use self::tags::*;
Expand Down Expand Up @@ -76,7 +78,7 @@ impl Info {

pub fn framebuffer_info_tag(&self) -> Option<&'static tags::framebuffer_info::FramebufferInfo> {
self.tags().find(|t| t.typ == 8).map(|t| unsafe {
&*(t as *const tags::Tag as *const tags::framebuffer_info::FramebufferInfo)
VirtAddr(addr_of!(*t) as usize).read_ref::<FramebufferInfo>()
})
}

Expand Down
4 changes: 3 additions & 1 deletion cykusz-rs/src/drivers/multiboot2/tags/framebuffer_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use core::ptr::addr_of;
use crate::drivers::multiboot2::Tag;
use crate::kernel::mm::VirtAddr;

#[repr(C)]
#[derive(Debug)]
Expand Down Expand Up @@ -84,6 +86,6 @@ impl FramebufferInfo {
}

pub fn framebuffer_type(&self) -> &'static FramebufferType {
unsafe { &*(&self.color_info as *const u8 as *const FramebufferType) }
unsafe { VirtAddr(addr_of!(self.color_info) as usize).read_ref::<FramebufferType>() }
}
}
7 changes: 2 additions & 5 deletions cykusz-rs/src/drivers/net/e1000/device.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use alloc::vec::Vec;
use bit_field::BitField;

use crate::drivers::net::e1000::addr::Addr;
use crate::drivers::net::e1000::regs::Regs;
use crate::drivers::pci::{PciData, PciHeader, PciHeader0};
use crate::drivers::pci::{PciData, PciHeader0};
use crate::kernel::mm::allocate_order;
use crate::kernel::mm::heap::{allocate_align, deallocate_align};
use crate::kernel::mm::{MappedAddr, PhysAddr, VirtAddr};
use crate::kernel::mm::{PhysAddr, VirtAddr};
use crate::kernel::net::PacketBaseTrait;
use crate::kernel::timer::busy_sleep;

Expand Down
1 change: 0 additions & 1 deletion cykusz-rs/src/drivers/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use alloc::sync::{Arc, Weak};

use crate::kernel::sync::Spin;
use crate::kernel::timer::current_ns;
use rand;
use rand::{RngCore, SeedableRng};

struct Random {
Expand Down
2 changes: 0 additions & 2 deletions cykusz-rs/src/kernel/mm/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use linked_list_allocator::Heap;
use spin::Once;

use crate::arch::mm::heap::{HEAP_END, HEAP_SIZE, HEAP_START};
use crate::kernel::mm::map;
use crate::kernel::mm::PAGE_SIZE;
use crate::kernel::mm::*;
use crate::kernel::sync::Spin;
use crate::kernel::utils::types::Align;
Expand Down
4 changes: 2 additions & 2 deletions cykusz-rs/src/kernel/syscall/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ pub fn sys_link(
)
};

if Weak::as_ptr(&inode.fs().unwrap()) != Weak::as_ptr(&target_entry.inode().fs().unwrap()) {
if !Weak::ptr_eq(&inode.fs().unwrap(), &target_entry.inode().fs().unwrap()) {
return Err(SyscallError::EINVAL);
}

Expand Down Expand Up @@ -677,7 +677,7 @@ pub fn sys_rename(
)
};

if new.inode().fs().unwrap().as_ptr() != old.inode().fs().unwrap().as_ptr() {
if !Weak::ptr_eq(&new.inode().fs().unwrap(), &old.inode().fs().unwrap()) {
return Err(SyscallError::EACCES);
}

Expand Down
1 change: 0 additions & 1 deletion cykusz-rs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![no_std]
#![allow(internal_features)]
#![feature(alloc_error_handler)]
#![feature(array_methods)]
#![feature(asm_const)]
#![feature(auto_traits)]
#![feature(c_variadic)]
Expand Down
3 changes: 0 additions & 3 deletions syscall-defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
extern crate alloc;
#[macro_use]
extern crate bitflags;

use core::convert::TryFrom;

pub mod events;
pub mod exec;
pub mod ioctl;
Expand Down
2 changes: 0 additions & 2 deletions syscall-defs/src/resource.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::SyscallError;
use core::convert::TryFrom;

pub enum RLimitKind {
Core = 1,
Cpu = 2,
Expand Down
1 change: 1 addition & 0 deletions user-alloc/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub trait Align {
}

pub trait CeilDiv {
#[allow(dead_code)]
fn ceil_div(self, d: Self) -> Self;
}

Expand Down
11 changes: 7 additions & 4 deletions userspace/src/bin/shell/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern crate syscall_user as syscall;

use alloc::string::String;
use alloc::vec::Vec;
use core::ptr::{addr_of, addr_of_mut};

use chrono::{Datelike, Timelike};
use syscall::bochs;
Expand Down Expand Up @@ -45,7 +46,7 @@ fn ls(path: &str) {
let struct_len = core::mem::size_of::<SysDirEntry>();

loop {
let dentry = unsafe { &*(buf.as_ptr().offset(offset) as *const SysDirEntry) };
let dentry = unsafe { &*(addr_of!(buf).offset(offset) as *const SysDirEntry) };
let namebytes = unsafe {
core::slice::from_raw_parts(
dentry.name.as_ptr(),
Expand Down Expand Up @@ -736,12 +737,12 @@ static mut READY: bool = false;

fn set_ready(r: bool) {
unsafe {
(&mut READY as *mut bool).write_volatile(r);
addr_of_mut!(READY).write_volatile(r);
}
}

fn ready() -> bool {
unsafe { (&READY as *const bool).read_volatile() }
unsafe { addr_of!(READY).read_volatile() }
}

fn signal_test() {
Expand Down Expand Up @@ -836,7 +837,9 @@ fn main_old() -> ! {
print!("[root {}]# ", make_str(&pwd[0..pwd_r]));

// Read some data from stdin
let r = syscall::read(1, &mut buf).unwrap();
let r = syscall::read(1, &mut unsafe {
*addr_of_mut!(buf)
}).unwrap();

{
// Write data from stdin into the file
Expand Down
3 changes: 2 additions & 1 deletion userspace/src/bin/shell/nc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use core::ptr::addr_of_mut;
use syscall_defs::net::{SockAddr, SockAddrIn, SockDomain, SockType, SockTypeFlags};
use syscall_defs::poll::FdSet;

Expand All @@ -23,7 +24,7 @@ static mut RECV_BUF: [u8; 2 * 4096] = [0u8; 2 * 4096];
static mut SENT: usize = 0;

fn recv(fd: usize) -> bool {
let res = unsafe { syscall::read(fd, &mut RECV_BUF) };
let res = unsafe { syscall::read(fd, &mut *addr_of_mut!(RECV_BUF)) };

match res {
Ok(len) if len > 1 => {
Expand Down

0 comments on commit da4c893

Please sign in to comment.