mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 22:47:50 +00:00
nic_dump/router.run: share nic_router.inc
Move common stuff from both scripts to the new include file. Ref #2543
This commit is contained in:
parent
657fa16f8c
commit
9e888df3c9
@ -5,126 +5,14 @@
|
||||
proc enable_test_1 { } { return 1 }
|
||||
proc enable_test_2 { } { return 1 }
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
source ${genode_dir}/repos/libports/run/nic_router.inc
|
||||
|
||||
proc nic_drv { } {
|
||||
if {[nic_drv_binary] == "usb_drv"} { return usb_drv }
|
||||
if {[nic_drv_binary] == ""} { return "" }
|
||||
return nic_drv
|
||||
}
|
||||
lappend targets server/nic_dump
|
||||
|
||||
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 }
|
||||
if {[have_spec gpio]} { return gpio_drv }
|
||||
}
|
||||
|
||||
if {[nic_drv] == ""} {
|
||||
puts "\n Run script is not supported on this platform. \n"; exit 0 }
|
||||
|
||||
proc nic_drv_build { } {
|
||||
if {[nic_drv] == "nic_drv"} { return drivers/nic }
|
||||
if {[nic_drv] == "usb_drv"} { return drivers/usb }
|
||||
}
|
||||
|
||||
proc gpio_drv_build { } { if {[gpio_drv] != ""} { return drivers/gpio } }
|
||||
|
||||
build "core init drivers/timer server/nic_router server/nic_bridge
|
||||
test/lwip/http_srv_static test/lwip/http_clnt test/lxip/udp_echo
|
||||
test/lxip/udp_client server/nic_dump [nic_drv_build] [gpio_drv_build]
|
||||
[platform_drv_build_components]"
|
||||
build $targets
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
proc gpio_drv_config { } {
|
||||
if {[have_spec gpio]} {
|
||||
append result {
|
||||
<start name="} [gpio_drv] {" caps="140">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
||||
proc nic_drv_config { } {
|
||||
if {[nic_drv] == "nic_drv"} {
|
||||
append result {
|
||||
<start name="nic_drv">
|
||||
<binary name="} [nic_drv_binary] {"/>
|
||||
<resource name="RAM" quantum="6M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
if {[nic_drv] == "usb_drv"} {
|
||||
append result {
|
||||
<start name="usb_drv" caps="120">
|
||||
<resource name="RAM" quantum="14M"/>
|
||||
<provides>
|
||||
<service name="Nic"/>
|
||||
</provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
</config>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
||||
proc client_bin { prot } {
|
||||
if {$prot == "udp"} { return "test-lxip_udp_client" }
|
||||
if {$prot == "http"} { return "test-http_clnt" } }
|
||||
|
||||
proc server_bin { prot } {
|
||||
if {$prot == "udp"} { return "test-lxip_udp_echo" }
|
||||
if {$prot == "http"} { return "test-lwip_httpsrv_static" } }
|
||||
|
||||
proc ram_quota { prot } {
|
||||
if {$prot == "udp"} { return 29M }
|
||||
if {$prot == "http"} { return 12M }
|
||||
}
|
||||
|
||||
proc client_config { prot index ip_addr gateway netmask nic srv_port srv_ip } {
|
||||
append result {
|
||||
<start name="} $prot {_client_} $index {" caps="200">
|
||||
<binary name="} [client_bin $prot] {" />
|
||||
<resource name="RAM" quantum="} [ram_quota $prot] {"/>
|
||||
<route>
|
||||
<service name="Nic"> <child name="} $nic {"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
<config server_ip="} $srv_ip {" server_port="} $srv_port {">
|
||||
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {"
|
||||
gateway="} $gateway {" netmask="} $netmask {"/>
|
||||
</config>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
|
||||
proc server_config { prot index ip_addr gateway netmask nic port } {
|
||||
append result {
|
||||
<start name="} $prot {_server_} $index {" caps="200">
|
||||
<binary name="} [server_bin $prot] {" />
|
||||
<resource name="RAM" quantum="} [ram_quota $prot] {"/>
|
||||
<route>
|
||||
<service name="Nic"> <child name="} $nic {"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
<config port="} $port {">
|
||||
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {"
|
||||
gateway="} $gateway {" netmask="} $netmask {"/>
|
||||
</config>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
|
||||
proc test_1_config { } {
|
||||
if {[enable_test_1]} { return "
|
||||
[client_config udp 2 10.0.2.212 10.0.2.1 255.255.255.0 nic_bridge 1 10.0.2.55]
|
||||
@ -138,7 +26,7 @@ proc test_2_config { } {
|
||||
}
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<config prio_levels="2">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="IRQ"/>
|
||||
@ -160,12 +48,12 @@ append config {
|
||||
} [nic_drv_config] {
|
||||
} [platform_drv_config] {
|
||||
|
||||
<start name="timer">
|
||||
<start name="timer" priority="0">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
|
||||
<start name="nic_dump">
|
||||
<start name="nic_dump" priority="-1">
|
||||
<resource name="RAM" quantum="6M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config uplink="bridge" downlink="router" time="yes"/>
|
||||
@ -175,7 +63,7 @@ append config {
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="nic_router" caps="200">
|
||||
<start name="nic_router" caps="200" priority="-1">
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config rtt_sec="6" verbose="no">
|
||||
@ -222,7 +110,7 @@ append config {
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="nic_bridge" caps="200">
|
||||
<start name="nic_bridge" caps="200" priority="-1">
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
<config>
|
||||
@ -246,21 +134,8 @@ append config {
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Create single image and execute
|
||||
#
|
||||
lappend boot_modules nic_dump
|
||||
|
||||
|
||||
build_boot_image "
|
||||
core init timer nic_router nic_bridge ld.lib.so libc.lib.so libm.lib.so
|
||||
posix.lib.so lwip.lib.so lxip.lib.so test-http_clnt
|
||||
test-lwip_httpsrv_static nic_dump test-lxip_udp_echo test-lxip_udp_client
|
||||
[nic_drv_binary] [gpio_drv] [platform_drv_boot_modules]"
|
||||
|
||||
proc nic_qemu_args { } {
|
||||
if {[have_spec x86]} { return "-net nic,model=e1000" }
|
||||
if {[have_spec lan9118]} { return "-net nic,model=lan9118" } }
|
||||
|
||||
append qemu_args "-nographic -net user [nic_qemu_args]"
|
||||
build_boot_image $boot_modules
|
||||
|
||||
run_genode_until {.*Test done.*\n.*Test done.*\n} 120
|
||||
|
120
repos/libports/run/nic_router.inc
Normal file
120
repos/libports/run/nic_router.inc
Normal file
@ -0,0 +1,120 @@
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
|
||||
proc nic_drv { } {
|
||||
if {[nic_drv_binary] == "usb_drv"} { return usb_drv }
|
||||
if {[nic_drv_binary] == ""} { return "" }
|
||||
return nic_drv
|
||||
}
|
||||
|
||||
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 }
|
||||
if {[have_spec gpio]} { return gpio_drv }
|
||||
}
|
||||
|
||||
if {[nic_drv] == ""} {
|
||||
puts "\n Run script is not supported on this platform. \n"; exit 0 }
|
||||
|
||||
proc nic_drv_build { } {
|
||||
if {[nic_drv] == "nic_drv"} { return drivers/nic }
|
||||
if {[nic_drv] == "usb_drv"} { return drivers/usb }
|
||||
}
|
||||
|
||||
proc gpio_drv_build { } { if {[gpio_drv] != ""} { return drivers/gpio } }
|
||||
|
||||
set targets "core init drivers/timer server/nic_router server/nic_bridge
|
||||
test/lwip/http_srv_static test/lwip/http_clnt test/lwip/udp
|
||||
[nic_drv_build] [gpio_drv_build] [platform_drv_build_components]"
|
||||
|
||||
proc gpio_drv_config { } {
|
||||
if {[have_spec gpio]} {
|
||||
append result {
|
||||
<start name="} [gpio_drv] {" caps="140" priority="-1">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
||||
proc nic_drv_config { } {
|
||||
if {[nic_drv] == "nic_drv"} {
|
||||
append result {
|
||||
<start name="nic_drv" priority="-1">
|
||||
<binary name="} [nic_drv_binary] {"/>
|
||||
<resource name="RAM" quantum="6M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
if {[nic_drv] == "usb_drv"} {
|
||||
append result {
|
||||
<start name="usb_drv" caps="120" priority="-1">
|
||||
<resource name="RAM" quantum="14M"/>
|
||||
<provides>
|
||||
<service name="Nic"/>
|
||||
</provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
</config>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
||||
proc client_bin { prot } {
|
||||
if {$prot == "udp"} { return "test-lwip-udp-client" }
|
||||
if {$prot == "http"} { return "test-http_clnt" } }
|
||||
|
||||
proc server_bin { prot } {
|
||||
if {$prot == "udp"} { return "test-lwip-udp-server" }
|
||||
if {$prot == "http"} { return "test-lwip_httpsrv_static" } }
|
||||
|
||||
proc client_config { prot index ip_addr gateway netmask nic srv_port srv_ip } {
|
||||
append result {
|
||||
<start name="} $prot {_client_} $index {" caps="200" priority="-1">
|
||||
<binary name="} [client_bin $prot] {" />
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<route>
|
||||
<service name="Nic"> <child name="} $nic {"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
<config server_ip="} $srv_ip {" server_port="} $srv_port {">
|
||||
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {"
|
||||
gateway="} $gateway {" netmask="} $netmask {"/>
|
||||
</config>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
|
||||
proc server_config { prot index ip_addr gateway netmask nic port } {
|
||||
append result {
|
||||
<start name="} $prot {_server_} $index {" caps="200" priority="-1">
|
||||
<binary name="} [server_bin $prot] {" />
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<route>
|
||||
<service name="Nic"> <child name="} $nic {"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
<config port="} $port {">
|
||||
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {"
|
||||
gateway="} $gateway {" netmask="} $netmask {"/>
|
||||
</config>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
|
||||
set boot_modules "
|
||||
core init timer nic_router nic_bridge ld.lib.so libc.lib.so libm.lib.so
|
||||
lwip.lib.so posix.lib.so [client_bin udp] [server_bin udp]
|
||||
[client_bin http] [server_bin http] [nic_drv_binary] [gpio_drv]
|
||||
[platform_drv_boot_modules]"
|
||||
|
||||
proc nic_qemu_args { } {
|
||||
if {[have_spec x86]} { return "-net nic,model=e1000" }
|
||||
if {[have_spec lan9118]} { return "-net nic,model=lan9118" } }
|
||||
|
||||
append qemu_args "-nographic -net user [nic_qemu_args]"
|
@ -9,120 +9,12 @@ proc enable_test_4 { } { return 1 }
|
||||
proc enable_test_5 { } { return 1 }
|
||||
proc enable_test_6 { } { return 1 }
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
source ${genode_dir}/repos/libports/run/nic_router.inc
|
||||
|
||||
proc nic_drv { } {
|
||||
if {[nic_drv_binary] == "usb_drv"} { return usb_drv }
|
||||
if {[nic_drv_binary] == ""} { return "" }
|
||||
return nic_drv
|
||||
}
|
||||
|
||||
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 }
|
||||
if {[have_spec gpio]} { return gpio_drv }
|
||||
}
|
||||
|
||||
if {[nic_drv] == ""} {
|
||||
puts "\n Run script is not supported on this platform. \n"; exit 0 }
|
||||
|
||||
proc nic_drv_build { } {
|
||||
if {[nic_drv] == "nic_drv"} { return drivers/nic }
|
||||
if {[nic_drv] == "usb_drv"} { return drivers/usb }
|
||||
}
|
||||
|
||||
proc gpio_drv_build { } { if {[gpio_drv] != ""} { return drivers/gpio } }
|
||||
|
||||
build "core init drivers/timer server/nic_router server/nic_bridge
|
||||
test/lwip/http_srv_static test/lwip/http_clnt test/lwip/udp
|
||||
[nic_drv_build] [gpio_drv_build] [platform_drv_build_components]"
|
||||
build $targets
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
proc gpio_drv_config { } {
|
||||
if {[have_spec gpio]} {
|
||||
append result {
|
||||
<start name="} [gpio_drv] {" caps="140" priority="-1">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides><service name="Gpio"/></provides>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
||||
proc nic_drv_config { } {
|
||||
if {[nic_drv] == "nic_drv"} {
|
||||
append result {
|
||||
<start name="nic_drv" priority="-1">
|
||||
<binary name="} [nic_drv_binary] {"/>
|
||||
<resource name="RAM" quantum="6M"/>
|
||||
<provides><service name="Nic"/></provides>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
if {[nic_drv] == "usb_drv"} {
|
||||
append result {
|
||||
<start name="usb_drv" caps="120" priority="-1">
|
||||
<resource name="RAM" quantum="14M"/>
|
||||
<provides>
|
||||
<service name="Nic"/>
|
||||
</provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
</config>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
||||
proc client_bin { prot } {
|
||||
if {$prot == "udp"} { return "test-lwip-udp-client" }
|
||||
if {$prot == "http"} { return "test-http_clnt" } }
|
||||
|
||||
proc server_bin { prot } {
|
||||
if {$prot == "udp"} { return "test-lwip-udp-server" }
|
||||
if {$prot == "http"} { return "test-lwip_httpsrv_static" } }
|
||||
|
||||
proc client_config { prot index ip_addr gateway netmask nic srv_port srv_ip } {
|
||||
append result {
|
||||
<start name="} $prot {_client_} $index {" caps="200" priority="-1">
|
||||
<binary name="} [client_bin $prot] {" />
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<route>
|
||||
<service name="Nic"> <child name="} $nic {"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
<config server_ip="} $srv_ip {" server_port="} $srv_port {">
|
||||
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {"
|
||||
gateway="} $gateway {" netmask="} $netmask {"/>
|
||||
</config>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
|
||||
proc server_config { prot index ip_addr gateway netmask nic port } {
|
||||
append result {
|
||||
<start name="} $prot {_server_} $index {" caps="200" priority="-1">
|
||||
<binary name="} [server_bin $prot] {" />
|
||||
<resource name="RAM" quantum="10M"/>
|
||||
<route>
|
||||
<service name="Nic"> <child name="} $nic {"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
<config port="} $port {">
|
||||
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {"
|
||||
gateway="} $gateway {" netmask="} $netmask {"/>
|
||||
</config>
|
||||
</start>}
|
||||
return $result
|
||||
}
|
||||
|
||||
proc test_1_config { } {
|
||||
if {[enable_test_1]} { return "
|
||||
[client_config udp 1 10.0.98.55 10.0.98.33 255.255.255.0 nic_router 1337 10.0.98.33]
|
||||
@ -263,21 +155,6 @@ append config {
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Create single image and execute
|
||||
#
|
||||
|
||||
|
||||
build_boot_image "
|
||||
core init timer nic_router nic_bridge ld.lib.so libc.lib.so libm.lib.so
|
||||
lwip.lib.so posix.lib.so test-http_clnt test-lwip_httpsrv_static
|
||||
test-lwip-udp-client test-lwip-udp-server [nic_drv_binary] [gpio_drv]
|
||||
[platform_drv_boot_modules]"
|
||||
|
||||
proc nic_qemu_args { } {
|
||||
if {[have_spec x86]} { return "-net nic,model=e1000" }
|
||||
if {[have_spec lan9118]} { return "-net nic,model=lan9118" } }
|
||||
|
||||
append qemu_args "-nographic -net user [nic_qemu_args]"
|
||||
build_boot_image $boot_modules
|
||||
|
||||
run_genode_until {.*Test done.*\n.*Test done.*\n.*Test done.*\n.*Test done.*\n.*Test done.*\n.*Test done.*\n} 120
|
||||
|
Loading…
Reference in New Issue
Block a user