mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-07 07:56:56 +00:00
There are several similar irq handlers with confusing function names and it's not friendly to call update_irq_handler() to update a proper handler after request_irq(). With this commit, a single generic irq handler is being used, in which, no lock need to be acquired because our design could guarantee there is no concurrent irq handling and irq handler request/free. A flags field is added to irq_desc struct to select the proper processing flow for an irq. Irqflags is defined as follows: IRQF_NONE (0U) IRQF_LEVEL (1U << 1U) /* 1: level trigger; 0: edge trigger */ IRQF_PT (1U << 2U) /* 1: for passthrough dev */ Because we have only one irq handler, update_irq_handler() should be replace by set_irq_trigger_mode(), whichs set trigger mode flag of a certian irq. Accordingly, the code where called update_irq_handler() need to be updated. Signed-off-by: Yan, Like <like.yan@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
/*
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef COMMON_IRQ_H
|
|
#define COMMON_IRQ_H
|
|
|
|
#define IRQF_NONE (0U)
|
|
#define IRQF_LEVEL (1U << 1U) /* 1: level trigger; 0: edge trigger */
|
|
#define IRQF_PT (1U << 2U) /* 1: for passthrough dev */
|
|
|
|
enum irq_mode {
|
|
IRQ_PULSE,
|
|
IRQ_ASSERT,
|
|
IRQ_DEASSERT,
|
|
};
|
|
|
|
enum irq_use_state {
|
|
IRQ_NOT_ASSIGNED = 0,
|
|
IRQ_ASSIGNED,
|
|
};
|
|
|
|
typedef int (*irq_action_t)(uint32_t irq, void *priv_data);
|
|
|
|
/* any field change in below required irq_lock protection with irqsave */
|
|
struct irq_desc {
|
|
uint32_t irq; /* index to irq_desc_base */
|
|
enum irq_use_state used; /* this irq have assigned to device */
|
|
uint32_t vector; /* assigned vector */
|
|
|
|
irq_action_t action; /* callback registered from component */
|
|
void *priv_data; /* irq_action private data */
|
|
uint32_t flags; /* flags for trigger mode/ptdev */
|
|
|
|
spinlock_t lock;
|
|
};
|
|
|
|
int32_t request_irq(uint32_t irq,
|
|
irq_action_t action_fn,
|
|
void *priv_data,
|
|
uint32_t flags);
|
|
|
|
void free_irq(uint32_t irq);
|
|
|
|
void set_irq_trigger_mode(uint32_t irq, bool is_level_trigger);
|
|
#endif /* COMMON_IRQ_H */
|