third_party.pigweed.src/pw_sys_io_baremetal_stm32f429/early_boot.c
Armando Montanez ec9dd67691 pw_boot_armv7m: Add pw_PreStaticConstructorInit()
Adds pw_PreStaticConstructorInit() to allow ARMv7-M targets that use
pw_boot to perform initialization before C++ static constructors are
run. Updates stm32f429i-disc1 to enable FPU before static constructors
so static constructors can safely perform FPU operations if necessary.

Change-Id: I66cfa82096719f59c42c84e4bafd0e1740002e09
2020-06-08 18:59:59 +00:00

32 lines
1.2 KiB
C

// 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 <inttypes.h>
#include "pw_boot_armv7m/boot.h"
void pw_PreStaticConstructorInit() {
// 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
}