2 * Kernel initialization code
8 #include "wine/winbase16.h"
14 #include "selectors.h"
19 /***********************************************************************
20 * KERNEL process initialisation routine
22 static BOOL process_attach(void)
26 /* Initialize DOS memory */
27 if (!DOSMEM_Init(0)) return FALSE;
29 if ((hModule = LoadLibrary16( "krnl386.exe" )) < 32) return FALSE;
31 /* Initialize special KERNEL entry points */
33 /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
34 NE_SetEntryPoint( hModule, 178, GetWinFlags16() );
36 /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
37 NE_SetEntryPoint( hModule, 454, __get_cs() );
38 NE_SetEntryPoint( hModule, 455, __get_ds() );
40 /* Initialize KERNEL.THHOOK */
41 TASK_InstallTHHook((THHOOK *)PTR_SEG_TO_LIN((SEGPTR)NE_GetEntryPoint( hModule, 332 )));
43 /* Initialize the real-mode selector entry points */
44 #define SET_ENTRY_POINT( num, addr ) \
45 NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
46 DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
47 FALSE, FALSE, FALSE, NULL ))
49 SET_ENTRY_POINT( 183, 0x00000 ); /* KERNEL.183: __0000H */
50 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
51 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
52 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
53 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
54 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
55 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
56 NE_SetEntryPoint( hModule, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
57 NE_SetEntryPoint( hModule, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
58 NE_SetEntryPoint( hModule, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
59 #undef SET_ENTRY_POINT
61 /* Force loading of some dlls */
62 if (LoadLibrary16( "system" ) < 32) return FALSE;
63 if (LoadLibrary16( "wprocs" ) < 32) return FALSE;
65 /* Initialize communications */
68 /* Read DOS config.sys */
69 if (!DOSCONF_ReadConfig()) return FALSE;
74 /***********************************************************************
75 * KERNEL initialisation routine
77 BOOL WINAPI MAIN_KernelInit( HINSTANCE hinst, DWORD reason, LPVOID reserved )
79 static int process_count;
83 case DLL_PROCESS_ATTACH:
84 if (!process_count++) return process_attach();
86 case DLL_PROCESS_DETACH: