I found that the rtl_hard_enable_irq() has no problem.
because if i use like bottom .. it won't crash.

It's a module counting received interrupts. When it got 4 interrupts,
append it to linux.

#include <rtl.h>
#include <rtl_fifo.h>
#include <rtl_time.h>
#include <rtl_sched.h>
#include <rtl_sync.h>
#include <rtl_core.h>
#define IRQ1 4     // IRQ of device1
#define IRQ2 3    // IRQ of device2

long long int1, int2;

unsigned int int_handler(unsigned int irq, struct pt_regs *regs)
{
        switch (irq) {
                case IRQ1 :
                        int1++;
                        if (int1>=4) {
                                rtl_global_pend_irq(irq);
                                int1=0;
                        } else {
                                rtl_hard_enable_irq(irq);
                        }
                        break;
                case IRQ2 :
                        int2++;
                        if (int2>=4) {
                                rtl_global_pend_irq(irq);
                                int2=0;
                        } else {
                                rtl_hard_enable_irq(irq);
                        }
                        break;
                default :
                        break;
        }
        return 1;
}
int init_module(void)
{
        int ret;

        int1=0;
        int2=0;


        ret = rtl_request_irq(IRQ1, int_handler);
        if (ret) {
                rtl_printf("failed to get irq%d: %d\n", IRQ1, ret);
        } else { rtl_printf("got irq%d\n", IRQ1); }
        ret = rtl_request_irq(IRQ2, int_handler);
        if (ret) {
                rtl_printf("failed to get irq%d: %d\n", IRQ2, ret);
        } else {rtl_printf("got irq%d\n", IRQ2);}

        return 0;
}

void cleanup_module(void)
{
        rtl_free_irq(IRQ1);
        rtl_free_irq(IRQ2);
}

==========================================
But if i use periodic pending method , just like bottom.
system will halt. sometimes reboot automatically. why?

#include <rtl.h>
#include <rtl_fifo.h>
#include <rtl_time.h>
#include <rtl_sched.h>
#include <rtl_sync.h>
#include <rtl_core.h>

#define IRQ1 4     // IRQ of device1
#define IRQ2 3    // IRQ of device2

long long int1, int2;
pthread_t taskno;

unsigned int int_handler(unsigned int irq, struct pt_regs *regs)
{
        switch (irq) {
                case IRQ1 :
                        int1++;
                        break;
                case IRQ2 :
                        int2++;
                        break;
                default :
                        break;
        }
        rtl_hard_enable_irq(irq);
        return 1;
}

void *pend_thread(void *t) {
        while(1) {
                pthread_wait_np();
                if (int1) {
                        int1=0;
                        rtl_global_pend_irq(IRQ1);
                }
                if (int2) {
                        int2=0;
                        rtl_global_pend_irq(IRQ2);
                }
        }
}
int init_module(void)
{
        int ret;
        pthread_attr_t attr;
        struct sched_param sched_param;
        hrtime_t period ;

        int1=0;
        int2=0;

        period =  5000000000;

        ret = rtl_request_irq(IRQ1, int_handler);
        if (ret) {
                rtl_printf("failed to get irq%d: %d\n", IRQ1, ret);
        } else { rtl_printf("got irq%d\n", IRQ1); }
        ret = rtl_request_irq(IRQ2, int_handler);
        if (ret) {
                rtl_printf("failed to get irq%d: %d\n", IRQ2, ret);
        } else {rtl_printf("got irq%d\n", IRQ2);}

        pthread_attr_init(&attr);
        sched_param.sched_priority = 9;
        pthread_attr_setschedparam(&attr, &sched_param);
        pthread_create(&taskno, &attr, pend_thread, NULL);
        pthread_make_periodic_np(taskno, gethrtime(), period);

        return 0;
}

void cleanup_module(void)
{
        rtl_free_irq(IRQ1);
        rtl_free_irq(IRQ2);

        pthread_suspend_np(taskno);
        pthread_cancel(taskno);
        pthread_join(taskno, NULL);

}


-Iven
----- Original Message -----
From: "Der Herr Hofrat" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 2:07 PM
Subject: Re: [rtl] NIC and rtl_hard_enable_irq


> >
> > hello , everyone
> >
> >     i wonder to know is there anyone use
> >     the rtl_hard_enable_irq() successfully
> >     in a realtime ISR handling interrupts from
> >     an ethernet card ?
> >
> could you post a bit of additional info
>
> What NIC ?
> code sample of the interrupt handler
> also a bit more details on what goes wrong would help
>
> hofrat
> -- [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/

-- [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/

Reply via email to