delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/03/21/19:14:39

Date: Tue, 21 Mar 95 11:43:55 -0800
From: brad AT tamri DOT com (Brad Walker)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: a DJGPP bug in interrupts

I think I'm hitting a bug in DJGPP and wanted to pass something by you.
I've attached my code at the end of this e-mail.

What I'm seeing this that my program never exits. It just keeps on running
until I hit a key. Then it exits and freezes. The value of flag gets updated
as it should be. I'm just surprised that once my interrupt routine gets called
the driver doesn't immediately exit because the while spin loop test
should fail. When I hit a key on the keyboard everything exits and then the
system hangs.

One last thing. I'm running the current version of DJGPP with maintance
patches.

Thanks a bunch!!


-brad w.



===========================================================================


/*
 *      COPYRIGHT (c) 1992 BY Toshiba America MRI, Inc., S. San Francisco, CA.
 *
 *      THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND
 *      COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH
 *      THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR
 *      ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
 *      AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE
 *      PROGRAM IS HEREBY TRANSFERRED.
 *
 *      THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
 *      NOTICE AND SHOULD NOT BE CONSIDERED AS A COMMITMENT BY Toshiba
 *      America MRI, INC.
 *
 *
 *      file:   drfep.ss
 *      author: bwalker
 *      created:        9/7/94
 *      sccs info:      %W%
 *
 *      (c)1994  Toshiba America MRI, Inc. All Rights Reserved.
 */


#include <sys/types.h>
#include <dpmi.h>
#include <go32.h>
#include <stdio.h>

#include "test.out"           /* compiled SCIPTS for NCR 53C7x0 */
#include "test.h"

#include "720_reg.h"

volatile int    flag = 0;

static _go32_dpmi_seginfo dosmem;
static _go32_dpmi_seginfo oldirq;
static _go32_dpmi_seginfo newirq;
static _go32_dpmi_registers regs;


void
pci_intr(void)
{
	flag = 6;

	(void)inportb(0xfc8c);        
	outportb(0x20, 0x20);
	outportb(0xa0, 0x20);

}


/* the table used to table-indirect referances */
volatile struct scsi_buffers *buffer_table;


main(int argc, char *argv[])
{
	int i, cnt;
	u_char filler;

	/* parse the arguments */


	/*
	 * build into the program the parsing of options
	 *
	 * need to handle: 1) SCSI id of ourselves, 2) diag mode
	 *                      3) board address, 4) dma channel
	 *                      5) intr level
	 */
	printf("Program start\n");

	/* reset the chip */
	outportb(0xfc94, inportb(0xfc94) | 0x40);        
	delay(1);
	outportb(0xfc94, inportb(0xfc94) & ~0x40);        
	
	printf("ENABLE intrs\n");        
	outportb(0xfcb9, inportb(0xfcb9) | 0x7d);
	printf("dien: 0x%x\n", inportb(0xfcb9));        
	outportb(0xfcbb, inportb(0xfcbb) | 0x1);

	/* out a couple of the chip registers */
	printf("ctest3 = 0x%x\n", inportb(0xfc9b));
	printf("flag = 0x%x\n", flag);

	newirq.pm_offset = (int)pci_intr;
	newirq.pm_selector = _go32_my_cs();        

	_go32_dpmi_get_protected_mode_interrupt_vector(0x9, &oldirq);
	_go32_dpmi_chain_protected_mode_interrupt_vector(0x9, &newirq);
	
	/* allocate space for the chip microcode */
	printf("running SCRIPTS\n");
	dosmem.size = (sizeof(SCRIPT) + 30) / 16;
	if (_go32_dpmi_allocate_dos_memory(&dosmem)) {
		printf("unable to allocate DOS memory\n");
		exit(1);        
	}

	/* copy the microcode in the DMA space */
	movedata(_go32_my_ds(), (int)&SCRIPT[0],
		 _go32_conventional_mem_selector(), (dosmem.rm_segment * 16),
		 sizeof(SCRIPT));

	/* tell the chip where to begin fetching the microcode from */
	outportl(0xfcac, (dosmem.rm_segment * 16) + Ent_scr_entry);
	
	/* wait for the interrupt routine to be called */
	while (flag == 0)
		;

	/* dump out some of the registers */
	printf("dien: 0x%x\n", inportb(0xfcb9));        
	printf("istat: 0x%x, dstat: 0x%x\n",
		inportb(0xfc94), inportb(0xfc8c));
	printf("dsps: 0x%x\n", inportl(0xfcb0));

	printf("flag = 0x%x\n", flag);
	_go32_dpmi_set_protected_mode_interrupt_vector(0x9, &oldirq);

	printf("end program\n");
	return 1;

}



- Raw text -


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