2 * 16-bit 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "kernel_private.h"
30 #include "kernel16_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(kernel);
35 /**************************************************************************
36 * DllEntryPoint (KERNEL.669)
38 BOOL WINAPI KERNEL_DllEntryPoint( DWORD reasion, HINSTANCE16 inst, WORD ds,
39 WORD heap, DWORD reserved1, WORD reserved2 )
43 /* the entry point can be called multiple times */
44 if (done) return TRUE;
47 /* Initialize 16-bit thunking entry points */
48 if (!WOWTHUNK_Init()) return FALSE;
50 /* Initialize DOS memory */
51 if (!DOSMEM_Init()) return FALSE;
53 /* Initialize special KERNEL entry points */
55 NE_SetEntryPoint( inst, 178, GetWinFlags16() );
57 NE_SetEntryPoint( inst, 454, wine_get_cs() );
58 NE_SetEntryPoint( inst, 455, wine_get_ds() );
60 NE_SetEntryPoint( inst, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
61 NE_SetEntryPoint( inst, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
62 NE_SetEntryPoint( inst, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
63 NE_SetEntryPoint( inst, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
65 /* Initialize KERNEL.THHOOK */
66 TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( inst, (LPCSTR)332 )));
68 /* Initialize the real-mode selector entry points */
69 #define SET_ENTRY_POINT( num, addr ) \
70 NE_SetEntryPoint( inst, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
71 DOSMEM_MapDosToLinear(addr), 0x10000, inst, \
72 WINE_LDT_FLAGS_DATA ))
74 SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
75 SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
76 SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
77 SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
78 SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
79 SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
80 #undef SET_ENTRY_POINT
82 /* Force loading of some dlls */
83 LoadLibrary16( "system.drv" );
88 /***********************************************************************
89 * EnableDos (KERNEL.41)
90 * DisableDos (KERNEL.42)
91 * GetLastDiskChange (KERNEL.98)
92 * ValidateCodeSegments (KERNEL.100)
94 * EnableKernel (KERNEL.124)
95 * DisableKernel (KERNEL.125)
96 * ValidateFreeSpaces (KERNEL.200)
98 * BUNNY_351 (KERNEL.351)
99 * PIGLET_361 (KERNEL.361)
101 * Entry point for kernel functions that do nothing.
103 LONG WINAPI KERNEL_nop(void)
109 /* thunk for 16-bit CreateThread */
116 static DWORD CALLBACK start_thread16( LPVOID threadArgs )
118 struct thread_args args = *(struct thread_args *)threadArgs;
119 HeapFree( GetProcessHeap(), 0, threadArgs );
120 return K32WOWCallback16( (DWORD)args.proc, args.param );
123 /***********************************************************************
124 * CreateThread16 (KERNEL.441)
126 HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
127 FARPROC16 start, SEGPTR param,
128 DWORD flags, LPDWORD id )
130 struct thread_args *args = HeapAlloc( GetProcessHeap(), 0, sizeof(*args) );
131 if (!args) return INVALID_HANDLE_VALUE;
134 return CreateThread( sa, stack, start_thread16, args, flags, id );