acrn-hypervisor/hypervisor/include/common/irq.h
Yan, Like 2c044e0c4e hv: pirq: refactor vector allocation/free
This commit refactors vector allocation/free codes, two functions are
defined to help alloc/free vectors for an irq:
- uint32_t alloc_irq_vector(uint32_t irq)
  - alloc a free vector (0x20 ~ 0xDF), and bind it to irq, for legacy irqs
    and static mapped irqs, vector has been allocated and bind, so just
    check the mapping correctness;
  - return: valid vector on success, VECTOR_INVALID on failure.

- void free_irq_vector(uint32_t irq)
  - free vector allocated via alloc_irq_vector(), for legacy irqs and static
    mapped irqs, nothing need to do.

Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-08-17 14:25:52 +08:00

46 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
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 */
int (*irq_handler)(struct irq_desc *irq_desc, void *handler_data);
/* callback for irq flow handling */
irq_action_t action; /* callback registered from component */
void *priv_data; /* irq_action private data */
spinlock_t lock;
};
int32_t request_irq(uint32_t irq,
irq_action_t action_fn,
void *priv_data);
void free_irq(uint32_t irq);
typedef int (*irq_handler_t)(struct irq_desc *desc, void *handler_data);
void update_irq_handler(uint32_t irq, irq_handler_t func);
#endif /* COMMON_IRQ_H */