debuggers.hg

view tools/firmware/vmxassist/vmxloader.c @ 6631:ed474440decd

Various minor vmxassist cleanups.

Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 02 17:53:52 2005 +0000 (2005-09-02)
parents bc8bb3a26ccc
children f27205ea60ef 29808fef9148
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 #endif
33 /*
34 * C runtime start off
35 */
36 asm(" \n\
37 .text \n\
38 .globl _start \n\
39 _start: \n\
40 cli \n\
41 movl $stack_top, %esp \n\
42 movl %esp, %ebp \n\
43 call main \n\
44 jmp halt \n\
45 \n\
46 .globl halt \n\
47 halt: \n\
48 sti \n\
49 jmp . \n\
50 \n\
51 .bss \n\
52 .align 8 \n\
53 .globl stack, stack_top \n\
54 stack: \n\
55 .skip 0x4000 \n\
56 stack_top: \n\
57 ");
59 void *
60 memcpy(void *dest, const void *src, unsigned n)
61 {
62 int t0, t1, t2;
64 __asm__ __volatile__(
65 "cld\n"
66 "rep; movsl\n"
67 "testb $2,%b4\n"
68 "je 1f\n"
69 "movsw\n"
70 "1: testb $1,%b4\n"
71 "je 2f\n"
72 "movsb\n"
73 "2:"
74 : "=&c" (t0), "=&D" (t1), "=&S" (t2)
75 : "0" (n/4), "q" (n), "1" ((long) dest), "2" ((long) src)
76 : "memory"
77 );
78 return dest;
79 }
81 int
82 puts(const char *s)
83 {
84 while (*s)
85 outb(0xE9, *s++);
86 return 0;
87 }
89 int
90 cirrus_check(void)
91 {
92 outw(0x3C4, 0x9206);
93 return inb(0x3C5) == 0x12;
94 }
96 int
97 main()
98 {
99 puts("VMXAssist Loader\n");
100 puts("Loading ROMBIOS ...\n");
101 memcpy((void *)0xF0000, rombios, sizeof(rombios));
102 if (cirrus_check()) {
103 puts("Loading Cirrus VGABIOS ...\n");
104 memcpy((void *)0xC0000,
105 vgabios_cirrusvga, sizeof(vgabios_cirrusvga));
106 } else {
107 puts("Loading Standard VGABIOS ...\n");
108 memcpy((void *)0xC0000,
109 vgabios_stdvga, sizeof(vgabios_stdvga));
110 }
111 #ifdef _ACPI_
112 puts("Loading ACPI ...\n");
113 if (ACPI_PHYSICAL_ADDRESS+sizeof(acpi) <= 0xF0000 ){
114 /* make sure acpi table does not overlap rombios
115 * currently acpi less than 8K will be OK.
116 */
117 memcpy((void *)ACPI_PHYSICAL_ADDRESS, acpi, sizeof(acpi));
118 }
119 #endif
121 puts("Loading VMXAssist ...\n");
122 memcpy((void *)TEXTADDR, vmxassist, sizeof(vmxassist));
123 puts("Go ...\n");
124 ((void (*)())TEXTADDR)();
125 return 0;
126 }