Skip to content

Commit a91118e

Browse files
jsun26inteljren1
authored andcommitted
DM: build UOS DSDT with vcpu px state data
With the DSDT which include virtual _PSS/_PCT/_PPC objects, UOS should have ACPI Px control capability if acpi cpufreq driver is enalbed in kernel. Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Kevin Tian <kevin.tian@intel.com>
1 parent e96fe06 commit a91118e

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

devicemodel/hw/acpi/acpi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,9 @@ basl_fwrite_dsdt(FILE *fp, struct vmctx *ctx)
764764
dsdt_line(" })");
765765
dsdt_line(" }");
766766
dsdt_line(" }");
767+
768+
pm_write_dsdt(ctx, basl_ncpu);
769+
767770
dsdt_line("}");
768771

769772
if (dsdt_error != 0)

devicemodel/hw/acpi/acpi_pm.c

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ static int get_vcpu_px_data(struct vmctx *ctx, int vcpu_id,
8686
/* _PPC: Performance Present Capabilities
8787
* hard code _PPC to 0, all states are available.
8888
*/
89-
void dsdt_write_ppc(void)
89+
static void dsdt_write_ppc(void)
9090
{
9191
dsdt_line(" Name (_PPC, Zero)");
9292
}
9393

9494
/* _PCT: Performance Control
9595
* Both Performance Control and Status Register are set to FFixedHW
9696
*/
97-
void dsdt_write_pct(void)
97+
static void dsdt_write_pct(void)
9898
{
9999
dsdt_line(" Method (_PCT, 0, NotSerialized)");
100100
dsdt_line(" {");
@@ -124,7 +124,7 @@ void dsdt_write_pct(void)
124124

125125
/* _PSS: Performance Supported States
126126
*/
127-
void dsdt_write_pss(struct vmctx *ctx, int vcpu_id)
127+
static void dsdt_write_pss(struct vmctx *ctx, int vcpu_id)
128128
{
129129
uint8_t vcpu_px_cnt;
130130
struct cpu_px_data *vcpu_px_data;
@@ -183,3 +183,45 @@ void dsdt_write_pss(struct vmctx *ctx, int vcpu_id)
183183
free(vcpu_px_data);
184184

185185
}
186+
187+
void pm_write_dsdt(struct vmctx *ctx, int ncpu)
188+
{
189+
/* Scope (_PR) */
190+
dsdt_line("");
191+
dsdt_line(" Scope (_PR)");
192+
dsdt_line(" {");
193+
for (int i = 0; i < ncpu; i++) {
194+
dsdt_line(" Processor (CPU%d, 0x%02X, 0x00000000, 0x00) {}",
195+
i, i);
196+
}
197+
dsdt_line(" }");
198+
dsdt_line("");
199+
200+
/* Scope (_PR.CPU(N)) */
201+
for (int i = 0; i < ncpu; i++) {
202+
dsdt_line(" Scope (_PR.CPU%d)", i);
203+
dsdt_line(" {");
204+
dsdt_line("");
205+
206+
dsdt_write_pss(ctx, i);
207+
208+
/* hard code _PPC and _PCT for all vpu */
209+
if (i == 0) {
210+
dsdt_write_ppc();
211+
dsdt_write_pct();
212+
} else {
213+
dsdt_line(" Method (_PPC, 0, NotSerialized)");
214+
dsdt_line(" {");
215+
dsdt_line(" Return (^^CPU0._PPC)");
216+
dsdt_line(" }");
217+
dsdt_line("");
218+
dsdt_line(" Method (_PCT, 0, NotSerialized)");
219+
dsdt_line(" {");
220+
dsdt_line(" Return (^^CPU0._PCT)");
221+
dsdt_line(" }");
222+
dsdt_line("");
223+
}
224+
225+
dsdt_line(" }");
226+
}
227+
}

devicemodel/include/acpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ void dsdt_fixed_mem32(uint32_t base, uint32_t length);
5757
void dsdt_indent(int levels);
5858
void dsdt_unindent(int levels);
5959
void sci_init(struct vmctx *ctx);
60+
void pm_write_dsdt(struct vmctx *ctx, int ncpu);
6061

6162
#endif /* _ACPI_H_ */

0 commit comments

Comments
 (0)