[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v3 12/13] hw/acpi/aml-build: Build ACPI cpu cache hierarchy i
From: |
Ying Fang |
Subject: |
[RFC PATCH v3 12/13] hw/acpi/aml-build: Build ACPI cpu cache hierarchy information |
Date: |
Mon, 9 Nov 2020 11:04:51 +0800 |
To build cache information, An AcpiCacheInfo structure is defined to
hold the type 1 cache structure according to ACPI spec v6.3 5.2.29.2.
A helper function build_cache_hierarchy is also introduced to encode
the cache information.
Signed-off-by: Ying Fang <fangying1@huawei.com>
---
hw/acpi/aml-build.c | 26 ++++++++++++++++++++++++++
include/hw/acpi/acpi-defs.h | 8 ++++++++
include/hw/acpi/aml-build.h | 3 +++
3 files changed, 37 insertions(+)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index d1aa9fd716..1a38110149 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1770,6 +1770,32 @@ void build_slit(GArray *table_data, BIOSLinker *linker,
MachineState *ms)
table_data->len - slit_start, 1, NULL, NULL);
}
+/* ACPI 6.3: 5.29.2 Cache type structure (Type 1) */
+static void build_cache_head(GArray *tbl, uint32_t next_level)
+{
+ build_append_byte(tbl, 1);
+ build_append_byte(tbl, 24);
+ build_append_int_noprefix(tbl, 0, 2);
+ build_append_int_noprefix(tbl, 0x7f, 4);
+ build_append_int_noprefix(tbl, next_level, 4);
+}
+
+static void build_cache_tail(GArray *tbl, AcpiCacheInfo *cache_info)
+{
+ build_append_int_noprefix(tbl, cache_info->size, 4);
+ build_append_int_noprefix(tbl, cache_info->sets, 4);
+ build_append_byte(tbl, cache_info->associativity);
+ build_append_byte(tbl, cache_info->attributes);
+ build_append_int_noprefix(tbl, cache_info->line_size, 2);
+}
+
+void build_cache_hierarchy(GArray *tbl,
+ uint32_t next_level, AcpiCacheInfo *cache_info)
+{
+ build_cache_head(tbl, next_level);
+ build_cache_tail(tbl, cache_info);
+}
+
/*
* ACPI 6.3: 5.2.29.1 Processor hierarchy node structure (Type 0)
*/
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index 38a42f409a..3df38ab449 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -618,4 +618,12 @@ struct AcpiIortRC {
} QEMU_PACKED;
typedef struct AcpiIortRC AcpiIortRC;
+typedef struct AcpiCacheInfo {
+ uint32_t size;
+ uint32_t sets;
+ uint8_t associativity;
+ uint8_t attributes;
+ uint16_t line_size;
+} AcpiCacheInfo;
+
#endif
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 56474835a7..01078753a8 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -437,6 +437,9 @@ void build_srat_memory(AcpiSratMemoryAffinity *numamem,
uint64_t base,
void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms);
+void build_cache_hierarchy(GArray *tbl,
+ uint32_t next_level, AcpiCacheInfo *cache_info);
+
void build_socket_hierarchy(GArray *tbl, uint32_t parent, uint32_t id);
void build_processor_hierarchy(GArray *tbl, uint32_t flags,
--
2.23.0
- [RFC PATCH v3 00/13] hw/arm/virt: Introduce cpu and cache topology support, Ying Fang, 2020/11/08
- [RFC PATCH v3 06/13] hw/arm/virt: DT: add cpu-map, Ying Fang, 2020/11/08
- [RFC PATCH v3 12/13] hw/acpi/aml-build: Build ACPI cpu cache hierarchy information,
Ying Fang <=
- [RFC PATCH v3 08/13] hw/acpi/aml-build: add processor hierarchy node structure, Ying Fang, 2020/11/08
- [RFC PATCH v3 04/13] device_tree: Add qemu_fdt_add_path, Ying Fang, 2020/11/08
- [RFC PATCH v3 13/13] hw/arm/virt-acpi-build: Enable cpu and cache topology, Ying Fang, 2020/11/08
- [RFC PATCH v3 02/13] hw/arm/virt: Remove unused variable, Ying Fang, 2020/11/08
- [RFC PATCH v3 11/13] hw/arm/virt: add fdt cache information, Ying Fang, 2020/11/08
- [RFC PATCH v3 03/13] hw/arm/virt: Replace smp_parse with one that prefers cores, Ying Fang, 2020/11/08