summaryrefslogtreecommitdiff
path: root/kernel/src/devices/keyboard.c
diff options
context:
space:
mode:
authorAleksa Vuckovic <aleksav013@gmail.com>2022-08-07 16:39:28 +0200
committerAleksa Vuckovic <aleksav013@gmail.com>2022-08-07 16:43:26 +0200
commit71396c5cd460890c52e348687e6e7c864e2dfeed (patch)
tree72e7dd114cea46c5209dba2e0c2ed9ffeb7f55b5 /kernel/src/devices/keyboard.c
parent50aaae893611af890a6855158ad0a3e32c7b2c43 (diff)
types.h; libk and heap begining
Diffstat (limited to 'kernel/src/devices/keyboard.c')
-rw-r--r--kernel/src/devices/keyboard.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/kernel/src/devices/keyboard.c b/kernel/src/devices/keyboard.c
index d4b06b9..f873a29 100644
--- a/kernel/src/devices/keyboard.c
+++ b/kernel/src/devices/keyboard.c
@@ -1,11 +1,11 @@
-#include <stdint.h>
-#include <stdbool.h>
+#include <types.h>
#include <pic.h>
#include <io.h>
#include <graphics.h>
#include <debug.h>
#include <keymap.h>
+#include <libk/string.h>
#define KEYBOARD_DATA_PORT 0x60
#define KEYBOARD_STATUS_PORT 0x64
@@ -14,29 +14,6 @@ static uint32_t x;
static uint32_t y;
bool is_pressed[128];
-uint32_t strlen(const char *s);
-
-uint32_t stoi(const char *s)
-{
- static uint32_t num;
- uint32_t s_len = strlen(s);
-
- for (int i = s_len - 1; i >= 0; i--) {
- num += s[i] - '0';
- }
-
- return num;
-}
-
-void itos(uint32_t num, char** s)
-{
- uint32_t i;
- for (i = 0; num; num/=10, i++) {
- *s[i] = num%10 - '0';
- }
- *s[i] = '\0';
-}
-
void print_char(char c)
{
@@ -59,11 +36,18 @@ void print_char(char c)
void print_string(char* s)
{
- for (uint32_t i = 0; i < strlen(s); i++) {
+ for (size_t i = 0; i < strlen(s); i++) {
print_char(s[i]);
}
}
+void print_int(uint64_t num)
+{
+ char a[100];
+ itos(num, a);
+ print_string(a);
+}
+
void keyboard_handler(void)
{
uint8_t status = inb(KEYBOARD_STATUS_PORT);