diff --git a/repos/libports/run/fatfs_blkio.run b/repos/libports/run/fatfs_blkio.run index 237f4e47ba..a0c2050e6e 100644 --- a/repos/libports/run/fatfs_blkio.run +++ b/repos/libports/run/fatfs_blkio.run @@ -31,7 +31,8 @@ set build_components { test/fatfs_block_io } -lappend_if $use_sd_card_drv build_components drivers/sd_card +lappend_if $use_sd_card_drv build_components drivers/platform +lappend_if $use_sd_card_drv build_components drivers/sd_card/pl180 source ${genode_dir}/repos/base/run/platform_drv.inc append_platform_drv_build_components @@ -95,7 +96,23 @@ append_if $use_ahci config { } append_if $use_sd_card_drv config { - + + + + + + + + + + + + + + + + + @@ -139,7 +156,8 @@ set boot_modules { test-fatfs_block_io } -lappend_if $use_sd_card_drv boot_modules pbxa9_sd_card_drv +lappend_if $use_sd_card_drv boot_modules platform_drv +lappend_if $use_sd_card_drv boot_modules pl180_sd_card_drv lappend_if $use_vfs_block boot_modules vfs_import.lib.so append_platform_drv_boot_modules diff --git a/repos/libports/run/libc_block.run b/repos/libports/run/libc_block.run index 0b19cd0032..3b53665bee 100644 --- a/repos/libports/run/libc_block.run +++ b/repos/libports/run/libc_block.run @@ -19,7 +19,8 @@ set build_components { } lappend_if $use_ahci_drv build_components drivers/ahci -lappend_if $use_sd_card_drv build_components drivers/sd_card +lappend_if $use_sd_card_drv build_components drivers/platform +lappend_if $use_sd_card_drv build_components drivers/sd_card/pl180 lappend_if $use_vfs_block build_components server/vfs_block lappend_if $use_vfs_block build_components lib/vfs/import @@ -79,7 +80,23 @@ append_if $use_ahci_drv config { } append_if $use_sd_card_drv config { - + + + + + + + + + + + + + + + + + @@ -119,7 +136,8 @@ set boot_modules { } lappend_if $use_ahci_drv boot_modules ahci_drv -lappend_if $use_sd_card_drv boot_modules pbxa9_sd_card_drv +lappend_if $use_sd_card_drv boot_modules platform_drv +lappend_if $use_sd_card_drv boot_modules pl180_sd_card_drv lappend_if $use_vfs_block boot_modules vfs_block lappend_if $use_vfs_block boot_modules vfs_import.lib.so diff --git a/repos/libports/run/libc_filesystem_test.inc b/repos/libports/run/libc_filesystem_test.inc index c46f26b8a8..c4c2bc9d76 100644 --- a/repos/libports/run/libc_filesystem_test.inc +++ b/repos/libports/run/libc_filesystem_test.inc @@ -39,7 +39,8 @@ set build_components { lappend build_components test/libc_$filesystem lappend_if $use_ahci build_components drivers/ahci -lappend_if $use_sd_card_drv build_components drivers/sd_card +lappend_if $use_sd_card_drv build_components drivers/platform +lappend_if $use_sd_card_drv build_components drivers/sd_card/pl180 lappend_if $use_vfs_block build_components server/vfs_block lappend_if $use_vfs_block build_components lib/vfs/import @@ -111,7 +112,23 @@ append_if $use_ahci config { } append_if $use_sd_card_drv config { - + + + + + + + + + + + + + + + + + @@ -167,7 +184,8 @@ append boot_modules " " append boot_modules libc_$filesystem.lib.so lappend_if $use_ahci boot_modules ahci_drv -lappend_if $use_sd_card_drv boot_modules pbxa9_sd_card_drv +lappend_if $use_sd_card_drv boot_modules platform_drv +lappend_if $use_sd_card_drv boot_modules pl180_sd_card_drv lappend_if $use_vfs_block boot_modules vfs_block lappend_if $use_vfs_block boot_modules test.hda lappend_if $use_vfs_block boot_modules vfs_import.lib.so diff --git a/repos/libports/run/libc_vfs_filesystem_test.inc b/repos/libports/run/libc_vfs_filesystem_test.inc index 19d9eaf2d2..3deb3f8cbd 100644 --- a/repos/libports/run/libc_vfs_filesystem_test.inc +++ b/repos/libports/run/libc_vfs_filesystem_test.inc @@ -45,7 +45,8 @@ set build_components { test/libc_vfs } lappend build_components {*}$test_build_components -lappend_if $use_sd_card_drv build_components drivers/sd_card +lappend_if $use_sd_card_drv build_components drivers/platform +lappend_if $use_sd_card_drv build_components drivers/sd_card/pl180 source ${genode_dir}/repos/base/run/platform_drv.inc append_platform_drv_build_components @@ -123,7 +124,23 @@ append_if $use_ahci config { } append_if $use_sd_card_drv config { - + + + + + + + + + + + + + + + + + @@ -188,7 +205,8 @@ append boot_modules { lappend boot_modules {*}$test_boot_modules -lappend_if $use_sd_card_drv boot_modules pbxa9_sd_card_drv +lappend_if $use_sd_card_drv boot_modules platform_drv +lappend_if $use_sd_card_drv boot_modules pl180_sd_card_drv lappend_if $use_vfs_block boot_modules test.hda append_platform_drv_boot_modules diff --git a/repos/libports/run/libc_vfs_fs_test.inc b/repos/libports/run/libc_vfs_fs_test.inc index b09dedf032..19c17cfe26 100644 --- a/repos/libports/run/libc_vfs_fs_test.inc +++ b/repos/libports/run/libc_vfs_fs_test.inc @@ -24,7 +24,8 @@ set build_components { lappend build_components $build_component lappend_if $use_ahci_drv build_components drivers/ahci -lappend_if $use_sd_card_drv build_components drivers/sd_card +lappend_if $use_sd_card_drv build_components drivers/platform +lappend_if $use_sd_card_drv build_components drivers/sd_card/pl180 lappend_if $use_vfs_block build_components server/vfs_block source ${genode_dir}/repos/base/run/platform_drv.inc @@ -99,7 +100,23 @@ append_if $use_ahci_drv config { } append_if $use_sd_card_drv config { - + + + + + + + + + + + + + + + + + @@ -141,7 +158,8 @@ set boot_modules { lappend boot_modules $binary lappend_if $use_ahci_drv boot_modules ahci_drv -lappend_if $use_sd_card_drv boot_modules pbxa9_sd_card_drv +lappend_if $use_sd_card_drv boot_modules platform_drv +lappend_if $use_sd_card_drv boot_modules pl180_sd_card_drv lappend_if $use_vfs_block boot_modules vfs_import.lib.so lappend_if $use_vfs_block boot_modules vfs_block lappend_if $use_vfs_block boot_modules test.hda diff --git a/repos/os/run/sd_card.run b/repos/os/run/sd_card.run index 178fd16421..0ae7a63baa 100644 --- a/repos/os/run/sd_card.run +++ b/repos/os/run/sd_card.run @@ -1,85 +1,88 @@ -# -# Build -# - assert_spec pbxa9 -# generic components -set build_components { - core init - timer - drivers/sd_card - test/block/client -} - -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - -build $build_components create_boot_directory +import_from_depot [depot_user]/src/[base_src] \ + [depot_user]/src/init \ + [depot_user]/src/platform_drv +build { drivers/sd_card test/block/client } -# -# Config -# +install_config { + + + + + + + + + + + -set config { - - - - - - - - - - - - - - } + + + + + + + + + + + + + + + + -append_platform_drv_config + + + + + + + + + + + -append config { - - - - - - - - - - - - } + + + + + + + + + + + + -install_config $config + + + + + + + + + + + + } +build_boot_image { pl180_sd_card_drv test-block-client } -# -# Boot modules -# - -# generic modules -set boot_modules { - core ld.lib.so init timer - pbxa9_sd_card_drv - test-block-client -} - -append_platform_drv_boot_modules set disk_image "bin/sd_card.img" - -build_boot_image $boot_modules -append qemu_args "-drive file=$disk_image,format=raw,if=sd,cache=writeback -nographic " - if { [file exists $disk_image] == 0 } then { # create empty block device file catch { exec dd if=/dev/zero of=$disk_image bs=1M count=512 } } - +append qemu_args "-drive file=$disk_image,format=raw,if=sd,cache=writeback -nographic " run_genode_until forever exec rm $disk_image diff --git a/repos/os/run/sd_card_bench.run b/repos/os/run/sd_card_bench.run index 5d9cbcc7ef..ee8ee1bb68 100644 --- a/repos/os/run/sd_card_bench.run +++ b/repos/os/run/sd_card_bench.run @@ -3,44 +3,78 @@ # proc buffer_size_kib {} { - if {[have_spec pl180]} { return [expr 12 * 1024] } + if {[have_spec pbxa9]} { return [expr 12 * 1024] } if {[have_spec imx8q_evk]} { return [expr 1024] } if {[have_spec imx6]} { return [expr 1024] } - if {[have_spec imx53] && - ![have_spec foc]} { return [expr 1024] } + if {[have_spec imx53]} { return [expr 1024] } if {[have_spec rpi]} { return [expr 4 * 1024] } puts "\n Run script is not supported on this platform. \n"; exit 0; } proc sd_card_drv {} { - if {[have_spec pbxa9]} { return pbxa9_sd_card_drv } - if {[have_spec imx8q_evk]} { return imx8q_evk_sd_card_drv } - if {[have_spec imx6q_sabrelite]} { return imx6q_sabrelite_sd_card_drv } + if {[have_spec pbxa9]} { return pl180_sd_card_drv } + if {[have_spec imx8q_evk]} { return imx8_sd_card_drv } + if {[have_spec imx6q_sabrelite]} { return imx6_sd_card_drv } if {[have_spec imx53]} { return imx53_sd_card_drv } - if {[have_spec rpi]} { return rpi_sd_card_drv } + if {[have_spec rpi]} { return rpi_sd_card_drv } puts "\n Run script is not supported on this platform. \n"; exit 0; } -# -# Build the boot modules -# +proc platform_drv {} { + if {[have_spec imx8q_evk]} { return imx8mq_platform_drv } + return platform_drv +} -set build_components { core init timer drivers/sd_card } +proc device_resources {} { + if {[have_spec pbxa9]} { + return { + + + } + } + if {[have_spec imx8q_evk]} { + return { + + + + + + + } + } + if {[have_spec imx6q_sabrelite]} { + return { + + + + } + } + if {[have_spec imx53]} { + return { + + + + } + } + if {[have_spec rpi]} { + return { + + + } + } + puts "\n Run script is not supported on this platform. \n"; + exit 0; +} -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components -build $build_components create_boot_directory +import_from_depot [depot_user]/src/[base_src] \ + [depot_user]/src/init \ + [depot_user]/src/platform_drv - -# -# Install the config -# - -append config { - +install_config { + @@ -50,40 +84,50 @@ append config { - - - - } + -append_platform_drv_config + + + + + + } [device_resources] { + + + + -append config { + + + + + + + - + + + + + + + + + + + -} -install_config $config + } - -# -# Create the boot image -# - -set boot_modules { - core ld.lib.so init - timer -} - -append boot_modules [sd_card_drv] -append_platform_drv_boot_modules -build_boot_image $boot_modules +build { drivers/sd_card } +build_boot_image [sd_card_drv] # @@ -104,4 +148,8 @@ if {[have_include power_on/qemu]} { run_genode_until "--- SD card benchmark finished ---" 120 -exec rm -f $disk_image +if {[have_include power_on/qemu]} { + if { [file exists $disk_image] != 0 } then { + exec rm -f $disk_image + } +} diff --git a/repos/os/run/tz_vmm.run b/repos/os/run/tz_vmm.run index f16bea3513..dda816affc 100644 --- a/repos/os/run/tz_vmm.run +++ b/repos/os/run/tz_vmm.run @@ -113,7 +113,7 @@ if { $mmc_rootfs } { # add targets that enable MMC access via paravirtualized block lappend targets timer lappend targets drivers/platform - lappend targets drivers/sd_card + lappend targets drivers/sd_card/imx53 lappend targets server/part_block } @@ -152,9 +152,12 @@ append_if $trusted_led config { - - - + + + + + + @@ -173,19 +176,12 @@ append_if $mmc_rootfs config { - - - - - - - - + + - - + @@ -260,7 +256,6 @@ if { $mmc_rootfs } { # add components that enable MMC access via parvirtualized block lappend boot_modules timer - lappend boot_modules imx53_platform_drv lappend boot_modules imx53_sd_card_drv lappend boot_modules part_block diff --git a/repos/os/src/drivers/sd_card/adma2.cc b/repos/os/src/drivers/sd_card/adma2.cc index 03aafd2721..88fc5423e1 100644 --- a/repos/os/src/drivers/sd_card/adma2.cc +++ b/repos/os/src/drivers/sd_card/adma2.cc @@ -12,6 +12,7 @@ */ /* Genode includes */ +#include #include /* local includes */ @@ -60,6 +61,6 @@ int Table::setup_request(size_t const size, addr_t const buffer_phys) consumed += curr; } /* ensure that all descriptor writes were actually executed */ - asm volatile ("dsb #15" ::: "memory"); + Genode::memory_barrier(); return 0; } diff --git a/repos/os/src/drivers/sd_card/benchmark.h b/repos/os/src/drivers/sd_card/benchmark.h index 9a622861f4..908960a10c 100644 --- a/repos/os/src/drivers/sd_card/benchmark.h +++ b/repos/os/src/drivers/sd_card/benchmark.h @@ -48,6 +48,7 @@ struct Benchmark }; Env &env; + Platform::Connection platform { env }; Attached_rom_dataspace config { env, "config" }; Packet_descriptor pkt { }; uint64_t time_before_ms { }; @@ -55,7 +56,7 @@ struct Benchmark Operation operation { READ }; Signal_handler ack_handler { env.ep(), *this, &Benchmark::update_state }; Driver_session drv_session { ack_handler }; - Sd_card::Driver drv { env }; + Sd_card::Driver drv { env, platform }; size_t const buf_size_kib { config.xml().attribute_value("buffer_size_kib", (size_t)0) }; size_t const buf_size { buf_size_kib * 1024 }; diff --git a/repos/os/src/drivers/sd_card/spec/imx/driver.cc b/repos/os/src/drivers/sd_card/imx/driver.cc similarity index 96% rename from repos/os/src/drivers/sd_card/spec/imx/driver.cc rename to repos/os/src/drivers/sd_card/imx/driver.cc index 108cf92335..cc2c97ff12 100644 --- a/repos/os/src/drivers/sd_card/spec/imx/driver.cc +++ b/repos/os/src/drivers/sd_card/imx/driver.cc @@ -519,3 +519,20 @@ void Driver::_clock(Clock clock) _disable_clock(); _clock_finish(clock); } + + +Driver::Driver(Env & env, Platform::Connection & platform) +: Driver_base(env.ram()), + Platform::Device_client(platform.device_by_index(0)), + Attached_dataspace(env.rm(), Device_client::io_mem_dataspace()), + Mmio((addr_t)local_addr()), + _env(env), + _platform(platform), + _irq(Device_client::irq()) +{ + log("SD card detected"); + log("capacity: ", card_info().capacity_mb(), " MiB"); +} + + +Driver::~Driver() { _platform.release_device(rpc_cap()); } diff --git a/repos/os/src/drivers/sd_card/spec/imx/driver.h b/repos/os/src/drivers/sd_card/imx/driver.h similarity index 93% rename from repos/os/src/drivers/sd_card/spec/imx/driver.h rename to repos/os/src/drivers/sd_card/imx/driver.h index b6eaeb45c1..a37ee591c3 100644 --- a/repos/os/src/drivers/sd_card/spec/imx/driver.h +++ b/repos/os/src/drivers/sd_card/imx/driver.h @@ -11,13 +11,15 @@ * under the terms of the GNU Affero General Public License version 3. */ -#ifndef _DRIVER_H_ -#define _DRIVER_H_ +#ifndef _SRC__DRIVERS__SD_CARD__SPEC__IMX__DRIVER_H_ +#define _SRC__DRIVERS__SD_CARD__SPEC__IMX__DRIVER_H_ /* Genode includes */ +#include +#include +#include #include -#include -#include +#include /* local includes */ #include @@ -27,7 +29,9 @@ namespace Sd_card { class Driver; } class Sd_card::Driver : public Driver_base, - private Attached_mmio + private Platform::Device_client, + private Attached_dataspace, + private Mmio { private: @@ -212,12 +216,13 @@ class Sd_card::Driver : public Driver_base, bool read = false; }; - Env &_env; + Env & _env; + Platform::Connection & _platform; Block_transfer _block_transfer { }; Timer_delayer _delayer { _env }; Signal_handler _irq_handler { _env.ep(), *this, &Driver::_handle_irq }; - Irq_connection _irq; + Irq_session_client _irq; Card_info _card_info { _init() }; Adma2::Table _adma2_table { _env.ram(), _env.rm() }; @@ -273,7 +278,8 @@ class Sd_card::Driver : public Driver_base, using Block::Driver::read; using Block::Driver::write; - Driver(Env &env); + Driver(Env &env, Platform::Connection & platform); + ~Driver(); /******************* @@ -296,4 +302,4 @@ class Sd_card::Driver : public Driver_base, return _env.ram().alloc(size, UNCACHED); } }; -#endif /* _DRIVER_H_ */ +#endif /* _SRC__DRIVERS__SD_CARD__SPEC__IMX__DRIVER_H_ */ diff --git a/repos/os/src/drivers/sd_card/spec/imx53/driver.cc b/repos/os/src/drivers/sd_card/imx53/driver.cc similarity index 91% rename from repos/os/src/drivers/sd_card/spec/imx53/driver.cc rename to repos/os/src/drivers/sd_card/imx53/driver.cc index 7b5beba310..3efef6a9b2 100644 --- a/repos/os/src/drivers/sd_card/spec/imx53/driver.cc +++ b/repos/os/src/drivers/sd_card/imx53/driver.cc @@ -13,7 +13,6 @@ /* local includes */ #include -#include using namespace Sd_card; using namespace Genode; @@ -118,14 +117,3 @@ void Driver::_clock_finish(Clock clock) void Driver::_disable_clock_preparation() { } void Driver::_enable_clock_finish() { } - - -Driver::Driver(Env &env) -: - Driver_base(env.ram()), - Attached_mmio(env, Imx53::SDHC_MMIO_BASE, Imx53::SDHC_MMIO_SIZE), - _env(env), _irq(env, Imx53::SDHC_IRQ) -{ - log("SD card detected"); - log("capacity: ", card_info().capacity_mb(), " MiB"); -} diff --git a/repos/os/src/drivers/sd_card/spec/imx53/target.mk b/repos/os/src/drivers/sd_card/imx53/target.mk similarity index 52% rename from repos/os/src/drivers/sd_card/spec/imx53/target.mk rename to repos/os/src/drivers/sd_card/imx53/target.mk index 6cfd93f642..6d87ccdb0b 100644 --- a/repos/os/src/drivers/sd_card/spec/imx53/target.mk +++ b/repos/os/src/drivers/sd_card/imx53/target.mk @@ -1,6 +1,6 @@ TARGET = imx53_sd_card_drv REQUIRES = arm_v7 -SRC_CC = adma2.cc spec/imx/driver.cc -INC_DIR = $(REP_DIR)/src/drivers/sd_card/spec/imx +SRC_CC = adma2.cc imx/driver.cc +INC_DIR = $(REP_DIR)/src/drivers/sd_card/imx include $(REP_DIR)/src/drivers/sd_card/target.inc diff --git a/repos/os/src/drivers/sd_card/spec/imx6/driver.cc b/repos/os/src/drivers/sd_card/imx6/driver.cc similarity index 100% rename from repos/os/src/drivers/sd_card/spec/imx6/driver.cc rename to repos/os/src/drivers/sd_card/imx6/driver.cc diff --git a/repos/os/src/drivers/sd_card/imx6/target.mk b/repos/os/src/drivers/sd_card/imx6/target.mk new file mode 100644 index 0000000000..34f4db3319 --- /dev/null +++ b/repos/os/src/drivers/sd_card/imx6/target.mk @@ -0,0 +1,6 @@ +TARGET = imx6_sd_card_drv +SRC_CC = adma2.cc imx/driver.cc +INC_DIR = $(REP_DIR)/src/drivers/sd_card/imx +REQUIRES = arm_v7a + +include $(REP_DIR)/src/drivers/sd_card/target.inc diff --git a/repos/os/src/drivers/sd_card/imx8/target.mk b/repos/os/src/drivers/sd_card/imx8/target.mk new file mode 100644 index 0000000000..fbfd0c0d22 --- /dev/null +++ b/repos/os/src/drivers/sd_card/imx8/target.mk @@ -0,0 +1,9 @@ +TARGET = imx8_sd_card_drv +SRC_CC = adma2.cc imx/driver.cc +INC_DIR = $(REP_DIR)/src/drivers/sd_card/imx +REQUIRES = arm_v8a + +include $(REP_DIR)/src/drivers/sd_card/target.inc + +vpath driver.cc $(REP_DIR)/src/drivers/sd_card/imx6 + diff --git a/repos/os/src/drivers/sd_card/main.cc b/repos/os/src/drivers/sd_card/main.cc index 366aabb439..7cca85968d 100644 --- a/repos/os/src/drivers/sd_card/main.cc +++ b/repos/os/src/drivers/sd_card/main.cc @@ -17,6 +17,7 @@ #include #include #include +#include /* local includes */ #include @@ -26,23 +27,26 @@ using namespace Genode; struct Main { - Env &env; - Heap heap { env.ram(), env.rm() }; + Env & env; + Heap heap { env.ram(), env.rm() }; + Platform::Connection platform { env }; struct Factory : Block::Driver_factory { - Env &env; - Heap &heap; + Env & env; + Heap & heap; + Platform::Connection & platform; - Factory(Env &env, Heap &heap) : env(env), heap(heap) { } + Factory(Env &env, Heap &heap, Platform::Connection &platform) + : env(env), heap(heap), platform(platform) { } Block::Driver *create() override { - return new (&heap) Sd_card::Driver(env); } + return new (&heap) Sd_card::Driver(env, platform); } void destroy(Block::Driver *driver) override { Genode::destroy(&heap, static_cast(driver)); } - } factory { env, heap }; + } factory { env, heap, platform }; Block::Root root { env.ep(), heap, env.rm(), factory, true }; diff --git a/repos/os/src/drivers/sd_card/spec/pbxa9/driver.cc b/repos/os/src/drivers/sd_card/pl180/driver.cc similarity index 93% rename from repos/os/src/drivers/sd_card/spec/pbxa9/driver.cc rename to repos/os/src/drivers/sd_card/pl180/driver.cc index f6c39567bc..38c262b9af 100644 --- a/repos/os/src/drivers/sd_card/spec/pbxa9/driver.cc +++ b/repos/os/src/drivers/sd_card/pl180/driver.cc @@ -138,8 +138,13 @@ void Driver::_write_data(unsigned length, } -Driver::Driver(Env &env) -: Block::Driver(env.ram()), Attached_mmio(env, PL180_PHYS, PL180_SIZE), _timer(env) +Driver::Driver(Env &env, Platform::Connection & platform) +: Block::Driver(env.ram()), + Platform::Device_client(platform.device_by_index(0)), + Attached_dataspace(env.rm(), Device_client::io_mem_dataspace()), + Mmio((addr_t)local_addr()), + _platform(platform), + _timer(env) { enum { POWER_UP = 2, POWER_ON = 3 }; @@ -185,6 +190,10 @@ Driver::Driver(Env &env) } +Driver::~Driver() { + _platform.release_device(Platform::Device_client::rpc_cap()); } + + void Driver::read(Block::sector_t block_number, size_t block_count, char *buffer, diff --git a/repos/os/src/drivers/sd_card/spec/pbxa9/driver.h b/repos/os/src/drivers/sd_card/pl180/driver.h similarity index 91% rename from repos/os/src/drivers/sd_card/spec/pbxa9/driver.h rename to repos/os/src/drivers/sd_card/pl180/driver.h index c5e8795f49..37f3d97e5b 100644 --- a/repos/os/src/drivers/sd_card/spec/pbxa9/driver.h +++ b/repos/os/src/drivers/sd_card/pl180/driver.h @@ -16,11 +16,11 @@ #define _DRIVER_H_ /* local includes */ -#include +#include #include +#include #include - -#include "board.h" +#include namespace Sd_card { @@ -30,7 +30,10 @@ namespace Sd_card { } -class Sd_card::Driver : public Block::Driver, private Attached_mmio +class Sd_card::Driver : public Block::Driver, + private Platform::Device_client, + private Attached_dataspace, + private Mmio { private: @@ -80,7 +83,9 @@ class Sd_card::Driver : public Block::Driver, private Attached_mmio RxDataAvlbl = 0x200000, }; - Timer::Connection _timer; + Platform::Connection & _platform; + Timer::Connection _timer; + uint32_t volatile *_base { local_addr() }; uint32_t _read_reg(Register reg) const { return _base[reg >> 2]; } @@ -118,7 +123,8 @@ class Sd_card::Driver : public Block::Driver, private Attached_mmio public: - Driver(Env &env); + Driver(Env &env, Platform::Connection & platform); + ~Driver(); /****************** diff --git a/repos/os/src/drivers/sd_card/spec/pbxa9/target.mk b/repos/os/src/drivers/sd_card/pl180/target.mk similarity index 70% rename from repos/os/src/drivers/sd_card/spec/pbxa9/target.mk rename to repos/os/src/drivers/sd_card/pl180/target.mk index be17641ab6..a54731760d 100644 --- a/repos/os/src/drivers/sd_card/spec/pbxa9/target.mk +++ b/repos/os/src/drivers/sd_card/pl180/target.mk @@ -1,4 +1,4 @@ -TARGET = pbxa9_sd_card_drv +TARGET = pl180_sd_card_drv REQUIRES = arm_v7 include $(REP_DIR)/src/drivers/sd_card/target.inc diff --git a/repos/os/src/drivers/sd_card/spec/rpi/driver.cc b/repos/os/src/drivers/sd_card/rpi/driver.cc similarity index 95% rename from repos/os/src/drivers/sd_card/spec/rpi/driver.cc rename to repos/os/src/drivers/sd_card/rpi/driver.cc index 2a3dc1da15..beb7b77d46 100644 --- a/repos/os/src/drivers/sd_card/spec/rpi/driver.cc +++ b/repos/os/src/drivers/sd_card/rpi/driver.cc @@ -21,17 +21,23 @@ using namespace Genode; using namespace Sd_card; -Driver::Driver(Env &env) -: - Driver_base(env.ram()), - Attached_mmio(env, Rpi::SDHCI_BASE, Rpi::SDHCI_SIZE), - _env(env) +Driver::Driver(Env & env, Platform::Connection & platform) +: Driver_base(env.ram()), + Platform::Device_client(platform.device_by_index(0)), + Attached_dataspace(env.rm(), Device_client::io_mem_dataspace()), + Mmio((addr_t)local_addr()), + _env(env), + _platform(platform), + _irq(Device_client::irq()) { log("SD card detected"); log("capacity: ", _card_info.capacity_mb(), " MiB"); } +Driver::~Driver() { _platform.release_device(rpc_cap()); } + + void Driver::_set_and_enable_clock(unsigned divider) { Control1::access_t ctl1 = Mmio::Mmio::read(); diff --git a/repos/os/src/drivers/sd_card/spec/rpi/driver.h b/repos/os/src/drivers/sd_card/rpi/driver.h similarity index 91% rename from repos/os/src/drivers/sd_card/spec/rpi/driver.h rename to repos/os/src/drivers/sd_card/rpi/driver.h index 45c0ba8e60..ee0c77a8bb 100644 --- a/repos/os/src/drivers/sd_card/spec/rpi/driver.h +++ b/repos/os/src/drivers/sd_card/rpi/driver.h @@ -17,10 +17,11 @@ #define _DRIVER_H_ /* Genode includes */ +#include +#include +#include #include -#include -#include -#include +#include /* local includes */ #include @@ -29,7 +30,9 @@ namespace Sd_card { class Driver; } class Sd_card::Driver : public Driver_base, - private Attached_mmio + private Platform::Device_client, + private Attached_dataspace, + private Mmio { private: @@ -155,10 +158,11 @@ class Sd_card::Driver : public Driver_base, void usleep(uint64_t us) override { Timer::Connection::usleep(us); } }; - Env &_env; - Timer_delayer _delayer { _env }; - Irq_connection _irq { _env, Rpi::SDHCI_IRQ }; - Card_info _card_info { _init() }; + Env & _env; + Platform::Connection & _platform; + Timer_delayer _delayer { _env }; + Irq_session_client _irq; + Card_info _card_info { _init() }; template bool _poll_and_wait_for(unsigned value) @@ -196,7 +200,8 @@ class Sd_card::Driver : public Driver_base, public: - Driver(Env &env); + Driver(Env & env, Platform::Connection & platform); + ~Driver(); /******************* diff --git a/repos/os/src/drivers/sd_card/spec/rpi/target.mk b/repos/os/src/drivers/sd_card/rpi/target.mk similarity index 100% rename from repos/os/src/drivers/sd_card/spec/rpi/target.mk rename to repos/os/src/drivers/sd_card/rpi/target.mk diff --git a/repos/os/src/drivers/sd_card/spec/imx6q_sabrelite/driver.cc b/repos/os/src/drivers/sd_card/spec/imx6q_sabrelite/driver.cc deleted file mode 100644 index 3b8936b4ab..0000000000 --- a/repos/os/src/drivers/sd_card/spec/imx6q_sabrelite/driver.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* - * \brief Secured Digital Host Controller - * \author Martin Stein - * \date 2016-12-13 - */ - -/* - * Copyright (C) 2016-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -/* local includes */ -#include -#include - -using namespace Sd_card; -using namespace Genode; - -Driver::Driver(Env &env) -: - Driver_base(env.ram()), - Attached_mmio(env, Imx6::SDHC_4_MMIO_BASE, Imx6::SDHC_4_MMIO_SIZE), - _env(env), _irq(env, Imx6::SDHC_4_IRQ) -{ - log("SD card detected"); - log("capacity: ", card_info().capacity_mb(), " MiB"); -} diff --git a/repos/os/src/drivers/sd_card/spec/imx6q_sabrelite/target.mk b/repos/os/src/drivers/sd_card/spec/imx6q_sabrelite/target.mk deleted file mode 100644 index d7fa48e1c6..0000000000 --- a/repos/os/src/drivers/sd_card/spec/imx6q_sabrelite/target.mk +++ /dev/null @@ -1,6 +0,0 @@ -TARGET = imx6q_sabrelite_sd_card_drv -REQUIRES = arm_v7 -SRC_CC += adma2.cc spec/imx/driver.cc spec/imx6/driver.cc -INC_DIR = $(REP_DIR)/src/drivers/sd_card/spec/imx - -include $(REP_DIR)/src/drivers/sd_card/target.inc diff --git a/repos/os/src/drivers/sd_card/spec/imx8q_evk/driver.cc b/repos/os/src/drivers/sd_card/spec/imx8q_evk/driver.cc deleted file mode 100644 index 99ada3dc91..0000000000 --- a/repos/os/src/drivers/sd_card/spec/imx8q_evk/driver.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* - * \brief Secure Digital Host Controller - * \author Christian Prochaska - * \date 2019-09-26 - */ - -/* - * Copyright (C) 2019 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -/* local includes */ -#include -#include - -using namespace Sd_card; -using namespace Genode; - -Driver::Driver(Env &env) -: - Driver_base(env.ram()), - Attached_mmio(env, Imx8::SDHC_2_MMIO_BASE, Imx8::SDHC_2_MMIO_SIZE), - _env(env), _irq(env, Imx8::SDHC_2_IRQ) -{ - log("SD card detected"); - log("capacity: ", card_info().capacity_mb(), " MiB"); -} diff --git a/repos/os/src/drivers/sd_card/spec/imx8q_evk/target.mk b/repos/os/src/drivers/sd_card/spec/imx8q_evk/target.mk deleted file mode 100644 index 0355a05644..0000000000 --- a/repos/os/src/drivers/sd_card/spec/imx8q_evk/target.mk +++ /dev/null @@ -1,6 +0,0 @@ -TARGET = imx8q_evk_sd_card_drv -REQUIRES = arm_v8 -SRC_CC += adma2.cc spec/imx/driver.cc spec/imx6/driver.cc -INC_DIR = $(REP_DIR)/src/drivers/sd_card/spec/imx - -include $(REP_DIR)/src/drivers/sd_card/target.inc diff --git a/repos/os/src/drivers/sd_card/spec/nit6_solox/driver.cc b/repos/os/src/drivers/sd_card/spec/nit6_solox/driver.cc deleted file mode 100644 index 222d6a2624..0000000000 --- a/repos/os/src/drivers/sd_card/spec/nit6_solox/driver.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* - * \brief Secured Digital Host Controller - * \author Stefan Kalkowski - * \date 2019-02-19 - */ - -/* - * Copyright (C) 2019 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -/* local includes */ -#include -#include - -using namespace Sd_card; -using namespace Genode; - -Driver::Driver(Env &env) -: - Driver_base(env.ram()), - Attached_mmio(env, Imx6::SDHC_2_MMIO_BASE, Imx6::SDHC_2_MMIO_SIZE), - _env(env), _irq(env, Imx6::SDHC_2_IRQ) -{ - log("SD card detected"); - log("capacity: ", card_info().capacity_mb(), " MiB"); -} diff --git a/repos/os/src/drivers/sd_card/spec/nit6_solox/target.mk b/repos/os/src/drivers/sd_card/spec/nit6_solox/target.mk deleted file mode 100644 index 940eab2491..0000000000 --- a/repos/os/src/drivers/sd_card/spec/nit6_solox/target.mk +++ /dev/null @@ -1,6 +0,0 @@ -TARGET = nit6_solox_sd_card_drv -REQUIRES = arm_v7 -SRC_CC = adma2.cc spec/imx/driver.cc spec/imx6/driver.cc -INC_DIR = $(REP_DIR)/src/drivers/sd_card/spec/imx - -include $(REP_DIR)/src/drivers/sd_card/target.inc diff --git a/repos/os/src/drivers/sd_card/spec/pbxa9/board.h b/repos/os/src/drivers/sd_card/spec/pbxa9/board.h deleted file mode 100644 index bbebddae55..0000000000 --- a/repos/os/src/drivers/sd_card/spec/pbxa9/board.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * \brief PL180 multi-media-card interface definitions for the RealView platform - * \author Christian Helmuth - * \date 2011-05-19 - */ - -/* - * Copyright (C) 2011-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef _INCLUDE__SPEC__PBXA9__PL180_DEFS_H_ -#define _INCLUDE__SPEC__PBXA9__PL180_DEFS_H_ - -#include - -enum { - PL180_PHYS = 0x10005000, PL180_SIZE = 0x1000, - - /** - * Interrupt lines - */ - PL180_IRQ0 = Pbxa9::PL180_IRQ_0, - PL180_IRQ1 = Pbxa9::PL180_IRQ_1, -}; - -#endif /* _INCLUDE__SPEC__PBXA9__PL180_DEFS_H_ */