From f85eb100f99919a67f0e1927d480934f0b02c01d Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 20 Nov 2011 00:41:15 +0100 Subject: [PATCH] Add console subsystem dummy Add dummy files for the console subsystem. This subsystem will be used to draw a console to a framebuffer. It uses pango and cairo for text-rendering and will provide all required modification functions that the terminal emulation will require. Signed-off-by: David Herrmann --- src/console.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/console.h | 25 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/console.c create mode 100644 src/console.h diff --git a/src/console.c b/src/console.c new file mode 100644 index 0000000..1273bdd --- /dev/null +++ b/src/console.c @@ -0,0 +1,67 @@ +/* + * kmscon - Console Management + * Written 2011 by David Herrmann + */ + +/* + * Console Management + * This provides the console drawing and manipulation functions. It does not + * provide the terminal emulation. It is just an abstraction layer to draw text + * to a framebuffer as used by terminals and consoles. + */ + +/* + * TODO: Avoid using this hack and instead retrieve GL extension + * pointers dynamically on initialization. + */ +#define GL_GLEXT_PROTOTYPES + +#include +#include +#include + +#include +#include + +#include "console.h" + +struct kmscon_console { + size_t ref; +}; + +int kmscon_console_new(struct kmscon_console **out) +{ + struct kmscon_console *con; + + if (!out) + return -EINVAL; + + con = malloc(sizeof(*con)); + if (!con) + return -ENOMEM; + + memset(con, 0, sizeof(*con)); + con->ref = 1; + + *out = con; + return 0; +} + +void kmscon_console_ref(struct kmscon_console *con) +{ + if (!con) + return; + + ++con->ref; +} + +void kmscon_con_unref(struct kmscon_console *con) +{ + if (!con || !con->ref) + return; + + if (--con->ref) + return; + + free(con); +} diff --git a/src/console.h b/src/console.h new file mode 100644 index 0000000..5e06700 --- /dev/null +++ b/src/console.h @@ -0,0 +1,25 @@ +/* + * kmscon - Console Management + * Written 2011 by David Herrmann + */ + +/* + * Console Management + * The console management uses OpenGL, cairo and pango to draw a console to a + * framebuffer. It is independent of the other subsystems and can also be used + * in other applications. + * + * This console does not emulate any terminal at all. This subsystem just + * provides functions to draw a console to a framebuffer and modifying the state + * of it. + */ + +#include + +struct kmscon_console; + +/* console objects */ + +int kmscon_console_new(struct kmscon_console **out); +void kmscon_console_ref(struct kmscon_console *con); +void kmscon_console_unref(struct kmscon_console *con);