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

4.115
Last change on this file since 801b5d8 was 801b5d8, checked in by Sebastian Huber <sebastian.huber@…>, on 02/17/14 at 08:23:59

powerpc: Change interrupt disable implemetation

Instead of SPRG0 (= special purpose register 272) use the new global
symbol _PPC_INTERRUPT_DISABLE_MASK to store the interrupt disable mask.
The benefit is that it is now possible to disable interrupts without
further run-time initialization in boot_card().

At least on Freescale e500 cores this leads also to a faster execution
since the mfmsr and mfspr instruction require four cycles to complete.
The instructions to load the mask value can execute while the mfmsr is
in progress.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc55xx
5 *
6 * @brief BSP startup code.
7 */
8
9/*
10 * Copyright (c) 2008-2013 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
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.
21 */
22
23#include <mpc55xx/mpc55xx.h>
24#include <mpc55xx/regs.h>
25#include <mpc55xx/edma.h>
26#include <mpc55xx/emios.h>
27
28#include <string.h>
29
30#include <rtems.h>
31#include <rtems/config.h>
32#include <rtems/counter.h>
33
34#include <libcpu/powerpc-utility.h>
35#include <bsp/vectors.h>
36
37#include <bsp.h>
38#include <bsp/bootcard.h>
39#include <bsp/irq.h>
40#include <bsp/irq-generic.h>
41#include <bsp/linker-symbols.h>
42#include <bsp/start.h>
43#include <bsp/mpc55xx-config.h>
44
45/* Symbols defined in linker command file */
46LINKER_SYMBOL(mpc55xx_exc_vector_base);
47
48unsigned int bsp_clock_speed = 0;
49
50uint32_t bsp_clicks_per_usec = 0;
51
52void _BSP_Fatal_error(unsigned n)
53{
54        rtems_interrupt_level level;
55
56        (void) level;
57        rtems_interrupt_disable( level);
58
59        while (true) {
60                mpc55xx_wait_for_interrupt();
61        }
62}
63
64void mpc55xx_fatal(mpc55xx_fatal_code code)
65{
66  rtems_fatal(RTEMS_FATAL_SOURCE_BSP_SPECIFIC, code);
67}
68
69static void null_pointer_protection(void)
70{
71#ifdef MPC55XX_NULL_POINTER_PROTECTION
72        struct MMU_tag mmu = { .MAS0 = { .B = { .TLBSEL = 1, .ESEL = 1 } } };
73
74        PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS0, mmu.MAS0.R);
75        __asm__ volatile ("tlbre");
76        mmu.MAS1.R = PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1);
77        mmu.MAS1.B.VALID = 0;
78        PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1, mmu.MAS1.R);
79        __asm__ volatile ("tlbwe");
80#endif
81}
82
83void bsp_start(void)
84{
85        null_pointer_protection();
86
87        /*
88         * make sure BSS/SBSS is cleared
89         */
90        memset(&bsp_section_bss_begin [0], 0, (size_t) bsp_section_bss_size);
91
92        /*
93         * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
94         * function store the result in global variables so that it can be used
95         * latter...
96         */
97        get_ppc_cpu_type();
98        get_ppc_cpu_revision();
99
100        /*
101         * determine clock speed
102         */
103        bsp_clock_speed = mpc55xx_get_system_clock() / MPC55XX_SYSTEM_CLOCK_DIVIDER;
104
105        /* Time reference value */
106        bsp_clicks_per_usec = bsp_clock_speed / 1000000;
107        rtems_counter_initialize_converter(bsp_clock_speed);
108
109        /* Initialize exceptions */
110        ppc_exc_initialize_with_vector_base(
111                (uintptr_t) bsp_section_work_begin,
112                rtems_configuration_get_interrupt_stack_size(),
113                mpc55xx_exc_vector_base
114        );
115        #ifndef PPC_EXC_CONFIG_USE_FIXED_HANDLER
116                ppc_exc_set_handler(ASM_ALIGN_VECTOR, ppc_exc_alignment_handler);
117        #endif
118
119        /* Initialize interrupts */
120        bsp_interrupt_initialize();
121
122        #if MPC55XX_CHIP_FAMILY != 566
123                mpc55xx_edma_init();
124        #endif
125
126        #ifdef MPC55XX_EMIOS_PRESCALER
127                mpc55xx_emios_initialize(MPC55XX_EMIOS_PRESCALER);
128        #endif
129}
Note: See TracBrowser for help on using the repository browser.