Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::runtime::TrapFlagExcpetion Class Reference

Exception handler for a hardware mem watch. More...

#include <gdbstub.h>

Inheritance diagram for MaxOS::runtime::TrapFlagExcpetion:
MaxOS::hardwarecommunication::ExceptionHandler MaxOS::hardwarecommunication::InterruptHandler

Public Member Functions

 TrapFlagExcpetion (GDBServer *server)
 Registers a handler for the TrapFlagException (interrupt 0x1)
 
system::cpu_status_t * handle_interrupt (system::cpu_status_t *status) override
 Handles the interrupt 0x1 by clearing the trap flag and pausing the thread.
 
- Public Member Functions inherited from MaxOS::hardwarecommunication::ExceptionHandler
 ExceptionHandler (uint8_t interrupt_number)
 Create a new base exception handler for an interrupt.
 
 ~ExceptionHandler ()
 
virtual string get_message (system::cpu_status_t *status)
 Get an human readable error message explaining 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

Exception handler for a hardware mem watch.

Definition at line 37 of file gdbstub.h.

Constructor & Destructor Documentation

◆ TrapFlagExcpetion()

TrapFlagExcpetion::TrapFlagExcpetion ( GDBServer *  server)

Registers a handler for the TrapFlagException (interrupt 0x1)

Parameters
serverThe GDB stub that will handle the exception

Definition at line 547 of file gdbstub.cpp.

548: ExceptionHandler(0x1),
549 m_gdb_handler(server)
550{
551
552}
Base class for handing CPU expection interrupts.
Definition interrupts.h:61

Member Function Documentation

◆ handle_interrupt()

cpu_status_t * TrapFlagExcpetion::handle_interrupt ( system::cpu_status_t *  status)
overridevirtual

Handles the interrupt 0x1 by clearing the trap flag and pausing the thread.

Parameters
statusThe registers at time of exception
Returns
The state to return to

Reimplemented from MaxOS::hardwarecommunication::ExceptionHandler.

Definition at line 562 of file gdbstub.cpp.

562 {
563
564 // Clear flag
565 status->rflags &= ~(1 << 8);
566 m_gdb_handler->thread_regs = *status;
567 m_gdb_handler->attached_thread()->thread_state = ThreadState::WAITING;
568
569 // Notify the server that it stopped
570 m_gdb_handler->send_message("S05");
571
572 // Dont execute further until instructed by GDB
574
575 // Copy the registers back as they may have been modified elsewhere
576 *status = m_gdb_handler->thread_regs;
577 return status;
578}
static Thread * current_thread()
Gets the thread on the currently executing core.
void yield()
Pass execution to the next ready thread.
Definition process.cpp:103
volatile thread_state_t thread_state
The current state of the thread.
Definition process.h:72
processes::Thread * attached_thread()
Get the attached thread.
Definition gdbstub.cpp:536
void send_message(const string &payload)
Converts a message to the required form and sends it over serial.
Definition gdbstub.cpp:267

References MaxOS::runtime::GDBServer::attached_thread(), MaxOS::processes::GlobalScheduler::current_thread(), MaxOS::runtime::GDBServer::send_message(), MaxOS::processes::Thread::thread_state, and MaxOS::processes::Thread::yield().


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