95 lines
1.8 KiB
C
95 lines
1.8 KiB
C
#include <socks/tty.h>
|
|
#include "u_vga16.h"
|
|
#include "fbcon.h"
|
|
|
|
#define CELL_WIDTH 8
|
|
#define CELL_HEIGHT 16
|
|
|
|
static void fbcon_init(struct device *dev)
|
|
{
|
|
|
|
}
|
|
|
|
static void fbcon_deinit(struct device *dev)
|
|
{
|
|
|
|
}
|
|
|
|
static void fbcon_clear(struct device *dev, int x, int y, int width, int height)
|
|
{
|
|
|
|
}
|
|
|
|
static void fbcon_putc(struct device *dev, int c, int xpos, int ypos, tty_attrib_t attrib)
|
|
{
|
|
|
|
}
|
|
|
|
static void fbcon_set_cursor(struct device *dev, enum tty_cursor cur)
|
|
{
|
|
|
|
}
|
|
|
|
static void fbcon_move_cursor(struct device *dev, int x, int y)
|
|
{
|
|
|
|
}
|
|
|
|
static void fbcon_scroll(struct device *dev, enum tty_scroll_dir dir, int lines)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
static struct tty_driver_ops fbcon_ops = {
|
|
.tty_init = fbcon_init,
|
|
.tty_deinit = fbcon_deinit,
|
|
.tty_clear = fbcon_clear,
|
|
.tty_putc = fbcon_putc,
|
|
.tty_set_cursor = fbcon_set_cursor,
|
|
.tty_move_cursor = fbcon_move_cursor,
|
|
.tty_scroll = fbcon_scroll,
|
|
};
|
|
|
|
kern_status_t init_fbcon_console(struct device *tty, struct device *fb)
|
|
{
|
|
struct char_device *cdev = CHAR_DEVICE(tty);
|
|
struct framebuffer_varinfo fb_mode;
|
|
struct framebuffer_fixedinfo fixedinfo;
|
|
struct tty_device *ttydev = cdev->c_tty;
|
|
|
|
struct fbcon_priv *priv = kmalloc(sizeof *priv, VM_NORMAL);
|
|
if (!priv) {
|
|
return KERN_NO_MEMORY;
|
|
}
|
|
|
|
kern_status_t status = framebuffer_get_varinfo(fb, &fb_mode);
|
|
|
|
if (status != KERN_OK) {
|
|
kfree(priv);
|
|
return status;
|
|
}
|
|
|
|
status = framebuffer_get_fixedinfo(fb, &fixedinfo);
|
|
|
|
if (status != KERN_OK) {
|
|
kfree(priv);
|
|
return status;
|
|
}
|
|
|
|
ttydev->tty_xcells = fb_mode.fb_xres / CELL_WIDTH;
|
|
ttydev->tty_ycells = fb_mode.fb_yres / CELL_HEIGHT;
|
|
ttydev->tty_xcur = 0;
|
|
ttydev->tty_ycur = 0;
|
|
|
|
priv->fbdev = fb;
|
|
priv->fb_pitch = fb_mode.fb_stride;
|
|
priv->fb_pixels = vm_phys_to_virt(fixedinfo.fb_baseptr);
|
|
priv->tty_ops = &fbcon_ops;
|
|
tty->dev_priv = priv;
|
|
|
|
memset(priv->fb_pixels, 0x00, fb_mode.fb_yres * fb_mode.fb_stride);
|
|
|
|
return KERN_OK;
|
|
}
|