Commit 1acb481d authored by Alexandre Julliard's avatar Alexandre Julliard

krnl386: Avoid using the selector functions from libwine.

parent 9d588819
......@@ -113,8 +113,8 @@ BOOL WINAPI KERNEL_DllEntryPoint( DWORD reasion, HINSTANCE16 inst, WORD ds,
NE_SetEntryPoint( inst, 178, GetWinFlags16() );
NE_SetEntryPoint( inst, 454, wine_get_cs() );
NE_SetEntryPoint( inst, 455, wine_get_ds() );
NE_SetEntryPoint( inst, 454, get_cs() );
NE_SetEntryPoint( inst, 455, get_ds() );
NE_SetEntryPoint( inst, 183, DOSMEM_0000H ); /* KERNEL.183: __0000H */
NE_SetEntryPoint( inst, 173, DOSMEM_BiosSysSeg ); /* KERNEL.173: __ROMBIOS */
......
......@@ -261,6 +261,11 @@ extern void SELECTOR_FreeBlock( WORD sel ) DECLSPEC_HIDDEN;
#define IS_SELECTOR_32BIT(sel) \
(ldt_is_system(sel) || (ldt_copy->flags[LOWORD(sel) >> 3] & LDT_FLAGS_32BIT))
static inline WORD get_cs(void) { WORD res; __asm__( "movw %%cs,%0" : "=r" (res) ); return res; }
static inline WORD get_ds(void) { WORD res; __asm__( "movw %%ds,%0" : "=r" (res) ); return res; }
static inline WORD get_fs(void) { WORD res; __asm__( "movw %%fs,%0" : "=r" (res) ); return res; }
static inline WORD get_gs(void) { WORD res; __asm__( "movw %%gs,%0" : "=r" (res) ); return res; }
/* relay16.c */
extern int relay_call_from_16( void *entry_point, unsigned char *args16, CONTEXT *context ) DECLSPEC_HIDDEN;
extern void RELAY16_InitDebugLists(void) DECLSPEC_HIDDEN;
......
......@@ -95,7 +95,7 @@ static inline void patch_code_segment( NE_MODULE *pModule )
call[i].glue = __wine_call_from_16_regs;
else
call[i].glue = __wine_call_from_16;
call[i].flatcs = wine_get_cs();
call[i].flatcs = get_cs();
}
if (TRACE_ON(relay)) /* patch relay functions to all point to relay_call_from_16 */
......
......@@ -725,6 +725,6 @@ void DOSVM_BuildCallFrame( CONTEXT *context, DOSRELAY relay, LPVOID data )
/*
* Adjust code pointer.
*/
context->SegCs = wine_get_cs();
context->SegCs = get_cs();
context->Eip = (DWORD)__wine_call_from_16_regs;
}
......@@ -72,8 +72,8 @@ static LDT_ENTRY ldt_make_entry( const void *base, unsigned int limit, unsigned
*/
void init_selectors(void)
{
if (!is_gdt_sel( wine_get_gs() )) first_ldt_entry += 512;
if (!is_gdt_sel( wine_get_fs() )) first_ldt_entry += 512;
if (!is_gdt_sel( get_gs() )) first_ldt_entry += 512;
if (!is_gdt_sel( get_fs() )) first_ldt_entry += 512;
RtlSetBits( &ldt_bitmap, 0, first_ldt_entry );
ldt_copy = (void *)GetProcAddress( GetModuleHandleA("ntdll.dll"), "__wine_ldt_copy" );
}
......
......@@ -116,7 +116,7 @@ SNOOP16_RegisterDLL(HMODULE16 hModule,LPCSTR name) {
snr[0].realfun = (DWORD)SNOOP16_Entry;
snr[0].lcall = 0x9a;
snr[0].callfromregs = (DWORD)__wine_call_from_16_regs;
snr[0].seg = wine_get_cs();
snr[0].seg = get_cs();
snr[0].lret = 0xcb66;
snr[1].pushbp = 0x5566;
......@@ -126,7 +126,7 @@ SNOOP16_RegisterDLL(HMODULE16 hModule,LPCSTR name) {
snr[1].realfun = (DWORD)SNOOP16_Return;
snr[1].lcall = 0x9a;
snr[1].callfromregs = (DWORD)__wine_call_from_16_regs;
snr[1].seg = wine_get_cs();
snr[1].seg = get_cs();
snr[1].lret = 0xcb66;
}
while (*dll) {
......
......@@ -108,7 +108,7 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock)
TRACE("(%p, level %d): thread %x count after %d\n",
lock, lock->level, GetCurrentThreadId(), thread_data->sys_count[lock->level] );
if (lock == &Win16Mutex) CallTo16_TebSelector = wine_get_fs();
if (lock == &Win16Mutex) CallTo16_TebSelector = get_fs();
}
/************************************************************************
......
......@@ -1168,7 +1168,7 @@ DEFINE_REGS_ENTRYPOINT( FreeMappedBuffer )
*/
void WINAPI GetTEBSelectorFS16(void)
{
CURRENT_STACK16->fs = wine_get_fs();
CURRENT_STACK16->fs = get_fs();
}
/**********************************************************************
......@@ -1421,8 +1421,6 @@ UINT WINAPI ThunkConnect16(
void WINAPI C16ThkSL(CONTEXT *context)
{
LPBYTE stub = MapSL(context->Eax), x = stub;
WORD cs = wine_get_cs();
WORD ds = wine_get_ds();
/* We produce the following code:
*
......@@ -1437,7 +1435,7 @@ void WINAPI C16ThkSL(CONTEXT *context)
* call __FLATCS:__wine_call_from_16_thunk
*/
*x++ = 0xB8; *(WORD *)x = ds; x += sizeof(WORD);
*x++ = 0xB8; *(WORD *)x = get_ds(); x += sizeof(WORD);
*x++ = 0x8E; *x++ = 0xC0;
*x++ = 0x66; *x++ = 0x0F; *x++ = 0xB7; *x++ = 0xC9;
*x++ = 0x67; *x++ = 0x66; *x++ = 0x26; *x++ = 0x8B;
......@@ -1449,7 +1447,7 @@ void WINAPI C16ThkSL(CONTEXT *context)
*x++ = 0x66; *x++ = 0x52;
*x++ = 0x66; *x++ = 0x9A;
*(void **)x = __wine_call_from_16_thunk; x += sizeof(void *);
*(WORD *)x = cs; x += sizeof(WORD);
*(WORD *)x = get_cs(); x += sizeof(WORD);
/* Jump to the stub code just created */
context->Eip = LOWORD(context->Eax);
......@@ -1474,7 +1472,6 @@ void WINAPI C16ThkSL01(CONTEXT *context)
struct ThunkDataSL *td = SL16->fpData;
DWORD procAddress = (DWORD)GetProcAddress16(GetModuleHandle16("KERNEL"), (LPCSTR)631);
WORD cs = wine_get_cs();
if (!td)
{
......@@ -1507,7 +1504,7 @@ void WINAPI C16ThkSL01(CONTEXT *context)
*x++ = 0x66; *x++ = 0x52;
*x++ = 0x66; *x++ = 0x9A;
*(void **)x = __wine_call_from_16_thunk; x += sizeof(void *);
*(WORD *)x = cs; x += sizeof(WORD);
*(WORD *)x = get_cs(); x += sizeof(WORD);
/* Jump to the stub code just created */
context->Eip = LOWORD(context->Eax);
......@@ -1979,7 +1976,7 @@ void WINAPI CBClientThunkSL( CONTEXT *context )
SEGPTR stack = stack16_push( 12 );
LPWORD stackLin = MapSL(stack);
/* stackLin[0] and stackLin[1] reserved for the 32-bit stack ptr */
stackLin[2] = wine_get_ss();
stackLin[2] = get_ds();
stackLin[3] = 0;
stackLin[4] = OFFSETOF(stack) + 12;
stackLin[5] = SELECTOROF(stack);
......@@ -2007,10 +2004,10 @@ void WINAPI CBClientThunkSLEx( CONTEXT *context )
stackLin = MapSL(stack);
stackLin[0] = OFFSETOF(stack) + 4;
stackLin[1] = SELECTOROF(stack);
stackLin[2] = wine_get_ds();
stackLin[2] = get_ds();
stackLin[5] = OFFSETOF(stack) + 24;
/* stackLin[6] and stackLin[7] reserved for the 32-bit stack ptr */
stackLin[8] = wine_get_ss();
stackLin[8] = get_ds();
stackLin[9] = 0;
stackLin[10] = OFFSETOF(CALL32_CBClientEx_RetAddr);
stackLin[11] = SELECTOROF(CALL32_CBClientEx_RetAddr);
......@@ -2065,7 +2062,7 @@ SEGPTR WINAPI Get16DLLAddress(HMODULE16 handle, LPSTR func_name)
*thunk++ = 0xea;
*(void **)thunk = QT_Thunk;
thunk += sizeof(FARPROC16);
*(WORD *)thunk = wine_get_cs();
*(WORD *)thunk = get_cs();
return MAKESEGPTR( code_sel32, (char *)thunk - (char *)ThunkletHeap );
}
......
......@@ -64,7 +64,7 @@ BOOL WOWTHUNK_Init(void)
/* Patch the return addresses for CallTo16 routines */
CallTo16_DataSelector = wine_get_ds();
CallTo16_DataSelector = get_ds();
call16_ret_addr = MAKESEGPTR( codesel, (BYTE *)__wine_call_to_16_ret - __wine_call16_start );
CALL32_CBClient_RetAddr =
MAKESEGPTR( codesel, (BYTE *)CALL32_CBClient_Ret - __wine_call16_start );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment