DM Cx: add function to get cx cnt and cx data

DM will use these functions to get cx entry cnt and cx data then inject
_CST objects to UOS DSDT table.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
This commit is contained in:
Victor Sun
2018-04-18 16:14:02 +08:00
committed by Jack Ren
parent bdd90e6597
commit a042538565
2 changed files with 61 additions and 2 deletions

View File

@@ -59,6 +59,17 @@ static inline uint8_t get_vcpu_px_cnt(struct vmctx *ctx, int vcpu_id)
return (uint8_t)px_cnt;
}
uint8_t get_vcpu_cx_cnt(struct vmctx *ctx, int vcpu_id)
{
uint64_t cx_cnt;
if (get_vcpu_pm_info(ctx, vcpu_id, PMCMD_GET_CX_CNT, &cx_cnt)) {
return 0;
}
return (uint8_t)cx_cnt;
}
static int get_vcpu_px_data(struct vmctx *ctx, int vcpu_id,
int px_num, struct cpu_px_data *vcpu_px_data)
{
@@ -88,6 +99,35 @@ static int get_vcpu_px_data(struct vmctx *ctx, int vcpu_id,
return 0;
}
int get_vcpu_cx_data(struct vmctx *ctx, int vcpu_id,
int cx_num, struct cpu_cx_data *vcpu_cx_data)
{
uint64_t *pm_ioctl_buf;
enum pm_cmd_type cmd_type = PMCMD_GET_CX_DATA;
pm_ioctl_buf = malloc(sizeof(struct cpu_cx_data));
if (!pm_ioctl_buf) {
return -1;
}
*pm_ioctl_buf = ((ctx->vmid << PMCMD_VMID_SHIFT) & PMCMD_VMID_MASK)
| ((vcpu_id << PMCMD_VCPUID_SHIFT) & PMCMD_VCPUID_MASK)
| ((cx_num << PMCMD_STATE_NUM_SHIFT) & PMCMD_STATE_NUM_MASK)
| cmd_type;
/* get and validate cx data */
if (vm_get_cpu_state(ctx, pm_ioctl_buf)) {
free(pm_ioctl_buf);
return -1;
}
memcpy(vcpu_cx_data, pm_ioctl_buf,
sizeof(struct cpu_cx_data));
free(pm_ioctl_buf);
return 0;
}
/* _PPC: Performance Present Capabilities
* hard code _PPC to 0, all states are available.
*/