The Pedigree Project  0.1
kernel/core/processor/x86/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_X86_INTERRUPTMANAGER_H
21 #define KERNEL_PROCESSOR_X86_INTERRUPTMANAGER_H
22 
23 #include "pedigree/kernel/Spinlock.h"
24 #include "pedigree/kernel/compiler.h"
25 #include "pedigree/kernel/processor/InterruptManager.h"
26 #include "pedigree/kernel/processor/SyscallManager.h"
27 #include "pedigree/kernel/processor/types.h"
28 
34 {
35  public:
38  inline static X86InterruptManager &instance()
39  {
40  return m_Instance;
41  }
42 
43  //
44  // InterruptManager Interface
45  //
46  virtual bool registerInterruptHandler(
47  size_t nInterruptNumber, InterruptHandler *pHandler);
48 
49 #ifdef DEBUGGER
51  size_t nInterruptNumber, InterruptHandler *pHandler);
52  virtual size_t getBreakpointInterruptNumber() PURE;
53  virtual size_t getDebugInterruptNumber() PURE;
54 #endif
55 
56  //
57  // SyscallManager Interface
58  //
59  virtual bool
60  registerSyscallHandler(Service_t Service, SyscallHandler *pHandler);
61 
62  virtual uintptr_t syscall(
63  Service_t service, uintptr_t function, uintptr_t p1 = 0,
64  uintptr_t p2 = 0, uintptr_t p3 = 0, uintptr_t p4 = 0, uintptr_t p5 = 0);
65 
70 
71  private:
75  static void interrupt(InterruptState &interruptState);
76 
82  void setInterruptGate(
83  size_t nInterruptNumber, uintptr_t interruptHandler,
84  bool bUserspace) INITIALISATION_ONLY;
88  void
89  setTaskGate(size_t nInterruptNumber, uint16_t tssSeg) INITIALISATION_ONLY;
99  virtual ~X86InterruptManager();
100 
103  {
105  uint16_t offset0;
107  uint16_t selector;
109  uint8_t res;
111  uint8_t flags;
113  uint16_t offset1;
114  } PACKED;
115 
120 #ifdef DEBUGGER
121 
123 #endif
124 
126 
129 
132 };
133 
136 #endif
virtual bool registerSyscallHandler(Service_t Service, SyscallHandler *pHandler)
Handles interrupts and interrupt registrations from kernel components.
void setTaskGate(size_t nInterruptNumber, uint16_t tssSeg) INITIALISATION_ONLY
static void initialiseProcessor() INITIALISATION_ONLY
SyscallHandler * m_pSyscallHandler[serviceEnd]
X86InterruptManager & operator=(const X86InterruptManager &)
virtual size_t getDebugInterruptNumber() PURE
X86InterruptManager() INITIALISATION_ONLY
virtual uintptr_t syscall(Service_t service, uintptr_t function, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0, uintptr_t p5=0)
virtual size_t getBreakpointInterruptNumber() PURE
Abstract base class for interrupt-handlers.
static void interrupt(InterruptState &interruptState)
static X86InterruptManager & instance()
void setInterruptGate(size_t nInterruptNumber, uintptr_t interruptHandler, bool bUserspace) INITIALISATION_ONLY
virtual bool registerInterruptHandlerDebugger(size_t nInterruptNumber, InterruptHandler *pHandler)
virtual bool registerInterruptHandler(size_t nInterruptNumber, InterruptHandler *pHandler)