Commit Graph

18 Commits

Author SHA1 Message Date
Kunhui-Li
e6d447e462 config_tools: update board_inspector to copy RTCT file
1. Remove acpi_template/ehl-crb-b/PTCT and acpi_template/tgl-rvp/PTCT files.
2. Update board_inspector/legacy/acpi.py script to copy RTCT file.

Tracked-On: #6238
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-07-02 13:42:06 +08:00
Kunhui Li
2ce0b38486 doc: update the content about generating board xml
Update the content about getting board xml from native
enviroment in acrn_configuration_tool.rst and README.

Tracked-On: #6134
Signed-off-by: Kunhui Li <kunhuix.li@intel.com>
2021-06-09 17:17:09 -04:00
Kunhui Li
ff2102a5c1 config_tools: replace illegal character with escaped character
For illegal characters, replace original characters with escaped characters in board.xml.

Tracked-On: #6113
Signed-off-by: Kunhui Li <kunhuix.li@intel.com>
2021-06-01 11:28:52 +08:00
Junjie Mao
99f15a27c2 board_inspector/acpiparser: enable parsing RTCT v2
This patch adds support to parse RTCT v2 using the refined board XML
schema. The major changes include:

 - Add the RTCT v2 parser in the acpiparser module. The version of an RTCT
   is detected automatically to choose the right parser.
 - Extract software SRAM capabilities of caches into the board XML.
 - Move the logic that determines the software SRAM base address for the
   pre-launched VM to the static allocator of GPAs.
 - Generate software SRAM related macros into misc_cfg.h when necessary.

Tracked-On: #6020
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-19 08:53:38 +08:00
Yonghua Huang
9facbb43b3 config-tool: rename PSRARM to SSRAM
'psram' and 'PSRAM' are legacy names and replaced
  with 'ssram' and 'SSRAM' respectively.

Tracked-On: #6012
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuang Zheng <shuang.zheng@intel.com>
2021-05-17 14:31:42 +08:00
Junjie Mao
0aa899271d board_inspector/extractors: extract device information
This patch extracts information on devices and put them under the
`/acrn-config/devices` node in the board XML.

The generated XML looks like the following:

  <devices>
    <bus type="system">
      <acpi_object>\_SB_</acpi_object>
      <bus id="PNP0A08" type="pci" address="0x0" description="...">
        <vendor>0x8086</vendor>
        <identifier>0x591f</identifier>
        <subsystem_vendor>0x1028</subsystem_vendor>
        <subsystem_identifier>0x07a1</subsystem_identifier>
        <class>0x060000</class>
        <acpi_object>\_SB_.PCI0</acpi_object>
        <resource type="bus_number" min="0x0" max="0x3e" len="0x3f"/>
        <resource type="io_port" min="0x0" max="0xcf7" len="0xcf8"/>
        <resource type="io_port" min="0xcf8" max="0xcf8" len="0x8"/>
        <resource type="io_port" min="0xd00" max="0xffff" len="0xf300"/>
        <resource type="memory" min="0x10000" max="0x1ffff" len="0x0"/>
        <resource type="memory" min="0xa0000" max="0xbffff" len="0x20000"/>
        <resource type="memory" min="0xc0000" max="0xc3fff" len="0x4000"/>
        <resource type="memory" min="0xc4000" max="0xc7fff" len="0x4000"/>
        ...
        <capability id="vendor_specific"/>
        <device address="0x1"> ... </device>
        ...
      <bus>
    <bus>
    <device> ... <device>
  <devices>

The hierarchy of devices are based on the hierarchy of device objects in
the ACPI namespace (which is established by interpreting the ACPI DSDT and
SSDT tables). Typically most device objects are under the predefined
`_SB_` (i.e. System Bus) object under which an object representing the PCI
root complex (`\_SB_.PCI0` in the example above) can be found. The PCI
devices attached to bus 0 are listed as children of the PCI root complex
node.

For each bus or device, the board inspector tries best to parse the
information from both ACPI device objects and PCI configuration space to
extract the following:

