2 * Kernel initialization code
13 #include "wine/winbase16.h"
19 extern void CODEPAGE_Init(void);
20 extern BOOL RELAY_Init(void);
23 /***********************************************************************
24 * KERNEL process initialisation routine
26 static BOOL process_attach(void)
30 /* Setup codepage info */
33 /* Initialize relay entry points */
34 if (!RELAY_Init()) return FALSE;
36 /* Initialize DOS memory */
37 if (!DOSMEM_Init(0)) return FALSE;
39 if ((hModule = LoadLibrary16( "krnl386.exe" )) < 32) return FALSE;
41 /* Initialize special KERNEL entry points */
43 /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
44 NE_SetEntryPoint( hModule, 178, GetWinFlags16() );
46 /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
47 NE_SetEntryPoint( hModule, 454, __get_cs() );
48 NE_SetEntryPoint( hModule, 455, __get_ds() );
50 /* Initialize KERNEL.THHOOK */
51 TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( hModule, (LPCSTR)332 )));
53 /* Initialize the real-mode selector entry points */
54 #define SET_ENTRY_POINT( num, addr ) \
55 NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
56 DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
57 WINE_LDT_FLAGS_DATA ))
59 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
60 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
61 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
62 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
63 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
64 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
65 NE_SetEntryPoint( hModule, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
66 NE_SetEntryPoint( hModule, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
67 NE_SetEntryPoint( hModule, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
68 NE_SetEntryPoint( hModule, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
69 #undef SET_ENTRY_POINT
71 /* Force loading of some dlls */
72 if (LoadLibrary16( "system" ) < 32) return FALSE;
74 /* Create 16-bit task */
75 TASK_CreateMainTask();
77 /* Create the shared heap for broken win95 native dlls */
78 HeapCreate( HEAP_SHARED, 0, 0 );
83 /***********************************************************************
84 * KERNEL initialisation routine
86 BOOL WINAPI MAIN_KernelInit( HINSTANCE hinst, DWORD reason, LPVOID reserved )
90 case DLL_PROCESS_ATTACH:
91 return process_attach();
92 case DLL_PROCESS_DETACH:
99 /***********************************************************************
100 * EnableDos (KERNEL.41)
101 * DisableDos (KERNEL.42)
102 * GetLastDiskChange (KERNEL.98)
103 * ValidateCodeSegments (KERNEL.100)
104 * KbdRst (KERNEL.123)
105 * EnableKernel (KERNEL.124)
106 * DisableKernel (KERNEL.125)
107 * ValidateFreeSpaces (KERNEL.200)
109 * BUNNY_351 (KERNEL.351)
110 * PIGLET_361 (KERNEL.361)
112 * Entry point for kernel functions that do nothing.
114 LONG WINAPI KERNEL_nop(void)