source: rtems/bsps/powerpc/t32mppc/start/bspstart.c

Last change on this file was bcef89f2, checked in by Sebastian Huber <sebastian.huber@…>, on 05/19/23 at 06:18:25

Update company name

The embedded brains GmbH & Co. KG is the legal successor of embedded
brains GmbH.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * Copyright (C) 2012, 2017 embedded brains GmbH & Co. KG
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <rtems/config.h>
29#include <rtems/counter.h>
30
31#include <bsp.h>
32#include <bsp/vectors.h>
33#include <bsp/bootcard.h>
34#include <bsp/irq-generic.h>
35#include <bsp/linker-symbols.h>
36
37LINKER_SYMBOL(bsp_exc_vector_base);
38
39/*
40 * Configuration parameter for clock driver.  The Trace32 PowerPC simulator has
41 * an odd decrementer frequency.  The time base frequency is one tick per
42 * instruction.  The decrementer frequency is one tick per ten instructions.
43 * The clock driver assumes that the time base and decrementer frequencies are
44 * equal.  For now we simulate processor that issues 10000000 instructions per
45 * second.
46 */
47uint32_t bsp_time_base_frequency = 10000000;
48
49#define MTIVPR(base) \
50  __asm__ volatile ("mtivpr %0" : : "r" (base))
51
52#define VECTOR_TABLE_ENTRY_SIZE 16
53
54#define MTIVOR(vec, offset) \
55  do { \
56    __asm__ volatile ("mtspr " RTEMS_XSTRING(vec) ", %0" : : "r" (offset)); \
57    offset += VECTOR_TABLE_ENTRY_SIZE; \
58  } while (0)
59
60static void t32mppc_initialize_exceptions(void)
61{
62  uintptr_t addr;
63
64  ppc_exc_initialize_interrupt_stack(
65    (uintptr_t) _ISR_Stack_area_begin
66  );
67
68  addr = (uintptr_t) bsp_exc_vector_base;
69  MTIVPR(addr);
70  MTIVOR(BOOKE_IVOR0,  addr);
71  MTIVOR(BOOKE_IVOR1,  addr);
72  MTIVOR(BOOKE_IVOR2,  addr);
73  MTIVOR(BOOKE_IVOR3,  addr);
74  MTIVOR(BOOKE_IVOR4,  addr);
75  MTIVOR(BOOKE_IVOR5,  addr);
76  MTIVOR(BOOKE_IVOR6,  addr);
77  MTIVOR(BOOKE_IVOR7,  addr);
78  MTIVOR(BOOKE_IVOR8,  addr);
79  MTIVOR(BOOKE_IVOR9,  addr);
80  MTIVOR(BOOKE_IVOR10, addr);
81  MTIVOR(BOOKE_IVOR11, addr);
82  MTIVOR(BOOKE_IVOR12, addr);
83  MTIVOR(BOOKE_IVOR13, addr);
84  MTIVOR(BOOKE_IVOR14, addr);
85  MTIVOR(BOOKE_IVOR15, addr);
86  MTIVOR(BOOKE_IVOR32, addr);
87  MTIVOR(BOOKE_IVOR33, addr);
88  MTIVOR(BOOKE_IVOR34, addr);
89  MTIVOR(BOOKE_IVOR35, addr);
90}
91
92uint32_t _CPU_Counter_frequency(void)
93{
94  return bsp_time_base_frequency;
95}
96
97void bsp_start(void)
98{
99  get_ppc_cpu_type();
100  get_ppc_cpu_revision();
101  t32mppc_initialize_exceptions();
102  bsp_interrupt_initialize();
103}
Note: See TracBrowser for help on using the repository browser.