/*1* Relay calls helper routines2*3* Copyright 1993 Robert J. Amstadt4* Copyright 1995 Martin von Loewis5* Copyright 1995, 1996, 1997 Alexandre Julliard6* Copyright 1997 Eric Youngdale7* Copyright 1999 Ulrich Weigand8*9* This library is free software; you can redistribute it and/or10* modify it under the terms of the GNU Lesser General Public11* License as published by the Free Software Foundation; either12* version 2.1 of the License, or (at your option) any later version.13*14* This library is distributed in the hope that it will be useful,15* but WITHOUT ANY WARRANTY; without even the implied warranty of16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU17* Lesser General Public License for more details.18*19* You should have received a copy of the GNU Lesser General Public20* License along with this library; if not, write to the Free Software21* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA22*/2324#include "config.h"2526#include <ctype.h>27#include <stdarg.h>2829#include "build.h"3031/* offset of the stack pointer relative to %fs:(0) */32#define STACKOFFSET 0x10c /* FIELD_OFFSET(TEB,SystemReserved1) */3334/* fix this if the x86_thread_data structure is changed */35#define GS_OFFSET 0x1d8 /* FIELD_OFFSET(TEB,SystemReserved2) + FIELD_OFFSET(struct x86_thread_data,gs) */363738/*******************************************************************39* BuildCallFrom16Core40*41* This routine builds the core routines used in 16->32 thunks:42* CallFrom16Word, CallFrom16Long, CallFrom16Register, and CallFrom16Thunk.43*44* These routines are intended to be called via a far call (with 32-bit45* operand size) from 16-bit code. The 16-bit code stub must push %bp,46* the 32-bit entry point to be called, and the argument conversion47* routine to be used (see stack layout below).48*49* The core routine completes the STACK16FRAME on the 16-bit stack and50* switches to the 32-bit stack. Then, the argument conversion routine51* is called; it gets passed the 32-bit entry point and a pointer to the52* 16-bit arguments (on the 16-bit stack) as parameters. (You can either53* use conversion routines automatically generated by BuildCallFrom16,54* or write your own for special purposes.)55*56* The conversion routine must call the 32-bit entry point, passing it57* the converted arguments, and return its return value to the core.58* After the conversion routine has returned, the core switches back59* to the 16-bit stack, converts the return value to the DX:AX format60* (CallFrom16Long), and returns to the 16-bit call stub. All parameters,61* including %bp, are popped off the stack.62*63* The 16-bit call stub now returns to the caller, popping the 16-bit64* arguments if necessary (pascal calling convention).65*66* In the case of a 'register' function, CallFrom16Register fills a67* CONTEXT86 structure with the values all registers had at the point68* the first instruction of the 16-bit call stub was about to be69* executed. A pointer to this CONTEXT86 is passed as third parameter70* to the argument conversion routine, which typically passes it on71* to the called 32-bit entry point.72*73* CallFrom16Thunk is a special variant used by the implementation of74* the Win95 16->32 thunk functions C16ThkSL and C16ThkSL01 and is75* implemented as follows:76* On entry, the EBX register is set up to contain a flat pointer to the77* 16-bit stack such that EBX+22 points to the first argument.78* Then, the entry point is called, while EBP is set up to point79* to the return address (on the 32-bit stack).80* The called function returns with CX set to the number of bytes81* to be popped of the caller's stack.82*83* Stack layout upon entry to the core routine (STACK16FRAME):84* ... ...85* (sp+24) word first 16-bit arg86* (sp+22) word cs87* (sp+20) word ip88* (sp+18) word bp89* (sp+14) long 32-bit entry point (reused for Win16 mutex recursion count)90* (sp+12) word ip of actual entry point (necessary for relay debugging)91* (sp+8) long relay (argument conversion) function entry point92* (sp+4) long cs of 16-bit entry point93* (sp) long ip of 16-bit entry point94*95* Added on the stack:96* (sp-2) word saved gs97* (sp-4) word saved fs98* (sp-6) word saved es99* (sp-8) word saved ds100* (sp-12) long saved ebp101* (sp-16) long saved ecx102* (sp-20) long saved edx103* (sp-24) long saved previous stack104*/105static void BuildCallFrom16Core( int reg_func, int thunk )106{107/* Function header */108if (thunk) output_function_header( "__wine_call_from_16_thunk", 1 );109else if (reg_func) output_function_header( "__wine_call_from_16_regs", 1 );110else output_function_header( "__wine_call_from_16", 1 );111112/* Create STACK16FRAME (except STACK32FRAME link) */113output( "\tpushw %%gs\n" );114output( "\tpushw %%fs\n" );115output( "\tpushw %%es\n" );116output( "\tpushw %%ds\n" );117output( "\tpushl %%ebp\n" );118output( "\tpushl %%ecx\n" );119output( "\tpushl %%edx\n" );120121/* Save original EFlags register */122if (reg_func) output( "\tpushfl\n" );123124if ( UsePIC )125{126output( "\tcall 1f\n" );127output( "1:\tpopl %%ecx\n" );128output( "\tmovl %%cs:%s-1b(%%ecx),%%edx\n", asm_name("CallTo16_DataSelector") );129}130else131output( "\tmovl %%cs:%s,%%edx\n", asm_name("CallTo16_DataSelector") );132133/* Load 32-bit segment registers */134output( "\tmovw %%dx, %%ds\n" );135output( "\tmovw %%dx, %%es\n" );136137if ( UsePIC )138output( "\tmovw %s-1b(%%ecx), %%fs\n", asm_name("CallTo16_TebSelector") );139else140output( "\tmovw %s, %%fs\n", asm_name("CallTo16_TebSelector") );141142output( "\tmov %%fs:(%d),%%gs\n", GS_OFFSET );143144/* Translate STACK16FRAME base to flat offset in %edx */145output( "\tmovw %%ss, %%dx\n" );146output( "\tandl $0xfff8, %%edx\n" );147output( "\tshrl $1, %%edx\n" );148if (UsePIC)149output( "\taddl .Lwine_ldt_copy_ptr-1b(%%ecx),%%edx\n" );150else151output( "\taddl .Lwine_ldt_copy_ptr,%%edx\n" );152output( "\tmovl (%%edx), %%edx\n" );153output( "\tmovzwl %%sp, %%ebp\n" );154output( "\tleal %d(%%ebp,%%edx), %%edx\n", reg_func ? 0 : -4 );155156/* Get saved flags into %ecx */157if (reg_func) output( "\tpopl %%ecx\n" );158159/* Get the 32-bit stack pointer from the TEB and complete STACK16FRAME */160output( "\tmovl %%fs:(%d), %%ebp\n", STACKOFFSET );161output( "\tpushl %%ebp\n" );162163/* Switch stacks */164output( "\tmovw %%ss, %%fs:(%d)\n", STACKOFFSET + 2 );165output( "\tmovw %%sp, %%fs:(%d)\n", STACKOFFSET );166output( "\tpushl %%ds\n" );167output( "\tpopl %%ss\n" );168output( "\tmovl %%ebp, %%esp\n" );169output( "\taddl $0x20,%%ebp\n"); /* FIELD_OFFSET(STACK32FRAME,ebp) */170171172/* At this point:173STACK16FRAME is completely set up174DS, ES, SS: flat data segment175FS: current TEB176ESP: points to last STACK32FRAME177EBP: points to ebp member of last STACK32FRAME178EDX: points to current STACK16FRAME179ECX: contains saved flags180all other registers: unchanged */181182/* Special case: C16ThkSL stub */183if ( thunk )184{185/* Set up registers as expected and call thunk */186output( "\tleal 0x1a(%%edx),%%ebx\n" ); /* sizeof(STACK16FRAME)-22 */187output( "\tleal -4(%%esp), %%ebp\n" );188189output( "\tcall *0x26(%%edx)\n"); /* FIELD_OFFSET(STACK16FRAME,entry_point) */190191/* Switch stack back */192output( "\tmovw %%fs:(%d), %%ss\n", STACKOFFSET+2 );193output( "\tmovzwl %%fs:(%d), %%esp\n", STACKOFFSET );194output( "\tpopl %%fs:(%d)\n", STACKOFFSET );195196/* Restore registers and return directly to caller */197output( "\taddl $8, %%esp\n" );198output( "\tpopl %%ebp\n" );199output( "\tpopw %%ds\n" );200output( "\tpopw %%es\n" );201output( "\tpopw %%fs\n" );202output( "\tpopw %%gs\n" );203output( "\taddl $20, %%esp\n" );204205output( "\txorb %%ch, %%ch\n" );206output( "\tpopl %%ebx\n" );207output( "\taddw %%cx, %%sp\n" );208output( "\tpush %%ebx\n" );209210output( "\t.byte 0x66\n" );211output( "\tlret\n" );212213output_function_size( "__wine_call_from_16_thunk" );214return;215}216217218/* Build register CONTEXT */219if ( reg_func )220{221output( "\tsubl $0x2cc,%%esp\n" ); /* sizeof(CONTEXT86) */222223output( "\tmovl %%ecx,0xc0(%%esp)\n" ); /* EFlags */224225output( "\tmovl %%eax,0xb0(%%esp)\n" ); /* Eax */226output( "\tmovl %%ebx,0xa4(%%esp)\n" ); /* Ebx */227output( "\tmovl %%esi,0xa0(%%esp)\n" ); /* Esi */228output( "\tmovl %%edi,0x9c(%%esp)\n" ); /* Edi */229230output( "\tmovl 0x0c(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ebp) */231output( "\tmovl %%eax,0xb4(%%esp)\n" ); /* Ebp */232output( "\tmovl 0x08(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ecx) */233output( "\tmovl %%eax,0xac(%%esp)\n" ); /* Ecx */234output( "\tmovl 0x04(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,edx) */235output( "\tmovl %%eax,0xa8(%%esp)\n" ); /* Edx */236237output( "\tmovzwl 0x10(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ds) */238output( "\tmovl %%eax,0x98(%%esp)\n" ); /* SegDs */239output( "\tmovzwl 0x12(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,es) */240output( "\tmovl %%eax,0x94(%%esp)\n" ); /* SegEs */241output( "\tmovzwl 0x14(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,fs) */242output( "\tmovl %%eax,0x90(%%esp)\n" ); /* SegFs */243output( "\tmovzwl 0x16(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,gs) */244output( "\tmovl %%eax,0x8c(%%esp)\n" ); /* SegGs */245246output( "\tmovzwl 0x2e(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,cs) */247output( "\tmovl %%eax,0xbc(%%esp)\n" ); /* SegCs */248output( "\tmovzwl 0x2c(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ip) */249output( "\tmovl %%eax,0xb8(%%esp)\n" ); /* Eip */250251output( "\tmovzwl %%fs:(%d), %%eax\n", STACKOFFSET+2 );252output( "\tmovl %%eax,0xc8(%%esp)\n" ); /* SegSs */253output( "\tmovzwl %%fs:(%d), %%eax\n", STACKOFFSET );254output( "\taddl $0x2c,%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ip) */255output( "\tmovl %%eax,0xc4(%%esp)\n" ); /* Esp */256#if 0257output( "\tfsave 0x1c(%%esp)\n" ); /* FloatSave */258#endif259260/* Push address of CONTEXT86 structure -- popped by the relay routine */261output( "\tmovl %%esp,%%eax\n" );262output( "\tandl $~15,%%esp\n" );263output( "\tsubl $4,%%esp\n" );264output( "\tpushl %%eax\n" );265}266else267{268output( "\tsubl $8,%%esp\n" );269output( "\tandl $~15,%%esp\n" );270output( "\taddl $8,%%esp\n" );271}272273/* Call relay routine (which will call the API entry point) */274output( "\tleal 0x30(%%edx),%%eax\n" ); /* sizeof(STACK16FRAME) */275output( "\tpushl %%eax\n" );276output( "\tpushl 0x26(%%edx)\n"); /* FIELD_OFFSET(STACK16FRAME,entry_point) */277output( "\tcall *0x20(%%edx)\n"); /* FIELD_OFFSET(STACK16FRAME,relay) */278279if ( reg_func )280{281output( "\tleal -748(%%ebp),%%ebx\n" ); /* sizeof(CONTEXT) + FIELD_OFFSET(STACK32FRAME,ebp) */282283/* Switch stack back */284output( "\tmovw %%fs:(%d), %%ss\n", STACKOFFSET+2 );285output( "\tmovzwl %%fs:(%d), %%esp\n", STACKOFFSET );286output( "\tpopl %%fs:(%d)\n", STACKOFFSET );287288/* Get return address to CallFrom16 stub */289output( "\taddw $0x14,%%sp\n" ); /* FIELD_OFFSET(STACK16FRAME,callfrom_ip)-4 */290output( "\tpopl %%eax\n" );291output( "\tpopl %%edx\n" );292293/* Restore all registers from CONTEXT */294output( "\tmovw 0xc8(%%ebx),%%ss\n"); /* SegSs */295output( "\tmovl 0xc4(%%ebx),%%esp\n"); /* Esp */296output( "\taddl $4, %%esp\n" ); /* room for final return address */297298output( "\tpushw 0xbc(%%ebx)\n"); /* SegCs */299output( "\tpushw 0xb8(%%ebx)\n"); /* Eip */300output( "\tpushl %%edx\n" );301output( "\tpushl %%eax\n" );302output( "\tpushl 0xc0(%%ebx)\n"); /* EFlags */303output( "\tpushl 0x98(%%ebx)\n"); /* SegDs */304305output( "\tpushl 0x94(%%ebx)\n"); /* SegEs */306output( "\tpopl %%es\n" );307output( "\tpushl 0x90(%%ebx)\n"); /* SegFs */308output( "\tpopl %%fs\n" );309output( "\tpushl 0x8c(%%ebx)\n"); /* SegGs */310output( "\tpopl %%gs\n" );311312output( "\tmovl 0xb4(%%ebx),%%ebp\n"); /* Ebp */313output( "\tmovl 0xa0(%%ebx),%%esi\n"); /* Esi */314output( "\tmovl 0x9c(%%ebx),%%edi\n"); /* Edi */315output( "\tmovl 0xb0(%%ebx),%%eax\n"); /* Eax */316output( "\tmovl 0xa8(%%ebx),%%edx\n"); /* Edx */317output( "\tmovl 0xac(%%ebx),%%ecx\n"); /* Ecx */318output( "\tmovl 0xa4(%%ebx),%%ebx\n"); /* Ebx */319320output( "\tpopl %%ds\n" );321output( "\tpopfl\n" );322output( "\tlret\n" );323324output_function_size( "__wine_call_from_16_regs" );325}326else327{328/* Switch stack back */329output( "\tmovw %%fs:(%d), %%ss\n", STACKOFFSET+2 );330output( "\tmovzwl %%fs:(%d), %%esp\n", STACKOFFSET );331output( "\tpopl %%fs:(%d)\n", STACKOFFSET );332333/* Restore registers */334output( "\tpopl %%edx\n" );335output( "\tpopl %%ecx\n" );336output( "\tpopl %%ebp\n" );337output( "\tpopw %%ds\n" );338output( "\tpopw %%es\n" );339output( "\tpopw %%fs\n" );340output( "\tpopw %%gs\n" );341342/* Return to return stub which will return to caller */343output( "\tlret $12\n" );344345output_function_size( "__wine_call_from_16" );346}347}348349350/*******************************************************************351* BuildCallTo16Core352*353* This routine builds the core routines used in 32->16 thunks:354*355* extern DWORD WINAPI wine_call_to_16( FARPROC16 target, DWORD cbArgs, PEXCEPTION_HANDLER handler );356* extern void WINAPI wine_call_to_16_regs( CONTEXT86 *context, DWORD cbArgs, PEXCEPTION_HANDLER handler );357*358* These routines can be called directly from 32-bit code.359*360* All routines expect that the 16-bit stack contents (arguments) and the361* return address (segptr to CallTo16_Ret) were already set up by the362* caller; nb_args must contain the number of bytes to be conserved. The363* 16-bit SS:SP will be set accordingly.364*365* All other registers are either taken from the CONTEXT86 structure366* or else set to default values. The target routine address is either367* given directly or taken from the CONTEXT86.368*/369static void BuildCallTo16Core( int reg_func )370{371const char *name = reg_func ? "wine_call_to_16_regs" : "wine_call_to_16";372const char *func_name = is_pe() ? strmake( "%s@12", name ) : name;373374/* Function header */375output_function_header( func_name, 1 );376377/* Function entry sequence */378output_cfi( ".cfi_startproc" );379output( "\tpushl %%ebp\n" );380output_cfi( ".cfi_adjust_cfa_offset 4" );381output_cfi( ".cfi_rel_offset %%ebp,0" );382output( "\tmovl %%esp, %%ebp\n" );383output_cfi( ".cfi_def_cfa_register %%ebp" );384385/* Save the 32-bit registers */386output( "\tpushl %%ebx\n" );387output_cfi( ".cfi_rel_offset %%ebx,-4" );388output( "\tpushl %%esi\n" );389output_cfi( ".cfi_rel_offset %%esi,-8" );390output( "\tpushl %%edi\n" );391output_cfi( ".cfi_rel_offset %%edi,-12" );392output( "\tmov %%gs,%%fs:(%d)\n", GS_OFFSET );393394/* Setup exception frame */395output( "\tpushl %%fs:(%d)\n", STACKOFFSET );396output( "\tpushl 16(%%ebp)\n" ); /* handler */397output( "\tpushl %%fs:(0)\n" );398output( "\tmovl %%esp,%%fs:(0)\n" );399400/* Call the actual CallTo16 routine (simulate a lcall) */401output( "\tpushl %%cs\n" );402output( "\tcall .L%s\n", name );403404/* Remove exception frame */405output( "\tpopl %%fs:(0)\n" );406output( "\taddl $4, %%esp\n" );407output( "\tpopl %%fs:(%d)\n", STACKOFFSET );408409if ( !reg_func )410{411/* Convert return value */412output( "\tandl $0xffff,%%eax\n" );413output( "\tshll $16,%%edx\n" );414output( "\torl %%edx,%%eax\n" );415}416else417{418/*419* Modify CONTEXT86 structure to contain new values420*421* NOTE: We restore only EAX, EBX, ECX, EDX, EBP, and ESP.422* The segment registers as well as ESI and EDI should423* not be modified by a well-behaved 16-bit routine in424* any case. [If necessary, we could restore them as well,425* at the cost of a somewhat less efficient return path.]426*/427428output( "\tmovl 0x14(%%esp),%%edi\n" ); /* FIELD_OFFSET(STACK32FRAME,target) - FIELD_OFFSET(STACK32FRAME,edi) */429/* everything above edi has been popped already */430431output( "\tmovl %%eax,0xb0(%%edi)\n"); /* Eax */432output( "\tmovl %%ebx,0xa4(%%edi)\n"); /* Ebx */433output( "\tmovl %%ecx,0xac(%%edi)\n"); /* Ecx */434output( "\tmovl %%edx,0xa8(%%edi)\n"); /* Edx */435output( "\tmovl %%ebp,0xb4(%%edi)\n"); /* Ebp */436output( "\tmovl %%esi,0xc4(%%edi)\n"); /* Esp */437/* The return glue code saved %esp into %esi */438}439440/* Restore the 32-bit registers */441output( "\tpopl %%edi\n" );442output_cfi( ".cfi_same_value %%edi" );443output( "\tpopl %%esi\n" );444output_cfi( ".cfi_same_value %%esi" );445output( "\tpopl %%ebx\n" );446output_cfi( ".cfi_same_value %%ebx" );447448/* Function exit sequence */449output( "\tpopl %%ebp\n" );450output_cfi( ".cfi_def_cfa %%esp,4" );451output_cfi( ".cfi_same_value %%ebp" );452output( "\tret $12\n" );453output_cfi( ".cfi_endproc" );454455456/* Start of the actual CallTo16 routine */457458output( ".L%s:\n", name );459460/* Switch to the 16-bit stack */461output( "\tmovl %%esp,%%edx\n" );462output( "\tmovw %%fs:(%d),%%ss\n", STACKOFFSET + 2);463output( "\tmovw %%fs:(%d),%%sp\n", STACKOFFSET );464output( "\tmovl %%edx,%%fs:(%d)\n", STACKOFFSET );465466/* Make %bp point to the previous stackframe (built by CallFrom16) */467output( "\tmovzwl %%sp,%%ebp\n" );468output( "\tleal 0x2a(%%ebp),%%ebp\n"); /* FIELD_OFFSET(STACK16FRAME,bp) */469470/* Add the specified offset to the new sp */471output( "\tsubw 0x2c(%%edx), %%sp\n"); /* FIELD_OFFSET(STACK32FRAME,nb_args) */472473if (reg_func)474{475/* Push the called routine address */476output( "\tmovl 0x28(%%edx),%%edx\n"); /* FIELD_OFFSET(STACK32FRAME,target) */477output( "\tpushw 0xbc(%%edx)\n"); /* SegCs */478output( "\tpushw 0xb8(%%edx)\n"); /* Eip */479480/* Get the registers */481output( "\tpushw 0x98(%%edx)\n"); /* SegDs */482output( "\tpushl 0x94(%%edx)\n"); /* SegEs */483output( "\tpopl %%es\n" );484output( "\tmovl 0xb4(%%edx),%%ebp\n"); /* Ebp */485output( "\tmovl 0xa0(%%edx),%%esi\n"); /* Esi */486output( "\tmovl 0x9c(%%edx),%%edi\n"); /* Edi */487output( "\tmovl 0xb0(%%edx),%%eax\n"); /* Eax */488output( "\tmovl 0xa4(%%edx),%%ebx\n"); /* Ebx */489output( "\tmovl 0xac(%%edx),%%ecx\n"); /* Ecx */490output( "\tmovl 0xa8(%%edx),%%edx\n"); /* Edx */491492/* Get the 16-bit ds */493output( "\tpopw %%ds\n" );494}495else /* not a register function */496{497/* Push the called routine address */498output( "\tpushl 0x28(%%edx)\n"); /* FIELD_OFFSET(STACK32FRAME,target) */499500/* Set %fs and %gs to the value saved by the last CallFrom16 */501output( "\tpushw -22(%%ebp)\n" ); /* FIELD_OFFSET(STACK16FRAME,fs)-FIELD_OFFSET(STACK16FRAME,bp) */502output( "\tpopw %%fs\n" );503output( "\tpushw -20(%%ebp)\n" ); /* FIELD_OFFSET(STACK16FRAME,gs)-FIELD_OFFSET(STACK16FRAME,bp) */504output( "\tpopw %%gs\n" );505506/* Set %ds and %es (and %ax just in case) equal to %ss */507output( "\tmovw %%ss,%%ax\n" );508output( "\tmovw %%ax,%%ds\n" );509output( "\tmovw %%ax,%%es\n" );510}511512/* Jump to the called routine */513output( "\tlretw\n" );514515/* Function footer */516output_function_size( func_name );517}518519520/*******************************************************************521* BuildRet16Func522*523* Build the return code for 16-bit callbacks524*/525static void BuildRet16Func(void)526{527output_function_header( "__wine_call_to_16_ret", 1 );528529/* Save %esp into %esi */530output( "\tmovl %%esp,%%esi\n" );531532/* Restore 32-bit segment registers */533534output( "\tmovl %%cs:%s", asm_name("CallTo16_DataSelector") );535output( "-%s,%%edi\n", asm_name("__wine_call16_start") );536output( "\tmovw %%di,%%ds\n" );537output( "\tmovw %%di,%%es\n" );538539output( "\tmov %%cs:%s", asm_name("CallTo16_TebSelector") );540output( "-%s,%%fs\n", asm_name("__wine_call16_start") );541542output( "\tmov %%fs:(%d),%%gs\n", GS_OFFSET );543544/* Restore the 32-bit stack */545546output( "\tmovw %%di,%%ss\n" );547output( "\tmovl %%fs:(%d),%%esp\n", STACKOFFSET );548549/* Return to caller */550551output( "\tlret\n" );552output_function_size( "__wine_call_to_16_ret" );553}554555556/*******************************************************************557* output_asm_relays16558*559* Build all the 16-bit relay callbacks560*/561void output_asm_relays16(void)562{563/* File header */564565output( "\t.text\n" );566output( "%s:\n\n", asm_name("__wine_spec_thunk_text_16") );567568output( "%s\n", asm_globl("__wine_call16_start") );569570/* Standard CallFrom16 routine */571BuildCallFrom16Core( 0, 0 );572573/* Register CallFrom16 routine */574BuildCallFrom16Core( 1, 0 );575576/* C16ThkSL CallFrom16 routine */577BuildCallFrom16Core( 0, 1 );578579/* Standard CallTo16 routine */580BuildCallTo16Core( 0 );581582/* Register CallTo16 routine */583BuildCallTo16Core( 1 );584585/* Standard CallTo16 return stub */586BuildRet16Func();587588output( "%s\n", asm_globl("__wine_call16_end") );589output_function_size( "__wine_spec_thunk_text_16" );590591/* Declare the return address and data selector variables */592output( "\n\t.data\n\t.balign 4\n" );593output( "%s\n\t.long 0\n", asm_globl("CallTo16_DataSelector") );594output( "%s\n\t.long 0\n", asm_globl("CallTo16_TebSelector") );595}596597598