Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::hardwarecommunication::GeneralProtectionHandler Class Reference

Handles a general protection exception. More...

#include <interrupts.h>

Inheritance diagram for MaxOS::hardwarecommunication::GeneralProtectionHandler:
MaxOS::hardwarecommunication::ExceptionHandler MaxOS::hardwarecommunication::InterruptHandler

Public Member Functions

 GeneralProtectionHandler ()
 Create a new GeneralProtectionHandler.
 
string get_message (system::cpu_status_t *status) final
 Get an human readable error message explaining this exception.
 
- Public Member Functions inherited from MaxOS::hardwarecommunication::ExceptionHandler
 ExceptionHandler (uint8_t interrupt_number)
 Create a new base exception handler for an interrupt.
 
 ~ExceptionHandler ()
 
virtual system::cpu_status_t * handle_interrupt (system::cpu_status_t *status)
 Handle the interrupt relating to this exception.
 
- Public Member Functions inherited from MaxOS::hardwarecommunication::InterruptHandler
virtual void handle_interrupt ()
 Handles an interrupt.
 

Additional Inherited Members

- Protected Member Functions inherited from MaxOS::hardwarecommunication::InterruptHandler
 InterruptHandler (uint8_t interrupt_number, int64_t redirect=-1, uint64_t redirect_index=0)
 Creates a new interrupt handler and registers it with the interrupt manager.
 
virtual ~InterruptHandler ()
 Destroys the interrupt handler and unregisters it from the interrupt manager.
 
- Protected Attributes inherited from MaxOS::hardwarecommunication::InterruptHandler
uint8_t m_interrupt_number
 The interrupt number this handler handles.
 

Detailed Description

Handles a general protection exception.

Definition at line 102 of file interrupts.h.

Constructor & Destructor Documentation

◆ GeneralProtectionHandler()

MaxOS::hardwarecommunication::GeneralProtectionHandler::GeneralProtectionHandler ( )
inline

Create a new GeneralProtectionHandler.

Definition at line 106 of file interrupts.h.

106: ExceptionHandler(0x0D) { }
ExceptionHandler(uint8_t interrupt_number)
Create a new base exception handler for an interrupt.

Member Function Documentation

◆ get_message()

string GeneralProtectionHandler::get_message ( system::cpu_status_t *  status)
finalvirtual

Get an human readable error message explaining this exception.

Parameters
statusThe CPU state at time of exception
Returns
The error message

Reimplemented from MaxOS::hardwarecommunication::ExceptionHandler.

Definition at line 161 of file interrupts.cpp.

161 {
162
163 // Get the core that the fault happened on
164 auto core = CPU::executing_core();
165 uint64_t core_id = core ? core->id : 0;
166
167 uint64_t error_code = status->error_code;
168 return StringBuilder() << "General Protection Fault: (0x" << status->rip << "): " << (error_code & 0x1 ? "Protection-Exception" : "Not a Protection Exception") << " cid: " << core_id << "\n";
169
170}
static Core * executing_core()
Gets the core that is currently executing.
Definition cpu.cpp:660

References MaxOS::system::CPU::executing_core().


The documentation for this class was generated from the following files: