direct-io.hg

view tools/firmware/vmxassist/vmxloader.c @ 7477:5a7baecb1c70

Fix an issue for passing arguement from control panel to deivce model
for some arguemnt like 'localtime', 'isa', device model need an argument
"-localtime", instead of "-localtime 1"
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Oct 23 16:51:47 2005 +0100 (2005-10-23)
parents 61b3b357d827
children 121ff5042eb3
line source
1 /*
2 * vmxloader.c: ROM/VMXAssist image loader.
3 *
4 * A quicky so that we can boot rom images as if they were a Linux kernel.
5 * This code will copy the rom images (ROMBIOS/VGABIOS/VM86) into their
6 * respective spaces and transfer control to VM86 to execute the BIOSes.
7 *
8 * Leendert van Doorn, leendert@watson.ibm.com
9 * Copyright (c) 2005, International Business Machines Corporation.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms and conditions of the GNU General Public License,
13 * version 2, as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22 * Place - Suite 330, Boston, MA 02111-1307 USA.
23 */
24 #include "machine.h"
25 #include "roms.h"
27 #ifdef _ACPI_
28 #include "acpi.h"
29 #include "../acpi/acpi2_0.h" // for ACPI_PHYSICAL_ADDRESS
30 int acpi_madt_update(unsigned char* acpi_start);
31 #endif
34 /*
35 * C runtime start off
36 */
37 asm(
38 " .text \n"
39 " .globl _start \n"
40 "_start: \n"
41 " cld \n"
42 " cli \n"
43 " lgdt gdt_desr \n"
44 " movl $stack_top, %esp \n"
45 " movl %esp, %ebp \n"
46 " call main \n"
47 " jmp halt \n"
48 " \n"
49 "gdt_desr: \n"
50 " .word gdt_end - gdt - 1 \n"
51 " .long gdt \n"
52 " \n"
53 " .align 8 \n"
54 "gdt: \n"
55 " .quad 0x0000000000000000 \n"
56 " .quad 0x00CF92000000FFFF \n"
57 " .quad 0x00CF9A000000FFFF \n"
58 "gdt_end: \n"
59 " \n"
60 "halt: \n"
61 " sti \n"
62 " jmp . \n"
63 " \n"
64 " .bss \n"
65 " .align 8 \n"
66 "stack: \n"
67 " .skip 0x4000 \n"
68 "stack_top: \n"
69 );
71 void *
72 memcpy(void *dest, const void *src, unsigned n)
73 {
74 int t0, t1, t2;
76 __asm__ __volatile__(
77 "cld\n"
78 "rep; movsl\n"
79 "testb $2,%b4\n"
80 "je 1f\n"
81 "movsw\n"
82 "1: testb $1,%b4\n"
83 "je 2f\n"
84 "movsb\n"
85 "2:"
86 : "=&c" (t0), "=&D" (t1), "=&S" (t2)
87 : "0" (n/4), "q" (n), "1" ((long) dest), "2" ((long) src)
88 : "memory"
89 );
90 return dest;
91 }
93 int
94 puts(const char *s)
95 {
96 while (*s)
97 outb(0xE9, *s++);
98 return 0;
99 }
101 int
102 cirrus_check(void)
103 {
104 outw(0x3C4, 0x9206);
105 return inb(0x3C5) == 0x12;
106 }
108 int
109 main(void)
110 {
111 puts("VMXAssist Loader\n");
112 puts("Loading ROMBIOS ...\n");
113 memcpy((void *)0xF0000, rombios, sizeof(rombios));
114 if (cirrus_check()) {
115 puts("Loading Cirrus VGABIOS ...\n");
116 memcpy((void *)0xC0000,
117 vgabios_cirrusvga, sizeof(vgabios_cirrusvga));
118 } else {
119 puts("Loading Standard VGABIOS ...\n");
120 memcpy((void *)0xC0000,
121 vgabios_stdvga, sizeof(vgabios_stdvga));
122 }
123 #ifdef _ACPI_
124 puts("Loading ACPI ...\n");
126 acpi_madt_update(acpi);
128 if (ACPI_PHYSICAL_ADDRESS+sizeof(acpi) <= 0xF0000) {
129 /* make sure acpi table does not overlap rombios
130 * currently acpi less than 8K will be OK.
131 */
132 memcpy((void *)ACPI_PHYSICAL_ADDRESS, acpi, sizeof(acpi));
133 }
134 #endif
136 puts("Loading VMXAssist ...\n");
137 memcpy((void *)TEXTADDR, vmxassist, sizeof(vmxassist));
139 puts("Go ...\n");
140 asm volatile ( "jmp *%%eax" : : "a" (TEXTADDR), "d" (0) );
142 return 0;
143 }