void check_kernel(unsigned long addr, unsigned long magic) {
init_serial();
- init_ttys();
+ // init_ttys();
printk("setup gdt\n");
setup_gdt();
#include <syscall.h>
#include <system.h>
#include <tty.h>
+#include <vt.h>
void reboot();
void poweroff();
// printd("[%02x]", scan_code);
- if (scan_code == 0x3B) { // F1
- tty_switch(default_tty);
- } else if (scan_code == 0x3C) { // F2
- tty_switch(monitor_tty);
- } else if (scan_code == 0x3D) { // F3
- tty_switch(debug_tty);
- }
+ // if (scan_code == 0x3B) { // F1
+ // // tty_switch(default_tty);
+ // vt_switch(0);
+ // } else if (scan_code == 0x3C) { // F2
+ // // tty_switch(monitor_tty);
+ // vt_switch(1);
+ // } else if (scan_code == 0x3D) { // F3
+ // // tty_switch(debug_tty);
+ // vt_switch(2);
+ // }
- if (scan_code == 0x43) { // F9
- void ata_test(uint64_t nr);
- ata_test(0);
- }
- if (scan_code == 0x44) { // F10
- void ata_send_read_identify_cmd(int dev);
- ata_send_read_identify_cmd(0);
+ switch (scan_code) {
+ case 0x3B: // F1
+ vt_switch(0);
+ break;
+ case 0x3C: // F2
+ vt_switch(1);
+ break;
+ case 0x3D: // F3
+ vt_switch(2);
+ break;
+ default:
+ break;
}
- if (scan_code == 0x57) // F11
- {
- asm("cli;");
- while (1)
- ;
- }
+ // if (scan_code == 0x43) { // F9
+ // void ata_test(uint64_t nr);
+ // ata_test(0);
+ // }
+ // if (scan_code == 0x44) { // F10
+ // void ata_send_read_identify_cmd(int dev);
+ // ata_send_read_identify_cmd(0);
+ // }
- if (scan_code == 0x58) { // F12
- tty_switch_to_next();
- }
+ // if (scan_code == 0x57) // F11
+ // {
+ // asm("cli;");
+ // while (1)
+ // ;
+ // }
+
+ // if (scan_code == 0x58) { // F12
+ // tty_switch_to_next();
+ // }
// ide_status();
}
const uint32_t baud_rate = 115200;
+void serial_putc(char c) {
+ while ((inb(SERIAL_PORT + 5) & 0x20) == 0) {
+ }
+ outb(c, SERIAL_PORT);
+}
+
+void serial_old_write(const char* buf, size_t size) {
+ // return 0;
+ for (size_t i = 0; i < size; i++) {
+ serial_putc(buf[i]);
+ }
+}
-int serial_write(const char *buf, size_t size) {
+int serial_write(const char* buf, size_t size) {
+ for (size_t i = 0; i < size; i++) {
+ serial_putc(buf[i]);
+ }
return 0;
}
-int serial_setup(console_t *console) {
+int serial_setup(console_t* console) {
assert(console != NULL);
uint32_t port = SERIAL_PORT;
void init_serial() {
register_console(&serial_console);
}
-
-void serial_putc(char c) {
- while ((inb(SERIAL_PORT + 5) & 0x20) == 0) {
- }
- outb(c, SERIAL_PORT);
-}
-
-void serial_old_write(const char* buf, size_t size) {
- // return 0;
- for (size_t i = 0; i < size; i++) {
- serial_putc(buf[i]);
- }
-}
* ------------------------------------------------------------------------
*/
-#include "vga.h"
+#include "vt.h"
+#include <io.h>
+#include <irq.h>
-static uint16_t *vga_vram_vaddr = (uint16_t *)pa2va(0xB8000);
+static const paddr_t vga_vram_base_paddr = 0xB8000;
+static uint16_t* vga_vram_base_vaddr = (uint16_t*)pa2va(vga_vram_base_paddr);
+static const size_t vga_cols = 80;
+static const size_t vga_rows = 25;
+static const size_t vga_vram_size = vga_cols * vga_rows;
+static const size_t vga_vram_byte_size = vga_vram_size * sizeof(uint16_t);
+static const size_t TAB_SPACE = 4;
-// VGA VC backend
+#define VGA_FG_HIGHLIGHT 0b1000
+#define VGA_BG_BLINK 0b1000
-// static int vga_write(const char *buf, size_t size) {
-// return 0;
-// }
+#define VGA_BLACK 0b0000
+#define VGA_BLUE 0b0001
+#define VGA_GREEN 0b0010
+#define VGA_CYAN 0b0011
+#define VGA_RED 0b0100
+#define VGA_PURPLE 0b0101
+#define VGA_YELLOW 0b0110
+#define VGA_WHITE 0b0111
-// static int vga_get_size(int *width, int *height) {
-// *width = VGA_WIDTH;
-// *height = VGA_HEIGHT;
-// return 0;
-// }
+uint8_t vga_make_attr(uint8_t fg, uint8_t bg, bool fg_highlight, bool bg_blink) {
+ assert((fg & 0x7) == fg);
+ assert((bg & 0x7) == bg);
-static int vga_init(vc_t *vc) {
- vc->cols = VGA_WIDTH;
- vc->rows = VGA_HEIGHT;
- return 0;
+ // 目前VT_COLOR和VGA_COLOR是一一对应的
+ // 所以直接处理
+
+ uint8_t attr = 0;
+ attr |= bg << 4;
+ attr |= fg << 0;
+
+ attr |= (bg_blink ? VGA_BG_BLINK : 0) << 4;
+ attr |= (fg_highlight ? VGA_FG_HIGHLIGHT : 0) << 0;
+
+ return attr;
+}
+
+static uint16_t* _vga_get_vram_vaddr(vc_t* vc) {
+ unsigned long addr = (unsigned long)vga_vram_base_vaddr;
+ addr += (vc->id * PAGE_UP(vga_vram_byte_size));
+ return (uint16_t*)addr;
}
-static int vga_switch(vc_t *vc) {
+static void _vga_clear(vc_t* vc, int x, int y, size_t size) {
+ assert(x >= 0);
+ assert(y >= 0);
+ assert(x < vc->cols);
+ assert(y < vc->rows);
- memcpy(vc->vram, vga_vram_vaddr, vc->vram_size);
+ const size_t begin_offset = y * vc->cols + x;
+ const size_t end_offset = begin_offset + size;
+ assert(begin_offset <= vga_vram_size);
+ assert(end_offset <= vga_vram_size);
- return 0;
+ uint16_t* vram_vaddr = vc->vram_vaddr;
+
+ for (size_t i = begin_offset; i < end_offset; i++) {
+ vram_vaddr[i] = (vc->default_color << 8) | 0;
+ }
}
-static int vga_set_vram_addr(vc_t *vc) {
+void vga_clear(vc_t* vc) {
+ _vga_clear(vc, 0, 0, vga_vram_size);
+}
+
+void vga_init_vc(vc_t* vc) {
+ assert(vc != NULL);
+ assert(vc->id >= 0);
+
+ vc->cols = vga_cols;
+ vc->rows = vga_rows;
+ vc->x = 0;
+ vc->y = 0;
+ vc->vram_vaddr = _vga_get_vram_vaddr(vc);
- vc->vram_addr = vga_vram_vaddr;
+ printk("vga_init_vc: id=%d, vram_vaddr=%08x\n", vc->id, vc->vram_vaddr);
- return 0;
+ vga_clear(vc);
}
-static int vga_save_screen(vc_t *vc) {
+void vga_clear_line(vc_t* vc, int y) {
+ assert(y >= 0);
+ assert(y < vc->rows);
+ _vga_clear(vc, 0, y, vc->cols);
+}
+
+void vga_scroll_up(vc_t* vc) {
+ // assert(vc->y == vc->rows);
+ assert(vc->x < vc->cols);
+ assert(vc->x >= 0);
+
+ uint16_t* vram_vaddr = vc->vram_vaddr;
+
+ for (int i = 0; i < ((vc->rows - 1) * vc->cols); i++) {
+ vram_vaddr[i] = vram_vaddr[i + vc->cols];
+ }
- memcpy(vc->vram, vga_vram_vaddr, vc->vram_size);
+ _vga_clear(vc, 0, (vc->rows - 1), vc->cols);
- return 0;
+ vc->y = vc->rows - 1;
}
-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 | ;
+off_t vga_get_offset(vc_t* vc) {
+ return vc->y * vc->cols + vc->x;
+}
+
+#define VGA_CRTC_ADDR 0x3D4
+#define VGA_CRTC_DATA 0x3D5
+#define VGA_CRTC_CURSOR_START 0x0A
+#define VGA_CRTC_CURSOR_END 0x0B
+#define VGA_CRTC_START_ADDR_H 0x0C
+#define VGA_CRTC_START_ADDR_L 0x0D
+#define VGA_CRTC_CURSOR_H 0x0E
+#define VGA_CRTC_CURSOR_L 0x0F
+
+#define VGA_CURSOR_DISABLE (1 << 5)
+
+void _vga_cursor(bool show) {
+ unsigned long eflags;
+ irq_save(eflags);
+
+ outb(VGA_CRTC_CURSOR_START, VGA_CRTC_ADDR);
+ uint8_t start = inb(VGA_CRTC_DATA);
+
+ if (show) {
+ start &= ~VGA_CURSOR_DISABLE;
+ } else {
+ start |= VGA_CURSOR_DISABLE;
}
- return 0;
+ outb(VGA_CRTC_CURSOR_START, VGA_CRTC_ADDR);
+ outb(start, VGA_CRTC_DATA);
+
+ irq_restore(eflags);
}
-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);
+void vga_set_cursor_style(bool block) {
+ unsigned long eflags;
+ irq_save(eflags);
+
+ outb(VGA_CRTC_CURSOR_START, VGA_CRTC_ADDR);
+ uint8_t start = inb(VGA_CRTC_DATA);
+
+ start &= 0xF0;
+ if (block) {
+ start |= 0x00;
+ } else {
+ start |= 0x0E;
+ }
+
+ outb(VGA_CRTC_CURSOR_START, VGA_CRTC_ADDR);
+ outb(start, VGA_CRTC_DATA);
+
+ outb(VGA_CRTC_CURSOR_END, VGA_CRTC_ADDR);
+ uint8_t end = inb(VGA_CRTC_DATA);
+
+ end &= 0xF0;
+ if (block) {
+ end |= 0x0F;
+ } else {
+ end |= 0x0F;
+ }
+
+ outb(VGA_CRTC_CURSOR_END, VGA_CRTC_ADDR);
+ outb(end, VGA_CRTC_DATA);
+
+ irq_restore(eflags);
}
-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,
-};
+void vga_set_cursor(vc_t* vc) {
+ assert(vc->x < vc->cols);
+ assert(vc->y < vc->rows);
+ assert(vc->x >= 0);
+ assert(vc->y >= 0);
+
+ if (!vc_is_view_vc(vc)) {
+ return;
+ }
+
+ if (!vc->show_cursor) {
+ return;
+ }
+
+ off_t offset = vga_get_offset(vc);
+ // offset += 1;
+ assert(offset < vga_vram_size);
+
+ offset += (vc->vram_vaddr - vga_vram_base_vaddr);
+
+ unsigned long eflags;
+ irq_save(eflags);
+
+ outb(VGA_CRTC_CURSOR_H, VGA_CRTC_ADDR);
+ outb((offset >> 8) & 0xFF, VGA_CRTC_DATA);
+ outb(VGA_CRTC_CURSOR_L, VGA_CRTC_ADDR);
+ outb(offset & 0xFF, VGA_CRTC_DATA);
+
+ irq_restore(eflags);
+}
+
+void _vga_set_start_addr(vc_t* vc) {
+ uint16_t* vram_vaddr = vc->vram_vaddr;
+
+ off_t offset = vram_vaddr - vga_vram_base_vaddr;
+
+ unsigned long eflags;
+ irq_save(eflags);
+
+ outb(VGA_CRTC_START_ADDR_H, VGA_CRTC_ADDR);
+ outb((offset >> 8) & 0xFF, VGA_CRTC_DATA);
+ outb(VGA_CRTC_START_ADDR_L, VGA_CRTC_ADDR);
+ outb(offset & 0xFF, VGA_CRTC_DATA);
+
+ irq_restore(eflags);
+}
+
+void vga_switch(vc_t* vc) {
+ _vga_set_start_addr(vc);
+
+ if (vc->show_cursor) {
+ _vga_cursor(true);
+ vga_set_cursor(vc);
+ } else {
+ _vga_cursor(false);
+ }
+}
+
+void vga_set_xy(vc_t* vc, off_t offset) {
+ // 最后一个字符写完是可能自动移动下一个的,所以是可能超过vga_vram_size的
+ // 所以这里用的是 <= 而不是 <
+ assert(offset <= vga_vram_size);
+ vc->x = offset % vc->cols;
+ vc->y = offset / vc->cols;
+
+ if (offset >= vga_vram_size) {
+ vga_scroll_up(vc);
+ }
+
+ vga_set_cursor(vc);
+}
+
+void vga_color_putc(vc_t* vc, uint8_t c, uint8_t color) {
+ assert(vc != NULL);
+ // assert(0);
+
+ bool display = false;
+ off_t offset = vga_get_offset(vc);
+
+ switch (c) {
+ case '\r':
+ offset = vc->y * vc->cols;
+ break;
+ case '\n':
+ offset = (vc->y + 1) * vc->cols;
+ break;
+ case '\t':
+ offset += TAB_SPACE;
+ offset &= ~(TAB_SPACE - 1);
+ break;
+ case '\b':
+ if (vc->x == 0 && vc->y == 0) {
+ break;
+ } else {
+ assert(vc->x < vc->cols);
+ assert(vc->y < vc->rows);
+ assert(offset < vga_vram_size);
+ offset -= 1;
+ }
+ break;
+ default:
+ display = true;
+ break;
+ }
+
+ vga_set_xy(vc, offset);
+
+ offset = vga_get_offset(vc);
+
+ if (display) {
+ assert(offset <= vga_vram_size);
+ uint16_t* vram_vaddr = vc->vram_vaddr;
+ vram_vaddr[offset] = (color << 8) | c;
+
+ offset += 1;
+ }
+
+ vga_set_xy(vc, offset);
+}
+
+void vga_putc(vc_t* vc, uint8_t c) {
+ vga_color_putc(vc, c, vc->default_color);
+}
+
+void vga_write(vc_t* vc, const char* buf, size_t size) {
+ assert(buf != NULL);
+ for (size_t i = 0; i < size; i++) {
+ vga_putc(vc, buf[i]);
+ }
+}
+
+void vga_ap_clear() {
+ vc_t* vc = vt_get_ap_vc();
+ assert(vc != NULL);
+ vga_clear(vc);
+}
+
+void vga_ap_write(int x, int y, char* buf, size_t size) {
+ assert(buf != NULL);
+ vc_t* vc = vt_get_ap_vc();
+ assert(vc != NULL);
+ assert(x >= 0);
+ assert(y >= 0);
+ assert(x < vc->cols);
+ assert(y < vc->rows);
+
+ vc->x = x;
+ vc->y = y;
+
+ for (size_t i = 0; i < size; i++) {
+ vga_color_putc(vc, buf[i], vc->default_color);
+ }
+}
+++ /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
#include "vt.h"
+void vga_init_vc(vc_t* vc);
+void vga_switch(vc_t* vc);
+void vga_write(vc_t* vc, const char* buf, size_t size);
+uint8_t vga_make_attr(uint8_t fg, uint8_t bg, bool fg_highlight, bool bg_blink);
+void vga_set_cursor_style(bool block);
static vc_t vcs[VC_COUNT];
-static vc_t *fg_vc = &vcs[0];
+static vc_t* fg_vc = &vcs[0];
+static vc_t* view_vc = &vcs[0]; // 当前显示的vC,因为AP的存在,当前显示的VC不一定是fg_vc,
+ // fg_vc是前台VC,AP VC不参与这个概念
+static const vc_t* ap_vc = &vcs[VC_ID_FOR_AP_ID];
-bool vc_is_fg(vc_t *vc) {
+bool vc_is_fg_vc(vc_t* vc) {
return vc == fg_vc;
}
-// // VT
-// static vt_t vt = {
-// .vcs = {{0},},
-// .fg_vc = &vt.vcs[0],
-// };
-
-
+bool vc_is_view_vc(vc_t* vc) {
+ return vc == view_vc;
+}
// VT CONSOLE: 仅桥接console用
-int vt_console_write(const char *buf, size_t size) {
- //找到前台vt调用其write
+int vt_console_write(const char* buf, size_t size) {
+ // 找到前台vt调用其write
+ assert(fg_vc != NULL);
+ assert(fg_vc->id < VC_FOR_TTY_COUNT);
+ vga_write(fg_vc, buf, size);
return 0;
}
-int vt_console_setup(console_t *console) {
+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;
+void vt_init_vc(vc_t* vc) {
+ assert(vc != NULL);
- for (int i=0; i<VC_COUNT; i++) {
- memset(vcs+i, 0, sizeof(vc_t));
- vc_t *vc = vcs+i;
+ vga_init_vc(vc);
+}
- backend->init(vc);
-
-
- vc->id = i;
- vc->backend = backend;
+vc_t* vt_get_vc(int id) {
+ assert(id >= 0);
+ assert(id < VC_COUNT);
+ return &vcs[id];
+}
- vc->vram_size = VGA_WIDTH * VGA_HEIGHT * 2;
- vc->vram = kmalloc(PAGE_UP(vc->vram_size), 0);
+vc_t* vt_get_ap_vc() {
+ return &vcs[VC_ID_FOR_AP_ID];
+}
- memset(vc->vram, 0, vc->vram_size);
+void vt_switch(int id) {
+ assert(id >= 0);
+ assert(id < VC_COUNT);
+ view_vc = &vcs[id];
- // int width = 0;
- // int height = 0;
- // assert(backend->get_size != NULL);
- // backend->get_size(&width, &height);
+ if (view_vc != ap_vc) {
+ fg_vc = view_vc;
+ }
- // assert(width > 0);
- // assert(height > 0);
+ vga_switch(view_vc);
+}
+
+uint8_t vt_make_attr(uint8_t fg, uint8_t bg, bool highlight, bool blink) {
+ return vga_make_attr(fg, bg, highlight, blink);
+}
+
+void init_vt() {
+ vga_set_cursor_style(false);
- // vc->cols = width;
- // vc->rows = height;
- // vc->x = 0;
- // vc->y = 0;
- // vc->fg_color = 0;
- // vc->bg_color = 0;
- // vc->vram = NULL;
+ for (int i = 0; i < VC_COUNT; i++) {
+ vc_t* vc = vcs + i;
+
+ vc->id = i;
+
+ if (i == VC_ID_FOR_AP_ID) {
+ vc->default_color = vt_make_attr(VT_WHITE, VT_BLUE, true, false);
+ vc->show_cursor = false;
+ } else {
+ vc->default_color = vt_make_attr(VT_GREEN, VT_BLACK, true, false);
+ vc->show_cursor = true;
+ }
+
+ vt_init_vc(vc);
}
- vt.fg_vc = &vt.vcs[0];
+ const int view_vc_id = 0;
+
+ fg_vc = vcs + view_vc_id;
+ view_vc = fg_vc;
+ vt_switch(view_vc_id);
register_console(&vt_console);
}
\ No newline at end of file
#include <console.h>
-typedef struct vc vc_t;
-typedef struct vt vt_t;
-typedef struct vc_backend_t vc_backend_t;
-
+// 暂不考虑别的类型的VC,直接按VGA来写
-#define VC_COUNT 4
+typedef struct vc vc_t;
+// 前面几个给TTY用的VC,后面跟一个给AP用的VC
+#define VC_FOR_TTY_COUNT 2
+#define VC_ID_FOR_AP_ID (VC_FOR_TTY_COUNT)
+#define VC_COUNT (VC_FOR_TTY_COUNT + 1)
enum {
VT_BLACK = 0,
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 cols;
int rows;
- // vt_color_t fg_color;
- // vt_color_t bg_color;
+ uint8_t default_color;
- vc_backend_t *backend;
+ bool show_cursor;
- uint16_t *vram_addr;
- uint16_t *vram;
- size_t vram_size;
-
- size_t bytes_per_row;
+ uint16_t* vram_vaddr;
};
-
-
-
-// struct vt {
-// vc_t vcs[VC_COUNT];
-// vc_t *fg_vc;
-// };
-
-bool vc_is_fg(vc_t *vc);
\ No newline at end of file
+bool vc_is_fg_vc(vc_t* vc);
+bool vc_is_view_vc(vc_t* vc);
+vc_t* vt_get_vc(int id);
+vc_t* vt_get_ap_vc();
+void vt_switch(int id);
\ No newline at end of file
typedef struct console console_t;
struct console {
- const char *name;
- int (*setup)(console_t *console);
- int (*write)(const char *buf, size_t size);
+ const char* name;
+ int (*setup)(console_t* console);
+ int (*write)(const char* buf, size_t size);
};
-void register_console(console_t *console);
-
-
-
+void register_console(console_t* console);
+int console_write(const char* buf, size_t size);
#define CNSL_QUEUE_SIZE 1024
typedef uint32_t vaddr_t;
typedef int64_t loff_t;
+typedef int32_t off_t;
typedef uint32_t dev_t;
typedef uint32_t umode_t;
#include <tty.h>
#include <wait.h>
-
#define MAX_CONSOLE_CNT 16
-static console_t *console_list[MAX_CONSOLE_CNT] = {NULL};
+static console_t* console_list[MAX_CONSOLE_CNT] = {NULL};
-void register_console(console_t *console) {
+void register_console(console_t* console) {
assert(console != NULL);
assert(console->name != NULL);
assert(console->write != NULL);
- //assert(console->setup != NULL);
-
+ // assert(console->setup != NULL);
- for (int i=0; i<MAX_CONSOLE_CNT; i++) {
+ for (int i = 0; i < MAX_CONSOLE_CNT; i++) {
if (console_list[i] == console) {
return;
}
}
-
- for (int i=0; i<MAX_CONSOLE_CNT; i++) {
+ for (int i = 0; i < MAX_CONSOLE_CNT; i++) {
if (console_list[i] == NULL) {
console_list[i] = console;
- if(console->setup != NULL) {
+ if (console->setup != NULL) {
console->setup(console);
}
printk("console %s registered\n", console->name);
return;
}
+int console_write(const char* buf, size_t size) {
+ assert(buf != NULL);
+ for (int i = 0; i < MAX_CONSOLE_CNT; i++) {
+ if (console_list[i] == NULL) {
+ break;
+ }
+
+ console_list[i]->write(buf, size);
+ }
+ return 0;
+}
+
void vga_putc(unsigned int nr, unsigned char c, const unsigned char color);
cnsl_t cnsl;
#include <irq.h>
#include <system.h>
#include <tty.h>
-
-int vsprintf(char* buf, const char* fmt, va_list args);
+#include <vt.h>
+#include <console.h>
void serial_old_write(const char* buf, size_t size);
-
-extern tty_t* const default_tty;
+int vsprintf(char* buf, const char* fmt, va_list args);
int _printk(const char* fmtstr, va_list args) {
char* pkbuf = kmalloc(1024, 0);
int size = vsprintf(pkbuf, fmtstr, args);
- tty_write(default_tty, pkbuf, (size_t)size);
- serial_old_write(pkbuf, (size_t)size);
+ console_write(pkbuf, size);
kfree(pkbuf);
return 0;
int size = vsprintf(_early_pkbuf, fmtstr, args);
- tty_write(default_tty, _early_pkbuf, (size_t)size);
- serial_old_write(_early_pkbuf, (size_t)size);
+ // vga_write(vt_get_vc(0), _early_pkbuf, (size_t)size);
+
+ // serial_old_write(_early_pkbuf, (size_t)size);
+ console_write(_early_pkbuf, size);
irq_restore(eflags);
return 0;
int size = vsprintf(pdbuf, fmtstr, args);
va_end(args);
- tty_write(debug_tty, pdbuf, (size_t)size);
serial_old_write(pdbuf, (size_t)size);
kfree(pdbuf);
extern tty_t* const monitor_tty;
int ap_print(unsigned int xpos, unsigned int ypos, const char* fmtstr, ...) {
+#if 1
static char plobuf[1024];
va_list args;
va_end(args);
- tty_write_at(monitor_tty, xpos, ypos, plobuf, (size_t)size);
-
+ // tty_write_at(monitor_tty, xpos, ypos, plobuf, (size_t)size);
+ void vga_ap_write(int x, int y, char* buf, size_t size);
+ vga_ap_write(xpos, ypos, plobuf, (size_t)size);
irq_restore(eflags);
+#endif
return 0;
-}
+}
\ No newline at end of file
}
void tty_write(tty_t* tty, const char* buf, size_t size) {
+ return;
assert(0 != tty);
if (0 == buf) {
return;