freebsd-dev/sys/conf/Makefile.riscv

67 lines
1.7 KiB
Makefile
Raw Normal View History

# Makefile.riscv -- with config changes.
# Copyright 1990 W. Jolitz
# from: @(#)Makefile.i386 7.1 5/10/91
# from FreeBSD: src/sys/conf/Makefile.i386,v 1.255 2002/02/20 23:35:49
# $FreeBSD$
#
# Makefile for FreeBSD
#
# RISCVTODO: copy pasted from aarch64, needs to be
# constructed from a machine description:
# config machineid
# Most changes should be made in the machine description
# /sys/riscv/conf/``machineid''
# after which you should do
# config machineid
# Generic makefile changes should be made in
# /sys/conf/Makefile.riscv
# after which config should be rerun for all machines.
#
# Which version of config(8) is required.
%VERSREQ= 600012
.if !defined(S)
S= ../../..
.endif
.include "$S/conf/kern.pre.mk"
INCLUDES+= -I$S/contrib/libfdt
Set the LMA of the riscv kernel to the OpenSBI jump target by default This allows us to boot FreeBSD RISCV on QEMU using the -kernel command line options. When using that option, QEMU maps the kernel ELF file to the addresses specified in the LMAs in the program headers. Since version 4.2 QEMU ships with OpenSBI fw_jump by default so this allows booting FreeBSD using the following command line: qemu-system-riscv64 -bios default -kernel /.../boot/kernel/kernel -nographic -M virt Without this change the -kernel option cannot be used since the LMAs start at address zero and QEMU already maps a ROM to these low physical addresses. For targets that require a different kernel LMA the make variable KERNEL_LMA can be overwritten in the config file. For example, adding `makeoptions KERNEL_LMA=0xc0200000` will create an ELF file that will be loaded at 0xc0200000. Before: There are 4 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xffffffc000000000 0x0000000000000000 0x75e598 0x8be318 RWE 0x1000 DYNAMIC 0x71fb20 0xffffffc00071eb20 0x000000000071eb20 0x000100 0x000100 RW 0x8 GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 NOTE 0x693400 0xffffffc000692400 0x0000000000692400 0x000024 0x000024 R 0x4 After: There are 4 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xffffffc000000000 0x0000000080200000 0x734198 0x893e18 RWE 0x1000 DYNAMIC 0x6f7810 0xffffffc0006f6810 0x00000000808f6810 0x000100 0x000100 RW 0x8 GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 NOTE 0x66ca70 0xffffffc00066ba70 0x000000008086ba70 0x000024 0x000024 R 0x4 Reviewed By: br, mhorne (earlier version) Differential Revision: https://reviews.freebsd.org/D23436
2020-02-04 00:06:16 +00:00
# Set the ELF LMA to the address that OpenSBI's fw_jump jumps to. This allows
# us to load the kernel with the -kernel flag in QEMU without having to embed
# it inside BBL or OpenSBI's fw_payload first.
# Note: For rv32 the start address is different (0x80400000).
# We set this value using --defsym rather than hardcoding it in ldscript.riscv
# so that different kernel configs can override the load address.
KERNEL_LMA?= 0x80200000
SYSTEM_LD= @${LD} -N -m ${LD_EMULATION} -Bdynamic -T ${LDSCRIPT} ${_LDFLAGS} \
--no-warn-mismatch --warn-common --export-dynamic \
Set the LMA of the riscv kernel to the OpenSBI jump target by default This allows us to boot FreeBSD RISCV on QEMU using the -kernel command line options. When using that option, QEMU maps the kernel ELF file to the addresses specified in the LMAs in the program headers. Since version 4.2 QEMU ships with OpenSBI fw_jump by default so this allows booting FreeBSD using the following command line: qemu-system-riscv64 -bios default -kernel /.../boot/kernel/kernel -nographic -M virt Without this change the -kernel option cannot be used since the LMAs start at address zero and QEMU already maps a ROM to these low physical addresses. For targets that require a different kernel LMA the make variable KERNEL_LMA can be overwritten in the config file. For example, adding `makeoptions KERNEL_LMA=0xc0200000` will create an ELF file that will be loaded at 0xc0200000. Before: There are 4 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xffffffc000000000 0x0000000000000000 0x75e598 0x8be318 RWE 0x1000 DYNAMIC 0x71fb20 0xffffffc00071eb20 0x000000000071eb20 0x000100 0x000100 RW 0x8 GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 NOTE 0x693400 0xffffffc000692400 0x0000000000692400 0x000024 0x000024 R 0x4 After: There are 4 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xffffffc000000000 0x0000000080200000 0x734198 0x893e18 RWE 0x1000 DYNAMIC 0x6f7810 0xffffffc0006f6810 0x00000000808f6810 0x000100 0x000100 RW 0x8 GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 NOTE 0x66ca70 0xffffffc00066ba70 0x000000008086ba70 0x000024 0x000024 R 0x4 Reviewed By: br, mhorne (earlier version) Differential Revision: https://reviews.freebsd.org/D23436
2020-02-04 00:06:16 +00:00
--defsym='kernel_lma=${KERNEL_LMA}' \
--dynamic-linker /red/herring \
-o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
.if !empty(DDB_ENABLED)
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
.endif
# hack because genassym.c includes sys/bus.h which includes these.
genassym.o: bus_if.h device_if.h
%BEFORE_DEPEND
%OBJS
%FILES.c
%FILES.s
%FILES.m
%CLEAN
%RULES
.include "$S/conf/kern.post.mk"