diff --git a/repos/gems/include/gems/magic_ring_buffer.h b/repos/gems/include/gems/magic_ring_buffer.h deleted file mode 100644 index 5153e43a69..0000000000 --- a/repos/gems/include/gems/magic_ring_buffer.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * \brief Region magic ring buffer - * \author Emery Hemingway - * \date 2018-02-01 - */ - -/* - * Copyright (C) 2018 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__GEMS__RING_BUFFER_H_ -#define _INCLUDE__GEMS__RING_BUFFER_H_ - -/* Genode includes */ -#include <base/attached_ram_dataspace.h> -#include <rm_session/connection.h> -#include <region_map/client.h> -#include <dataspace/client.h> - -namespace Genode { - template <typename TYPE> - struct Magic_ring_buffer; -} - -/** - * A ring buffer that uses a single dataspace mapped twice in consecutive - * regions. This allows any operation that is less or equal to the size of - * the buffer to be read or written in a single pass. - */ -template <typename TYPE> -class Genode::Magic_ring_buffer -{ - private: - - Magic_ring_buffer(Magic_ring_buffer const &); - Magic_ring_buffer &operator = (Magic_ring_buffer const &); - - Genode::Env &_env; - - Ram_dataspace_capability _buffer_ds; - - size_t const _ds_size = Dataspace_client(_buffer_ds).size(); - size_t const _capacity = _ds_size / sizeof(TYPE); - - Rm_connection _rm_connection { _env }; - - /* create region map (reserve address space) */ - Region_map_client _rm { _rm_connection.create(_ds_size*2) }; - - /* attach map to global region map */ - TYPE *_buffer = (TYPE *)_env.rm().attach(_rm.dataspace()); - - size_t _wpos = 0; - size_t _rpos = 0; - - - public: - - /** - * Ring capacity of TYPE items - */ - size_t capacity() { return _capacity; } - - /** - * Constructor - * - * \param TYPE Ring item type, size of type must be a - * power of two and less than the page size - * - * \param env Env for dataspace allocation and mapping - * \param num_bytes Size of ring in bytes, may be rounded up - * to the next page boundry - * - * \throw Region_map::Region_conflict - * \throw Out_of_ram - * \throw Out_of_caps - * - */ - Magic_ring_buffer(Genode::Env &env, size_t num_bytes) - : _env(env), _buffer_ds(_env.pd().alloc(num_bytes)) - { - if (_ds_size % sizeof(TYPE)) { - error("Magic_ring_buffer cannot hold unaligned TYPE"); - throw Exception(); - } - - /* attach buffer dataspace twice into reserved region */ - _rm.attach_at(_buffer_ds, 0, _ds_size); - _rm.attach_at(_buffer_ds, _ds_size, _ds_size); - } - - ~Magic_ring_buffer() - { - /* detach dataspace from reserved region */ - _rm.detach((addr_t)_ds_size); - _rm.detach((addr_t)0); - - /* detach reserved region */ - _env.rm().detach((addr_t)_buffer); - - /* free buffer */ - _env.ram().free(_buffer_ds); - } - - /** - * Number of items that may be written to ring - */ - size_t write_avail() const - { - if (_wpos > _rpos) - return ((_rpos - _wpos + _capacity) % _capacity) - 2; - else if (_wpos < _rpos) - return _rpos - _wpos; - else - return _capacity - 2; - } - - /** - * Number of items that may be read from ring - */ - size_t read_avail() const - { - if (_wpos > _rpos) - return _wpos - _rpos; - else - return (_wpos - _rpos + _capacity) % _capacity; - } - - /** - * Pointer to ring write address - */ - TYPE *write_addr() const { return &_buffer[_wpos]; } - - /** - * Pointer to ring read address - */ - TYPE *read_addr() const { return &_buffer[_rpos]; } - - /** - * Advance the ring write pointer - */ - void fill(size_t items) { - _wpos = (_wpos+items) % _capacity; } - - /** - * Advance the ring read pointer - */ - void drain(size_t items) { - _rpos = (_rpos+items) % _capacity; } -}; - -#endif diff --git a/repos/gems/recipes/pkg/test-magic_ring_buffer/README b/repos/gems/recipes/pkg/test-magic_ring_buffer/README deleted file mode 100644 index d4fa7b1457..0000000000 --- a/repos/gems/recipes/pkg/test-magic_ring_buffer/README +++ /dev/null @@ -1 +0,0 @@ -Test of Genodes magic-ring-buffer implementation. diff --git a/repos/gems/recipes/pkg/test-magic_ring_buffer/archives b/repos/gems/recipes/pkg/test-magic_ring_buffer/archives deleted file mode 100644 index 149eb32ff7..0000000000 --- a/repos/gems/recipes/pkg/test-magic_ring_buffer/archives +++ /dev/null @@ -1,2 +0,0 @@ -_/src/init -_/src/test-magic_ring_buffer diff --git a/repos/gems/recipes/pkg/test-magic_ring_buffer/hash b/repos/gems/recipes/pkg/test-magic_ring_buffer/hash deleted file mode 100644 index 20ff9911e3..0000000000 --- a/repos/gems/recipes/pkg/test-magic_ring_buffer/hash +++ /dev/null @@ -1 +0,0 @@ -2022-01-18 b93a983aa7d731e2235d65498abc3e301f163578 diff --git a/repos/gems/recipes/pkg/test-magic_ring_buffer/runtime b/repos/gems/recipes/pkg/test-magic_ring_buffer/runtime deleted file mode 100644 index d893704fc5..0000000000 --- a/repos/gems/recipes/pkg/test-magic_ring_buffer/runtime +++ /dev/null @@ -1,29 +0,0 @@ -<runtime ram="32M" caps="1000" binary="init"> - - <events> - <timeout meaning="failed" sec="10" /> - <log meaning="succeeded">child "test-magic_ring_buffer" exited with exit value 0</log> - <log meaning="failed">Error: </log> - </events> - - <content> - <rom label="ld.lib.so"/> - <rom label="test-magic_ring_buffer"/> - </content> - - <config> - <parent-provides> - <service name="CPU"/> - <service name="LOG"/> - <service name="PD"/> - <service name="RM"/> - <service name="ROM"/> - </parent-provides> - <default-route> - <any-service> <parent/> </any-service> - </default-route> - <start name="test-magic_ring_buffer" caps="64"> - <resource name="RAM" quantum="2M"/> - </start> - </config> -</runtime> diff --git a/repos/gems/recipes/src/test-magic_ring_buffer/content.mk b/repos/gems/recipes/src/test-magic_ring_buffer/content.mk deleted file mode 100644 index 717720a7a9..0000000000 --- a/repos/gems/recipes/src/test-magic_ring_buffer/content.mk +++ /dev/null @@ -1,3 +0,0 @@ -SRC_DIR = src/test/magic_ring_buffer - -include $(GENODE_DIR)/repos/base/recipes/src/content.inc diff --git a/repos/gems/recipes/src/test-magic_ring_buffer/hash b/repos/gems/recipes/src/test-magic_ring_buffer/hash deleted file mode 100644 index df7fa9a2dc..0000000000 --- a/repos/gems/recipes/src/test-magic_ring_buffer/hash +++ /dev/null @@ -1 +0,0 @@ -2022-01-18 bb72eddaf80e7d0f98c6c954f176acd4e0963bd6 diff --git a/repos/gems/recipes/src/test-magic_ring_buffer/used_apis b/repos/gems/recipes/src/test-magic_ring_buffer/used_apis deleted file mode 100644 index 05edbca903..0000000000 --- a/repos/gems/recipes/src/test-magic_ring_buffer/used_apis +++ /dev/null @@ -1,2 +0,0 @@ -base -gems diff --git a/repos/gems/run/depot_autopilot.run b/repos/gems/run/depot_autopilot.run index 3d3ac7f791..df6ad9340a 100644 --- a/repos/gems/run/depot_autopilot.run +++ b/repos/gems/run/depot_autopilot.run @@ -689,7 +689,6 @@ set default_test_pkgs { test-libc_vfs_ram test-log test-lx_block - test-magic_ring_buffer test-mmio test-new_delete test-nic_loopback diff --git a/repos/gems/src/test/magic_ring_buffer/main.cc b/repos/gems/src/test/magic_ring_buffer/main.cc deleted file mode 100644 index ef3663ebab..0000000000 --- a/repos/gems/src/test/magic_ring_buffer/main.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * \brief Magic ring buffer test - * \author Emery Hemingway - * \date 2018-04-04 - */ - -/* - * Copyright (C) 2018 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. - */ - -/* Genode includes */ -#include <base/component.h> -#include <base/log.h> - -/* gems includes */ -#include <gems/magic_ring_buffer.h> - -void Component::construct(Genode::Env &env) -{ - using namespace Genode; - - Magic_ring_buffer<int> ring_buffer(env, 4097); - - log("--- magic ring buffer test, ", ring_buffer.capacity(), " int ring ---"); - - size_t const count = ring_buffer.capacity()/3; - - size_t total = 0; - - for (size_t j = 0; j < 99; ++j) { - for (size_t i = 0; i < count; ++i) { - ring_buffer.write_addr()[i] = (int)i; - } - - ring_buffer.fill(count); - - for (size_t i = 0; i < count; ++i) { - if (ring_buffer.read_addr()[i] != (int)i) { - error("ring buffer corruption, ", - ring_buffer.read_addr()[i], " != ", i); - env.parent().exit((int)(total + i)); - return; - } - } - ring_buffer.drain(count); - - total += count; - } - - log("--- test complete, ", total, " ints passed through ring ---"); - env.parent().exit(0); -} - diff --git a/repos/gems/src/test/magic_ring_buffer/target.mk b/repos/gems/src/test/magic_ring_buffer/target.mk deleted file mode 100644 index 716d9fb7b3..0000000000 --- a/repos/gems/src/test/magic_ring_buffer/target.mk +++ /dev/null @@ -1,3 +0,0 @@ -TARGET = test-magic_ring_buffer -SRC_CC = main.cc -LIBS = base