aboutsummaryrefslogtreecommitdiffstats
path: root/mini-os/head.S
blob: 3f4e6670c373ffbd6a737718a48a65fa6b46d91e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <os.h>

/* Offsets in start_info structure */
#define SHARED_INFO  4
#define MOD_START   12
#define MOD_LEN     16

#define ENTRY(X) .globl X ; X :

.globl _start                
_start:
        cld
        
        lss stack_start,%esp
        
        /* Copy any module somewhere safe before it's clobbered by BSS. */
        mov  MOD_LEN(%esi),%ecx
        shr  $2,%ecx
        jz   2f        /* bail from copy loop if no module */
        
        mov  $_end,%edi
        add  MOD_LEN(%esi),%edi
        mov  MOD_START(%esi),%eax
        add  MOD_LEN(%esi),%eax
1:      sub  $4,%eax
        sub  $4,%edi
        mov  (%eax),%ebx
        mov  %ebx,(%edi)
        loop 1b
        mov  %edi,MOD_START(%esi)

        /* Clear BSS first so that there are no surprises... */
2:      xorl %eax,%eax
	    movl $__bss_start,%edi
	    movl $_end,%ecx
	    subl %edi,%ecx
	    rep stosb

        push %esi 
        call start_kernel


stack_start:
	.long stack+8192, __KERNEL_DS