mirror of
https://github.com/fergalmoran/ferglos.git
synced 2026-02-15 12:24:00 +00:00
Clean up folders
This commit is contained in:
79
include/hardware/interrupts.h
Normal file
79
include/hardware/interrupts.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#ifndef __FERGLOS_HARDWARE_INTERRUPTS_H
|
||||
#define __FERGLOS_HARDWARE_INTERRUPTS_H
|
||||
|
||||
#include <common/types.h>
|
||||
#include <gdt.h>
|
||||
#include <hardware/port.h>
|
||||
|
||||
using namespace ferglos::drivers;
|
||||
|
||||
namespace ferglos {
|
||||
namespace hardware {
|
||||
class InterruptManager;
|
||||
class InterruptHandler {
|
||||
protected:
|
||||
uint8_t _interruptNumber;
|
||||
InterruptManager* _interruptManager;
|
||||
|
||||
InterruptHandler(uint8_t interruptNumber, InterruptManager* interruptManager);
|
||||
~InterruptHandler();
|
||||
|
||||
public:
|
||||
virtual uint32_t HandleInterrupt(uint32_t esp);
|
||||
};
|
||||
|
||||
class InterruptManager {
|
||||
friend class InterruptHandler;
|
||||
|
||||
protected:
|
||||
static InterruptManager* _activeInterruptManager;
|
||||
|
||||
InterruptHandler* _handlers[256];
|
||||
|
||||
struct GateDescriptor {
|
||||
uint16_t handlerAddressLowBits;
|
||||
uint16_t gdt_codeSegmentSelector;
|
||||
uint8_t reserved;
|
||||
uint8_t access;
|
||||
uint16_t handlerAddressHiBits;
|
||||
|
||||
} __attribute__((packed));
|
||||
|
||||
static GateDescriptor _interruptDescriptorTable[256];
|
||||
|
||||
struct InterruptDescriptorTablePointer {
|
||||
uint16_t size;
|
||||
uint32_t base;
|
||||
} __attribute__((packed));
|
||||
|
||||
static void
|
||||
SetInterruptDescriptorTableEntries(
|
||||
uint8_t interruptNumber,
|
||||
uint16_t codeSegmentSelectorOffset,
|
||||
void (*handler)(),
|
||||
uint8_t descriptorPrivilegeLevel,
|
||||
uint8_t descriptorType);
|
||||
|
||||
Port8Bit_Slow _picPrimaryCommand;
|
||||
Port8Bit_Slow _picPrimaryData;
|
||||
Port8Bit_Slow _picSecondaryCommand;
|
||||
Port8Bit_Slow _picSecondaryData;
|
||||
|
||||
public:
|
||||
InterruptManager(GlobalDescriptorTable* gdt);
|
||||
~InterruptManager();
|
||||
|
||||
void Activate();
|
||||
void Deactivate();
|
||||
|
||||
static uint32_t HandleInterrupt(uint8_t interrupt, uint32_t esp);
|
||||
uint32_t DoHandleInterrupt(uint8_t interruptNumber, uint32_t esp);
|
||||
|
||||
static void IgnoreInterruptRequest();
|
||||
static void HandleInterruptRequest0x00();
|
||||
static void HandleInterruptRequest0x01();
|
||||
static void HandleInterruptRequest0x0C();
|
||||
};
|
||||
} // namespace hardware
|
||||
} // namespace ferglos
|
||||
#endif
|
||||
53
include/hardware/port.h
Normal file
53
include/hardware/port.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef __FERGLOS_HARDWARE_PORT_H
|
||||
#define __FERGLOS_HARDWARE_PORT_H
|
||||
|
||||
#include <common/types.h>
|
||||
using namespace ferglos::common;
|
||||
|
||||
namespace ferglos {
|
||||
namespace drivers {
|
||||
|
||||
class Port {
|
||||
protected:
|
||||
uint16_t portNumber;
|
||||
Port(uint16_t portNumber);
|
||||
~Port();
|
||||
};
|
||||
|
||||
class Port8Bit : public Port {
|
||||
public:
|
||||
Port8Bit(uint16_t portNumber);
|
||||
~Port8Bit();
|
||||
|
||||
virtual void Write(uint8_t data);
|
||||
virtual uint8_t Read();
|
||||
};
|
||||
|
||||
class Port8Bit_Slow : public Port8Bit {
|
||||
public:
|
||||
Port8Bit_Slow(uint16_t portNumber);
|
||||
~Port8Bit_Slow();
|
||||
|
||||
virtual void Write(uint8_t data);
|
||||
};
|
||||
|
||||
class Port16Bit : public Port {
|
||||
public:
|
||||
Port16Bit(uint16_t portNumber);
|
||||
~Port16Bit();
|
||||
|
||||
virtual void Write(uint16_t data);
|
||||
virtual uint16_t Read();
|
||||
};
|
||||
|
||||
class Port32Bit : public Port {
|
||||
public:
|
||||
Port32Bit(uint16_t portNumber);
|
||||
~Port32Bit();
|
||||
|
||||
virtual void Write(uint32_t data);
|
||||
virtual uint32_t Read();
|
||||
};
|
||||
} // namespace drivers
|
||||
} // namespace ferglos
|
||||
#endif
|
||||
Reference in New Issue
Block a user