summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2014-08-04 23:00:13 +0000
committerbrooks <brooks@FreeBSD.org>2014-08-04 23:00:13 +0000
commit38b0021d0a5ccbc3ae3fa9af5c2668a0426b264e (patch)
treee2921e6daa6109b801b0173bc72f31373408b8dc
parent661b96f06e13e80cbb17562fe9f9672c7759429d (diff)
downloadFreeBSD-src-38b0021d0a5ccbc3ae3fa9af5c2668a0426b264e.zip
FreeBSD-src-38b0021d0a5ccbc3ae3fa9af5c2668a0426b264e.tar.gz
Merge from CheriBSD:
Make the sysinit tool a build tool rather than building in with /usr/bin/cc and running it from OBJDIR. (It will be moved to usr.bin once a manpage is written and a few style cleanups are done.) Split the makefile bits for Hans' kernel shim layer into their own includable kshim.mk. Move USB support into a .mk file so loaders can include it.
-rw-r--r--Makefile.inc13
-rw-r--r--sys/boot/kshim/bsd_busspace.c (renamed from sys/boot/usb/bsd_busspace.c)0
-rw-r--r--sys/boot/kshim/bsd_global.h (renamed from sys/boot/usb/bsd_global.h)0
-rw-r--r--sys/boot/kshim/bsd_kernel.c (renamed from sys/boot/usb/bsd_kernel.c)0
-rw-r--r--sys/boot/kshim/bsd_kernel.h (renamed from sys/boot/usb/bsd_kernel.h)0
-rw-r--r--sys/boot/kshim/kshim.mk79
-rw-r--r--sys/boot/kshim/sysinit.h (renamed from sys/boot/usb/tools/sysinit.h)0
-rw-r--r--sys/boot/usb/Makefile175
-rw-r--r--sys/boot/usb/tools/Makefile10
-rw-r--r--sys/boot/usb/usbcore.mk154
10 files changed, 254 insertions, 167 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index 62ed26a..f50b788 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -1406,7 +1406,8 @@ cross-tools: .MAKE
usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
${_btxld} \
${_crunchide} \
- ${_kgzip}
+ ${_kgzip} \
+ sys/boot/usb/tools
${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
cd ${.CURDIR}/${_tool} && \
${MAKE} DIRPRFX=${_tool}/ obj && \
diff --git a/sys/boot/usb/bsd_busspace.c b/sys/boot/kshim/bsd_busspace.c
index c9ba09f..c9ba09f 100644
--- a/sys/boot/usb/bsd_busspace.c
+++ b/sys/boot/kshim/bsd_busspace.c
diff --git a/sys/boot/usb/bsd_global.h b/sys/boot/kshim/bsd_global.h
index 2fb0dcc..2fb0dcc 100644
--- a/sys/boot/usb/bsd_global.h
+++ b/sys/boot/kshim/bsd_global.h
diff --git a/sys/boot/usb/bsd_kernel.c b/sys/boot/kshim/bsd_kernel.c
index d41b9f4..d41b9f4 100644
--- a/sys/boot/usb/bsd_kernel.c
+++ b/sys/boot/kshim/bsd_kernel.c
diff --git a/sys/boot/usb/bsd_kernel.h b/sys/boot/kshim/bsd_kernel.h
index 975211e..975211e 100644
--- a/sys/boot/usb/bsd_kernel.h
+++ b/sys/boot/kshim/bsd_kernel.h
diff --git a/sys/boot/kshim/kshim.mk b/sys/boot/kshim/kshim.mk
new file mode 100644
index 0000000..7e9b00d
--- /dev/null
+++ b/sys/boot/kshim/kshim.mk
@@ -0,0 +1,79 @@
+#
+# $FreeBSD$
+#
+# Copyright (c) 2013 Hans Petter Selasky.
+# Copyright (c) 2014 SRI International
+# All rights reserved.
+#
+# This software was developed by SRI International and the University of
+# Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+# ("CTSRD"), as part of the DARPA CRASH research programme.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+KSHIM_DIR:= ${.PARSEDIR}
+.PATH: ${KSHIM_DIR}
+
+CFLAGS+= -I${KSHIM_DIR}
+CFLAGS+= -I${KSHIM_DIR}/../..
+CFLAGS+= -DUSB_GLOBAL_INCLUDE_FILE=\"bsd_global.h\"
+CFLAGS+= -DHAVE_ENDIAN_DEFS
+
+#
+# Single threaded BSD kernel
+#
+KSRCS+= bsd_kernel.c
+
+#
+# BUSSPACE implementation
+#
+KSRCS+= bsd_busspace.c
+
+SRCS+= sysinit_data.c
+SRCS+= sysuninit_data.c
+
+CLEANFILES+= sysinit.bin
+CLEANFILES+= sysinit_data.c
+CLEANFILES+= sysuninit_data.c
+
+SRCS+= ${KSRCS}
+SYSINIT_OBJS= ${KSRCS:R:C/$/.osys/}
+CLEANFILES+= ${SYSINIT_OBJS}
+
+#
+# SYSINIT() and SYSUNINIT() handling
+#
+
+sysinit_data.c: sysinit.bin
+ sysinit -i sysinit.bin -o ${.TARGET} -k sysinit -s sysinit_data
+
+sysuninit_data.c: sysinit.bin
+ sysinit -i sysinit.bin -o ${.TARGET} -R -k sysuninit -s sysuninit_data
+
+.for KSRC in ${KSRCS:R}
+${KSRC}.osys: ${KSRC}.o
+ ${OBJCOPY} -j ".debug.sysinit" -O binary ${KSRC}.o ${KSRC}.osys
+.endfor
+
+sysinit.bin: ${SYSINIT_OBJS}
+ cat ${.ALLSRC} > sysinit.bin
diff --git a/sys/boot/usb/tools/sysinit.h b/sys/boot/kshim/sysinit.h
index a7a450e..a7a450e 100644
--- a/sys/boot/usb/tools/sysinit.h
+++ b/sys/boot/kshim/sysinit.h
diff --git a/sys/boot/usb/Makefile b/sys/boot/usb/Makefile
index cd4dec0..1b94b3d 100644
--- a/sys/boot/usb/Makefile
+++ b/sys/boot/usb/Makefile
@@ -1,7 +1,13 @@
#
# $FreeBSD$
#
-# Copyright (c) 2013 Hans Petter Selasky. All rights reserved.
+# Copyright (c) 2013 Hans Petter Selasky.
+# Copyright (c) 2014 SRI International
+# All rights reserved.
+#
+# This software was developed by SRI International and the University of
+# Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+# ("CTSRD"), as part of the DARPA CRASH research programme.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -25,37 +31,15 @@
# SUCH DAMAGE.
#
-T=${.CURDIR}/tools
-S=${.CURDIR}/../..
-
-.PATH: \
- ${.CURDIR} \
- ${.CURDIR}/storage \
- ${S}/dev/usb \
- ${S}/dev/usb/controller \
- ${S}/dev/usb/serial \
- ${S}/dev/usb/storage \
- ${S}/dev/usb/template
-
LIB= usbboot
INTERNALLIB=
-OBJCOPY?= objcopy
-SYSCC?= /usr/bin/cc
CFLAGS+= -DBOOTPROG=\"usbloader\"
-CFLAGS+= -DUSB_GLOBAL_INCLUDE_FILE=\"bsd_global.h\"
CFLAGS+= -ffunction-sections -fdata-sections
CFLAGS+= -ffreestanding
CFLAGS+= -Wformat -Wall
-CFLAGS+= -I${S}
-CFLAGS+= -I${T}
-CFLAGS+= -I${.CURDIR}
-CFLAGS+= -I${.CURDIR}/../common
CFLAGS+= -g
-CFLAGS+= -DUSB_MSCTEST_BULK_SIZE=65536
-CFLAGS+= -DUSB_POOL_SIZE=131072
CFLAGS+= -fno-pic
-CFLAGS+= -DHAVE_ENDIAN_DEFS
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -march=i386
@@ -68,148 +52,7 @@ CFLAGS+= -m32
CFLAGS+= -mno-abicalls
.endif
-#
-# Single threaded BSD kernel
-#
-SRCS+= bsd_kernel.c
-
-#
-# BUSSPACE implementation
-#
-SRCS+= bsd_busspace.c
-
-#
-# BUSDMA implementation
-#
-SRCS+= usb_busdma_loader.c
-
-#
-# USB controller drivers
-#
-
-SRCS+= usb_controller.c
-
-.if defined(HAVE_AT91DCI)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"at91dci\""
-SRCS+= at91dci.c
-.endif
-
-.if defined(HAVE_ATMEGADCI)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"atmegadci\""
-SRCS+= atmegadci.c
-.endif
-
-.if defined(HAVE_AVR32DCI)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"avr32dci\""
-SRCS+= avr32dci.c
-.endif
-
-.if defined(HAVE_DWCOTG)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"dwcotg\""
-SRCS+= dwcotg.c
-.endif
-
-.if defined(HAVE_MUSBOTG)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"musbotg\""
-SRCS+= musbotg.c
-.endif
-
-.if defined(HAVE_EHCI)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"ehci\""
-SRCS+= ehci.c
-.endif
-
-.if defined(HAVE_OHCI)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"ohci\""
-SRCS+= ohci.c
-.endif
-
-.if defined(HAVE_UHCI)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"uhci\""
-SRCS+= uhci.c
-.endif
-
-.if defined(HAVE_XHCI)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"xhci\""
-SRCS+= xhci.c
-.endif
-
-.if defined(HAVE_USS820DCI)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"uss820dci\""
-SRCS+= uss820dci.c
-.endif
-
-.if defined(HAVE_SAF1761OTG)
-CFLAGS += -DUSB_PCI_PROBE_LIST="\"saf1761otg\""
-CFLAGS += -DUSB_PCI_MEMORY_ADDRESS=0x900000007f100000ULL
-CFLAGS += -DUSB_PCI_MEMORY_SIZE=0x40000U
-SRCS+= saf1761_otg.c
-SRCS+= saf1761_otg_boot.c
-.endif
-
-#
-# USB core and templates
-#
-SRCS+= usb_core.c
-SRCS+= usb_debug.c
-SRCS+= usb_device.c
-SRCS+= usb_dynamic.c
-SRCS+= usb_error.c
-SRCS+= usb_handle_request.c
-SRCS+= usb_hid.c
-SRCS+= usb_hub.c
-SRCS+= usb_lookup.c
-SRCS+= usb_msctest.c
-SRCS+= usb_parse.c
-SRCS+= usb_request.c
-SRCS+= usb_transfer.c
-SRCS+= usb_util.c
-SRCS+= usb_template.c
-SRCS+= usb_template_cdce.c
-SRCS+= usb_template_msc.c
-SRCS+= usb_template_mtp.c
-SRCS+= usb_template_modem.c
-SRCS+= usb_template_mouse.c
-SRCS+= usb_template_kbd.c
-SRCS+= usb_template_audio.c
-SRCS+= sysinit_data.c
-SRCS+= sysuninit_data.c
-
-#
-# USB mass storage support
-#
-SRCS+= umass_common.c
-
-.if defined(HAVE_UMASS_LOADER)
-SRCS+= umass_loader.c
-.endif
-
-CLEANFILES+= sysinit
-CLEANFILES+= sysinit.bin
-CLEANFILES+= sysinit_data.c
-CLEANFILES+= sysuninit_data.c
-
-CLEANFILES+= ${SRCS:C/\.c/.osys/g}
+.include "usbcore.mk"
+.include "../kshim/kshim.mk"
.include <bsd.lib.mk>
-
-#
-# SYSINIT() and SYSUNINIT() handling
-#
-sysinit: ${T}/sysinit.c
- ${SYSCC} -Wall -o ${.TARGET} ${.ALLSRC}
-
-sysinit_data.c: sysinit.bin sysinit
- ${.OBJDIR}/sysinit -i sysinit.bin -o ${.TARGET} -k sysinit -s sysinit_data
-
-sysuninit_data.c: sysinit.bin sysinit
- ${.OBJDIR}/sysinit -i sysinit.bin -o ${.TARGET} -R -k sysuninit -s sysuninit_data
-
-.for F in ${OBJS}
-${F}sys: ${F}
- ${OBJCOPY} -j ".debug.sysinit" -O binary ${F} ${.TARGET}
- [ -f ${.TARGET} ] || touch ${.TARGET}
-.endfor
-
-sysinit.bin: ${OBJS:C/\.o/.osys/g:C/sysinit_data.osys//g:C/sysuninit_data.osys//g}
- cat ${.ALLSRC} > sysinit.bin
diff --git a/sys/boot/usb/tools/Makefile b/sys/boot/usb/tools/Makefile
new file mode 100644
index 0000000..ae3259f
--- /dev/null
+++ b/sys/boot/usb/tools/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+PROG= sysinit
+NO_MAN=
+
+CFLAGS+= -I${.CURDIR}/../../kshim
+
+BINDIR?= /usr/bin
+
+.include <bsd.prog.mk>
diff --git a/sys/boot/usb/usbcore.mk b/sys/boot/usb/usbcore.mk
new file mode 100644
index 0000000..8b6c59a
--- /dev/null
+++ b/sys/boot/usb/usbcore.mk
@@ -0,0 +1,154 @@
+#
+# $FreeBSD$
+#
+# Copyright (c) 2013 Hans Petter Selasky.
+# Copyright (c) 2014 SRI International
+# All rights reserved.
+#
+# This software was developed by SRI International and the University of
+# Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+# ("CTSRD"), as part of the DARPA CRASH research programme.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+USBCOREDIR:= ${.PARSEDIR}
+S=${USBCOREDIR}/../..
+
+.PATH: \
+ ${USBCOREDIR} \
+ ${USBCOREDIR}/storage \
+ ${S}/dev/usb \
+ ${S}/dev/usb/controller \
+ ${S}/dev/usb/serial \
+ ${S}/dev/usb/storage \
+ ${S}/dev/usb/template
+.undef S
+
+CFLAGS+= -DUSB_MSCTEST_BULK_SIZE=65536
+CFLAGS+= -DUSB_POOL_SIZE=131072
+
+#
+# BUSDMA implementation
+#
+SRCS+= usb_busdma_loader.c
+
+#
+# USB controller drivers
+#
+
+KSRCS+= usb_controller.c
+
+.if defined(HAVE_AT91DCI)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"at91dci\""
+KSRCS+= at91dci.c
+.endif
+
+.if defined(HAVE_ATMEGADCI)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"atmegadci\""
+KSRCS+= atmegadci.c
+.endif
+
+.if defined(HAVE_AVR32DCI)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"avr32dci\""
+KSRCS+= avr32dci.c
+.endif
+
+.if defined(HAVE_DWCOTG)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"dwcotg\""
+KSRCS+= dwcotg.c
+.endif
+
+.if defined(HAVE_MUSBOTG)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"musbotg\""
+KSRCS+= musbotg.c
+.endif
+
+.if defined(HAVE_EHCI)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"ehci\""
+KSRCS+= ehci.c
+.endif
+
+.if defined(HAVE_OHCI)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"ohci\""
+KSRCS+= ohci.c
+.endif
+
+.if defined(HAVE_UHCI)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"uhci\""
+KSRCS+= uhci.c
+.endif
+
+.if defined(HAVE_XHCI)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"xhci\""
+KSRCS+= xhci.c
+.endif
+
+.if defined(HAVE_USS820DCI)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"uss820dci\""
+KSRCS+= uss820dci.c
+.endif
+
+.if defined(HAVE_SAF1761OTG)
+CFLAGS += -DUSB_PCI_PROBE_LIST="\"saf1761otg\""
+CFLAGS += -DUSB_PCI_MEMORY_ADDRESS=0x900000007f100000ULL
+CFLAGS += -DUSB_PCI_MEMORY_SIZE=0x40000U
+KSRCS+= saf1761_otg.c
+KSRCS+= saf1761_otg_boot.c
+.endif
+
+#
+# USB core and templates
+#
+KSRCS+= usb_core.c
+KSRCS+= usb_debug.c
+KSRCS+= usb_device.c
+KSRCS+= usb_dynamic.c
+KSRCS+= usb_error.c
+KSRCS+= usb_handle_request.c
+KSRCS+= usb_hid.c
+KSRCS+= usb_hub.c
+KSRCS+= usb_lookup.c
+KSRCS+= usb_msctest.c
+KSRCS+= usb_parse.c
+KSRCS+= usb_request.c
+KSRCS+= usb_transfer.c
+KSRCS+= usb_util.c
+KSRCS+= usb_template.c
+KSRCS+= usb_template_cdce.c
+KSRCS+= usb_template_msc.c
+KSRCS+= usb_template_mtp.c
+KSRCS+= usb_template_modem.c
+KSRCS+= usb_template_mouse.c
+KSRCS+= usb_template_kbd.c
+KSRCS+= usb_template_audio.c
+
+#
+# USB mass storage support
+#
+SRCS+= umass_common.c
+
+.if defined(HAVE_UMASS_LOADER)
+CFLAGS+= -I${.CURDIR}/../common
+SRCS+= umass_loader.c
+.endif
+
OpenPOWER on IntegriCloud