mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 14:13:09 +00:00
fd401bdf53
This patch cleans up the thread API and comes with the following noteworthy changes: - Introduced Cpu_session::Weight type that replaces a formerly used plain integer value to prevent the accidental mix-up of arguments. - The enum definition of Cpu_session::DEFAULT_WEIGHT moved to Cpu_session::Weight::DEFAULT_WEIGHT - New Thread constructor that takes a 'Env &' as first argument. The original constructors are now marked as deprecated. For the common use case where the default 'Weight' and 'Affinity' are used, a shortcut is provided. In the long term, those two constructors should be the only ones to remain. - The former 'Thread<>' class template has been renamed to 'Thread_deprecated'. - The former 'Thread_base' class is now called 'Thread'. - The new 'name()' accessor returns the thread's name as 'Name' object as centrally defined via 'Cpu_session::Name'. It is meant to replace the old-fashioned 'name' method that takes a buffer and size as arguments. - Adaptation of the thread test to the new API Issue #1954
59 lines
1.1 KiB
C++
59 lines
1.1 KiB
C++
/*
|
|
* \brief Utilities for implementing VMMs on Genode/NOVA
|
|
* \author Norman Feske
|
|
* \date 2013-08-20
|
|
*/
|
|
|
|
/*
|
|
* 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__VMM__PRINTF_H_
|
|
#define _INCLUDE__VMM__PRINTF_H_
|
|
|
|
/* Genode includes */
|
|
#include <base/thread.h>
|
|
#include <base/lock.h>
|
|
#include <base/printf.h>
|
|
|
|
/* NOVA includes */
|
|
#include <nova/syscalls.h>
|
|
|
|
namespace Vmm {
|
|
|
|
using namespace Genode;
|
|
|
|
void printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
|
}
|
|
|
|
|
|
/**
|
|
* Print message while preserving the UTCB content
|
|
*/
|
|
inline void Vmm::printf(const char *format, ...)
|
|
{
|
|
va_list list;
|
|
va_start(list, format);
|
|
|
|
struct Utcb_backup { char buf[Nova::Utcb::size()]; };
|
|
|
|
static Lock lock;
|
|
static Utcb_backup utcb_backup;
|
|
|
|
Lock::Guard guard(lock);
|
|
|
|
utcb_backup = *(Utcb_backup *)Thread::myself()->utcb();
|
|
|
|
Genode::printf("VMM: ");
|
|
Genode::vprintf(format, list);
|
|
|
|
*(Utcb_backup *)Thread::myself()->utcb() = utcb_backup;
|
|
|
|
va_end(list);
|
|
}
|
|
|
|
#endif /* _INCLUDE__VMM__PRINTF_H_ */
|