]> rtime.felk.cvut.cz Git - jailhouse-test.git/blob - bootstrap-relink/boot.S
ef13a9fd4b2517a625c1847d9678486b428a7b71
[jailhouse-test.git] / bootstrap-relink / boot.S
1 /*
2  * (c) 2009 Frank Mehnert <fm3@os.inf.tu-dresden.de>,
3  *          Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 /* -*- c -*- */
11
12         .globl  _start
13         .p2align 4
14 _start:
15 #ifdef REALMODE_LOADING
16         cld
17         cli
18         mov     $(3 * 8), %eax
19         mov     %eax, %ds
20         mov     %eax, %es
21         mov     %eax, %fs
22         mov     %eax, %gs
23
24         /* We have the following problem: Our image is loaded at 0x00100000
25          * by the boot loader but we don't want to get into conflict with
26          * the AMD64 executable. Therefore we move ourself out of the way.
27          * We are linked to 0x01000000 (see ARCH-amd64/boot32/bootstrap.ld) */
28         mov     %esi, %ebx
29         mov     $0x00100000, %esi
30         mov     $0x01000000, %edi
31         mov     $_image_end, %ecx
32         sub     $_image_start, %ecx
33         rep     movsb
34         mov     $1f, %eax
35         jmp     *%eax
36  1:     mov     %ebx, %esi
37         lss     _stack_seg, %esp
38  #else
39         leal    _stack,%esp
40 #endif
41
42         pushl   %esi                    /* ptr to real mode */
43         pushl   %eax
44         pushl   %ebx
45         pushl   $0                      /* no return address */
46         jmp     bootstrap
47
48         .align  4
49
50         .p2align(2), 0x90
51         .long   0x1BADB002              /* magic */
52         .long   0x00000000              /* feature flags */
53         .long   0 - 0x1BADB002
54
55 #ifdef REALMODE_LOADING
56 _stack_seg:
57         .long   _stack
58         .word   (3 * 8)
59 #endif
60
61         .bss
62         .space  8192
63 _stack: