mirror of
https://fuchsia.googlesource.com/third_party/pigweed.googlesource.com/pigweed/pigweed
synced 2024-09-20 13:51:05 +00:00
lm3s6965evb-qemu: move early_boot into targets/*
Updates targets/lm3s6965evb-qemu/* and its sys_io counterpart to match targets/stm32f429i-disc1/* by moving the early boot and vector tables out of sys_io. Change-Id: If1f82d5bd242807d9c4914d207b7f332291de8cf Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/16700 Commit-Queue: Ewout van Bekkum <ewout@google.com> Reviewed-by: Armando Montanez <amontanez@google.com> Reviewed-by: Keir Mierle <keir@google.com>
This commit is contained in:
parent
9692257d24
commit
712cbfb017
|
@ -12,14 +12,22 @@
|
|||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
load(
|
||||
"//pw_build:pigweed.bzl",
|
||||
"pw_cc_library",
|
||||
)
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"]) # Apache License 2.0
|
||||
|
||||
filegroup(
|
||||
pw_cc_library(
|
||||
name = "pw_sys_io_baremetal_lm3s6965evb",
|
||||
srcs = [
|
||||
"early_boot.c",
|
||||
"sys_io_baremetal.cc",
|
||||
],
|
||||
hdrs = ["public/pw_sys_io_baremetal_lm3s6965evb/init.h"],
|
||||
srcs = ["sys_io_baremetal.cc"],
|
||||
deps = [
|
||||
"//pw_preprocessor",
|
||||
"//pw_sys_io",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -17,15 +17,18 @@ import("//build_overrides/pigweed.gni")
|
|||
|
||||
import("$dir_pw_build/target_types.gni")
|
||||
import("$dir_pw_docgen/docs.gni")
|
||||
config("default_config") {
|
||||
include_dirs = [ "public" ]
|
||||
}
|
||||
|
||||
pw_source_set("pw_sys_io_baremetal_lm3s6965evb") {
|
||||
public_configs = [ ":default_config" ]
|
||||
public = [ "public/pw_sys_io_baremetal_lm3s6965evb/init.h" ]
|
||||
public_deps = [ "$dir_pw_boot_armv7m" ]
|
||||
deps = [
|
||||
"$dir_pw_preprocessor",
|
||||
"$dir_pw_sys_io:default_putget_bytes",
|
||||
"$dir_pw_sys_io:facade",
|
||||
]
|
||||
sources = [
|
||||
"early_boot.c",
|
||||
"sys_io_baremetal.cc",
|
||||
]
|
||||
sources = [ "sys_io_baremetal.cc" ]
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
// License for the specific language governing permissions and limitations under
|
||||
// the License.
|
||||
#pragma once
|
||||
|
||||
#include "pw_boot_armv7m/boot.h"
|
||||
|
||||
void pw_boot_PreStaticMemoryInit() {}
|
||||
void pw_boot_PreStaticConstructorInit() {}
|
||||
// The actual implement of PreMainInit() in sys_io_BACKEND.
|
||||
void pw_sys_io_Init();
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "pw_boot_armv7m/boot.h"
|
||||
#include "pw_preprocessor/compiler.h"
|
||||
#include "pw_sys_io/sys_io.h"
|
||||
|
||||
|
@ -62,12 +61,6 @@ volatile UartBlock& uart0 = *reinterpret_cast<volatile UartBlock*>(0x4000C000U);
|
|||
constexpr uint32_t kRcgcUart0EnableMask = 0x1;
|
||||
volatile uint32_t& rcgc1 = *reinterpret_cast<volatile uint32_t*>(0x400FE104U);
|
||||
|
||||
constexpr uint32_t kRccDefault = 0x078E3AD1U;
|
||||
volatile uint32_t& rcc = *reinterpret_cast<volatile uint32_t*>(0x400FE070U);
|
||||
|
||||
constexpr uint32_t kRcc2Default = 0x07802810U;
|
||||
volatile uint32_t& rcc2 = *reinterpret_cast<volatile uint32_t*>(0x400FE070U);
|
||||
|
||||
// Calculate a baud rate multiplier such that we have 16 bits of precision for
|
||||
// the integer portion and 6 bits for the fractional portion.
|
||||
void SetBaudRate(uint32_t clock, uint32_t target_baud) {
|
||||
|
@ -77,53 +70,9 @@ void SetBaudRate(uint32_t clock, uint32_t target_baud) {
|
|||
uart0.fractional_baud = (((remainder << 7) / divisor + 1) >> 1) & 0x3f;
|
||||
}
|
||||
|
||||
// Default handler to insert into the ARMv7-M vector table (below).
|
||||
// This function exists for convenience. If a device isn't doing what you
|
||||
// expect, it might have hit a fault and ended up here.
|
||||
void DefaultFaultHandler(void) {
|
||||
while (true) {
|
||||
// Wait for debugger to attach.
|
||||
}
|
||||
}
|
||||
|
||||
// This is the device's interrupt vector table. It's not referenced in any code
|
||||
// because the platform expects this table to be present at the beginning of
|
||||
// flash. The exact address is specified in the pw_boot_armv7m configuration as
|
||||
// part of the target config.
|
||||
//
|
||||
// For more information, see ARMv7-M Architecture Reference Manual DDI 0403E.b
|
||||
// section B1.5.3.
|
||||
|
||||
// This typedef is for convenience when building the vector table. With the
|
||||
// exception of SP_main (0th entry in the vector table), all the entries of the
|
||||
// vector table are function pointers.
|
||||
typedef void (*InterruptHandler)();
|
||||
|
||||
PW_KEEP_IN_SECTION(".vector_table")
|
||||
const InterruptHandler vector_table[] = {
|
||||
// The starting location of the stack pointer.
|
||||
// This address is NOT an interrupt handler/function pointer, it is simply
|
||||
// the address that the main stack pointer should be initialized to. The
|
||||
// value is reinterpret casted because it needs to be in the vector table.
|
||||
[0] = reinterpret_cast<InterruptHandler>(&pw_boot_stack_high_addr),
|
||||
|
||||
// Reset handler, dictates how to handle reset interrupt. This is the
|
||||
// address that the Program Counter (PC) is initialized to at boot.
|
||||
[1] = pw_boot_Entry,
|
||||
|
||||
// NMI handler.
|
||||
[2] = DefaultFaultHandler,
|
||||
// HardFault handler.
|
||||
[3] = DefaultFaultHandler,
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" void pw_boot_PreMainInit() {
|
||||
// Force RCC to be at default at boot.
|
||||
rcc = kRccDefault;
|
||||
rcc2 = kRcc2Default;
|
||||
|
||||
extern "C" void pw_sys_io_Init() {
|
||||
rcgc1 |= kRcgcUart0EnableMask;
|
||||
for (volatile int i = 0; i < 3; ++i) {
|
||||
// We must wait after enabling uart.
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "pw_boot_armv7m/boot.h"
|
||||
#include "pw_preprocessor/compiler.h"
|
||||
#include "pw_sys_io/sys_io.h"
|
||||
|
||||
|
|
35
targets/lm3s6965evb-qemu/BUILD
Normal file
35
targets/lm3s6965evb-qemu/BUILD
Normal file
|
@ -0,0 +1,35 @@
|
|||
# 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.
|
||||
|
||||
load(
|
||||
"//pw_build:pigweed.bzl",
|
||||
"pw_cc_library",
|
||||
)
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"]) # Apache License 2.0
|
||||
|
||||
pw_cc_library(
|
||||
name = "pre_init",
|
||||
srcs = [
|
||||
"early_boot.c",
|
||||
"vector_table.cc"
|
||||
],
|
||||
deps = [
|
||||
"//pw_boot_armv7m",
|
||||
"//pw_preprocessor",
|
||||
"//pw_sys_io_baremetal_lm3s6965evb",
|
||||
],
|
||||
)
|
|
@ -15,6 +15,7 @@
|
|||
# gn-format disable
|
||||
import("//build_overrides/pigweed.gni")
|
||||
|
||||
import("$dir_pw_build/target_types.gni")
|
||||
import("$dir_pw_docgen/docs.gni")
|
||||
import("$dir_pw_toolchain/generate_toolchain.gni")
|
||||
import("target_toolchains.gni")
|
||||
|
@ -22,6 +23,20 @@ generate_toolchains("target_toolchains") {
|
|||
toolchains = pw_target_toolchain_lm3s6965evb_qemu_list
|
||||
}
|
||||
|
||||
if (current_toolchain != default_toolchain) {
|
||||
pw_source_set("pre_init") {
|
||||
public_deps = [
|
||||
"$dir_pw_boot_armv7m",
|
||||
"$dir_pw_sys_io_baremetal_lm3s6965evb",
|
||||
]
|
||||
deps = [ "$dir_pw_preprocessor" ]
|
||||
sources = [
|
||||
"early_boot.c",
|
||||
"vector_table.cc",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pw_doc_group("target_docs") {
|
||||
sources = [ "target_docs.rst" ]
|
||||
}
|
||||
|
|
30
targets/lm3s6965evb-qemu/early_boot.c
Normal file
30
targets/lm3s6965evb-qemu/early_boot.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
// 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"
|
||||
#include "pw_sys_io_baremetal_lm3s6965evb/init.h"
|
||||
|
||||
void pw_boot_PreStaticMemoryInit() {
|
||||
// Force RCC to be at default at boot.
|
||||
const uint32_t kRccDefault = 0x078E3AD1U;
|
||||
volatile uint32_t* rcc = (volatile uint32_t*)0x400FE070U;
|
||||
*rcc = kRccDefault;
|
||||
const uint32_t kRcc2Default = 0x07802810U;
|
||||
volatile uint32_t* rcc2 = (volatile uint32_t*)0x400FE070U;
|
||||
*rcc2 = kRcc2Default;
|
||||
}
|
||||
|
||||
void pw_boot_PreStaticConstructorInit() {}
|
||||
|
||||
void pw_boot_PreMainInit() { pw_sys_io_Init(); }
|
|
@ -22,6 +22,6 @@ template("lm3s6965evb_executable") {
|
|||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
deps += [ dir_pw_sys_io_baremetal_lm3s6965evb ]
|
||||
deps += [ "$dir_pigweed/targets/lm3s6965evb-qemu:pre_init" ]
|
||||
}
|
||||
}
|
||||
|
|
59
targets/lm3s6965evb-qemu/vector_table.cc
Normal file
59
targets/lm3s6965evb-qemu/vector_table.cc
Normal file
|
@ -0,0 +1,59 @@
|
|||
// 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"
|
||||
|
||||
namespace {
|
||||
|
||||
// Default handler to insert into the ARMv7-M vector table (below).
|
||||
// This function exists for convenience. If a device isn't doing what you
|
||||
// expect, it might have hit a fault and ended up here.
|
||||
void DefaultFaultHandler(void) {
|
||||
while (true) {
|
||||
// Wait for debugger to attach.
|
||||
}
|
||||
}
|
||||
|
||||
// This is the device's interrupt vector table. It's not referenced in any
|
||||
// code because the platform (STM32F4xx) expects this table to be present at the
|
||||
// beginning of flash. The exact address is specified in the pw_boot_armv7m
|
||||
// configuration as part of the target config.
|
||||
//
|
||||
// For more information, see ARMv7-M Architecture Reference Manual DDI 0403E.b
|
||||
// section B1.5.3.
|
||||
|
||||
// This typedef is for convenience when building the vector table. With the
|
||||
// exception of SP_main (0th entry in the vector table), all the entries of the
|
||||
// vector table are function pointers.
|
||||
typedef void (*InterruptHandler)();
|
||||
|
||||
PW_KEEP_IN_SECTION(".vector_table")
|
||||
const InterruptHandler vector_table[] = {
|
||||
// The starting location of the stack pointer.
|
||||
// This address is NOT an interrupt handler/function pointer, it is simply
|
||||
// the address that the main stack pointer should be initialized to. The
|
||||
// value is reinterpret casted because it needs to be in the vector table.
|
||||
[0] = reinterpret_cast<InterruptHandler>(&pw_boot_stack_high_addr),
|
||||
|
||||
// Reset handler, dictates how to handle reset interrupt. This is the
|
||||
// address that the Program Counter (PC) is initialized to at boot.
|
||||
[1] = pw_boot_Entry,
|
||||
|
||||
// NMI handler.
|
||||
[2] = DefaultFaultHandler,
|
||||
// HardFault handler.
|
||||
[3] = DefaultFaultHandler,
|
||||
};
|
||||
|
||||
} // namespace
|
|
@ -22,7 +22,7 @@ package(default_visibility = ["//visibility:public"])
|
|||
licenses(["notice"]) # Apache License 2.0
|
||||
|
||||
pw_cc_library(
|
||||
name = "pw_pre_init",
|
||||
name = "pre_init",
|
||||
srcs = [
|
||||
"early_boot.c",
|
||||
"vector_table.cc"
|
||||
|
|
|
@ -31,7 +31,7 @@ config("pw_malloc_active") {
|
|||
}
|
||||
|
||||
if (current_toolchain != default_toolchain) {
|
||||
pw_source_set("pw_pre_init") {
|
||||
pw_source_set("pre_init") {
|
||||
configs = [ ":pw_malloc_active" ]
|
||||
public_deps = [
|
||||
"$dir_pw_boot_armv7m",
|
||||
|
|
|
@ -23,7 +23,7 @@ template("stm32f429i_executable") {
|
|||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
deps += [ "$dir_pigweed/targets/stm32f429i-disc1:pw_pre_init" ]
|
||||
deps += [ "$dir_pigweed/targets/stm32f429i-disc1:pre_init" ]
|
||||
if (pw_malloc_BACKEND != "") {
|
||||
if (!defined(configs)) {
|
||||
configs = []
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "pw_boot_armv7m/boot.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// Default handler to insert into the ARMv7-M vector table (below).
|
||||
// This function exists for convenience. If a device isn't doing what you
|
||||
// expect, it might have hit a fault and ended up here.
|
||||
|
@ -54,4 +55,5 @@ const InterruptHandler vector_table[] = {
|
|||
// HardFault handler.
|
||||
[3] = DefaultFaultHandler,
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in New Issue
Block a user