aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/syscall/actions/sys_read.c
blob: 02960f628110c6d8ab8fa5f7933d679ff7026eba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdint.h>
#include <kernel/lib/stdio.h>
#include <kernel/input/input.h>
#include <kernel/lib/lib.h>
#include <kernel/lib/string.h>
#include <kernel/io/io.h>

uint32_t sys_read(char *buf)
{
    keyboard_clear_buffer();
    keyboard_char_buffer = 0;
    while (keyboard_char_buffer != '\n') {
        getch();
    }
    memcpy(buf, keyboard_buffer, strlen(keyboard_buffer));
    return strlen(buf);
}

uint32_t sys_readc(char *ch)
{
    char buf = getch();
    ch = &buf;
    serial_put(*ch);
    return (uint32_t) ch;
}