refactor(interrupts): make bitmap and count functions private

Move the functions to modify the interrupt bitmap or count into
vcpu.c and make them static so only the getter functions can be
accessed externally. This helps ensure consistency between the
bitmap, queue and count.

Also rename the count_get functions to match the
vcpu_virt_interrupt_ naming used for other public functions
for virtual interrupts within the vcpu.c file.

Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: Id4eaa76f448ddddfd9ca99e2e12789b0c57c20f3
diff --git a/inc/hf/vcpu.h b/inc/hf/vcpu.h
index f335b9d..2e26ff4 100644
--- a/inc/hf/vcpu.h
+++ b/inc/hf/vcpu.h
@@ -259,124 +259,6 @@
 void vcpu_set_phys_core_idx(struct vcpu *vcpu);
 void vcpu_set_boot_info_gp_reg(struct vcpu *vcpu);
 
-static inline bool vcpu_is_virt_interrupt_enabled(struct interrupts *interrupts,
-						  uint32_t intid)
-{
-	return interrupt_bitmap_get_value(&interrupts->interrupt_enabled,
-					  intid) == 1U;
-}
-
-static inline void vcpu_virt_interrupt_set_enabled(
-	struct interrupts *interrupts, uint32_t intid)
-{
-	interrupt_bitmap_set_value(&interrupts->interrupt_enabled, intid);
-}
-
-static inline void vcpu_virt_interrupt_clear_enabled(
-	struct interrupts *interrupts, uint32_t intid)
-{
-	interrupt_bitmap_clear_value(&interrupts->interrupt_enabled, intid);
-}
-
-static inline bool vcpu_is_virt_interrupt_pending(struct interrupts *interrupts,
-						  uint32_t intid)
-{
-	return interrupt_bitmap_get_value(&interrupts->interrupt_pending,
-					  intid) == 1U;
-}
-
-static inline void vcpu_virt_interrupt_set_pending(
-	struct interrupts *interrupts, uint32_t intid)
-{
-	interrupt_bitmap_set_value(&interrupts->interrupt_pending, intid);
-}
-
-static inline void vcpu_virt_interrupt_clear_pending(
-	struct interrupts *interrupts, uint32_t intid)
-{
-	interrupt_bitmap_clear_value(&interrupts->interrupt_pending, intid);
-}
-
-static inline enum interrupt_type vcpu_virt_interrupt_get_type(
-	struct interrupts *interrupts, uint32_t intid)
-{
-	return (enum interrupt_type)interrupt_bitmap_get_value(
-		&interrupts->interrupt_type, intid);
-}
-
-static inline void vcpu_virt_interrupt_set_type(struct interrupts *interrupts,
-						uint32_t intid,
-						enum interrupt_type type)
-{
-	if (type == INTERRUPT_TYPE_IRQ) {
-		interrupt_bitmap_clear_value(&interrupts->interrupt_type,
-					     intid);
-	} else {
-		interrupt_bitmap_set_value(&interrupts->interrupt_type, intid);
-	}
-}
-
-static inline void vcpu_irq_count_increment(struct vcpu_locked vcpu_locked)
-{
-	vcpu_locked.vcpu->interrupts.enabled_and_pending_irq_count++;
-}
-
-static inline void vcpu_irq_count_decrement(struct vcpu_locked vcpu_locked)
-{
-	vcpu_locked.vcpu->interrupts.enabled_and_pending_irq_count--;
-}
-
-static inline void vcpu_fiq_count_increment(struct vcpu_locked vcpu_locked)
-{
-	vcpu_locked.vcpu->interrupts.enabled_and_pending_fiq_count++;
-}
-
-static inline void vcpu_fiq_count_decrement(struct vcpu_locked vcpu_locked)
-{
-	vcpu_locked.vcpu->interrupts.enabled_and_pending_fiq_count--;
-}
-static inline void vcpu_interrupt_count_increment(
-	struct vcpu_locked vcpu_locked, struct interrupts *interrupts,
-	uint32_t intid)
-{
-	if (vcpu_virt_interrupt_get_type(interrupts, intid) ==
-	    INTERRUPT_TYPE_IRQ) {
-		vcpu_irq_count_increment(vcpu_locked);
-	} else {
-		vcpu_fiq_count_increment(vcpu_locked);
-	}
-}
-
-static inline void vcpu_interrupt_count_decrement(
-	struct vcpu_locked vcpu_locked, struct interrupts *interrupts,
-	uint32_t intid)
-{
-	if (vcpu_virt_interrupt_get_type(interrupts, intid) ==
-	    INTERRUPT_TYPE_IRQ) {
-		vcpu_irq_count_decrement(vcpu_locked);
-	} else {
-		vcpu_fiq_count_decrement(vcpu_locked);
-	}
-}
-
-static inline uint32_t vcpu_interrupt_irq_count_get(
-	struct vcpu_locked vcpu_locked)
-{
-	return vcpu_locked.vcpu->interrupts.enabled_and_pending_irq_count;
-}
-
-static inline uint32_t vcpu_interrupt_fiq_count_get(
-	struct vcpu_locked vcpu_locked)
-{
-	return vcpu_locked.vcpu->interrupts.enabled_and_pending_fiq_count;
-}
-
-static inline uint32_t vcpu_interrupt_count_get(struct vcpu_locked vcpu_locked)
-{
-	return vcpu_locked.vcpu->interrupts.enabled_and_pending_irq_count +
-	       vcpu_locked.vcpu->interrupts.enabled_and_pending_fiq_count;
-}
-
 static inline void vcpu_call_chain_extend(struct vcpu_locked vcpu1_locked,
 					  struct vcpu_locked vcpu2_locked)
 {
@@ -422,13 +304,65 @@
 void vcpu_save_interrupt_priority(struct vcpu_locked vcpu_locked,
 				  uint8_t priority);
 
+void vcpu_enter_secure_interrupt_rtm(struct vcpu_locked vcpu_locked);
+
+void vcpu_secure_interrupt_complete(struct vcpu_locked vcpu_locked);
+
+static inline bool vcpu_is_virt_interrupt_enabled(struct interrupts *interrupts,
+						  uint32_t intid)
+{
+	return interrupt_bitmap_get_value(&interrupts->interrupt_enabled,
+					  intid) == 1U;
+}
+
+static inline void vcpu_virt_interrupt_set_enabled(
+	struct interrupts *interrupts, uint32_t intid)
+{
+	interrupt_bitmap_set_value(&interrupts->interrupt_enabled, intid);
+}
+
+static inline void vcpu_virt_interrupt_clear_enabled(
+	struct interrupts *interrupts, uint32_t intid)
+{
+	interrupt_bitmap_clear_value(&interrupts->interrupt_enabled, intid);
+}
+
+static inline bool vcpu_is_virt_interrupt_pending(struct interrupts *interrupts,
+						  uint32_t intid)
+{
+	return interrupt_bitmap_get_value(&interrupts->interrupt_pending,
+					  intid) == 1U;
+}
+
+static inline enum interrupt_type vcpu_virt_interrupt_get_type(
+	struct interrupts *interrupts, uint32_t intid)
+{
+	return (enum interrupt_type)interrupt_bitmap_get_value(
+		&interrupts->interrupt_type, intid);
+}
+
+static inline void vcpu_virt_interrupt_set_type(struct interrupts *interrupts,
+						uint32_t intid,
+						enum interrupt_type type)
+{
+	if (type == INTERRUPT_TYPE_IRQ) {
+		interrupt_bitmap_clear_value(&interrupts->interrupt_type,
+					     intid);
+	} else {
+		interrupt_bitmap_set_value(&interrupts->interrupt_type, intid);
+	}
+}
+
+uint32_t vcpu_virt_interrupt_irq_count_get(struct vcpu_locked vcpu_locked);
+uint32_t vcpu_virt_interrupt_fiq_count_get(struct vcpu_locked vcpu_locked);
+uint32_t vcpu_virt_interrupt_count_get(struct vcpu_locked vcpu_locked);
+
+void vcpu_virt_interrupt_enable(struct vcpu_locked vcpu_locked,
+				uint32_t vint_id, bool enable);
+
 uint32_t vcpu_virt_interrupt_peek_pending_and_enabled(
 	struct vcpu_locked vcpu_locked);
 uint32_t vcpu_virt_interrupt_get_pending_and_enabled(
 	struct vcpu_locked vcpu_locked);
 void vcpu_virt_interrupt_inject(struct vcpu_locked vcpu_locked,
 				uint32_t vint_id);
-
-void vcpu_enter_secure_interrupt_rtm(struct vcpu_locked vcpu_locked);
-
-void vcpu_secure_interrupt_complete(struct vcpu_locked vcpu_locked);