extras/mini-os/tpmback.c: fix compilation error.

This patch is with respect to the following discussion on xen-devel -
http://lists.xenproject.org/archives/html/xen-devel/2014-07/msg01991.html

The file extras/mini-os/tpmback.c was failing compilation on certain compilers
because of size mismatch between enum and int. Earlier the code used to read
value of enum using %d format, which failed compilation on some compilers:

tpmback.c: In function ‘tpmif_change_state’:
tpmback.c:350:4: error: format ‘%d’ expects argument of type ‘int *’,
but argument 3 has type ‘enum xenbus_state *’ [-Werror=format=]
    if(sscanf(value, "%d", &readst) != 1) {
    ^

Now the value is read into an actual int variable and then assigned to the
enum.

Signed-off-by:- Dushyant Behl <myselfdushyantbehl@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
[ ijc -- added the actual error to the commit log ]
xen: arm: avoid reusing incorrect mappings when walking the p2m.

When we change which PT page we are mapping at a given level then we need to
invalidate any cached mappings further down the tree, otherwise we risk using
them because their offset might match but be based on a different offset
further up the table.

e.g. when remapping first then cur_first_offset and cur_second_offset (which
indicate the currently mapped second and third tables respectively) both become
invalid

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: implement generic multiboot compatibility strings

This causes Xen to accept the more generic names specified in
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot as of
2014-06-06.

These names are more generic than those proposed by Andre in
http://thread.gmane.org/gmane.linux.linaro.announce.boot/326 and those
used in earlier drafts of the /Multiboot wiki page.

This will allow bootloaders to not special case Xen (or at least to reduce
the amount which is required).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: /chosen/module@N/bootargs bootprotcol node is not deprecated

When using a multiboot capable bootloader this is exactly the field which
should be used.

Replace the deprecation wording with a reference to the information on the
priority of the bootargs fields.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: prefer typesafe max()/min() over MAX()/MIN()

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: rename early_info structs

There isn't really anything Device Tree specific about the early_info, we just
happen to get it from device tree (but in the future it might come e.g. from
UEFI or ACPI or something else).

Move the relevant structs out of device_tree.h and into asm/setup.h and rename to
be more neutral.

For now the code to parse the DT into the now arch specific structs remains in
common code.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
xen: arm: move boot time fdt parsing into separate file.

Move the early code for walking the flattened device tree out of device_tree.c.
The intention is that eventually only the proper (i.e.  unflattened) device
tree support will live in device_tree.c.

The new home is bootfdt.c to try and better reflect the purpose of the code.
Although in theory this early code could be generic in reality it is pretty ARM
specific, so place it under xen/arch/arm until a second user wants it.

As part of the move rename device_tree_early_init to boot_fdt_info. Drop
device_tree_dump, it is unused.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
xen: arm: move device_tree_bootargs to bootfdt.c, renaming to boot_fdt_cmdline

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: store per-boot module type instead of relying on index

This is more natural and better matches how multiboot is actually supposed to
work.

As part of this we need to modify consider_modules to handle Xen not
necessarily being module zero any more. To do this we first register a module
for Xen at the original load address and then update after we have relocated.
This is also fixing a latent issue which is that get_xen_paddr() would not
consider Xen's current physical address when picking the target address which
was buggy because the relocation code cannot handle the possibility of the old
and new locations overlapping.

All callers of consider_modules now consider the full range instead of some
skipping slot 0.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: support bootmodule type detection by ordering

Assign modules types based on the order in which they are defined in the FDT.
This is supported only for the dom0 kernel and ramdisk when given as the first
and second modules respectively, similar to how
http://wiki.xen.org/wiki?title=Xen_ARM_with_Virtualization_Extensions/Multiboot&oldid=11824
defined the default types from the bootloader side.

This is compatible with how Xen interprets the modules with x86 multiboot and I
think simplifies things for bootloaders which now need not contain similar
guessing code if they only care about the most basic case.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: update multiboot device tree bindings.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>