Skip to content

Commit b068959

Browse files
Shawnshhlijinxia
authored andcommitted
HV:change the cpu state to enum type
enum cpu state is better than cpu state macro. V1->V2: move enum cpu_state under #ifndef ASSEMBLER MACRO to avoid assembler compiler scan. Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent eaa5418 commit b068959

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static int init_phy_cpu_storage(void)
293293
return bsp_cpu_id;
294294
}
295295

296-
static void cpu_set_current_state(uint32_t logical_id, int state)
296+
static void cpu_set_current_state(uint32_t logical_id, enum cpu_state state)
297297
{
298298
spinlock_obtain(&up_count_spinlock);
299299

hypervisor/include/arch/x86/cpu.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,6 @@
132132
/* Boot CPU ID */
133133
#define CPU_BOOT_ID 0U
134134

135-
/* CPU states defined */
136-
#define CPU_STATE_RESET 0
137-
#define CPU_STATE_INITIALIZING 1
138-
#define CPU_STATE_RUNNING 2
139-
#define CPU_STATE_HALTED 3
140-
#define CPU_STATE_DEAD 4
141-
142135
/* hypervisor stack bottom magic('intl') */
143136
#define SP_BOTTOM_MAGIC 0x696e746cUL
144137

@@ -218,6 +211,15 @@ enum feature_word {
218211
FEATURE_WORDS,
219212
};
220213

214+
/* CPU states defined */
215+
enum cpu_state {
216+
CPU_STATE_RESET = 0,
217+
CPU_STATE_INITIALIZING,
218+
CPU_STATE_RUNNING,
219+
CPU_STATE_HALTED,
220+
CPU_STATE_DEAD,
221+
};
222+
221223
struct cpu_state_info {
222224
uint8_t px_cnt; /* count of all Px states */
223225
const struct cpu_px_data *px_data;

hypervisor/include/arch/x86/per_cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct per_cpu_region {
3232
struct emul_cnx g_inst_ctxt;
3333
struct host_gdt gdt;
3434
struct tss_64 tss;
35-
int state;
35+
enum cpu_state state;
3636
uint8_t mc_stack[CONFIG_STACK_SIZE] __aligned(16);
3737
uint8_t df_stack[CONFIG_STACK_SIZE] __aligned(16);
3838
uint8_t sf_stack[CONFIG_STACK_SIZE] __aligned(16);

0 commit comments

Comments
 (0)