Verified Commit 944189f6 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Remove unused memory function from Os trait

parent 1c7bfa88
use core::slice;
use redoxfs::Disk;
use crate::os::{Os, OsMemoryEntry, OsVideoMode};
use crate::os::{Os, OsVideoMode};
unsafe fn paging_allocate<
D: Disk,
M: Iterator<Item=OsMemoryEntry>,
V: Iterator<Item=OsVideoMode>
>(os: &mut dyn Os<D, M, V>) -> Option<&'static mut [u64]> {
>(os: &mut dyn Os<D, V>) -> Option<&'static mut [u64]> {
let ptr = os.alloc_zeroed_page_aligned(4096);
if ! ptr.is_null() {
Some(slice::from_raw_parts_mut(
......@@ -21,9 +20,8 @@ unsafe fn paging_allocate<
pub unsafe fn paging_create<
D: Disk,
M: Iterator<Item=OsMemoryEntry>,
V: Iterator<Item=OsVideoMode>
>(os: &mut dyn Os<D, M, V>, kernel_phys: usize, kernel_base: usize) -> Option<usize> {
>(os: &mut dyn Os<D, V>, kernel_phys: usize, kernel_base: usize) -> Option<usize> {
log::error!("paging_create not implemented for aarch64");
None
}
use core::slice;
use redoxfs::Disk;
use crate::os::{Os, OsMemoryEntry, OsVideoMode};
use crate::os::{Os, OsVideoMode};
unsafe fn paging_allocate<
D: Disk,
M: Iterator<Item=OsMemoryEntry>,
V: Iterator<Item=OsVideoMode>
>(os: &mut dyn Os<D, M, V>) -> Option<&'static mut [u64]> {
>(os: &mut dyn Os<D, V>) -> Option<&'static mut [u64]> {
let ptr = os.alloc_zeroed_page_aligned(4096);
if ! ptr.is_null() {
Some(slice::from_raw_parts_mut(
......@@ -21,9 +20,8 @@ unsafe fn paging_allocate<
pub unsafe fn paging_create<
D: Disk,
M: Iterator<Item=OsMemoryEntry>,
V: Iterator<Item=OsVideoMode>
>(os: &mut dyn Os<D, M, V>, kernel_phys: usize, kernel_size: usize) -> Option<usize> {
>(os: &mut dyn Os<D, V>, kernel_phys: usize, kernel_size: usize) -> Option<usize> {
// Create PML4
let pml4 = paging_allocate(os)?;
......
......@@ -93,9 +93,8 @@ pub struct KernelArgs {
fn select_mode<
D: Disk,
M: Iterator<Item=OsMemoryEntry>,
V: Iterator<Item=OsVideoMode>
>(os: &mut dyn Os<D, M, V>) -> Option<OsVideoMode> {
>(os: &mut dyn Os<D, V>) -> Option<OsVideoMode> {
let mut modes = Vec::new();
for mode in os.video_modes() {
let mut aspect_w = mode.width;
......@@ -232,9 +231,8 @@ fn select_mode<
fn redoxfs<
D: Disk,
M: Iterator<Item=OsMemoryEntry>,
V: Iterator<Item=OsVideoMode>
>(os: &mut dyn Os<D, M, V>) -> (redoxfs::FileSystem<D>, Option<String>) {
>(os: &mut dyn Os<D, V>) -> (redoxfs::FileSystem<D>, Option<String>) {
let attempts = 10;
for attempt in 0..=attempts {
let mut password_opt = None;
......@@ -283,9 +281,8 @@ fn redoxfs<
fn main<
D: Disk,
M: Iterator<Item=OsMemoryEntry>,
V: Iterator<Item=OsVideoMode>
>(os: &mut dyn Os<D, M, V>) -> (usize, KernelArgs) {
>(os: &mut dyn Os<D, V>) -> (usize, KernelArgs) {
println!("Redox OS Bootloader {} on {}", env!("CARGO_PKG_VERSION"), os.name());
let (mut fs, password_opt) = redoxfs(os);
......
......@@ -44,25 +44,23 @@ impl DiskBios {
impl Disk for DiskBios {
unsafe fn read_at(&mut self, block: u64, buffer: &mut [u8]) -> Result<usize> {
for (i, chunk) in buffer.chunks_mut(BLOCK_SIZE as usize).enumerate() {
unsafe {
let mut dap = DiskAddressPacket::from_block(block + i as u64);
ptr::write(DISK_ADDRESS_PACKET_ADDR as *mut DiskAddressPacket, dap);
let mut dap = DiskAddressPacket::from_block(block + i as u64);
ptr::write(DISK_ADDRESS_PACKET_ADDR as *mut DiskAddressPacket, dap);
let mut data = ThunkData::new();
data.eax = 0x4200;
data.edx = self.boot_disk as u32;
data.esi = DISK_ADDRESS_PACKET_ADDR as u32;
let mut data = ThunkData::new();
data.eax = 0x4200;
data.edx = self.boot_disk as u32;
data.esi = DISK_ADDRESS_PACKET_ADDR as u32;
data.with(self.thunk13);
data.with(self.thunk13);
//TODO: return result on error
assert_eq!({ data.eax }, 0);
//TODO: return result on error
assert_eq!({ data.eax }, 0);
//TODO: check blocks transferred
dap = ptr::read(DISK_ADDRESS_PACKET_ADDR as *mut DiskAddressPacket);
//TODO: check blocks transferred
dap = ptr::read(DISK_ADDRESS_PACKET_ADDR as *mut DiskAddressPacket);
ptr::copy(DISK_BIOS_ADDR as *const u8, chunk.as_mut_ptr(), chunk.len());
}
ptr::copy(DISK_BIOS_ADDR as *const u8, chunk.as_mut_ptr(), chunk.len());
}
Ok(buffer.len())
......
......@@ -12,7 +12,7 @@ use crate::logger::LOGGER;
use crate::os::{Os, OsKey, OsVideoMode};
use self::disk::DiskBios;
use self::memory_map::{memory_map, MemoryMapIter};
use self::memory_map::memory_map;
use self::thunk::ThunkData;
use self::vbe::VideoModeIter;
use self::vga::{VgaTextColor, Vga};
......@@ -57,7 +57,6 @@ pub struct OsBios {
impl Os<
DiskBios,
MemoryMapIter,
VideoModeIter
> for OsBios {
fn name(&self) -> &str {
......@@ -93,10 +92,6 @@ impl Os<
redoxfs::FileSystem::open(disk, password_opt, Some(block), false)
}
fn memory(&self) -> MemoryMapIter {
MemoryMapIter::new(self.thunk15)
}
fn video_modes(&self) -> VideoModeIter {
VideoModeIter::new(self.thunk10)
}
......@@ -212,11 +207,6 @@ pub unsafe extern "C" fn start(
// Set logger
LOGGER.init();
let (heap_start, heap_size) = memory_map(thunk15)
.expect("No memory for heap");
ALLOCATOR.lock().init(heap_start, heap_size);
let mut os = OsBios {
boot_disk,
thunk10,
......@@ -225,6 +215,11 @@ pub unsafe extern "C" fn start(
thunk16,
};
let (heap_start, heap_size) = memory_map(os.thunk15)
.expect("No memory for heap");
ALLOCATOR.lock().init(heap_start, heap_size);
let (page_phys, args) = crate::main(&mut os);
kernel_entry(
......
......@@ -56,7 +56,6 @@ pub struct OsVideoMode {
pub trait Os<
D: Disk,
M: Iterator<Item=OsMemoryEntry>,
V: Iterator<Item=OsVideoMode>
> {
fn name(&self) -> &str;
......@@ -67,8 +66,6 @@ pub trait Os<
fn filesystem(&self, password_opt: Option<&[u8]>) -> syscall::Result<redoxfs::FileSystem<D>>;
fn memory(&self) -> M;
fn video_modes(&self) -> V;
fn set_video_mode(&self, mode: &mut OsVideoMode);
fn best_resolution(&self) -> Option<(u32, u32)>;
......
......@@ -23,7 +23,6 @@ use crate::os::{
use self::{
disk::DiskEfi,
display::{EdidActive, Output},
memory_map::MemoryMapIter,
video_mode::VideoModeIter,
};
......@@ -41,7 +40,6 @@ pub struct OsEfi {
impl Os<
DiskEfi,
MemoryMapIter,
VideoModeIter
> for OsEfi {
#[cfg(target_arch = "aarch64")]
......@@ -103,10 +101,6 @@ impl Os<
Err(syscall::Error::new(syscall::ENOENT))
}
fn memory(&self) -> MemoryMapIter {
MemoryMapIter::new()
}
fn video_modes(&self) -> VideoModeIter {
VideoModeIter::new()
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment