#
# \brief  Test for using the lwIP TCP/IP stack over USB
# \author Sebastian Sumpf
# \date   2012-07-06
#
# This test case executes a small HTTP server, it has been used on PandaBoard
# hardware only, though it should execute but not do anything on other hardware
#

#
# Build
#

set build_components {
	core init timer
	drivers/usb_host
	drivers/usb_net
	test/lwip/http_srv
	lib/vfs/lwip
}

lappend_if [have_spec gpio] build_components drivers/gpio

source ${genode_dir}/repos/base/run/platform_drv.inc
append_platform_drv_build_components

build $build_components

create_boot_directory

#
# Generate config
#

append config {
<config>
	<parent-provides>
		<service name="ROM"/>
		<service name="IRQ"/>
		<service name="IO_MEM"/>
		<service name="IO_PORT"/>
		<service name="PD"/>
		<service name="RM"/>
		<service name="CPU"/>
		<service name="LOG"/>
	</parent-provides>
	<default-route>
		<any-service> <parent/> <any-child/> </any-service>
	</default-route>
	<default caps="200"/>}

append_if [have_spec gpio] config "
	<start name=\"[gpio_drv]\">
		<resource name=\"RAM\" quantum=\"4M\"/>
		<provides><service name=\"Gpio\"/></provides>
		<config/>
	</start>"

append_platform_drv_config

append config {
	<start name="timer">
		<resource name="RAM" quantum="1M"/>
		<provides><service name="Timer"/></provides>
	</start>

	<start name="usb_drv" caps="120"> }
append config "<binary name=\"[usb_host_drv_binary]\"/>"
append config {
		<resource name="RAM" quantum="12M"/>
		<provides> <service name="Usb"/> </provides>
		<config bios_handoff="yes">}
append_if [have_spec arndale] config {
			<policy label_prefix="usb_net_drv" vendor_id="0x0b95" product_id="0x772a"/> }
append_if [expr [have_spec panda] || [have_spec rpi] ] config {
			<policy label_prefix="usb_net_drv" vendor_id="0x0424" product_id="0xec00"/> }
append_if [have_spec x86] config {
			<policy label_prefix="usb_net_drv" vendor_id="0x0b95" product_id="0x1790"/> }
append config {
		</config>
		<route>
			<service name="Report"> <child name="report_rom"/> </service>
			<any-service> <parent/> <any-child/> </any-service>
		</route>
	</start>

	<start name="usb_net_drv">
		<resource name="RAM" quantum="10M"/>
		<provides> <service name="Nic"/> </provides>
		<config mac="02:00:00:00:01:01" />
	</start>

	<start name="test-lwip_httpsrv" caps="120">
		<resource name="RAM" quantum="4M"/>
		<config>
			<vfs>
				<dir name="dev">    <log/>             </dir>
				<dir name="socket"> <lwip dhcp="yes"/> </dir>
			</vfs>
			<libc stdout="/dev/log" stderr="/dev/log" socket="/socket"/>
		</config>
	</start>
</config>
}

install_config $config

#
# Boot modules
#

# generic modules
set boot_modules {
	core init timer usb_net_drv
	ld.lib.so libc.lib.so vfs.lib.so vfs_lwip.lib.so test-lwip_httpsrv
}

append boot_modules [usb_host_drv_binary]
lappend_if [have_spec gpio] boot_modules [gpio_drv]

append_platform_drv_boot_modules

build_boot_image $boot_modules

append qemu_args "  -nographic"

run_genode_until forever

# vi: set ft=tcl :
