[Denali] Begin porting to rust.
This commit is contained in:
parent
72e5d8c618
commit
51478e7ccf
|
@ -22,6 +22,7 @@ name = "denali"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mammoth",
|
"mammoth",
|
||||||
|
"yellowstone-yunq",
|
||||||
"yunq",
|
"yunq",
|
||||||
"yunqc",
|
"yunqc",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
members = [ "lib/denali",
|
members = [
|
||||||
"lib/mammoth", "lib/victoriafalls", "lib/voyageurs", "lib/yellowstone", "lib/yunq", "lib/yunq-test", "sys/teton", "sys/yellowstone", "usr/testbed",
|
"lib/mammoth", "lib/victoriafalls", "lib/voyageurs", "lib/yellowstone", "lib/yunq", "lib/yunq-test", "sys/denali", "sys/teton", "sys/yellowstone", "usr/testbed",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "denali"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
mammoth = { path = "../mammoth" }
|
|
||||||
yunq = {path = "../yunq"}
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
yunqc = {path = "../../../yunq/rust"}
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
[package]
|
||||||
|
name = "denali"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
mammoth = { path = "../../lib/mammoth" }
|
||||||
|
yunq = {path = "../../lib/yunq"}
|
||||||
|
|
||||||
|
yellowstone-yunq = { path = "../../lib/yellowstone", optional = true }
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "denali"
|
||||||
|
required-features = ["binary"]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
yunqc = {path = "../../../yunq/rust"}
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["binary"]
|
||||||
|
binary = ["dep:yellowstone-yunq"]
|
|
@ -0,0 +1,49 @@
|
||||||
|
use mammoth::mem::MemoryRegion;
|
||||||
|
|
||||||
|
#[repr(C, packed)]
|
||||||
|
pub struct PciDeviceHeader {
|
||||||
|
pub vendor_id: u16,
|
||||||
|
pub device_id: u16,
|
||||||
|
pub command_reg: u16,
|
||||||
|
pub status_reg: u16,
|
||||||
|
pub revision: u8,
|
||||||
|
pub prog_interface: u8,
|
||||||
|
pub subclass: u8,
|
||||||
|
pub class_code: u8,
|
||||||
|
pub cache_line_size: u8,
|
||||||
|
pub latency_timer: u8,
|
||||||
|
pub header_type: u8,
|
||||||
|
pub bist: u8,
|
||||||
|
pub bars: [u32; 5],
|
||||||
|
pub abar: u32,
|
||||||
|
pub reserved0: u32,
|
||||||
|
pub subsystem_id: u32,
|
||||||
|
pub expansion_rom: u16,
|
||||||
|
pub cap_ptr: u8,
|
||||||
|
pub reserved1: [u8; 7],
|
||||||
|
pub interrupt_line: u8,
|
||||||
|
pub interrupt_pin: u8,
|
||||||
|
pub min_grant: u8,
|
||||||
|
pub max_latency: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct AhciController {
|
||||||
|
pci_memory: MemoryRegion,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AhciController {
|
||||||
|
pub fn new(pci_memory: MemoryRegion) -> Self {
|
||||||
|
Self { pci_memory }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pci_header(&self) -> &mut PciDeviceHeader {
|
||||||
|
unsafe {
|
||||||
|
self.pci_memory
|
||||||
|
.mut_slice::<u8>()
|
||||||
|
.as_mut_ptr()
|
||||||
|
.cast::<PciDeviceHeader>()
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
mod controller;
|
||||||
|
|
||||||
|
pub use controller::AhciController;
|
|
@ -0,0 +1,29 @@
|
||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
use mammoth::{define_entry, zion::z_err_t};
|
||||||
|
|
||||||
|
use denali::ahci::AhciController;
|
||||||
|
|
||||||
|
define_entry!();
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
extern "C" fn main() -> z_err_t {
|
||||||
|
mammoth::debug!("IN Denali!");
|
||||||
|
|
||||||
|
let yellowstone = yellowstone_yunq::from_init_endpoint();
|
||||||
|
|
||||||
|
let ahci_info = yellowstone
|
||||||
|
.get_ahci_info()
|
||||||
|
.expect("Failed to get ahci info");
|
||||||
|
|
||||||
|
let ahci_controller = AhciController::new(
|
||||||
|
mammoth::mem::MemoryRegion::from_cap(mammoth::cap::Capability::take(ahci_info.ahci_region))
|
||||||
|
.unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
|
mammoth::debug!("AHCI ABAR {:#x}", ahci_controller.pci_header().abar as u64);
|
||||||
|
0
|
||||||
|
}
|
|
@ -3,3 +3,5 @@
|
||||||
use core::include;
|
use core::include;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/yunq.rs"));
|
include!(concat!(env!("OUT_DIR"), "/yunq.rs"));
|
||||||
|
|
||||||
|
pub mod ahci;
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mammoth = { path = "../../lib/mammoth" }
|
mammoth = { path = "../../lib/mammoth" }
|
||||||
denali = { path = "../../lib/denali" }
|
denali = { path = "../../sys/denali", default-features = false}
|
||||||
victoriafalls = { path = "../../lib/victoriafalls" }
|
victoriafalls = { path = "../../lib/victoriafalls" }
|
||||||
voyageurs = { path = "../../lib/voyageurs" }
|
voyageurs = { path = "../../lib/voyageurs" }
|
||||||
yellowstone-yunq = { path = "../../lib/yellowstone" }
|
yellowstone-yunq = { path = "../../lib/yellowstone" }
|
||||||
|
|
|
@ -40,7 +40,7 @@ cp ../zion/boot/limine.cfg efi/
|
||||||
cp zion/zion efi/
|
cp zion/zion efi/
|
||||||
mkdir -p efi/sys
|
mkdir -p efi/sys
|
||||||
cp ../sysroot/bin/yellowstone efi/sys/yellowstone
|
cp ../sysroot/bin/yellowstone efi/sys/yellowstone
|
||||||
cp sys/denali/denali efi/sys/denali
|
cp ../sysroot/bin/denali efi/sys/denali
|
||||||
cp sys/victoriafalls/victoriafalls efi/sys/victoriafalls
|
cp sys/victoriafalls/victoriafalls efi/sys/victoriafalls
|
||||||
|
|
||||||
mkdir -p sysroot
|
mkdir -p sysroot
|
||||||
|
|
|
@ -23,7 +23,7 @@ for BIN in ${DIR}/../rust/usr/*/; do
|
||||||
done
|
done
|
||||||
|
|
||||||
for BIN in ${DIR}/../rust/sys/*/; do
|
for BIN in ${DIR}/../rust/sys/*/; do
|
||||||
cargo install --force --path "${BIN}" --root $CARGO_SYS_ROOT
|
cargo install --all-features --force --path "${BIN}" --root $CARGO_SYS_ROOT
|
||||||
done
|
done
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue