Mail Archives: djgpp-workers/1998/12/16/17:26:06
These are from Toshio KUDO, Miyagi, Japan <adamtk AT altavista DOT net> He
had a keyboard exception patch too, but it was trivial and I already
applied it.
Comments?
>-rwxrwxr-x kudo/kudo 5179 Dec 16 11:32 1998 nofpu.dif
If no 80x87, V2 COFF emulates co-processor, turn on EM and MP bit in
CR0, register the protect-mode exception handler. But, there is no
real-mode exception handler.
So, when V2 COFF terminates, or executes real-mode command as a
child process, next, use FPU instruction in real-mode (ie detect x87),
then it hangs up, reboot, or something wrong occures.
This patch fixes inconvenience above.
>-rwxrwxr-x kudo/kudo 13230 Dec 15 01:01 1998 edebug32.dif
EDEBUG32 works on PC/AT or compatible, but not works on Japanese
PC98. So, I make a patch for PC98. I hope you'll apply this patch to
edebug32. Could you please grant my wish?
diff -rcN orig/src/libc/dos/process/dosexec.c new/src/libc/dos/process/dosexec.c
*** orig/src/libc/dos/process/dosexec.c Sun Dec 13 13:09:46 1998
--- new/src/libc/dos/process/dosexec.c Wed Dec 16 11:10:36 1998
***************
*** 139,144 ****
--- 139,148 ----
extern char __PROXY[]; /* defined on crt0/crt1.c */
extern size_t __PROXY_LEN;
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ extern void restore_DPMI_fpu_state (void); /* defined on emu387/npxsetup.c */
+ extern void resetup_DPMI_fpu_state (void);
+ #endif /* end of patch by adamtk 98.12.16 */
/* Functions that call `direct_exec_tail' after they've put
some data into the transfer buffer, should set LFN parameter
***************
*** 325,336 ****
--- 329,346 ----
parm.fcb2_off = fcb2_la & 15;
dosmemput(&parm, sizeof(parm), parm_la);
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ restore_DPMI_fpu_state ();
+ #endif /* end of patch by adamtk 98.12.16 */
r.x.ax = 0x4b00;
r.x.ds = program_la / 16;
r.x.dx = program_la & 15;
r.x.es = parm_la / 16;
r.x.bx = parm_la & 15;
__dpmi_int(0x21, &r);
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ resetup_DPMI_fpu_state ();
+ #endif /* end of patch by adamtk 98.12.16 */
#if 0
if (tbuf_selector)
__dpmi_free_dos_memory (tbuf_selector);
diff -rcN orig/src/libc/emu387/npxsetup.c new/src/libc/emu387/npxsetup.c
*** orig/src/libc/emu387/npxsetup.c Mon Sep 7 18:55:40 1998
--- new/src/libc/emu387/npxsetup.c Wed Dec 16 11:17:42 1998
***************
*** 51,62 ****
--- 51,80 ----
longjmp(__djgpp_exception_state, __djgpp_exception_state->__eax);
}
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ static int DPMIfpustate = -1; /* negative means not saved */
+ void restore_DPMI_fpu_state (void);
+ void resetup_DPMI_fpu_state (void);
+ void
+ restore_DPMI_fpu_state (void)
+ {
+ if (DPMIfpustate >= 0)
+ __dpmi_set_coprocessor_emulation (DPMIfpustate);
+ }
+ void
+ resetup_DPMI_fpu_state (void)
+ {
+ if (DPMIfpustate >= 0)
+ __dpmi_set_coprocessor_emulation (3);
+ }
+ #else /* not patched by adamtk 98.12.16 */
#ifdef RESTORE_FPU
static void restore_DPMI_fpu_state(void)
{
__dpmi_set_coprocessor_emulation(1); /* Enable Coprocessor, no exceptions */
}
#endif
+ #endif /* end of patch by adamtk 98.12.16 */
extern int _detect_80387(void);
***************
*** 64,73 ****
--- 82,102 ----
{
char *cp;
char have_80387;
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ int lastfpustate;
+ #else /* not patched by adamtk 98.12.16 */
#ifdef RESTORE_FPU
static int veryfirst = 1;
#endif
+ #endif /* end of patch by adamtk 98.12.16 */
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ /* CWSDPMI don't support DPMI-0E00 (and do not touch CR0),
+ * So, set DPMIfpustate to 1 for make sure EM bit off.
+ */
+ if ((lastfpustate = __dpmi_get_coprocessor_status ()) < 0)
+ lastfpustate = 1;
+ #endif /* end of patch by adamtk 98.12.16 */
cp = getenv("387");
if (cp && (tolower(cp[0]) == 'y'))
{
***************
*** 82,87 ****
--- 111,119 ----
nested FPU client fault - DJ */
__dpmi_set_coprocessor_emulation(1);
have_80387 = _detect_80387();
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ __dpmi_set_coprocessor_emulation (lastfpustate);
+ #endif /* end of patch by adamtk 98.12.16 */
_8087 = (have_80387 ? 3 : 0);
}
***************
*** 96,101 ****
--- 128,136 ----
_control87(0x033f, 0xffff);
} else {
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ DPMIfpustate = lastfpustate;
+ #endif /* end of patch by adamtk 98.12.16 */
/* Flags value 3 means coprocessor emulation, exceptions to us */
if (__dpmi_set_coprocessor_emulation(3)) {
_write(2, "Warning: Coprocessor not present and DPMI setup failed!\r\n", 57);
***************
*** 118,123 ****
--- 153,159 ----
if (_emu_entry == 0)
return;
#endif
+ #if 0 /* patched by adamtk AT altavista DOT net 98.12.16 */
#ifdef RESTORE_FPU
if (veryfirst)
{
***************
*** 125,130 ****
--- 161,167 ----
atexit(restore_DPMI_fpu_state);
}
#endif
+ #endif /* end of patch by adamtk 98.12.16 */
signal(SIGNOFP, nofpsig);
}
}
diff -rcN orig/src/libc/go32/dpmiexcp.c new/src/libc/go32/dpmiexcp.c
*** orig/src/libc/go32/dpmiexcp.c Sun Dec 13 13:06:46 1998
--- new/src/libc/go32/dpmiexcp.c Wed Dec 16 11:21:02 1998
***************
*** 579,584 ****
--- 579,587 ----
return oldenable;
}
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ extern void restore_DPMI_fpu_state (void); /* defined on emu387/npxsetup.c */
+ #endif /* end of patch by adamtk 98.12.16 */
void __attribute__((noreturn))
_exit(int status)
{
***************
*** 589,594 ****
--- 592,600 ----
if (__djgpp_old_kbd.offset32 == kbd_ori.offset32
&& __djgpp_old_kbd.selector == kbd_ori.selector)
__djgpp_exception_toggle ();
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.16 */
+ restore_DPMI_fpu_state ();
+ #endif /* end of patch by adamtk 98.12.16 */
__exit (status);
}
diff -rcN orig/src/debug/edebug/debug.c new/src/debug/edebug/debug.c
*** orig/src/debug/edebug/debug.c Mon Sep 7 18:01:28 1998
--- new/src/debug/edebug/debug.c Mon Dec 14 20:30:30 1998
***************
*** 17,23 ****
--- 17,25 ----
#include <setjmp.h>
#include <math.h>
#include <string.h>
+ #if 0 /* patched by adamtk AT altavista DOT net 98.12.14 */
#include <pc.h> /* For getkey() */
+ #endif /* end of patch by adamtk 98.12.14 */
#include "ed.h"
#include "debug.h"
***************
*** 44,50 ****
--- 46,56 ----
NPXREG reg[8];
} NPX;
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ static char char32spc[] = "xxx.xxx.xxx.xxx-xxx.xxx.xxx.xxx ";
+ #else /* not patched by adamtk 98.12.14 */
static char char32spc[] = "xxxúxxxúxxxúxxxùxxxúxxxúxxxúxxx ";
+ #endif /* end of patch by adamtk 98.12.14 */
static char flset[] = "VMRF NT OFDNIETFMIZR AC PE CY";
static char floff[] = " UPID PLNZ PO NC";
***************
*** 113,119 ****
--- 119,129 ----
while (1)
{
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ ch = getkbd();
+ #else /* not patched by adamtk 98.12.14 */
ch = getkey();
+ #endif /* end of patch by adamtk 98.12.14 */
if (erase_it)
{
for (i=0; lasttoken[i]; i++)
***************
*** 313,319 ****
--- 323,333 ----
{
printf("--- More ---");
fflush(stdout);
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ key = getkbd();
+ #else /* not patched by adamtk 98.12.14 */
key = getkey();
+ #endif /* end of patch by adamtk 98.12.14 */
printf("\r \r");
switch (key)
{
***************
*** 356,361 ****
--- 370,379 ----
{
int found;
undefined_symbol = 0;
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ if (!lasttoken[0])
+ rem_cmd = Zero;
+ #endif /* end of patch by adamtk 98.12.14 */
my_getline(buf, lasttoken);
token[0] = 0;
if (sscanf(buf, "%s %[^\n]", token, buf) < 2)
***************
*** 551,559 ****
--- 569,587 ----
break;
}
if (read_child(vaddr, &ch, 1))
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ {
+ putchar('\n');
+ break;
+ }
+ #else /* not patched by adamtk 98.12.14 */
break;
+ #endif /* end of patch by adamtk 98.12.14 */
if (ch == 0)
{
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ vaddr++;
+ #endif /* end of patch by adamtk 98.12.14 */
putchar('\n');
break;
}
***************
*** 594,600 ****
--- 622,635 ----
{
word32 v1;
if (read_child(vaddr+i*4, &v1, 4))
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ {
+ putchar('\n');
+ break;
+ }
+ #else /* not patched by adamtk 98.12.14 */
break;
+ #endif /* end of patch by adamtk 98.12.14 */
printf(" 0x%08lx", v1);
}
else
***************
*** 607,621 ****
--- 642,674 ----
if ((j+i*4-12>=0) && (j+i*4-12 < n*4))
{
if (read_child(vaddr+j+i*4-12, &c, 1))
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ {
+ putchar('\n');
+ break;
+ }
+ #else /* not patched by adamtk 98.12.14 */
break;
+ #endif /* end of patch by adamtk 98.12.14 */
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ if ((c&=0xFF)<' ')
+ putchar('.');
+ else
+ putchar(c);
+ #else /* not patched by adamtk 98.12.14 */
if (c<' ')
putchar('.');
else
putchar(c);
+ #endif /* end of patch by adamtk 98.12.14 */
}
else
putchar(' ');
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ printf(" \n"); /* for DBCS */
+ #else /* not patched by adamtk 98.12.14 */
printf("\n");
+ #endif /* end of patch by adamtk 98.12.14 */
}
s++;
}
***************
*** 718,723 ****
--- 771,779 ----
}
else
{
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ printf("%s ", buf2);
+ #endif /* end of patch by adamtk 98.12.14 */
switch (regs[i].size)
{
case 1:
***************
*** 732,756 ****
--- 788,828 ----
}
break;
case 2:
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ printf("%04x ", *(word16 *)((word8 *)tss_ptr + regs[i].ofs));
+ #else /* not patched by adamtk 98.12.14 */
printf("%04x ", *(word16 *)((word16 *)tss_ptr + regs[i].ofs));
+ #endif /* end of patch by adamtk 98.12.14 */
my_getline(buf, "");
if (buf[0])
{
v = syms_name2val(buf);
if (undefined_symbol)
break;
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ *(word16 *)((word8 *)tss_ptr + regs[i].ofs) = v;
+ #else /* not patched by adamtk 98.12.14 */
*(word16 *)((word16 *)tss_ptr + regs[i].ofs) = v;
+ #endif /* end of patch by adamtk 98.12.14 */
}
break;
case 4:
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ printf("%08lx ", *(word32 *)((word8 *)tss_ptr + regs[i].ofs));
+ #else /* not patched by adamtk 98.12.14 */
printf("%08lx ", *(word32 *)((word32 *)tss_ptr + regs[i].ofs));
+ #endif /* end of patch by adamtk 98.12.14 */
my_getline(buf, "");
if (buf[0])
{
v = syms_name2val(buf);
if (undefined_symbol)
break;
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ *(word32 *)((word8 *)tss_ptr + regs[i].ofs) = v;
+ #else /* not patched by adamtk 98.12.14 */
*(word32 *)((word32 *)tss_ptr + regs[i].ofs) = v;
+ #endif /* end of patch by adamtk 98.12.14 */
}
break;
}
***************
*** 762,768 ****
--- 834,844 ----
vaddr = syms_name2val(buf2);
if (undefined_symbol)
break;
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ if (len > 1)
+ #else /* not patched by adamtk 98.12.14 */
if (len < 2)
+ #endif /* end of patch by adamtk 98.12.14 */
{
v = syms_name2val(buf);
if (undefined_symbol)
***************
*** 773,779 ****
--- 849,862 ----
{
word32 vv;
if (read_child(vaddr, &vv,4))
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ {
+ putchar('\n');
+ break;
+ }
+ #else /* not patched by adamtk 98.12.14 */
break;
+ #endif /* end of patch by adamtk 98.12.14 */
printf("0x%08lx 0x%08lx", vaddr, vv);
my_getline(buf, "");
if (buf[0])
***************
*** 847,853 ****
--- 930,940 ----
break;
case CLS:
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ ansicls ();
+ #else /* not patched by adamtk 98.12.14 */
asm volatile("pusha; movb $15,%ah; int $0x10; movb $0,%ah; int $0x10; popa");
+ #endif /* end of patch by adamtk 98.12.14 */
break;
default:
diff -rcN orig/src/debug/edebug/ed.c new/src/debug/edebug/ed.c
*** orig/src/debug/edebug/ed.c Tue Oct 28 19:32:12 1997
--- new/src/debug/edebug/ed.c Tue Dec 15 00:54:08 1998
***************
*** 5,12 ****
--- 5,20 ----
#include <unistd.h>
#include "ed.h"
#include "debug.h"
+ #include <debug/v2load.h>
#include <debug/syms.h>
#include <libc/file.h> /* Workaround for stderr bug below */
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ #include <io.h>
+ #include <fcntl.h>
+ #include <dpmi.h>
+ #include <go32.h>
+ #include <pc.h> /* For getkey() */
+ #endif /* end of patch by adamtk 98.12.14 */
static char ansi_mode; /* if set, OK to emit ansi control codes */
***************
*** 16,21 ****
--- 24,53 ----
printf("\033[%d;%dm", (fg & A_bold) ? 1 : 0, 30+(fg&7));
}
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ void
+ ansicls (void)
+ {
+ if (ansi_mode)
+ printf ("\033[2J\033[0;0H");
+ else
+ asm volatile ("pusha; movb $15,%ah; int $0x10; movb $0,%ah; int $0x10; popa");
+ }
+
+ int
+ getkbd (void)
+ {
+ if (ScreenPrimary == 0xa0000) /* Japanese PC98? */
+ {
+ __dpmi_regs r;
+ r.h.ah = 0x07;
+ __dpmi_int(0x21, &r);
+ return (r.h.al);
+ }
+ return (getkey ());
+ }
+ #endif /* end of patch by adamtk 98.12.14 */
+
/* for debugging a qdpmi bug */
#if 0
#define x printf("%s:%d\n", __FILE__, __LINE__);
***************
*** 26,31 ****
--- 58,70 ----
void ansidetect(void) /* Idea from DJ's install program */
{
word16 oldp, newp;
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ if (ScreenPrimary == 0xa0000) /* Japanese PC98? */
+ {
+ ansi_mode = 1;
+ return;
+ }
+ #endif /* end of patch by adamtk 98.12.14 */
asm("movb $3,%%ah;movb $0,%%bh;int $0x10;movw %%dx,%0" : "=g" (oldp) :
: "ax", "bx", "cx", "dx");
printf("\033[0m");
***************
*** 66,75 ****
--- 105,129 ----
x printf("Load failed for image %s\n",argv[1]);
exit(1);
}
+ printf("text: 0x%6x - 0x%6x\n"
+ "data: 0x%6x - 0x%6x\n"
+ "bss: 0x%6x - 0x%6x\n"
+ "stack: 0x%6x - 0x%6x\n"
+ "arena: 0x%6x - 0x%6x\n",
+ areas[A_text].first_addr, areas[A_text].last_addr,
+ areas[A_data].first_addr, areas[A_data].last_addr,
+ areas[A_bss].first_addr, areas[A_bss].last_addr,
+ areas[A_stack].first_addr, areas[A_stack].last_addr,
+ areas[A_arena].first_addr, areas[A_arena].last_addr);
x
edi_init(start_state);
x ansidetect();
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ x stdout->_file = open(ctermid(NULL), (O_RDWR | O_TEXT), 0666);
+ stdin->_file = dup(stdout->_file);
+ #else /* not patched by adamtk 98.12.14 */
x stdout->_file = dup(fileno(stdout));
+ #endif /* end of patch by adamtk 98.12.14 */
x
x debugger();
diff -rcN orig/src/debug/edebug/ed.h new/src/debug/edebug/ed.h
*** orig/src/debug/edebug/ed.h Tue Mar 21 05:17:12 1995
--- new/src/debug/edebug/ed.h Mon Dec 14 20:28:32 1998
***************
*** 24,29 ****
--- 24,33 ----
#define A_yellow 14
#define A_white 15
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ void ansicls (void);
+ int getkbd (void);
+ #endif /* end of patch by adamtk 98.12.14 */
void ansi(int fg);
void ansidetect(void);
diff -rcN orig/src/debug/edebug/unassmbl.c new/src/debug/edebug/unassmbl.c
*** orig/src/debug/edebug/unassmbl.c Tue Oct 28 19:35:18 1997
--- new/src/debug/edebug/unassmbl.c Mon Dec 14 20:16:00 1998
***************
*** 135,141 ****
--- 135,145 ----
"mov %eax,%I-vv", "mov %ecx,%I-vv", "mov %edx,%I-vv", "mov %ebx,%I-vv",
"mov %esp,%Ivv", "mov %ebp,%Ivv", "mov %esi,%I-vv", "mov %edi,%I-vv",
/* c */
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ "%g2 %Eb,%Ibb", "%g2 %Ev,%Ibb", "ret %Iww", "ret",
+ #else /* not patched by adamtk 98.12.14 */
"%g2 %Eb,%Ibb", "%g2 %Ev,%Ibb", "ret %Iw", "ret",
+ #endif /* end of patch by adamtk 98.12.14 */
"les %Gv,%Mp", "lds %Gv,%Mp", "mov %Eb,%Ibb", "mov %Ev,%I-vv",
"enter %Iww,%Ibb", "leave", "retf %Iww", "retf",
"int 3", "int %Ibb", "into", "iret",
***************
*** 186,192 ****
--- 190,200 ----
/* 9 */
"seto %Eb", "setno %Eb", "setc %Eb", "setnc %Eb",
"setz %Eb", "setnz %Eb", "setbe %Eb", "setnbe %Eb",
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ "sets %Eb", "setns %Eb", "setpe %Eb", "setpo %Eb",
+ #else /* not patched by adamtk 98.12.14 */
"sets %Eb", "setns %Eb", "setp %Eb", "setnp %Eb",
+ #endif /* end of patch by adamtk 98.12.14 */
"setl %Eb", "setge %Eb", "setle %Eb", "setg %Eb",
/* a */
"push fs", "pop fs", 0, "bt %Ev,%Gv",
***************
*** 425,431 ****
--- 433,443 ----
for (i=0; i<n; i++)
buf1[i] = getbyte();
for (; i<extend; i++)
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ buf1[i] = (buf1[i-1] & 0x80) ? 0xff : 0;
+ #else /* not patched by adamtk 98.12.14 */
buf1[i] = (buf[i-1] & 0x80) ? 0xff : 0;
+ #endif /* end of patch by adamtk 98.12.14 */
if (s)
{
uprintf("0x%02x%02x:", buf1[n-1], buf1[n-2]);
***************
*** 712,720 ****
--- 724,738 ----
}
name = syms_val2name(vofs+vaddr, &delta);
uprintf("%s", name);
+ #if 1 /* patched by adamtk AT altavista DOT net 98.12.14 */
+ if (delta)
+ uprintf("+%lu (0x%lx %c)", delta, vofs+vaddr,
+ (vofs & 0x80000000UL) ? '^' : 'v');
+ #else /* not patched by adamtk 98.12.14 */
if (delta)
uprintf("+%lu (0x%lx %c)", delta, vofs+vaddr,
(vofs & 0x80000000UL) ? 0x1e : 0x1f);
+ #endif /* end of patch by adamtk 98.12.14 */
break;
case 'M':
do_modrm(t);
- Raw text -