#![cfg(target_arch = "aarch64")]
#[test]
fn test_psci_function_ranges() {
const PSCI_FN_RANGE_32_START: u64 = 0x8400_0000;
const PSCI_FN_RANGE_32_END: u64 = 0x8400_001F;
const PSCI_FN_RANGE_64_START: u64 = 0xC400_0000;
const PSCI_FN_RANGE_64_END: u64 = 0xC400_001F;
assert!(PSCI_FN_RANGE_32_START <= PSCI_FN_RANGE_32_END);
assert_eq!(PSCI_FN_RANGE_32_END - PSCI_FN_RANGE_32_START, 0x1F);
assert!(PSCI_FN_RANGE_64_START <= PSCI_FN_RANGE_64_END);
assert_eq!(PSCI_FN_RANGE_64_END - PSCI_FN_RANGE_64_START, 0x1F);
assert!(PSCI_FN_RANGE_32_END < PSCI_FN_RANGE_64_START);
}
#[test]
fn test_psci_function_offsets() {
const PSCI_FN_VERSION: u64 = 0x0;
const PSCI_FN_CPU_SUSPEND: u64 = 0x1;
const PSCI_FN_CPU_OFF: u64 = 0x2;
const PSCI_FN_CPU_ON: u64 = 0x3;
const PSCI_FN_MIGRATE: u64 = 0x5;
const PSCI_FN_SYSTEM_OFF: u64 = 0x8;
const PSCI_FN_SYSTEM_RESET: u64 = 0x9;
assert_eq!(PSCI_FN_VERSION, 0);
assert_eq!(PSCI_FN_CPU_SUSPEND, 1);
assert_eq!(PSCI_FN_CPU_OFF, 2);
assert_eq!(PSCI_FN_CPU_ON, 3);
assert_eq!(PSCI_FN_MIGRATE, 5);
assert_eq!(PSCI_FN_SYSTEM_OFF, 8);
assert_eq!(PSCI_FN_SYSTEM_RESET, 9);
}
#[test]
fn test_psci_function_number_construction() {
let psci_version_32: u64 = 0x8400_0000;
let psci_cpu_on_32: u64 = 0x8400_0003;
let psci_version_64: u64 = 0xC400_0000;
let psci_cpu_on_64: u64 = 0xC400_0003;
assert_eq!(psci_version_32 & 0xFF, 0);
assert_eq!(psci_cpu_on_32 & 0xFF, 3);
assert_eq!(psci_version_64 & 0xFF, 0);
assert_eq!(psci_cpu_on_64 & 0xFF, 3);
assert_eq!(psci_version_32 & 0x40000000, 0);
assert_eq!(psci_version_64 & 0x40000000, 0x40000000);
}