<To RTLinux [EMAIL PROTECTED]>

G'morning Everyone,

I am trying to write an RTLinux module that does interrupt driven
data acquisition with Computer Board's PCI-DAS-1602 card on a 233
Mhz Pentium running Red Hat Linux 6.1 Kernel 2.2.14-rtl2.2.

I have a DOS program that programs the DAS card at the register
level so I am very familiar with programming this card.

I have an RTL module that compiles & loads. The interrupt service
routine (ISR) does in fact gets control and on the first interrupt
then the machine crashes ("oops" kernel dump) and the computer is
dead.

Once set up properly, I want the ISR to run every 1 ms, with the
interrupts paced by counters on the DAS card (not by a CPU timer)
after it finishes its "burst" (collects data into an on-card FIFO).
On each interrupt, my ISR reads the data off of the DAS card and
processes it.  I copied most of the code from my working DOS program
and the card appears to be setup properly to do this.

1. What do I have to do in my RTL module to indicate that the IRQ
   is a "shared IRQ" when I install my ISR?  (Both the PCI-DAS-1602
   and the 3COM 10Mbit ethernet card share IRQ 10).

2. What is the meaning of the return value for the ISR (the
   function specified in the rtl_request_irq() call)?  I looked at
   the RTL code and it appears to not be used.
   
3. When my ISR gets control, if it determines that the interrupt
   was NOT generated by the DAS card, what is the correct RTL code
   sequence (function calls) to exit my ISR so that the interrupt
   will be "chained" to the next (shared) ISR?
   
4. When my ISR gets control, if it determines that the interrupt
   WAS generated by the DAS card, what is the correct RTL code
   sequence (function calls) to reset the 8259 PIC and exit my ISR
   so that another interrupt can occur?  (Of course before I exit my
   ISR, I will make sure the DAS card has been correctly set up to
   generate another interrupt).
   
5. (Unrelated question) What must I do to safely use floating
   point inside an RTL FIFO handler call-back function (specified in
   the rtf_create_handler()) (I understand that I must call
   pthread_setfp_np() before I can use floating point in an RTL
   thread.)
   
Here are the relevant code fragments (that don't work).

//-----------------------------------------------------------------------
// Called from an RTL FIFO handler in the RTL module

static short
install_isr(void)
{
    short   err = P16ERR_OK;            // Return code (assume ok)
    INTERRUPT_STATE interrupts;         // (#defined as rtl_irqstate_t)
            
DisableInterrupts(&interrupts);         // ==rtl_no_interrupts()
err = rtl_request_irq(mio.Irq1Lvl, piggy);
if (err)
    {
    //print_msg("p1600b Error %d requesting IRQ %d", err, mio.Irq1Lvl);
    EnableInterrupts(&interrupts);
    return(P16ERR_INSTALLISRERR);
    }
    
PCI_EnableInts(pciDasInfo.badr0);       // ENABLE PCI INTERRUPTS ON DAS CARD
rtl_hard_enable_irq(mio.Irq1Lvl);       // Enable CPU interrupts for this IRQ
EnableInterrupts(&interrupts);          // ==rtl_restore_interrupts()

return(P16ERR_OK);
}

//-----------------------------------------------------------------------
// Called from an RTL FIFO handler in the RTL module

static short
remove_isr(void)
{
                                        // RESTORE ORIGINAL INTERRUPT
PCI_DisableInts(pciDasInfo.badr0);      // Disable DAS card interrupts
rtl_free_irq(mio.Irq1Lvl);              // Release IRQ

return(0);
} 

//-----------------------------------------------------------------------
// The ACKNOWLEDGE_CARD macro clears interrupts on the card and
// preforms any other actions necessary to prepare the card for
// the next interrupt.

#define ACKNOWLEDGE_CARD     ResetCardInterruptRequests() /* RESET DAS CARD 
INTERRUPTS. */

// The ACKNOWLEDGE_PIC macro clears the PIC by sending EOI in DOS.
// For Linux, PIC management is done for us so we don't mess with the PIC.

// LINUX - We ACK PCI but not PIC (this is done by RTLinux when our ISR returns)

#define ACKNOWLEDGE_PIC    PCI_ResetIRQ(pciDasInfo.badr0)     /* Acknowledge PCI 
controller on DAS card */

//-----------------------------------------------------------------------
static unsigned int                     // ISR declaration for LINUX
piggy(unsigned int irq, struct pt_regs *regs)
{                                       // DYNAMIC LOCAL VARIABLES DONT WORK!!

mio.status = inpw(INTADCFIFO);          // INTERRUPT & PACER CONTROL REGISTER

if (!(mio.status & 0x0080))             // DID DAS CAUSE INTERRUPT? (INT bit set?)
    {
                                        // THIS IS NOT OUR INTERRUPT!
    return(0);                          // ??what is return value used for?
    }

mio.isr_count++;                        // Count only our interrupts

// MOVE DATA OUT OF FIFO ON THE DAS CARD AND INTO OUR CPU MEMORY BUFFER

//c = mio.numChans;                       // # of words (Samples) to read from FIFO
//d = (int *) read_buffer + mio.numChans * nBursts;   // destination CPU buffer
//nBursts++;                              // Point to next burst
//REPINSW(c, d, ADCDATA);                 // REP INSW instruction

ACKNOWLEDGE_CARD;                       // Reset card
ACKNOWLEDGE_PIC;                        // Reset PIC

//if (mio.sched_isr)                      // If user specified a processing fcn..
//    (*mio.sched_isr)();                 // ..call user's processing fcn
                                          // NOTE: User's fcn _could_ enable CPU 
interrupts
        
DisableInterrupts(NULL);                // Interrupts will be enabled when we return

rtl_hard_enable_irq(mio.Irq1Lvl);       // Enable CPU interrupts for this IRQ

// ?? What is the meaning of the return value from an ISR?
// It doesn't appear to be used by anything by RTLinux.

return(0);
}



-------------------------
Shel Hoffman
Reflective Computing
917 Alanson Dr
St. Louis, MO 63132 USA
(314) 993-6132 voice
(314) 993-3316 fax
[EMAIL PROTECTED]
-------------------------


-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to