Project

General

Profile

Statistics
| Branch: | Revision:

scoutos / prex-0.9.0 / bsp / hal / arm / integrator / machdep.c @ 03e9c04a

History | View | Annotate | Download (3.57 KB)

1 03e9c04a Brad Neuman
/*-
2
 * Copyright (c) 2008-2009, Kohsuke Ohtani
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
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. Neither the name of the author nor the names of any co-contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29
30
/*
31
 * machdep.c - machine-dependent routines for ARM Integrator-CP
32
 */
33
34
#include <machine/syspage.h>
35
#include <sys/power.h>
36
#include <sys/bootinfo.h>
37
#include <kernel.h>
38
#include <page.h>
39
#include <mmu.h>
40
#include <cpu.h>
41
#include <cpufunc.h>
42
#include <locore.h>
43
44
#include "platform.h"
45
46
/* System control reg */
47
#define SC_CTRL                (*(volatile uint32_t *)(FPGA_BASE + 0x0c))
48
49
#define SCCTRL_SOFTRESET        0x08
50
51
#ifdef CONFIG_MMU
52
/*
53
 * Virtual and physical address mapping
54
 *
55
 *      { virtual, physical, size, type }
56
 */
57
struct mmumap mmumap_table[] =
58
{
59
        /*
60
         * Internal SRAM (4M)
61
         */
62
        { 0x80000000, 0x00000000, 0x400000, VMT_RAM },
63
64
        /*
65
         * FPGA core control (4K)
66
         */
67
        { 0xD0000000, 0x10000000, 0x1000, VMT_IO },
68
69
        /*
70
         * Counter/Timers (1M)
71
         */
72
        { 0xD3000000, 0x13000000, 0x100000, VMT_IO },
73
74
        /*
75
         * Interrupt controller (1M)
76
         */
77
        { 0xD4000000, 0x14000000, 0x100000, VMT_IO },
78
79
        /*
80
         * Real-time clock (1M)
81
         */
82
        { 0xD5000000, 0x15000000, 0x100000, VMT_IO },
83
84
        /*
85
         * UART 0 (1M)
86
         */
87
        { 0xD6000000, 0x16000000, 0x100000, VMT_IO },
88
89
        { 0,0,0,0 }
90
};
91
#endif
92
93
/*
94
 * Idle
95
 */
96
void
97
machine_idle(void)
98
{
99
100
        cpu_idle();
101
}
102
103
/*
104
 * Reset system.
105
 */
106
static void
107
machine_reset(void)
108
{
109
110
        SC_CTRL = SCCTRL_SOFTRESET;
111
112
        for (;;) ;
113
        /* NOTREACHED */
114
}
115
116
/*
117
 * Set system power
118
 */
119
void
120
machine_powerdown(int state)
121
{
122
123
        splhigh();
124
125
        DPRINTF(("Power down machine\n"));
126
127
        switch (state) {
128
        case PWR_OFF:
129
                for (;;)
130
                        cpu_idle();
131
                /* NOTREACHED */
132
                break;
133
        case PWR_REBOOT:
134
                machine_reset();
135
                /* NOTREACHED */
136
                break;
137
        }
138
}
139
140
/*
141
 * Return pointer to the boot information.
142
 */
143
void
144
machine_bootinfo(struct bootinfo **bip)
145
{
146
147
        *bip = (struct bootinfo *)BOOTINFO;
148
}
149
150
void
151
machine_abort(void)
152
{
153
154
        for (;;)
155
                cpu_idle();
156
}
157
158
/*
159
 * Machine-dependent startup code
160
 */
161
void
162
machine_startup(void)
163
{
164
165
        /*
166
         * Initialize CPU and basic hardware.
167
         */
168
        cpu_init();
169
        cache_init();
170
171
        /*
172
         * Reserve system pages.
173
         */
174
        page_reserve(kvtop(SYSPAGE), SYSPAGESZ);
175
176
        /*
177
         * Setup vector page.
178
         */
179
        vector_copy((vaddr_t)ptokv(CONFIG_ARM_VECTORS));
180
181
#ifdef CONFIG_MMU
182
        /*
183
         * Initialize MMU
184
         */
185
        mmu_init(mmumap_table);
186
#endif
187
}