Integrate changes from Raspberry Pi team

Due to irregularities in the Embedded Xinu development process such as not
having a standard repository to use, we've had trouble making our (the
Raspberry Pi team's) changes available with a proper development history.
This commit finally just makes our changes available in one changeset based
on the master branch of this repo.

The following summarizes the changes made.

Changes in compile/:

    Build system (general):
        - Added README.compiling.  This documents compiling Embedded Xinu,
          including prerequisites, Makefile variables, and Makefile
          targets.
        - Rewrote compile/Makefile to improve documentation and add various
          fixes.
        - Added automatic header dependency generation.
        - Added ability to easily change platform and other build
          parameters on command line without editing Makefile.  This is
          documented in README.compiling.
        - Made it possibly to staticly link the kernel with libgcc.
        - Added -fwrapv compiler flag.
        - Fixed generation of version information.
        - Added compile/scripts/ directory for miscellaneous useful
          scripts.  However, this currently only contains a script to build
          an ARM cross compiler, and this could be removed if there's a
          better way to help users acquire an appropriate cross compiler.

    Build system (platform-specific):
        - Added README.porting to document the changes in compile/
          necessary to port Embedded Xinu to a new platform.
        - Simplified platformVars by making use of per-architecture
          templates.
        - Made ld.script optional when the architecture default suffices.

    Configuration generator:
        - Rewrote the configuration generator program to use lex and bison
          in a more standard way.  The parser no longer relies on internal
          implementation details of the lexer; instead it uses semantic
          token values (yylval) as documented in various manuals.  This
          fixes a failure to build due to internal changes in recent
          versions of flex and/or bison.
        - Added "%option noyywrap" to the lexer, which makes it unnecessary
          to link with -lfl.
        - Fixed Makefile bug that made parallel builds fail.
        - Fixed undefined exit status.

    Doxygen documentation:
        - Updated Doxyfile for Doxygen 1.7.5.
        - Added main page to Doxygen documentation.
        - Made Doxygen input file list be automatically generated based on
          target platform.  We did this with the assumption that most users
          of Embedded Xinu will only be concerned with one platform, so
          specialized docs (with no cruft from other platforms) will be
          preferred.

    Raspberry Pi-specific:
        - Added Raspberry Pi platform (compile/platforms/arm-rpi/) and ARM
          architecture template (compile/templates/arm/).

Added device/usb/:

    Added a relatively simple USB subsystem, including a USB core driver
    and USB hub driver.  (Note: the USB host controller driver, which is
    platform-specific code needed for USB to actually operate, is not in
    this directory; currently the only implementation is in
    system/platforms/arm-rpi/usb_dwc_hcd.c.)

Added device/uart-pl011/:

    Added the driver for the PL011 UART found on the Raspberry Pi.
    Although the Raspberry Pi has another UART, known as the "Mini UART",
    which is partially 16550-compatible, we found the PL011 to be better
    documented.   Moreover, it is a bad idea to attempt to maintain the
    16550 UART driver such that it continues to work with a UART that is in
    fact not fully 16550-compatible.

Added device/uart/, modified device/uart-ns16550/ and device/uart-x86/:

    Refactored Xinu's UART drivers.  Common functionality shared by all
    UART drivers is now in a separate device/uart/ directory.
    UART-specific directories, such as device/uart-ns16550/, now contain a
    stripped-down set of functions needed to interface with a specific
    UART.  This reduces the size of UART-specific code significantly and
    reduces duplication in shared functionality.

Added device/smsc9512/:

    Added a driver for the Ethernet controller part of the SMSC LAN9512 USB
    2.0 Hub and 10/100 Ethernet Controller, which is found on the Raspberry
    Pi model B.  This is a new Ethernet driver for Xinu, but unlike the
    ones currently implemented, the SMSC LAN9512 is a USB device and
    therefore needs to be communicated with over the USB using the new USB
    subsystem we implemented.  More information can be found in
    device/smsc9512/Doxygroup.c.

Added device/framebuffer_rpi/:

    Added support for graphics, including drawing text and shapes, on the
    Raspberry Pi via a memory-mapped framebuffer.  This is primarily
    Farzeen's work and has been tested using the HDMI output on the
    Raspberry Pi.

Other changes in device/:

    - Improved documentation for various functions.
    - Fixed bugs in handling of error conditions in various drivers.
    - Added Doxygen groupings.

Changes in lib/libxc/:

    Rewrote Xinu's stripped-down C library (libxc) to fix multiple bugs,
    improve the documentation, add a few basic string functions that really
    should be included, and make the code easier to understand.

Changes in test/:

    Fixed various bugs in Xinu's testsuite, including race conditions and
    not testing return values strictly enough, and added various
    improvements such as correctly skipping tests for features not
    supported in the current configuration and more detailed tests for
    formatted printing and scanning.

