blob: 184bfe676ea2b5f18e12a442667906654de96412 [file] [log] [blame]
Chris Mumforde2fa1842023-01-17 19:45:43 +00001// Copyright 2023 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/boot.h"
18#include "pw_boot_cortex_m/boot.h"
19
20// Default handler to insert into the ARMv7-M vector table (below).
21// This function exists for convenience. If a device isn't doing what you
22// expect, it might have hit a fault and ended up here.
23static void DefaultFaultHandler(void) {
24 while (true) {
25 // Wait for debugger to attach.
26 }
27}
28
29// This is the device's interrupt vector table. It's not referenced in any
30// code because the platform (STM32F7xx) expects this table to be present at the
31// beginning of flash. The exact address is specified in the pw_boot_cortex_m
32// configuration as part of the target config.
33//
34// For more information, see ARMv7-M Architecture Reference Manual DDI 0403E.b
35// section B1.5.3.
36
37// This typedef is for convenience when building the vector table. With the
38// exception of SP_main (0th entry in the vector table), all the entries of the
39// vector table are function pointers.
40typedef void (*InterruptHandler)(void);
41
42PW_KEEP_IN_SECTION(".vector_table")
43const InterruptHandler vector_table[] = {
44 // The starting location of the stack pointer.
45 // This address is NOT an interrupt handler/function pointer, it is simply
46 // the address that the main stack pointer should be initialized to. The
47 // value is reinterpret casted because it needs to be in the vector table.
48 [0] = (InterruptHandler)(&pw_boot_stack_high_addr),
49
50 // Reset handler, dictates how to handle reset interrupt. This is the
51 // address that the Program Counter (PC) is initialized to at boot.
52 [1] = pw_boot_Entry,
53
54 // NMI handler.
55 [2] = DefaultFaultHandler,
56 // HardFault handler.
57 [3] = DefaultFaultHandler,
58};