Skip to content

Commit 7dc3e60

Browse files
lyan3dbkinder
authored andcommitted
doc: hv: add comments to irq APIs for documentation
Tracked-On: #1595 Signed-off-by: Yan, Like <like.yan@intel.com>
1 parent f69dd1c commit 7dc3e60

File tree

7 files changed

+148
-13
lines changed

7 files changed

+148
-13
lines changed

doc/acrn.doxyfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,11 @@ INPUT = custom-doxygen/mainpage.md \
800800
../hypervisor/include/public/acrn_hv_defs.h \
801801
../hypervisor/include/arch/x86/guest/vcpu.h \
802802
../hypervisor/arch/x86/trusty.c \
803-
../devicemodel/include/virtio.h
803+
../devicemodel/include/virtio.h \
804+
../hypervisor/include/arch/x86/ioapic.h \
805+
../hypervisor/include/arch/x86/irq.h \
806+
../hypervisor/include/arch/x86/lapic.h \
807+
../hypervisor/include/common/irq.h
804808

805809
# This tag can be used to specify the character encoding of the source files
806810
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

doc/developer-guides/hld/hv-interrupt.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ related operations.
470470
void free_irq(uint32_t irq)
471471
/* Free irq num and unregister the irq action. */
472472
473-
void set_irq_trigger_mode(uint32_t irq, bool is_level_trigger)
473+
void set_irq_trigger_mode(uint32_t irq, bool is_level_triggered)
474474
/* Set the irq trigger mode: edge-triggered or level-triggered */
475475
476476
uint32_t irq_to_vector(uint32_t irq)

hypervisor/arch/x86/irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void free_irq(uint32_t irq)
245245
spinlock_irqrestore_release(&desc->lock, rflags);
246246
}
247247

