--- /dev/null
+/*
+ * ------------------------------------------------------------------------
+ * File Name: vga.c
+ * Author: Zhao Yanbai
+ * 2026-08-10 09:01:44 Monday CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+
+#include "vga.h"
+
+static uint16_t *vga_vram_vaddr = (uint16_t *)pa2va(0xB8000);
+
+// VGA VC backend
+
+// static int vga_write(const char *buf, size_t size) {
+// return 0;
+// }
+
+// static int vga_get_size(int *width, int *height) {
+// *width = VGA_WIDTH;
+// *height = VGA_HEIGHT;
+// return 0;
+// }
+
+static int vga_init(vc_t *vc) {
+ vc->cols = VGA_WIDTH;
+ vc->rows = VGA_HEIGHT;
+ return 0;
+}
+
+static int vga_switch(vc_t *vc) {
+
+ memcpy(vc->vram, vga_vram_vaddr, vc->vram_size);
+
+ return 0;
+}
+
+static int vga_set_vram_addr(vc_t *vc) {
+
+ vc->vram_addr = vga_vram_vaddr;
+
+ return 0;
+}
+
+static int vga_save_screen(vc_t *vc) {
+
+ memcpy(vc->vram, vga_vram_vaddr, vc->vram_size);
+
+ return 0;
+}
+
+static int vga_clear(vc_t *vc) {
+ // memset(vc->vram, 0, vc->vram_size);
+ for (int i = 0; i < vc->vram_size; i++) {
+ vc->vram[i] = 0 | ;
+ }
+ return 0;
+}
+
+static uint8_t vga_build_attr(vc_t *vc, uint8_t bg_color, uint8_t fg_color, bool blink, bool highlight) {
+ uint8_t bgc = bg_color;
+ uint8_t fgc = fg_color;
+ return (bgc << 4) | fgc | (blink ? 0b1000 : 0) | (highlight ? 0b10000 : 0);
+}
+
+static vc_backend_t vga_backend = {
+ .init = vga_init,
+ // .write = vga_write,
+ // .get_size = vga_get_size,
+ .switch = vga_switch,
+ .set_vram_addr = vga_set_vram_addr,
+ .save_screen = vga_save_screen,
+};
--- /dev/null
+/*
+ * ------------------------------------------------------------------------
+ * File Name: vga.h
+ * Author: Zhao Yanbai
+ * 2026-08-10 09:02:59 Monday CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+
+#pragma once
+
+
+
+const int VGA_WIDTH = 80;
+const int VGA_HEIGHT = 25;
\ No newline at end of file
--- /dev/null
+/*
+ * ------------------------------------------------------------------------
+ * File Name: vt.c
+ * Author: Zhao Yanbai
+ * 2026-08-09 18:38:52 Sunday CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+
+#include "vt.h"
+
+
+static vc_t vcs[VC_COUNT];
+static vc_t *fg_vc = &vcs[0];
+
+bool vc_is_fg(vc_t *vc) {
+ return vc == fg_vc;
+}
+
+// // VT
+// static vt_t vt = {
+// .vcs = {{0},},
+// .fg_vc = &vt.vcs[0],
+// };
+
+
+
+// VT CONSOLE: 仅桥接console用
+int vt_console_write(const char *buf, size_t size) {
+ //找到前台vt调用其write
+ return 0;
+}
+
+int vt_console_setup(console_t *console) {
+ return 0;
+}
+
+
+static console_t vt_console = {
+ .name = "VT",
+ .write = vt_console_write,
+ .setup = vt_console_setup,
+};
+
+
+// INIT VT
+
+void init_vt() {
+ vc_backend_t *backend = &vga_backend;
+
+ for (int i=0; i<VC_COUNT; i++) {
+ memset(vcs+i, 0, sizeof(vc_t));
+ vc_t *vc = vcs+i;
+
+ backend->init(vc);
+
+
+ vc->id = i;
+ vc->backend = backend;
+
+ vc->vram_size = VGA_WIDTH * VGA_HEIGHT * 2;
+ vc->vram = kmalloc(PAGE_UP(vc->vram_size), 0);
+
+ memset(vc->vram, 0, vc->vram_size);
+
+
+ // int width = 0;
+ // int height = 0;
+ // assert(backend->get_size != NULL);
+ // backend->get_size(&width, &height);
+
+ // assert(width > 0);
+ // assert(height > 0);
+
+ // vc->cols = width;
+ // vc->rows = height;
+ // vc->x = 0;
+ // vc->y = 0;
+ // vc->fg_color = 0;
+ // vc->bg_color = 0;
+ // vc->vram = NULL;
+ }
+
+ vt.fg_vc = &vt.vcs[0];
+
+
+ register_console(&vt_console);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * ------------------------------------------------------------------------
+ * File Name: vt.h
+ * Author: Zhao Yanbai
+ * 2026-08-09 18:39:06 Sunday CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+
+#pragma once
+
+#include <console.h>
+
+typedef struct vc vc_t;
+typedef struct vt vt_t;
+typedef struct vc_backend_t vc_backend_t;
+
+
+#define VC_COUNT 4
+
+
+enum {
+ VT_BLACK = 0,
+ VT_BLUE = 1,
+ VT_GREEN = 2,
+ VT_CYAN = 3,
+ VT_RED = 4,
+ VT_PURPLE = 5,
+ VT_YELLOW = 6,
+ VT_WHITE = 7,
+};
+
+// typedef uint8_t vt_color_t;
+
+struct vc_backend_t {
+ int (*init)(vc_t *vc);
+ // int (*write)(const char *buf, size_t size);
+ int (*switch)(vc_t *vc);
+ int (*set_vram_addr)(vc_t *vc);
+ int (*save_screen)(vc_t *vc);
+ int (*clear)(vc_t *vc);
+ uint8_t (*build_attr)(vc_t *vc, uint8_t bg_color, uint8_t fg_color, bool blink, bool highlight);
+
+};
+
+struct vc {
+ int id;
+
+ int x;
+ int y;
+
+ int cols;
+ int rows;
+
+ // vt_color_t fg_color;
+ // vt_color_t bg_color;
+
+ vc_backend_t *backend;
+
+ uint16_t *vram_addr;
+ uint16_t *vram;
+ size_t vram_size;
+
+ size_t bytes_per_row;
+};
+
+
+
+
+// struct vt {
+// vc_t vcs[VC_COUNT];
+// vc_t *fg_vc;
+// };
+
+bool vc_is_fg(vc_t *vc);
\ No newline at end of file
set_printk(_printk);
+ void init_vt();
+ init_vt();
+
init_buffer();
void init_mount();