bootstub: get system memory map by int 15h on Baytrail platform

BZ: 96847

There is no SFI MMAP table any more for Baytrail platform.
Now we can get system memory map information by int 15h which returns
an e820 table with memory map entries.
We have to switch to real mode to call int 15h then switch back to
protected mode.
This patch implements the real mode int 15 call in assembly language
but exported a C style function:
int get_e820_by_bios(void *e820_buf);
See details in e820_bios.S.

Change-Id: I33dbeaaa58da217e74e015f0d911896500043d17
Signed-off-by: Bin Gao <bin.gao@intel.com>
Reviewed-on: http://android.intel.com:8080/99216
Reviewed-by: Balestriere, VianneyX <vianneyx.balestriere@intel.com>
Tested-by: Balestriere, VianneyX <vianneyx.balestriere@intel.com>
diff --git a/bootstub.c b/bootstub.c
index f53409f..26c96d2 100644
--- a/bootstub.c
+++ b/bootstub.c
@@ -27,33 +27,6 @@
 
 #define bs_printk(x) { if (! *(int *)SPI_UART_SUPPRESSION) bs_spi_printk(x);}
 
-struct gdt_ptr {
-        u16 len;
-        u32 ptr;
-} __attribute__((packed));
-
-static void setup_gdt(void)
-{
-        static const u64 boot_gdt[] __attribute__((aligned(16))) = {
-                /* CS: code, read/execute, 4 GB, base 0 */
-                [GDT_ENTRY_BOOT_CS] = GDT_ENTRY(0xc09b, 0, 0xfffff),
-                /* DS: data, read/write, 4 GB, base 0 */
-                [GDT_ENTRY_BOOT_DS] = GDT_ENTRY(0xc093, 0, 0xfffff),
-        };
-        static struct gdt_ptr gdt;
-
-        gdt.len = sizeof(boot_gdt)-1;
-        gdt.ptr = (u32)&boot_gdt;
-
-        asm volatile("lgdtl %0" : : "m" (gdt));
-}
-
-static void setup_idt(void)
-{
-        static const struct gdt_ptr null_idt = {0, 0};
-        asm volatile("lidtl %0" : : "m" (null_idt));
-}
-
 static void *memcpy(void *dest, const void *src, size_t count)
 {
         char *tmp = dest;
@@ -101,6 +74,7 @@
 static void setup_boot_params(struct boot_params *bp, struct setup_header *sh)
 {
 	u8 *initramfs;
+	int nr_entries;
 
 	memset(bp, 0, sizeof (struct boot_params));
 	bp->screen_info.orig_video_mode = 0;
@@ -121,7 +95,12 @@
 	} else {
 		bs_printk("Won't relocate initramfs, are you in SLE?\n");
 	}
-	sfi_setup_e820(bp);
+	if (mrst_identify_cpu() == MRST_CPU_CHIP_VALLEYVIEW2) {
+		nr_entries = get_e820_by_bios(bp->e820_map);
+		bp->e820_entries = (nr_entries > 0) ? nr_entries : 0;
+	} else {
+		sfi_setup_e820(bp);
+	}
 }
 
 static int get_32bit_entry(unsigned char *ptr)
@@ -187,8 +166,6 @@
 
 int bootstub(void)
 {
-	setup_idt();
-	setup_gdt();
 	setup_spi();
 	bs_printk("Bootstub Version: 1.2 ...\n");
 	setup_boot_params((struct boot_params *)BOOT_PARAMS_OFFSET,