summaryrefslogtreecommitdiff
path: root/kernel/src/devices
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/devices')
-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);