1# 2# $FreeBSD$ 3# 4# Copyright (c) 2013 Hans Petter Selasky. All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# 27 28T=${.CURDIR}/tools 29S=${.CURDIR}/../.. 30 31.PATH: \ 32 ${.CURDIR} \ 33 ${S}/dev/usb \ 34 ${S}/dev/usb/controller \ 35 ${S}/dev/usb/serial \ 36 ${S}/dev/usb/storage \ 37 ${S}/dev/usb/template 38 39LIB= usbboot 40INTERNALLIB= 41OBJCOPY?= objcopy 42SYSCC?= cc 43 44CFLAGS+= -DBOOTPROG=\"usbloader\" 45CFLAGS+= -DUSB_GLOBAL_INCLUDE_FILE=\"bsd_global.h\" 46CFLAGS+= -ffunction-sections -fdata-sections 47CFLAGS+= -ffreestanding 48CFLAGS+= -Wformat -Wall 49CFLAGS+= -I${S} 50CFLAGS+= -I${T} 51CFLAGS+= -I${.CURDIR} 52CFLAGS+= -g 53 54.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 55CFLAGS+= -march=i386 56CFLAGS.gcc+= -mpreferred-stack-boundary=2 57.endif 58.if ${MACHINE_CPUARCH} == "amd64" 59CFLAGS+= -m32 60.endif 61 62# 63# Single threaded BSD kernel 64# 65SRCS+= bsd_kernel.c 66 67# 68# BUSSPACE implementation 69# 70SRCS+= bsd_busspace.c 71 72# 73# BUSDMA implementation 74# 75SRCS+= usb_busdma_loader.c 76 77# 78# USB controller drivers 79# 80SRCS+= at91dci.c 81SRCS+= atmegadci.c 82SRCS+= avr32dci.c 83SRCS+= dwc_otg.c 84SRCS+= ehci.c 85SRCS+= musb_otg.c 86SRCS+= ohci.c 87SRCS+= uhci.c 88SRCS+= uss820dci.c 89SRCS+= xhci.c 90SRCS+= usb_controller.c 91 92CFLAGS += -DUSB_PROBE_LIST="\"xhci\", \"ehci\", \"uhci\", \"ohci\"" 93 94# 95# USB core and templates 96# 97SRCS+= usb_core.c 98SRCS+= usb_debug.c 99SRCS+= usb_device.c 100SRCS+= usb_dynamic.c 101SRCS+= usb_error.c 102SRCS+= usb_handle_request.c 103SRCS+= usb_hid.c 104SRCS+= usb_hub.c 105SRCS+= usb_lookup.c 106SRCS+= usb_msctest.c 107SRCS+= usb_parse.c 108SRCS+= usb_request.c 109SRCS+= usb_transfer.c 110SRCS+= usb_util.c 111SRCS+= usb_template.c 112SRCS+= usb_template_cdce.c 113SRCS+= usb_template_msc.c 114SRCS+= usb_template_mtp.c 115SRCS+= usb_template_modem.c 116SRCS+= usb_template_mouse.c 117SRCS+= usb_template_kbd.c 118SRCS+= usb_template_audio.c 119SRCS+= usb_template_phone.c 120SRCS+= sysinit_data.c 121SRCS+= sysuninit_data.c 122 123CLEANFILES+= sysinit 124CLEANFILES+= sysinit.bin 125CLEANFILES+= sysinit_data.c 126CLEANFILES+= sysuninit_data.c 127 128CLEANFILES+= ${SRCS:C/\.c/.osys/g} 129 130.include <bsd.lib.mk> 131 132# 133# SYSINIT() and SYSUNINIT() handling 134# 135sysinit: ${T}/sysinit.c 136 ${SYSCC} -Wall -o ${.TARGET} ${.ALLSRC} 137 138sysinit_data.c: sysinit.bin sysinit 139 ${.OBJDIR}/sysinit -i sysinit.bin -o ${.TARGET} -k sysinit -s sysinit_data 140 141sysuninit_data.c: sysinit.bin sysinit 142 ${.OBJDIR}/sysinit -i sysinit.bin -o ${.TARGET} -R -k sysuninit -s sysuninit_data 143 144.for F in ${OBJS} 145${F}sys: ${F} 146 ${OBJCOPY} -j ".debug.sysinit" -O binary ${F} ${.TARGET} 147 [ -f ${.TARGET} ] || touch ${.TARGET} 148.endfor 149 150sysinit.bin: ${OBJS:C/\.o/.osys/g:C/sysinit_data.osys//g:C/sysuninit_data.osys//g} 151 cat ${.ALLSRC} > sysinit.bin 152