source: trunk/hal/x86_64/drivers/soclib_xcu.c @ 138

Last change on this file since 138 was 138, checked in by max@…, 7 years ago

update

File size: 3.2 KB
Line 
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
31extern size_t ioapic_pins;
32
33/*
34 * These indexes are used to translate a type::idx to a pin on the IOAPIC.
35 */
36uint32_t hwi_baseidx __in_kdata = 0;
37uint32_t wti_baseidx __in_kdata = 0;
38uint32_t pti_baseidx __in_kdata = 0;
39
40static 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
55void 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
67void 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                case WTI_TYPE:
80                        vec = VECTOR_APIC_XCU_WTI;
81                case PTI_TYPE:
82                        vec = VECTOR_APIC_XCU_PTI;
83                default:
84                        x86_panic("enabling wrong irq");
85        }
86
87        hal_ioapic_set_entry(pin, vec, dest);
88
89        x86_panic((char *)__func__);
90}
91
92void soclib_xcu_disable_irq(chdev_t *icu, uint32_t idx, uint32_t type,
93    lid_t lid)
94{
95        uint32_t pin = get_pin(idx, type);
96
97        hal_ioapic_disable_entry(pin);
98
99        x86_panic((char *)__func__);
100}
101
102void soclib_xcu_get_masks(chdev_t *icu, lid_t lid, uint32_t *hwi_mask,
103    uint32_t *wti_mask, uint32_t *pti_mask)
104{
105        x86_panic((char *)__func__);
106}
107
108void soclib_xcu_set_period( chdev_t * icu,
109                            uint32_t  index,
110                            uint32_t  period )
111{
112        x86_panic((char *)__func__);
113}
114
115uint32_t soclib_xcu_ack_timer( chdev_t * icu,
116                               uint32_t  index )
117{
118        x86_panic((char *)__func__);
119        return 0;
120}
121
122void soclib_xcu_get_status(chdev_t *icu, lid_t lid, uint32_t *hwi_status,
123    uint32_t *wti_status, uint32_t *pti_status)
124{
125        if (lid != 0) {
126                x86_panic("xcu_get_status should have lid==0");
127        }
128
129        x86_panic((char *)__func__);
130}
131
132void soclib_xcu_send_ipi( xptr_t  icu_xp,
133                          lid_t   lid )
134{
135        x86_panic((char *)__func__);
136}
137
138uint32_t * soclib_xcu_wti_ptr( chdev_t  * icu,
139                               uint32_t   index )
140{
141        x86_panic((char *)__func__);
142        return NULL;
143}
Note: See TracBrowser for help on using the repository browser.