#
# Build
#

if {[have_spec okl4] == 0} {
	puts "Runs on OKL4 only"
	exit 0
}

# generic components
set build_components {
	core
	init
	drivers/timer
	drivers/pci
	drivers/framebuffer/vesa
	drivers/input/ps2
	server/rom_loopdev
	oklinux
}

build $build_components
create_boot_directory


#
# Config
#

set config  {
<config>
	<parent-provides>
		<service name="ROM"/>
		<service name="RAM"/>
		<service name="IRQ"/>
		<service name="IO_MEM"/>
		<service name="IO_PORT"/>
		<service name="CAP"/>
		<service name="PD"/>
		<service name="RM"/>
		<service name="CPU"/>
		<service name="LOG"/>
		<service name="SIGNAL"/>
	</parent-provides>
	<default-route>
		<any-service> <parent/> <any-child/> </any-service>
	</default-route>
	<start name="pci_drv">
		<resource name="RAM" quantum="1M"/>
		<provides><service name="PCI"/></provides>
	</start>
	<start name="vesa_drv">
		<resource name="RAM" quantum="1M"/>
		<provides><service name="Framebuffer"/></provides>
		<config><!--<preinit/>--></config>
	</start>
	<start name="ps2_drv">
		<resource name="RAM" quantum="1M"/>
		<provides><service name="Input"/></provides>
	</start>
	<start name="timer">
		<resource name="RAM" quantum="1M"/>
		<provides><service name="Timer"/></provides>
	</start>
	<start name="rom_loopdev">
		<resource name="RAM" quantum="1M"/>
		<provides><service name="Block"/></provides>
		<config file="tinycore.img" block_size="512"/>
	</start>
	<start name="vmlinux">
		<resource name="RAM" quantum="256M"/>
		<config>
			<commandline args="root=/dev/sda host=tinycore"/>
			<initrd name="initrd.gz"/>
			<screens><framebuffer/></screens>
			<block/>
		</config>
	</start>
</config>
}

install_config $config


#
# Boot modules
#

set boot_modules { }

# basic binaries
lappend boot_modules "core init"

# drivers
lappend boot_modules "pci_drv vesa_drv ps2_drv timer rom_loopdev"

# oklinux
lappend boot_modules "vmlinux initrd.gz tinycore.img"

build_boot_image  [join $boot_modules " "]

append qemu_args " -m 512 "

run_genode_until forever
