inmates: Factor our interrupt library services

This simplifies registering interrupt handlers and also moves the EOI
ACK into library code. Only 64-bit support so far. Still, we need to fix
the definition of s64/u64 and make read/write_msr compatible with 32-bit
builds.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Factor out timing services

Move the APIC timer services together with PM timer access into a timing
library module.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Truly terminate apic-demo on second attempt

More consistent demo: Reject the first shutdown request and keep running
until the second arrives. Then terminate directly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Add memory services to inmates framework

This adds a primitive memory allocator (without release) and a page
mapper (without unmap) to the inmates library. MMIO accessors are also
included. Those used for intercepted resources are encoded in assembly
to ensure that only supported instructions are used. With these
services, inmates can now access memory-mapped devices.

The allocator uses the lower memory starting from the first page.
Document this as well as the remaining memory layout.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Provide missing PIO accessors

Add inw, outw and outl.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Add IOAPIC service to inmates framework

This provides the functionality for programing an assigned IOAPIC pin to
send standard IRQs to the caller's CPU. Just enough for basic IOAPIC
usage.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Add IOAPIC demo

Simply demonstration and test for using the IOAPIC within an non-root
cell: Rob the ACPI IRQ and wait for events on this line, e.g. a power
button push. Read the warning before using it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Halt on return from inmate_main

Remove the need for explicit clt;hlt from the inmates, moving this to
header code.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Add primitive 32-bit demo

This only demonstrates the capability to build inmates which come up in
32-bit mode. Note that not all library services support this already.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Add PCI services to inmates framework

Provide library services for PCI config space access, bus scanning,
capability scanning (non-extended only so far) and MSI vector
programming (MSI-X to be added later).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Add PCI demo using an Intel HDA

This demonstrates the setup of a PCI device including MSI.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>