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::{
use uefi::{
Handle,
boot::LocateSearchType,
reset::ResetType,
memory::MemoryType,
reset::ResetType,
status::{Result, Status},
system::SystemTable,
text::TextInputKey,
......@@ -26,6 +26,7 @@ use crate::os::{
};
use self::{
device::{disk_device_priority, device_path_to_string},
disk::DiskEfi,
display::{EdidActive, Output},
video_mode::VideoModeIter,
......@@ -33,9 +34,11 @@ use self::{
mod acpi;
mod arch;
mod device;
mod disk;
mod display;
mod dtb;
#[cfg(target_arch = "aarch64")]
pub mod dtb;
mod memory_map;
mod video_mode;
......@@ -163,39 +166,36 @@ impl Os<
}
fn filesystem(&self, password_opt: Option<&[u8]>) -> syscall::Result<redoxfs::FileSystem<DiskEfi>> {
for block_io in DiskEfi::all().into_iter() {
if ! block_io.0.Media.MediaPresent {
// Search for RedoxFS on disks in prioritized order
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;
}
if block_io.0.Media.LogicalPartition {
match redoxfs::FileSystem::open(block_io, password_opt, Some(0), false) {
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);
}
}
}
let block = if device.disk.0.Media.LogicalPartition {
0
} else {
//TODO: get block from partition table
let block = 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 {
// Ignore header not found error
syscall::ENOENT => (),
// Print any other errors
_ => {
log::warn!("BlockIo error: {:?}", err);
}
2 * crate::MIBI as u64 / redoxfs::BLOCK_SIZE
};
match redoxfs::FileSystem::open(device.disk, password_opt, Some(block), false) {
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);
}
}
}
}
log::warn!("No RedoxFS partitions found");
Err(syscall::Error::new(syscall::ENOENT))
}
......@@ -304,9 +304,10 @@ impl Os<
}
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)
).unwrap();
);
}
fn set_text_highlight(&self, highlight: bool) {
......
use bitflags::bitflags;
use core::convert::TryInto;
use core::fmt;
use core::ptr::{addr_of, addr_of_mut};
use syscall::io::{Io, Mmio, ReadOnly};
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use syscall::io::Pio;
......@@ -71,24 +71,23 @@ where
T::Value: From<u8> + TryInto<u8>,
{
pub fn init(&mut self) {
// Disable all interrupts
self.int_en.write(0x00.into());
// Use DLAB register
self.line_ctrl.write(0x80.into());
// Set divisor to 1 (115200 baud)
self.data.write(0x01.into());
self.int_en.write(0x00.into());
// 8 bits, no parity, one stop bit
self.line_ctrl.write(0x03.into());
// Enable FIFO, clear FIFO, 14-byte threshold
self.fifo_ctrl.write(0xC7.into());
// Enable IRQs and set RTS/DSR
self.modem_ctrl.write(0x0B.into());
unsafe {
//TODO: Cleanup
// FIXME: Fix UB if unaligned
(&mut *addr_of_mut!(self.int_en)).write(0x00.into());
(&mut *addr_of_mut!(self.line_ctrl)).write(0x80.into());
(&mut *addr_of_mut!(self.data)).write(0x01.into());
(&mut *addr_of_mut!(self.int_en)).write(0x00.into());
(&mut *addr_of_mut!(self.line_ctrl)).write(0x03.into());
(&mut *addr_of_mut!(self.fifo_ctrl)).write(0xC7.into());
(&mut *addr_of_mut!(self.modem_ctrl)).write(0x0B.into());
(&mut *addr_of_mut!(self.int_en)).write(0x01.into());
}
}
fn line_sts(&self) -> LineStsFlags {
LineStsFlags::from_bits_truncate(
(self.line_sts.read() & 0xFF.into())
(unsafe { &*addr_of!(self.line_sts) }.read() & 0xFF.into())
.try_into()
.unwrap_or(0),
)
......@@ -97,7 +96,7 @@ where
pub fn receive(&mut self) -> Option<u8> {
if self.line_sts().contains(LineStsFlags::INPUT_FULL) {
Some(
(self.data.read() & 0xFF.into())
(unsafe { &*addr_of!(self.data) }.read() & 0xFF.into())
.try_into()
.unwrap_or(0),
)
......@@ -108,7 +107,7 @@ where
pub fn send(&mut self, data: u8) {
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]) {
......@@ -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 @@
"target-endian": "little",
"target-pointer-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",
"os": "none",
"env": "",
......@@ -16,7 +16,7 @@
"features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float",
"dynamic-linking": false,
"executables": false,
"relocation-model": "pic",
"relocation-model": "static",
"code-model": "large",
"disable-redzone": true,
"frame-pointer": "always",
......