source: mainline/kernel/arch/mips32/src/mach/msim/msim.c

Last change on this file was 124bc22, checked in by Jakub Jermar <jakub@…>, 6 years ago

Reorganize interrupt and IRQ handling on mips32

This allows msim to use MIPS CPU interrupt numbers as IRQ numbers and
Malta to use ISA IRQ numbers as IRQ numbers. Common code can still
register MIPS CPU interrupts by their respective numbers.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Copyright (c) 2013 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup kernel_mips32
30 * @{
31 */
32/** @file
33 * @brief msim platform driver.
34 */
35
36#include <arch/mach/msim/msim.h>
37#include <arch/mach/msim/dorder.h>
38#include <console/console.h>
39#include <sysinfo/sysinfo.h>
40#include <genarch/drivers/dsrln/dsrlnin.h>
41#include <genarch/drivers/dsrln/dsrlnout.h>
42#include <genarch/srln/srln.h>
43#include <stdbool.h>
44
45static void msim_init(void);
46static void msim_cpu_halt(void);
47static void msim_get_memory_extents(uintptr_t *, size_t *);
48static void msim_frame_init(void);
49static void msim_output_init(void);
50static void msim_input_init(void);
51static const char *msim_get_platform_name(void);
52
53struct mips32_machine_ops msim_machine_ops = {
54 .machine_init = msim_init,
55 .machine_cpu_halt = msim_cpu_halt,
56 .machine_get_memory_extents = msim_get_memory_extents,
57 .machine_frame_init = msim_frame_init,
58 .machine_output_init = msim_output_init,
59 .machine_input_init = msim_input_init,
60 .machine_get_platform_name = msim_get_platform_name
61};
62
63static void msim_irq_handler(unsigned int i)
64{
65 irq_t *irq = irq_dispatch_and_lock(i);
66 if (irq) {
67 irq->handler(irq);
68 irq_spinlock_unlock(&irq->lock, false);
69 } else {
70#ifdef CONFIG_DEBUG
71 log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious IRQ (irq=%u)",
72 CPU->id, i);
73#endif
74 }
75}
76
77void msim_init(void)
78{
79 irq_init(HW_INTERRUPTS, HW_INTERRUPTS);
80
81 int_handler[INT_HW0] = msim_irq_handler;
82 int_handler[INT_HW1] = msim_irq_handler;
83 int_handler[INT_HW2] = msim_irq_handler;
84 int_handler[INT_HW3] = msim_irq_handler;
85 int_handler[INT_HW4] = msim_irq_handler;
86
87 dorder_init();
88 cp0_unmask_int(MSIM_DDISK_IRQ);
89}
90
91void msim_cpu_halt(void)
92{
93}
94
95void msim_get_memory_extents(uintptr_t *start, size_t *size)
96{
97}
98
99void msim_frame_init(void)
100{
101}
102
103void msim_output_init(void)
104{
105#ifdef CONFIG_MSIM_PRN
106 outdev_t *dsrlndev = dsrlnout_init((ioport8_t *) MSIM_KBD_ADDRESS,
107 KSEG12PA(MSIM_KBD_ADDRESS));
108 if (dsrlndev)
109 stdout_wire(dsrlndev);
110#endif
111}
112
113void msim_input_init(void)
114{
115#ifdef CONFIG_MSIM_KBD
116 /*
117 * Initialize the msim keyboard port. Then initialize the serial line
118 * module and connect it to the msim keyboard. Enable keyboard
119 * interrupts.
120 */
121 dsrlnin_instance_t *dsrlnin_instance =
122 dsrlnin_init((dsrlnin_t *) MSIM_KBD_ADDRESS, MSIM_KBD_IRQ);
123 if (dsrlnin_instance) {
124 srln_instance_t *srln_instance = srln_init();
125 if (srln_instance) {
126 indev_t *sink = stdin_wire();
127 indev_t *srln = srln_wire(srln_instance, sink);
128 dsrlnin_wire(dsrlnin_instance, srln);
129 cp0_unmask_int(MSIM_KBD_IRQ);
130 }
131 }
132#endif
133}
134
135const char *msim_get_platform_name(void)
136{
137 return "msim";
138}
139
140/** @}
141 */
Note: See TracBrowser for help on using the repository browser.