head	1.11;
access;
symbols
	netbsd-11-0-RC4:1.11
	netbsd-11-0-RC3:1.11
	netbsd-11-0-RC2:1.11
	netbsd-11-0-RC1:1.11
	perseant-exfatfs-base-20250801:1.11
	netbsd-11:1.11.0.4
	netbsd-11-base:1.11
	netbsd-10-1-RELEASE:1.8.4.1
	perseant-exfatfs-base-20240630:1.11
	perseant-exfatfs:1.11.0.2
	perseant-exfatfs-base:1.11
	netbsd-8-3-RELEASE:1.2
	netbsd-9-4-RELEASE:1.5
	netbsd-10-0-RELEASE:1.8.4.1
	netbsd-10-0-RC6:1.8.4.1
	netbsd-10-0-RC5:1.8.4.1
	netbsd-10-0-RC4:1.8.4.1
	netbsd-10-0-RC3:1.8.4.1
	netbsd-10-0-RC2:1.8.4.1
	thorpej-ifq:1.10.0.4
	thorpej-ifq-base:1.10
	thorpej-altq-separation:1.10.0.2
	thorpej-altq-separation-base:1.10
	netbsd-10-0-RC1:1.8.4.1
	netbsd-10:1.8.0.4
	netbsd-10-base:1.8
	bouyer-sunxi-drm:1.8.0.2
	bouyer-sunxi-drm-base:1.8
	netbsd-9-3-RELEASE:1.5
	thorpej-i2c-spi-conf2:1.7.0.10
	thorpej-i2c-spi-conf2-base:1.7
	thorpej-futex2:1.7.0.8
	thorpej-futex2-base:1.7
	thorpej-cfargs2:1.7.0.6
	thorpej-cfargs2-base:1.7
	cjep_sun2x-base1:1.7
	cjep_sun2x:1.7.0.4
	cjep_sun2x-base:1.7
	cjep_staticlib_x-base1:1.7
	netbsd-9-2-RELEASE:1.5
	cjep_staticlib_x:1.7.0.2
	cjep_staticlib_x-base:1.7
	thorpej-i2c-spi-conf:1.6.0.8
	thorpej-i2c-spi-conf-base:1.7
	thorpej-cfargs:1.6.0.6
	thorpej-cfargs-base:1.6
	thorpej-futex:1.6.0.4
	thorpej-futex-base:1.6
	netbsd-9-1-RELEASE:1.5
	bouyer-xenpvh-base2:1.6
	phil-wifi-20200421:1.6
	bouyer-xenpvh-base1:1.6
	phil-wifi-20200411:1.6
	bouyer-xenpvh:1.6.0.2
	bouyer-xenpvh-base:1.6
	is-mlppp:1.5.0.6
	is-mlppp-base:1.5
	phil-wifi-20200406:1.6
	netbsd-8-2-RELEASE:1.2
	ad-namecache-base3:1.5
	netbsd-9-0-RELEASE:1.5
	netbsd-9-0-RC2:1.5
	ad-namecache-base2:1.5
	ad-namecache-base1:1.5
	ad-namecache:1.5.0.4
	ad-namecache-base:1.5
	netbsd-9-0-RC1:1.5
	phil-wifi-20191119:1.5
	netbsd-9:1.5.0.2
	netbsd-9-base:1.5
	phil-wifi-20190609:1.4
	netbsd-8-1-RELEASE:1.2
	netbsd-8-1-RC1:1.2
	isaki-audio2:1.3.0.2
	isaki-audio2-base:1.3
	pgoyette-compat-merge-20190127:1.2.20.1
	pgoyette-compat-20190127:1.3
	pgoyette-compat-20190118:1.3
	pgoyette-compat-1226:1.3
	pgoyette-compat-1126:1.3
	pgoyette-compat-1020:1.3
	pgoyette-compat-0930:1.3
	pgoyette-compat-0906:1.2
	pgoyette-compat-0728:1.2
	netbsd-8-0-RELEASE:1.2
	phil-wifi:1.2.0.22
	phil-wifi-base:1.2
	pgoyette-compat-0625:1.2
	netbsd-8-0-RC2:1.2
	pgoyette-compat-0521:1.2
	pgoyette-compat-0502:1.2
	pgoyette-compat-0422:1.2
	netbsd-8-0-RC1:1.2
	pgoyette-compat-0415:1.2
	pgoyette-compat-0407:1.2
	pgoyette-compat-0330:1.2
	pgoyette-compat-0322:1.2
	pgoyette-compat-0315:1.2
	pgoyette-compat:1.2.0.20
	pgoyette-compat-base:1.2
	tls-maxphys:1.2.0.18
	tls-maxphys-base-20171202:1.2
	matt-nb8-mediatek:1.2.0.16
	matt-nb8-mediatek-base:1.2
	nick-nhusb-base-20170825:1.2
	perseant-stdc-iso10646:1.2.0.14
	perseant-stdc-iso10646-base:1.2
	netbsd-8:1.2.0.12
	netbsd-8-base:1.2
	prg-localcount2-base3:1.2
	prg-localcount2-base2:1.2
	prg-localcount2-base1:1.2
	prg-localcount2:1.2.0.10
	prg-localcount2-base:1.2
	pgoyette-localcount-20170426:1.2
	bouyer-socketcan-base1:1.2
	jdolecek-ncq:1.2.0.8
	jdolecek-ncq-base:1.2
	pgoyette-localcount-20170320:1.2
	nick-nhusb-base-20170204:1.2
	bouyer-socketcan:1.2.0.6
	bouyer-socketcan-base:1.2
	pgoyette-localcount-20170107:1.2
	nick-nhusb-base-20161204:1.2
	pgoyette-localcount-20161104:1.2
	nick-nhusb-base-20161004:1.2
	localcount-20160914:1.2
	pgoyette-localcount-20160806:1.2
	pgoyette-localcount-20160726:1.2
	pgoyette-localcount:1.2.0.4
	pgoyette-localcount-base:1.2
	nick-nhusb-base-20160907:1.2
	nick-nhusb-base-20160529:1.2
	nick-nhusb-base-20160422:1.2
	nick-nhusb-base-20160319:1.2
	nick-nhusb-base-20151226:1.2
	nick-nhusb-base-20150921:1.2
	nick-nhusb-base-20150606:1.2
	nick-nhusb:1.2.0.2
	nick-nhusb-base-20150406:1.2;
