Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • redox-os/bootloader
  • microcolonel/bootloader
  • noam93k/bootloader
  • carrot93/bootloader
  • tcrawford/bootloader
  • potatogim/bootloader
  • 4lDO2/bootloader
  • Ivan/bootloader
  • uuuvn/bootloader
  • lewiszlw/bootloader
  • andar1an/bootloader
  • BjornTheProgrammer/bootloader
  • CodingRays/bootloader
  • ybalrid/bootloader
  • rus/bootloader
  • saraelsa/bootloader
  • willnode/bootloader
  • bjorn3/bootloader
  • jensliu29/bootloader
  • xTibor/bootloader
  • enygmator/bootloader
  • crclark96/bootloader
22 results
Show changes
...@@ -12,8 +12,8 @@ use std::{ ...@@ -12,8 +12,8 @@ use std::{
use uefi::{ use uefi::{
Handle, Handle,
boot::LocateSearchType, boot::LocateSearchType,
reset::ResetType,
memory::MemoryType, memory::MemoryType,
reset::ResetType,
status::{Result, Status}, status::{Result, Status},
system::SystemTable, system::SystemTable,
text::TextInputKey, text::TextInputKey,
...@@ -26,6 +26,7 @@ use crate::os::{ ...@@ -26,6 +26,7 @@ use crate::os::{
}; };
use self::{ use self::{
device::{disk_device_priority, device_path_to_string},
disk::DiskEfi, disk::DiskEfi,
display::{EdidActive, Output}, display::{EdidActive, Output},
video_mode::VideoModeIter, video_mode::VideoModeIter,
...@@ -33,9 +34,11 @@ use self::{ ...@@ -33,9 +34,11 @@ use self::{
mod acpi; mod acpi;
mod arch; mod arch;
mod device;
mod disk; mod disk;
mod display; mod display;
mod dtb; #[cfg(target_arch = "aarch64")]
pub mod dtb;
mod memory_map; mod memory_map;
mod video_mode; mod video_mode;
...@@ -163,39 +166,36 @@ impl Os< ...@@ -163,39 +166,36 @@ impl Os<
} }
fn filesystem(&self, password_opt: Option<&[u8]>) -> syscall::Result<redoxfs::FileSystem<DiskEfi>> { fn filesystem(&self, password_opt: Option<&[u8]>) -> syscall::Result<redoxfs::FileSystem<DiskEfi>> {
for block_io in DiskEfi::all().into_iter() { // Search for RedoxFS on disks in prioritized order
if ! block_io.0.Media.MediaPresent { println!("Looking for RedoxFS:");
for device in disk_device_priority() {
println!(" - {}", device_path_to_string(device.device_path.0));
if ! device.disk.0.Media.MediaPresent {
continue; continue;
} }
if block_io.0.Media.LogicalPartition { let block = if device.disk.0.Media.LogicalPartition {
match redoxfs::FileSystem::open(block_io, password_opt, Some(0), false) { 0
Ok(ok) => return Ok(ok),
Err(err) => match err.errno {
// Ignore header not found error
syscall::ENOENT => (),
// Print any other errors
_ => {
log::warn!("BlockIo error: {:?}", err);
}
}
}
} else { } else {
//TODO: get block from partition table //TODO: get block from partition table
let block = 2 * crate::MIBI as u64 / redoxfs::BLOCK_SIZE; 2 * crate::MIBI as u64 / redoxfs::BLOCK_SIZE
match redoxfs::FileSystem::open(block_io, password_opt, Some(block), false) { };
Ok(ok) => return Ok(ok),
Err(err) => match err.errno { match redoxfs::FileSystem::open(device.disk, password_opt, Some(block), false) {
// Ignore header not found error Ok(ok) => return Ok(ok),
syscall::ENOENT => (), Err(err) => match err.errno {
// Print any other errors // Ignore header not found error
_ => { syscall::ENOENT => (),
log::warn!("BlockIo error: {:?}", err); // Print any other errors
} _ => {
log::warn!("BlockIo error: {:?}", err);
} }
} }
} }
} }
log::warn!("No RedoxFS partitions found");
Err(syscall::Error::new(syscall::ENOENT)) Err(syscall::Error::new(syscall::ENOENT))
} }
...@@ -304,9 +304,10 @@ impl Os< ...@@ -304,9 +304,10 @@ impl Os<
} }
fn set_text_position(&self, x: usize, y: usize) { fn set_text_position(&self, x: usize, y: usize) {
status_to_result( // Ignore error because Tow-Boot appears to not implement this
let _ = status_to_result(
(self.st.ConsoleOut.SetCursorPosition)(self.st.ConsoleOut, x, y) (self.st.ConsoleOut.SetCursorPosition)(self.st.ConsoleOut, x, y)
).unwrap(); );
} }
fn set_text_highlight(&self, highlight: bool) { fn set_text_highlight(&self, highlight: bool) {
......
use bitflags::bitflags; use bitflags::bitflags;
use core::convert::TryInto; use core::convert::TryInto;
use core::fmt; use core::ptr::{addr_of, addr_of_mut};
use syscall::io::{Io, Mmio, ReadOnly}; use syscall::io::{Io, Mmio, ReadOnly};
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use syscall::io::Pio; use syscall::io::Pio;
...@@ -71,24 +71,23 @@ where ...@@ -71,24 +71,23 @@ where
T::Value: From<u8> + TryInto<u8>, T::Value: From<u8> + TryInto<u8>,
{ {
pub fn init(&mut self) { pub fn init(&mut self) {
// Disable all interrupts unsafe {
self.int_en.write(0x00.into()); //TODO: Cleanup
// Use DLAB register // FIXME: Fix UB if unaligned
self.line_ctrl.write(0x80.into()); (&mut *addr_of_mut!(self.int_en)).write(0x00.into());
// Set divisor to 1 (115200 baud) (&mut *addr_of_mut!(self.line_ctrl)).write(0x80.into());
self.data.write(0x01.into()); (&mut *addr_of_mut!(self.data)).write(0x01.into());
self.int_en.write(0x00.into()); (&mut *addr_of_mut!(self.int_en)).write(0x00.into());
// 8 bits, no parity, one stop bit (&mut *addr_of_mut!(self.line_ctrl)).write(0x03.into());
self.line_ctrl.write(0x03.into()); (&mut *addr_of_mut!(self.fifo_ctrl)).write(0xC7.into());
// Enable FIFO, clear FIFO, 14-byte threshold (&mut *addr_of_mut!(self.modem_ctrl)).write(0x0B.into());
self.fifo_ctrl.write(0xC7.into()); (&mut *addr_of_mut!(self.int_en)).write(0x01.into());
// Enable IRQs and set RTS/DSR }
self.modem_ctrl.write(0x0B.into());
} }
fn line_sts(&self) -> LineStsFlags { fn line_sts(&self) -> LineStsFlags {
LineStsFlags::from_bits_truncate( LineStsFlags::from_bits_truncate(
(self.line_sts.read() & 0xFF.into()) (unsafe { &*addr_of!(self.line_sts) }.read() & 0xFF.into())
.try_into() .try_into()
.unwrap_or(0), .unwrap_or(0),
) )
...@@ -97,7 +96,7 @@ where ...@@ -97,7 +96,7 @@ where
pub fn receive(&mut self) -> Option<u8> { pub fn receive(&mut self) -> Option<u8> {
if self.line_sts().contains(LineStsFlags::INPUT_FULL) { if self.line_sts().contains(LineStsFlags::INPUT_FULL) {
Some( Some(
(self.data.read() & 0xFF.into()) (unsafe { &*addr_of!(self.data) }.read() & 0xFF.into())
.try_into() .try_into()
.unwrap_or(0), .unwrap_or(0),
) )
...@@ -108,7 +107,7 @@ where ...@@ -108,7 +107,7 @@ where
pub fn send(&mut self, data: u8) { pub fn send(&mut self, data: u8) {
while !self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY) {} while !self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY) {}
self.data.write(data.into()) unsafe { &mut *addr_of_mut!(self.data) }.write(data.into())
} }
pub fn write(&mut self, buf: &[u8]) { pub fn write(&mut self, buf: &[u8]) {
...@@ -130,11 +129,3 @@ where ...@@ -130,11 +129,3 @@ where
} }
} }
} }
impl<T: Io> fmt::Write for SerialPort<T>
where T::Value: From<u8> + TryInto<u8> {
fn write_str(&mut self, s: &str) -> fmt::Result {
self.write(s.as_bytes());
Ok(())
}
}
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"target-endian": "little", "target-endian": "little",
"target-pointer-width": "32", "target-pointer-width": "32",
"target-c-int-width": "32", "target-c-int-width": "32",
"data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128",
"arch": "x86", "arch": "x86",
"os": "none", "os": "none",
"env": "", "env": "",
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float", "features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float",
"dynamic-linking": false, "dynamic-linking": false,
"executables": false, "executables": false,
"relocation-model": "pic", "relocation-model": "static",
"code-model": "large", "code-model": "large",
"disable-redzone": true, "disable-redzone": true,
"frame-pointer": "always", "frame-pointer": "always",
......