mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-01 00:45:29 +00:00
parent
c76f7c0c2a
commit
4f99224255
@ -28,8 +28,8 @@ namespace File_system {
|
||||
|
||||
class Chunk_base;
|
||||
|
||||
template <unsigned> class Chunk;
|
||||
template <unsigned, typename> class Chunk_index;
|
||||
template <size_t> class Chunk;
|
||||
template <size_t, typename> class Chunk_index;
|
||||
}
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ class File_system::Chunk_base : Noncopyable
|
||||
/**
|
||||
* Chunk of bytes used as leaf in hierarchy of chunk indices
|
||||
*/
|
||||
template <unsigned CHUNK_SIZE>
|
||||
template <Genode::size_t CHUNK_SIZE>
|
||||
class File_system::Chunk : public Chunk_base
|
||||
{
|
||||
private:
|
||||
@ -177,7 +177,7 @@ class File_system::Chunk : public Chunk_base
|
||||
};
|
||||
|
||||
|
||||
template <unsigned NUM_ENTRIES, typename ENTRY_TYPE>
|
||||
template <Genode::size_t NUM_ENTRIES, typename ENTRY_TYPE>
|
||||
class File_system::Chunk_index : public Chunk_base
|
||||
{
|
||||
public:
|
||||
|
42
repos/os/include/ram_fs/param.h
Normal file
42
repos/os/include/ram_fs/param.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* \brief Dimensioning of the hierarchic 'Chunk' structure for the RAM fs
|
||||
* \author Norman Feske
|
||||
* \date 2019-03-17
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__RAM_FS__PARAM_H_
|
||||
#define _INCLUDE__RAM_FS__PARAM_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/stdint.h>
|
||||
|
||||
namespace Ram_fs
|
||||
{
|
||||
using Genode::size_t;
|
||||
|
||||
/*
|
||||
* Let number of level-0 and level-1 entries depend on the machine-word
|
||||
* size to allow the use of more than 2 GiB on 64-bit machines.
|
||||
*
|
||||
* 32 bit: 64*64*128*4096 = 2 GiB
|
||||
* 64 bit: 128*128*128*4096 = 8 GiB
|
||||
*/
|
||||
static constexpr size_t num_level_0_entries()
|
||||
{
|
||||
return sizeof(size_t) == 8 ? 128 : 64;
|
||||
}
|
||||
|
||||
static constexpr size_t num_level_1_entries() { return num_level_0_entries(); }
|
||||
static constexpr size_t num_level_2_entries() { return 128; }
|
||||
static constexpr size_t num_level_3_entries() { return 4096; }
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__RAM_FS__PARAM_H_ */
|
||||
|
@ -1,8 +1,10 @@
|
||||
SRC_DIR = include/file_system src/server/vfs
|
||||
include $(GENODE_DIR)/repos/base/recipes/src/content.inc
|
||||
|
||||
MIRROR_FROM_REP_DIR += $(addprefix include/ram_fs/,chunk.h param.h) \
|
||||
lib/mk/vfs.mk src/lib/vfs
|
||||
|
||||
content: include/ram_fs/chunk.h lib/mk/vfs.mk src/lib/vfs
|
||||
content: $(MIRROR_FROM_REP_DIR)
|
||||
|
||||
include/vfs include/ram_fs/chunk.h lib/mk/vfs.mk src/lib/vfs:
|
||||
$(MIRROR_FROM_REP_DIR):
|
||||
$(mirror_from_rep_dir)
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define _INCLUDE__VFS__RAM_FILE_SYSTEM_H_
|
||||
|
||||
#include <ram_fs/chunk.h>
|
||||
#include <ram_fs/param.h>
|
||||
#include <vfs/file_system.h>
|
||||
#include <dataspace/client.h>
|
||||
#include <util/avl_tree.h>
|
||||
@ -25,6 +26,9 @@ namespace Vfs_ram {
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Vfs;
|
||||
using namespace Ram_fs;
|
||||
using File_system::Chunk;
|
||||
using File_system::Chunk_index;
|
||||
|
||||
struct Io_handle;
|
||||
struct Watch_handle;
|
||||
@ -235,10 +239,10 @@ class Vfs_ram::File : public Vfs_ram::Node
|
||||
{
|
||||
private:
|
||||
|
||||
typedef ::File_system::Chunk<4096> Chunk_level_3;
|
||||
typedef ::File_system::Chunk_index<128, Chunk_level_3> Chunk_level_2;
|
||||
typedef ::File_system::Chunk_index<64, Chunk_level_2> Chunk_level_1;
|
||||
typedef ::File_system::Chunk_index<64, Chunk_level_1> Chunk_level_0;
|
||||
typedef Chunk <num_level_3_entries()> Chunk_level_3;
|
||||
typedef Chunk_index<num_level_2_entries(), Chunk_level_3> Chunk_level_2;
|
||||
typedef Chunk_index<num_level_1_entries(), Chunk_level_2> Chunk_level_1;
|
||||
typedef Chunk_index<num_level_0_entries(), Chunk_level_1> Chunk_level_0;
|
||||
|
||||
Chunk_level_0 _chunk;
|
||||
file_size _length = 0;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
/* local includes */
|
||||
#include <ram_fs/chunk.h>
|
||||
#include <ram_fs/param.h>
|
||||
#include "node.h"
|
||||
|
||||
namespace Ram_fs
|
||||
@ -36,10 +37,10 @@ class Ram_fs::File : public Node
|
||||
{
|
||||
private:
|
||||
|
||||
typedef Chunk<4096> Chunk_level_3;
|
||||
typedef Chunk_index<128, Chunk_level_3> Chunk_level_2;
|
||||
typedef Chunk_index<64, Chunk_level_2> Chunk_level_1;
|
||||
typedef Chunk_index<64, Chunk_level_1> Chunk_level_0;
|
||||
typedef Chunk <num_level_3_entries()> Chunk_level_3;
|
||||
typedef Chunk_index<num_level_2_entries(), Chunk_level_3> Chunk_level_2;
|
||||
typedef Chunk_index<num_level_1_entries(), Chunk_level_2> Chunk_level_1;
|
||||
typedef Chunk_index<num_level_0_entries(), Chunk_level_1> Chunk_level_0;
|
||||
|
||||
Chunk_level_0 _chunk;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user