kexts: fbcon: implement VGA text mode tty driver
This commit is contained in:
@@ -6,25 +6,6 @@
|
||||
#include "fbcon.h"
|
||||
|
||||
static struct tty_driver *fbcon_driver = NULL;
|
||||
static struct device *tty0 = NULL;
|
||||
|
||||
static void tty_console_write(struct console *con, const char *s, unsigned int len)
|
||||
{
|
||||
if (!tty0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static int tty_console_read(struct console *con, char *s, unsigned int len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct console tty_console = {
|
||||
.c_name = "tty0",
|
||||
.c_write = tty_console_write,
|
||||
.c_read = tty_console_read,
|
||||
};
|
||||
|
||||
static void tty_clear(struct device *dev, int x, int y, int width, int height)
|
||||
{
|
||||
@@ -72,9 +53,9 @@ static kern_status_t online(struct kext *self)
|
||||
}
|
||||
|
||||
fbcon_driver->tty_ops = &tty_ops;
|
||||
fbcon_driver->tty_type = TTY_DRIVER_FULL;
|
||||
|
||||
tty_driver_register(fbcon_driver);
|
||||
console_register(&tty_console);
|
||||
|
||||
return KERN_OK;
|
||||
}
|
||||
@@ -98,8 +79,11 @@ kern_status_t start_console_on_framebuffer(struct device *fb)
|
||||
return status;
|
||||
}
|
||||
|
||||
if (!tty0) {
|
||||
tty0 = tty;
|
||||
status = tty_device_register(tty, fbcon_driver, misc_device());
|
||||
|
||||
if (status != KERN_OK) {
|
||||
/* TODO destroy tty device */
|
||||
return status;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user