Removed obsolete INT_Int31Handler.
[wine/multimedia.git] / dlls / kernel / kernel_main.c
blobc549e1fee47b6bd3780bb7e01d82cb77463cd040
1 /*
2 * Kernel initialization code
4 * Copyright 2000 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <assert.h>
25 #include <ctype.h>
26 #include <string.h>
27 #include <sys/stat.h>
28 #include <signal.h>
30 #include "winbase.h"
31 #include "wincon.h"
32 #include "winternl.h"
34 #include "wine/winbase16.h"
35 #include "wine/library.h"
36 #include "file.h"
37 #include "global.h"
38 #include "miscemu.h"
39 #include "module.h"
40 #include "task.h"
41 #include "wincon.h"
42 #include "console_private.h"
44 extern void LOCALE_Init(void);
45 extern BOOL RELAY_Init(void);
46 extern void COMPUTERNAME_Init(void);
48 extern int __wine_set_signal_handler(unsigned, int (*)(unsigned));
50 extern int main_create_flags;
52 /***********************************************************************
53 * KERNEL process initialisation routine
55 static BOOL process_attach(void)
57 HMODULE16 hModule;
59 /* Get the umask */
60 FILE_umask = umask(0777);
61 umask( FILE_umask );
63 /* Setup codepage info */
64 LOCALE_Init();
66 /* Initialize relay entry points */
67 if (!RELAY_Init()) return FALSE;
69 /* Initialize DOS memory */
70 if (!DOSMEM_Init(0)) return FALSE;
72 /* Setup computer name */
73 COMPUTERNAME_Init();
75 if ((hModule = LoadLibrary16( "krnl386.exe" )) >= 32)
77 /* Initialize special KERNEL entry points */
79 /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
80 NE_SetEntryPoint( hModule, 178, GetWinFlags16() );
82 /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
83 NE_SetEntryPoint( hModule, 454, wine_get_cs() );
84 NE_SetEntryPoint( hModule, 455, wine_get_ds() );
86 /* Initialize KERNEL.THHOOK */
87 TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( hModule, (LPCSTR)332 )));
89 /* Initialize the real-mode selector entry points */
90 #define SET_ENTRY_POINT( num, addr ) \
91 NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
92 DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
93 WINE_LDT_FLAGS_DATA ))
95 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
96 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
97 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
98 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
99 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
100 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
101 NE_SetEntryPoint( hModule, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
102 NE_SetEntryPoint( hModule, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
103 NE_SetEntryPoint( hModule, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
104 NE_SetEntryPoint( hModule, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
105 #undef SET_ENTRY_POINT
108 /* Force loading of some dlls */
109 LoadLibrary16( "system" );
111 /* Create 16-bit task */
112 TASK_CreateMainTask();
114 /* Create the shared heap for broken win95 native dlls */
115 HeapCreate( HEAP_SHARED, 0, 0 );
117 /* finish the process initialisation for console bits, if needed */
118 __wine_set_signal_handler(SIGINT, CONSOLE_HandleCtrlC);
120 if (main_create_flags & CREATE_NEW_CONSOLE)
122 HMODULE mod = GetModuleHandleA(0);
123 if (RtlImageNtHeader(mod)->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
124 AllocConsole();
126 if (main_create_flags & CREATE_NEW_PROCESS_GROUP)
127 SetConsoleCtrlHandler(NULL, TRUE);
129 return TRUE;
132 /***********************************************************************
133 * KERNEL initialisation routine
135 BOOL WINAPI MAIN_KernelInit( HINSTANCE hinst, DWORD reason, LPVOID reserved )
137 switch(reason)
139 case DLL_PROCESS_ATTACH:
140 return process_attach();
141 case DLL_PROCESS_DETACH:
142 WriteOutProfiles16();
143 break;
145 return TRUE;
148 /***********************************************************************
149 * EnableDos (KERNEL.41)
150 * DisableDos (KERNEL.42)
151 * GetLastDiskChange (KERNEL.98)
152 * ValidateCodeSegments (KERNEL.100)
153 * KbdRst (KERNEL.123)
154 * EnableKernel (KERNEL.124)
155 * DisableKernel (KERNEL.125)
156 * ValidateFreeSpaces (KERNEL.200)
157 * K237 (KERNEL.237)
158 * BUNNY_351 (KERNEL.351)
159 * PIGLET_361 (KERNEL.361)
161 * Entry point for kernel functions that do nothing.
163 LONG WINAPI KERNEL_nop(void)
165 return 0;
168 /***********************************************************************
169 * SwitchToThread (KERNEL32.@)
172 BOOL WINAPI SwitchToThread(void)
174 Sleep(0);
175 return 1;