36
36
37
37
static void vpic_set_pinstate (struct acrn_vpic * vpic , uint32_t pin , uint8_t level );
38
38
39
- static inline struct acrn_vpic * vm_pic (const struct acrn_vm * vm )
39
+ struct acrn_vpic * vm_pic (const struct acrn_vm * vm )
40
40
{
41
41
return (struct acrn_vpic * )& (vm -> arch_vm .vpic );
42
42
}
@@ -453,21 +453,19 @@ static void vpic_set_pinstate(struct acrn_vpic *vpic, uint32_t pin, uint8_t leve
453
453
/**
454
454
* @brief Set vPIC IRQ line status.
455
455
*
456
- * @param[in] vm Pointer to target VM
456
+ * @param[in] vpic Pointer to virtual pic structure
457
457
* @param[in] irqline Target IRQ number
458
458
* @param[in] operation action options:GSI_SET_HIGH/GSI_SET_LOW/
459
459
* GSI_RAISING_PULSE/GSI_FALLING_PULSE
460
460
*
461
461
* @return None
462
462
*/
463
- void vpic_set_irqline (const struct acrn_vm * vm , uint32_t irqline , uint32_t operation )
463
+ void vpic_set_irqline (struct acrn_vpic * vpic , uint32_t irqline , uint32_t operation )
464
464
{
465
- struct acrn_vpic * vpic ;
466
465
struct i8259_reg_state * i8259 ;
467
466
uint32_t pin ;
468
467
469
468
if (irqline < NR_VPIC_PINS_TOTAL ) {
470
- vpic = vm_pic (vm );
471
469
i8259 = & vpic -> i8259 [irqline >> 3U ];
472
470
pin = irqline ;
473
471
@@ -511,13 +509,9 @@ vpic_pincount(void)
511
509
* @pre irqline < NR_VPIC_PINS_TOTAL
512
510
* @pre this function should be called after vpic_init()
513
511
*/
514
- void vpic_get_irqline_trigger_mode (const struct acrn_vm * vm , uint32_t irqline ,
512
+ void vpic_get_irqline_trigger_mode (const struct acrn_vpic * vpic , uint32_t irqline ,
515
513
enum vpic_trigger * trigger )
516
514
{
517
- struct acrn_vpic * vpic ;
518
-
519
- vpic = vm_pic (vm );
520
-
521
515
if ((vpic -> i8259 [irqline >> 3U ].elc & (1U << (irqline & 0x7U ))) != 0U ) {
522
516
* trigger = LEVEL_TRIGGER ;
523
517
} else {
@@ -528,21 +522,18 @@ void vpic_get_irqline_trigger_mode(const struct acrn_vm *vm, uint32_t irqline,
528
522
/**
529
523
* @brief Get pending virtual interrupts for vPIC.
530
524
*
531
- * @param[in] vm Pointer to target VM
525
+ * @param[in] vpic Pointer to target VM's vpic table
532
526
* @param[inout] vecptr Pointer to vector buffer and will be filled
533
527
* with eligible vector if any.
534
528
*
535
529
* @pre this function should be called after vpic_init()
536
530
* @return None
537
531
*/
538
- void vpic_pending_intr (struct acrn_vm * vm , uint32_t * vecptr )
532
+ void vpic_pending_intr (struct acrn_vpic * vpic , uint32_t * vecptr )
539
533
{
540
- struct acrn_vpic * vpic ;
541
534
struct i8259_reg_state * i8259 ;
542
535
uint32_t pin ;
543
536
544
- vpic = vm_pic (vm );
545
-
546
537
i8259 = & vpic -> i8259 [0 ];
547
538
548
539
spinlock_obtain (& (vpic -> lock ));
@@ -597,13 +588,10 @@ static void vpic_pin_accepted(struct i8259_reg_state *i8259, uint32_t pin)
597
588
* @pre vm != NULL
598
589
* @pre this function should be called after vpic_init()
599
590
*/
600
- void vpic_intr_accepted (struct acrn_vm * vm , uint32_t vector )
591
+ void vpic_intr_accepted (struct acrn_vpic * vpic , uint32_t vector )
601
592
{
602
- struct acrn_vpic * vpic ;
603
593
uint32_t pin ;
604
594
605
- vpic = vm_pic (vm );
606
-
607
595
spinlock_obtain (& (vpic -> lock ));
608
596
609
597
pin = (vector & 0x7U );
@@ -709,14 +697,12 @@ static int32_t vpic_write(struct acrn_vpic *vpic, struct i8259_reg_state *i8259,
709
697
return error ;
710
698
}
711
699
712
- static int32_t vpic_master_handler (struct acrn_vm * vm , bool in , uint16_t port ,
700
+ static int32_t vpic_master_handler (struct acrn_vpic * vpic , bool in , uint16_t port ,
713
701
size_t bytes , uint32_t * eax )
714
702
{
715
- struct acrn_vpic * vpic ;
716
703
struct i8259_reg_state * i8259 ;
717
704
int32_t ret ;
718
705
719
- vpic = vm_pic (vm );
720
706
i8259 = & vpic -> i8259 [0 ];
721
707
722
708
if (bytes != 1U ) {
@@ -734,7 +720,7 @@ static bool vpic_master_io_read(struct acrn_vm *vm, struct acrn_vcpu *vcpu, uint
734
720
{
735
721
struct pio_request * pio_req = & vcpu -> req .reqs .pio ;
736
722
737
- if (vpic_master_handler (vm , true, addr , width , & pio_req -> value ) < 0 ) {
723
+ if (vpic_master_handler (vm_pic ( vm ) , true, addr , width , & pio_req -> value ) < 0 ) {
738
724
pr_err ("pic master read port 0x%x width=%d failed\n" ,
739
725
addr , width );
740
726
}
@@ -747,22 +733,20 @@ static bool vpic_master_io_write(struct acrn_vm *vm, uint16_t addr, size_t width
747
733
{
748
734
uint32_t val = v ;
749
735
750
- if (vpic_master_handler (vm , false, addr , width , & val ) < 0 ) {
736
+ if (vpic_master_handler (vm_pic ( vm ) , false, addr , width , & val ) < 0 ) {
751
737
pr_err ("%s: write port 0x%x width=%d value 0x%x failed\n" ,
752
738
__func__ , addr , width , val );
753
739
}
754
740
755
741
return true;
756
742
}
757
743
758
- static int32_t vpic_slave_handler (struct acrn_vm * vm , bool in , uint16_t port ,
744
+ static int32_t vpic_slave_handler (struct acrn_vpic * vpic , bool in , uint16_t port ,
759
745
size_t bytes , uint32_t * eax )
760
746
{
761
- struct acrn_vpic * vpic ;
762
747
struct i8259_reg_state * i8259 ;
763
748
int32_t ret ;
764
749
765
- vpic = vm_pic (vm );
766
750
i8259 = & vpic -> i8259 [1 ];
767
751
768
752
if (bytes != 1U ) {
@@ -780,7 +764,7 @@ static bool vpic_slave_io_read(struct acrn_vm *vm, struct acrn_vcpu *vcpu, uint1
780
764
{
781
765
struct pio_request * pio_req = & vcpu -> req .reqs .pio ;
782
766
783
- if (vpic_slave_handler (vm , true, addr , width , & pio_req -> value ) < 0 ) {
767
+ if (vpic_slave_handler (vm_pic ( vm ) , true, addr , width , & pio_req -> value ) < 0 ) {
784
768
pr_err ("pic slave read port 0x%x width=%d failed\n" ,
785
769
addr , width );
786
770
}
@@ -792,22 +776,20 @@ static bool vpic_slave_io_write(struct acrn_vm *vm, uint16_t addr, size_t width,
792
776
{
793
777
uint32_t val = v ;
794
778
795
- if (vpic_slave_handler (vm , false, addr , width , & val ) < 0 ) {
779
+ if (vpic_slave_handler (vm_pic ( vm ) , false, addr , width , & val ) < 0 ) {
796
780
pr_err ("%s: write port 0x%x width=%d value 0x%x failed\n" ,
797
781
__func__ , addr , width , val );
798
782
}
799
783
800
784
return true;
801
785
}
802
786
803
- static int32_t vpic_elc_handler (struct acrn_vm * vm , bool in , uint16_t port , size_t bytes ,
787
+ static int32_t vpic_elc_handler (struct acrn_vpic * vpic , bool in , uint16_t port , size_t bytes ,
804
788
uint32_t * eax )
805
789
{
806
- struct acrn_vpic * vpic ;
807
790
bool is_master ;
808
791
int32_t ret ;
809
792
810
- vpic = vm_pic (vm );
811
793
is_master = (port == IO_ELCR1 );
812
794
813
795
if (bytes == 1U ) {
@@ -850,7 +832,7 @@ static bool vpic_elc_io_read(struct acrn_vm *vm, struct acrn_vcpu *vcpu, uint16_
850
832
{
851
833
struct pio_request * pio_req = & vcpu -> req .reqs .pio ;
852
834
853
- if (vpic_elc_handler (vm , true, addr , width , & pio_req -> value ) < 0 ) {
835
+ if (vpic_elc_handler (vm_pic ( vm ) , true, addr , width , & pio_req -> value ) < 0 ) {
854
836
pr_err ("pic elc read port 0x%x width=%d failed" , addr , width );
855
837
}
856
838
@@ -862,7 +844,7 @@ static bool vpic_elc_io_write(struct acrn_vm *vm, uint16_t addr, size_t width,
862
844
{
863
845
uint32_t val = v ;
864
846
865
- if (vpic_elc_handler (vm , false, addr , width , & val ) < 0 ) {
847
+ if (vpic_elc_handler (vm_pic ( vm ) , false, addr , width , & val ) < 0 ) {
866
848
pr_err ("%s: write port 0x%x width=%d value 0x%x failed\n" ,
867
849
__func__ , addr , width , val );
868
850
}
@@ -900,9 +882,9 @@ void vpic_init(struct acrn_vm *vm)
900
882
{
901
883
struct acrn_vpic * vpic = vm_pic (vm );
902
884
vpic_register_io_handler (vm );
903
- vm -> arch_vm . vpic . vm = vm ;
904
- vm -> arch_vm . vpic . i8259 [0 ].mask = 0xffU ;
905
- vm -> arch_vm . vpic . i8259 [1 ].mask = 0xffU ;
885
+ vpic -> vm = vm ;
886
+ vpic -> i8259 [0 ].mask = 0xffU ;
887
+ vpic -> i8259 [1 ].mask = 0xffU ;
906
888
907
889
spinlock_init (& (vpic -> lock ));
908
890
}
0 commit comments