Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

enable/disable interrupt

Hi,

I am porting a small kernel from avr to nios2 using a DE2 board. I have tried to modify the enable and disable interrupt macro like the follow:

# define DISABLE_INTERRUPTS {

asm volatile (

"addi r27, r27, -4 \n\t"

"stw r3, 0(r27) \n\t"

"addi r27, r27, -4 \n\t"

"stw r2, 0(r27) \n\t"

"movhi r2, 0xFF00 \n\t"

"subi r2, r2, 2 \n\t"

"rdctl r3, ctl0 \n\t"

"and r3, r3, r2 \n\t"

"wrctl ctl0, r3 \n\t"

"ldw r2, 0(r27) \n\t"

"addi r27, r27, 4 \n\t"

"ldw r3, 0(r27) \n\t"

"addi r27, r27, 4 " );

}

# define ENABLE_INTERRUPTS {

asm volatile (

"addi r27, r27, -4 \n\t"

"stw r3, 0(r27) \n\t"

"rdctl r3, ctl0 \n\t"

"ori r3, r3, 1 \n\t"

"wrctl ctl0, r3 \n\t"

"ldw r3, 0(r27) \n\t"

"addi r27, r27, 4 " );

}

When I try to debug using the hardware, the status register can not be correctly set. But when I use the instruction set simulator, it works fine.

Can someone give me some hint.

with regards,

Wei

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi aprado,

    --- Quote Start ---

    Why don't you use altera's library irq enable and disable?

    --- Quote End ---

    I have looked into the provided one.

    The alt_irq_enable_all need a context, which force me the modify other kernel code.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    you can pass null as the context i think

    --- Quote End ---

    I will try that.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Context is useful when calling irq enable all to restore interrupt conditions present before calling irq disable all!