locks; strict;
comment	@# @;


1.11
date	2024.02.25.14.27.41;	author skrll;	state Exp;
branches;
next	1.10;
commitid	mrgM9X2q2DSR3PZE;

1.10
date	2023.07.26.03.41.57;	author rin;	state Exp;
branches;
next	1.9;
commitid	3Lrx3eREXdcFmgyE;

1.9
date	2023.05.07.12.41.48;	author skrll;	state Exp;
branches;
next	1.8;
commitid	W1X4g8g57obtV1oE;

1.8
date	2022.09.28.05.02.02;	author skrll;	state Exp;
branches
	1.8.4.1;
next	1.7;
commitid	jlH4bUtOD2JhuAVD;

1.7
date	2021.05.01.07.13.21;	author skrll;	state Exp;
branches;
next	1.6;
commitid	gou3hL101lwwLpRC;

1.6
date	2020.03.14.16.12.15;	author skrll;	state Exp;
branches
	1.6.8.1;
next	1.5;
commitid	psGw4umqsNrH1o0C;

1.5
date	2019.06.16.07.42.52;	author maxv;	state Exp;
branches;
next	1.4;
commitid	LgOmb85BFHHVWnrB;

1.4
date	2019.06.01.12.42.27;	author maxv;	state Exp;
branches;
next	1.3;
commitid	GD349nPBemHB5upB;

