console: merge console_cell.c into console.c

We currently have too much layers in the console subsystem. This reduces
performance and produces ugly hacks like our "*_clear_region" function. We
now merge both files so we can directly access the buffer-structure.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: allow an eloop to be an event source

This allows to add one eloop object into another eloop. This is useful if
we want to run a single event source isolated (for instance VT on exit).

The internal epoll-descriptor allows polling so this is a fairly
straightforward implementation.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
conf: add configuration subsystem

The conf-subsystem is used throughout the whole source and provides a
global static read-only configuration. The configuration is read on
startup from the command-line and filesystem and then provided to the
other subsystems.

This is no database, that is, the data is not written to a file on
shutdown!

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vt: fix callback enum type

We should use the enum type instead of plain "int" to be more verbose
here.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: remove ev_eloop_get_fd()

This function was never used so remove it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: remove fd from epoll-set on HUP

If a handler does not correctly remove itself on HUP, the epoll-loop will
never sleep again because the fd will always be notified as HUP.
Therefore, remove the fd from the epoll-set directly on HUP. This doesn't
change application behavior so it is safe here.

This also allows other subsystems to ignore HUP/ERR events if they are not
fatal. The FD won't be readded but that may not bother.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: several fixes

Fix parameter validation, fix log_* statements, fix indentation and print
messages on HUP/ERR.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: add ev_eloop_run() function

ev_eloop_run() runs the eloop for a given fixed time. If the dispatcher
returns and the timeout isn't reached, then the dispatcher is called
again.
This also adds the *_exit() function which allows to exit the main-loop
and can be called from anywhere (including the callbacks).

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
conf: remove unneeded global initialization

Global variables are initialized to 0 automatically. So remove the
initialization.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
conf: fix --help handling

Handle --help same way as -h.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
conf: add --switchvt

--switchvt enables kmscon to automatically switch to the new VT that was
opened by kmscon. If this is the current VT, then this has obviously no
effect.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: add debug messages

Add two debug messages to track eloop behavior.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: correctly set ->exit

When exiting a child eloop we should forward the exit to the parent. Also,
we should reset ->exit on ev_eloop_run() otherwise we cannot run multiple
times.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
build: add conf.c to build

conf.c was recently added so add it to the build-script now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Fix time calculations

eloop.c and log.c use struct timeval to calculate time-diffs but
incorrectly use "-" instead of "+" as the value is already negative.
They also use unsigned integers so fix both occurences.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vt: fix log messages

Add new improved log messages to the VT subsystem.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
main: add proper main application

This is not finished and only implements the basic VT handling +
application initialization.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>