1 // Copyright 2016 The Fuchsia Authors
2 // Copyright (c) 2016, Google Inc. All rights reserved.
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 <sys/types.h>
11 #include <zircon/compiler.h>
12 #include <zircon/types.h>
13 
14 /**
15  * Structure used to hold information about a GICv2m register frame
16  * @see arm_gicv2m_get_frame_info
17  */
18 typedef struct arm_gicv2m_frame_info {
19     uint start_spi_id; /** The first valid SPI ID in the frame */
20     uint end_spi_id;   /** The last valid SPI ID in the frame */
21     paddr_t doorbell;  /** The physical address of the doorbell register */
22     uint32_t iid;      /** The value of the Interface ID register */
23 } arm_gicv2m_frame_info_t;
24 
25 /**
26  * Support for the MSI extensions to the GICv2 architecture.  See the ARM Server
27  * Base System Architecture v3.0 (ARM_DEN_0029) Appendix E for details.
28  *
29  * @param reg_frames An array of physical addresses of the 4k V2M register
30  * frames implemented by this platform's GIC.  Note: The memory backing this
31  * array must be alive for the lifetime of the system.
32  * @param reg_frame_count The number of entries in the reg_frames array.
33  */
34 void arm_gicv2m_init(const paddr_t* reg_frames, const vaddr_t* reg_frames_virt, uint reg_frame_count);
35 
36 /**
37  * Fetch info about a specific GICv2m register frame
38  *
39  * @param frame_num The index of the frame to fetch info for
40  * @param out_info A pointer to the structure which will hold info about the frame
41  * @return A status code indicating the success or failure of the operation.
42  * Status codes may include...
43  *  ++ ZX_ERR_UNAVAILABLE The GICv2m subsystem was never initialized
44  *  ++ ZX_ERR_NOT_FOUND frame_ndx is out of range
45  *  ++ ZX_ERR_INVALID_ARGS out_info is NULL
46  *  ++ ZX_ERR_BAD_STATE The frame index exists, but the registers in the frame
47  *     appear to be corrupt or invalid (internal error)
48  */
49 zx_status_t arm_gicv2m_get_frame_info(uint frame_ndx, arm_gicv2m_frame_info_t* out_info);
50