Skip to content

Commit

Permalink
update: remove allow attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
watasuke102 committed Jun 14, 2023
1 parent 99f6e73 commit e717f29
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 122 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ OVMF_DIR := /usr/share/edk2-ovmf/x64
INITFS_ITEM := $(shell find initfs -type f)
COMMON_SRC := $(shell find common -name "*.rs")
LOADER_SRC := $(COMMON_SRC) $(shell find loader -name "*.rs")
KERNEL_SRC := $(COMMON_SRC) $(shell find kernel -name "*.rs")
KERNEL_SRC := $(COMMON_SRC) $(shell find kernel -name "*.rs" -or -name "*.asm")
APPS := none fib

.PHONY: all b r kill apps loader kernel initfs
Expand Down
2 changes: 0 additions & 2 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

extern crate alloc;
pub mod memory_map;
pub mod rect;
pub mod serial;
pub mod vec2;
21 changes: 0 additions & 21 deletions common/src/rect.rs

This file was deleted.

44 changes: 0 additions & 44 deletions common/src/vec2.rs

This file was deleted.

3 changes: 1 addition & 2 deletions kernel/src/exec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use alloc::string::String;
use common::serial_println;
use core::arch::asm;
use elf_rs::{Elf, ElfFile, ElfType, ProgramType};
use elf_rs::{Elf, ElfFile};

pub fn execute_elf(data: &[u8], mut entry_addr: u64) {
let Ok(elf) = Elf::from_bytes(data) else {
Expand Down
5 changes: 1 addition & 4 deletions kernel/src/fat.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use core::str::FromStr;

use alloc::{borrow::ToOwned, format, string::String, vec::Vec};
use common::{serial_print, serial_println};
use alloc::{format, string::String, vec::Vec};

#[derive(Debug)]
pub struct File {
Expand Down
5 changes: 1 addition & 4 deletions kernel/src/interrupt.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use common::serial_println;
use x86_64::{
instructions::{
interrupts,
port::{PortReadOnly, PortWriteOnly},
},
instructions::interrupts,
structures::idt::{InterruptDescriptorTable, InterruptStackFrame},
};

Expand Down
16 changes: 2 additions & 14 deletions kernel/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![no_std]
#![no_main]
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]
#![feature(const_mut_refs)]
#![feature(abi_x86_interrupt)]
#![feature(vec_into_raw_parts)]
Expand All @@ -16,21 +13,12 @@ mod interrupt;
mod linked_list;
mod memory;

use alloc::{
alloc::Layout,
string::String,
vec::{self, Vec},
};
use alloc::{alloc::Layout, string::String, vec::Vec};
use common::{memory_map::MemoryMap, serial, serial_print, serial_println};
use core::{arch::asm, mem::transmute, panic::PanicInfo};
use elf_rs::{Elf, ElfFile, ElfType, ProgramType};
use kernel::*;
use core::panic::PanicInfo;
use memory::*;
use uefi::proto::media::file;
use x86_64::instructions::hlt;

use crate::interrupt::init;

#[panic_handler]
fn handle_panic(info: &PanicInfo) -> ! {
serial_println!("[PANIC] {}", info);
Expand Down
5 changes: 0 additions & 5 deletions kernel/src/memory/global_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ pub fn init(memmap: &MemoryMap) {
);
}

pub fn print_free_memory() {
let mem = ALLOCATOR.lock().total_size();
serial_println!("[Debug] free memory: {} ({} MB)", mem, mem / (1024 * 1024));
}

struct Allocator {
item: Mutex<LinkedListAllocator>,
}
Expand Down
4 changes: 0 additions & 4 deletions kernel/src/memory/linked_list_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ impl LinkedListAllocator {
}
}

pub unsafe fn init(&mut self, heap_begin: usize, heap_size: usize) {
self.add_free_region(heap_begin, heap_size);
}

/// return (size, align)
pub fn size_align(layout: Layout) -> (usize, usize) {
let layout = layout
Expand Down
1 change: 0 additions & 1 deletion kernel/src/memory/paging.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use common::serial_println;
use x86_64::{
registers::control::{Cr3, Cr3Flags},
structures::paging::*,
Expand Down
25 changes: 5 additions & 20 deletions loader/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
#![no_std]
#![no_main]
#![feature(abi_efiapi)]
#![feature(vec_into_raw_parts)]
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]

extern crate alloc;
use alloc::{vec, vec::Vec};
use common::{
memory_map::{is_available_memory, MemoryMap, MEMORYMAP_LIST_LEN},
serial_print, serial_println,
vec2::Vec2,
serial_println,
};
use core::{arch::asm, fmt::Write};
use elf_rs::{Elf, ElfFile, ProgramType};
use uefi::{
prelude::*,
proto::{
console::gop::GraphicsOutput,
media::file::{File, FileAttribute, FileMode, FileType::*, RegularFile},
},
table::boot::{
self, AllocateType, MemoryDescriptor, MemoryType, OpenProtocolAttributes, OpenProtocolParams,
},
CStr16, ResultExt,
proto::media::file::{File, FileAttribute, FileMode, FileType::*, RegularFile},
table::boot::MemoryDescriptor,
CStr16,
};

#[derive(Debug)]
struct LoadSegment {
begin: u64,
end: u64,
offset: u64,
vaddr: u64,
memory_size: u64,
Expand Down Expand Up @@ -64,8 +52,6 @@ fn main(handle: Handle, mut table: SystemTable<Boot>) -> Status {
for program_header in elf.program_header_iter() {
if program_header.ph_type() == ProgramType::LOAD {
load_segment.push(LoadSegment {
begin: program_header.paddr(),
end: program_header.paddr() + program_header.memsz(),
offset: program_header.offset(),
vaddr: program_header.vaddr(),
file_size: program_header.filesz(),
Expand Down Expand Up @@ -93,14 +79,13 @@ fn main(handle: Handle, mut table: SystemTable<Boot>) -> Status {
initfs.read(&mut initfs_pool).unwrap();

// get memmap
let memmap_size = table.boot_services().memory_map_size().map_size;
let mut memmap = MemoryMap {
list: [MemoryDescriptor::default(); MEMORYMAP_LIST_LEN],
len: 0,
};
let mut buf = [0 as u8; 1024 * 8];
println!("[Info] Exiting boot services");
let (memmap_key, memmap_iter) = table.exit_boot_services(handle, &mut buf).unwrap();
let (_, memmap_iter) = table.exit_boot_services(handle, &mut buf).unwrap();
serial_println!(
"[Debug] end of boot services (memmap: {})",
memmap_iter.len()
Expand Down

0 comments on commit e717f29

Please sign in to comment.