Fixed the displaying of the FOURCC codes in _dump_pixelformat.
[wine] / dlls / kernel / kernel_main.c
1 /*
2  * Kernel initialization code
3  */
4
5 #include <assert.h>
6
7 #include "winbase.h"
8 #include "wine/winbase16.h"
9
10 #include "neexe.h"
11 #include "module.h"
12 #include "task.h"
13 #include "comm.h"
14 #include "selectors.h"
15 #include "miscemu.h"
16 #include "global.h"
17
18 extern void CODEPAGE_Init(void);
19 extern BOOL THUNK_Init(void);
20
21
22 /***********************************************************************
23  *           KERNEL process initialisation routine
24  */
25 static BOOL process_attach(void)
26 {
27     HMODULE16 hModule;
28
29     /* Setup codepage info */
30     CODEPAGE_Init();
31
32     /* Initialize thunking */
33     if (!THUNK_Init()) return FALSE;
34
35     /* Initialize DOS memory */
36     if (!DOSMEM_Init(0)) return FALSE;
37
38     if ((hModule = LoadLibrary16( "krnl386.exe" )) < 32) return FALSE;
39
40     /* Initialize special KERNEL entry points */
41
42     /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
43     NE_SetEntryPoint( hModule, 178, GetWinFlags16() );
44
45     /* Initialize KERNEL.454/455 (__FLATCS/__FLATDS) */
46     NE_SetEntryPoint( hModule, 454, __get_cs() );
47     NE_SetEntryPoint( hModule, 455, __get_ds() );
48
49     /* Initialize KERNEL.THHOOK */
50     TASK_InstallTHHook((THHOOK *)PTR_SEG_TO_LIN((SEGPTR)NE_GetEntryPoint( hModule, 332 )));
51
52     /* Initialize the real-mode selector entry points */
53 #define SET_ENTRY_POINT( num, addr ) \
54     NE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
55                       DOSMEM_MapDosToLinear(addr), 0x10000, hModule, \
56                       FALSE, FALSE, FALSE ))
57
58     SET_ENTRY_POINT( 183, 0x00000 );  /* KERNEL.183: __0000H */
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, 173, DOSMEM_BiosSysSeg );  /* KERNEL.173: __ROMBIOS */
66     NE_SetEntryPoint( hModule, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
67     NE_SetEntryPoint( hModule, 194, DOSMEM_BiosSysSeg );  /* KERNEL.194: __F000H */
68 #undef SET_ENTRY_POINT
69
70     /* Force loading of some dlls */
71     if (LoadLibrary16( "system" ) < 32) return FALSE;
72     if (LoadLibrary16( "wprocs" ) < 32) return FALSE;
73
74     /* Initialize communications */
75     COMM_Init();
76
77     /* Read DOS config.sys */
78     if (!DOSCONF_ReadConfig()) return FALSE;
79
80     return TRUE;
81 }
82
83 /***********************************************************************
84  *           KERNEL initialisation routine
85  */
86 BOOL WINAPI MAIN_KernelInit( HINSTANCE hinst, DWORD reason, LPVOID reserved )
87 {
88     switch(reason)
89     {
90     case DLL_PROCESS_ATTACH:
91         return process_attach();
92     case DLL_PROCESS_DETACH:
93         WriteOutProfiles16();
94         break;
95     }
96     return TRUE;
97 }
98
99 /***********************************************************************
100  *              KERNEL_nop
101  *
102  * Entry point for kernel functions that do nothing.
103  */
104 LONG WINAPI KERNEL_nop(void) { return 0; }