HisiPkg: D01: add secondary core HYP mode switch function to support KVM/Xen

Signed-off-by: Wei Xu <xuwei5@huawei.com>
HisiPkg: D01: Move Bootwrapper read code into subfunction

We want to split the bootwrapper reads from direct kernel boot. For that
we need to be able to directly issue bootwrapper reads from other pieces
of code.

Move the .text/.monitor file read into its own function.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Wei Xu <xuwei5@huawei.com>
HisiPkg: D01: Load bootwrapper when exiting boot services

Today we load the bootwrapper binaries before we enter a kernel using
direct kernel boot. But kernels loaded via EFI applications (like grub2)
also need to have the bootwrapper code loaded.

This patch adds a callback when we exit the runtime services and in that
case loads the bootwrapper code. This happens with direct kernel boot as
well as with grub2 boot.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Wei Xu <xuwei5@huawei.com>
HisiPkg: D01: Move bootwrapper and kernel offsets to header

We have 2 files that need to know the location of kernel and bootwrapper
in the physical address layout. Move the definitions to a header file so
both can use defines rather than hard coded values.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Wei Xu <xuwei5@huawei.com>
HisiPkg: D01: Run bootwrapper before we exit runtime services

When we exit the runtime services, we need to also execute our bootwrapper
code to make sure that we get into HYP mode.

This patch adds wrapping code that allows us to execute the bootwrapper code
when exiting runtime services. However we only run them for non-direct kernel
boot, as that one would run the bootwrapper twice otherwise.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Wei Xu <xuwei5@huawei.com>
HisiPkg: D01: Move bootwrapper to SRAM

Reserving DDR memory is a very tricky thing to do. We always need to make
sure we don't overlap with memory regions the guest uncondionally uses.

However, we need to keep the bootwrapper code resident in memory for CPU
hotplug. So let's just move it into SRAM. There it can stay happily ever
after.

Unfortunately we need to make sure we only copy the bootwrapper to SRAM,
not a full NAND block. So this patch also introduces a bounce buffer for
NAND access.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Wei Xu <xuwei5@huawei.com>
HisiPkg: D01: Add support for dynamic target bootwrapper

The bootwrapper code improved slightly and it can now handle parameters
as kernel entry point. Add awareness of this and tell the bootwrapper
where to jump to.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Wei Xu <xuwei5@huawei.com>
HisiPkg: D01: Change architected timer frequency to 50Mhz

When running with HYP mode enabled, Linux uses the architected timer. It detects
168.75Mhz as indicated by firmware, but the timer only runs at 50Mhz. I've tried
to change the speed setting in bootwrapper but the timer was still stuck at 50Mhz.

This patch resignates to hardware and simply configured the architected timer to
be at 50Mhz which makes my Linux guest happily run "sleep 1" within one second.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Wei Xu <xuwei5@huawei.com>
HisiPkg: D01: Load NAND rootfs into memory before we exit runtime services.

This patch allow we could enter into NAND rootfs via grub.

Signed-off-by: Wei Xu <xuwei5@huawei.com>