source: rtems/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c @ 574fb67

4.104.114.9
Last change on this file since 574fb67 was 574fb67, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on Jul 14, 2008 at 4:15:28 PM

updated gen83xx BSP
updated haleakala BSP
added MPC55xx BSP

  • Property mode set to 100644
File size: 4.3 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/irq-generic.h>
33#include <bsp/ppc_exc_bspsupp.h>
34
35#ifdef HAS_UBOOT
36
37/*
38 * We want this in the data section, because the startup code clears the BSS
39 * section after the initialization of the board info.
40 */
41bd_t mpc83xx_uboot_board_info = { .bi_baudrate = 123 };
42
43/* Size in words */
44const size_t mpc83xx_uboot_board_info_size = (sizeof( bd_t) + 3) / 4;
45
46#endif /* HAS_UBOOT */
47
48/* Configuration parameters for console driver, ... */
49unsigned int BSP_bus_frequency;
50
51/* Configuration parameters for clock driver, ... */
52uint32_t bsp_clicks_per_usec;
53
54static char *BSP_heap_start, *BSP_heap_end;
55
56/*
57 *  Use the shared implementations of the following routines.
58 *  Look in rtems/c/src/lib/libbsp/shared/bsplibc.c.
59 */
60extern void cpu_init( void);
61
62void BSP_panic( char *s)
63{
64        rtems_interrupt_level level;
65
66        rtems_interrupt_disable( level);
67
68        printk( "%s PANIC %s\n", _RTEMS_version, s);
69
70        while (1) {
71                /* Do nothing */
72        }
73}
74
75void _BSP_Fatal_error( unsigned n)
76{
77        rtems_interrupt_level level;
78
79        rtems_interrupt_disable( level);
80
81        printk( "%s PANIC ERROR %u\n", _RTEMS_version, n);
82
83        while (1) {
84                /* Do nothing */
85        }
86}
87
88void bsp_pretasking_hook( void)
89{
90        /* Initialize libc including the heap */
91        bsp_libc_init( BSP_heap_start, BSP_heap_end - BSP_heap_start, 0);
92}
93
94void bsp_calc_mem_layout()
95{
96        size_t workspace_size = rtems_configuration_get_work_space_size();
97
98        /* We clear the workspace here */
99        Configuration.do_zero_of_workspace = 0;
100        /*
101        TODO
102        mpc83xx_zero_4( bsp_workspace_start, workspace_size);
103         */
104        mpc83xx_zero_4( bsp_interrupt_stack_start, bsp_ram_end - bsp_interrupt_stack_start);
105
106        Configuration.work_space_start = bsp_workspace_start;
107
108        BSP_heap_start = (char *) Configuration.work_space_start + workspace_size;
109
110#ifdef HAS_UBOOT
111        BSP_heap_end = mpc83xx_uboot_board_info.bi_memstart + mpc83xx_uboot_board_info.bi_memsize;
112#else /* HAS_UBOOT */
113        BSP_heap_end = bsp_ram_end;
114#endif /* HAS_UBOOT */
115}
116
117void bsp_start( void)
118{
119        ppc_cpu_id_t myCpu;
120        ppc_cpu_revision_t myCpuRevision;
121
122        uint32_t interrupt_stack_start = (uint32_t) bsp_interrupt_stack_start;
123        uint32_t interrupt_stack_size = (uint32_t) bsp_interrupt_stack_size;
124
125        /*
126         * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
127         * store the result in global variables so that it can be used latter...
128         */
129        myCpu = get_ppc_cpu_type();
130        myCpuRevision = get_ppc_cpu_revision();
131
132        /* Determine heap and workspace placement */
133        bsp_calc_mem_layout();
134
135        cpu_init();
136
137        /*
138         * This is evaluated during runtime, so it should be ok to set it
139         * before we initialize the drivers.
140         */
141
142        /* Initialize some device driver parameters */
143
144#ifdef HAS_UBOOT
145        BSP_bus_frequency = mpc83xx_uboot_board_info.bi_busfreq;
146#else /* HAS_UBOOT */
147        BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
148#endif /* HAS_UBOOT */
149
150        bsp_clicks_per_usec = BSP_bus_frequency / 4000000;
151
152        /*
153         * Enable instruction and data caches. Do not force writethrough mode.
154         */
155
156#if INSTRUCTION_CACHE_ENABLE
157        rtems_cache_enable_instruction();
158#endif
159
160#if DATA_CACHE_ENABLE
161        rtems_cache_enable_data();
162#endif
163
164        /* Initialize exception handler */
165        ppc_exc_initialize(
166                PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
167                interrupt_stack_start,
168                interrupt_stack_size
169        );
170
171        /* Initalize interrupt support */
172        if (bsp_interrupt_initialize() != RTEMS_SUCCESSFUL) {
173                BSP_panic("Cannot intitialize interrupt support\n");
174        }
175
176#ifdef SHOW_MORE_INIT_SETTINGS
177        printk("Exit from bspstart\n");
178#endif
179}
180
181/**
182 * @brief Idle thread body.
183 *
184 * Replaces the one in c/src/exec/score/src/threadidlebody.c
185 * The MSR[POW] bit is set to put the CPU into the low power mode
186 * defined in HID0.  HID0 is set during starup in start.S.
187 */
188Thread _Thread_Idle_body( uint32_t ignored)
189{
190
191        while (1) {
192                asm volatile (
193                        "mfmsr 3;"
194                        "oris 3, 3, 4;"
195                        "sync;"
196                        "mtmsr 3;"
197                        "isync;"
198                        "ori 3, 3, 0;"
199                        "ori 3, 3, 0"
200                );
201        }
202
203        return NULL;
204}
Note: See TracBrowser for help on using the repository browser.