Integrate flaterm terminal
This commit is contained in:
45
kernel/term/term.c
Normal file
45
kernel/term/term.c
Normal file
@ -0,0 +1,45 @@
|
||||
#include "flanterm.h"
|
||||
#include "flanterm_backends/fb.h"
|
||||
#include "spinlock/spinlock.h"
|
||||
#include "bootinfo/bootinfo.h"
|
||||
#include "term.h"
|
||||
#include "putchar.h"
|
||||
|
||||
Term TERM;
|
||||
|
||||
void term_init(void) {
|
||||
spinlock_init(&TERM.spinlock);
|
||||
TERM.ftctx = flanterm_fb_init(
|
||||
NULL, NULL,
|
||||
BOOT_INFO.fb->address,
|
||||
BOOT_INFO.fb->width,
|
||||
BOOT_INFO.fb->height,
|
||||
BOOT_INFO.fb->pitch,
|
||||
BOOT_INFO.fb->red_mask_size,
|
||||
BOOT_INFO.fb->red_mask_shift,
|
||||
BOOT_INFO.fb->green_mask_size,
|
||||
BOOT_INFO.fb->green_mask_shift,
|
||||
BOOT_INFO.fb->blue_mask_size,
|
||||
BOOT_INFO.fb->blue_mask_shift,
|
||||
NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, 0, 0, 1,
|
||||
0, 0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
void term_write(const char *s, size_t len) {
|
||||
spinlock_acquire(&TERM.spinlock);
|
||||
flanterm_write(TERM.ftctx, s, len);
|
||||
spinlock_release(&TERM.spinlock);
|
||||
}
|
||||
|
||||
#if PUTCHAR_ == PUTCHAR_FB
|
||||
// For printf library
|
||||
void putchar_(char c) {
|
||||
term_write(&c, 1);
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user