1 | /* |
---|
2 | * soclib_xcu.c - x86 XCU driver API implementation. |
---|
3 | * |
---|
4 | * Copyright (c) 2017 Maxime Villard |
---|
5 | * |
---|
6 | * This file is part of ALMOS-MKH. |
---|
7 | * |
---|
8 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
9 | * under the terms of the GNU General Public License as published by |
---|
10 | * the Free Software Foundation; version 2.0 of the License. |
---|
11 | * |
---|
12 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | * General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with ALMOS-MKH.; if not, write to the Free Software Foundation, |
---|
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
20 | */ |
---|
21 | |
---|
22 | #include <soclib_xcu.h> |
---|
23 | #include <hal_types.h> |
---|
24 | #include <core.h> |
---|
25 | #include <chdev.h> |
---|
26 | |
---|
27 | #include <hal_apic.h> |
---|
28 | #include <hal_segmentation.h> |
---|
29 | #include <hal_internal.h> |
---|
30 | |
---|
31 | extern size_t ioapic_pins; |
---|
32 | |
---|
33 | /* |
---|
34 | * These indexes are used to translate a type::idx to a pin on the IOAPIC. |
---|
35 | */ |
---|
36 | uint32_t hwi_baseidx __in_kdata = 0; |
---|
37 | uint32_t wti_baseidx __in_kdata = 0; |
---|
38 | uint32_t pti_baseidx __in_kdata = 0; |
---|
39 | |
---|
40 | static uint32_t get_pin(uint32_t idx, uint32_t type) |
---|
41 | { |
---|
42 | switch (type) { |
---|
43 | case HWI_TYPE: |
---|
44 | return hwi_baseidx + idx; |
---|
45 | case WTI_TYPE: |
---|
46 | return wti_baseidx + idx; |
---|
47 | case PTI_TYPE: |
---|
48 | return pti_baseidx + idx; |
---|
49 | default: |
---|
50 | x86_panic("get_pin: wrong type"); |
---|
51 | return 0; |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | void soclib_xcu_init(chdev_t *icu, lid_t lid) |
---|
56 | { |
---|
57 | size_t i; |
---|
58 | |
---|
59 | /* disable all IRQs */ |
---|
60 | for (i = 0; i < ioapic_pins; i++) { |
---|
61 | hal_ioapic_disable_entry(i); |
---|
62 | } |
---|
63 | |
---|
64 | x86_panic((char *)__func__); |
---|
65 | } |
---|
66 | |
---|
67 | void soclib_xcu_enable_irq(chdev_t *icu, uint32_t idx, uint32_t type, |
---|
68 | lid_t lid) |
---|
69 | { |
---|
70 | uint8_t dest = (uint8_t)lid; /* XXX */ |
---|
71 | uint32_t pin; |
---|
72 | uint8_t vec; |
---|
73 | |
---|
74 | pin = get_pin(idx, type); |
---|
75 | |
---|
76 | switch (type) { |
---|
77 | case HWI_TYPE: |
---|
78 | vec = VECTOR_APIC_XCU_HWI; |
---|
79 | break; |
---|
80 | case WTI_TYPE: |
---|
81 | vec = VECTOR_APIC_XCU_WTI; |
---|
82 | break; |
---|
83 | case PTI_TYPE: |
---|
84 | vec = VECTOR_APIC_XCU_PTI; |
---|
85 | break; |
---|
86 | default: |
---|
87 | x86_panic("enabling wrong irq"); |
---|
88 | } |
---|
89 | |
---|
90 | hal_ioapic_set_entry(pin, vec, dest); |
---|
91 | |
---|
92 | x86_panic((char *)__func__); |
---|
93 | } |
---|
94 | |
---|
95 | void soclib_xcu_disable_irq(chdev_t *icu, uint32_t idx, uint32_t type, |
---|
96 | lid_t lid) |
---|
97 | { |
---|
98 | uint32_t pin = get_pin(idx, type); |
---|
99 | |
---|
100 | hal_ioapic_disable_entry(pin); |
---|
101 | |
---|
102 | x86_panic((char *)__func__); |
---|
103 | } |
---|
104 | |
---|
105 | void soclib_xcu_get_masks(chdev_t *icu, lid_t lid, uint32_t *hwi_mask, |
---|
106 | uint32_t *wti_mask, uint32_t *pti_mask) |
---|
107 | { |
---|
108 | x86_panic((char *)__func__); |
---|
109 | } |
---|
110 | |
---|
111 | void soclib_xcu_set_period( chdev_t * icu, |
---|
112 | uint32_t index, |
---|
113 | uint32_t period ) |
---|
114 | { |
---|
115 | x86_panic((char *)__func__); |
---|
116 | } |
---|
117 | |
---|
118 | uint32_t soclib_xcu_ack_timer( chdev_t * icu, |
---|
119 | uint32_t index ) |
---|
120 | { |
---|
121 | x86_panic((char *)__func__); |
---|
122 | return 0; |
---|
123 | } |
---|
124 | |
---|
125 | void soclib_xcu_get_status(chdev_t *icu, lid_t lid, uint32_t *hwi_status, |
---|
126 | uint32_t *wti_status, uint32_t *pti_status) |
---|
127 | { |
---|
128 | if (lid != 0) { |
---|
129 | x86_panic("xcu_get_status should have lid==0"); |
---|
130 | } |
---|
131 | |
---|
132 | x86_panic((char *)__func__); |
---|
133 | } |
---|
134 | |
---|
135 | void soclib_xcu_send_ipi( xptr_t icu_xp, |
---|
136 | lid_t lid ) |
---|
137 | { |
---|
138 | x86_panic((char *)__func__); |
---|
139 | } |
---|
140 | |
---|
141 | uint32_t * soclib_xcu_wti_ptr( chdev_t * icu, |
---|
142 | uint32_t index ) |
---|
143 | { |
---|
144 | x86_panic((char *)__func__); |
---|
145 | return NULL; |
---|
146 | } |
---|