mini-os: arm: time

Based on an initial patch by Karim Raslan.

Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@gmail.com>
Signed-off-by: Thomas Leonard <talex5@gmail.com>

---

Addressed Ian Campbell comments:
- removed unnecessary isb
- removed some debug comments
- simplified some of the asm calls
mini-os: arm: interrupt controller

Based on an initial patch by Karim Raslan.

Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@gmail.com>
Signed-off-by: Thomas Leonard <talex5@gmail.com>

---

Changes since v6:

Addressed Julien Grall's comments:
- converted ?: to if
mini-os: arm: build system

Based on an initial patch by Karim Raslan.

This activates the ARM code added in the previous patches. 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=y CONFIG_START_NETWORK=n CONFIG_BLKFRONT=n \
	CONFIG_NETFRONT=n CONFIG_FBFRONT=n CONFIG_KBDFRONT=n \
	CONFIG_CONSFRONT=n CONFIG_XC=n -j4

The memmove implementation is from FreeBSD's
contrib/ldns/compat/memmove.c (r246827).

Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@gmail.com>
Signed-off-by: Thomas Leonard <talex5@gmail.com>

---

Changes since v7:

- updated libfdt_env for new libfdt version
  (broken by commit d198fbe6cfe6feaa85259da984a221d841f8355a)
mini-os: arm: show registers, stack and exception vector on fault

Signed-off-by: Thomas Leonard <talex5@gmail.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
mini-os: fixed compiling with debug=n

Without -fno-tree-loop-distribute-patterns, gcc -O3 recognises that our
"memset" is doing a memset operation and tries to make it call the
standard "memset", creating a loop.

The change to fdt_ro.c is to avoid a compiler warning.

Signed-off-by: Thomas Leonard <talex5@gmail.com>
mini-os: reorganised arch headers

Before, we had:

- include
- include/arm
- include/x86

Where either arm or x86 was added directly to the search path. So
<x86/arch_limits.h> was the same file as <arch_limits.h> on x86.

We now have:

- include
- arch/arm/include
- arch/x86/include

This means that only the second form is now legal. It also simplifies
installation of the headers, since we can now install everything in the
include directory without getting files for other archs.
mini-os: added make install target

This installs libminios.a, the linker script, the headers and a
pkg-config file to locate them.
mini-os: expose gnttab_table, NR_GRANT_FRAMES, etc

Needed by Mirage.
mini-os: make do_hypervisor_callback weak

This is for Mirage, which handles events synchronously by checking for
pending events before blocking.

Signed-off-by: Thomas Leonard <talex5@gmail.com>
mini-os: added stub for printing floats for sprintf, etc

Override the weak __printf_render_float to implement.
mini-os: make start_kernel weak

Possibly we should just move it to test.c. It should be up to
applications which features they want to initialise.
mini-os: arm: extend boot stack by 1 MB

At boot, we only have a 16 KB stack. Once we've found the rest of the
RAM, we map the top 1 MB just below the boot stack. The advantage of
putting it here is that we don't need to relocate the stack, and we
still get overflow protection.
mini-os: arm: annotate asm functions with %function

Needed if we want to call them from thumb mode.
gntmap: fix on ARM, probably break x86

The hypercall GNTTAPOP_map_grant_ref expects a "host virtual address"
but our buffer is a virtual address which appears to be offset by
a "physical_address_offset". Correct this using the available macro.

On x86 this will probably break because the address is correct without
the transformation. It could only possibly work if
(unsigned long)&_text = 0.

Signed-off-by: David Scott <dave.scott@citrix.com>
arm: create a demand map area of size 640K

The API has 'malloc' but no 'free': this works for x86 because mini-os
can use the pagetable to see if a page is free or not. I don't know
whether we can use the same trick, so instead create a simple array to
track business.

Note since there is no 'free' API in gntmap.c, we leak allocations. This
is ok if we're using protocols like vchan which allocate up-front, but
would clearly be a disaster for protocols such as netfront/back or
blockfront/back.

Signed-off-by: David Scott <dave.scott@citrix.com>
Removed FIXME for grant mapping on x86

This doesn't actually make any difference, because _text=0 on x86, but
it's cleaner this way.