Skip to content

Commit 77039f2

Browse files
Sainath Grandhiwenlingz
authored andcommitted
acrn-config: Extend ve820 generation script for sizes gt 512 MB
Current ve820 generation script assumes the size of pre-launched VM memory is less than or equal to 512 MB (Must be the assumption of logical partition scenario as such). This patch extends the script to handle pre-launched VM memory sizes greater than 512 MB. Tracked-On: #4182 Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
1 parent 450d2cf commit 77039f2

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

misc/acrn-config/board_config/ve820_c.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import board_cfg_lib
88

99

10-
TOTAL_MEM_SIZE = 4 * 1024 * 1024 * 1024
10+
FOUR_GBYTE = 4 * 1024 * 1024 * 1024
1111
LOW_MEM_TO_PCI_HOLE = 0x20000000
1212

1313

@@ -22,18 +22,27 @@ def ve820_per_launch(config, hpa_size):
2222

2323
board_name = board_cfg_lib.undline_name(board_name)
2424

25+
high_mem_hpa_len = 0x0
2526
low_mem_to_pci_hole_len = '0xA0000000'
2627
low_mem_to_pci_hole = '0x20000000'
2728
pci_hole_addr = '0xe0000000'
2829
pci_hole_len = '0x20000000'
2930
start_low_hpa = 0x100000
30-
hpa_len = int(hpa_size, 16) - 1 * 1024 * 1024
31+
if (int(hpa_size, 16) <= 512 * 1024 * 1024):
32+
low_mem_hpa_len = int(hpa_size, 16) - 1 * 1024 * 1024
33+
else:
34+
low_mem_hpa_len = 511 * 1024 * 1024
35+
high_mem_hpa_len = int(hpa_size, 16) - 512 * 1024 * 1024
3136

3237
# pre_launch memroy: mem_size is the ve820 length
3338
print("#include <e820.h>", file=config)
3439
print("#include <vm.h>", file=config)
3540
print("", file=config)
36-
print("#define VE820_ENTRIES_{}\t{}U".format(board_name, 5), file=config)
41+
if (high_mem_hpa_len == 0):
42+
print("#define VE820_ENTRIES_{}\t{}U".format(board_name, 5), file=config)
43+
else:
44+
print("#define VE820_ENTRIES_{}\t{}U".format(board_name, 6), file=config)
45+
3746
print("static const struct e820_entry ve820_entry[{}] = {{".format(
3847
"VE820_ENTRIES_{}".format(board_name)), file=config)
3948
print("\t{\t/* usable RAM under 1MB */", file=config)
@@ -54,7 +63,7 @@ def ve820_per_launch(config, hpa_size):
5463
print("\t\t.baseaddr = {}UL,\t\t/* 1MB */".format(
5564
hex(start_low_hpa)), file=config)
5665
print("\t\t.length = {}UL,\t/* {}MB */".format(
57-
hex(hpa_len), hpa_len / 1024 / 1024), file=config)
66+
hex(low_mem_hpa_len), low_mem_hpa_len / 1024 / 1024), file=config)
5867

5968
print("\t\t.type = E820_TYPE_RAM", file=config)
6069
print("\t},", file=config)
@@ -68,14 +77,24 @@ def ve820_per_launch(config, hpa_size):
6877
print("\t\t.type = E820_TYPE_RESERVED", file=config)
6978
print("\t},", file=config)
7079
print("", file=config)
71-
print("\t{{\t/* between PCI hole and {}GB */".format(
72-
TOTAL_MEM_SIZE / 1024 / 1024 / 1024), file=config)
80+
print("\t{\t/* between PCI hole and 4 GB */", file=config)
7381
print("\t\t.baseaddr = {}UL,\t/* {}GB */".format(
7482
hex(int(pci_hole_addr, 16)), int(pci_hole_addr, 16) / 1024 / 1024 / 1024), file=config)
7583
print("\t\t.length = {}UL,\t/* {}MB */".format(
7684
hex(int(pci_hole_len, 16)), int(pci_hole_len, 16) / 1024 / 1024), file=config)
7785
print("\t\t.type = E820_TYPE_RESERVED", file=config)
7886
print("\t},", file=config)
87+
print("", file=config)
88+
if (high_mem_hpa_len != 0):
89+
print("\t{\t/* high mem after 4GB*/", file=config)
90+
print("\t\t.baseaddr = {}UL,\t/* 4 GB */".format(
91+
hex(FOUR_GBYTE)), file=config)
92+
print("\t\t.length = {}UL,\t/* {}MB */".format(
93+
hex(high_mem_hpa_len), high_mem_hpa_len / 1024 / 1024), file=config)
94+
print("\t\t.type = E820_TYPE_RAM", file=config)
95+
print("\t},", file=config)
96+
print("", file=config)
97+
7998
print("};", file=config)
8099
print("", file=config)
81100
print("/**", file=config)

0 commit comments

Comments
 (0)