segment_alloc may not allocate enough memory.
[mit-jos.git] / lib / entry.S
blob5e0248a28c77fae54627c3a837c4b77f8d1ba624
1 #include <inc/mmu.h>
2 #include <inc/memlayout.h>
4 .data
5         // define page-aligned fsipcbuf for fsipc.c
6         // ... and fdtab for file.c
7         .p2align PGSHIFT
8         .globl fsipcbuf
9 fsipcbuf:
10         .space PGSIZE
11         .globl fdtab
12 fdtab:
13         .space PGSIZE
15 // Define the global symbols 'envs', 'pages', 'vpt', and 'vpd'
16 // so that they can be used in C as if they were ordinary global arrays.
17         .globl envs
18         .set envs, UENVS
19         .globl pages
20         .set pages, UPAGES
21         .globl vpt
22         .set vpt, UVPT
23         .globl vpd
24         .set vpd, (UVPT+(UVPT>>12)*4)
27 // Entrypoint - this is where the kernel (or our parent environment)
28 // starts us running when we are initially loaded into a new environment.
29 .text
30 .globl _start
31 _start:
32         // See if we were started with arguments on the stack
33         cmpl $USTACKTOP, %esp
34         jne args_exist
36         // If not, push dummy argc/argv arguments.
37         // This happens when we are loaded by the kernel,
38         // because the kernel does not know about passing arguments.
39         pushl $0
40         pushl $0
42 args_exist:
43         call libmain
44 1:      jmp 1b