Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • K kernel
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 23
    • Issues 23
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • redox-osredox-os
  • kernel
  • Merge requests
  • !98

WIP: Make ACPI testable

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Julien Férard requested to merge jferard/kernel:clean_aml into master Dec 06, 2018
  • Overview 0
  • Commits 72
  • Pipelines 0
  • Changes 49

Note: I didn't find the "provided form" (14. in https://gitlab.redox-os.org/redox-os/redox/blob/master/CONTRIBUTING.md#creating-a-pr). I'll try to give as much information as I can

This is a work in progress. The main goal is to reduce coupling between ACPI and the rest of the kernel and to unit test ACPI.

But there are a lot of things in this MR on ACPI:

  • I added comments everywhere it was possible;
  • I used constants instead of magic numbers;
  • I moved, when possible, the switch out of parse functions: since we know the opcode in the main parse functions, we can decide which object we have to parse;
  • I put all connections between ACPI and the rest of the kernel in a trait KernelServiceForAcpi. The kernel implements this trait in arch.

I made a little script here to unit test ACPI. This script copies the acpi directory in a temp directory and creates a temp fake cargo project to run the tests.

jferard@jferard-Z170XP-SLI:~/prog/rust/perso-redox/work-in-progress$ python3 acpi-tester.py ~/prog/rust/redox/kernel/
.:
.:
Cargo.toml  src

...

Finished dev [unoptimized + debuginfo] target(s) in 4.16s
 Running target/debug/deps/acpi-0be920ff12be4550

running 16 tests
test acpi::aml::dataobj::tests::test_byte ... ok
test acpi::aml::pkglength::tests::test_pkg_length_bad_reserved ... ok
test acpi::aml::pkglength::tests::test_pkg_length_max_size ... ok
test acpi::aml::pkglength::tests::test_pkg_length_one_byte ... ok
test acpi::aml::termlist::tests::test_term_arg ... ok
test acpi::aml::tests::test_apic ... ok
test acpi::aml::pkglength::tests::test_pkg_length_two_bytes ... ok
test acpi::aml::type1opcode::tests::test_break ... ok
test acpi::aml::type1opcode::tests::test_continue ... ok
test acpi::aml::type1opcode::tests::test_fatal ... ok
test acpi::aml::type2opcode::tests::test_leftmost ... ok
test acpi::aml::type2opcode::tests::test_u64_from_bcd ... ok
test acpi::aml::type2opcode::tests::test_u64_to_bcd ... ok
test acpi::aml::namestring::tests::test_name_string ... ok
test acpi::aml::type2opcode::tests::test_rightmost ... ok
test acpi::aml::type1opcode::tests::test_if_else ... ok

test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Doc-tests acpi
error: no global memory allocator found but one is required; link to std or add #[global_allocator] to a static item that implements the GlobalAlloc trait.


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

But I think the AML parser is bugged because I couldn't parse the AML in the table /sys/firmware/acpi/tables/SSDT1 on my Linux/Ubuntu.

TODO:

  • add more unit tests for simple parse functions;
  • use a stream (= data + offset) instead of things like &data[2 + if_length + else_length_len..2 + if_length + else_length]
  • draw a distinction between parse and execute (runX = parseX + executeX), but keep the immediate execution of parsed instructions.
  • MAYBE: add debugging (this implies a 7th function in the interface). Goals: a verbose mode, a view of the AST, maybe a detection of endless loops. And finally make it parse whole tables!
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: clean_aml