• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 
15 #include <stdbool.h>
16 
17 #include "pw_boot_armv7m/boot.h"
18 
19 // Default handler to insert into the ARMv7-M vector table (below).
20 // This function exists for convenience. If a device isn't doing what you
21 // expect, it might have hit a fault and ended up here.
DefaultFaultHandler(void)22 static void DefaultFaultHandler(void) {
23   while (true) {
24     // Wait for debugger to attach.
25   }
26 }
27 
28 // This is the device's interrupt vector table. It's not referenced in any
29 // code because the platform (STM32F4xx) expects this table to be present at the
30 // beginning of flash. The exact address is specified in the pw_boot_armv7m
31 // configuration as part of the target config.
32 //
33 // For more information, see ARMv7-M Architecture Reference Manual DDI 0403E.b
34 // section B1.5.3.
35 
36 // This typedef is for convenience when building the vector table. With the
37 // exception of SP_main (0th entry in the vector table), all the entries of the
38 // vector table are function pointers.
39 typedef void (*InterruptHandler)(void);
40 
41 PW_KEEP_IN_SECTION(".vector_table")
42 const InterruptHandler vector_table[] = {
43     // The starting location of the stack pointer.
44     // This address is NOT an interrupt handler/function pointer, it is simply
45     // the address that the main stack pointer should be initialized to. The
46     // value is reinterpret casted because it needs to be in the vector table.
47     [0] = (InterruptHandler)(&pw_boot_stack_high_addr),
48 
49     // Reset handler, dictates how to handle reset interrupt. This is the
50     // address that the Program Counter (PC) is initialized to at boot.
51     [1] = pw_boot_Entry,
52 
53     // NMI handler.
54     [2] = DefaultFaultHandler,
55     // HardFault handler.
56     [3] = DefaultFaultHandler,
57 };
58