r1mikey / illumos-gate

An open-source Unix operating system
https://illumos.org
2 stars 0 forks source link

Loaders should abstract the arch_timer frequency #1

Open r1mikey opened 2 weeks ago

r1mikey commented 2 weeks ago

The Arm documentation makes three statements about _cntfrqel0:

  1. This register is provided so that software can discover the frequency of the system counter.
  2. It must be programmed with this value as part of system initialization.
  3. The value of the register is not interpreted by hardware.

This register is documented as being conditionally writable, so it's complicated.

if IsHighestEL(PSTATE.EL) then
    CNTFRQ_EL0 = X[t, 64];
else
    UNDEFINED;

Since inetboot is our only loader that can be directly executed (in the qemu boot case for FDT systems), it is also the only loader that can take any meaningful action, but the ACPI loader should set up the system to look the same to unix for the sake of simplicity.

In the inetboot case:

In the ACPI/UEFI case:

Effectively, we replace any firmware-lookup interface with inspection of _xbootinfo and maintain the (now unnecessary) fallback to _cntfrqel0.

r1mikey commented 1 day ago

Fix up usr/src/uts/armv8/os/arch_timer.c - timer_freq needs to be renamed and made visible, then set very early. Maybe use an accessor function.