1.3
date	2018.09.22.12.24.03;	author rin;	state Exp;
branches;
next	1.2;
commitid	oPiNEJ7VnAF626TA;

1.2
date	2015.03.31.01.05.52;	author matt;	state Exp;
branches
	1.2.2.1
	1.2.18.1
	1.2.20.1
	1.2.22.1;
next	1.1;
commitid	nwdDEww7xd7QbHfy;

1.1
date	2015.03.28.16.13.56;	author matt;	state Exp;
branches;
next	;
commitid	SobwTQinlgtRiofy;

1.8.4.1
date	2023.09.11.13.35.38;	author martin;	state Exp;
branches;
next	;
commitid	DVOFlvNJch029mEE;

1.6.8.1
date	2021.05.13.00.47.27;	author thorpej;	state Exp;
branches;
next	;
commitid	hlq0lOvHnylpfVSC;

1.2.2.1
date	2015.03.31.01.05.52;	author skrll;	state dead;
branches;
next	1.2.2.2;
commitid	pz01Zhy7RP6iGxgy;

1.2.2.2
date	2015.04.06.15.18.01;	author skrll;	state Exp;
branches;
next	;
commitid	pz01Zhy7RP6iGxgy;

1.2.18.1
date	2015.03.31.01.05.52;	author jdolecek;	state dead;
branches;
next	1.2.18.2;
commitid	XcIYRZTAh1LmerhA;

1.2.18.2
date	2017.12.03.11.36.38;	author jdolecek;	state Exp;
branches;
next	;
commitid	XcIYRZTAh1LmerhA;

1.2.20.1
date	2018.09.30.01.45.46;	author pgoyette;	state Exp;
branches;
next	;
commitid	SQ44grEPCeKPh4UA;

1.2.22.1
date	2019.06.10.22.06.41;	author christos;	state Exp;
branches;
next	1.2.22.2;
commitid	jtc8rnCzWiEEHGqB;

1.2.22.2
date	2020.04.08.14.07.50;	author martin;	state Exp;
branches;
next	1.2.22.3;
commitid	Qli2aW9E74UFuA3C;

1.2.22.3
date	2020.04.13.08.04.05;	author martin;	state Exp;
branches;
next	;
commitid	X01YhRUPVUDaec4C;


desc
@@


1.11
log
@Warn about building a kernel with the wrong toolchain.

Idea from mrg@@
@
text
@#	$NetBSD: Makefile.riscv,v 1.10 2023/07/26 03:41:57 rin Exp $

# Makefile for NetBSD
#
# This makefile is constructed from a machine description:
#	config machineid
# Most changes should be made in the machine description
#	/sys/arch/<machine>/conf/``machineid''
# after which you should do
#	config machineid
# Machine generic makefile changes should be made in
#	/sys/arch/riscv/conf/Makefile.riscv
# after which config should be rerun for all machines of that type.
#
# To specify debugging, add the config line: makeoptions DEBUG="-g"
# A better way is to specify -g only for a few files.
#
#	makeoptions DEBUGLIST="uvm* trap if_*"

USETOOLS?=	no
NEED_OWN_INSTALL_TARGET?=no
.include <bsd.own.mk>


.if !defined(LP64) && ${MACHINE_ARCH} == "riscv64"
. info (Building GENERIC instead of GENERIC64?)
. error Don't build 32-bit kernel with 64-bit toolchain
.endif

.if defined(LP64) && ${MACHINE_ARCH} == "riscv32"
. info (Building GENERIC64 instead of GENERIC?)
. error Don't build 64-bit kernel with 32-bit toolchain
.endif


##
## (1) port identification
##
.ifndef S
S=		../../../..
.endif
THISRISCV=	$S/arch/${MACHINE}
RISCV=		$S/arch/riscv
GENASSYM_CONF=	${RISCV}/riscv/genassym.cf
.-include "${THISRISCV}/conf/Makefile.${MACHINE}.inc"

