Skip to content

Commit cc2c0c3

Browse files
mingqiangchiwenlingz
authored andcommitted
hv:Move several inline APIs from vm.h to *.c
-- move vm_pic() from vm.h to vpic.c since it is only used in vpic.c -- move vm_ioapic() from vm.h to vioapic.c change vioapic_reset(struct acrn_vioapic *vioapic) --> vioapic_reset(struct acrn_vm *vm) then vm_vioapic() is only used in vioapic.c -- move vm_vuart() from vm.h to vuart.c, now this api is used in vuart.c and shell.c Tracked-On: #1842 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com>
1 parent 6155245 commit cc2c0c3

File tree

7 files changed

+22
-23
lines changed

7 files changed

+22
-23
lines changed

hypervisor/arch/x86/guest/vm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ int32_t reset_vm(struct acrn_vm *vm)
321321
}
322322

323323
reset_vm_ioreqs(vm);
324-
vioapic_reset(vm_ioapic(vm));
324+
vioapic_reset(vm);
325325
destroy_secure_world(vm, false);
326326
vm->sworld_control.flag.active = 0UL;
327327
ret = 0;

hypervisor/debug/vuart.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ static uint8_t vuart_intr_reason(const struct acrn_vuart *vu)
122122
}
123123
}
124124

125+
struct acrn_vuart *vm_vuart(struct acrn_vm *vm)
126+
{
127+
return &(vm->vuart);
128+
}
129+
125130
/*
126131
* Toggle the COM port's intr pin depending on whether or not we have an
127132
* interrupt condition to report to the processor.

hypervisor/dm/vioapic.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
#define IOAPIC_ID_MASK 0x0f000000U
4141
#define MASK_ALL_INTERRUPTS 0x0001000000010000UL
4242

43+
static inline struct acrn_vioapic *vm_ioapic(const struct acrn_vm *vm)
44+
{
45+
return (struct acrn_vioapic *)&(vm->arch_vm.vioapic);
46+
}
47+
4348
/**
4449
* @pre pin < vioapic_pincount(vm)
4550
*/
@@ -495,12 +500,13 @@ vioapic_process_eoi(struct acrn_vm *vm, uint32_t vector)
495500
}
496501

497502
void
498-
vioapic_reset(struct acrn_vioapic *vioapic)
503+
vioapic_reset(struct acrn_vm *vm)
499504
{
500505
uint32_t pin, pincount;
506+
struct acrn_vioapic *vioapic = vm_ioapic(vm);
501507

502508
/* Initialize all redirection entries to mask all interrupts */
503-
pincount = vioapic_pincount(vioapic->vm);
509+
pincount = vioapic_pincount(vm);
504510
for (pin = 0U; pin < pincount; pin++) {
505511
vioapic->rtbl[pin].full = MASK_ALL_INTERRUPTS;
506512
}
@@ -514,7 +520,7 @@ vioapic_init(struct acrn_vm *vm)
514520
vm->arch_vm.vioapic.vm = vm;
515521
spinlock_init(&(vm->arch_vm.vioapic.mtx));
516522

517-
vioapic_reset(vm_ioapic(vm));
523+
vioapic_reset(vm);
518524

519525
(void)register_mmio_emulation_handler(vm,
520526
vioapic_mmio_access_handler,

hypervisor/dm/vpic.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333

3434
static void vpic_set_pinstate(struct acrn_vpic *vpic, uint32_t pin, uint8_t level);
3535

36+
static inline struct acrn_vpic *vm_pic(const struct acrn_vm *vm)
37+
{
38+
return (struct acrn_vpic *)&(vm->arch_vm.vpic);
39+
}
40+
3641
static inline bool master_pic(const struct acrn_vpic *vpic, const struct i8259_reg_state *i8259)
3742
{
3843
bool ret;

hypervisor/include/arch/x86/guest/vioapic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct acrn_vioapic {
6060
};
6161

6262
void vioapic_init(struct acrn_vm *vm);
63-
void vioapic_reset(struct acrn_vioapic *vioapic);
63+
void vioapic_reset(struct acrn_vm *vm);
6464

6565

6666
/**

hypervisor/include/arch/x86/guest/vm.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -272,24 +272,6 @@ static inline struct acrn_vcpu *get_primary_vcpu(struct acrn_vm *vm)
272272
return target_vcpu;
273273
}
274274

275-
static inline struct acrn_vuart*
276-
vm_vuart(struct acrn_vm *vm)
277-
{
278-
return &(vm->vuart);
279-
}
280-
281-
static inline struct acrn_vpic *
282-
vm_pic(const struct acrn_vm *vm)
283-
{
284-
return (struct acrn_vpic *)&(vm->arch_vm.vpic);
285-
}
286-
287-
static inline struct acrn_vioapic *
288-
vm_ioapic(const struct acrn_vm *vm)
289-
{
290-
return (struct acrn_vioapic *)&(vm->arch_vm.vioapic);
291-
}
292-
293275
int32_t shutdown_vm(struct acrn_vm *vm);
294276
void pause_vm(struct acrn_vm *vm);
295277
void resume_vm(struct acrn_vm *vm);

hypervisor/include/debug/vuart.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct acrn_vuart {
7070
extern int8_t vuart_vmid;
7171
#endif /* CONFIG_PARTITION_MODE */
7272

73+
struct acrn_vuart *vm_vuart(struct acrn_vm *vm);
7374
void vuart_init(struct acrn_vm *vm);
7475
struct acrn_vuart *vuart_console_active(void);
7576
void vuart_console_tx_chars(struct acrn_vuart *vu);

0 commit comments

Comments
 (0)