kernel: add WARN_ON() and PANIC_ON()

Add macros to output a warning, and in the case of PANIC_ON(), panic the
system.

Currently, the output is very basic, simply printing the assertion that
failed and its location in the OS.

These should be used throughout the kernel to make assertions about
internal state, where an error cannot be returned to the user.

Change-Id: I7c8c11befb01b356bd6b4aa773389c8b6b912b9f
Rename semaphore to mutex

The locks provided by the operating system are mutexes, not counting
semaphores.  While they are technically binary semaphores, use of the
name mutex avoids any confusion over the type of the lock.
Additionally, it frees up the name for a potential future counting
semaphore implementation.

Change-Id: I43f4e3f5212c2879a81d9c5eff3161b5fe860809
kernel: add reentrant mutexes

Implement reentrant mutexes entirely in userspace.  They allow locks to
be acquired multiple times by the same task, so long as they are
released the same number of times.

The locks store the task that has them acquired, allowing that task to
reacquire, and forcing others to perform an actual acquire.

Change-Id: Ic0eb412145e6d739a27e109db81ecdd03eaebbbc
kernel: use reentrant mutexes for collections

Use a reentrant mutex for a collection, to allow addtional actions to be
taken after the lock is acquired.  For example, for calling
collection_add() after collection_iter().

Change-Id: Ibc024a77049badf1698e404c8f9ce6d091084e4b
kernel: cleanup collections API

Perform a basic cleanup of the collections API.  The most significant
public changes are significantly expanded API docs in the collections
header file, new collection_lock() and collection_unlock() functions,
and a rename of get_by_name() to collection_get_by_name() to match the
rest of the collection API conventions.  The collection_get_by_name()
rename, which included a swap of argument order, is the only breaking
change.

Internally, the functions perform many more checks.  Arguments are
checked for NULL values, and functions that should only be called during
iteration check that condition.  collection_get_by_name() makes use of
strcpy() to allow arbitrary length obj names.

Change-Id: I778c085f5b3e39d27c759e32257b2ae1b0934ee9
dev: ADC class

Add an ADC class.  A linker array contains all available ADC drivers and
their compatibility strings.  When getting an ADC object for a GPIO,
look through this list and the device tree for a device and driver
capable of creating the object.

The class itself is based on a GPIO object, and simply provides a raw
data reading method.

Change-Id: Ie6ee2155e355a2bbf88ddebf1f8ee33588a30ec1
shell: add adc shell program

Prints ADC values from multiple specified GPIOs, until the user quits.

Change-Id: Ied49632a8c704f867c82e614677e702d385928ac
dev: fdt: parse gpio list

Add fdtparse_get_gpios() which will parse a list of GPIO cells into an
array of struct fdt_gpio.

Change-Id: I7069fbea785b6bc81eba7a66f4c0d01c5fc18932
stm32f4: Add analog GPIO direction flag

Add a special flag, STM32F4_GPIO_DIRECTION_ANALOG, which can be passed
into GPIO direction() to set a GPIO to analog mode.

Analog mode is used for both analog input and output, so the standard
GPIO input and output direction flags are ignored.

Change-Id: Ie4429141c6e2d271e48453b7537542c0fad1d60d
stm32f4: ADC driver

Standard ADC driver for the STM32F4 series.  Decodes the channel GPIOs
from the FDT, and keeps track of allocated channels.  When a new ADC is
requested from a GPIO, the driver finds a compatible, free channel, and
prepares it for scanning.

The actual read_raw() method actually ignores the sequence setup and
sets the channel to read as the first channel in a one channel sequence.
This one channel is converted and read within the function.

Eventually, DMA should be used to copy converted data, allowing the
entire channel sequence to be converted.

Change-Id: Ifccf751f84126c66e6ab51d4d972a04c14620221
kernel: correct list_add() argument order

In list_add(), the item to add comes first, followed by the list to add
to.  collection_add() got the argument order backwards.

In the collections interface, this manifested itself as
collection_iter() returning the correct value, followed by
collection_next() returning a bad value.  The value was in memory, so it
could be dereferenced, but was not the correct type.

As a result, only the first item in a collection could be retrieved.

Change-Id: I6454fcd07abfaaf2690f413fcad63f3e9f005935
stm32f4: pwm: don't free obj name in dtor

class_deinstantiate() will free the name, since instantiate() will
strdup() the name.  The implementation dtor should not free this.

Change-Id: I2d11cd96a8455b50d730e0a50fdb4a363cd0d2be