source: rtems/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c @ 9a85541

4.104.114.95
Last change on this file since 9a85541 was 541c9e84, checked in by Joel Sherrill <joel.sherrill@…>, on 08/18/08 at 13:40:15

2008-08-18 Sebastian Huber <sebastian.huber@…>

  • Makefile.am, startup/bspstart.c, startup/cpuinit.c: For the MPC8313ERDB -- The BAT entry for the eLBC was missing and add hard reset sequence in bsp_cleanup().
  • Property mode set to 100644
File size: 4.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc83xx
5 *
6 * @brief Source for BSP startup code.
7 */
8
9/*
10 * Copyright (c) 2008
11 * Embedded Brains GmbH
12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
15 * rtems@embedded-brains.de
16 *
17 * The license and distribution terms for this file may be found in the file
18 * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
19 *
20 * $Id$
21 */
22
23#include <string.h>
24
25#include <rtems/libio.h>
26#include <rtems/libcsupport.h>
27#include <rtems/score/thread.h>
28
29#include <libcpu/powerpc-utility.h>
30
31#include <bsp.h>
32#include <bsp/bootcard.h>
33#include <bsp/irq-generic.h>
34#include <bsp/ppc_exc_bspsupp.h>
35
36#ifdef HAS_UBOOT
37
38/*
39 * We want this in the data section, because the startup code clears the BSS
40 * section after the initialization of the board info.
41 */
42bd_t mpc83xx_uboot_board_info = { .bi_baudrate = 123 };
43
44/* Size in words */
45const size_t mpc83xx_uboot_board_info_size = (sizeof( bd_t) + 3) / 4;
46
47#endif /* HAS_UBOOT */
48
49/* Configuration parameters for console driver, ... */
50unsigned int BSP_bus_frequency;
51
52/* Configuration parameters for clock driver, ... */
53uint32_t bsp_clicks_per_usec;
54
55/*
56 *  Use the shared implementations of the following routines.
57 *  Look in rtems/c/src/lib/libbsp/shared/bsplibc.c.
58 */
59extern void cpu_init( void);
60
61void BSP_panic( char *s)
62{
63        rtems_interrupt_level level;
64
65        rtems_interrupt_disable( level);
66
67        printk( "%s PANIC %s\n", _RTEMS_version, s);
68
69        while (1) {
70                /* Do nothing */
71        }
72}
73
74void _BSP_Fatal_error( unsigned n)
75{
76        rtems_interrupt_level level;
77
78        rtems_interrupt_disable( level);
79
80        printk( "%s PANIC ERROR %u\n", _RTEMS_version, n);
81
82        while (1) {
83                /* Do nothing */
84        }
85}
86
87void bsp_pretasking_hook( void)
88{
89        /* Do noting */
90}
91
92void bsp_get_work_area( void **work_area_start, size_t *work_area_size, void **heap_start, size_t *heap_size)
93{
94#ifdef HAS_UBOOT
95        char *ram_end = (char *) mpc83xx_uboot_board_info.bi_memstart + mpc83xx_uboot_board_info.bi_memsize;
96#else /* HAS_UBOOT */
97        char *ram_end = bsp_ram_end;
98#endif /* HAS_UBOOT */
99
100        *work_area_start = bsp_work_area_start;
101        *work_area_size = ram_end - bsp_work_area_start;
102        *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
103        *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT;
104}
105
106void bsp_start( void)
107{
108        ppc_cpu_id_t myCpu;
109        ppc_cpu_revision_t myCpuRevision;
110
111        uint32_t interrupt_stack_start = (uint32_t) bsp_interrupt_stack_start;
112        uint32_t interrupt_stack_size = (uint32_t) bsp_interrupt_stack_size;
113
114        /*
115         * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
116         * store the result in global variables so that it can be used latter...
117         */
118        myCpu = get_ppc_cpu_type();
119        myCpuRevision = get_ppc_cpu_revision();
120
121        /* Basic CPU initialization */
122        cpu_init();
123
124        /*
125         * Enable instruction and data caches. Do not force writethrough mode.
126         */
127
128#if INSTRUCTION_CACHE_ENABLE
129        rtems_cache_enable_instruction();
130#endif
131
132#if DATA_CACHE_ENABLE
133        rtems_cache_enable_data();
134#endif
135
136        /*
137         * This is evaluated during runtime, so it should be ok to set it
138         * before we initialize the drivers.
139         */
140
141        /* Initialize some device driver parameters */
142
143#ifdef HAS_UBOOT
144        BSP_bus_frequency = mpc83xx_uboot_board_info.bi_busfreq;
145        bsp_clicks_per_usec = mpc83xx_uboot_board_info.bi_intfreq / 8000000;
146#else /* HAS_UBOOT */
147        BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
148        bsp_clicks_per_usec = BSP_bus_frequency / 1000000;
149#endif /* HAS_UBOOT */
150
151        /* Initialize exception handler */
152        ppc_exc_initialize(
153                PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
154                interrupt_stack_start,
155                interrupt_stack_size
156        );
157
158        /* Initalize interrupt support */
159        if (bsp_interrupt_initialize() != RTEMS_SUCCESSFUL) {
160                BSP_panic("Cannot intitialize interrupt support\n");
161        }
162
163#ifdef SHOW_MORE_INIT_SETTINGS
164        printk("Exit from bspstart\n");
165#endif
166}
167
168/**
169 * @brief Idle thread body.
170 *
171 * Replaces the one in c/src/exec/score/src/threadidlebody.c
172 * The MSR[POW] bit is set to put the CPU into the low power mode
173 * defined in HID0.  HID0 is set during starup in start.S.
174 */
175Thread _Thread_Idle_body( uint32_t ignored)
176{
177
178        while (1) {
179                asm volatile (
180                        "mfmsr 3;"
181                        "oris 3, 3, 4;"
182                        "sync;"
183                        "mtmsr 3;"
184                        "isync;"
185                        "ori 3, 3, 0;"
186                        "ori 3, 3, 0"
187                );
188        }
189
190        return NULL;
191}
192
193void bsp_cleanup( void)
194{
195#ifdef MPC8313ERDB
196
197        /* Set Reset Protection Register (RPR) to "RSTE" */
198        mpc83xx.res.rpr = 0x52535445;
199
200        /*
201         * Wait for Control Register Enabled in the
202         * Reset Control Enable Register (RCER).
203         */
204        while (mpc83xx.res.rcer != 0x00000001) {
205                /* Wait */
206        }
207
208        /* Set Software Hard Reset in the Reset Control Register (RCR) */
209        mpc83xx.res.rcr = 0x00000002;
210
211#else /* MPC8313ERDB */
212
213        /* Do nothing */
214
215#endif /* MPC8313ERDB */
216}
Note: See TracBrowser for help on using the repository browser.