#include #include #include #include #include #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) { struct fbcon_priv *priv = dev->dev_priv; priv->tty_ops->tty_clear(dev, x, y, width, height); } static void tty_putc(struct device *dev, int c, int xpos, int ypos, tty_attrib_t attrib) { struct fbcon_priv *priv = dev->dev_priv; priv->tty_ops->tty_putc(dev, c, xpos, ypos, attrib); } static void tty_set_cursor(struct device *dev, enum tty_cursor cur) { struct fbcon_priv *priv = dev->dev_priv; priv->tty_ops->tty_set_cursor(dev, cur); } static void tty_move_cursor(struct device *dev, int x, int y) { struct fbcon_priv *priv = dev->dev_priv; priv->tty_ops->tty_move_cursor(dev, x, y); } static void tty_scroll(struct device *dev, enum tty_scroll_dir dir, int lines) { struct fbcon_priv *priv = dev->dev_priv; priv->tty_ops->tty_scroll(dev, dir, lines); } static struct tty_driver_ops tty_ops = { .tty_clear = tty_clear, .tty_putc = tty_putc, .tty_set_cursor = tty_set_cursor, .tty_move_cursor = tty_move_cursor, .tty_scroll = tty_scroll, }; static kern_status_t online(struct kext *self) { fbcon_driver = tty_driver_create(self, "tty"); if (!fbcon_driver) { return KERN_NO_MEMORY; } fbcon_driver->tty_ops = &tty_ops; tty_driver_register(fbcon_driver); console_register(&tty_console); return KERN_OK; } kern_status_t start_console_on_framebuffer(struct device *fb) { struct framebuffer_varinfo fb_mode; framebuffer_get_varinfo(fb, &fb_mode); struct device *tty = tty_device_create(); kern_status_t status; if (fb_mode.fb_flags & FB_MODE_VGATEXT) { status = init_vgacon_console(tty, fb); } else { status = init_fbcon_console(tty, fb); } if (status != KERN_OK) { /* TODO destroy tty device */ return status; } if (!tty0) { tty0 = tty; } return status; } DEFINE_KEXT("net.doorstuck.socks.fbcon", online, NULL, KEXT_NO_DEPENDENCIES);