Skip to content

Commit f9521fd

Browse files
committed
* Implemented syscall
1 parent bbf4c0d commit f9521fd

File tree

6 files changed

+52
-1
lines changed

6 files changed

+52
-1
lines changed

CPU/Interrupts.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ InterruptManager::InterruptManager(uint16_t hardwareInterruptOffset, GlobalDescr
101101
SetInterruptDescriptorTableEntry(hardwareInterruptOffset + 0x0E, CodeSegment, &HandleInterruptRequest0x0E, 0, IDT_INTERRUPT_GATE);
102102
SetInterruptDescriptorTableEntry(hardwareInterruptOffset + 0x0F, CodeSegment, &HandleInterruptRequest0x0F, 0, IDT_INTERRUPT_GATE);
103103

104+
SetInterruptDescriptorTableEntry(0x80, CodeSegment, &HandleInterruptRequest0x80, 0, IDT_INTERRUPT_GATE);
105+
104106
programmableInterruptControllerMasterCommandPort.WriteToPort(0x11);
105107
programmableInterruptControllerSlaveCommandPort.WriteToPort(0x11);
106108

CPU/Interrupts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class InterruptManager
7676
static void HandleInterruptRequest0x0F();
7777
static void HandleInterruptRequest0x31();
7878

79+
static void HandleInterruptRequest0x80();
80+
7981
static void HandleException0x00();
8082
static void HandleException0x01();
8183
static void HandleException0x02();

CPU/interruptstab.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ HandleInterruptRequest 0x0D
5959
HandleInterruptRequest 0x0E
6060
HandleInterruptRequest 0x0F
6161
HandleInterruptRequest 0x31
62+
HandleInterruptRequest 0x80
6263

6364
int_bottom:
6465

CPU/syscall.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "syscall.h"
2+
3+
void printf(char*);
4+
5+
SyscallHandler::SyscallHandler(InterruptManager* interruptManager, uint8_t InterruptNumber)
6+
:InterruptHandler(InterruptNumber + interruptManager->HardwareInterruptOffset(), interruptManager)
7+
{
8+
}
9+
10+
SyscallHandler::~SyscallHandler()
11+
{
12+
}
13+
14+
uint32_t SyscallHandler::HandleInterrupt(uint32_t esp)
15+
{
16+
CPUState* cpu = (CPUState*)esp;
17+
18+
19+
switch(cpu->eax)
20+
{
21+
case 4:
22+
printf((char*)cpu->ebx);
23+
break;
24+
25+
default:
26+
break;
27+
}
28+
29+
30+
return esp;
31+
}

CPU/syscall.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef __SYSCALL_H
2+
#define __SYSCALL_H
3+
4+
#include "../Includes/types.h"
5+
#include "Interrupts.h"
6+
7+
class SyscallHandler : public InterruptHandler
8+
{
9+
public:
10+
SyscallHandler(InterruptManager* interruptManager, uint8_t InterruptNumber);
11+
~SyscallHandler();
12+
virtual uint32_t HandleInterrupt(uint32_t esp);
13+
};
14+
15+
#endif

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ to build the project. The output will be in the Build folder.
1515
To run the OS in qemu, Run:
1616

1717
```shell
18-
make run
18+
make runQEMU
1919
```
2020

2121
To clean all output files, Run:

0 commit comments

Comments
 (0)