Skip to content

Commit 987003e

Browse files
committed
* Trying to implement custom handler for keyboard
* Added new syscall Reboot
1 parent 3fa4feb commit 987003e

25 files changed

+390
-263
lines changed

CPU/Interrupts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define __INTERRUPTMANAGER_H
44

55
#include "../kernel/gdt.h"
6-
#include "../Includes/types.h"
6+
#include "../Include/types.h"
77
#include "../Drivers/IOPorts.h"
88
#include "../CPU/PowerControl.h"
99
#include "../kernel/MultiTask.h"

CPU/PowerControl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ void PowerControl::StopVirtualBox()
1919
{
2020
port32BIT pt(0x4004);
2121
pt.WriteToPort(0x3400);
22+
}
23+
24+
bool PowerControl::getPowerState()
25+
{
26+
port8BIT pt(0xB0);
27+
return pt.ReadFromPort() & 0x01;
2228
}

CPU/PowerControl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef __POWERCONTROL_H
22
#define __POWERCONTROL_H
33

4-
#include "../Includes/types.h"
4+
#include "../Include/types.h"
55
#include "../Drivers/IOPorts.h"
66

77
class PowerControl
@@ -13,6 +13,9 @@ class PowerControl
1313
void halt();
1414
//If running in virtualBox. This function will Stop virtualBox
1515
void StopVirtualBox();
16+
17+
//To get the current power state
18+
bool getPowerState();
1619
};
1720

1821
#endif

CPU/syscall.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "syscall.h"
22

33
void printf(char*);
4+
PowerControl syscontrol;
45

56
SyscallHandler::SyscallHandler(InterruptManager* interruptManager, uint8_t InterruptNumber)
67
:InterruptHandler(InterruptNumber + interruptManager->HardwareInterruptOffset(), interruptManager)
@@ -18,10 +19,14 @@ uint32_t SyscallHandler::HandleInterrupt(uint32_t esp)
1819

1920
switch(cpu->eax)
2021
{
21-
case 4:
22+
case 1: // sys_print
2223
printf((char*)cpu->ebx);
2324
break;
2425

26+
case 2: // sys_reboot
27+
syscontrol.reboot();
28+
break;
29+
2530
default:
2631
break;
2732
}

CPU/syscall.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#ifndef __SYSCALL_H
22
#define __SYSCALL_H
33

4-
#include "../Includes/types.h"
4+
#include "../Include/types.h"
55
#include "Interrupts.h"
6+
#include "PowerControl.h"
67

78
class SyscallHandler : public InterruptHandler
89
{

Drivers/HDD-ATA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define __HDD_ATA_H
33

44
#include "IOPorts.h"
5-
#include "../Includes/types.h"
5+
#include "../Include/types.h"
66

77

88
class AdvancedTechnologyAttachment

Drivers/IOPorts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef __PORT_H
22

33
#define __PORT_H
4-
#include "../Includes/types.h"
4+
#include "../Include/types.h"
55

66
class port
77
{

0 commit comments

Comments
 (0)