drivers: usart: added empty files for the usart.

Added various standard files for the usart driver core. The USART driver
core is going to be responsible for all generic USART operations and
calling the correct chip driver when needed or requested. In other
words, is a thin abstraction layer for USART drivers.

Signed-off-by: Michel Megens <dev@michelmegens.net>
irq: cleaned up some of the IRQ core code.

The IRQ core had some bad functions which would easily lead to errors.
Removed those functions and made the work for users easier by requiring
only a call to irq_request to install a new hardware interrupt handler.

Signed-off-by: Michel Megens <dev@michelmegens.net>
irq: handle: added an implementation to irq_handle

irq_handle is the base of the portable IRQ subsystem. This function gets
called by the IRQ chip and is responsible for calling the correct
handler, hidden somewhere else in the system.

Signed-off-by: Michel Megens <dev@michelmegens.net>
irq: handle: implemented hardware irq handles.

Added an implementation for hardware IRQ's. When a hardware IRQ is
triggered, the chip handler is called first. This handler is usually
irq_handle from kernel/irq/handle.c. This handle will then check if the
IRQ is enabled and valid. If all is good it will determine if its a SOFT
IRQ or HARD IRQ. Hard IRQs are handled instantly, in IRQ context, while
soft IRQs are handled at the next schedule call right before a context
switch in process context.

An IRQ can also have a thread associated with it, which can be woken up
when the IRQ has been handled by the driver. The driver should return
IRQ_WAKE_OWNER to do so.

Signed-off-by: Michel Megens <dev@michelmegens.net>
irq: handle: removed a handle for slow soft IRQs.

The software (threaded) IRQs are handled (read: requested to be handled)
in the hard IRQ handle. In otherwords, there is no need for this
function to exist, therefore I cut it out and removed it.

Signed-off-by: Michel Megens <dev@michelmegens.net>
atomic: added atomic types and API funcs.

Added the types:

	* atomic_t;
	* atomic64_t;

The atomic_t type is an integer type with the length `signed int'. The
atomic64_t type is defined as an `int64_t' type and is for that reason
ALWAYS 64 bits long. Usage of the latter should be reduced for data
space reasons only.

The currently implemented atomic API functions:

	* atomic_inc & atomic64_inc
	* atomic_get & atomic64_get

The get functions return their respective types mentioned above.

Signed-off-by: Michel Megens <dev@michelmegens.net>
avr: atomic: reimplemented the atomic operations

Reimplemented most atomic operations so they rely on the most basic
version of themselves. For example, atomic_inc is basically an
atomic_add with 1.

New functions implemented:

	* atomic_add
	* atomic_sub
	* atomic_dec

Functions which have been rewritten:

	* atomic_inc

Signed-off-by: Michel Megens <dev@michelmegens.net>
time: added timer and clocksource structures.

The timer structure is the frontend structure for a timer. It defines
how often it fires, and what to do when it fires. You can compare this
structure to the pointers on the clock. Behind the clock there's an
engine which defines how fast these pointers are being moved. It is
basically the driver of the clock. In ETA/OS there is a specific
structure to define this mechanism: the clocksource.

Signed-off-by: Michel Megens <dev@michelmegens.net>
timer: source: added a basic clock source.

Implmented the basics of the clock source data structure. The clock
source data structure has:

	* a name
	* a way to turn it on
	* a way to turn it off
	* a list of all timers registered for that specific source.

Signed-off-by: Michel Megens <dev@michelmegens.net>
irq: threaded: added an init for threaded IRQs

Threaded IRQs can now also be initialized by irq_request (after the
scheduler has seen birth, ofcourse) by passing the flag
IRQ_THREADED_MASK to the flags argument (together with other flags,
ofcourse).

Signed-off-by: Michel Megens <dev@michelmegens.net>
usart: core: implemented the core usart structure.

Implemented the core data structure for the USART device driver. The
USART device driver is located at drivers/usart/usart-core.c. A platform
specific driver is then using that driver to implement the hardware in
drivers/usart/usart-<platform-name>.c

The USART data structure contains:

	* a lock (mutex)
	* device structure (embedded, no pointer)
	* read fpointer
	* write fpointer
	* timeout for reads and writes

Signed-off-by: Michel Megens <dev@michelmegens.net>
Merge branch 'master' into time

Signed-off-by: Michel Megens <dev@michelmegens.net>
time: timer: added basic timer API

Added a basic API for timers. Creating (i.e. starting) and stopping
timers. Timers are driven by a clocksource and 1 clock source can drive
multiple timers.

Timers are listed on the clocksource in a sorted linked list. Timers are
listed with increasing tick intervals so if you have the timers with the
following ticks:

timer 1 -> tick every 200ms
timer 2 -> tick every 100ms
timer 3 -> tick every 300ms

Then the timers will be listed on the source as:

timer 2 - timer 1 - timer 3

Signed-off-by: Michel Megens <dev@michelmegens.net>
usr: tests: added a test for kernl/time/*

Added a time test to test the generic timer API. It currently tests the
insertion and deletion of timers.

Signed-off-by: Michel Megens <dev@michelmegens.net>
time: timer: added a clocksource processor.

The clocksources processor is the engine behind the timers. It updates
the ticks on the timers, and if expired, calls the timer handle if one
is present.

Signed-off-by: Michel Megens <dev@michelmegens.net>
avr: timer: added the AVR system clock source.

The AVR system clock source is going to run the main systems which need
timing for AVR based systems. Virtual timers, scheduler run queue's are
some examples which will be using this source. It is basically the feed
for the system tick.

Signed-off-by: Michel Megens <dev@michelmegens.net>
timer: tick: added systick IRQ

The systick IRQ is responsible for updating the clocksource's tick from
the timer interrupt. The only responsibility it has is updating the `tc'
field in the clocksource data structure.

Signed-off-by: Michel Megens <dev@michelmegens.net>
avr: timer: implemented the avr sys-clk init.

The AVR system clock is run of the AVR core timer 0, which is an 8 bit
HR timer. The timer is configured to interrupt on overflow, which occurs
at each time the timer hits 125 or 250 (depending on the CPU frequency). The
timer only works for CPU's running on either 8MHz or 16Mhz:

 8Mhz/64/125 = 1000Hz
16Mhz/64/250 = 1000Hz

Signed-off-by: Michel Megens <dev@michelmegens.net>
Merge branch 'master' into irq

* Unit tests in usr/tests
* Bunch of minor fixes

Signed-off-by: Michel Megens <dev@michelmegens.net>

Conflicts:
	arch/avr/include/asm/iom328.h
	kernel/irq/irqchip.c
link: irq: fixed a linking error.

The interrupt vectors are defined from PROGMEM address 0x0 - 0xXXXX.
There was some linking error which placed garbage at the first ~30-ish
bytes of the program memory. Up until now, this wasn't a problem,
however as soon as interrupts come in play it caused a crash because the
right IRQ vector couldn't be found.

Signed-off-by: Michel Megens <dev@michelmegens.net>