Skip to content

Commit

Permalink
Rewrite Handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtyson123 committed Oct 21, 2023
1 parent 6d6d1d8 commit db8cdc7
Show file tree
Hide file tree
Showing 24 changed files with 147 additions and 141 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MaxOS now has support for hardrives (Fat32 filesytem) and can be booted from an

## Screenshots
Booting
![Screenshot](docs/Screenshots/Boot/Console%20v2.png)
![Screenshot](docs/Screenshots/Boot/Console%20v2.png) cd

GUI Window System
![Screenshot](docs/Screenshots/GUI/Windows%20(VESA).png)
Expand Down Expand Up @@ -50,37 +50,38 @@ Kernel Cleanup
- [x] VESA Video Mode
- [x] Kernel Boot Rewrite
- [x] Rewrite Event Handlers
- [ ] Usable Desktop
- [ ] Better Doxygen Documentation
- [ ] Network Touch Up
- [ ] HTTP Protocol, DCHP protocol
- [ ] GUI Bug Fixes
- [ ] Better Commenting and Doxygen Documentation
- [ ] Use better c++ coding conventions
- [ ] Fix Filesystem
- [ ] Fix filesystem (move to linux one?)
- [ ] USB
- [ ] HTTP Protocol, DCHP protocol
- [ ] Codebase cleanup / rewrite
- [ ] CMAKE
- [ ] Custom Toolchain
- [ ] CMAKE Build System (and maybe get it building and debugging in CLion)

Road to Userspace
Road to Userspace pt 1 - kernel core features

- [ ] New Process Manager / Scheduler
- [ ] Interprocess Communication
- [ ] Might need an I/O Rewrite (more to come)
- [ ] Better Memory Management
- [ ] Paging - ?
- [ ] Filesystem Fixes
- [ ] System Calls

Road to Userspace pt 2 - kernel supporting features

- [ ] Elf Loader
- [ ] Shell
- [ ] More System Calls
- [ ] OS Specific Toolchain
- [ ] LibC
- [ ] LibM
- [ ] Interprocess Communication
- [ ] Services, (GUI Server, Network Server, etc)
- [ ] LibNet - SMB Needed
- [ ] Example Telnet Server (GUI) (EXTERNALLY LOADED)

POSIX
- [ ] Unix Filesystem "proc, bin etc"
- [ ] Unix System Calls
- [ ] Other posix stuff

OS Functionality

- [ ] POSIX
- [ ] ext2 Filesystem
- [ ] GUI Theming, More GUI Widgets
- [ ] Game Ports (DOOM etc..)
Expand Down
5 changes: 2 additions & 3 deletions docs/commit.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Input Box - 20/10/23
- Added Input Boxes
- Will need to fix focusing and stuff tho
# Windows Fix - 20/10/23
-
65 changes: 44 additions & 21 deletions kernel/include/common/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ namespace maxOS{
};




