# -*- makefile -*-
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# RISC-V core OS files build
#

# Select RISC-V bare-metal toolchain
$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_riscv),\
	/opt/coreboot-sdk/bin/riscv64-elf-)

# CPU specific compilation flags
CFLAGS_CPU+=-march=rv32imafc -mabi=ilp32f -Os
LDFLAGS_EXTRA+=-mrelax
LDFLAGS_EXTRA+=-static-libgcc -lgcc

core-y=cpu.o init.o panic.o task.o switch.o __builtin.o math.o

# -*- makefile -*-
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# RISC-V core OS files build
#

# Select RISC-V bare-metal toolchain
$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_riscv),\
	/opt/coreboot-sdk/bin/riscv64-elf-)

# Enable FPU extension if config option of FPU is enabled.
_FPU_EXTENSION=$(if $(CONFIG_FPU),f,)
# CPU specific compilation flags
CFLAGS_CPU+=-march=rv32ima$(_FPU_EXTENSION)c -mabi=ilp32$(_FPU_EXTENSION) -Os
LDFLAGS_EXTRA+=-mrelax
LDFLAGS_EXTRA+=-static-libgcc -lgcc

core-y=cpu.o init.o panic.o task.o switch.o __builtin.o math.o

Enable FPU extension only if CONFIG_FPU is enabled
riscv-rv32i: Enable FPU extension only if CONFIG_FPU is enabled

At default, CONFIG_FPU option isn't enabled. But currently,
FPU extension is always enabled when building FW image.
This will cause problem if hardware doesn't support the extension
and floating-point instructions are generated. So we fix it.

BUG=none
BRANCH=none
TEST=Floating-point instructions are used for floating point
     operation if CONFIG_FPU is enabled. Otherwise, library
     routines are used.

Signed-off-by: Dino Li <338d523ecf3700bd86eb9c34d220f91911d2a18c@ite.com.tw>
Change-Id: Ifb77bd0cca1158ca7f6637fa9ec025ac8712bbfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2227779
Reviewed-by: Vincent Palatin <70a9964ec8fd10b0b08fcc8623c2add25ddf99ac@chromium.org>
Commit-Queue: Vincent Palatin <70a9964ec8fd10b0b08fcc8623c2add25ddf99ac@chromium.org>