Changes in system/ (other than in system/platforms/):

    - Improved documentation for various functions and added Doxygen
      groupings.
    - Fixed resource leaks in bfpalloc() error paths.
    - Fixed kill() leaving system in inconsistent state when killing
      sleeping thread.
    - Added udelay() and mdelay() functions, needed by various drivers.
      Note: to simplify porting Embedded Xinu, these functions are
      implemented platform-independently and only rely on clkcount() being
      available.

Added system/platforms/arm-rpi/:

    This new directory contains the majority of the platform-specific code
    for the Raspberry Pi.  This primarily includes functionality equivalent
    to that used on other Embedded Xinu platforms, such as creating
    threads, context switching, interrupt handling, and timer handling.
    However, there are also a few features currently used in the Raspberry
    Pi port that have no equivalent on other platforms, such as:

    - Board power management (bcm2835_power.c)
    - Transferring control to a new kernel (kexec.c; implemented for
      network bootloader)
    - USB host controller driver (usb_dwc_hcd.c)
    - Watchdog timer support (watchdog.c; currently only used for
      xsh_reset() implementation)

Added loader/platforms/arm-rpi/:

    Added startup code for the Raspberry Pi.  Note that this primarily
    deals with ARM-specific details, so this code probably should
    refactored into generic ARM startup code if Embedded Xinu were to be
    ported to another ARM platform.

Added network/tftp/ and network/dhcpc/:

    Added TFTP and DHCP clients for Embedded Xinu.  The C interfaces are:

    - TFTP client:  tftpGet() or tftpGetIntoBuffer()
    - DHCP client:  dhcpClient()

    The TFTP client was written from scratch, while the DHCP client is a
    rewritten version of code included in a previous release of Embedded
    Xinu.

    The current limitations are:

    - The TFTP client does not support putting files, only getting.
    - The DHCP client returns when IP address is determined and does not
      handle rebinding leases.
    - The DHCP client is IPv4-only (of course, Embedded Xinu doesn't
      support IPv6 yet anyway...), and also assumes the link layer protocol
      is Ethernet-compatible.
    - Both the TFTP and DHCP clients are compiled unconditionally when the
      network module is supported.  The build system needs to provide a way
      to easily omit these modules if they are not needed.  (However, if
      you never call the interface functions, the linker will remove the
      compiled code for them.)

    This DHCP and TFTP client functionality was added primarily to support
    having Embedded Xinu act as a network bootloader in the same way that
    the Linksys routers Common Firmware Environment does.  The reason being
    that the Raspberry Pi firmware doesn't have a sophisticated interface
    and just supports booting from the SD card.

Other changes in network/:

    Mostly documentation improvements and bugfixes, such as:

    - Fixed leaking of packet buffer in ipv4Recv() when UDP, TCP, and/or
      "raw" protocols not supported in the build.
    - netDown(), netUp():  Cleaned up and simplified the code.
    - netRecv():  Don't leak packets having unknown ether packet type or
      bad address (VERY bad bug in my opinion; someone could easily freeze
      the network stack by sending bad packets.)

    NOTE:  There is another bug in the network code that I was not able to
    fix, namely that when netDown() kills the netRecv() threads, resources
    allocated by the network stack can be leaked.

