The Pedigree Project 0.1
kernel/core/processor/hosted/InterruptManager.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 KERNEL_PROCESSOR_HOSTED_INTERRUPTMANAGER_H
21#define KERNEL_PROCESSOR_HOSTED_INTERRUPTMANAGER_H
22#include "pedigree/kernel/Spinlock.h"
23#include "pedigree/kernel/compiler.h"
24#include "pedigree/kernel/processor/InterruptManager.h"
25#include "pedigree/kernel/processor/state_forward.h"
26#include "pedigree/kernel/processor/types.h"
27
28#include <config.h>
29#include <signal.h>
30
34#define MAX_SIGNAL 32
35
38 public:
42 return m_Instance;
43 }
44
45 virtual bool registerInterruptHandler(size_t nInterruptNumber, InterruptHandler* pHandler);
46
47#if DEBUGGER
48 virtual bool registerInterruptHandlerDebugger(size_t nInterruptNumber,
49 InterruptHandler* pHandler);
50 virtual size_t getBreakpointInterruptNumber() PURE;
51 virtual size_t getDebugInterruptNumber() PURE;
52#endif
53
58
60 static void quiesceProcessor();
61
63 void signalShim(int which, void* siginfo, void* meta, bool fromUserspace);
64
66 struct sigaction getOriginalSigaction(int which) const;
67
68#if HOSTED && PEDIGREE_HOSTED_SMOKE_TESTS
69 using MutationLockHook = void (*)();
70
72 static EXPORTED_PUBLIC void withMutationLockForTest(MutationLockHook hook);
73#endif
74
75 private:
79 static void interrupt(InterruptState& interruptState);
80
86 void setInterruptGate(size_t nInterruptNumber, uintptr_t interruptHandler) INITIALISATION_ONLY;
90 void setIst(size_t nInterruptNumber, size_t ist);
100 virtual ~HostedInterruptManager();
101
104
107#if DEBUGGER
110#endif
111
113 static struct sigaction m_OriginalActions[MAX_SIGNAL];
114 static bool m_ActionInstalled[MAX_SIGNAL];
115
116 static bool m_bQuiesced;
117
120};
121
124#endif
static void initialiseProcessor() INITIALISATION_ONLY
void setInterruptGate(size_t nInterruptNumber, uintptr_t interruptHandler) INITIALISATION_ONLY
void signalShim(int which, void *siginfo, void *meta, bool fromUserspace)
virtual size_t getDebugInterruptNumber() PURE
virtual bool registerInterruptHandlerDebugger(size_t nInterruptNumber, InterruptHandler *pHandler)
void setIst(size_t nInterruptNumber, size_t ist)
virtual bool registerInterruptHandler(size_t nInterruptNumber, InterruptHandler *pHandler)
virtual size_t getBreakpointInterruptNumber() PURE
struct sigaction getOriginalSigaction(int which) const
HostedInterruptManager() INITIALISATION_ONLY
static struct sigaction m_OriginalActions[MAX_SIGNAL]
Abstract base class for interrupt-handlers.
Handles interrupts and interrupt registrations from kernel components.