fdt: move libfdt_env.h to include/

The fdtX_to_cpu() functions in the header are already endian-agnostic,
so putting the header in an arch-specific folder is unnecessary.

Change-Id: Ic60df140fe03b93cf06e5c5ab800fd2e3d1d2ae6
arch: Initial port to ARMv7-A and TI AM335X

Currently, it must be manually loaded into memory.  It does not support
task switching, and thus ends execution with a "Task switching ended"
panic, but it does successfully run to completion.

Includes a barebones device tree source for the AM335X.  Since the Linux
dts is GPL'd, the current plan is to write our own DTS, using the same
bindings as the Linux kernel, to maintain compatibility.

For most atomic operations, use the __atomic_* GCC builtins.  These are
guaranteed to generate atomic accesses with the specified memory model.
For now, the most conservative memory model is selected, ensuring full
data synchronization.

Change-Id: Ie002c31ab4d12435bbaa4a0c6f9734289e4293a1
am335x: add memory map

Provide a memory map with the base addresses of all of the register
banks.

Change-Id: I4815cd62bdb5f6fa6d14a2e80756a85b9d56741f
am335x: add clock initialization

Initialize the AM335X PLLs based on the reference manual
recommendations.  Individual peripheral clock support needs to be added,
as well as correct DDR PLL settings determined.

Change-Id: I3cc0b59dd18389896ee5e46a2796a4ef205fd834
armv7a: add init_chip() function

On the AM335X, it does clock initialization

Change-Id: Id7f17b552d58f84a9a63113a2d86394807590d91
am335x: add initial IRQ and FIQ interrupt handlers

These handlers look up the given the source of the interrupt, and call
the handler out of a table of function pointers.

A standard set of functions is provided to enable, disable, register,
set priority, etc of interrupts, based on the interrupts and
interrupt-parent FDT properties.

The appropriate interrupt controller is looked up in interrupt-parent,
but currently only the primary system interrupt controller is supported.
This is the controller referenced by interrupt-parent in the root node.

Change-Id: I193f30244b8edc5dadea6abb7107b75dacdc3145
build: chip-specific binary rule

Use a new chip Makefile rule 'binary' to build the final binary used for
flashing the board.  For the STM32F4 and LM4F, this is simply the .bin
file.  For the AM335x, this is a MLO file, generated with u-boot's
mkimage tool.

Change-Id: I06f082424aba028eb9223b36fd603bbab20a9926
am335x: basic usart driver

Add a very basic and rudimentary driver for UART0 on the AM335X.  This
should allow basic IO while continuing to port F4OS.

Change-Id: I786a71399d47b49a3e80f82acc369dce25af6d08
armv7a: initialize all priviledged stack pointers, panic exceptions

At startup, set the SP for SVC, IRQ, FIQ, ABR, and UND modes to
configured values.  This way, the SP will already be set up when those
exceptions are taken.

When an abort occurs, branch to a handler, which will currently panic
the system.

In addition, for the AM335x, make more efficient use of the 63K internal
SRAM + 64K of L3 OCMC ram.  Allocate 32K for user heap, 16K for kernel
heap, and 1K of stack space for each priviledged mode, except SVC, which
gets 12K.

Change-Id: I3e6c821352fd0cda97ea8a1224340c3f301e8903
dev: add clocks interface

Add a generic clocks interface for enabling and disabling peripheral
clocks.  This interface take advantage of the clocks property bindings
in the device tree.  This property contains a phandle to the clock
controller, plus controller-defined cell values, generally a clock or
register number.

clocks_enable() and clocks_disable() will look up the referenced clock
controller, and find its driver from a staticly-defined list of clock
drivers, passing control to the compatible driver for actual work to be
done.

An additional parameter setting function can be used to select a source
for a clock or set the clock speed.

TODO: create general static lists, to avoid adding new linker sections
and list implementations ad nauseam.

Change-Id: If8dc3f266a85a93073837a92181daee61d228d38
am335x: add prcm clocks driver

