genode/repos/ports/include/vmm/utcb_guard.h
Norman Feske aa66b5d62f base: remove dependency from deprecated APIs
This patch adjusts the implementation of the base library and core such
that the code no longer relies on deprecated APIs except for very few
cases, mainly to keep those deprecated APIs in tact for now.

The most prominent changes are:

- Removing the use of base/printf.h

- Removing of the log backend for printf. The 'Console' with the
  format-string parser is still there along with 'snprintf.h' because
  the latter is still used at a few places, most prominently the
  'Connection' classes.

- Removing the notion of a RAM session, which does not exist in
  Genode anymore. Still the types were preserved (by typedefs to
  PD session) to keep up compatibility. But this transition should
  come to an end now.

- Slight rennovation of core's tracing service, e.g., the use of an
  Attached_dataspace as the Argument_buffer.

- Reducing the reliance on global accessors like deprecated_env() or
  core_env(). Still there is a longish way to go to eliminate all such
  calls. A useful pattern (or at least a stop-gap solution) is to
  pass the 'Env' to the individual compilation units via init functions.

- Avoiding the use of the old 'Child_policy::resolve_session_request'
  interface that returned a 'Service' instead of a 'Route'.

Issue #1987
2019-02-19 11:08:17 +01:00

67 lines
1.5 KiB
C++

/*
* \brief Guard to save a UTCB and restore it during guard destruction
* \author Alexander Boettcher
* \date 2013-07-05
*/
/*
* Copyright (C) 2013-2017 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__VMM__UTCB_GUARD_H_
#define _INCLUDE__VMM__UTCB_GUARD_H_
/* Genode includes */
#include <base/printf.h>
#include <util/string.h>
/* NOVA syscalls */
#include <nova/syscalls.h>
namespace Vmm {
using namespace Genode;
class Utcb_guard;
}
class Vmm::Utcb_guard
{
public:
struct Utcb_backup { char buf[Nova::Utcb::size()]; };
private:
Utcb_backup &_backup_utcb;
public:
Utcb_guard(Utcb_backup &backup_utcb) : _backup_utcb(backup_utcb)
{
Nova::Utcb *utcb =
reinterpret_cast<Nova::Utcb *>(Thread::myself()->utcb());
unsigned header_len = (char *)utcb->msg() - (char *)utcb;
unsigned len = header_len + utcb->msg_words() * sizeof(Nova::mword_t);
Genode::memcpy(&_backup_utcb, utcb, len);
if (utcb->msg_items())
Genode::warning("Error: msg items on UTCB are not saved and restored!");
}
~Utcb_guard()
{
Nova::Utcb *utcb = reinterpret_cast<Nova::Utcb *>(&_backup_utcb);
unsigned header_len = (char *)utcb->msg() - (char *)utcb;
unsigned len = header_len + utcb->msg_words() * sizeof(Nova::mword_t);
Genode::memcpy(Thread::myself()->utcb(), utcb, len);
}
};
#endif /* _INCLUDE__VMM__UTCB_GUARD_H_ */