83 lines
1.8 KiB
C
83 lines
1.8 KiB
C
#ifndef BOOTLOADER_CONSOLE_H
|
|
#define BOOTLOADER_CONSOLE_H 1
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <sys/types.h>
|
|
#include <stdarg.h>
|
|
|
|
//---
|
|
// macros
|
|
//---
|
|
|
|
/* internal terminal hardcoded information */
|
|
#define TERM_BUFFER_NB_FRAME (2)
|
|
|
|
//---
|
|
// Types
|
|
//---
|
|
|
|
/* define console structure */
|
|
struct console
|
|
{
|
|
/* windows information */
|
|
struct {
|
|
unsigned short ws_col;
|
|
unsigned short ws_row;
|
|
unsigned short ws_xpixel;
|
|
unsigned short ws_ypixel;
|
|
unsigned short ft_xpixel;
|
|
unsigned short ft_ypixel;
|
|
} winsize;
|
|
|
|
/* cursor information */
|
|
struct {
|
|
unsigned short x;
|
|
unsigned short y;
|
|
} cursor;
|
|
|
|
/* buffer information */
|
|
struct {
|
|
uint8_t *data;
|
|
off_t cursor;
|
|
size_t size;
|
|
} buffer;
|
|
|
|
/* private information */
|
|
struct {
|
|
uint32_t watermark;
|
|
struct {
|
|
int fg;
|
|
int bg;
|
|
} color;
|
|
} _private;
|
|
};
|
|
|
|
//---
|
|
// Public API
|
|
//---
|
|
|
|
/* console_open() : open console */
|
|
extern int console_open(struct console *console);
|
|
|
|
/* console_write() : printf-like write primitive (support line discipline) */
|
|
extern int console_write(struct console *console, char const *format, ...);
|
|
|
|
/* console_vwrite() : printf wrapper for the terminal device with va_list */
|
|
extern int console_vwrite(struct console *console, const char *f, va_list ap);
|
|
|
|
/* console_close() : close console */
|
|
extern int console_close(struct console *console);
|
|
|
|
//---
|
|
// Low-level API
|
|
//---
|
|
|
|
/* console_buffer_insert() : insert string anywhere in the output buffer */
|
|
extern int console_buffer_insert(struct console *console, char *b, size_t nb);
|
|
|
|
/* console_buffer_write() : display the buffer on screen */
|
|
extern int console_buffer_display(struct console *console);
|
|
|
|
#endif /* BOOTLOADER_CONSOLE_H */
|