- the model (via `_HID` object and PCI vendor ID, device ID and class code),
- assigned resources (via `_CRS` object and PCI BARs),
- capabilities (via the PCI capability list)

v1 -> v2:
 - Fix references to undeclared modules or variables.
 - Make the ACPI extractor advanced and not enabled by default.
 - Extract the secondary I/O and memory-mapped I/O addresses of bridges.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
52ee5827e1 board_inspector/extractors: extract memory layout
This patch extracts information on mapping of available RAM and put them
under the `/acrn-config/memory` node in the board XML. Each range of
available RAM is represented by its start (host physical) address, end
address and size (in byte).

The following is an example of the generated XML.

  <memory>
    <range start="0x0000000000000000" end="0x0000000000057fff" size="360448"/>
    <range start="0x0000000000059000" end="0x000000000009dfff" size="282624"/>
    <range start="0x0000000000100000" end="0x00000000c9ff9fff"
    size="3387924480"/>
    <range start="0x00000000c9ffc000" end="0x00000000d984afff"
    size="260370432"/>
    <range start="0x00000000dbdff000" end="0x00000000dbdfffff" size="4096"/>
    <range start="0x0000000100000000" end="0x000000041dffffff"
    size="13388218368"/>
  </memory>

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
ffe213359c board_inspector/extractors: extract cache topology and capabilities
This patch extracts information on cache topology and capabilities and put
them under the `/acrn-config/caches` node in the board XML in the following
manner.

  <caches>
    <cache level="1" id="0x0" type="1">
      <cache_size>32768</cache_size>
      <line_size>64</line_size>
      <ways>8</ways>
      <sets>64</sets>
      <partitions>1</partitions>
      <self_initializing>1</self_initializing>
      <fully_associative>0</fully_associative>
      <write_back_invalidate>0</write_back_invalidate>
      <cache_inclusiveness>0</cache_inclusiveness>
      <complex_cache_indexing>0</complex_cache_indexing>
      <processors>
        <processor>0x0</processor>
        <processor>0x1</processor>
      </processors>
    </cache>
    <cache level="1" id="0x0" type="2"> ... </cache>
    <cache level="1" id="0x1" type="1"> ... </cache>
    <cache level="1" id="0x1" type="2"> ... </cache>
    ...
    <cache level="2" id="0x0" type="3"> ... </cache>
    <cache level="2" id="0x1" type="3"> ... </cache>
    ...
    <cache level="3" id="0x0" type="3"> ... </cache>
  </caches>

Each cache block is represented by a separate `cache` node identified by
its level, cache ID and type (as reported by CPUID). More information, such
as the size, characteristics and capabilities, are attached as children of
the node.

The current implementation fetches cache information solely from the CPUID
leaf 4H. In the future more cache-related information, such as those in the
ACPI RTCT tables, will be appended here.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
3e3120d342 board_inspector/extractors: extract CPU topology and models
This patch extracts information on CPU topology and capability and put them
under the `/acrn-config/processors` node in the board XML.

The added information can be divided into two categories.

1. The topology of CPUs like the following. Each thread (which is a leaf
   node in the topology) contains its addresses (i.e. CPU ID, APIC ID,
   x2APIC ID) and model identifiers (i.e. family, model, stepping IDs, core
   types and native model ID).

    <die id="0">
      <core id="0x0">
        <thread id="0x0">
          <cpu_id>0</cpu_id>
          <apic_id>0x0</apic_id>
          <x2apic_id>0x0</x2apic_id>
          <family_id>0x6</family_id>
          <model_id>0x9e</model_id>
          <stepping_id>0x9</stepping_id>
          <core_type></core_type>
          <native_model_id></native_model_id>
	</thread>
        <thread id="0x1"> ... </thread>
      </core>
      <core id="0x1">
        <thread id="0x2"> ... </thread>
        <thread id="0x3"> ... </thread>
      </core>
      <core id="0x2">
        <thread id="0x4"> ... </thread>
        <thread id="0x5"> ... </thread>
      </core>
      <core id="0x3">
        <thread id="0x6"> ... </thread>
        <thread id="0x7"> ... </thread>
      </core>
    </die>

