2000-06-03 04:49:40 +00:00
|
|
|
/*
|
|
|
|
* Kernel initialization code
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* Copyright 2000 Alexandre Julliard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-06-03 04:49:40 +00:00
|
|
|
*/
|
|
|
|
|
2001-07-18 21:04:23 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-06-03 04:49:40 +00:00
|
|
|
#include <assert.h>
|
2000-10-17 00:27:47 +00:00
|
|
|
#include <ctype.h>
|
2001-01-26 20:43:40 +00:00
|
|
|
#include <string.h>
|
2002-03-29 18:17:35 +00:00
|
|
|
#include <sys/stat.h>
|
2000-06-03 04:49:40 +00:00
|
|
|
|
|
|
|
#include "winbase.h"
|
|
|
|
|
2001-07-18 21:04:23 +00:00
|
|
|
#include "wine/winbase16.h"
|
2002-05-16 20:32:16 +00:00
|
|
|
#include "wine/library.h"
|
2002-03-29 18:17:35 +00:00
|
|
|
#include "file.h"
|
2001-07-18 21:04:23 +00:00
|
|
|
#include "global.h"
|
|
|
|
#include "miscemu.h"
|
2000-06-03 04:49:40 +00:00
|
|
|
#include "module.h"
|
|
|
|
#include "task.h"
|
|
|
|
|
2000-07-11 22:08:43 +00:00
|
|
|
extern void CODEPAGE_Init(void);
|
2000-12-12 00:50:19 +00:00
|
|
|
extern BOOL RELAY_Init(void);
|
2000-07-25 16:42:25 +00:00
|
|
|
|
2000-06-03 04:49:40 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KERNEL process initialisation routine
|
|
|
|
*/
|
|
|
|
static BOOL process_attach(void)
|
|
|
|
{
|
|
|
|
HMODULE16 hModule;
|
|
|
|
|
2002-03-29 18:17:35 +00:00
|
|
|
/* Get the umask */
|
|
|
|
FILE_umask = umask(0777);
|
|
|
|
umask( FILE_umask );
|
|
|
|
|
2000-07-11 22:08:43 +00:00
|
|
|
/* Setup codepage info */
|
|
|
|
CODEPAGE_Init();
|
|
|
|
|
2000-12-12 00:50:19 +00:00
|
|
|
/* Initialize relay entry points */
|
|
|
|
if (!RELAY_Init()) return FALSE;
|
|
|
|
|
2000-06-03 04:49:40 +00:00
|
|
|
/* Initialize DOS memory */
|
|
|
|
if (!DOSMEM_Init(0)) return FALSE;
|
|
|
|
|
|
|
|
if ((hModule = LoadLibrary16( "krnl386.exe" )) < 32) return FALSE;
|
|
|
|
|
|
|
|
/* Initialize special KERNEL entry points */
|
|
|
|
|
|
|
|
/* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
|
|
|
|
NE_SetEntryPoint( hModule, 178, GetWinFlags16() );
|
|
|
|
|
|
|
|
/* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
|
2002-05-16 20:32:16 +00:00
|
|
|
NE_SetEntryPoint( hModule, 454, wine_get_cs() );
|
|
|
|
NE_SetEntryPoint( hModule, 455, wine_get_ds() );
|
2000-06-03 04:49:40 +00:00
|
|
|
|
|
|
|
/* Initialize KERNEL.THHOOK */
|
2000-12-13 20:20:09 +00:00
|
|
|
TASK_InstallTHHook(MapSL((SEGPTR)GetProcAddress16( hModule, (LPCSTR)332 )));
|
2000-06-03 04:49:40 +00:00
|
|
|
|
|
|
|
/* Initialize the real-mode selector entry points */
|
|
|
|
#define SET_ENTRY_POINT( num, addr ) \
|
|
|
|
NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
|
|
|
|
DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
|
2000-11-14 01:54:49 +00:00
|
|
|
WINE_LDT_FLAGS_DATA ))
|
2000-06-03 04:49:40 +00:00
|
|
|
|
|
|
|
SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
|
|
|
|
SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
|
|
|
|
SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
|
|
|
|
SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
|
|
|
|
SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
|
|
|
|
SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
|
2000-10-15 00:37:50 +00:00
|
|
|
NE_SetEntryPoint( hModule, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
|
2000-06-03 04:49:40 +00:00
|
|
|
NE_SetEntryPoint( hModule, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
|
|
|
|
NE_SetEntryPoint( hModule, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
|
|
|
|
NE_SetEntryPoint( hModule, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
|
|
|
|
#undef SET_ENTRY_POINT
|
|
|
|
|
|
|
|
/* Force loading of some dlls */
|
|
|
|
if (LoadLibrary16( "system" ) < 32) return FALSE;
|
|
|
|
|
2000-08-25 22:02:14 +00:00
|
|
|
/* Create 16-bit task */
|
2001-02-28 05:29:50 +00:00
|
|
|
TASK_CreateMainTask();
|
2000-08-25 22:02:14 +00:00
|
|
|
|
2001-03-04 01:06:07 +00:00
|
|
|
/* Create the shared heap for broken win95 native dlls */
|
|
|
|
HeapCreate( HEAP_SHARED, 0, 0 );
|
|
|
|
|
2000-06-03 04:49:40 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* KERNEL initialisation routine
|
|
|
|
*/
|
|
|
|
BOOL WINAPI MAIN_KernelInit( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
|
|
|
{
|
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2000-08-21 03:33:31 +00:00
|
|
|
return process_attach();
|
2000-06-03 04:49:40 +00:00
|
|
|
case DLL_PROCESS_DETACH:
|
2000-08-21 03:33:31 +00:00
|
|
|
WriteOutProfiles16();
|
2000-06-03 04:49:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-08-06 02:42:46 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* EnableDos (KERNEL.41)
|
|
|
|
* DisableDos (KERNEL.42)
|
|
|
|
* GetLastDiskChange (KERNEL.98)
|
|
|
|
* ValidateCodeSegments (KERNEL.100)
|
|
|
|
* KbdRst (KERNEL.123)
|
|
|
|
* EnableKernel (KERNEL.124)
|
|
|
|
* DisableKernel (KERNEL.125)
|
|
|
|
* ValidateFreeSpaces (KERNEL.200)
|
|
|
|
* K237 (KERNEL.237)
|
|
|
|
* BUNNY_351 (KERNEL.351)
|
|
|
|
* PIGLET_361 (KERNEL.361)
|
2000-08-06 02:42:46 +00:00
|
|
|
*
|
|
|
|
* Entry point for kernel functions that do nothing.
|
|
|
|
*/
|
2001-05-24 19:32:00 +00:00
|
|
|
LONG WINAPI KERNEL_nop(void)
|
2001-01-02 20:00:37 +00:00
|
|
|
{
|
2001-05-24 19:32:00 +00:00
|
|
|
return 0;
|
2001-01-02 20:00:37 +00:00
|
|
|
}
|