]> rtime.felk.cvut.cz Git - jailhouse-test.git/blob - bootstrap-relink/boot.S
Change the bootstrap to our custom. For now, bootstrap-jh.bin contains whole image...
[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 #define REALMODE_LOADING
12
13         .globl  _start
14         .p2align 4
15 _start:
16 #ifdef REALMODE_LOADING
17         cld
18         cli
19         mov     $(3 * 8), %eax
20         mov     %eax, %ds
21         mov     %eax, %es
22         mov     %eax, %fs
23         mov     %eax, %gs
24
25         /* We have the following problem: Our image is loaded at 0x00100000
26          * by the boot loader but we don't want to get into conflict with
27          * the AMD64 executable. Therefore we move ourself out of the way.
28          * We are linked to 0x01000000 (see ARCH-amd64/boot32/bootstrap.ld) */
29         mov     %esi, %ebx
30         mov     $0x00100000, %esi
31         mov     $0x01000000, %edi
32         mov     $_image_end, %ecx
33         sub     $_image_start, %ecx
34         rep     movsb
35         mov     $1f, %eax
36         jmp     *%eax
37  1:     mov     %ebx, %esi
38         lss     _stack_seg, %esp
39  #else
40         leal    _stack,%esp
41 #endif
42
43         pushl   %esi                    /* ptr to real mode */
44         pushl   %eax
45         pushl   %ebx
46         pushl   $0                      /* no return address */
47         jmp     bootstrap
48
49         .align  4
50
51         .p2align(2), 0x90
52         .long   0x1BADB002              /* magic */
53         .long   0x00000000              /* feature flags */
54         .long   0 - 0x1BADB002
55
56 #ifdef REALMODE_LOADING
57 _stack_seg:
58         .long   _stack
59         .word   (3 * 8)
60 #endif
61
62         .bss
63         .space  8192
64 _stack: