kexts: fbcon: implement VGA text mode tty driver

This commit is contained in:
2023-06-11 09:24:22 +01:00
parent abe4af093e
commit d10c89544c
4 changed files with 54 additions and 34 deletions

View File

@@ -150,7 +150,9 @@ static void vgacon_clear(struct device *dev, int x, int y, int width, int height
static void vgacon_putc(struct device *dev, int c, int xpos, int ypos, tty_attrib_t attrib)
{
struct tty_device *ttydev = TTY_DEVICE(dev);
struct fbcon_priv *priv = dev->dev_priv;
priv->fb_cells[(ypos * ttydev->tty_xcells) + xpos] = VGA_CHAR(c, attrib);
}
static void vgacon_set_cursor(struct device *dev, enum tty_cursor cur)
@@ -160,7 +162,7 @@ static void vgacon_set_cursor(struct device *dev, enum tty_cursor cur)
static void vgacon_move_cursor(struct device *dev, int x, int y)
{
move_vga_cursor(x, y);
}
static void vgacon_scroll(struct device *dev, enum tty_scroll_dir dir, int lines)
@@ -186,7 +188,7 @@ kern_status_t init_vgacon_console(struct device *tty, struct device *fb)
struct framebuffer_fixedinfo fixedinfo;
struct tty_device *ttydev = cdev->c_tty;
struct fbcon_priv *priv = kmalloc(sizeof *priv, VM_NORMAL);
struct fbcon_priv *priv = kzalloc(sizeof *priv, VM_NORMAL);
if (!priv) {
return KERN_NO_MEMORY;
}
@@ -207,12 +209,13 @@ kern_status_t init_vgacon_console(struct device *tty, struct device *fb)
ttydev->tty_xcells = fb_mode.fb_xcells;
ttydev->tty_ycells = fb_mode.fb_ycells;
ttydev->tty_xcur = 0;
ttydev->tty_ycur = 0;
ttydev->tty_xcur = g_console_cursor_xpos;
ttydev->tty_ycur = g_console_cursor_ypos;
ttydev->tty_curattrib = DEFAULT_ATTRIB;
priv->fbdev = fb;
priv->fb_pitch = fb_mode.fb_stride;
priv->fb_pixels = vm_phys_to_virt(fixedinfo.fb_baseptr);
priv->fb_cells = vm_phys_to_virt(fixedinfo.fb_baseptr);
priv->tty_ops = &vgacon_ops;
tty->dev_priv = priv;