2020-06-05 19:32:51 +00:00
|
|
|
// Copyright 2020 The Pigweed Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
|
|
// use this file except in compliance with the License. You may obtain a copy of
|
|
|
|
// the License at
|
|
|
|
//
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing permissions and limitations under
|
|
|
|
// the License.
|
|
|
|
|
|
|
|
#include "pw_boot_armv7m/boot.h"
|
2020-06-18 19:42:06 +00:00
|
|
|
#include "pw_malloc/malloc.h"
|
2020-08-24 19:55:13 +00:00
|
|
|
#include "pw_preprocessor/compiler.h"
|
2020-07-20 16:21:42 +00:00
|
|
|
#include "pw_sys_io_baremetal_stm32f429/init.h"
|
2020-06-05 19:32:51 +00:00
|
|
|
|
2020-08-21 22:54:28 +00:00
|
|
|
void pw_boot_PreStaticMemoryInit() {
|
2020-06-05 19:32:51 +00:00
|
|
|
// TODO(pwbug/17): Optionally enable Replace when Pigweed config system is
|
|
|
|
// added.
|
|
|
|
#if PW_ARMV7M_ENABLE_FPU
|
|
|
|
// Enable FPU if built using hardware FPU instructions.
|
|
|
|
// CPCAR mask that enables FPU. (ARMv7-M Section B3.2.20)
|
|
|
|
const uint32_t kFpuEnableMask = (0xFu << 20);
|
|
|
|
|
|
|
|
// Memory mapped register to enable FPU. (ARMv7-M Section B3.2.2, Table B3-4)
|
|
|
|
volatile uint32_t* arm_v7m_cpacr = (volatile uint32_t*)0xE000ED88u;
|
|
|
|
|
|
|
|
*arm_v7m_cpacr |= kFpuEnableMask;
|
|
|
|
#endif // PW_ARMV7M_ENABLE_FPU
|
2020-08-21 22:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pw_boot_PreStaticConstructorInit() {
|
2020-06-18 19:42:06 +00:00
|
|
|
#if PW_MALLOC_ACTIVE
|
|
|
|
pw_MallocInit();
|
|
|
|
#endif // PW_MALLOC_ACTIVE
|
|
|
|
}
|
2020-07-20 16:21:42 +00:00
|
|
|
|
2020-08-21 22:54:28 +00:00
|
|
|
void pw_boot_PreMainInit() { pw_sys_io_Init(); }
|
2020-08-24 19:55:13 +00:00
|
|
|
|
|
|
|
PW_NO_RETURN void pw_boot_PostMain() {
|
|
|
|
// In case main() returns, just sit here until the device is reset.
|
|
|
|
while (1) {
|
|
|
|
}
|
|
|
|
PW_UNREACHABLE;
|
|
|
|
}
|