#
# \brief  Test of ssh_client
# \author Emery Hemingway
#

assert_spec x86

set build_components {
	app/ssh_client
	drivers/nic
	lib/vfs/import
	lib/vfs/lwip
}

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

build $build_components

create_boot_directory

import_from_depot \
	genodelabs/src/[base_src] \
	genodelabs/pkg/[drivers_interactive_pkg] \
	genodelabs/src/init \
	genodelabs/pkg/terminal \
	genodelabs/src/input_filter \

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

append_platform_drv_config

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

	<start name="nic_drv" caps="120">
		<binary name="ipxe_nic_drv"/>
		<resource name="RAM" quantum="16M"/>
		<provides> <service name="Nic"/> </provides>
	</start>

	<start name="fb_drv" caps="200">
		<binary name="vesa_fb_drv"/>
		<resource name="RAM" quantum="10M"/>
		<provides><service name="Framebuffer"/></provides>
		<config buffered="yes"/>
	</start>

	<start name="ps2_drv">
		<resource name="RAM" quantum="1M"/>
		<provides><service name="Input"/></provides>
	</start>

	<start name="input_filter" caps="80">
		<resource name="RAM" quantum="1M"/>
		<provides> <service name="Input"/> </provides>
		<config>
			<input label="ps2"/>
			<output>
				<chargen>
					<input name="ps2"/>
					<repeat delay_ms="230" rate_ms="90"/>
					<include rom="en_us.chargen"/>
					<include rom="special.chargen"/>
				</chargen>
			</output>
		</config>
		<route>
			<service name="Input" label="ps2"> <child name="ps2_drv"/> </service>
			<any-service> <parent/> <any-child/> </any-service>
		</route>
	</start>

	<start name="terminal">
		<resource name="RAM" quantum="2M"/>
		<provides><service name="Terminal"/></provides>
		<route>
			<service name="ROM" label="config">
				<parent label="terminal.config"/> </service>
			<service name="Input">
				<child name="input_filter"/> </service>
			<any-service> <parent/> <any-child/> </any-service>
		</route>
	</start>

	<start name="ssh_client" caps="500">
		<resource name="RAM" quantum="32M"/>
		<config>
			<vfs>
				<ram/>
				<dir name="dev">
					<log/> <null/> <inline name="rtc">2000-01-01 00:00</inline>
					<inline name="random">01234567890123456789</inline>
				</dir>
				<dir name="socket"> <lwip dhcp="yes"/> </dir>

				<import>
					<!-- sdf-eu.org -->
					<inline name="host"><host name="178.63.35.194" user="new" known="no"/></inline>
				</import>
			</vfs>
			<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc" socket="/socket"/>
		</config>
	</start>
</config>
}

install_config $config

# generic modules
set boot_modules {
	ipxe_nic_drv
	libc.lib.so
	libcrypto.lib.so
	libm.lib.so
	libssh.lib.so
	ssh_client
	vfs_import.lib.so
	vfs.lib.so
	vfs_lwip.lib.so
	zlib.lib.so
}

# platform-specific modules
append_platform_drv_boot_modules
build_boot_image $boot_modules

append qemu_args " -net nic,model=e1000 "
append qemu_args " -net user -net dump,file=[run_dir].pcap"

run_genode_until forever
