46 lines
955 B
C
46 lines
955 B
C
#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
|