##
## (2) compile settings
##
## Note: -ffixed-?? must be kept in sync with cpu.h.
##
CPPFLAGS+=	-D${MACHINE}
CFLAGS+=	-mcmodel=medany
AFLAGS+=	-x assembler-with-cpp ${AOPTS}

##
## (3) libkern and compat
##
OPT_MODULAR=	%MODULAR%

##
## (4) local objects, compile rules, and dependencies
##
MD_OBJS=	locore.o
MD_CFILES=
MD_SFILES=	${RISCV}/riscv/locore.S

locore.o: ${RISCV}/riscv/locore.S assym.h
	${NORMAL_S}

##
## (5) link settings
##
.if ${MACHINE_ARCH} == "riscv64" && ${LP64:Uyes} == "yes"
TEXTADDR?=		0xFFFFFFC000000000
.else
TEXTADDR?=		0x80200000
.endif
KERNLDSCRIPT?=		${RISCV}/conf/kern.ldscript
EXTRA_LINKFLAGS=	${LDOPTS} --relax
LINKFLAGS_NORMAL=	-X
OBJCOPY_STRIPFLAGS=	-g -X

# Set the physical load address (aka 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.
#
KERNEL_PHYS?=		0x80200000
EXTRA_LINKFLAGS+=	--defsym='KERNEL_PHYS=${KERNEL_PHYS}'

##
## (6) port specific target dependencies
##

# depend on CPU configuration
machdep.o mainbus.o trap.o: Makefile

# depend on System V IPC/shmem options
riscv_machdep.o pmap.o: Makefile

# various assembly files that depend on assym.h
locore.o: assym.h

##
## (7) misc settings
##
RAMDISKDIR!=    cd ${NETBSDSRCDIR}/distrib/riscv/ramdisk && ${PRINTOBJDIR}

.if defined(NEED_MDSETIMAGE) && ${NEED_MDSETIMAGE} != "no" \
    && defined(RAMDISKDIR) && exists(${RAMDISKDIR}/ramdisk.fs)
SYSTEM_DEP+=    ${RAMDISKDIR}/ramdisk.fs
SYSTEM_LD_TAIL_EXTRA+=; \
	echo ${TOOL_MDSETIMAGE} -s $@@ ${RAMDISKDIR}/ramdisk.fs; \
	${TOOL_MDSETIMAGE} -s $@@ ${RAMDISKDIR}/ramdisk.fs
.if !empty(DEBUG:M-g*)
SYSTEM_LD_TAIL_EXTRA+=; \
	echo ${TOOL_MDSETIMAGE} -s $@@.gdb ${RAMDISKDIR}/ramdisk.fs; \
	${TOOL_MDSETIMAGE} -s $@@.gdb ${RAMDISKDIR}/ramdisk.fs
.endif
.endif

##
## (8) config(8) generated machinery
##
%INCLUDES

%OBJS

%CFILES

%SFILES

%LOAD

%RULES

##
## (9) port independent kernel machinery
##
.include "$S/conf/Makefile.kern.inc"

##
## (10) Appending make options.
##
%MAKEOPTIONSAPPEND
@


1.10
log
@Use OBJCOPY_STRIPFLAGS instead of STRIPFLAGS.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.9 2023/05/07 12:41:48 skrll Exp $
d24 12
@


1.9
log
@RISC-V support that works on QEMU with a single hart.

Thanks for Simon Burge for plic(4).
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.8 2022/09/28 05:02:02 skrll Exp $
d70 1
a70 1
STRIPFLAGS=		-g -X
@


