acrn-hypervisor/devicemodel/include
Zhi Jin 02f0ecddc1 DM: implement emulated npk pci device
The Intel Trace Hub (aka. North Peak, NPK) is a trace aggregator for
Software, Firmware, and Hardware. On the virtualization platform, it
can be used to output the traces from SOS/UOS/Hypervisor/FW together
with unified timestamps.

There are 2 software visible MMIO space in the npk pci device. One is
the CSR which maps the configuration registers, and the other is the
STMR which is organized as many Masters, and used to send the traces.
Each Master has a fixed number of Channels, which is 128 on GP. Each
channel occupies 64B, so the offset of each Master is 8K (64B*128).
Here is the detailed layout of STMR:
                         M=NPK_SW_MSTR_STP (1024 on GP)
                       +-------------------+
                       |    m[M],c[C-1]    |
          Base(M,C-1)  +-------------------+
                       |        ...        |
                       +-------------------+
                       |     m[M],c[0]     |
            Base(M,0)  +-------------------+
                       |        ...        |
                       +-------------------+
                       |    m[i+1],c[1]    |
          Base(i+1,1)  +-------------------+
                       |    m[i+1],c[0]    |
          Base(i+1,0)  +-------------------+
                       |        ...        |
                       +-------------------+
                       |     m[i],c[1]     |
Base(i,1)=SW_BAR+0x40  +-------------------+
                       |     m[i],c[0]     |  64B
     Base(i,0)=SW_BAR  +-------------------+
                        i=NPK_SW_MSTR_STRT (256 on GP)

CSR and STMR are treated differently in npk virtualization because:
1. CSR configuration should come from just one OS, instead of each OS.
In our case, it should come from SOS.
2. For performance and timing concern, the traces from each OS should
be written to STMR directly.

Based on these, the npk virtualization is implemented in this way:
1. The physical CSR is owned by SOS, and dm/npk emulates a software
one for the UOS, to keep the npk driver on UOS unchanged. Some CSR
initial values are configured to make the UOS npk driver think it
is working on a real npk. The CSR configuration from UOS is ignored
by dm, and it will not bring any side-effect. Because traces are the
only things needed from UOS, the location to send traces to and the
trace format are not affected by the CSR configuration.
2. Part of the physical STMR will be reserved for the SOS, and the
others will be passed through to the UOS, so that the UOS can write
the traces to the MMIO space directly.

A parameter is needed to indicate the offset and size of the Masters
to pass through to the UOS. For example, "-s 0:2,npk,512/256", there
are 256 Masters from #768 (256+512, #256 is the starting Master for
software tracing) passed through to the UOS.

            CSR                       STMR
SOS:  +--------------+  +----------------------------------+
      | physical CSR |  | Reserved for SOS |               |
      +--------------+  +----------------------------------+
UOS:  +--------------+                     +---------------+
      | sw CSR by dm |                     | mapped to UOS |
      +--------------+                     +---------------+

Here is an overall flow about how it works.
1. System boots up, and the npk driver on SOS is loaded.
2. The dm is launched with parameters to enable npk virtualization.
3. The dm/npk sets up a bar for CSR, and some values are initialized
based on the parameters, for example, the total number of Masters for
the UOS.
4. The dm/npk sets up a bar for STMR, and maps part of the physical
STMR to it with an offset, according to the parameters.
5. The UOS boots up, and the native npk driver on the UOS is loaded.
6. Enable the traces from UOS, and the traces are written directly to
STMR, but not output by npk for now.
7. Enable the npk output on SOS, and now the traces are output by npk
to the selected target.
8. If the memory is the selected target, the traces can be retrieved
from memory on SOS, after stopping the traces.

