2 * Kernel initialization code
13 #include "wine/winbase16.h"
20 extern void CODEPAGE_Init(void);
21 extern BOOL RELAY_Init(void);
22 extern BOOL THUNK_Init(void);
25 /***********************************************************************
26 * KERNEL process initialisation routine
28 static BOOL process_attach(void)
32 /* Setup codepage info */
35 /* Initialize relay entry points */
36 if (!RELAY_Init()) return FALSE;
38 /* Initialize thunking */
39 if (!THUNK_Init()) return FALSE;
41 /* Initialize DOS memory */
42 if (!DOSMEM_Init(0)) return FALSE;
44 if ((hModule = LoadLibrary16( "krnl386.exe" )) < 32) return FALSE;
46 /* Initialize special KERNEL entry points */
48 /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
49 NE_SetEntryPoint( hModule, 178, GetWinFlags16() );
51 /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
52 NE_SetEntryPoint( hModule, 454, __get_cs() );
53 NE_SetEntryPoint( hModule, 455, __get_ds() );
55 /* Initialize KERNEL.THHOOK */
56 TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( hModule, (LPCSTR)332 )));
58 /* Initialize the real-mode selector entry points */
59 #define SET_ENTRY_POINT( num, addr ) \
60 NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
61 DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
62 WINE_LDT_FLAGS_DATA ))
64 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
65 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
66 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
67 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
68 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
69 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
70 NE_SetEntryPoint( hModule, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
71 NE_SetEntryPoint( hModule, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
72 NE_SetEntryPoint( hModule, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
73 NE_SetEntryPoint( hModule, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
74 #undef SET_ENTRY_POINT
76 /* Force loading of some dlls */
77 if (LoadLibrary16( "system" ) < 32) return FALSE;
79 /* Read DOS config.sys */
80 if (!DOSCONF_ReadConfig()) return FALSE;
82 /* Create 16-bit task */
83 TASK_CreateMainTask();
85 /* Create the shared heap for broken win95 native dlls */
86 HeapCreate( HEAP_SHARED, 0, 0 );
91 /***********************************************************************
92 * KERNEL initialisation routine
94 BOOL WINAPI MAIN_KernelInit( HINSTANCE hinst, DWORD reason, LPVOID reserved )
98 case DLL_PROCESS_ATTACH:
99 return process_attach();
100 case DLL_PROCESS_DETACH:
101 WriteOutProfiles16();
107 /***********************************************************************
108 * EnableDos (KERNEL.41)
109 * DisableDos (KERNEL.42)
110 * GetLastDiskChange (KERNEL.98)
111 * ValidateCodeSegments (KERNEL.100)
112 * KbdRst (KERNEL.123)
113 * EnableKernel (KERNEL.124)
114 * DisableKernel (KERNEL.125)
115 * ValidateFreeSpaces (KERNEL.200)
117 * BUNNY_351 (KERNEL.351)
118 * PIGLET_361 (KERNEL.361)
120 * Entry point for kernel functions that do nothing.
122 LONG WINAPI KERNEL_nop(void)