Removed some unnecessary includes.
[wine] / dlls / kernel / kernel_main.c
1 /*
2  * Kernel initialization code
3  */
4
5 #include "config.h"
6
7 #include <assert.h>
8 #include <ctype.h>
9 #include <string.h>
10
11 #include "winbase.h"
12
13 #include "wine/winbase16.h"
14 #include "callback.h"
15 #include "global.h"
16 #include "miscemu.h"
17 #include "module.h"
18 #include "task.h"
19
20 extern void CODEPAGE_Init(void);
21 extern BOOL RELAY_Init(void);
22 extern BOOL THUNK_Init(void);
23 extern void COMM_Init(void);
24
25
26 /***********************************************************************
27  *           KERNEL process initialisation routine
28  */
29 static BOOL process_attach(void)
30 {
31     HMODULE16 hModule;
32
33     /* Setup codepage info */
34     CODEPAGE_Init();
35
36     /* Initialize relay entry points */
37     if (!RELAY_Init()) return FALSE;
38
39     /* Initialize thunking */
40     if (!THUNK_Init()) return FALSE;
41
42     /* Initialize DOS memory */
43     if (!DOSMEM_Init(0)) return FALSE;
44
45     if ((hModule = LoadLibrary16( "krnl386.exe" )) < 32) return FALSE;
46
47     /* Initialize special KERNEL entry points */
48
49     /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
50     NE_SetEntryPoint( hModule, 178, GetWinFlags16() );
51
52     /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
53     NE_SetEntryPoint( hModule, 454, __get_cs() );
54     NE_SetEntryPoint( hModule, 455, __get_ds() );
55
56     /* Initialize KERNEL.THHOOK */
57     TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( hModule, (LPCSTR)332 )));
58
59     /* Initialize the real-mode selector entry points */
60 #define SET_ENTRY_POINT( num, addr ) \
61     NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
62                       DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
63                       WINE_LDT_FLAGS_DATA ))
64
65     SET_ENTRY_POINT( 174, 0xa0000 );  /* KERNEL.174: __A000H */
66     SET_ENTRY_POINT( 181, 0xb0000 );  /* KERNEL.181: __B000H */
67     SET_ENTRY_POINT( 182, 0xb8000 );  /* KERNEL.182: __B800H */
68     SET_ENTRY_POINT( 195, 0xc0000 );  /* KERNEL.195: __C000H */
69     SET_ENTRY_POINT( 179, 0xd0000 );  /* KERNEL.179: __D000H */
70     SET_ENTRY_POINT( 190, 0xe0000 );  /* KERNEL.190: __E000H */
71     NE_SetEntryPoint( hModule, 183, DOSMEM_0000H );       /* KERNEL.183: __0000H */
72     NE_SetEntryPoint( hModule, 173, DOSMEM_BiosSysSeg );  /* KERNEL.173: __ROMBIOS */
73     NE_SetEntryPoint( hModule, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
74     NE_SetEntryPoint( hModule, 194, DOSMEM_BiosSysSeg );  /* KERNEL.194: __F000H */
75 #undef SET_ENTRY_POINT
76
77     /* Force loading of some dlls */
78     if (LoadLibrary16( "system" ) < 32) return FALSE;
79
80     /* Initialize communications */
81     COMM_Init();
82
83     /* Read DOS config.sys */
84     if (!DOSCONF_ReadConfig()) return FALSE;
85
86     /* Create 16-bit task */
87     TASK_CreateMainTask();
88
89     /* Create the shared heap for broken win95 native dlls */
90     HeapCreate( HEAP_SHARED, 0, 0 );
91
92     return TRUE;
93 }
94
95 /***********************************************************************
96  *           KERNEL initialisation routine
97  */
98 BOOL WINAPI MAIN_KernelInit( HINSTANCE hinst, DWORD reason, LPVOID reserved )
99 {
100     switch(reason)
101     {
102     case DLL_PROCESS_ATTACH:
103         return process_attach();
104     case DLL_PROCESS_DETACH:
105         WriteOutProfiles16();
106         break;
107     }
108     return TRUE;
109 }
110
111 /***********************************************************************
112  *              EnableDos (KERNEL.41)
113  *              DisableDos (KERNEL.42)
114  *              GetLastDiskChange (KERNEL.98)
115  *              ValidateCodeSegments (KERNEL.100)
116  *              KbdRst (KERNEL.123)
117  *              EnableKernel (KERNEL.124)
118  *              DisableKernel (KERNEL.125)
119  *              ValidateFreeSpaces (KERNEL.200)
120  *              K237 (KERNEL.237)
121  *              BUNNY_351 (KERNEL.351)
122  *              PIGLET_361 (KERNEL.361)
123  *
124  * Entry point for kernel functions that do nothing.
125  */
126 LONG WINAPI KERNEL_nop(void)
127 {
128     return 0;
129 }