delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/11/16/22:42:20

Date: Sun, 17 Nov 1996 16:36:55 +0000
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: cwsdpmi - rm callbacks and pm sw ints
To: Charles Sandmann <sandmann AT clio DOT rice DOT edu>
Cc: djgpp-workers AT delorie DOT com
Reply-to: billc AT blackmagic DOT tait DOT co DOT nz
Message-id: <328F3F27.4ADE@blackmagic.tait.co.nz>
Organization: Tait Electronics NZ
MIME-version: 1.0

This is a multi-part message in MIME format.

--------------57B812062D4C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

It seems I may have found a bug in cwsdpmi (I hope I'm wrong and it's my
code).

If I allocate a real mode callback and insert it in the dos int 21 chain
(havn't tried for others), and do a __dpmi_int(0x21,&regs), everything
works fine. BUT, if I us a software interrupt instead, the computer
locks up  and requires a reset.

I've attaced my test code (which works perfectly under windows 3.11).
Bill
-- 
Leave others their otherness.

--------------57B812062D4C
Content-Type: text/plain; charset=us-ascii; name="INT21.C"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="INT21.C"

#include <dpmi.h>
#include <go32.h>
#include <sys/farptr.h>

void handleInt21(void);

__dpmi_regs dpmi_regs;
unsigned long oldInt21;

/* if ax==0x3000 (get version) return deadbeef as the version number
 * if ah==0x40 (write to handle) click the speaker and chain to dos
 */
asm("
_handleInt21:
		pushl	%eax
		cmpw	$0x3000,%es:0x1c(%edi)
		je		1f
		cmpb	$0x40,%es:0x1d(%edi)
		jne		2f
		inb		$0x61,%al
		xorb	$2,%al
		outb	%al,$0x61
2:		movl	%cs:_oldInt21,%eax
		movl	%eax,%es:0x2a(%edi)
		popl	%eax
		iret
1:
		movl	$0xdeadbeef,%es:0x1c(%edi)
		movl	%ds:(%esi),%eax
		movl	%eax,%es:0x2a(%edi)
		movw	%ds:4(%esi),%ax
		movw	%ax,%es:0x20(%edi)
		popl	%eax
		iret
");

int main()
{
	__dpmi_raddr raddr;
	__dpmi_regs regs;

	_go32_dpmi_lock_code(handleInt21,(unsigned long)main-(unsigned long)handleInt21);
	_go32_dpmi_lock_data(&dpmi_regs,sizeof(dpmi_regs));

	memset(&regs,0,sizeof(regs));
	__dpmi_allocate_real_mode_callback(handleInt21,&dpmi_regs,&raddr);
	_farsetsel(_dos_ds);
	oldInt21=_farnspeekl(0x21*4);
	asm("int $0x21":"=a"(regs.d.eax):"0"(0x3000):"%ebx","%ecx");
	printf("%08lx\n",regs.d.eax);
	regs.x.ax=0x3000;
	__dpmi_int(0x21,&regs);
	printf("%08lx\n",regs.d.eax);
	_farnspokel(0x21*4,raddr.segment<<16|raddr.offset16);
	regs.x.ax=0x3000;
	__dpmi_int(0x21,&regs);
	printf("%08lx\n",regs.d.eax);
	asm("int $0x21":"=a"(regs.d.eax):"0"(0x3000):"%ebx","%ecx");
	printf("%08lx\n",regs.d.eax);
	_farnspokel(0x21*4,oldInt21);
	asm("int $0x21":"=a"(regs.d.eax):"0"(0x3000):"%ebx","%ecx");
	printf("%08lx\n",regs.d.eax);
	regs.x.ax=0x3000;
	__dpmi_int(0x21,&regs);
	printf("%08lx\n",regs.d.eax);
	return 0;
}

--------------57B812062D4C--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019