acrn-hypervisor/hypervisor/include/common/irq.h
Yan, Like 8fda0d8c5f hv: pirq: add static irq:vector mappings
Since vector is x86 specific concept, we'd like to hide it from common irq APIs.
This commit
 - adds static irq:vector mappings for special interrupt such as timer
and cpu notification;
 - reserves the irq and vector at initialization;
 - removed the vector argument in pri_register_handler(), get reserved vector
   from irq_desc in common_register_handler().

Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-08-15 10:40:43 +08:00

76 lines
1.8 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_state {
IRQ_NOT_ASSIGNED = 0,
IRQ_ASSIGNED,
};
enum irq_desc_state {
IRQ_DESC_PENDING,
IRQ_DESC_IN_PROCESS,
};
typedef int (*irq_action_t)(uint32_t irq, void *dev_data);
struct irq_request_info {
/* vector set to 0xE0 ~ 0xFF for pri_register_handler
* and set to VECTOR_INVALID for normal_register_handler
*/
irq_action_t func;
void *priv_data;
char *name;
};
/* any field change in below required irq_lock protection with irqsave */
struct irq_desc {
uint32_t irq; /* index to irq_desc_base */
enum irq_state used; /* this irq have assigned to device */
enum irq_desc_state state; /* irq_desc status */
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 */
char name[32]; /* name of component */
spinlock_t irq_lock;
uint64_t *irq_cnt; /* this irq cnt happened on CPUs */
uint64_t irq_lost_cnt;
};
uint32_t irq_mark_used(uint32_t irq);
uint32_t irq_desc_alloc_vector(uint32_t irq);
void irq_desc_try_free_vector(uint32_t irq);
uint32_t irq_to_vector(uint32_t irq);
int32_t pri_register_handler(uint32_t irq,
irq_action_t func,
void *priv_data,
const char *name);
int32_t normal_register_handler(uint32_t irq,
irq_action_t func,
void *priv_data,
const char *name);
void unregister_handler_common(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 */