.githooks/
compiler/
kernel/
lib/
scripts/
seed/
sublime/
test/
boot/
bootstrap/
compiler/
cycles/
dispatch/
format/
host/
integration/
kernel/
loader/
manifests/
mmio/
kernel/
cases.rad
1.1 KiB
machine.ras
683 B
spin.rad
2.0 KiB
native/
packages/
runtime/
scheduling/
shared/
slots/
smp/
std/
sync/
termination/
tests/
trap/
verify/
Makefile
9.2 KiB
kernel.rad
776 B
runner.rad
11.6 KiB
vim/
.gitignore
333 B
.gitsigners
224 B
AGENTS.md
8.3 KiB
CONTRIBUTING
2.1 KiB
LICENSE
1.1 KiB
Makefile
2.5 KiB
README
3.4 KiB
STYLE
3.2 KiB
std.lib
2.1 KiB
std.lib.test
1.1 KiB
test/mmio/spin.rad
raw
| 1 | //! User-mode register widths and rejected MMIO authority. |
| 2 | export mod cases; |
| 3 | export mod abi; |
| 4 | export mod sys; |
| 5 | export mod mmio; |
| 6 | |
| 7 | /// Execute each width, or require a kernel fault before an unauthorized access. |
| 8 | @default fn main(env: *abi::Env) { |
| 9 | // The arguments Page holds the device handle under test, the read-only |
| 10 | // machine timer handle, and the number of the test case, all installed by |
| 11 | // the test parent. |
| 12 | let words = try! sys::pageWords(abi::Handle(env.args)); |
| 13 | let device = abi::Handle(words[0]); |
| 14 | let clock = abi::Handle(words[1]); |
| 15 | let scenario = words[2]; |
| 16 | if scenario == cases::Scenario::Widths as u64 { |
| 17 | let before = mmio::read64(clock, 0); |
| 18 | mmio::write8(device, 0, 0x81); |
| 19 | mmio::write16(device, 2, 0x8123); |
| 20 | mmio::write32(device, 4, 0x81234567); |
| 21 | mmio::write64(device, 8, 0x8123456789abcdef); |
| 22 | assert mmio::read8(device, 0) == 0x81; |
| 23 | assert mmio::read16(device, 2) == 0x8123; |
| 24 | assert mmio::read32(device, 4) == 0x81234567; |
| 25 | assert mmio::read64(device, 8) == 0x8123456789abcdef; |
| 26 | assert mmio::read32(clock, 0) as u64 >= before; |
| 27 | sys::exit(cases::EXIT_STATUS); |
| 28 | } |
| 29 | if scenario == cases::Scenario::MissingHandle as u64 |
| 30 | or scenario == cases::Scenario::ReadOnly as u64 |
| 31 | { |
| 32 | mmio::write32(device, 0, cases::FINISH_VALUE); |
| 33 | } |
| 34 | if scenario == cases::Scenario::WriteOnly as u64 { |
| 35 | let value = mmio::read8(device, 0); |
| 36 | } |
| 37 | if scenario == cases::Scenario::Misaligned as u64 { |
| 38 | mmio::write32(device, 1, 1); |
| 39 | } |
| 40 | if scenario == cases::Scenario::OutOfBounds as u64 { |
| 41 | let value = mmio::read8(device, cases::REGION_SIZE); |
| 42 | } |
| 43 | if scenario == cases::Scenario::DroppedHandle as u64 { |
| 44 | try! sys::capabilityDrop(device); |
| 45 | mmio::write32(device, 0, cases::FINISH_VALUE); |
| 46 | } |
| 47 | if scenario == cases::Scenario::WrongKind as u64 { |
| 48 | let value = mmio::read8(device, 0); |
| 49 | } |
| 50 | if scenario == cases::Scenario::AddressOverflow as u64 { |
| 51 | mmio::write64(device, 0xfffffffffffffff8, 1); |
| 52 | } |
| 53 | sys::exit(99); |
| 54 | } |