1.8
log
@Fix RV32 so it gets to the same point as RV64
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.7 2021/05/01 07:13:21 skrll Exp $
a41 9
.if !defined(LP64) || ${LP64} == "no"
CFLAGS+=	-m32
AFLAGS+=	-m32
LDFLAGS+=	-m elf32lriscv
LINKFORMAT+=	-m elf32lriscv
SYSTEM_LD_TAIL_EXTRA+= \
		;echo ${OBJCOPY} -O elf32-littleriscv $@@ $@@.elf32; \
		${OBJCOPY} -O elf32-littleriscv $@@ $@@.elf32
.endif # LP64=no
@


1.8.4.1
log
@Pull up following revision(s) (requested by rin in ticket #363):

	sys/arch/aarch64/conf/Makefile.aarch64: revision 1.24
	sys/arch/aarch64/conf/Makefile.aarch64: revision 1.25
	sys/arch/shark/conf/Makefile.shark.inc: revision 1.28
	sys/arch/alpha/conf/Makefile.alpha: revision 1.88
	sys/arch/mips/conf/Makefile.mips: revision 1.73
	sys/conf/Makefile.kern.inc: revision 1.298
	sys/conf/Makefile.kern.inc: revision 1.299
	sys/arch/cats/conf/Makefile.cats.inc: revision 1.37
	sys/arch/arm/conf/Makefile.arm: revision 1.56
	sys/arch/arm/conf/Makefile.arm: revision 1.57
	sys/arch/riscv/conf/Makefile.riscv: revision 1.10

Always use arm-elf2aout; no a.out support both for binutils{,.old}

Fix kernel size inflation for arm and aarch64 (PR toolchain/57146)

For some conditions, SYSTEM_LD_TAIL is set for arm and aarch64.
Then, ctfmerge(1) in default SYSTEM_LD_TAIL is unintentionally
skipped, which results in the catastrophic kernel size inflation,
as reported in the PR.

Also, introduce and use OBJCOPY_STRIPFLAGS variable instead of
STRIPFLAGS, as strip(1) is replaced by objcopy(1) during MI
kernel build procedure.

For Makefile.{arm,aarch64}, weird logic is used to determine how
to handle debug symbols; MKDEBUG{,KERNEL} are taken into account
later in sys/conf/Makefile.kern.inc.

Use OBJCOPY_STRIPFLAGS instead of STRIPFLAGS.
Simplify fix for PR toolchain/57146

Introduce ARCH_STRIP_SYMBOLS variable to centralize logic for debug
symbols from MD Makefile's to Makefile.kern.inc.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.8 2022/09/28 05:02:02 skrll Exp $
d79 1
a79 1
OBJCOPY_STRIPFLAGS=	-g -X
@


1.7
log
@Fixup kernel linking and provide a linker script with standard sections
and symbols
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.6 2020/03/14 16:12:15 skrll Exp $
d74 1
a74 1
TEXTADDR?=		0xC0001000
@


1.6
log
@Trailing whitespace
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.5 2019/06/16 07:42:52 maxv Exp $
a76 1
LINKFORMAT+=		-T ${KERNLDSCRIPT}
d81 7
@


1.6.8.1
log
@Sync with HEAD.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.7 2021/05/01 07:13:21 skrll Exp $
d77 1
a81 7
# Set the physical load address (aka 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.
#
KERNEL_PHYS?=		0x80200000
EXTRA_LINKFLAGS+=	--defsym='KERNEL_PHYS=${KERNEL_PHYS}'

@


1.5
log
@Misc changes in RISC-V.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.4 2019/06/01 12:42:27 maxv Exp $
d102 1
a102 1
SYSTEM_DEP+=    ${RAMDISKDIR}/ramdisk.fs 
@


1.4
log
@Misc changes in RISC-V. Start changing the memory layout, too.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.3 2018/09/22 12:24:03 rin Exp $
d72 2
a73 2
TEXTADDR?=              0xFFFFFFC000000000
.else   
@


1.3
log
@- Determine KERN_AS automatically depending on whether OPT_MODULAR is
  set or not, in the same way as libcompat.

- Specify OPT_MODULAR in the port Makefile instead of KERN_AS.

Now, KERN_AS=library is used for kernels without module(7) for all ports.

OK christos
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.2 2015/03/31 01:05:52 matt Exp $
a41 1
CFLAGS+=	-msoft-float
d72 1
a72 1
TEXTADDR?=              0xFFFFFFFF80002000
@


1.2
log
@Use -mcmodel=medany to get PICish code.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.1 2015/03/28 16:13:56 matt Exp $
a57 5
.if !empty(OPT_MODULAR)
KERN_AS=	obj
.else
KERN_AS=	library
.endif
@


1.2.22.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.4 2019/06/01 12:42:27 maxv Exp $
d42 1
d58 5
d78 1
a78 1
TEXTADDR?=              0xFFFFFFC000000000
@


1.2.22.2
log
@Merge changes from current as of 20200406
@
text
@d1 1
a1 1
#	$NetBSD$
d102 1
a102 1
SYSTEM_DEP+=    ${RAMDISKDIR}/ramdisk.fs
@


1.2.22.3
log
@Mostly merge changes from HEAD upto 20200411
@
text
@d72 2
a73 2
TEXTADDR?=		0xFFFFFFC000000000
.else
@


1.2.20.1
log
@Ssync with HEAD
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.3 2018/09/22 12:24:03 rin Exp $
d58 5
@


1.2.18.1
log
@file Makefile.riscv was added on branch tls-maxphys on 2017-12-03 11:36:38 +0000
@
text
@d1 142
@


1.2.18.2
log
@update from HEAD
@
text
@a0 142
#	$NetBSD$

# Makefile for NetBSD
#
# This makefile is constructed from a machine description:
#	config machineid
# Most changes should be made in the machine description
#	/sys/arch/<machine>/conf/``machineid''
# after which you should do
#	config machineid
# Machine generic makefile changes should be made in
#	/sys/arch/riscv/conf/Makefile.riscv
# after which config should be rerun for all machines of that type.
#
# To specify debugging, add the config line: makeoptions DEBUG="-g"
# A better way is to specify -g only for a few files.
#
#	makeoptions DEBUGLIST="uvm* trap if_*"

USETOOLS?=	no
NEED_OWN_INSTALL_TARGET?=no
.include <bsd.own.mk>

##
## (1) port identification
##
.ifndef S
S=		../../../..
.endif
THISRISCV=	$S/arch/${MACHINE}
RISCV=		$S/arch/riscv
GENASSYM_CONF=	${RISCV}/riscv/genassym.cf
.-include "${THISRISCV}/conf/Makefile.${MACHINE}.inc"

##
## (2) compile settings
##
## Note: -ffixed-?? must be kept in sync with cpu.h.
##
CPPFLAGS+=	-D${MACHINE}
CFLAGS+=	-mcmodel=medany
CFLAGS+=	-msoft-float
.if !defined(LP64) || ${LP64} == "no"
CFLAGS+=	-m32
AFLAGS+=	-m32
LDFLAGS+=	-m elf32lriscv
LINKFORMAT+=	-m elf32lriscv
SYSTEM_LD_TAIL_EXTRA+= \
		;echo ${OBJCOPY} -O elf32-littleriscv $@@ $@@.elf32; \
		${OBJCOPY} -O elf32-littleriscv $@@ $@@.elf32
.endif # LP64=no
AFLAGS+=	-x assembler-with-cpp ${AOPTS}

##
## (3) libkern and compat
##
OPT_MODULAR=	%MODULAR%
.if !empty(OPT_MODULAR)
KERN_AS=	obj
.else
KERN_AS=	library
.endif

##
## (4) local objects, compile rules, and dependencies
##
MD_OBJS=	locore.o
MD_CFILES=
MD_SFILES=	${RISCV}/riscv/locore.S

locore.o: ${RISCV}/riscv/locore.S assym.h
	${NORMAL_S}

##
## (5) link settings
##
.if ${MACHINE_ARCH} == "riscv64" && ${LP64:Uyes} == "yes"
TEXTADDR?=              0xFFFFFFFF80002000
.else   
TEXTADDR?=		0xC0001000
.endif
KERNLDSCRIPT?=		${RISCV}/conf/kern.ldscript
LINKFORMAT+=		-T ${KERNLDSCRIPT}
EXTRA_LINKFLAGS=	${LDOPTS} --relax
LINKFLAGS_NORMAL=	-X
STRIPFLAGS=		-g -X

##
## (6) port specific target dependencies
##

# depend on CPU configuration
machdep.o mainbus.o trap.o: Makefile

# depend on System V IPC/shmem options
riscv_machdep.o pmap.o: Makefile

# various assembly files that depend on assym.h
locore.o: assym.h

##
## (7) misc settings
##
RAMDISKDIR!=    cd ${NETBSDSRCDIR}/distrib/riscv/ramdisk && ${PRINTOBJDIR}

.if defined(NEED_MDSETIMAGE) && ${NEED_MDSETIMAGE} != "no" \
    && defined(RAMDISKDIR) && exists(${RAMDISKDIR}/ramdisk.fs)
SYSTEM_DEP+=    ${RAMDISKDIR}/ramdisk.fs 
SYSTEM_LD_TAIL_EXTRA+=; \
	echo ${TOOL_MDSETIMAGE} -s $@@ ${RAMDISKDIR}/ramdisk.fs; \
	${TOOL_MDSETIMAGE} -s $@@ ${RAMDISKDIR}/ramdisk.fs
.if !empty(DEBUG:M-g*)
SYSTEM_LD_TAIL_EXTRA+=; \
	echo ${TOOL_MDSETIMAGE} -s $@@.gdb ${RAMDISKDIR}/ramdisk.fs; \
	${TOOL_MDSETIMAGE} -s $@@.gdb ${RAMDISKDIR}/ramdisk.fs
.endif
.endif

##
## (8) config(8) generated machinery
##
%INCLUDES

%OBJS

%CFILES

%SFILES

%LOAD

%RULES

##
## (9) port independent kernel machinery
##
.include "$S/conf/Makefile.kern.inc"

##
## (10) Appending make options.
##
%MAKEOPTIONSAPPEND
@


1.2.2.1
log
@file Makefile.riscv was added on branch nick-nhusb on 2015-04-06 15:18:01 +0000
@
text
@d1 142
@


1.2.2.2
log
@Sync with HEAD
@
text
@a0 142
#	$NetBSD: Makefile.riscv,v 1.2 2015/03/31 01:05:52 matt Exp $

# Makefile for NetBSD
#
# This makefile is constructed from a machine description:
#	config machineid
# Most changes should be made in the machine description
#	/sys/arch/<machine>/conf/``machineid''
# after which you should do
#	config machineid
# Machine generic makefile changes should be made in
#	/sys/arch/riscv/conf/Makefile.riscv
# after which config should be rerun for all machines of that type.
#
# To specify debugging, add the config line: makeoptions DEBUG="-g"
# A better way is to specify -g only for a few files.
#
#	makeoptions DEBUGLIST="uvm* trap if_*"

USETOOLS?=	no
NEED_OWN_INSTALL_TARGET?=no
.include <bsd.own.mk>

##
## (1) port identification
##
.ifndef S
S=		../../../..
.endif
THISRISCV=	$S/arch/${MACHINE}
RISCV=		$S/arch/riscv
GENASSYM_CONF=	${RISCV}/riscv/genassym.cf
.-include "${THISRISCV}/conf/Makefile.${MACHINE}.inc"

##
## (2) compile settings
##
## Note: -ffixed-?? must be kept in sync with cpu.h.
##
CPPFLAGS+=	-D${MACHINE}
CFLAGS+=	-mcmodel=medany
CFLAGS+=	-msoft-float
.if !defined(LP64) || ${LP64} == "no"
CFLAGS+=	-m32
AFLAGS+=	-m32
LDFLAGS+=	-m elf32lriscv
LINKFORMAT+=	-m elf32lriscv
SYSTEM_LD_TAIL_EXTRA+= \
		;echo ${OBJCOPY} -O elf32-littleriscv $@@ $@@.elf32; \
		${OBJCOPY} -O elf32-littleriscv $@@ $@@.elf32
.endif # LP64=no
AFLAGS+=	-x assembler-with-cpp ${AOPTS}

##
## (3) libkern and compat
##
OPT_MODULAR=	%MODULAR%
.if !empty(OPT_MODULAR)
KERN_AS=	obj
.else
KERN_AS=	library
.endif

##
## (4) local objects, compile rules, and dependencies
##
MD_OBJS=	locore.o
MD_CFILES=
MD_SFILES=	${RISCV}/riscv/locore.S

locore.o: ${RISCV}/riscv/locore.S assym.h
	${NORMAL_S}

##
## (5) link settings
##
.if ${MACHINE_ARCH} == "riscv64" && ${LP64:Uyes} == "yes"
TEXTADDR?=              0xFFFFFFFF80002000
.else   
TEXTADDR?=		0xC0001000
.endif
KERNLDSCRIPT?=		${RISCV}/conf/kern.ldscript
LINKFORMAT+=		-T ${KERNLDSCRIPT}
EXTRA_LINKFLAGS=	${LDOPTS} --relax
LINKFLAGS_NORMAL=	-X
STRIPFLAGS=		-g -X

##
## (6) port specific target dependencies
##

# depend on CPU configuration
machdep.o mainbus.o trap.o: Makefile

# depend on System V IPC/shmem options
riscv_machdep.o pmap.o: Makefile

# various assembly files that depend on assym.h
locore.o: assym.h

##
## (7) misc settings
##
RAMDISKDIR!=    cd ${NETBSDSRCDIR}/distrib/riscv/ramdisk && ${PRINTOBJDIR}

.if defined(NEED_MDSETIMAGE) && ${NEED_MDSETIMAGE} != "no" \
    && defined(RAMDISKDIR) && exists(${RAMDISKDIR}/ramdisk.fs)
SYSTEM_DEP+=    ${RAMDISKDIR}/ramdisk.fs 
SYSTEM_LD_TAIL_EXTRA+=; \
	echo ${TOOL_MDSETIMAGE} -s $@@ ${RAMDISKDIR}/ramdisk.fs; \
	${TOOL_MDSETIMAGE} -s $@@ ${RAMDISKDIR}/ramdisk.fs
.if !empty(DEBUG:M-g*)
SYSTEM_LD_TAIL_EXTRA+=; \
	echo ${TOOL_MDSETIMAGE} -s $@@.gdb ${RAMDISKDIR}/ramdisk.fs; \
	${TOOL_MDSETIMAGE} -s $@@.gdb ${RAMDISKDIR}/ramdisk.fs
.endif
.endif

##
## (8) config(8) generated machinery
##
%INCLUDES

%OBJS

%CFILES

%SFILES

%LOAD

%RULES

##
## (9) port independent kernel machinery
##
.include "$S/conf/Makefile.kern.inc"

##
## (10) Appending make options.
##
%MAKEOPTIONSAPPEND
@


1.1
log
@Beginnings of RISCV kernel support.  Note that the pmap support is not yet
committed and probably won't be for awhile.  This is mostly preliminary
waiting for the supervisor specification to come out.  Lots of missing pieces
but it mostly builds.
@
text
@d1 1
a1 1
#	$NetBSD: Makefile.riscv,v 1.59 2013/03/10 07:18:20 christos Exp $
d41 2
a42 1
CFLAGS+=	-fPIC -Wa,-fno-pic -msoft-float
@

