Initial checkin of toy OS project.
[os.git] / kernel / init / main.c
1 //+----------------------------------------------------------------------------
2 //
3 // File:     main.c
4 //
5 // Module:   
6 //
7 // Synopsis: 
8 //
9 // Created:  sgasch  4 Jul 2003
10 //
11 //+----------------------------------------------------------------------------
12
13 #include "kernel.h"
14 #include "hal.h"
15 #include "rtl.h"
16
17 extern char __bss_start;
18 extern char end;
19
20 void
21 ZeroBSS(void)
22 {
23     BYTE *pBssStart, *pBssEnd;
24
25     pBssStart = &__bss_start;
26     pBssEnd = &end;
27
28     // Fill .bss section with zero
29     RtlSetMemory((void *)pBssStart, '\0', (pBssEnd - pBssStart));
30 }
31
32 void
33 _assert(CHAR *szFunction, CHAR *szFile, ULONG uLine)
34 {
35     HalVideoSetCursorPosition(0, 0);
36     HalVideoPrint("ASSERTION in %s at %s line %u.\n",
37                szFunction, szFile, uLine);
38     while(1)
39     {
40         ;
41     }
42 }
43
44 //
45 // Entry point of the kernel.  Not called main because I don't care to 
46 // listen to gcc's warnings about argc and argv anymore.
47 //
48 int
49 KernelEntry(BIOS_HARDWARE_BLOCK *phw)
50 {
51     ZeroBSS();
52
53     HalVideoInitialize(phw);
54     HalInitializeInterrupts();
55
56     HalVideoPrint("Interrupts initialized.\n");
57     
58  hang:
59     HalReadTimestampCounter();
60     HalVideoPrint("Timestamp Counter: %u%u\n", 
61                   ((g_ullTimeStampCounter >> 32) & 0xffffffff),
62                   (g_ullTimeStampCounter & 0xffffffff));
63     goto hang;
64
65     return(-1);
66 }
67