From: Jim Kingdon Date: Wed, 3 Nov 1993 21:04:56 +0000 (+0000) Subject: Merge changes from progressive for dos x udi: X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d1b785153e6d914551aa78cd3adbb24c008d4c77;p=binutils-gdb.git Merge changes from progressive for dos x udi: * Makefile.in (udi2go32.o): add rule to build this file * 29k-share/udi/udi2go32.c: new file * config/a29k/a29k-udi.mt: add udi2go32.o * 29k-share/udi/{udr.c, udip2soc.c}: #ifdef out the entire file if __GO32__ is defined. What a hack. --- diff --git a/gdb/29k-share/udi/udi2go32.c b/gdb/29k-share/udi/udi2go32.c new file mode 100644 index 00000000000..63d98ae4017 --- /dev/null +++ b/gdb/29k-share/udi/udi2go32.c @@ -0,0 +1,607 @@ +/* + +Interface from UDI calls in 32-bit mode to go32 in 16-bit mode. +Communication is done through a single interrupt vector, which passes +data through two linear buffers. + +Call: + AH = 0xfe + AL = UDI function number + ECX = IN length + ESI = pointer to IN buffer + EDI = pointer to OUT buffer + +Return: + EAX = return value of UDI function + +Vector: + 0x21 + +*/ +#ifdef __GO32__ + +#include +#include "udiproc.h" +#include "udisoc.h" + +char dfe_errmsg[500]; + +static char in_buffer[4096]; +static char out_buffer[4096]; +static char *in_ptr; +static char *out_ptr; + +#define IN_INIT() in_ptr = in_buffer +#define IN_VAL(t,v) *((t *)in_ptr)++ = v +#define IN_DATA(ptr, cnt) memcpy(in_ptr, ptr, cnt), in_ptr += cnt + +#define OUT_INIT() out_ptr = out_buffer +#define OUT_VAL(t) (*((t *)out_ptr)++) +#define OUT_DATA(ptr, cnt) memcpy(ptr, out_ptr, cnt), out_ptr += cnt + +static int DO_CALL(int function) +{ + asm("pushl %esi"); + asm("pushl %edi"); + asm("movb %0, %%al" : : "g" (function)); + asm("movl _in_ptr, %ecx"); + asm("movl $_in_buffer, %esi"); + asm("subl %esi, %ecx"); + asm("movl $_out_buffer, %edi"); + asm("movb $0xfe, %ah"); + asm("int $0x21"); + asm("popl %edi"); + asm("popl %esi"); +} + +/*----------------------------------------------------------------------*/ + +#ifdef TEST_UDI +int main() +{ + int r; + long p2; + short p1; + IN_INIT(); + IN_VAL(long, 11111111); + IN_VAL(short, 2222); + IN_DATA("Hello, world\n", 17); + + r = DO_CALL(42); + + OUT_INIT(); + p1 = OUT_VAL(short); + p2 = OUT_VAL(long); + printf("main: p1=%d p2=%d rv=%d\n", p1, p2, r); + return r; +} +#endif + +/*----------------------------------------------------------------------*/ + +unsupported(char *s) +{ + printf("unsupported UDI host call %s\n", s); + abort(); +} + +UDIError UDIConnect ( + char *Configuration, /* In */ + UDISessionId *Session /* Out */ + ) +{ + int r; + out_buffer[0] = 0; /* DJ - test */ + IN_INIT(); + IN_DATA(Configuration, strlen(Configuration)+1); + + r = DO_CALL(UDIConnect_c); + + OUT_INIT(); + *Session = OUT_VAL(UDISessionId); + return r; +} + +UDIError UDIDisconnect ( + UDISessionId Session, /* In */ + UDIBool Terminate /* In */ + ) +{ + int r; + IN_INIT(); + IN_VAL(UDISessionId, Session); + IN_VAL(UDIBool, Terminate); + + return DO_CALL(UDIDisconnect_c); +} + +UDIError UDISetCurrentConnection ( + UDISessionId Session /* In */ + ) +{ + IN_INIT(); + IN_VAL(UDISessionId, Session); + + return DO_CALL(UDISetCurrentConnection_c); +} + +UDIError UDICapabilities ( + UDIUInt32 *TIPId, /* Out */ + UDIUInt32 *TargetId, /* Out */ + UDIUInt32 DFEId, /* In */ + UDIUInt32 DFE, /* In */ + UDIUInt32 *TIP, /* Out */ + UDIUInt32 *DFEIPCId, /* Out */ + UDIUInt32 *TIPIPCId, /* Out */ + char *TIPString /* Out */ + ) +{ + int r; + IN_INIT(); + IN_VAL(UDIUInt32, DFEId); + IN_VAL(UDIUInt32, DFE); + r = DO_CALL(UDICapabilities_c); + OUT_INIT(); + *TIPId = OUT_VAL(UDIUInt32); + *TargetId = OUT_VAL(UDIUInt32); + *TIP = OUT_VAL(UDIUInt32); + *DFEIPCId = OUT_VAL(UDIUInt32); + *TIPIPCId = OUT_VAL(UDIUInt32); + strcpy(TIPString, out_ptr); + return r; +} + +UDIError UDIEnumerateTIPs ( + UDIInt (*UDIETCallback) /* In */ + ( char *Configuration ) /* In to callback() */ + ) +{ + UDIETCallback("montip.exe"); +} + +UDIError UDIGetErrorMsg ( + UDIError ErrorCode, /* In */ + UDISizeT MsgSize, /* In */ + char *Msg, /* Out */ + UDISizeT *CountDone /* Out */ + ) +{ + int r; + if (MsgSize > 4000) + MsgSize = 4000; + IN_INIT(); + IN_VAL(UDIError, ErrorCode); + IN_VAL(UDISizeT, MsgSize); + + r = DO_CALL(UDIGetErrorMsg_c); + + OUT_INIT(); + *CountDone = OUT_VAL(UDISizeT); + OUT_DATA(Msg, *CountDone); + return r; +} + +UDIError UDIGetTargetConfig ( + UDIMemoryRange KnownMemory[], /* Out */ + UDIInt *NumberOfRanges, /* In/Out */ + UDIUInt32 ChipVersions[], /* Out */ + UDIInt *NumberOfChips /* In/Out */ + ) +{ + int r, i; + int nr = *NumberOfRanges; + int nc = *NumberOfChips; + IN_INIT(); + IN_VAL(UDIInt, *NumberOfRanges); + IN_VAL(UDIInt, *NumberOfChips); + r = DO_CALL(UDIGetTargetConfig_c); + if (r == UDIErrorIncomplete) + return r; + OUT_INIT(); + *NumberOfRanges = OUT_VAL(UDIInt); + *NumberOfChips = OUT_VAL(UDIInt); + for (i=0; iSpace = OUT_VAL(short); + Addr->Offset = OUT_VAL(CPUOffset); + *PassCount = OUT_VAL(UDIInt32); + *Type = OUT_VAL(UDIBreakType); + *CurrentCount = OUT_VAL(UDIInt32); + + return r; +} + +UDIError UDIClearBreakpoint ( + UDIBreakId BreakId /* In */ + ) +{ + IN_INIT(); + IN_VAL(UDIBreakId, BreakId); + + return DO_CALL(UDIClearBreakpoint_c); +} + +UDIError UDIGetStdout ( + UDIHostMemPtr Buf, /* Out */ + UDISizeT BufSize, /* In */ + UDISizeT *CountDone /* Out */ + ) +{ + int r; + IN_INIT(); + if (BufSize > 4000) + BufSize = 4000; + IN_VAL(UDISizeT,BufSize); + r = DO_CALL(UDIGetStdout_c); + OUT_INIT(); + *CountDone = OUT_VAL(UDISizeT); + if (*CountDone <= BufSize) + OUT_DATA(Buf, *CountDone); + return r; +} + +UDIError UDIGetStderr ( + UDIHostMemPtr Buf, /* Out */ + UDISizeT BufSize, /* In */ + UDISizeT *CountDone /* Out */ + ) +{ + int r; + IN_INIT(); + if (BufSize > 4000) + BufSize = 4000; + IN_VAL(UDISizeT,BufSize); + r = DO_CALL(UDIGetStderr_c); + OUT_INIT(); + *CountDone = OUT_VAL(UDISizeT); + OUT_DATA(Buf, *CountDone); + return r; +} + +UDIError UDIPutStdin ( + UDIHostMemPtr Buf, /* In */ + UDISizeT Count, /* In */ + UDISizeT *CountDone /* Out */ + ) +{ + int r; + IN_INIT(); + if (Count > 4000) + Count = 4000; + IN_VAL(UDISizeT,Count); + IN_DATA(Buf, Count); + r = DO_CALL(UDIPutStdin_c); + OUT_INIT(); + *CountDone = OUT_VAL(UDISizeT); + return r; +} + +UDIError UDIStdinMode ( + UDIMode *Mode /* Out */ + ) +{ + int r; + IN_INIT(); + r = DO_CALL(UDIStdinMode_c); + OUT_INIT(); + *Mode = OUT_VAL(UDIMode); + return r; +} + +UDIError UDIPutTrans ( + UDIHostMemPtr Buf, /* In */ + UDISizeT Count, /* In */ + UDISizeT *CountDone /* Out */ + ) +{ + int r; + IN_INIT(); + if (Count > 4000) + Count = 4000; + IN_VAL(UDISizeT,Count); + IN_DATA(Buf, Count); + r = DO_CALL(UDIPutTrans_c); + OUT_INIT(); + *CountDone = OUT_VAL(UDISizeT); + return r; +} + +UDIError UDIGetTrans ( + UDIHostMemPtr Buf, /* Out */ + UDISizeT BufSize, /* In */ + UDISizeT *CountDone /* Out */ + ) +{ + int r; + IN_INIT(); + if (BufSize > 4000) + BufSize = 4000; + IN_VAL(UDISizeT,BufSize); + r = DO_CALL(UDIGetTrans_c); + OUT_INIT(); + *CountDone = OUT_VAL(UDISizeT); + OUT_DATA(Buf, *CountDone); + return r; +} + +UDIError UDITransMode ( + UDIMode *Mode /* Out */ + ) +{ + int r; + IN_INIT(); + r = DO_CALL(UDITransMode_c); + OUT_INIT(); + *Mode = OUT_VAL(UDIMode); + return r; +} + +#define DFEIPCIdCompany 0x0001 /* Company ID AMD */ +#define DFEIPCIdProduct 0x1 /* Product ID 0 */ +#define DFEIPCIdVersion 0x125 /* 1.2.5 */ + +unsigned UDIGetDFEIPCId () +{ + return((((UDIUInt32)DFEIPCIdCompany) << 16) |(DFEIPCIdProduct << 12) | DFEIPCIdVersion); +} + +#endif /* __GO32__ */