4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 * Copyright Novell Inc, 2009
18 * Authors: Alexander Graf <agraf@suse.de>
20 * Copyright (c) 2019 Red Hat Inc.
21 * Authors: Stefano Garzarella <sgarzare@redhat.com>
24 #include "optionrom.h"
26 #define BOOT_ROM_PRODUCT "PVH loader"
28 #define GS_PROT_JUMP 0
31 #ifdef OPTION_ROM_START
32 #undef OPTION_ROM_START
39 * Redefine OPTION_ROM_START and OPTION_ROM_END, because this rom is produced
40 * linking multiple objects.
41 * signrom.py will add padding.
43 #define OPTION_ROM_START \
49 .byte 3; /* desired size in 512 units */
51 #define OPTION_ROM_END \
64 /* set up a long jump descriptor that is PC relative */
66 /* move stack memory to %gs */
76 /* now push the indirect jump descriptor there */
79 movl %ebx, %gs:GS_PROT_JUMP
81 movw %bx, %gs:GS_PROT_JUMP + 4
83 /* fix the gdt descriptor to be PC relative */
85 movw %bx, %gs:GS_GDT_DESC
86 movl (gdt_desc+2), %ebx
88 movl %ebx, %gs:GS_GDT_DESC + 2
90 /* initialize HVM memmap table using int 0x15(e820) */
92 /* ES = pvh_e820 struct */
97 /* start storing memmap table at %es:8 (pvh_e820.table) */
103 /* pvh_e820 can contains up to 128 entries */
108 /* entry size (hvm_memmap_table_entry) & max buffer size (int15) */
111 movl $0x0000e820, %eax
113 movl $0x534d4150, %edx
114 /* store counter value at %es:0 (pvh_e820.entries) */
118 /* error or last entry already done? */
121 /* %edi += entry size (hvm_memmap_table_entry) */
124 /* continuation value 0 means last entry */
126 jnz memmap_loop_check
128 /* increase pvh_e820.entries to save the last entry */
137 /* load the GDT before going into protected mode */
139 data32 lgdt %gs:GS_GDT_DESC
141 /* get us to protected mode now */
145 /* the LJMP sets CS for us and gets us to 32-bit */
147 data32 ljmp *%gs:GS_PROT_JUMP
152 /* initialize all other segments */
164 prot_jump: .long prot_mode
170 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
174 * (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k)
176 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00
180 * (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k)
182 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00
186 * (base=0, limit=0x0ffff, type=16bit code exec/read/conf, DPL=0, 1b)
188 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00
192 * (base=0, limit=0x0ffff, type=16bit data read/write, DPL=0, 1b)
194 .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00