-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
191 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <device/cmos.h> | ||
#include <kernel/io.h> | ||
|
||
using namespace Device; | ||
using namespace Kernel; | ||
|
||
#define PORT_ADDR 0x70 | ||
#define PORT_DATA 0x71 | ||
|
||
uint8_t CMOS::Read(uint8_t addr) | ||
{ | ||
IO::Out8(PORT_ADDR, addr); | ||
return IO::In8(PORT_DATA); | ||
} | ||
|
||
void CMOS::Write(uint8_t addr, uint8_t value) | ||
{ | ||
IO::Out8(PORT_ADDR, addr); | ||
IO::Out8(PORT_DATA, value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef _CMOS_H | ||
#define _CMOS_H | ||
|
||
#include <stdint.h> | ||
|
||
namespace Device | ||
{ | ||
|
||
class CMOS | ||
{ | ||
public: | ||
static uint8_t Read(uint8_t addr); | ||
|
||
static void Write(uint8_t addr, uint8_t value); | ||
}; | ||
|
||
} // namespace Device | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
#include "cpu.h" | ||
#include "keyboard.h" | ||
#include "pic.h" | ||
#include "cmos.h" | ||
|
||
namespace Device | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ namespace Device | |
{ | ||
private: | ||
char scancode_map[128]; | ||
|
||
public: | ||
void Initialize(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <stddef.h> | ||
#include <stdlib.h> | ||
#include "icxxabi.h" | ||
|
||
extern "C" void __cxa_pure_virtual() | ||
{ | ||
// Do nothing or print an error message. | ||
} | ||
|
||
atexitFuncEntry_t __atexitFuncs[ATEXIT_FUNC_MAX]; | ||
uarch_t __atexitFuncCount = 0; | ||
|
||
void *__dso_handle = 0; | ||
|
||
int __cxa_atexit(void (*f)(void *), void *objptr, void *dso){ | ||
if(__atexitFuncCount >= ATEXIT_FUNC_MAX){ | ||
return -1; | ||
} | ||
__atexitFuncs[__atexitFuncCount].destructorFunc = f; | ||
__atexitFuncs[__atexitFuncCount].objPtr = objptr; | ||
__atexitFuncs[__atexitFuncCount].dsoHandle = dso; | ||
__atexitFuncCount++; | ||
return 0; | ||
} | ||
|
||
void __cxa_finalize(void *f){ | ||
signed i = __atexitFuncCount; | ||
if(!f){ | ||
while(i--){ | ||
if(__atexitFuncs[i].destructorFunc){ | ||
(*__atexitFuncs[i].destructorFunc)(__atexitFuncs[i].objPtr); | ||
} | ||
} | ||
return; | ||
} | ||
|
||
for(; i >= 0; i--){ | ||
if(__atexitFuncs[i].destructorFunc == f){ | ||
(*__atexitFuncs[i].destructorFunc)(__atexitFuncs[i].objPtr); | ||
__atexitFuncs[i].destructorFunc = 0; | ||
} | ||
} | ||
} | ||
|
||
void *operator new(size_t size) | ||
{ | ||
return malloc(size); | ||
} | ||
|
||
void *operator new[](size_t size) | ||
{ | ||
return malloc(size); | ||
} | ||
|
||
void operator delete(void *p) | ||
{ | ||
free(p); | ||
} | ||
|
||
void operator delete[](void *p) | ||
{ | ||
free(p); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef _ICXXABI_H | ||
#define _ICXXABI_H | ||
#define ATEXIT_FUNC_MAX 128 | ||
|
||
extern "C" | ||
{ | ||
|
||
typedef unsigned uarch_t; | ||
|
||
struct atexitFuncEntry_t | ||
{ | ||
void (*destructorFunc)(void *); | ||
void *objPtr; | ||
void *dsoHandle; | ||
}; | ||
|
||
extern void *__dso_handle; | ||
|
||
int __cxa_atexit(void (*f)(void *), void *objptr, void *dso); | ||
void __cxa_finalize(void *f); | ||
|
||
void __cxa_pure_virtual(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters