Reimplement the terminal user access via separate syscalls
This commit is contained in:
@ -3,7 +3,6 @@
|
|||||||
#include "spinlock/spinlock.h"
|
#include "spinlock/spinlock.h"
|
||||||
#include "std/string.h"
|
#include "std/string.h"
|
||||||
#include "dev/dev.h"
|
#include "dev/dev.h"
|
||||||
#include "dev/termdev.h"
|
|
||||||
#include "dev/ps2kbdev.h"
|
#include "dev/ps2kbdev.h"
|
||||||
#include "dev/serialdev.h"
|
#include "dev/serialdev.h"
|
||||||
#include "dev/fbdev.h"
|
#include "dev/fbdev.h"
|
||||||
@ -15,7 +14,6 @@ void dev_init(void) {
|
|||||||
memset(&DEVTABLE, 0, sizeof(DEVTABLE));
|
memset(&DEVTABLE, 0, sizeof(DEVTABLE));
|
||||||
spinlock_init(&DEVTABLE.spinlock);
|
spinlock_init(&DEVTABLE.spinlock);
|
||||||
|
|
||||||
termdev_init();
|
|
||||||
ps2kbdev_init();
|
ps2kbdev_init();
|
||||||
serialdev_init();
|
serialdev_init();
|
||||||
fbdev_init();
|
fbdev_init();
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include "dev/termdev.h"
|
|
||||||
#include "dev/dev.h"
|
|
||||||
#include "util/util.h"
|
|
||||||
#include "sysdefs/dev.h"
|
|
||||||
#include "kprintf.h"
|
|
||||||
#include "hshtb.h"
|
|
||||||
#include "errors.h"
|
|
||||||
|
|
||||||
int32_t termdev_putch(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
|
|
||||||
(void)dev; (void)pid;
|
|
||||||
kprintf("%.*s", (int)len, (char *)buffer);
|
|
||||||
return E_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void termdev_init(void) {
|
|
||||||
Dev *termdev = NULL;
|
|
||||||
HSHTB_ALLOC(DEVTABLE.devs, ident, "termdev", termdev);
|
|
||||||
termdev->fns[DEV_TERMDEV_PUTCH] = &termdev_putch;
|
|
||||||
spinlock_init(&termdev->spinlock);
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
#ifndef DEV_TERMDEV_H_
|
|
||||||
#define DEV_TERMDEV_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include "dev.h"
|
|
||||||
|
|
||||||
void termdev_init(void);
|
|
||||||
|
|
||||||
#endif // DEV_TERMDEV_H_
|
|
||||||
@ -11,6 +11,7 @@
|
|||||||
#include "syscall/dev.h"
|
#include "syscall/dev.h"
|
||||||
#include "syscall/time.h"
|
#include "syscall/time.h"
|
||||||
#include "syscall/ipcmbus.h"
|
#include "syscall/ipcmbus.h"
|
||||||
|
#include "syscall/term.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "kprintf.h"
|
#include "kprintf.h"
|
||||||
|
|
||||||
@ -75,4 +76,6 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
|
|||||||
[SYS_IPC_MBUSCONSUME] = &sys_ipc_mbusconsume,
|
[SYS_IPC_MBUSCONSUME] = &sys_ipc_mbusconsume,
|
||||||
[SYS_IPC_MBUSATTCH] = &sys_ipc_mbusattch,
|
[SYS_IPC_MBUSATTCH] = &sys_ipc_mbusattch,
|
||||||
[SYS_IPC_MBUSDTTCH] = &sys_ipc_mbusdttch,
|
[SYS_IPC_MBUSDTTCH] = &sys_ipc_mbusdttch,
|
||||||
|
|
||||||
|
[SYS_TERM_WRITE] = &sys_term_write,
|
||||||
};
|
};
|
||||||
|
|||||||
18
kernel/syscall/term.c
Normal file
18
kernel/syscall/term.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "syscall/syscall.h"
|
||||||
|
#include "kprintf.h"
|
||||||
|
#include "errors.h"
|
||||||
|
|
||||||
|
int32_t SYSCALL2(sys_term_write, buffer1, len1) {
|
||||||
|
const char *buffer = (const char *)buffer1;
|
||||||
|
size_t len = len1;
|
||||||
|
|
||||||
|
if (buffer == NULL) {
|
||||||
|
return E_INVALIDARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
kprintf("%.*s", (int)len, buffer);
|
||||||
|
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
10
kernel/syscall/term.h
Normal file
10
kernel/syscall/term.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef SYSCALL_TERM_H_
|
||||||
|
#define SYSCALL_TERM_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "syscall/syscall.h"
|
||||||
|
|
||||||
|
int32_t SYSCALL2(sys_term_write, buffer1, len1);
|
||||||
|
|
||||||
|
#endif // SYSCALL_TERM_H_
|
||||||
@ -4,8 +4,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#define DEV_TERMDEV_PUTCH 0
|
|
||||||
|
|
||||||
#define DEV_SERIALDEV_SENDB 0
|
#define DEV_SERIALDEV_SENDB 0
|
||||||
#define DEV_SERIALDEV_SENDREADY 1
|
#define DEV_SERIALDEV_SENDREADY 1
|
||||||
#define DEV_SERIALDEV_RECVB 2
|
#define DEV_SERIALDEV_RECVB 2
|
||||||
|
|||||||
@ -45,5 +45,6 @@
|
|||||||
#define SYS_IPC_MBUSCONSUME 43
|
#define SYS_IPC_MBUSCONSUME 43
|
||||||
#define SYS_IPC_MBUSATTCH 44
|
#define SYS_IPC_MBUSATTCH 44
|
||||||
#define SYS_IPC_MBUSDTTCH 45
|
#define SYS_IPC_MBUSDTTCH 45
|
||||||
|
#define SYS_TERM_WRITE 46
|
||||||
|
|
||||||
#endif // SHARE_HDRS_SYSCALL_H_
|
#endif // SHARE_HDRS_SYSCALL_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user