Changes in include/:

    New headers:
       - dhcpc.h for DHCP client
       - framebuffer.h for framebuffer driver
       - arm.h for ARM definitions
       - tftp.h for TFTP client
       - kexec.h for prototype of kexec() system call
       - watchdog.h for prototypes of watchdog timer functions

    Changes to existing headers:
       - limits.h:  Correctly defined CHAR_MIN and CHAR_MAX when 'char' is
                    unsigned.
       - kernel.h:  Added kvprintf() prototype
       - ether.h:  Documented Ethernet functions here to avoid repeating
                   docs in each driver.
       - platform.h:  Documented members of `struct platform'
       - Various headers:  Marked parameters 'const' when possible.

Changes in shell/:

    We added several new shell commands, each of which are only available
    when certain features are enabled, and changed several other shell
    commands slightly.

    New commands:
        - 'turtle' (xsh_turtle.c):  This is Farzeen's work to implement a
          turtle graphics program for the Raspberry Pi.  It has a
          dependency on the Raspberry Pi framebuffer driver.

        - 'kexec' (xsh_kexec.c):  This command provides the ability to load
          and execute a new kernel over the UART or network.  The UART
          capability is currently Raspberry-Pi specific as it relies on
          'raspbootcom' running on the other end, while the network
          capability is in theory platform-independent and only relies on
          networking support (with the DHCP and TFTP clients I added) along
          with an implementation of kexec() to actually transfer control to
          the new kernel.  This functionality was primarily added to
          support having Embedded Xinu act as a network bootloader to
          implement a back-end pool (as is set up currently with the MIPS
          routers) without relying on firmware support.

        - 'usbinfo' (xsh_usbinfo.c):  This command is available only when
          the USB subsystem is enabled, and it will print out the current
          state of the USB, including a diagram of attached devices and
          various descriptors.

    Changes to existing commands:
        - 'netup' (xsh_netup.c):  Cleaned up code, and also extended it to
          use DHCP, when available, if an IP address was not specified on
          the command line and was not found in NVRAM.

        - 'memdump' (xsh_memdump.c):  Improved checking of "sane" addresses
          and allowed architectures to override what address are considered
          "sane".  Also simplified the scanning of arguments by using
          sscanf() rather than hard-coding custom scanning.

    Other changes:
        - Made inclusion of 'testsuite' command conditional on whether the
          testsuite is actually included in the build.

Miscellaneous changes:

    - Got rid of all $Id$ SVN keywords, since we aren't using SVN anymore.
    - Got rid of all the "@provides" tags, since Doxygen already knows what
      functions each file contains and there's no need to manually
      duplicate this information.
    - Replaced some calls of strncpy() with strlcpy(), since strncpy() was
      being used incorrectly and the calling code expected behavior like
      strlcpy().

Additional note:  As our (the Raspberry Pi team's) code is based on the
"research" version of Embedded Xinu rather than the "2.01" version that
this repo was based on, some other changes have slipped in as well, for
example the addition of monitors functions, the e2100l platform, and the
wl330ge platform.  We have never tested those two additional platforms
however.  Note that we took out the "scc" platform because apparently Intel
isn't going to make that platform available anymore and it also had some
ugly hooks in platform-independent code that we didn't want to leave
around if no one is using the code.
system/platforms/arm-rpi:  Cleanup

* Define peripherals addresses, IRQ numbers, and memory barriers in a
  centralized location (bcm2835.h).
* Improve various comments.
* Fix style inconsistencies.
* Move memory_barrier() to its own file because its use is not
  restricted to interrupt handling.
Factor out architecture-common code

This commit drastically reduces duplicated code among Embedded Xinu
platforms, especially the various MIPS ports.  Platforms can now refer to
files in the directories "system/arch" or "loader/arch" to use code shared
between multiple Embedded Xinu platforms that all share the same underlying
CPU architecture.

Some ARM code has been factored out the same way, although there is
currently only one supported ARM platform (the Raspberry Pi).

Code duplication in create() was also reduced.  The platform-independent
portion is now implemented in system/create.c.  The platform-dependent
portion is delegated to a new function arch_setup_stack() that each
platform implements.

Also modified device/flash/flashInit.c:  Removed poorly designed
'flash_size' global variable that was modified directly from the loader on
one platform only, then ultimately not even used.
Add stdint.h
Add endianness.h
Use standard fixed-width integer types in a few appropriate places
Factor some more definitions out of usb_util.h
strchr(), strrchr():  Convert c to 'char'

According to C99, the character to find must be intepreted as a 'char'.
memset():  Make it clear 'c' is intepreted as 'unsigned char'

No change in behavior due to existing implicit cast, but make it clear
that the character to set is interpreted as 'unsigned char', as per C99.
Import docs from mediawiki to restructured text w/ sphinx
Add loader/arch/README
Rename arch_setup_stack() => setupStack()

(Coding style)
stkget() and stkfree():  Clarify documentation
system/create.c:  Remove redundant store to thrptr->stkptr
setupStack():  Fix stack alignment on ARM and MIPS

Ensure the stack is always 8-byte aligned when a new thread begins its
starting procedure.
shell:  Replace strncmp() with strcmp() where safe

This eliminates the need to manually count the characters in string
literals being compared against.  This also fixes bugs in several places
where the previous code forgot to count the null terminator and actually
tested for the prefix property rather than the equality property.
Update and reorganize docs/

- Organize the documentation exported from the Embedded Xinu Wiki into
  arm/, development/, features/, mips/, projects/, and teaching/
  directories.

- Delete a few unneeded documentation files, such as those for accessing
  the (now deprecated) Subversion repo

- Fix many links and tables

- Add page about BCM2835 memory barriers

- Add page about SMSC9512 using info previously in
  device/smsc9512/Doxygroup.c

- Replace Standard Library page using info previously in
  lib/libxc/Doxygroup.c

- Improvements to various pages, such as ARP, Shell.

NOTE: Files under docs/mips/ and docs/projects/ still need work and there
should be a later commit handling them.
Get rid of unicode characters
Another documentation update

- Wrote "Getting Started" page which brings together content previously in
  multiple places.

- Moved build system, porting, and trace documentation to
  docs/development/.

- Moved networking documentation to its own subdirectory of features/.

- The toplevel index.rst no longer contains the toplevel table of contents;
  instead the table of contents is separate.  This helps make the chapters
  in the generated PDF come out sanely.

- Removed toplevel RELEASE file as it's out of date and will need to be
  re-written for the next release anyway (or turned into an incremental
  NEWS file).
Documentation update

- Moved all assignment pages into teaching/assignments/

- Moved deployment and backend pool instructions to teaching/

- Partially fixed up some of the pages in mips/

- Deleted a few pages from mips/ that were useless or redundant

- Made list of supported platforms consistent with actual code (I don't
  personally know about the status of a few of them though...)

- Made various other improvements