mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
sd_card: make main.cc generic
The previous platform-specific implementations differed only in minor aspects. Ref #2206
This commit is contained in:
parent
613f4171f3
commit
9e1f3259c5
@ -1,6 +1,5 @@
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card
|
||||
|
||||
LIBS += base
|
||||
SRC_CC += main.cc
|
||||
LIBS += base
|
||||
|
||||
vpath %.cc $(REP_DIR)/src/drivers/sd_card
|
||||
|
@ -1,2 +1,5 @@
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/exynos5
|
||||
include $(REP_DIR)/lib/mk/sd_card_bench.inc
|
||||
|
||||
vpath main.cc $(REP_DIR)/src/test/sd_card_bench
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -1,3 +1,3 @@
|
||||
SRC_CC += spec/exynos5/main.cc
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/exynos5
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -2,4 +2,7 @@ INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/imx
|
||||
SRC_CC += spec/imx/adma2.cc
|
||||
SRC_CC += spec/imx/sdhc.cc
|
||||
SRC_CC += spec/imx53/sdhc.cc
|
||||
include $(REP_DIR)/lib/mk/sd_card_bench.inc
|
||||
|
||||
vpath main.cc $(REP_DIR)/src/test/sd_card_bench
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -1,6 +1,6 @@
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/imx
|
||||
SRC_CC += spec/imx/adma2.cc
|
||||
SRC_CC += spec/imx/sdhc.cc
|
||||
SRC_CC += spec/imx/main.cc
|
||||
SRC_CC += spec/imx53/sdhc.cc
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -2,4 +2,7 @@ INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/imx
|
||||
SRC_CC += spec/imx/adma2.cc
|
||||
SRC_CC += spec/imx/sdhc.cc
|
||||
SRC_CC += spec/imx6/sdhc.cc
|
||||
include $(REP_DIR)/lib/mk/sd_card_bench.inc
|
||||
|
||||
vpath main.cc $(REP_DIR)/src/test/sd_card_bench
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -1,6 +1,6 @@
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/imx
|
||||
SRC_CC += spec/imx/adma2.cc
|
||||
SRC_CC += spec/imx/sdhc.cc
|
||||
SRC_CC += spec/imx/main.cc
|
||||
SRC_CC += spec/imx6/sdhc.cc
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -1,2 +1,5 @@
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/omap4
|
||||
include $(REP_DIR)/lib/mk/sd_card_bench.inc
|
||||
|
||||
vpath main.cc $(REP_DIR)/src/test/sd_card_bench
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -1,3 +1,3 @@
|
||||
SRC_CC += spec/omap4/main.cc
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/omap4
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -1,4 +1,5 @@
|
||||
SRC_CC += main.cc
|
||||
LIBS += server
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/pl180
|
||||
|
||||
vpath main.cc $(REP_DIR)/src/test/sd_card_bench
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
@ -1,3 +1,3 @@
|
||||
SRC_CC += spec/pl180/main.cc
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/pl180
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -1,2 +1,5 @@
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/rpi
|
||||
include $(REP_DIR)/lib/mk/sd_card_bench.inc
|
||||
|
||||
vpath main.cc $(REP_DIR)/src/test/sd_card_bench
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -1,3 +1,3 @@
|
||||
SRC_CC += spec/rpi/main.cc
|
||||
INC_DIR += $(REP_DIR)/src/drivers/sd_card/spec/rpi
|
||||
|
||||
include $(REP_DIR)/lib/mk/sd_card.inc
|
||||
|
@ -1,58 +1,98 @@
|
||||
#
|
||||
# Build
|
||||
# Check for platform support
|
||||
#
|
||||
|
||||
build {
|
||||
if {[expr ![have_spec exynos5] && \
|
||||
![have_spec omap4] && \
|
||||
![have_spec imx6] && \
|
||||
![have_spec imx53] && \
|
||||
![have_spec pl180] && \
|
||||
![have_spec rpi]]} \
|
||||
{
|
||||
puts "\n Run script is not supported on this platform. \n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Build the boot modules
|
||||
#
|
||||
|
||||
set build_components {
|
||||
core init
|
||||
drivers/timer
|
||||
test/sd_card_bench
|
||||
}
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
build $build_components
|
||||
create_boot_directory
|
||||
|
||||
|
||||
#
|
||||
# Config
|
||||
# Install the config
|
||||
#
|
||||
|
||||
install_config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="sd_card_bench">
|
||||
<resource name="RAM" quantum="16M"/>
|
||||
<provides><service name="Block"/></provides>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
append_platform_drv_config
|
||||
|
||||
append config {
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
<start name="sd_card_bench">
|
||||
<resource name="RAM" quantum="16M"/>
|
||||
<provides><service name="Block"/></provides>
|
||||
</start>
|
||||
</config>}
|
||||
|
||||
install_config $config
|
||||
|
||||
|
||||
#
|
||||
# Boot modules
|
||||
# Create the boot image
|
||||
#
|
||||
|
||||
build_boot_image {
|
||||
set boot_modules {
|
||||
core ld.lib.so init
|
||||
timer
|
||||
sd_card_bench
|
||||
}
|
||||
|
||||
run_genode_until forever
|
||||
append_platform_drv_boot_modules
|
||||
build_boot_image $boot_modules
|
||||
|
||||
# vi: set ft=tcl :
|
||||
|
||||
#
|
||||
# Run and evaluate the test
|
||||
#
|
||||
# If we run on qemu, provide a virtual disk
|
||||
#
|
||||
|
||||
if {[have_include power_on/qemu]} {
|
||||
|
||||
set disk_image "bin/sd_card.img"
|
||||
if { [file exists $disk_image] == 0 } then {
|
||||
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 "
|
||||
append qemu_args "-nographic "
|
||||
}
|
||||
|
||||
run_genode_until "--- SD card benchmark finished ---" 120
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* \brief SD-card driver
|
||||
* \author Martin Stein
|
||||
* \date 2015-02-04
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2013-03-06
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2015 Genode Labs GmbH
|
||||
* Copyright (C) 2013-2016 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
@ -14,41 +15,42 @@
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <base/heap.h>
|
||||
#include <block/component.h>
|
||||
|
||||
/* local includes */
|
||||
#include <driver.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
struct Main
|
||||
{
|
||||
Genode::Env &env;
|
||||
Genode::Heap heap { env.ram(), env.rm() };
|
||||
Env &env;
|
||||
Heap heap { env.ram(), env.rm() };
|
||||
|
||||
struct Factory : Block::Driver_factory
|
||||
{
|
||||
Genode::Entrypoint &ep;
|
||||
Genode::Heap &heap;
|
||||
Env &env;
|
||||
Heap &heap;
|
||||
|
||||
Factory(Genode::Entrypoint &ep, Genode::Heap &heap)
|
||||
: ep(ep), heap(heap) { }
|
||||
Factory(Env &env, Heap &heap) : env(env), heap(heap) { }
|
||||
|
||||
Block::Driver *create() {
|
||||
return new (&heap) Block::Sdhci_driver(ep, true); }
|
||||
return new (&heap) Block::Sdhci_driver(env); }
|
||||
|
||||
void destroy(Block::Driver *driver) {
|
||||
Genode::destroy(&heap,
|
||||
static_cast<Block::Sdhci_driver*>(driver)); }
|
||||
} factory { env.ep(), heap };
|
||||
Genode::destroy(&heap, static_cast<Block::Sdhci_driver*>(driver)); }
|
||||
|
||||
} factory { env, heap };
|
||||
|
||||
Block::Root root { env.ep(), heap, factory };
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
Genode::log("--- SD card driver ---");
|
||||
|
||||
env.parent().announce(env.ep().manage(root));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Main m(env); }
|
||||
void Component::construct(Genode::Env &env) { static Main main(env); }
|
@ -14,12 +14,14 @@
|
||||
#ifndef _DRIVERS__SD_CARD__SPEC__EXYNOS5__DRIVER_H_
|
||||
#define _DRIVERS__SD_CARD__SPEC__EXYNOS5__DRIVER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/mmio.h>
|
||||
#include <os/attached_io_mem_dataspace.h>
|
||||
#include <base/log.h>
|
||||
#include <timer_session/connection.h>
|
||||
#include <block/component.h>
|
||||
#include <os/server.h>
|
||||
#include <regulator_session/connection.h>
|
||||
|
||||
/* local includes */
|
||||
#include <dwmmc.h>
|
||||
@ -54,8 +56,15 @@ class Block::Sdhci_driver : public Block::Driver
|
||||
MSH_SIZE = 0x10000,
|
||||
};
|
||||
|
||||
struct Clock_regulator
|
||||
{
|
||||
Regulator::Connection regulator;
|
||||
|
||||
Clock_regulator(Env &env) : regulator(env, Regulator::CLK_MMC0) {
|
||||
regulator.state(true); }
|
||||
|
||||
} _clock_regulator;
|
||||
|
||||
Server::Entrypoint &_ep;
|
||||
|
||||
/* display sub system registers */
|
||||
Attached_io_mem_dataspace _mmio;
|
||||
@ -67,13 +76,13 @@ class Block::Sdhci_driver : public Block::Driver
|
||||
|
||||
public:
|
||||
|
||||
Sdhci_driver(Server::Entrypoint &ep, bool use_dma)
|
||||
Sdhci_driver(Env &env)
|
||||
:
|
||||
_ep(ep),
|
||||
_clock_regulator(env),
|
||||
_mmio(MSH_BASE, MSH_SIZE),
|
||||
_controller(ep, (addr_t)_mmio.local_addr<void>(),
|
||||
_delayer, use_dma),
|
||||
_use_dma(use_dma)
|
||||
_controller(env.ep(), (addr_t)_mmio.local_addr<void>(),
|
||||
_delayer, true),
|
||||
_use_dma(true)
|
||||
{
|
||||
Sd_card::Card_info const card_info = _controller.card_info();
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* \brief eMMC driver for Arndale/Exynos5 platform
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2013-03-06
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <regulator_session/connection.h>
|
||||
|
||||
/* local includes */
|
||||
#include <driver.h>
|
||||
|
||||
|
||||
struct Main
|
||||
{
|
||||
Genode::Env &env;
|
||||
Genode::Heap heap { env.ram(), env.rm() };
|
||||
|
||||
struct Factory : Block::Driver_factory
|
||||
{
|
||||
Genode::Entrypoint &ep;
|
||||
Genode::Heap &heap;
|
||||
|
||||
Factory(Genode::Entrypoint &ep, Genode::Heap &heap)
|
||||
: ep(ep), heap(heap) { }
|
||||
|
||||
Block::Driver *create() {
|
||||
return new (&heap) Block::Sdhci_driver(ep, true); }
|
||||
|
||||
void destroy(Block::Driver *driver) {
|
||||
Genode::destroy(&heap,
|
||||
static_cast<Block::Sdhci_driver *>(driver)); }
|
||||
} factory { env.ep(), heap };
|
||||
|
||||
Regulator::Connection regulator { env, Regulator::CLK_MMC0 };
|
||||
Block::Root root { env.ep(), heap, factory };
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
Genode::log("--- Arndale eMMC card driver ---");
|
||||
|
||||
env.parent().announce(env.ep().manage(root));
|
||||
regulator.state(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Main m(env); }
|
@ -51,12 +51,12 @@ class Block::Sdhci_driver : public Block::Driver
|
||||
|
||||
public:
|
||||
|
||||
Sdhci_driver(Entrypoint &, bool use_dma)
|
||||
Sdhci_driver(Env &)
|
||||
:
|
||||
_sdhc_mmio(Board_base::SDHC_MMIO_BASE, Board_base::SDHC_MMIO_SIZE),
|
||||
_controller((addr_t)_sdhc_mmio.local_addr<void>(),
|
||||
Board_base::SDHC_IRQ, _delayer, use_dma),
|
||||
_use_dma(use_dma)
|
||||
Board_base::SDHC_IRQ, _delayer, true),
|
||||
_use_dma(true)
|
||||
{
|
||||
Sd_card::Card_info const card_info = _controller.card_info();
|
||||
|
||||
|
@ -58,13 +58,16 @@ class Block::Sdhci_driver : public Block::Driver
|
||||
|
||||
public:
|
||||
|
||||
Sdhci_driver(Entrypoint &, bool use_dma)
|
||||
struct Dma_not_supported : Exception { };
|
||||
|
||||
Sdhci_driver(Env &)
|
||||
:
|
||||
_mmchs1_mmio(MMCHS1_MMIO_BASE, MMCHS1_MMIO_SIZE),
|
||||
_controller((addr_t)_mmchs1_mmio.local_addr<void>(),
|
||||
_delayer, use_dma),
|
||||
_use_dma(use_dma)
|
||||
_delayer, false),
|
||||
_use_dma(false)
|
||||
{
|
||||
if (_use_dma) { throw Dma_not_supported(); }
|
||||
Sd_card::Card_info const card_info = _controller.card_info();
|
||||
|
||||
Genode::log("SD card detected");
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* \brief SD-card driver for OMAP4 platform
|
||||
* \author Norman Feske
|
||||
* \date 2012-07-03
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-2015 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
|
||||
/* local includes */
|
||||
#include <driver.h>
|
||||
|
||||
|
||||
struct Main
|
||||
{
|
||||
Genode::Env &env;
|
||||
Genode::Heap heap { env.ram(), env.rm() };
|
||||
|
||||
struct Factory : Block::Driver_factory
|
||||
{
|
||||
Genode::Entrypoint &ep;
|
||||
Genode::Heap &heap;
|
||||
|
||||
Factory(Genode::Entrypoint &ep, Genode::Heap &heap)
|
||||
: ep(ep), heap(heap) { }
|
||||
|
||||
Block::Driver *create() {
|
||||
return new (&heap) Block::Sdhci_driver(ep, true); }
|
||||
|
||||
void destroy(Block::Driver *driver) {
|
||||
Genode::destroy(&heap,
|
||||
static_cast<Block::Sdhci_driver*>(driver)); }
|
||||
} factory { env.ep(), heap };
|
||||
|
||||
Block::Root root { env.ep(), heap, factory };
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
Genode::log("--- OMAP4 SD card driver ---");
|
||||
|
||||
env.parent().announce(env.ep().manage(root));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Main m(env); }
|
@ -11,26 +11,33 @@
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _DRIVERS__SD_CARD__SPEC__PL180__SD_CARD_H_
|
||||
#define _DRIVERS__SD_CARD__SPEC__PL180__SD_CARD_H_
|
||||
#ifndef _DRIVER_H_
|
||||
#define _DRIVER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <block/driver.h>
|
||||
|
||||
#include "host_driver.h"
|
||||
/* local includes */
|
||||
#include <pl180.h>
|
||||
#include <pl180_defs.h>
|
||||
|
||||
namespace Block {
|
||||
|
||||
class Sd_card : public Block::Driver
|
||||
using namespace Genode;
|
||||
class Sdhci_driver;
|
||||
}
|
||||
|
||||
class Block::Sdhci_driver : public Block::Driver
|
||||
{
|
||||
private:
|
||||
|
||||
Host_driver &_hd;
|
||||
Pl180 _hd;
|
||||
|
||||
enum { BLOCK_SIZE = 512 };
|
||||
|
||||
public:
|
||||
|
||||
Sd_card(Host_driver &host_driver)
|
||||
: _hd(host_driver)
|
||||
Sdhci_driver(Env &) : _hd(PL180_PHYS, PL180_SIZE)
|
||||
{
|
||||
unsigned resp;
|
||||
|
||||
@ -133,4 +140,4 @@ class Sd_card : public Block::Driver
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _DRIVERS__SD_CARD__SPEC__PL180__SD_CARD_H_ */
|
||||
#endif /* _DRIVER_H_ */
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* \brief Driver for PL180 multi-media card interface (MMCI)
|
||||
* \author Christian Helmuth
|
||||
* \date 2011-05-20
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-2013 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <block/component.h>
|
||||
|
||||
/* local includes */
|
||||
#include <pl180_defs.h>
|
||||
#include "pl180.h"
|
||||
#include "sd_card.h"
|
||||
|
||||
|
||||
struct Main
|
||||
{
|
||||
Genode::Env &env;
|
||||
Genode::Heap heap { env.ram(), env.rm() };
|
||||
|
||||
struct Factory : Block::Driver_factory
|
||||
{
|
||||
Genode::Entrypoint &ep;
|
||||
Genode::Heap &heap;
|
||||
|
||||
Factory(Genode::Entrypoint &ep, Genode::Heap &heap)
|
||||
: ep(ep), heap(heap) { }
|
||||
|
||||
Block::Driver *create() {
|
||||
Pl180 *pl180 = new (Genode::env()->heap())
|
||||
Pl180(PL180_PHYS, PL180_SIZE);
|
||||
Sd_card *sd_card = new (Genode::env()->heap())
|
||||
Sd_card(*pl180);
|
||||
|
||||
return sd_card;
|
||||
}
|
||||
|
||||
void destroy(Block::Driver *driver)
|
||||
{
|
||||
Sd_card *sd_card = static_cast<Sd_card *>(driver);
|
||||
Pl180 *pl180 = static_cast<Pl180 *>(&sd_card->host_driver());
|
||||
|
||||
Genode::destroy(Genode::env()->heap(), sd_card);
|
||||
Genode::destroy(Genode::env()->heap(), pl180);
|
||||
}
|
||||
} factory { env.ep(), heap };
|
||||
|
||||
Block::Root root { env.ep(), heap, factory };
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
Genode::log("--- PL180 MMC/SD card driver started ---");
|
||||
|
||||
env.parent().announce(env.ep().manage(root));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Main m(env); }
|
@ -54,11 +54,11 @@ class Block::Sdhci_driver : public Block::Driver
|
||||
|
||||
public:
|
||||
|
||||
Sdhci_driver(Entrypoint &, bool use_dma, const bool set_voltage = false)
|
||||
Sdhci_driver(Env &)
|
||||
:
|
||||
_controller((addr_t)_sdhci_mmio.local_addr<void>(),
|
||||
_delayer, Board_base::SDHCI_IRQ, use_dma, set_voltage),
|
||||
_use_dma(use_dma)
|
||||
_delayer, Board_base::SDHCI_IRQ, false, true),
|
||||
_use_dma(false)
|
||||
{
|
||||
Sd_card::Card_info const card_info = _controller.card_info();
|
||||
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* \brief SD-card driver for Raspberry Pi
|
||||
* \author Norman Feske
|
||||
* \date 2014-09-21
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <platform_session/connection.h>
|
||||
|
||||
/* local includes */
|
||||
#include <driver.h>
|
||||
|
||||
|
||||
struct Main
|
||||
{
|
||||
Genode::Env &env;
|
||||
Genode::Heap heap { env.ram(), env.rm() };
|
||||
Platform::Connection platform { env };
|
||||
|
||||
struct Factory : Block::Driver_factory
|
||||
{
|
||||
Genode::Entrypoint &ep;
|
||||
Genode::Heap &heap;
|
||||
|
||||
Factory(Genode::Entrypoint &ep, Genode::Heap &heap)
|
||||
: ep(ep), heap(heap) { }
|
||||
|
||||
Block::Driver *create() {
|
||||
return new (&heap) Block::Sdhci_driver(ep, false); }
|
||||
|
||||
void destroy(Block::Driver *driver) {
|
||||
Genode::destroy(&heap,
|
||||
static_cast<Block::Sdhci_driver*>(driver)); }
|
||||
} factory { env.ep(), heap };
|
||||
|
||||
Block::Root root { env.ep(), heap, factory };
|
||||
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
Genode::log("--- SD card driver ---");
|
||||
|
||||
while (platform.power_state(Platform::Session::POWER_SDHCI) == 0)
|
||||
platform.power_state(Platform::Session::POWER_SDHCI, true);
|
||||
|
||||
env.parent().announce(env.ep().manage(root));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Main m(env); }
|
@ -13,15 +13,16 @@
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/sleep.h>
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <timer_session/connection.h>
|
||||
#include <os/attached_ram_dataspace.h>
|
||||
#include <os/server.h>
|
||||
#include <os/config.h>
|
||||
|
||||
/* local includes */
|
||||
#include <driver.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
struct Operation
|
||||
{
|
||||
@ -90,15 +91,13 @@ static void run_benchmark(Block::Driver &driver,
|
||||
|
||||
struct Main
|
||||
{
|
||||
Main(Server::Entrypoint &ep)
|
||||
Main(Env &env)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
log("--- SD card benchmark ---");
|
||||
|
||||
bool const use_dma = true;
|
||||
|
||||
static Block::Sdhci_driver driver(ep, use_dma);
|
||||
static Block::Sdhci_driver driver(env);
|
||||
bool const use_dma = driver.dma_enabled();
|
||||
|
||||
static Timer::Connection timer;
|
||||
|
||||
@ -109,7 +108,7 @@ struct Main
|
||||
size_t const buffer_size = 10 * 1024 * 1024;
|
||||
|
||||
/* allocate read/write buffer */
|
||||
static Attached_ram_dataspace buffer(env()->ram_session(), buffer_size, Genode::UNCACHED);
|
||||
static Attached_ram_dataspace buffer(&env.ram(), buffer_size, Genode::UNCACHED);
|
||||
char * const buffer_virt = buffer.local_addr<char>();
|
||||
addr_t const buffer_phys = Dataspace_client(buffer.cap()).phys_addr();
|
||||
|
||||
@ -117,7 +116,7 @@ struct Main
|
||||
* Benchmark reading from SD card
|
||||
*/
|
||||
|
||||
log("\n-- reading from SD card --");
|
||||
log("\n-- reading from SD card (", use_dma ? "" : "not ", "using DMA) --");
|
||||
|
||||
struct Read : Operation
|
||||
{
|
||||
@ -145,7 +144,7 @@ struct Main
|
||||
* its original content.
|
||||
*/
|
||||
|
||||
log("\n-- writing to SD card --");
|
||||
log("\n-- writing to SD card (", use_dma ? "" : "not ", "using DMA) --");
|
||||
|
||||
struct Write : Operation
|
||||
{
|
||||
@ -169,12 +168,4 @@ struct Main
|
||||
};
|
||||
|
||||
|
||||
/************
|
||||
** Server **
|
||||
************/
|
||||
|
||||
namespace Server {
|
||||
char const *name() { return "sd_card_bench_ep"; }
|
||||
size_t stack_size() { return 16*1024*sizeof(long); }
|
||||
void construct(Entrypoint &ep) { static Main server(ep); }
|
||||
}
|
||||
void Component::construct(Genode::Env &env) { static Main main(env); }
|
||||
|
Loading…
Reference in New Issue
Block a user