From 385212f554e997e01abb89243b938bb03ae0e451 Mon Sep 17 00:00:00 2001 From: Till Straumann Date: Fri, 30 Oct 2009 04:07:51 +0000 Subject: 2009-10-29 Till Straumann * shared/irq/irq_asm.S: Make sure stack is aligned to CPU_STACK_ALIGNMENT for *all* C-routines (including _Thread_Dispatch() and _ThreadProcessSignalsFromIrq()) not only C_dispatch_isr(). * shared/irq/irq.c: Added IRQ statistics counters. --- c/src/lib/libbsp/i386/ChangeLog | 8 ++++ c/src/lib/libbsp/i386/shared/irq/irq.c | 19 ++++++++ c/src/lib/libbsp/i386/shared/irq/irq_asm.S | 72 +++++++++++++++++++----------- 3 files changed, 72 insertions(+), 27 deletions(-) diff --git a/c/src/lib/libbsp/i386/ChangeLog b/c/src/lib/libbsp/i386/ChangeLog index d4f0193575..bcf7664ee9 100644 --- a/c/src/lib/libbsp/i386/ChangeLog +++ b/c/src/lib/libbsp/i386/ChangeLog @@ -1,3 +1,11 @@ +2009-10-29 Till Straumann + + * shared/irq/irq_asm.S: Make sure stack is aligned to CPU_STACK_ALIGNMENT + for *all* C-routines (including _Thread_Dispatch() and + _ThreadProcessSignalsFromIrq()) not only C_dispatch_isr(). + + * shared/irq/irq.c: Added IRQ statistics counters. + 2009-10-29 Till Straumann * shared/irq/irq_asm.S: Beautification; ajusted margins and diff --git a/c/src/lib/libbsp/i386/shared/irq/irq.c b/c/src/lib/libbsp/i386/shared/irq/irq.c index 450ff35848..5e66817a88 100644 --- a/c/src/lib/libbsp/i386/shared/irq/irq.c +++ b/c/src/lib/libbsp/i386/shared/irq/irq.c @@ -21,6 +21,8 @@ #include #include +#include +#include /* * pointer to the mask representing the additionnal irq vectors @@ -32,6 +34,22 @@ */ rtems_i8259_masks irq_mask_or_tbl[BSP_IRQ_LINES_NUMBER]; +uint32_t irq_count[BSP_IRQ_LINES_NUMBER] = {0}; + +uint32_t +BSP_irq_count_dump(FILE *f) +{ +uint32_t tot = 0; +int i; + if ( !f ) + f = stdout; + for ( i=0; iesp near the end of every interrupt. */ nested: @@ -102,26 +120,19 @@ nested: incl SYM (_Thread_Dispatch_disable_level) /* disable multitasking */ /* - * Ensure CPU_STACK_ALIGNMENT for C-code. - * esp = (esp - 4) & ~(CPU_STACK_ALIGNMENT - 1) - * makes sure 'esp' is aligned AND there is enough space - * for the vector argument on the stack! - */ - subl $4, esp - - andl $ - CPU_STACK_ALIGNMENT, esp - /* * re-enable interrupts at processor level as the current * interrupt source is now masked via i8259 */ sti /* - * ECX is preloaded with the vector number but it is a scratch register - * so we must save it again. + * ECX is preloaded with the vector number; store as arg + * on top of stack. Note that _CPU_Interrupt_stack_high + * was adjusted in _CPU_Interrupt_stack_setup() (score/rtems/cpu.h) + * to make sure there is space. */ - movl ecx, (esp) /* store vector arg in stack */ + movl ecx, ARG_OFF(esp) /* store vector arg in stack */ call C_dispatch_isr /* @@ -130,15 +141,15 @@ nested: cli /* - * restore stack + * Restore stack. This moves back to the task stack + * when all interrupts are unnested. */ movl ebp, esp - popl ebp /* * restore the original i8259 masks */ - popl eax + movl MSK_OFF(esp), eax movw ax, SYM (i8259s_cache) outb $PIC_MASTER_IMR_IO_PORT movb ah, al @@ -186,6 +197,10 @@ nested: * eip, CS, Flags). */ .exit: + /* restore ebp and original esp */ + addl $EBP_OFF, esp + popl ebp + popl esp /* * BEGINNING OF DE-ESTABLISH SEGMENTS * @@ -241,7 +256,10 @@ PUBLIC (raw_idt_notify) SYM (default_raw_idt_handler): pusha cld - call raw_idt_notify + mov esp, ebp + andl $ - CPU_STACK_ALIGNMENT, esp + call raw_idt_notify + mov ebp, esp popa iret -- cgit v1.2.3