1 /*
2  * Copyright (c) 2008 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #pragma once
9 
10 #include <lk/compiler.h>
11 #include <stdbool.h>
12 #include <sys/types.h>
13 
14 __BEGIN_CDECLS
15 
16 /* Routines implemented by the platform or system specific interrupt controller
17  * to allow for installation and masking/unmask of interrupt vectors.
18  *
19  * Some platforms do not allow for dynamic registration.
20  */
21 status_t mask_interrupt(unsigned int vector);
22 status_t unmask_interrupt(unsigned int vector);
23 
24 typedef enum handler_return (*int_handler)(void *arg);
25 void register_int_handler(unsigned int vector, int_handler handler, void *arg);
26 
27 /* Register a MSI interrupt handler. Basically the same as register_int_handler, except
28  * interrupt controller may have additional setup.
29  */
30 void register_int_handler_msi(unsigned int vector, int_handler handler, void *arg, bool edge);
31 
32 /* Allocate a run of interrupts with alignment log2 in a platform specific way.
33  * Used for PCI MSI and possibly other use cases.
34  */
35 status_t platform_allocate_interrupts(size_t count, uint align_log2, bool msi, unsigned int *vector);
36 
37 /* Map the incoming interrupt line number from the pci bus config to raw
38  * vector number, usable in the above apis.
39  */
40 status_t platform_pci_int_to_vector(unsigned int pci_int, unsigned int *vector);
41 
42 /* Ask the platform to compute for us the value to stuff in the MSI address and data fields. */
43 status_t platform_compute_msi_values(unsigned int vector, unsigned int cpu, bool edge,
44         uint64_t *msi_address_out, uint16_t *msi_data_out);
45 
46 __END_CDECLS
47