2. The CPU models identified by the quadruple (family_id, model_id,
   core_type, native_model_id). Each model is described by its brandstring
   and capabilities, both of which are fetched from CPUID leaves.

    <model description="Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz">
      <family_id>0x6</family_id>
      <model_id>0x9e</model_id>
      <core_type></core_type>
      <native_model_id></native_model_id>
      <capability id="sse3"/>
      <capability id="pclmulqdq"/>
      <capability id="dtes64"/>
      <capability id="monitor"/>
      ...
    </model>

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
4d3a765708 board_inspector/extractors: framework to support extractors
This patch makes the `run.py` enumerate and invoke all extractors (whose
name should be `##-<name>.py` where `##` is a decimal number for ordering)
under the extractors/ directory. Only some helper subroutines are added in
this patch; the actual extractors will be added in the subsequent patches
in this series.

v1 -> v2:
 - Allow an extractor to be classified as advanced by defining the variable
   `advanced` to True. Advanced extractors are not enabled by default and
   can be invoked by passing `--advanced` to the board inspector.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
b3921137c2 board_inspector/smbiosparser: add SMBIOS table parsers
This patch adds a parser of SMBIOS tables. The tables are fetched from
/sys/firmware/dmi/tables on target board. The parser comes from
BITS (https://biosbits.org/) without modifications, except how the raw
SMBIOS tables are read.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
3a395bb342 board_inspector/pcieparser: add PCIe config space parser
This patch adds a parser of PCI-compatible configuration space read from
sysfs. The headers and capability lists are fully parsed, but only a couple
of capabilities are parsed completely. Parsing of additional capabilities
will be added on an on-demand basis.

v1 -> v2:
 - Fix a typo that causes incorrect parsing of BAR types
 - Parse capability structures using from_buffer_copy instead of
   from_address

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
0215603812 board_inspector/acpiparser: add DSDT/SSDT parser
This patch adds a parser and interpreter of ACPI DSDT/SSDT tables in
AML (ACPI Machine Language) in order to understand the complete device
layout and resource allocation.

Kindly note that the interpreter is still experimental and not yet
complete.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
6276e5759a board_inspector/memmapparser: add parser of e820 memory maps
This patch adds a parser of the physical E820 memory maps fetched from
/sys/firmware/memmap.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
598be99dc2 board_inspector/cpuparser: add CPUID parsers
This patch adds a parser of CPU identification information reported by the
CPUID instruction.

The framework is based on the CPUID parsing facilities in
BITS (https://biosbits.org/), but with the following changes.

1. The CPUID data is fetched by executing the `cpuid` utility, rather than
   executing the `cpuid` instruction. This avoids introducing any
   additional library or Python/C extension and gets a CPUID leaf on all
   physical cores in one shot.

2. Parsers of CPUID leaves 0x10, 0x1A and 0x1F are added. New fields in
   existing leaves are also added.

3. A wrapper function, named `parse_cpuid`, is added as the single API that
   allows other modules to get an arbitrary CPUID leaf or subleaf.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
05c738a480 board_inspector/lib: fix compatibility issues in unpack.py
Starting from Python 3.0 the following changes to the language are
effective:

1. The integer types `int` and `long` have been unified as `int`. See
   `https://www.python.org/dev/peps/pep-0237/` for details.
2. The `.iterkeys` method is removed from the `dict` class. See
   `https://www.python.org/dev/peps/pep-3106/` for details.

This patch updates `unpack.py`, originally from BITS, so that it can be
used in Python 3.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
e6e61a4979 board_inspector/legacy: fix a copy destination error
Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00
Junjie Mao
bd4ddbd31d board-inspector: reorganize the scripts
This patch reorganize the files of the board inspector as follows.

1. Rename the directory name from `target` to `board_inspector`, in order to
   align with the name used in ACRN documentation.
2. Move the scripts that generate the current board XML into the `legacy`
   sub-directory. The legacy nodes will be removed after transitioning to the
   new board XML schema completely,
3. Add the main script `cli.py` which is the command line interface of the board
   inspector.

v1 -> v2:
 - Rename `run.py` to `cli.py`.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-16 19:02:00 +08:00