Add a clocks driver for the AM335x PRCM module, which controls clock
gating to modules.  Additionally, the set_param() function can be used
to select clock sources for several module clocks.  It simply assigns
the parameter to the register.

In the device tree source, describe the hierarchal L3 and L4 bus
interconnects.  In the PRCM node, each of its register banks is
described by a subnode.

Change-Id: I4b56d26a89c0819b7ed42e80ea6bd69b3815f414
armv7a: context switching and service calls

Implement context switching for ARMv7-A.  Tasks are run in User Mode.

Support performing reentrant SVC, IRQ, FIQ due to the nature of
save_context and restore_context.  By default, these functions simply
save the necessary state to allow exception handling, including reentrant
exceptions or SVCs.

When coming from user mode, however, save_context will additionally save
the state to the user mode stack.  In restore_context, if returning to
user mode, restore state from the user mode stack, rather than the
exception stack.  This allows the exception to swap out the user mode
stack pointer, and thus switch tasks, which makes this the task "context
switching".  The initial task switch is simply detected as an SVC from
user mode when task switching is not enabled.

Since SVCs are always allowed, they may go several levels deep.  For
example, the systick handler runs in IRQ mode based on timer interrupts.
It calls task_switch(), which will ultimately call an SVC to do the
switch.  Thus the context saving frame looks something like this:

IRQ entry:
    save_context (save user mode context)
    SVC entry (for task switch):
        save_context (save IRQ mode context)
        perform a task switch (change user mode sp)
        restore_context (restore IRQ mode context)
    SVC exit
    restore_context (restore new user mode context)
IRQ exit

Change-Id: Ie662311497ea7690f2471dc697b849b7d7ec88ef
am335x: system tick timer

Enable and use the DMTimer 1ms for use as the system tick timer.
For now, simply the first DMTimer 1ms found in the device tree
will be used as the system timer.

Use the main oscillator as the source, computing the number of counts
necessary for the desired system tick frequency.

Set the load register to count that many ticks up to 1<<32 - 1, then
trigger the overflow interrupt.

In the system tick handler, perform the standard tick routines.

Change-Id: I5dd5988917fdbad9eb859e7672257ccdc3517119
linker_array: add linker arrays

Add "linker array" header file.  This file defines macros that allow
building arrays across compilation units, using the linker.  Entries are
placed in special sections that are placed together by the linker,
allowing them to be treated as arrays.  They are placed in read-only
memory.

This will allow special sections, like .user and .clocks, to be removed
in favor of a general interface.

Change-Id: I0c124cad113eb9fabf8e76119cb895bba9c63b3e
clocks: switch to linker array

Rather than using a special section dedicated to clock drivers, use the
linker array "clocks" for clock entries.

Change-Id: Id8aaaf8a8d5eab7aba0aaeffd3c570e20da7f1a3
shell: convert to linker array

Use the linker array functionality to power the shell app list, rather
than a custom use of the .user section.

Change-Id: I9a167f202bf663f43ecd7798e85fd93135d157dd
tests: convert to linker array

Use the linker array functionality to power the list of tests, rather
than a custom use of the .user section.

Change-Id: I06ef3318456b924c24ce474dbd50c899aa50fe45
build: remove .user section

The linker array system provides a more powerful interface to the sort
of use cases that the .user section was intended for.

Since it has been superseded, remove the .user section.

Change-Id: I264827b780e82e9491f755868e228c68b5209320
kernel: convert initializers to linker arrays

Use the linker array functionality to implement initializer lists,
rather than a custom use of the .initializers section.

Each type of linker array is placed in its own linker array.  The
initializers themselves are converted to structs containing a function
pointer.

Change-Id: Icdf1f53500bc04cb98ef5e6a57abe01dbec5aa98
docs: update for armv7a and am335x support

Now that multiple architectures are supported, break out some of the
README into dedicated files in docs/.

Mention the AM335x, and include a small snippet about booting with MLO.
This should be expanded upon in a more complete chip docs/ file.

Change-Id: I3129eda98b8da4ef2cda207599a994ebbe191af4