Changeset aace6624 in mainline


Ignore:
Timestamp:
2005-12-10T02:05:05Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
402fc8bf
Parents:
6095342
Message:

Added exception printing.
It does not work correctly on SMP architectures :-/
Preemption error….

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • arch/mips32/include/interrupt.h

    r6095342 raace6624  
    3232#include <arch/exception.h>
    3333
    34 #define IVT_ITEMS   32
     34#define IVT_ITEMS   8
    3535
    3636#define IRQ2    2
  • generic/include/interrupt.h

    r6095342 raace6624  
    3838typedef void (* iroutine)(int n, void *stack);
    3939
    40 extern iroutine exc_register(int n, char *name, iroutine f);
     40extern iroutine exc_register(int n, const char *name, iroutine f);
    4141extern void exc_dispatch(int n, void *stack);
     42void exc_init(void);
    4243
    4344#endif
  • generic/src/interrupt/interrupt.c

    r6095342 raace6624  
    2929#include <interrupt.h>
    3030#include <debug.h>
     31#include <console/kconsole.h>
     32#include <console/console.h>
     33#include <console/chardev.h>
     34#include <panic.h>
     35#include <print.h>
     36#include <symtab.h>
    3137
    3238static struct {
    33         char *name;
     39        const char *name;
    3440        iroutine f;
    35 } ivt[IVT_ITEMS];
     41} exc_table[IVT_ITEMS];
    3642
    37 iroutine exc_register(int n, char *name, iroutine f)
     43static spinlock_t exctbl_lock;
     44
     45/** Register exception handler
     46 *
     47 * @param n Exception number
     48 * @param name Description
     49 * @param f Exception handler
     50 */
     51iroutine exc_register(int n, const char *name, iroutine f)
    3852{
    3953        ASSERT(n < IVT_ITEMS);
     
    4155        iroutine old;
    4256       
    43         old = ivt[n].f;
    44         ivt[n].f = f;
    45         ivt[n].name = name;
    46        
     57        spinlock_lock(&exctbl_lock);
     58
     59        old = exc_table[n].f;
     60        exc_table[n].f = f;
     61        exc_table[n].name = name;
     62
     63        spinlock_unlock(&exctbl_lock); 
     64
    4765        return old;
    4866}
    4967
    50 /*
     68/** Dispatch exception according to exception table
     69 *
    5170 * Called directly from the assembler code.
    5271 * CPU is interrupts_disable()'d.
     
    5675        ASSERT(n < IVT_ITEMS);
    5776       
    58         ivt[n].f(n, stack);
     77        exc_table[n].f(n, stack);
    5978}
     79
     80/** Default 'null' exception handler */
     81static void exc_undef(int n, void *stack)
     82{
     83        panic("Unhandled exception %d.", n);
     84}
     85
     86/** KConsole cmd - print all exceptions */
     87static int exc_print_cmd(cmd_arg_t *argv)
     88{
     89        int i;
     90        char *symbol;
     91
     92        spinlock_lock(&exctbl_lock);
     93        printf("Exc Handler    Description\n");
     94        for (i=0; i < IVT_ITEMS; i++) {
     95                symbol = get_symtab_entry((__native)exc_table[i].f);
     96                if (!symbol)
     97                        symbol = "not found";
     98                printf("%d %s 0x%p(%s)\n",i,exc_table[i].name,
     99                       exc_table[i].f,symbol);         
     100                if (!((i+1) % 20)) {
     101                        printf("Press any key to continue.");
     102                        getc(stdin);
     103                        printf("\n");
     104                }
     105        }
     106        spinlock_unlock(&exctbl_lock);
     107       
     108        return 1;
     109}
     110
     111static cmd_info_t exc_info = {
     112        .name = "exc_print",
     113        .description = "Print exception table",
     114        .func = exc_print_cmd,
     115        .help = NULL,
     116        .argc = 0,
     117        .argv = NULL
     118};
     119
     120/** Initialize generic exception handling support */
     121void exc_init(void)
     122{
     123        int i;
     124
     125        spinlock_initialize(&exctbl_lock, "exctbl_lock");
     126
     127        for (i=0;i < IVT_ITEMS; i++)
     128                exc_register(i, "undef", exc_undef);
     129
     130        spinlock_initialize(&exc_info.lock, "kconsole_excinfo");
     131        link_initialize(&exc_info.link);
     132        if (!cmd_register(&exc_info))
     133                panic("could not register command %s\n", exc_info.name);
     134}
     135
  • generic/src/main/kinit.c

    r6095342 raace6624  
    4545#include <memstr.h>
    4646#include <console/console.h>
     47#include <interrupt.h>
    4748#include <console/kconsole.h>
    4849
  • generic/src/main/main.c

    r6095342 raace6624  
    4141#include <cpu.h>
    4242#include <align.h>
     43#include <interrupt.h>
    4344
    4445#ifdef CONFIG_SMP
     
    174175         */
    175176        kconsole_init();
     177        /* Exception handler initialization, before architecture
     178         * starts adding it's own handlers
     179         */
     180        exc_init();
    176181       
    177182        arch_pre_mm_init();
Note: See TracChangeset for help on using the changeset viewer.