source: mainline/kernel/arch/sparc32/src/machine/leon3/leon3.c@ e76fed9

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since e76fed9 was e76fed9, checked in by Jakub Klama <jakub.klama@…>, 12 years ago

Separate architecture-dependent code from machine-dependent.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Copyright (c) 2013 Jakub Klama
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 sparc32
30 * @{
31 */
32/** @file
33 */
34
35#include <arch.h>
36#include <typedefs.h>
37#include <arch/interrupt.h>
38#include <arch/asm.h>
39#include <arch/machine_func.h>
40
41#include <arch/machine/leon3/leon3.h>
42
43#include <genarch/drivers/grlib_uart/grlib_uart.h>
44#include <genarch/drivers/grlib_irqmp/grlib_irqmp.h>
45
46#include <func.h>
47#include <config.h>
48#include <errno.h>
49#include <context.h>
50#include <fpu_context.h>
51#include <interrupt.h>
52#include <syscall/copy.h>
53#include <ddi/irq.h>
54#include <proc/thread.h>
55#include <syscall/syscall.h>
56#include <console/console.h>
57#include <macros.h>
58#include <memstr.h>
59#include <str.h>
60
61static void leon3_init(bootinfo_t *);
62static void leon3_cpu_halt(void);
63static void leon3_get_memory_extents(uintptr_t *, size_t *);
64static void leon3_timer_start(void);
65static void leon3_irq_exception(unsigned int, istate_t *);
66static void leon3_output_init(void);
67static void leon3_input_init(void);
68static size_t leon3_get_irq_count(void);
69static const char *leon3_get_platform_name(void);
70
71struct leon3_machine_t
72{
73 bootinfo_t *bootinfo;
74 outdev_t *scons_dev;
75 grlib_irqmp_t irqmp;
76 //grlib_timer_t timer;
77};
78
79struct sparc_machine_ops leon3_machine_ops = {
80 leon3_init,
81 leon3_cpu_halt,
82 leon3_get_memory_extents,
83 leon3_timer_start,
84 leon3_irq_exception,
85 leon3_output_init,
86 leon3_input_init,
87 leon3_get_irq_count,
88 leon3_get_platform_name
89};
90
91static struct leon3_machine_t machine;
92
93static void leon3_init(bootinfo_t *bootinfo)
94{
95 machine.bootinfo = bootinfo;
96
97 grlib_irqmp_init(&machine.irqmp, bootinfo);
98}
99
100static void leon3_cpu_halt(void)
101{
102 for (;;);
103}
104
105static void leon3_get_memory_extents(uintptr_t *start, size_t *size)
106{
107 *start = LEON3_SDRAM_START;
108 *size = machine.bootinfo->memsize;
109}
110
111static void leon3_timer_start(void)
112{
113 //machine.timer = grlib_timer_init(machine.bootinfo->timer_base, machine.bootinfo->timer_irq);
114}
115
116static void leon3_irq_exception(unsigned int exc_no, istate_t *istate)
117{
118 int irqnum = grlib_irqmp_inum_get(&machine.irqmp);
119
120 grlib_irqmp_clear(&machine.irqmp, irqnum);
121
122 irq_t *irq = irq_dispatch_and_lock(irqnum);
123 if (irq) {
124 irq->handler(irq);
125 spinlock_unlock(&irq->lock);
126 } else
127 printf("cpu%d: spurious interrupt (irq=%d)\n", CPU->id, irqnum);
128}
129
130static void leon3_output_init(void)
131{
132 machine.scons_dev = grlib_uart_init(machine.bootinfo->uart_base, machine.bootinfo->uart_irq);
133
134 if (machine.scons_dev)
135 stdout_wire(machine.scons_dev);
136}
137
138static void leon3_input_init(void)
139{
140 if (machine.scons_dev) {
141
142 }
143}
144
145static size_t leon3_get_irq_count(void)
146{
147 return LEON3_IRQ_COUNT;
148}
149
150static const char *leon3_get_platform_name(void)
151{
152 return "LEON3";
153}
154
155
Note: See TracBrowser for help on using the repository browser.