248-
void set_irq_trigger_mode(uint32_t irq, bool is_level_trigger)
248+
void set_irq_trigger_mode(uint32_t irq, bool is_level_triggered)
249249
{
250250
uint64_t rflags;
251251
struct irq_desc *desc;
@@ -256,7 +256,7 @@ void set_irq_trigger_mode(uint32_t irq, bool is_level_trigger)
256256

257257
desc = &irq_desc_array[irq];
258258
spinlock_irqsave_obtain(&desc->lock, &rflags);
259-
if (is_level_trigger == true) {
259+
if (is_level_triggered == true) {
260260
desc->flags |= IRQF_LEVEL;
261261
} else {
262262
desc->flags &= ~IRQF_LEVEL;

hypervisor/include/arch/x86/ioapic.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,34 @@ void setup_ioapic_irqs(void);
2020

2121
bool irq_is_gsi(uint32_t irq);
2222
uint8_t irq_to_pin(uint32_t irq);
23+
24+
/**
25+
* @brief Get irq num from pin num
26+
*
27+
* @param[in] pin The pin number
28+
*/
2329
uint32_t pin_to_irq(uint8_t pin);
30+
31+
/**
32+
* @brief Set the redirection table entry
33+
*
34+
* Set the redirection table entry of an interrupt
35+
*
36+
* @param[in] irq The number of irq to set
37+
* @param[in] rte Union of ioapic_rte to set
38+
*/
2439
void ioapic_set_rte(uint32_t irq, union ioapic_rte rte);
40+
41+
/**
42+
* @brief Get the redirection table entry
43+
*
44+
* Get the redirection table entry of an interrupt
45+
*
46+
* @param[in] irq The number of irq to fetch RTE
47+
* @param[inout] rte Pointer to union ioapic_rte to return result RTE
48+
*
49+
* @pre rte != NULL
50+
*/
2551
void ioapic_get_rte(uint32_t irq, union ioapic_rte *rte);
2652

2753
void suspend_ioapic(void);
@@ -33,6 +59,15 @@ void gsi_unmask_irq(uint32_t irq);
3359
extern uint8_t pic_ioapic_pin_map[NR_LEGACY_PIN];
3460

3561
#ifdef HV_DEBUG
62+
/**
63+
* @brief Get information of ioapic
64+
*
65+
* It's for debug only.
66+
*
67+
* @param[in] str_max_len The max size of the string containing
68+
* interrupt info
69+
* @param[inout] str_arg Pointer to the output information
70+
*/
3671
int get_ioapic_info(char *str_arg, size_t str_max_len);
3772
#endif /* HV_DEBUG */
3873

hypervisor/include/arch/x86/irq.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ extern spurious_handler_t spurious_handler;
8989
uint32_t alloc_irq_num(uint32_t req_irq);
9090
uint32_t alloc_irq_vector(uint32_t irq);
9191

92+
93+
/**
94+
* @brief Get vector number of an interupt from irq number
95+
*
96+
* @param[in] irq The irq_num to convert
97+
*/
9298
uint32_t irq_to_vector(uint32_t irq);
9399

94100
/*
@@ -122,11 +128,27 @@ int exception_vmexit_handler(struct vcpu *vcpu);
122128
int interrupt_window_vmexit_handler(struct vcpu *vcpu);
123129
int external_interrupt_vmexit_handler(struct vcpu *vcpu);
124130
int acrn_handle_pending_request(struct vcpu *vcpu);
131+
132+
/**
133+
* @brief Initialize the interrupt
134+
*
135+
* To do interrupt initialization for a cpu, will be called for each physical cpu.
136+
*
137+
* @param[in] pcpu_id The id of physical cpu to initialize
138+
*/
125139
void interrupt_init(uint16_t pcpu_id);
126140

127141
void cancel_event_injection(struct vcpu *vcpu);
128142

129143
#ifdef HV_DEBUG
144+
/**
145+
* @brief Get the interupt statistics
146+
*
147+
* It's for debug only.
148+
*
149+
* @param[in] str_max The max size of the string containing interrupt info
150+
* @param[inout] str_arg Pointer to the output interrupt info
151+
*/
130152
void get_cpu_interrupt_info(char *str_arg, size_t str_max);
131153
#endif /* HV_DEBUG */
132154

hypervisor/include/arch/x86/lapic.h

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,54 @@ enum intr_cpu_startup_shorthand {
5151
INTR_CPU_STARTUP_UNKNOWN,
5252
};
5353

54+
55+
/**
56+
* @brief Save context of lapic
57+
*
58+
* @param[inout] regs Pointer to struct lapic_regs to hold the
59+
* context of current lapic
60+
*/
5461
void save_lapic(struct lapic_regs *regs);
5562
void early_init_lapic(void);
5663
void init_lapic(uint16_t pcpu_id);
5764
void send_lapic_eoi(void);
65+
66+
/**
67+
* @brief Get the lapic id
68+
*
69+
* @return lapic id
70+
*/
5871
uint32_t get_cur_lapic_id(void);
72+
73+
/**
74+
* @brief Send an SIPI to a specific cpu
75+
*
76+
* Send an Startup IPI to a specific cpu, to notify the cpu to start booting.
77+
*
78+
* @param[in] cpu_startup_shorthand The startup_shorthand
79+
* @param[in] dest_pcpu_id The id of destination physical cpu
80+
* @param[in] cpu_startup_start_address The address for the dest pCPU to start running
81+
*
82+
* @pre cpu_startup_shorthand < INTR_CPU_STARTUP_UNKNOWN
83+
*/
5984
void send_startup_ipi(enum intr_cpu_startup_shorthand cpu_startup_shorthand,
6085
uint16_t dest_pcpu_id,
6186
uint64_t cpu_startup_start_address);
62-
/* API to send an IPI to multiple pCPUs */
87+
88+
/**
89+
* @brief Send an IPI to multiple pCPUs
90+
*
91+
* @param[in] dest_mask The mask of destination physical cpus
92+
* @param[in] vector The vector of interrupt
93+
*/
6394
void send_dest_ipi_mask(uint32_t dest_mask, uint32_t vector);
64-
/* API to send an IPI to a single pCPU */
95+
96+
/**
97+
* @brief Send an IPI to a single pCPU
98+
*
99+
* @param[in] pcpu_id The id of destination physical cpu
100+
* @param[in] vector The vector of interrupt
101+
*/
65102
void send_single_ipi(uint16_t pcpu_id, uint32_t vector);
66103

67104
void suspend_lapic(void);

hypervisor/include/common/irq.h

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@
1414

1515
typedef void (*irq_action_t)(uint32_t irq, void *priv_data);
1616

17-
/* any field change in below required irq_lock protection with irqsave */
17+
/**
18+
* @brief Interrupt descriptor
19+
*
20+
* Any field change in below required lock protection with irqsave
21+
*/
1822
struct irq_desc {
19-
uint32_t irq; /* index to irq_desc_base */
20-
uint32_t vector; /* assigned vector */
23+
uint32_t irq; /**< index to irq_desc_base */
24+
uint32_t vector; /**< assigned vector */
2125

22-
irq_action_t action; /* callback registered from component */
23-
void *priv_data; /* irq_action private data */
24-
uint32_t flags; /* flags for trigger mode/ptdev */
26+
irq_action_t action; /**< callback registered from component */
27+
void *priv_data; /**< irq_action private data */
28+
uint32_t flags; /**< flags for trigger mode/ptdev */
2529

2630
spinlock_t lock;
2731
#ifdef PROFILING_ON
@@ -31,10 +35,43 @@ struct irq_desc {
3135
#endif
3236
};
3337

38+
/**
39+
* @brief Request an interrupt
40+
*
41+
* Request interrupt num if not specified, and register irq action for the
42+
* specified/allocated irq.
43+
*
44+
* @param[in] req_irq irq_num to request, if IRQ_INVALID, a free irq
45+
* number will be allocated
46+
* @param[in] action_fn Function to be called when the IRQ occurs
47+
* @param[in] priv_data Private data for action function.
48+
* @param[in] flags Interrupt type flags, including:
49+
* IRQF_NONE;
50+
* IRQF_LEVEL - 1: level trigger; 0: edge trigger;
51+
* IRQF_PT - 1: for passthrough dev
52+
*
53+
* @return valid irq num - on success
54+
* @return IRQ_INVALID - on failure
55+
*/
3456
int32_t request_irq(uint32_t req_irq, irq_action_t action_fn, void *priv_data,
3557
uint32_t flags);
3658

59+
/**
60+
* @brief Free an interrupt
61+
*
62+
* Free irq num and unregister the irq action.
63+
*
64+
* @param[in] irq irq_num to be freed
65+
*/
3766
void free_irq(uint32_t irq);
3867

39-
void set_irq_trigger_mode(uint32_t irq, bool is_level_trigger);
68+
/**
69+
* @brief Set interrupt trigger mode
70+
*
71+
* Set the irq trigger mode: edge-triggered or level-triggered
72+
*
73+
* @param[in] irq irq_num of interupt to be set
74+
* @param[in] is_level_triggered Trigger mode to set
75+
*/
76+
void set_irq_trigger_mode(uint32_t irq, bool is_level_triggered);
4077
#endif /* COMMON_IRQ_H */

0 commit comments

Comments
 (0)