Files
2ine-tms34010/native/viocalls.c
T
Ryan C. Gordon 26a52988a6 16-bit support!
This gets us everything we need (I hope!) to support 16-bit code in LX
binaries and call into 16-bit OS/2 APIs. This is just enough to call
into VioGetMode() (which isn't otherwise implemented yet) as an example.

If this is ever used Winelib-style to provide an OS/2 API to native Linux
binaries, the 16-bit system APIs are 32-bit clean and C callable, as one
might expect them to be. All the tapdancing is to support existing LX
binaries in the loader and bridge between the 32-bit clean APIs and
existing 16-bit code that expects to call 16-bit APIs.

This was a staggering amount of effort, but yay!

Other fixes and improvements probably leaked into this commit, as a
lot of code got touched and a lot of research and debugging took place.
2016-10-27 01:44:26 -04:00

44 lines
1.3 KiB
C

#include "os2native16.h"
#include "viocalls.h"
LX_NATIVE_MODULE_16BIT_SUPPORT()
LX_NATIVE_MODULE_16BIT_API(VioGetMode)
LX_NATIVE_MODULE_16BIT_SUPPORT_END()
// !!! FIXME:
#undef TRACE_NATIVE
#define TRACE_NATIVE(...) do { if (GLoaderState->trace_native) { fprintf(stderr, "2INE TRACE [%lu]: ", (unsigned long) pthread_self()); fprintf(stderr, __VA_ARGS__); fprintf(stderr, ";\n"); } } while (0)
LX_NATIVE_MODULE_DEINIT({
LX_NATIVE_MODULE_DEINIT_16BIT_SUPPORT();
})
APIRET16 VioGetMode(PVIOMODEINFO pvioModeInfo, HVIO hvio)
{
TRACE_NATIVE("VioGetMode(%p, %u)", pvioModeInfo, (uint) hvio);
FIXME("write me");
return ERROR_INVALID_PARAMETER;
} // VioGetMode
static APIRET16 bridge16to32_VioGetMode(uint8 *args)
{
const HVIO hvio = *((HVIO *) args); args += 2;
PVIOMODEINFO pvmi = (PVIOMODEINFO) GLoaderState->convert1616to32(*((uint32*) args)); //args += 4;
return VioGetMode(pvmi, hvio);
} // bridge16to32_VioGetMode
static int initViocalls(LxLoaderState *lx_state)
{
LX_NATIVE_MODULE_INIT_16BIT_SUPPORT()
LX_NATIVE_INIT_16BIT_BRIDGE(VioGetMode, 6)
LX_NATIVE_MODULE_INIT_16BIT_SUPPORT_END()
return 1;
} // initViocalls
LX_NATIVE_MODULE_INIT({ if (!initViocalls(lx_state)) return NULL; })
LX_NATIVE_EXPORT16(VioGetMode, 21)
LX_NATIVE_MODULE_INIT_END()
// end of viocalls.c ...