The Pedigree Project 0.1
hosted/state.cc
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#include "pedigree/kernel/processor/state.h"
21
22#include <ucontext.h>
23
24const char* HostedInterruptStateRegisterName[3] = {
25 "state",
26 "extra",
27 "meta",
28};
29
31 : state(0),
32 which(0),
33 fromUserspace(0),
34 extra(0),
35 meta(0),
36 m_basePointer(0),
37 m_instructionPointer(0),
38 m_stackPointer(0) {}
39
41
43 return 3;
44}
45processor_register_t HostedInterruptState::getRegister(size_t index) const {
46 if (index == 0)
47 return state;
48 if (index == 1)
49 return extra;
50 if (index == 2)
51 return meta;
52 return 0;
53}
54const char* HostedInterruptState::getRegisterName(size_t index) const {
55 return HostedInterruptStateRegisterName[index];
56}
57
59 return 0;
60}
61
62processor_register_t HostedSyscallState::getRegister(size_t index) const {
63 return 0;
64}
65
66const char* HostedSyscallState::getRegisterName(size_t index) const {
67 return "<no registers>";
68}
69
73
74HostedSchedulerState::HostedSchedulerState() {
75 stackBase = 0;
76 stackSize = 0;
77
78 ucontext_t* ctx = reinterpret_cast<ucontext_t*>(state);
79 getcontext(ctx);
80}
processor_register_t getRegister(size_t index) const
static HostedInterruptState * construct(class HostedProcessorState &state, bool userMode)
size_t getRegisterCount() const
const char * getRegisterName(size_t index) const
const char * getRegisterName(size_t index) const
size_t getRegisterCount() const
processor_register_t getRegister(size_t index) const