Blame view

RIOT/cpu/mips32r2_common/cpu.c 1.6 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  /*
   * Copyright 2016, Imagination Technologies Limited and/or its
   *                 affiliated group companies.
   *
   * This file is subject to the terms and conditions of the GNU Lesser
   * General Public License v2.1. See the file LICENSE in the top level
   * directory for more details.
   */
  
  #include <mips/m32c0.h>
  #include <mips/regdef.h>
  #include <mips/asm.h>
  #include <string.h>
  #include <assert.h>
  
  #include "periph/uart.h"
  #include "periph/timer.h"
  #include "arch/panic_arch.h"
  #include "kernel_init.h"
  #include "cpu.h"
  #include "board.h"
  
  void mips_start(void);
  
  extern void _fini(void);
  extern void atexit(void (*)(void));
  extern void _init(void);
  extern void exit(int);
  
  #ifdef FLASH_XIP
  extern char _rom_data_copy __attribute__((section("data")));
  extern char _fdata __attribute__((section("data")));
  extern char _edata __attribute__((section("data")));
  #endif
  
  /*
   * Note the mips toolchain crt expects to jump to main but RIOT wants the user
   * code to start at main for some perverse reason, but thankfully the crt
   * does provide this hook function which gets called fairly close to the jump
   * to main, thus if we finish off the job of the crt here and never returns
   * we can support this madness.
   */
  void software_init_hook(void)
  {
  #ifdef FLASH_XIP
      /* copy initialized data from its LMA to VMA */
      memcpy(&_fdata, &_rom_data_copy, (int)&_edata - (int)&_fdata);
  #endif
  
      atexit(_fini);
      _init();
  
      mips_start();
  
      exit(-1);
  }
  
  
  void mips_start(void)
  {
      board_init();
  
      /* kernel_init */
      kernel_init();
  }
  
  void panic_arch(void)
  {
      printf("\nPANIC!\n");
      assert(0);
      while (1) {
      }
  }