template<class Type> class Vector
{
protected:
Expand Down Expand Up @@ -57,9 +55,9 @@ namespace maxOS{

//______________________________________Implementation__________________________________________________
/**
* Base Template for VectorIterationHandler
* @tparam Type Type of the Vector
*/
* Base Template for VectorIterationHandler
* @tparam Type Type of the Vector
*/
template<class Type>
Vector<Type>::Vector() {
MaxSize = 100;
Expand Down Expand Up @@ -192,12 +190,14 @@ namespace maxOS{
* @return The iterator of the element
*/
template<class Type>
typename Vector<Type>::iterator Vector<Type>::pushFront(Type element) {
if (Size >= MaxSize) // if the Vector is full
return end(); // return the end of the Vector
template<class Type> typename Vector<Type>::iterator Vector<Type>::pushFront(Type element) {

// Make sure the Vector is not full
if (Size >= MaxSize)
return end();

for (iterator i = end(); i > begin(); --i) // for each element in the Vector
// for each element in the Vector
for (iterator i = end(); i > begin(); --i)
*i = *(i - 1); // move the element one index to the right

elements[0] = element; // add the element to front of the Vector
Expand All @@ -211,8 +211,7 @@ namespace maxOS{
* @tparam Type Type of the Vector
*/
template<class Type>
void Vector<Type>::popFront() {
template<class Type> void Vector<Type>::popFront() {
if (Size > 0) //If the Vector is not empty
{
for (iterator i = begin() + 1; i != end(); ++i) // for each element in the Vector
Expand All @@ -226,18 +225,21 @@ namespace maxOS{
* @tparam Type The type of the Vector
* @param element The element to remove
*/
template<class Type>
void Vector<Type>::erase(Type element) {
int hits = 0; // number of hits
for (iterator i = begin(); i != end(); ++i) // for each element in the Vector
template<class Type> void Vector<Type>::erase(Type element) {

// Search for the element
int hits = 0;
for (iterator i = begin(); i != end(); ++i)
{
if (*i ==
element) // if the element is equal to the element we are looking for
// If it is the element we are looking for
if (*i == element)
{
++hits; // increase the number of hits
++hits;
} else {
if (hits > 0) // if we have hits
*(i - hits) = *i; // move the element one index to the left

// if we have hits
if (hits > 0)
*(i - hits) = *i; // move the element to the left
}

}
Expand Down Expand Up @@ -297,6 +299,27 @@ namespace maxOS{
for (iterator i = begin(); i != end(); ++i) // for each element in the Vector
callback(*i); // call the callback function
}

template<class Type>
void VectorIterationHandler<Type>::OnEndOfStream() {

}

template<class Type>
void VectorIterationHandler<Type>::OnRead(Type) {

}

template<class Type>
VectorIterationHandler<Type>::~VectorIterationHandler() {

}

template<class Type>
VectorIterationHandler<Type>::VectorIterationHandler() {

}

}
}

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/clock/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace maxOS {
common::uint16_t ticksUntilNextEvent;

// Other functions
common::uint32_t HandleInterrupt(common::uint32_t esp);
void HandleInterrupt();
common::uint8_t readHardwareClock(common::uint8_t address);
common::uint8_t binaryRepresentation(common::uint8_t number);

Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/ethernet/amd_am79c973.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace maxOS{
common::string getDeviceName();

//Override Interrupt default methods
common::uint32_t HandleInterrupt(common::uint32_t esp);
void HandleInterrupt();

//Ethernet Driver functions
void DoSend(common::uint8_t* buffer, common::uint32_t size);
Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/ethernet/intel_i217.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace maxOS{
void deactivate();

//Override Interrupt default methods
common::uint32_t HandleInterrupt(common::uint32_t esp);
void HandleInterrupt();


//Ethernet Driver functions
Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/peripherals/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ namespace maxOS
KeyboardDriver(hardwarecommunication::InterruptManager *manager);
~KeyboardDriver();

virtual common::uint32_t HandleInterrupt(common::uint32_t esp);
void HandleInterrupt();

virtual void activate();
common::string getDeviceName();
Expand Down
2 changes: 1 addition & 1 deletion kernel/include/drivers/peripherals/mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace maxOS {
hardwarecommunication::Port8Bit dataPort;
hardwarecommunication::Port8Bit commandPort;

common::uint32_t HandleInterrupt(common::uint32_t esp);
void HandleInterrupt();

common::uint8_t buffer[3];
common::uint8_t offest;
Expand Down
21 changes: 10 additions & 11 deletions kernel/include/hardwarecommunication/interrupts.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ namespace maxOS {
common::uint8_t interrupNumber;
InterruptManager *interruptManager;

InterruptHandler(common::uint8_t interrupNumber, InterruptManager *interruptManager);

InterruptHandler(common::uint8_t interrupNumber, InterruptManager *interruptManager = 0);
~InterruptHandler();

public:
virtual common::uint32_t HandleInterrupt(common::uint32_t esp);
virtual void HandleInterrupt();

};

Expand All @@ -38,7 +37,9 @@ namespace maxOS {
protected:

static InterruptManager *ActiveInterruptManager;
InterruptHandler *interruptHandlers[256];
static common::OutputStream* errorMessages;
common::uint16_t hardwareInterruptOffset;
InterruptHandler *interruptHandlers[256]; // Make vector?
ThreadManager* threadManager;

struct GateDescriptor {
Expand All @@ -56,9 +57,6 @@ namespace maxOS {
common::uint32_t base;
} __attribute__((packed));

common::uint16_t hardwareInterruptOffset;
common::OutputStream* errorMessages;

static void SetInterruptDescriptorTableEntry(common::uint8_t interrupt,
common::uint16_t codeSegmentSelectorOffset,
void (*handler)(),
Expand Down Expand Up @@ -122,8 +120,8 @@ namespace maxOS {


static common::uint32_t HandleInterrupt(common::uint8_t interrupt, common::uint32_t esp);

common::uint32_t DoHandleInterrupt(common::uint8_t interrupt, common::uint32_t esp);
static common::uint32_t HandleInterruptRequest(common::uint32_t esp);
common::uint32_t DoHandleInterruptRequest(common::uint8_t interrupt, common::uint32_t esp);

//PIC Cominunication
Port8BitSlow programmableInterruptControllerMasterCommandPort;
Expand All @@ -134,13 +132,14 @@ namespace maxOS {

public:
InterruptManager(common::uint16_t hardwareInterruptOffset, system::GlobalDescriptorTable *globalDescriptorTable, ThreadManager* threadManage, common::OutputStream* handler);

~InterruptManager();

common::uint16_t HardwareInterruptOffset();

void Activate();
void setInterruptHandler(common::uint8_t interrupt, InterruptHandler *handler);
void removeInterruptHandler(common::uint8_t interrupt);

void Activate();
void Deactivate();

};
Expand Down
2 changes: 1 addition & 1 deletion kernel/include/hardwarecommunication/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace maxOS{
serial(InterruptManager* interruptManager);
~serial();

common::uint32_t HandleInterrupt(common::uint32_t esp);
void HandleInterrupt();

void Test();
char Read();
Expand Down
2 changes: 1 addition & 1 deletion kernel/include/system/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace maxOS{
SyscallHandler(hardwarecommunication::InterruptManager* interruptManager, common::uint8_t interruptNumber);
~SyscallHandler();

virtual common::uint32_t HandleInterrupt(common::uint32_t esp);
virtual void HandleInterrupt();

};

Expand Down
6 changes: 2 additions & 4 deletions kernel/src/drivers/clock/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ Clock::~Clock() {
* @details Handle the RTC interrupt, It increments the number of ticks and calls the event clockEventHandlers if the number of ticks is equal to the number of ticks between events
* @param esp The stack pointer
*/
uint32_t Clock::HandleInterrupt(uint32_t esp) {
void Clock::HandleInterrupt() {

// Increment the number of ticks and decrement the number of ticks until the next event
ticks++;
ticksUntilNextEvent--;

// If the number of ticks until the next event is not 0 then return
if(ticksUntilNextEvent != 0)
return esp;
return;

// Otherwise, reset the number of ticks until the next event
ticksUntilNextEvent = ticksBetweenEvents;
Expand All @@ -96,8 +96,6 @@ uint32_t Clock::HandleInterrupt(uint32_t esp) {
TimeEvent* event = new TimeEvent(&time);
raiseEvent(event);
//TODO: delete event;

return esp;
}


Expand Down
2 changes: 1 addition & 1 deletion kernel/src/drivers/console/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void ConsoleStream::writeChar(char c) {
cursorY = console->getHeight()-1;
}

// dont break here, we want to go to the next case because of the \r
// don't break here, we want to go to the next case because of the \r

// Carriage return
case '\r':
Expand Down
9 changes: 2 additions & 7 deletions kernel/src/drivers/ethernet/amd_am79c973.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ uint32_t amd_am79c973::reset() {
* @details This function handles the interrupt for the device
*
* @param esp The stack pointer (where to return to)
*/
common::uint32_t amd_am79c973::HandleInterrupt(common::uint32_t esp) {
*/
void amd_am79c973::HandleInterrupt() {


// Similar to PIC, data needs to be read when a interrupt is sent, or it hangs
Expand All @@ -179,11 +179,6 @@ common::uint32_t amd_am79c973::HandleInterrupt(common::uint32_t esp) {
// Reply that it was received
registerAddressPort.Write(0); // Tell device to write to register 0
registerDataPort.Write(temp); // Tell device that the interrupt was received



return esp;

}


Expand Down
6 changes: 1 addition & 5 deletions kernel/src/drivers/ethernet/intel_i217.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void intel_i217::activate() {

}

common::uint32_t intel_i217::HandleInterrupt(common::uint32_t esp) {
void intel_i217::HandleInterrupt() {

Write(interruptMaskRegister, 0x1); //Clear the interrupt or it will hang
uint32_t temp = Read(0xc0); //Read the interrupt status register
Expand All @@ -317,10 +317,6 @@ common::uint32_t intel_i217::HandleInterrupt(common::uint32_t esp) {
if(temp & 0x04) driverMessageStream -> write("INTEL i217 START LINK");//initDone = true;
if(temp & 0x10) driverMessageStream -> write("INTEL i217 GOOD THRESHOLD");
if(temp & 0x80) FetchDataReceived();


return esp;

}

void intel_i217::FetchDataReceived() {
Expand Down
Loading

0 comments on commit db8cdc7

Please sign in to comment.