Signed-off-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: Zhang Di <di.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-06-07 16:11:49 +08:00
..
public license: Replace license text with SPDX tag 2018-06-01 10:43:06 +08:00
acpi.h DM: build UOS DSDT with vcpu px state data 2018-05-15 17:25:25 +08:00
ahci.h initial import 2018-05-11 14:44:28 +08:00
ata.h initial import 2018-05-11 14:44:28 +08:00
atkbdc.h DM: add deinit function to virtual keyboard device 2018-05-15 17:25:24 +08:00
block_if.h initial import 2018-05-11 14:44:28 +08:00
console.h DM: add deinit function for ps2kbd and ps2mouse 2018-05-15 17:25:24 +08:00
cpuset.h initial import 2018-05-11 14:44:28 +08:00
dm.h DM: Add option of no check against ptdev reset 2018-05-29 13:44:13 +08:00
gc.h initial import 2018-05-11 14:44:28 +08:00
heci.h license: Replace license text with SPDX tag 2018-06-01 10:43:06 +08:00
inout.h DM: add deinit function for bvmcons 2018-05-15 17:25:55 +08:00
ioapic.h DM: increase vioapic pin count 2018-05-16 15:09:48 +08:00
ioc.h license: Replace license text with SPDX tag 2018-06-01 10:43:06 +08:00
iodev.h initial import 2018-05-11 14:44:28 +08:00
irq.h initial import 2018-05-11 14:44:28 +08:00
lpc.h initial import 2018-05-11 14:44:28 +08:00
macros.h license: Replace license text with SPDX tag 2018-06-01 10:43:06 +08:00
mc146818rtc.h initial import 2018-05-11 14:44:28 +08:00
mem.h DM: release mem range allocated in init_pci 2018-05-15 17:25:55 +08:00
mevent.h DM: add init/deinit function for mevent 2018-05-15 17:25:27 +08:00
monitor.h license: Replace license text with SPDX tag 2018-06-01 10:43:06 +08:00
mptable.h initial import 2018-05-11 14:44:28 +08:00
mptbl.h initial import 2018-05-11 14:44:28 +08:00
netmap.h initial import 2018-05-11 14:44:28 +08:00
netmap_user.h initial import 2018-05-11 14:44:28 +08:00
npk.h DM: implement emulated npk pci device 2018-06-07 16:11:49 +08:00
ns16550.h initial import 2018-05-11 14:44:28 +08:00
pci_core.h dm: add pci_emul_find_capability 2018-05-31 11:25:15 +08:00
pciio.h initial import 2018-05-11 14:44:28 +08:00
pcireg.h initial import 2018-05-11 14:44:28 +08:00
ps2kbd.h DM: add deinit function for ps2kbd and ps2mouse 2018-05-15 17:25:24 +08:00
ps2mouse.h DM: add deinit function for ps2kbd and ps2mouse 2018-05-15 17:25:24 +08:00
rpmb.h DM: Add simulated RPMB support 2018-05-25 10:45:24 +08:00
rpmb_backend.h DM: RPMB virtualization 2018-05-25 10:45:24 +08:00
rpmb_sim.h DM: Add simulated RPMB support 2018-05-25 10:45:24 +08:00
rtc.h DM: vrtc code cleanup 2018-05-15 17:25:57 +08:00
segments.h initial import 2018-05-11 14:44:28 +08:00
smbiostbl.h initial import 2018-05-11 14:44:28 +08:00
specialreg.h initial import 2018-05-11 14:44:28 +08:00
sw_load.h DM: add add_e820_entry to update e820 table. 2018-05-15 17:25:26 +08:00
tree.h initial import 2018-05-11 14:44:28 +08:00
types.h initial import 2018-05-11 14:44:28 +08:00
uart_core.h DM: cleanup resource for uart. 2018-05-15 17:25:55 +08:00
usb.h DM USB: move the UREQ macro into common header 2018-05-29 10:35:05 +08:00
usb_core.h DM USB: xHCI: add log level switch 2018-05-29 10:35:05 +08:00
usb_pmapper.h license: more spdx license tag updates 2018-06-04 14:29:45 +08:00
usbdi.h initial import 2018-05-11 14:44:28 +08:00
vbs_common_if.h license: Replace license text with SPDX tag 2018-06-01 10:43:06 +08:00
virtio.h doc: fix doxygen comments in virtio.h 2018-06-01 13:16:58 +08:00
virtio_kernel.h license: Replace license text with SPDX tag 2018-06-01 10:43:06 +08:00
vmm.h initial import 2018-05-11 14:44:28 +08:00
vmmapi.h DM: increase vioapic pin count 2018-05-16 15:09:48 +08:00
vrpmb.h DM: Generate vRPMB key when creating UOS 2018-05-25 10:45:24 +08:00
xhci.h DM USB: xHCI: Support APL extended capability for DRD. 2018-05-31 11:26:38 +08:00
xhcireg.h DM USB: xHCI: Support APL extended capability for DRD. 2018-05-31 11:26:38 +08:00