From 1a7efc0df10a49e2fe9b66a86b1a4b26383c74a3 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Sat, 18 May 2013 10:03:48 +0200 Subject: [PATCH] os: helper Attached_mmio Genode::Attached_mmio is the fusion of Genode::Attached_io_mem_dataspace and Genode::Mmio. Ref #706 --- os/include/os/attached_mmio.h | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 os/include/os/attached_mmio.h diff --git a/os/include/os/attached_mmio.h b/os/include/os/attached_mmio.h new file mode 100644 index 000000000..5711cbb94 --- /dev/null +++ b/os/include/os/attached_mmio.h @@ -0,0 +1,56 @@ +/* + * \brief MMIO framework utility + * \author Martin Stein + * \date 2013-05-17 + */ + +/* + * Copyright (C) 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. + */ + +#ifndef _INCLUDE__OS__ATTACHED_MMIO_H_ +#define _INCLUDE__OS__ATTACHED_MMIO_H_ + +/* Genode includes */ +#include +#include + +namespace Genode +{ + /** + * Eases the application of the MMIO framework + * + * In the classical case the user wants device memory to be structured + * by inheriting from Genode::Mmio and using its subclasses. As + * prerequisite one needs to alloc the IO dataspace, attach it locally + * and cast the received address. This helper undertakes all of this + * generic work when inheriting from it. + */ + class Attached_mmio : public Attached_io_mem_dataspace, + public Mmio + { + public: + + /** + * Constructor + * + * \param base base address of memory-mapped I/O resource + * \param size size of resource + * \param write_combined enable write combining for the resource + * + * \throw Parent::Service_denied + * \throw Parent::Quota_exceeded + * \throw Parent::Unavailable + * \throw Rm_session::Attach_failed + */ + Attached_mmio(addr_t base, size_t size, + bool write_combined = false) + : Attached_io_mem_dataspace(base, size, write_combined), + Mmio((addr_t)local_addr()) { } + }; +} + +#endif /* _INCLUDE__OS__ATTACHED_MMIO_H_ */