Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
fruhland committed Oct 11, 2024
1 parent b982a60 commit e4d201e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 56 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,5 @@
on: [push]
jobs:
test:
# Make sure that everything works on the newest Ubuntu.
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
shared-key: cargo-${{ hashFiles('**/Cargo.lock') }}
cache-all-crates: true
cache-on-failure: true
- name: Install qemu
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
- name: Run tests
uses: clechasseur/rs-cargo@v2
with:
command: test
args: --package tests
build:
# Applications linked against glibc only work on that version of glibc
# (or newer ones), so this is effectively the oldest version the release
Expand All @@ -35,7 +9,6 @@ jobs:
# but Ubuntu 20.04 has OpenSSL 1.1 which newer ones don't have, so we need
# to go with at least 22.04.
runs-on: ubuntu-22.04
needs: test
steps:
- uses: actions/checkout@v4
- name: Install Rust
Expand Down Expand Up @@ -98,7 +71,6 @@ jobs:
# Downloading them requires logging in with an Apple ID,
# which is not possible in the CI. The macOS runners include it.
runs-on: macos-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Install Rust for x86_64-apple and aarch64-apple
Expand Down
80 changes: 54 additions & 26 deletions towboot/src/boot/config_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::collections::BTreeSet;
use alloc::slice;
use alloc::vec::Vec;

use log::{debug, warn};
use log::{debug, info, warn};
use multiboot12::information::InfoBuilder;
use acpi::rsdp::Rsdp;
use smbioslib::{SMBiosEntryPoint32, SMBiosEntryPoint64};
Expand Down Expand Up @@ -39,43 +39,71 @@ pub(super) fn parse_for_multiboot(info_builder: &mut InfoBuilder) {

handled_guids.insert(table.guid);
match table.guid {
ACPI_GUID => handle_acpi(&table, info_builder),
ACPI2_GUID => handle_acpi(&table, info_builder),
DEBUG_IMAGE_INFO_GUID => debug!("ignoring image debug info"),
DXE_SERVICES_GUID => debug!("ignoring dxe services table"),
HAND_OFF_BLOCK_LIST_GUID => debug!("ignoring hand-off block list"),
LZMA_COMPRESS_GUID => debug!("ignoring lzma filesystem"),
MEMORY_STATUS_CODE_RECORD_GUID => debug!("ignoring early memory info"),
MEMORY_TYPE_INFORMATION_GUID => debug!("ignoring early memory info"),
SMBIOS_GUID => handle_smbios(&table, info_builder),
SMBIOS3_GUID => handle_smbios(&table, info_builder),
guid => debug!("ignoring table {guid}"),
ACPI_GUID => {
info!("ACPI {}", table.guid);
handle_acpi(&table, info_builder)
},
ACPI2_GUID => {
info!("ACPIv2 {}", table.guid);
handle_acpi2(&table, info_builder)
},
DEBUG_IMAGE_INFO_GUID => info!("ignoring image debug info {}", table.guid),
DXE_SERVICES_GUID => info!("ignoring dxe services table {}", table.guid),
HAND_OFF_BLOCK_LIST_GUID => info!("ignoring hand-off block list {}", table.guid),
LZMA_COMPRESS_GUID => info!("ignoring lzma filesystem {}", table.guid),
MEMORY_STATUS_CODE_RECORD_GUID => info!("ignoring early memory info {}", table.guid),
MEMORY_TYPE_INFORMATION_GUID => info!("ignoring early memory info {}", table.guid),
SMBIOS_GUID => {
info!("SMBIOS {}", table.guid);
handle_smbios(&table, info_builder)
},
SMBIOS3_GUID => {
info!("SMBIOSv3 {}", table.guid);
handle_smbios(&table, info_builder)
},
guid => info!("ignoring table {guid}"),
}
}
}

/// Parse the ACPI RSDP and create the Multiboot struct for it.
fn handle_acpi(table: &ConfigTableEntry, info_builder: &mut InfoBuilder) {
debug!("handling ACPI RSDP");
debug!("handling ACPI RSDP version 1");
let rsdp = unsafe { *(table.address as *const Rsdp) };
if rsdp.validate().is_err() {
warn!("the RSDP is invalid");
return;
}
if rsdp.revision() != 0 {
warn!("invalid RSDP revision (expected: 0, got: {})", rsdp.revision());
return;
}

info_builder.set_rsdp_v1(
rsdp.signature(), rsdp.checksum(),
rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(),
rsdp.revision(), rsdp.rsdt_address(),
);
}

/// Parse the ACPI RSDP and create the Multiboot struct for it.
fn handle_acpi2(table: &ConfigTableEntry, info_builder: &mut InfoBuilder) {
debug!("handling ACPI RSDP version 2");
let rsdp = unsafe { *(table.address as *const Rsdp) };
if rsdp.validate().is_err() {
warn!("the RSDP is invalid");
return;
}
if rsdp.revision() == 0 {
info_builder.set_rsdp_v1(
rsdp.signature(), rsdp.checksum(),
rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(),
rsdp.revision(), rsdp.rsdt_address(),
);
} else {
info_builder.set_rsdp_v2(
rsdp.signature(), rsdp.checksum(),
rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(),
rsdp.revision(), rsdp.rsdt_address(), rsdp.length(),
rsdp.xsdt_address(), rsdp.ext_checksum(),
);
warn!("invalid RSDP revision (expected: >0, got: {})", rsdp.revision());
return;
}

info_builder.set_rsdp_v2(
rsdp.signature(), rsdp.checksum(),
rsdp.oem_id().as_bytes()[0..6].try_into().unwrap(),
rsdp.revision(), rsdp.rsdt_address(), rsdp.length(),
rsdp.xsdt_address(), rsdp.ext_checksum(),
);
}

/// The entry point for SMBIOS.
Expand Down
6 changes: 4 additions & 2 deletions towboot/src/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,15 @@ impl EntryPoint {
/// Jump to the loaded kernel.
/// This requires everything else to be ready and won't return.
fn jump(self, signature: u32, info: Vec<u8>) -> ! {

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build

unused variable: `signature`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build

unused variable: `info`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build

unused variable: `signature`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build

unused variable: `info`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build

unused variable: `signature`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build

unused variable: `info`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build

unused variable: `signature`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build

unused variable: `info`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build-mac

unused variable: `signature`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build-mac

unused variable: `info`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build-mac

unused variable: `signature`

Check warning on line 436 in towboot/src/boot/mod.rs

View workflow job for this annotation

GitHub Actions / build-mac

unused variable: `info`
if let Self::Uefi(entry_address) = self {
loop {}

/*if let Self::Uefi(entry_address) = self {
self.jump_uefi(entry_address, signature, info)
} else if let Self::Multiboot(entry_address) = self {
self.jump_multiboot(entry_address, signature, info)
} else {
panic!("invalid entry point")
}
}*/
}

/// Jump to the loaded kernel, UEFI-style, eg. just passing the information.
Expand Down

0 comments on commit e4d201e

Please sign in to comment.