(Maybe) better console subsystem

This commit is contained in:
Mark
2020-06-18 16:32:01 +03:00
parent bc36220152
commit dd36f0decf
17 changed files with 475 additions and 102 deletions
+3 -3
View File
@@ -3,9 +3,9 @@
struct multiboot_tag_framebuffer;
extern int vesa_available, vesa_hold;
extern uint32_t vesa_width, vesa_height, vesa_pitch, vesa_bpp;
extern uint64_t vesa_addr;
//extern int vesa_available, vesa_hold;
//extern uint32_t vesa_width, vesa_height, vesa_pitch, vesa_bpp;
//extern uint64_t vesa_addr;
void amd64_vesa_init(struct multiboot_tag_framebuffer *info);
void vesa_put(uint32_t x, uint32_t y, uint32_t v);
+2 -2
View File
@@ -1,8 +1,8 @@
#pragma once
#include "sys/types.h"
struct chrdev;
extern struct chrdev *g_keyboard_tty;
struct console;
extern struct console *g_keyboard_console;
#define INPUT_MOD_CONTROL (1 << 0)
#define INPUT_MOD_SHIFT (1 << 1)
+10 -3
View File
@@ -1,14 +1,19 @@
#pragma once
#include "sys/types.h"
#include "sys/list.h"
struct chrdev;
struct console;
struct console_buffer;
struct tty_data {
// Process group ID of the foreground group (session leader)
pid_t fg_pgid;
// Output device info
void *out_dev;
int (*out_putc) (void *dev, char c);
// Console to which the TTY is attached
struct console *master;
struct console_buffer *buffer;
// List link of TTYs which share the same console
struct list_head list;
};
// From keyboard handlers and stuff
@@ -19,4 +24,6 @@ void tty_data_write(struct chrdev *n, char c);
void tty_puts(struct chrdev *n, const char *s);
void tty_putc(struct chrdev *n, char c);
int tty_create(struct console *con);
void tty_init(void);
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include "sys/types.h"
#include "sys/list.h"
struct chrdev;
struct display;
struct console_buffer;
struct console {
struct display *display;
// Current display
struct chrdev *tty_active;
struct console_buffer *buf_active;
// This console's slaves
struct list_head slaves;
// All consoles
struct list_head list;
uint16_t width_chars, height_chars;
};
// Enslave a TTY to a physical console
void console_attach(struct console *con, struct chrdev *tty);
void console_resize(struct console *con, uint16_t new_width, uint16_t new_height);
void console_putc(struct console *con, struct chrdev *tty, int c);
void console_type(struct console *con, int c);
void console_default_putc(int c);
struct console *console_get_default(void);
void console_init_default(void);
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include "sys/types.h"
#include "sys/list.h"
// Not a text mode
#define DISP_GRAPHIC (1 << 0)
// Has a linear framebuffer
#define DISP_LFB (1 << 1)
struct display {
// Text modes: set character at y, x
void (*setc) (uint16_t y, uint16_t x, uint16_t c);
// If DISP_GRAPHIC and not DISP_LFB
void (*setpixel) (uint32_t x, uint32_t y, uint32_t c);
uint32_t flags;
// If DISP_GRAPHIC
uint32_t width_pixels, height_pixels;
uint32_t bpp, pitch;
// If DISP_LFB
uintptr_t framebuffer;
uint16_t width_chars, height_chars;
// Private data
void *data;
struct list_head list;
};
void display_add(struct display *d);
struct display *display_create(void);
void display_setc(struct display *disp, uint16_t y, uint16_t x, uint16_t ch);
struct display *display_get_default(void);
+4 -2
View File
@@ -14,5 +14,7 @@ struct psf_font {
uint32_t width;
};
void psf_init(uintptr_t addr, uintptr_t pitch, uint16_t *charw, uint16_t *charh);
void psf_draw(uint16_t row, uint16_t col, uint8_t c, uint32_t fg, uint32_t bg);
extern struct psf_font *font;
struct display;
void psf_draw(struct display *disp, uint16_t row, uint16_t col, uint8_t c, uint32_t fg, uint32_t bg);