91 lines
1.8 KiB
C
91 lines
1.8 KiB
C
#include "flanterm.h"
|
|
#include "flanterm_backends/fb.h"
|
|
#include "spinlock/spinlock.h"
|
|
#include "bootinfo/bootinfo.h"
|
|
#include "term.h"
|
|
#include "putchar.h"
|
|
#include "fm-t-437.f16.h"
|
|
|
|
Term TERM;
|
|
|
|
static uint32_t ansi_colours[8] = {
|
|
0xFFFFFBF0,
|
|
0xFFE64C4C,
|
|
0xFF4CAF50,
|
|
0xFFCC9900,
|
|
0xFF337AB7,
|
|
0xFF9B59B6,
|
|
0xFF0097A7,
|
|
0xFF555555
|
|
};
|
|
|
|
static uint32_t ansi_bright_colours[8] = {
|
|
0xFFBFB9AA,
|
|
0xFFFF6B6B,
|
|
0xFF66BB6A,
|
|
0xFFFFC107,
|
|
0xFF42A5F5,
|
|
0xFFBA68C8,
|
|
0xFF26C6DA,
|
|
0xFF000000
|
|
};
|
|
|
|
// defaults
|
|
static uint32_t default_bg = 0xFFFFFBF0;
|
|
static uint32_t default_fg = 0xFF222222;
|
|
static uint32_t default_bg_bright = 0xFFFFFBF0;
|
|
static uint32_t default_fg_bright = 0xFF000000;
|
|
|
|
void term_doinit(void *addr) {
|
|
TERM.ftctx = flanterm_fb_init(
|
|
NULL, // malloc
|
|
NULL, // free
|
|
addr, // fb addr
|
|
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, // canvas
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
/* ansi_colours, // ansi colors */
|
|
/* ansi_bright_colours, // ansi bright colors */
|
|
/* &default_bg, // default bg */
|
|
/* &default_fg, // default fg */
|
|
/* &default_fg_bright, // default bg bright */
|
|
/* &default_bg_bright, // default fg bright */
|
|
FM_T_437_F16,
|
|
8,
|
|
16,
|
|
0,
|
|
0,
|
|
0,
|
|
20
|
|
);
|
|
}
|
|
|
|
void term_init(void *addr) {
|
|
term_doinit(addr);
|
|
spinlock_init(&TERM.spinlock);
|
|
}
|
|
|
|
void term_write_unsafe(const char *s, size_t len) {
|
|
flanterm_write(TERM.ftctx, s, len);
|
|
}
|
|
|
|
#if PUTCHAR_ == PUTCHAR_FB
|
|
// For printf library
|
|
void putchar_(char c) {
|
|
term_write_unsafe(&c, 1);
|
|
}
|
|
#endif
|