Revision dd4b2659 pc-bios/optionrom/multiboot.S

b/pc-bios/optionrom/multiboot.S
18 18
 *   Authors: Alexander Graf <agraf@suse.de>
19 19
 */
20 20

  
21
#define NO_QEMU_PROTOS
22
#include "../../hw/fw_cfg.h"
23

  
24
#define BIOS_CFG_IOPORT_CFG	0x510
25
#define BIOS_CFG_IOPORT_DATA	0x511
21
#include "optionrom.h"
26 22

  
27 23
#define MULTIBOOT_MAGIC		0x2badb002
28 24

  
29 25
#define GS_PROT_JUMP		0
30 26
#define GS_GDT_DESC		6
31 27

  
32
/* Break the translation block flow so -d cpu shows us values */
33
#define DEBUG_HERE \
34
	jmp		1f;				\
35
	1:
36
	
37
/* Read a variable from the fw_cfg device.
38
   Clobbers:	%edx
39
   Out:		%eax */
40
.macro read_fw VAR
41
	mov		$\VAR, %ax
42
	mov		$BIOS_CFG_IOPORT_CFG, %dx
43
	outw		%ax, (%dx)
44
	mov		$BIOS_CFG_IOPORT_DATA, %dx
45
	inb		(%dx), %al
46
	shl		$8, %eax
47
	inb		(%dx), %al
48
	shl		$8, %eax
49
	inb		(%dx), %al
50
	shl		$8, %eax
51
	inb		(%dx), %al
52
	bswap		%eax
53
.endm
54 28

  
55
/*
56
 * Read a blob from the fw_cfg device.
57
 * Requires _ADDR, _SIZE and _DATA values for the parameter.
58
 *
59
 * Clobbers:	%eax, %edx, %es, %ecx, %edi
60
 */
61
#define read_fw_blob(var) \
62
	read_fw		var ## _ADDR;			\
63
	mov		%eax, %edi;			\
64
	read_fw		var ## _SIZE;			\
65
	mov		%eax, %ecx;			\
66
	mov		$var ## _DATA, %ax;		\
67
	mov		$BIOS_CFG_IOPORT_CFG, %edx;	\
68
	outw		%ax, (%dx);			\
69
	mov		$BIOS_CFG_IOPORT_DATA, %dx;	\
70
	cld;						\
71
	DEBUG_HERE \
72
	rep insb	(%dx), %es:(%edi);
73

  
74
.code16
75
.text
76
	.global 	_start
77
_start:
78
	.short		0xaa55
79
	.byte		(_end - _start) / 512
80
	push		%eax
81
	push		%ds
82

  
83
	/* setup ds so we can access the IVT */
84
	xor		%ax, %ax
85
	mov		%ax, %ds
86

  
87
	/* install our int 19 handler */
88
	movw		$int19_handler, (0x19*4)
89
	mov		%cs, (0x19*4+2)
90

  
91
	pop		%ds
92
	pop		%eax
93
	lret
94

  
95
int19_handler:
96
	/* DS = CS */
97
	movw		%cs, %ax
98
	movw		%ax, %ds
99

  
100
	/* fall through */
29
BOOT_ROM_START
101 30

  
102 31
run_multiboot:
103 32

  
......
249 178
.short	(5 * 8) - 1
250 179
.long	gdt
251 180

  
252
.align 512, 0
253
_end:
254

  
181
BOOT_ROM_END

Also available in: Unified diff