Compare commits

..

3 Commits

12 changed files with 29 additions and 53 deletions

View File

@ -5,7 +5,6 @@
#include "dev/dev.h"
#include "dev/ps2kbdev.h"
#include "dev/serialdev.h"
#include "dev/fbdev.h"
#include "hshtb.h"
DevTable DEVTABLE;
@ -16,5 +15,4 @@ void dev_init(void) {
ps2kbdev_init();
serialdev_init();
fbdev_init();
}

View File

@ -1,35 +0,0 @@
#include <stdint.h>
#include <stddef.h>
#include "dev/fbdev.h"
#include "dev/dev.h"
#include "sysdefs/dev.h"
#include "spinlock/spinlock.h"
#include "util/util.h"
#include "bootinfo/bootinfo.h"
#include "std/string.h"
#include "errors.h"
#include "hshtb.h"
int32_t fbdev_getinfo(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
(void)dev; (void)pid;
if (len != sizeof(FbDevGetInfo)) {
return E_INVALIDARGUMENT;
}
FbDevGetInfo info = {
.w = BOOT_INFO.fb->width,
.h = BOOT_INFO.fb->height,
.margin = 20,
.fontw = 8,
.fonth = 16,
};
memcpy(buffer, &info, sizeof(info));
return E_OK;
}
void fbdev_init(void) {
Dev *fbdev;
HSHTB_ALLOC(DEVTABLE.devs, ident, "fbdev", fbdev);
fbdev->fns[DEV_FBDEV_GETINFO] = &fbdev_getinfo;
}

View File

@ -1,6 +0,0 @@
#ifndef DEV_FBDEV_H_
#define DEV_FBDEV_H_
void fbdev_init(void);
#endif // DEV_FBDEV_H_

View File

@ -78,4 +78,5 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
[SYS_IPC_MBUSDTTCH] = &sys_ipc_mbusdttch,
[SYS_TERM_WRITE] = &sys_term_write,
[SYS_TERM_GETSIZES] = &sys_term_getsizes,
};

View File

@ -1,6 +1,7 @@
#include <stdint.h>
#include <stddef.h>
#include "syscall/syscall.h"
#include "bootinfo/bootinfo.h"
#include "kprintf.h"
#include "errors.h"
@ -16,3 +17,17 @@ int32_t SYSCALL2(sys_term_write, buffer1, len1) {
return E_OK;
}
int32_t SYSCALL2(sys_term_getsizes, w1, h1) {
uint16_t *w = (uint16_t *)w1;
uint16_t *h = (uint16_t *)h1;
if (w == NULL || h == NULL) {
return E_INVALIDARGUMENT;
}
*w = (uint16_t)(BOOT_INFO.fb->width / 16);
*h = (uint16_t)(BOOT_INFO.fb->height / 16);
return E_OK;
}

View File

@ -6,5 +6,6 @@
#include "syscall/syscall.h"
int32_t SYSCALL2(sys_term_write, buffer1, len1);
int32_t SYSCALL2(sys_term_getsizes, w1, h1);
#endif // SYSCALL_TERM_H_

View File

@ -9,8 +9,6 @@
#define DEV_SERIALDEV_RECVB 2
#define DEV_SERIALDEV_RECVREADY 3
#define DEV_FBDEV_GETINFO 0
#define DEV_STOREDEV_READ 0
#define DEV_STOREDEV_WRITE 1
#define DEV_STOREDEV_SECCOUNT 2
@ -32,12 +30,6 @@ typedef struct {
typedef uint64_t Dev_t;
typedef struct {
uint16_t w, h;
uint16_t margin;
uint8_t fontw, fonth;
} FbDevGetInfo;
typedef struct {
bool present;
char name[0x100];

View File

@ -46,5 +46,6 @@
#define SYS_IPC_MBUSATTCH 44
#define SYS_IPC_MBUSDTTCH 45
#define SYS_TERM_WRITE 46
#define SYS_TERM_GETSIZES 47
#endif // SHARE_HDRS_SYSCALL_H_

View File

@ -186,3 +186,7 @@ int32_t ipc_mbusdttch(char *name) {
int32_t term_write(char *buffer, size_t len) {
return syscall(SYS_TERM_WRITE, (uint64_t)buffer, (uint64_t)len, 0, 0, 0, 0);
}
int32_t term_getsizes(uint16_t *w, uint16_t *h) {
return syscall(SYS_TERM_GETSIZES, (uint64_t)w, (uint64_t)h, 0, 0, 0, 0);
}

View File

@ -55,5 +55,6 @@ int32_t ipc_mbusconsume(char *name, uint8_t *const buffer);
int32_t ipc_mbusattch(char *name);
int32_t ipc_mbusdttch(char *name);
int32_t term_write(char *buffer, size_t len);
int32_t term_getsizes(uint16_t *w, uint16_t *h);
#endif // ULIB_SYSTEM_SYSTEM_H_

View File

@ -195,7 +195,7 @@ bool interp_runstring(char *string, InterpResult **res, bool interactive) {
char *line = string_tokenizealloc_linecontinue(string, "\n");
while (line != NULL) {
if (CONFIG.logcmds) {
uprintf("+%s\n", line);
uprintf("+"ANSIQ_SETFG_YELLOW"%s"ANSIQ_GR_RESET"\n", line);
}
bool skip;

View File

@ -78,11 +78,15 @@ done:
}
void do_mode_interactive(void) {
uint16_t w, h;
term_getsizes(&w, &h);
uprintf("TERMINAL: %ux%u\n", (uint32_t)w, (uint32_t)h);
char linebuf[LINEBUF_MAX];
size_t cursor;
for(;;) {
begin:
uprintf("tb# ");
uprintf("["ANSIQ_SETFG_RGB(0, 163, 255)"TB"ANSIQ_GR_RESET"]# ");
cursor = 0;
string_memset(linebuf, 0, LINEBUF_MAX);