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 <[email protected]>
Reviewed-on: http://android.intel.com:8080/99216
Reviewed-by: Balestriere, VianneyX <[email protected]>
Tested-by: Balestriere, VianneyX <[email protected]>
diff --git a/head.S b/head.S
index d4f21e2..a949e7a 100644
--- a/head.S
+++ b/head.S
@@ -62,26 +62,53 @@
 _start:
 	cld
 	cli
-	/* setup stack, because we are heading off to "C" */
-	movl $STACK_OFFSET, %esp
-	/* after call bootstub, GDT was set (0x10 and 0x18) IDT was clear
-	 * eax will store 32bit entry of bzImage
-         */
-	calll bootstub
-	/* DS=ES=FS=GS=10 */
+
+	/* Set our own GDT and IDT, don't derive from IAFW */
+	lgdtl	%cs:gdtr
+	lidtl	%cs:idtr
+
+	/* Load segment registers per protected mode kernel entry requirement:
+	 * CS=0x10,
+	 * DS=ES=SS=FS=GS=0x18
+	 */
+	ljmp	$__BOOT_CS, $1f
+1:
 	movl $__BOOT_DS, %ebx	
 	movl %ebx, %ds
 	movl %ebx, %es
 	movl %ebx, %fs
 	movl %ebx, %gs
 	movl %ebx, %ss
-	ljmp $__BOOT_CS,$1f
-1:	
+
+	/* setup stack, because we are heading off to "C" */
+	movl $STACK_OFFSET, %esp
+
+	/* bootstub() returns 32bit entry address of bzImage, stored in eax */
+	calll bootstub
+
 	/* tell kernel where is boot_param */
 	movl $(BOOT_PARAMS_OFFSET), %esi
 	xor %ebp, %ebp
 	xor %edi, %edi
 	xor %ebx, %ebx
-	
-	jmpl *%eax    # Jump to the 32-bit entrypoint
-	
+
+	/* Jump to the 32-bit entrypoint */
+	jmpl *%eax
+
+	.balign 8
+gdt:
+        .quad   0
+        .quad   0
+        .quad   GDT_ENTRY(0xc09b, 0, 0xfffff)
+        .quad   GDT_ENTRY(0xc093, 0, 0xfffff)
+gdtr:
+        .word   4*8-1
+        .long   gdt
+
+	.balign 8
+idt:
+	.quad	0
+	.quad	0
+idtr:
+	.word	2*8-1
+	.long	idt