Makefile: fix readlink on Mac OS X

Change-Id: Iae8a871a406cf274a1993b8f01b0e51b31896f1a
Makefile: strip `wc` results

Change-Id: Ib41230d7c3333ce27c864fe5abd2cb0b0d7ad5ca
Makefile: use toolchain cpp for reprocessing

Mac OS X's clang system toolchain doesn't like the config for some reason

Change-Id: I399928cda1c7afa17cf0121d658824d67cee899c
lib: pass const arguments into string functions

Many of the strings functions in the C standard library take const
arguments.  Update the definitions and declarations to reflect this.

Change-Id: Idda6e56cbbee65b95e096e258737d87f2752bc82
lib: add memchr, memcmp, strchr, strcmp

These C standard library string functions were not implemented.  Add
them, along with tests.

We cannot escape, strcmp is necessary, even if less safe than strncmp.

Change-Id: I41e44d716d59a0c0ba2959caacb091c9356bbb45
build: place .rodata in its own section

I'm not sure why this wasn't done in the first place.  The compiled
binaries are identical, but by explicitly placing .rodata in its own
section, objdumped ELF files are easier to read, since .rodata is not
merged with .text.

Change-Id: Icb29113eb6a1d42c96a2f2239eb3be5b65793fed
kernel: column limit

Ensure that prototypes fit in 80 character columns.

Change-Id: Ifb2f4003da63c822cf8855bc10d2cf11073ed7ff
obj: make name a const char *

Since const strings may be used as an obj name, declare it const.  For
instances where the name is dynamically allocated, the const qualifer
can be cast away in order to free the name.

Change-Id: I3cb29445555932aa01f46986058f53367463aa77
class: instantiate() does not return allocated address

instantiate() allocates a class instance by allocating space for its
container type, and returns a pointer to the struct obj within the
container.  The obj is returned because it is the universally know type
shared between classes.

However, when freeing a class instance, care must be taken.  It is the
*container* that needs to be freed, not the obj returned from
instantiate().  Thus, if you only have the obj, get_container() needs to
be used to find the correct container address for freeing.

Add instantiate() documentation to explain this.

Change-Id: I0e30b68759301928b0b6012b37fda3d72372a6f2
dev: use strcmp() for device driver name comparison

Device driver names may be of artibrary length, but should definitely be
valid strings.  Use strcmp(), rather than stopping at an arbitary limit.

Change-Id: I5b81d47f84fd5612b200418763fb372950372623
stm32f4: RCC registers struct

Like many of the peripherals, provide access to the RCC registers
through a struct interface.  Of course, there is only one set of RCC
registers, but this interface is still convenient.  Provide a function
to get this struct.

Change-Id: I05b08bc4733b827263dc7352540d4c3077a4fa23
stm32f4: add peripheral ids

Introduce "peripheral ids" for STM32F4 peripherals.  These IDs uniquely
identify a hardware peripheral in the STM32F4.  Make use of these IDs by
providing a function to enable RCC peripheral clocks, based on the
peripheral ID.

Change-Id: I730674bfdfde474d67570c33c0a00fa9b2fa9ab4
stm32f4: clock: use raw_mem_* and RCC struct

Access the RCC registers using the RCC struct, and write memory using
the raw_mem_* macros.

Change-Id: I83e8b01b40b76ae7e5b5ec496f0ca77df0e70ce2
stm32f4: spi: properly release semaphore if already initialized

In stm32f4_spi_init(), if the port was already initialized, the function
returned immediately, without releasing the held semaphore.  This would
lead to a deadlock situation if the SPI was used.

Change-Id: I32a93de508e62152547cdb97ae593120375e6a50
stm32f4: spi: check and call init after acquiring semaphore

Avoid an initialization race condition by not checking port->ready until
after the semaphore has been acquired, and no one else can change the
value.

Since acquire() has already been called, it is not necessary to do so in
init() itself.

Additionally, fix a bug whereby init() would be called simply because
port was NULL.

Change-Id: Id0048e7e78c5d4d2e754c7d95921ce3a2182ca1f
lib: import libfdt 1.4.0

Import libfdt from http://git.jdl.com/software/dtc.git commit 65cc4d2.
The library is unchanged, with the exception that fdt.h and libfdt.h
have been moved to include/, and libfdt_env.h has been moved to
arch/include/, and its references have been updated to include from
arch/.

Change-Id: I59cff9ae4934db40d19766e162134b6127845bf2
build: build barebones device tree into OS

For each target, a barebones dts file is added, simply defining
compatible strings.  The dts file for the target is selected by
CONFIG_DEVICE_TREE.

Use dtc to compile the dts, then link it into the .dtb section for
further runtime evaluation.

Change-Id: I970fbfc968556e5210964ddccb0f1fad076042ce
dev: register device drivers from FDT nodes

Allow drivers to register 'compatible string device drivers', which
register their capability to handle a certain compatible string.  Once
those are all registered, walk the entire device tree, finding matching
drivers for each node with a 'compatible' property.  The 'compatible
string device driver' is used to create a standard device driver for
that specific node.  The device driver name is the full FDT path.

Change-Id: I528e7a3bafc8c366edf65234caf7b8aacbe8b71b
dev: add FDT parsing functions

Add additional FDT helper functions, with the prefix fdtparse_.  These
provide additional FDT specific functionality not available from libfdt.

Change-Id: I4012020612bfe965dabf76961cff35cd84e9ba0f
stm32f4: convert i2c driver to FDT

Add device tree entries for each i2c peripheral.  The compatible string
is registered with the device driver system, which automatically creates
device driver entries for each peripherals.  At construction, parse the
FDT node to get the required information about the peripheral.  The
'periph-id' property is used to determine which peripheral clocks to
enable, using the RCC clock enable function.

Remove num field from global i2c struct.  If drivers need it, they can
put it in priv.

Change-Id: I53f3aa1ea8be5a4790a965fea1f57a96ddfe5d8e