mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-27 01:11:06 +00:00
250 lines
7.2 KiB
Plaintext
250 lines
7.2 KiB
Plaintext
set use_usb_driver [expr [have_spec omap4] || [have_spec arndale] || [have_spec rpi]]
|
|
set use_nic_driver [expr !$use_usb_driver && ![have_spec linux] && ![have_spec odroid_xu]]
|
|
|
|
if {[expr !$use_usb_driver && !$use_nic_driver] ||
|
|
[expr [have_include "power_on/qemu"] && [have_spec zynq]] ||
|
|
[expr [have_spec imx53] && [have_spec trustzone]]} {
|
|
puts "\n Run script is not supported on this platform. \n"; exit 0 }
|
|
|
|
|
|
set bridge_mac "02:02:02:02:02:00"
|
|
|
|
# autopilot: configure disjoint mac-address ranges for x86_32, x86_64, and others
|
|
if {[get_cmd_switch --autopilot]} {
|
|
if {[have_spec x86_32]} { set bridge_mac "02:02:02:02:32:00" }
|
|
if {[have_spec x86_64]} { set bridge_mac "02:02:02:02:64:00" }
|
|
}
|
|
|
|
set build_components {
|
|
core init
|
|
drivers/timer
|
|
server/tcp_terminal
|
|
server/nic_bridge
|
|
noux/net lib/libc_noux
|
|
noux-pkg/netcat
|
|
}
|
|
|
|
proc gpio_drv { } { if {[have_spec rpi] && [have_spec hw]} { return hw_gpio_drv }
|
|
if {[have_spec rpi] && [have_spec foc]} { return foc_gpio_drv }
|
|
return gpio_drv }
|
|
|
|
lappend_if $use_usb_driver build_components drivers/usb
|
|
lappend_if $use_nic_driver build_components drivers/nic
|
|
lappend_if [have_spec gpio] build_components drivers/gpio
|
|
lappend_if [have_include "power_on/qemu"] build_components drivers/uart
|
|
|
|
source ${genode_dir}/repos/base/run/platform_drv.inc
|
|
append_platform_drv_build_components
|
|
|
|
build $build_components
|
|
|
|
#
|
|
# The '<build-dir>/bin/etc/' directory is expected to contain the
|
|
# files 'services', 'protocols', and 'hosts'.
|
|
# Download these files from the FreeBSD source tree is possible.
|
|
#
|
|
exec mkdir -p bin/etc
|
|
set freebsd_url "http://svn.freebsd.org/base/release/8.2.0/etc"
|
|
foreach etc_file { services protocols hosts } {
|
|
if {![file exists bin/etc/$etc_file]} {
|
|
catch { exec wget -c -P bin/etc $freebsd_url/$etc_file } } }
|
|
|
|
exec tar rfv bin/netcat.tar -h -C bin/ etc
|
|
|
|
create_boot_directory
|
|
|
|
append config {
|
|
<config verbose="yes">
|
|
<parent-provides>
|
|
<service name="ROM"/>
|
|
<service name="LOG"/>
|
|
<service name="RM"/>
|
|
<service name="CPU"/>
|
|
<service name="PD"/>
|
|
<service name="IRQ"/>
|
|
<service name="IO_MEM"/>
|
|
<service name="IO_PORT"/>
|
|
</parent-provides>
|
|
<default-route>
|
|
<any-service> <parent/> <any-child/> </any-service>
|
|
</default-route>
|
|
<default caps="100"/>
|
|
<start name="timer">
|
|
<resource name="RAM" quantum="1M"/>
|
|
<provides><service name="Timer"/></provides>
|
|
</start>}
|
|
|
|
append_if [have_include "power_on/qemu"] config {
|
|
<start name="uart_drv">
|
|
<resource name="RAM" quantum="1M"/>
|
|
<provides>
|
|
<service name="Terminal"/>
|
|
<service name="Uart"/>
|
|
</provides>
|
|
<config>
|
|
<policy label_prefix="noux_net" uart="1"/>
|
|
</config>
|
|
</start>}
|
|
|
|
if {![have_include "power_on/qemu"]} {
|
|
append config {
|
|
<start name="tcp_terminal" caps="200">
|
|
<resource name="RAM" quantum="5M"/>
|
|
<provides> <service name="Terminal"/> </provides>
|
|
<route>
|
|
<service name="Nic"> <child name="nic_bridge"/> </service>
|
|
<any-service> <parent/> <any-child/> </any-service>
|
|
</route>
|
|
<config>
|
|
<policy label_prefix="noux_net" port="8888"/>
|
|
</config>
|
|
</start>
|
|
<start name="nic_bridge" caps="200">
|
|
<resource name="RAM" quantum="6M"/>
|
|
<provides><service name="Nic"/></provides>
|
|
<config mac="} $bridge_mac {"/>
|
|
<route>}
|
|
append_if $use_nic_driver config {
|
|
<service name="Nic"> <child name="nic_drv"/></service>}
|
|
append_if $use_usb_driver config {
|
|
<service name="Nic"> <child name="usb_drv"/></service>}
|
|
append config {
|
|
<any-service> <parent/> </any-service>
|
|
</route>
|
|
</start>}
|
|
}
|
|
|
|
append_if $use_nic_driver config {
|
|
<start name="nic_drv" caps="130">
|
|
<resource name="RAM" quantum="20M"/>
|
|
<provides> <service name="Nic"/> </provides>
|
|
} [nic_drv_config] {
|
|
</start>}
|
|
|
|
append_if [have_spec gpio] config "
|
|
<start name=\"[gpio_drv]\" caps=\"140\">
|
|
<resource name=\"RAM\" quantum=\"4M\"/>
|
|
<provides><service name=\"Gpio\"/></provides>
|
|
<config/>
|
|
</start>"
|
|
|
|
append_if $use_usb_driver config {
|
|
<start name="usb_drv" caps="120">
|
|
<resource name="RAM" quantum="14M"/>
|
|
<provides>
|
|
<service name="Nic"/>
|
|
<service name="Input"/>
|
|
</provides>
|
|
<config uhci="no" ehci="yes" xhci="no">
|
|
<nic mac="02:00:00:00:01:01"/>
|
|
</config>
|
|
</start>}
|
|
|
|
append_platform_drv_config
|
|
|
|
append config {
|
|
<start name="noux_net" caps="500">
|
|
<resource name="RAM" quantum="1G"/>
|
|
<config>
|
|
<fstab> <tar name="netcat.tar" at="/"/> </fstab>
|
|
<start name="/bin/netcat">
|
|
<arg value="-l"/>
|
|
<arg value="-p 5555"/>
|
|
</start>
|
|
</config>}
|
|
|
|
append_if [expr ![have_include "power_on/qemu"]] config {
|
|
<route>
|
|
<service name="Nic"> <child name="nic_bridge"/> </service>
|
|
<any-service> <parent/> <any-child/> </any-service>
|
|
</route>}
|
|
|
|
append config {
|
|
</start>
|
|
</config>
|
|
}
|
|
|
|
install_config $config
|
|
|
|
#
|
|
# Boot modules
|
|
#
|
|
|
|
# generic modules
|
|
set boot_modules {
|
|
core init timer tcp_terminal nic_bridge
|
|
ld.lib.so noux_net libc.lib.so vfs.lib.so libm.lib.so libc_pipe.lib.so pthread.lib.so
|
|
libc_noux.lib.so lwip_legacy.lib.so netcat.tar posix.lib.so
|
|
}
|
|
|
|
# platform-specific modules
|
|
lappend_if $use_nic_driver boot_modules nic_drv
|
|
lappend_if $use_usb_driver boot_modules usb_drv
|
|
lappend_if [have_include "power_on/qemu"] boot_modules uart_drv
|
|
lappend_if [have_spec gpio] boot_modules [gpio_drv]
|
|
|
|
append_platform_drv_boot_modules
|
|
|
|
build_boot_image $boot_modules
|
|
|
|
set noux_output_file "noux_output.log"
|
|
set serial_ip_addr "localhost"
|
|
set noux_ip_addr "localhost"
|
|
|
|
if {[have_include "power_on/qemu"]} {
|
|
#
|
|
# Redirect the output of Noux via the virtual serial port 1 into a file to be
|
|
# dumped after the successful completion of the test.
|
|
append qemu_args " -nographic"
|
|
append qemu_args " -serial mon:stdio"
|
|
append qemu_args " -serial file:$noux_output_file"
|
|
|
|
append_if [have_spec x86] qemu_args " -net nic,model=e1000 "
|
|
append_if [have_spec lan9118] qemu_args " -net nic,model=lan9118 "
|
|
|
|
append qemu_args " -net user -redir tcp:5555::5555 "
|
|
|
|
run_genode_until {.*got IP address.*\n} 60
|
|
set serial_id [output_spawn_id]
|
|
} else {
|
|
# wait until we got both IP addresses in the output afterwards
|
|
run_genode_until {.*got IP address.*\n.*got IP address.*\n} 60
|
|
set serial_id [output_spawn_id]
|
|
|
|
regexp {\[init -> noux_net\] got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output noux_ip_addr
|
|
regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $noux_ip_addr noux_ip_addr
|
|
|
|
regexp {\[init -> tcp_terminal\] got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output serial_ip_addr
|
|
regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $serial_ip_addr serial_ip_addr
|
|
|
|
# connect to Genode target and reading log output via network connection
|
|
|
|
spawn socat -u tcp:$serial_ip_addr:8888 OPEN:$noux_output_file,creat,append
|
|
}
|
|
|
|
sleep 4
|
|
|
|
|
|
puts "--- serial '$serial_ip_addr' noux '$noux_ip_addr'"
|
|
#
|
|
# This usage of netcat needs the OpenBSD nc command and will not
|
|
# work with GNU netcat because it will not close the connection
|
|
# automatically after sending the string.
|
|
#
|
|
exec echo -e "Hello Genode" | netcat $noux_ip_addr 5555 &
|
|
|
|
run_genode_until {exited with exit value 1} 20 $serial_id
|
|
|
|
sleep 4
|
|
|
|
set output [exec cat $noux_output_file]
|
|
puts "\noutput:\n$output\n"
|
|
exec rm $noux_output_file
|
|
|
|
exec rm -r bin/etc
|
|
|
|
if {![regexp {Hello Genode} $output dummy]} {
|
|
puts stderr "Error: output not as expected"
|
|
exit 1
|
|
}
|