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);
23 extern void COMM_Init(void);
26 /***********************************************************************
27 * KERNEL process initialisation routine
29 static BOOL process_attach(void)
33 /* Setup codepage info */
36 /* Initialize relay entry points */
37 if (!RELAY_Init()) return FALSE;
39 /* Initialize thunking */
40 if (!THUNK_Init()) return FALSE;
42 /* Initialize DOS memory */
43 if (!DOSMEM_Init(0)) return FALSE;
45 if ((hModule = LoadLibrary16( "krnl386.exe" )) < 32) return FALSE;
47 /* Initialize special KERNEL entry points */
49 /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
50 NE_SetEntryPoint( hModule, 178, GetWinFlags16() );
52 /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
53 NE_SetEntryPoint( hModule, 454, __get_cs() );
54 NE_SetEntryPoint( hModule, 455, __get_ds() );
56 /* Initialize KERNEL.THHOOK */
57 TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( hModule, (LPCSTR)332 )));
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 ))
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
77 /* Force loading of some dlls */
78 if (LoadLibrary16( "system" ) < 32) return FALSE;
80 /* Initialize communications */
83 /* Read DOS config.sys */
84 if (!DOSCONF_ReadConfig()) return FALSE;
86 /* Create 16-bit task */
87 TASK_CreateMainTask();
89 /* Create the shared heap for broken win95 native dlls */
90 HeapCreate( HEAP_SHARED, 0, 0 );
95 /***********************************************************************
96 * KERNEL initialisation routine
98 BOOL WINAPI MAIN_KernelInit( HINSTANCE hinst, DWORD reason, LPVOID reserved )
102 case DLL_PROCESS_ATTACH:
103 return process_attach();
104 case DLL_PROCESS_DETACH:
105 WriteOutProfiles16();
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)
121 * BUNNY_351 (KERNEL.351)
122 * PIGLET_361 (KERNEL.361)
124 * Entry point for kernel functions that do nothing.
126 LONG WINAPI KERNEL_nop(void)