The Pedigree Project 0.1
InfoBlock.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef _INFO_BLOCK_H
21#define _INFO_BLOCK_H
22
23#ifdef __cplusplus
24
25#include "pedigree/kernel/processor/types.h"
26
27#else
28
29#include <stddef.h>
30#include <stdint.h>
31
32#endif
33
34#define INFO_BLOCK_VDSO_GETCPU_RDTSCP (1u << 0)
35
36struct InfoBlock {
38 uint64_t now;
39
41 uint64_t now_s;
42
44 size_t pid;
45
47 char sysname[64];
48 char release[64];
49 char version[64];
50 char machine[64];
51
53 uint64_t monotonic;
54
56 uint32_t vdso_features;
57};
58
59#ifdef __cplusplus
60
61#include "pedigree/kernel/Spinlock.h"
62#include "pedigree/kernel/machine/TimerHandler.h"
63
64class Timer;
65
66class InfoBlockManager : public TimerHandler {
67 public:
68 InfoBlockManager();
69 virtual ~InfoBlockManager();
70
71 static InfoBlockManager& instance();
72
73 bool initialise();
74
76 bool shutdown();
77
78 virtual void timer(uint64_t delta);
79
80 void refreshTime();
81
82 void setPid(size_t value);
83
84 private:
85 static InfoBlockManager m_Instance;
86
87 bool m_bInitialised;
88 Spinlock m_UpdateLock;
89 Timer* m_pTimer;
90
91 struct InfoBlock* m_pInfoBlock;
92};
93
94#endif
95
96#endif
uint64_t monotonic
Monotonic tick count in nanoseconds.
Definition InfoBlock.h:53
uint64_t now
Current timestamp in nanoseconds since the UNIX epoch.
Definition InfoBlock.h:38
uint32_t vdso_features
CPU-local vDSO capabilities published by the kernel.
Definition InfoBlock.h:56
size_t pid
Current process' ID.
Definition InfoBlock.h:44
uint64_t now_s
Current timestamp in seconds since the UNIX epoch.
Definition InfoBlock.h:41
char sysname[64]
uname fields.
Definition InfoBlock.h:47