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
RevLine 
[75]1/*
[138]2 * soclib_xcu.c - x86 XCU driver API implementation.
[75]3 *
[138]4 * Copyright (c) 2017 Maxime Villard
[75]5 *
6 * This file is part of ALMOS-MKH.
7 *
[138]8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
[75]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 *
[138]12 * ALMOS-MKH is distributed in the hope that it will be useful, but
[75]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
[138]18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
[75]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
[135]27#include <hal_apic.h>
[138]28#include <hal_segmentation.h>
[129]29#include <hal_internal.h>
30
[135]31extern size_t ioapic_pins;
32
[137]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
[138]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
[135]55void soclib_xcu_init(chdev_t *icu, lid_t lid)
[75]56{
[135]57        size_t i;
58
59        /* disable all IRQs */
60        for (i = 0; i < ioapic_pins; i++) {
[137]61                hal_ioapic_disable_entry(i);
[135]62        }
63
[129]64        x86_panic((char *)__func__);
[75]65}
66
[137]67void soclib_xcu_enable_irq(chdev_t *icu, uint32_t idx, uint32_t type,
68    lid_t lid)
[75]69{
[138]70        uint8_t dest = (uint8_t)lid; /* XXX */
[137]71        uint32_t pin;
[138]72        uint8_t vec;
[137]73
[138]74        pin = get_pin(idx, type);
75
[137]76        switch (type) {
77                case HWI_TYPE:
[138]78                        vec = VECTOR_APIC_XCU_HWI;
[137]79                case WTI_TYPE:
[138]80                        vec = VECTOR_APIC_XCU_WTI;
[137]81                case PTI_TYPE:
[138]82                        vec = VECTOR_APIC_XCU_PTI;
[137]83                default:
84                        x86_panic("enabling wrong irq");
85        }
86
[138]87        hal_ioapic_set_entry(pin, vec, dest);
88
[129]89        x86_panic((char *)__func__);
[75]90}
91
[137]92void soclib_xcu_disable_irq(chdev_t *icu, uint32_t idx, uint32_t type,
93    lid_t lid)
[75]94{
[138]95        uint32_t pin = get_pin(idx, type);
96
97        hal_ioapic_disable_entry(pin);
98
[129]99        x86_panic((char *)__func__);
[75]100}
101
[138]102void soclib_xcu_get_masks(chdev_t *icu, lid_t lid, uint32_t *hwi_mask,
103    uint32_t *wti_mask, uint32_t *pti_mask)
[75]104{
[129]105        x86_panic((char *)__func__);
[75]106}
107
108void soclib_xcu_set_period( chdev_t * icu,
109                            uint32_t  index,
110                            uint32_t  period )
111{
[129]112        x86_panic((char *)__func__);
[75]113}
114
115uint32_t soclib_xcu_ack_timer( chdev_t * icu,
116                               uint32_t  index )
117{
[129]118        x86_panic((char *)__func__);
[81]119        return 0;
[75]120}
121
[137]122void soclib_xcu_get_status(chdev_t *icu, lid_t lid, uint32_t *hwi_status,
123    uint32_t *wti_status, uint32_t *pti_status)
[75]124{
[137]125        if (lid != 0) {
126                x86_panic("xcu_get_status should have lid==0");
127        }
128
[129]129        x86_panic((char *)__func__);
[75]130}
131
132void soclib_xcu_send_ipi( xptr_t  icu_xp,
133                          lid_t   lid )
134{
[129]135        x86_panic((char *)__func__);
[75]136}
137
138uint32_t * soclib_xcu_wti_ptr( chdev_t  * icu,
139                               uint32_t   index )
140{
[129]141        x86_panic((char *)__func__);
[81]142        return NULL;
[75]143}
Note: See TracBrowser for help on using the repository browser.