mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
784206c85c
This patch equips the 'Block::Connection' with a framework API for the implementation of robust block-session clients that perform block I/O in an asynchronous fashion. An application-defined 'JOB' type, inherited from 'Connection::Job', encapsulates the application's context information associated with a block operation. The lifecycle of the jobs is implemented by the 'Connection' and driven by the application's invokation of 'Connection::update_jobs'. The 'update_jobs' mechanism takes three hook functions as arguments, which implement the applications-defined policy for producing and consuming data, and for the completion of jobs. Issue #3283
92 lines
1.7 KiB
C++
92 lines
1.7 KiB
C++
/*
|
|
* \brief Block request
|
|
* \author Norman Feske
|
|
* \date 2018-12-17
|
|
*/
|
|
|
|
/*
|
|
* 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__BLOCK__REQUEST_H_
|
|
#define _INCLUDE__BLOCK__REQUEST_H_
|
|
|
|
/* Genode includes */
|
|
#include <base/stdint.h>
|
|
#include <base/output.h>
|
|
|
|
namespace Block {
|
|
|
|
typedef Genode::uint64_t block_number_t;
|
|
typedef Genode::size_t block_count_t;
|
|
typedef Genode::off_t off_t;
|
|
|
|
struct Operation;
|
|
struct Request;
|
|
}
|
|
|
|
|
|
struct Block::Operation
|
|
{
|
|
enum class Type { INVALID = 0, READ = 1, WRITE = 2, SYNC = 3, TRIM = 4 };
|
|
|
|
Type type;
|
|
block_number_t block_number;
|
|
block_count_t count;
|
|
|
|
bool valid() const
|
|
{
|
|
return type == Type::READ || type == Type::WRITE
|
|
|| type == Type::SYNC || type == Type::TRIM;
|
|
}
|
|
|
|
static bool has_payload(Type type)
|
|
{
|
|
return type == Type::READ || type == Type::WRITE;
|
|
}
|
|
|
|
static char const *type_name(Type type)
|
|
{
|
|
switch (type) {
|
|
case Type::INVALID: return "INVALID";
|
|
case Type::READ: return "READ";
|
|
case Type::WRITE: return "WRITE";
|
|
case Type::SYNC: return "SYNC";
|
|
case Type::TRIM: return "TRIM";
|
|
}
|
|
return "INVALID";
|
|
}
|
|
|
|
void print(Genode::Output &out) const
|
|
{
|
|
Genode::print(out, type_name(type), " block=", block_number, " count=", count);
|
|
}
|
|
};
|
|
|
|
|
|
struct Block::Request
|
|
{
|
|
struct Tag { unsigned long value; };
|
|
|
|
Operation operation;
|
|
|
|
bool success;
|
|
|
|
/**
|
|
* Location of payload within the packet stream
|
|
*/
|
|
off_t offset;
|
|
|
|
/**
|
|
* Client-defined identifier to associate acknowledgements with requests
|
|
*
|
|
* The underlying type corresponds to 'Id_space::Id'.
|
|
*/
|
|
Tag tag;
|
|
};
|
|
|
|
#endif /* _INCLUDE__BLOCK__REQUEST_H_ */
|