mini-os: build fixes

Make .o rules depend on the includes. Before, only the final link step
depended on setting up the includes directory, making parallel builds
unreliable.

Make symlinks use explicit make rules instead of using a phony target.
Avoids unnecessary rebuilds.

Signed-off-by: Thomas Leonard <talex5@gmail.com>
mini-os: fixed shutdown thread

Before, it read "" and started a shutdown immediately. Now, it waits for
a non-empty value and then actually shuts down.

Signed-off-by: Thomas Leonard <talex5@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
mini-os: tidied up code

Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@gmail.com>
[talex5@gmail.com: separated from big ARM commit]
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
[talex5@gmail.com: use __func__ in DEBUG macro]
[talex5@gmail.com: drop text about "xm create"]
Signed-off-by: Thomas Leonard <talex5@gmail.com>
mini-os: moved events code under arch

This is all code motion, except that we now initialise
the ev_actions array before calling the arch-specific code
to make it more robust against future changes.

Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@gmail.com>
[talex5@gmail.com: separated from big ARM commit]
Signed-off-by: Thomas Leonard <talex5@gmail.com>
mini-os: switched initial C entry point to arch_init

arch_print_info (a debug print called during start up) was also removed.

Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@gmail.com>
[talex5@gmail.com: separated from big ARM commit]
[talex5@gmail.com: restored comment, moved prototypes to headers]
Signed-off-by: Thomas Leonard <talex5@gmail.com>
mini-os: don't include queue.h if there's no libc

Signed-off-by: Thomas Leonard <talex5@gmail.com>
mini-os: initial ARM support

On ARM, Mini-OS will boot and display some output on the console.
Tested with:

make XEN_TARGET_ARCH=arm32 CROSS_COMPILE=arm-linux-gnueabihf- \
  CONFIG_TEST=n CONFIG_START_NETWORK=n CONFIG_BLKFRONT=n \
  CONFIG_NETFRONT=n CONFIG_FBFRONT=n CONFIG_KBDFRONT=n \
  CONFIG_CONSFRONT=n CONFIG_XC=n CONFIG_XENBUS=n

Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@gmail.com>
[talex5@gmail.com: made x86_64 support work again]
[talex5@gmail.com: split into multiple patches]
[talex5@gmail.com: re-enabled force_evtchn_callback]
[talex5@gmail.com: enable regular console]
[talex5@gmail.com: fixed initialisation code:
- Configure write-back caching in page table. This is needed for
  reliable hypercalls to Xen (thanks to Julien Grall).
- Use "client mode" for access control (domains are deprecated,
  according to ARM Cortex-A Series Programmer’s Guide version 4.0,
  section 9.6.4).
- Enable more SCTLR features (icache, branch prediction)]
[talex5@gmail.com: use Virtual Count register for monotonic time]
[talex5@gmail.com: fixed HYPERVISOR_shutdown]
[talex5@gmail.com: get xenstore details from hypervisor]
[talex5@gmail.com: use GCC implementation of division]
[talex5@gmail.com: include hypervisor.h from os.h, as on x86]
[talex5@gmail.com: cleaned up interrupt handlers and threading]
[talex5@gmail.com: call exit_thread when a thread returns]
[talex5@gmail.com: implemented block_domain for ARM]
Signed-off-by: Thomas Leonard <talex5@gmail.com>
mini-os: arm: show registers and exception vector on fault
mini-os: import libfdt

Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@gmail.com>
[talex5@gmail.com: split out FDT support into a separate patch]
[talex5@gmail.com: fixed "make clean" for FDT]
Signed-off-by: Thomas Leonard <talex5@gmail.com>
Get RAM base and size from the FDT
Fixed MM printk output

Was printing:

MM: Initialise page allocator for 80032000(80032000) - 0(84000000)
Preserve device tree when initialising MM

Move the device tree to a reserved area at the end of the RAM.
Disable memory test

Everything seems to be working now and the output clutters up the
console logs.
Get GIC addresses from FDT
Fixed hang when enabling interrupts

It seems we must call gic_enable_interrupts before enabling individual
interrupts, otherwise our IRQ handler gets called endlessly with
spurious interrupts (interrupt number 1023).
Whitespace
Added arch_endian.h for ARM
Added ARM grant table initialisation

On x86, we get told which pages to use, but on ARM we get the base
address in the FDT and have to map each page.
Networking on ARM

Set MEM_ALIGNMENT=4 to request word-aligned memory access. However, this
does not cover all cases in lwIP, so also configure the CPU to allow
unaligned accesses.
mini-os: Made off_t type signed

POSIX requires this.