source: rtems/c/src/lib/libbsp/powerpc/mpc55xxevb/startup/bspstart.c @ b1e8a58

4.115
Last change on this file since b1e8a58 was b1e8a58, checked in by Sebastian Huber <sebastian.huber@…>, on 11/14/12 at 08:57:55

bsps/powerpc: Exception initialization error is fatal

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[574fb67]1/**
2 * @file
3 *
4 * @ingroup mpc55xx
5 *
6 * @brief BSP startup code.
7 */
8
9/*
[9e7758b]10 * Copyright (c) 2008-2011 embedded brains GmbH.  All rights reserved.
[574fb67]11 *
[9e7758b]12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
[574fb67]21 */
22
23#include <mpc55xx/mpc55xx.h>
24#include <mpc55xx/regs.h>
25#include <mpc55xx/edma.h>
[2f5435a4]26#include <mpc55xx/emios.h>
[9e7758b]27
28#include <string.h>
[574fb67]29
30#include <rtems.h>
[9e7758b]31#include <rtems/config.h>
[574fb67]32
33#include <libcpu/powerpc-utility.h>
[2d2de4eb]34#include <bsp/vectors.h>
[574fb67]35
36#include <bsp.h>
[d4886a06]37#include <bsp/bootcard.h>
[574fb67]38#include <bsp/irq.h>
39#include <bsp/irq-generic.h>
[9e7758b]40#include <bsp/linker-symbols.h>
41#include <bsp/start.h>
42#include <bsp/mpc55xx-config.h>
[574fb67]43
44/* Symbols defined in linker command file */
[9e7758b]45LINKER_SYMBOL(mpc55xx_exc_vector_base);
[574fb67]46
47unsigned int bsp_clock_speed = 0;
48
49uint32_t bsp_clicks_per_usec = 0;
50
51void BSP_panic( char *s)
52{
53        rtems_interrupt_level level;
54
55        rtems_interrupt_disable( level);
56
57        printk( "%s PANIC %s\n", _RTEMS_version, s);
58
59        while (1) {
60                /* Do nothing */
61        }
62}
63
64void _BSP_Fatal_error( unsigned n)
65{
66        rtems_interrupt_level level;
67
68        rtems_interrupt_disable( level);
69
70        printk( "%s PANIC ERROR %u\n", _RTEMS_version, n);
71
72        while (1) {
73                /* Do nothing */
74        }
75}
76
[9e7758b]77static void null_pointer_protection(void)
[574fb67]78{
[b9b3f3b7]79#ifdef MPC55XX_NULL_POINTER_PROTECTION
[9e7758b]80        struct MMU_tag mmu = { .MAS0 = { .B = { .TLBSEL = 1, .ESEL = 1 } } };
81
82        PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS0, mmu.MAS0.R);
83        __asm__ volatile ("tlbre");
84        mmu.MAS1.R = PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1);
85        mmu.MAS1.B.VALID = 0;
86        PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1, mmu.MAS1.R);
87        __asm__ volatile ("tlbwe");
[dbb3211a]88#endif
[574fb67]89}
90
91void bsp_start(void)
92{
93        ppc_cpu_id_t myCpu;
94        ppc_cpu_revision_t myCpuRevision;
95
[9e7758b]96        null_pointer_protection();
[08013e8]97
98        /*
99         * make sure BSS/SBSS is cleared
100         */
[9e7758b]101        memset(&bsp_section_bss_begin [0], 0, (size_t) bsp_section_bss_size);
[ac7af4a]102
[574fb67]103        /*
104         * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
105         * function store the result in global variables so that it can be used
106         * latter...
107         */
108        myCpu = get_ppc_cpu_type();
109        myCpuRevision = get_ppc_cpu_revision();
[ac7af4a]110
[08013e8]111        /*
112         * determine clock speed
113         */
[dafacfa7]114        bsp_clock_speed = mpc55xx_get_system_clock() / MPC55XX_SYSTEM_CLOCK_DIVIDER;
[ac7af4a]115
[dbb3211a]116        /* Time reference value */
117        bsp_clicks_per_usec = bsp_clock_speed / 1000000;
118
[574fb67]119        /* Initialize exceptions */
[9e7758b]120        ppc_exc_vector_base = (uint32_t) mpc55xx_exc_vector_base;
[b1e8a58]121        ppc_exc_initialize(
[2d2de4eb]122                PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
[9e7758b]123                (uintptr_t) bsp_section_work_begin,
[75524a5e]124                rtems_configuration_get_interrupt_stack_size()
[2d2de4eb]125        );
[601d500]126        ppc_exc_set_handler(ASM_ALIGN_VECTOR, ppc_exc_alignment_handler);
[574fb67]127
128        /* Initialize interrupts */
[dd8df59]129        bsp_interrupt_initialize();
[ac7af4a]130
[9e7758b]131        mpc55xx_edma_init();
[a762dc2]132        #ifdef MPC55XX_EMIOS_PRESCALER
133                mpc55xx_emios_initialize(MPC55XX_EMIOS_PRESCALER);
134        #endif
135}
Note: See TracBrowser for help on using the repository browser.