Changeset 7a8c866a in mainline


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

Move all MIPS exceptions to generic dispatcher.
Align size in malloc() to native size, some architectures
don't like it unaligned.

Files:
9 edited

Legend:

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

    re5fcf00 r7a8c866a  
    9595extern void exception_entry(void);
    9696extern void cache_error_entry(void);
     97extern void exception_init(void);
    9798#endif
  • arch/mips32/include/interrupt.h

    re5fcf00 r7a8c866a  
    3232#include <arch/exception.h>
    3333
    34 #define IVT_ITEMS   8
     34#define IVT_ITEMS   40
     35#define INT_OFFSET  32
     36
     37#define int_register(it, name, handler) exc_register(((it)+INT_OFFSET),name,handler)
    3538
    3639#define IRQ2    2
     
    4043#define TIMER_IRQ       IRQ7
    4144
    42 extern void interrupt(struct exception_regdump *pstate);
    4345extern void interrupt_init(void);
    4446
  • arch/mips32/src/drivers/arc.c

    re5fcf00 r7a8c866a  
    252252       
    253253        chardev_initialize("arc_console", &console, &arc_ops);
    254         old_timer = exc_register(TIMER_IRQ, "arc_kb_poll", timer_replace);
     254        old_timer = int_register(TIMER_IRQ, "arc_kb_poll", timer_replace);
    255255        return &console;
    256256}
  • arch/mips32/src/drivers/msim.c

    re5fcf00 r7a8c866a  
    8282        chardev_initialize("msim_console", &console, &msim_ops);
    8383
    84         exc_register(MSIM_KBD_IRQ, "msim_kbd", msim_interrupt);
     84        int_register(MSIM_KBD_IRQ, "msim_kbd", msim_interrupt);
    8585
    8686        cp0_unmask_int(MSIM_KBD_IRQ);
  • arch/mips32/src/drivers/serial.c

    re5fcf00 r7a8c866a  
    112112        kb_enabled = true;
    113113
    114 //      exc_register(2, "serial_drvr", serial_interrupt);
     114//      int_register(2, "serial_drvr", serial_interrupt);
    115115        /* I don't know why, but the serial interrupts simply
    116116         * don't work on simics
    117117         */
    118         old_timer = exc_register(TIMER_IRQ, "serial_drvr_poll", timer_replace);
     118        old_timer = int_register(TIMER_IRQ, "serial_drvr_poll", timer_replace);
    119119       
    120120
  • arch/mips32/src/exception.c

    re5fcf00 r7a8c866a  
    3535#include <debug.h>
    3636#include <proc/thread.h>
     37#include <symtab.h>
     38#include <print.h>
     39#include <interrupt.h>
     40
     41static char * exctable[] = {
     42        "Interrupt","TLB Modified","TLB Invalid","TLB Invalid Store",
     43                "Address Error - load/instr. fetch",
     44                "Address Error - store",
     45                "Bus Error - fetch instruction",
     46                "Bus Error - data reference",
     47                "Syscall",
     48                "BreakPoint",
     49                "Reserved Instruction",
     50                "Coprocessor Unusable",
     51                "Arithmetic Overflow",
     52                "Trap",
     53                "Virtual Coherency - instruction",
     54                "Floating Point",
     55                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     56                "WatchHi/WatchLo", /* 23 */
     57                NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     58                "Virtual Coherency - data",
     59};
     60
     61static void print_regdump(struct exception_regdump *pstate)
     62{
     63        char *pcsymbol = "";
     64        char *rasymbol = "";
     65
     66        char *s = get_symtab_entry(pstate->epc);
     67        if (s)
     68                pcsymbol = s;
     69        s = get_symtab_entry(pstate->ra);
     70        if (s)
     71                rasymbol = s;
     72       
     73        printf("PC: %X(%s) RA: %X(%s)\n",pstate->epc,pcsymbol,
     74               pstate->ra,rasymbol);
     75}
     76
     77static void unhandled_exception(int n, void *data)
     78{
     79        struct exception_regdump *pstate = (struct exception_regdump *)data;
     80
     81        print_regdump(pstate);
     82        panic("unhandled exception %s\n", exctable[n]);
     83}
     84
     85static void breakpoint_exception(int n, void *data)
     86{
     87        struct exception_regdump *pstate = (struct exception_regdump *)data;
     88        /* it is necessary to not re-execute BREAK instruction after
     89           returning from Exception handler
     90           (see page 138 in R4000 Manual for more information) */
     91        pstate->epc += 4;
     92}
     93
     94static void tlbmod_exception(int n, void *data)
     95{
     96        struct exception_regdump *pstate = (struct exception_regdump *)data;
     97        tlb_modified(pstate);
     98}
     99
     100static void tlbinv_exception(int n, void *data)
     101{
     102        struct exception_regdump *pstate = (struct exception_regdump *)data;
     103        tlb_invalid(pstate);
     104}
     105
     106static void cpunsbl_exception(int n, void *data)
     107{
     108        if (cp0_cause_coperr(cp0_cause_read()) == fpu_cop_id)
     109                scheduler_fpu_lazy_request();
     110        else
     111                panic("unhandled Coprocessor Unusable Exception\n");
     112}
     113
     114static void interrupt_exception(int n, void *pstate)
     115{
     116        __u32 cause;
     117        int i;
     118       
     119        /* decode interrupt number and process the interrupt */
     120        cause = (cp0_cause_read() >> 8) &0xff;
     121       
     122        for (i = 0; i < 8; i++)
     123                if (cause & (1 << i))
     124                        exc_dispatch(i+INT_OFFSET, pstate);
     125}
     126
    37127
    38128void exception(struct exception_regdump *pstate)
     
    64154        cause = cp0_cause_read();
    65155        excno = cp0_cause_excno(cause);
    66         /* decode exception number and process the exception */
    67         switch (excno) {
    68                 case EXC_Int:
    69                         interrupt(pstate);
    70                         break;
    71                 case EXC_TLBL:
    72                 case EXC_TLBS:
    73                         tlb_invalid(pstate);
    74                         break;
    75                 case EXC_CpU:
    76 #ifdef CONFIG_FPU_LAZY     
    77                         if (cp0_cause_coperr(cause) == fpu_cop_id)
    78                                 scheduler_fpu_lazy_request();
    79                         else
    80 #endif
    81                                 panic("unhandled Coprocessor Unusable Exception\n");
    82                         break;
    83                 case EXC_Mod:
    84                         tlb_modified(pstate);
    85                         break;
    86                 case EXC_AdEL:
    87                         panic("unhandled Address Error Exception - load or instruction fetch\n");
    88                         break;
    89                 case EXC_AdES:
    90                         panic("unhandled Address Error Exception - store\n");
    91                         break;
    92                 case EXC_IBE:
    93                         panic("unhandled Bus Error Exception - fetch instruction\n");
    94                         break;
    95                 case EXC_DBE:
    96                         panic("unhandled Bus Error Exception - data reference: load or store\n");
    97                         break;
    98                 case EXC_Bp:
    99                         /* it is necessary to not re-execute BREAK instruction after returning from Exception handler
    100                            (see page 138 in R4000 Manual for more information) */
    101                         epc_shift = 4;
    102                         break;
    103                 case EXC_RI:
    104                         panic("unhandled Reserved Instruction Exception\n");
    105                         break;
    106                 case EXC_Ov:
    107                         panic("unhandled Arithmetic Overflow Exception\n");
    108                         break;
    109                 case EXC_Tr:
    110                         panic("unhandled Trap Exception\n");
    111                         break;
    112                 case EXC_VCEI:
    113                         panic("unhandled Virtual Coherency Exception - instruction\n");
    114                         break;
    115                 case EXC_FPE:
    116                         panic("unhandled Floating-Point Exception\n");
    117                         break;
    118                 case EXC_WATCH:
    119                         panic("unhandled reference to WatchHi/WatchLo address\n");
    120                         break;
    121                 case EXC_VCED:
    122                         panic("unhandled Virtual Coherency Exception - data\n");
    123                         break;
    124                 default:
    125                         panic("unhandled exception %d\n", excno);
    126         }
    127        
    128         pstate->epc += epc_shift;
     156        /* Dispatch exception */
     157        exc_dispatch(excno, pstate);
     158
    129159        /* Set to NULL, so that we can still support nested
    130160         * exceptions
     
    136166                THREAD->pstate = NULL;
    137167}
     168
     169void exception_init(void)
     170{
     171        int i;
     172
     173        /* Clear exception table */
     174        for (i=0;i < IVT_ITEMS; i++)
     175                exc_register(i, "undef", unhandled_exception);
     176        exc_register(EXC_Bp, "bkpoint", breakpoint_exception);
     177        exc_register(EXC_Mod, "tlb_mod", tlbmod_exception);
     178        exc_register(EXC_TLBL, "tlbinvl", tlbinv_exception);
     179        exc_register(EXC_TLBS, "tlbinvl", tlbinv_exception);
     180        exc_register(EXC_Int, "interrupt", interrupt_exception);
     181#ifdef CONFIG_FPU_LAZY
     182        exc_register(EXC_CpU, "cpunus", cpun_exception);
     183#endif
     184}
  • arch/mips32/src/interrupt.c

    re5fcf00 r7a8c866a  
    3333#include <arch/cp0.h>
    3434#include <time/clock.h>
    35 #include <panic.h>
    36 #include <print.h>
    37 #include <symtab.h>
    3835#include <arch/drivers/arc.h>
    39 
    40 static void print_regdump(struct exception_regdump *pstate)
    41 {
    42         char *pcsymbol = "";
    43         char *rasymbol = "";
    44 
    45         char *s = get_symtab_entry(pstate->epc);
    46         if (s)
    47                 pcsymbol = s;
    48         s = get_symtab_entry(pstate->ra);
    49         if (s)
    50                 rasymbol = s;
    51        
    52         printf("PC: %X(%s) RA: %X(%s)\n",pstate->epc,pcsymbol,
    53                pstate->ra,rasymbol);
    54 }
    5536
    5637/** Disable interrupts.
     
    9475}
    9576
    96 static void unhandled_exception(int n, void *stack)
    97 {
    98         struct exception_regdump *pstate = (struct exception_regdump *)stack;
    99 
    100         print_regdump(pstate);
    101         panic("unhandled interrupt %d\n", n);
    102 }
    103 
    10477static void timer_exception(int n, void *stack)
    10578{
     
    11891}
    11992
    120 /** Basic exception handler */
    121 void interrupt(struct exception_regdump *pstate)
    122 {
    123         __u32 cause;
    124         int i;
    125        
    126         /* decode interrupt number and process the interrupt */
    127         cause = (cp0_cause_read() >> 8) &0xff;
    128        
    129         for (i = 0; i < 8; i++)
    130                 if (cause & (1 << i))
    131                         exc_dispatch(i, (void *)pstate);
    132 }
    133 
    13493/* Initialize basic tables for exception dispatching */
    13594void interrupt_init(void)
     
    13796        int i;
    13897
    139         for (i=0;i < IVT_ITEMS; i++)
    140                 exc_register(i, "undef", unhandled_exception);
    141 
    142         exc_register(TIMER_IRQ, "timer", timer_exception);
    143         exc_register(0, "swint0", swint0);
    144         exc_register(1, "swint1", swint1);
     98        int_register(TIMER_IRQ, "timer", timer_exception);
     99        int_register(0, "swint0", swint0);
     100        int_register(1, "swint1", swint1);
    145101}
  • arch/mips32/src/mips32.c

    re5fcf00 r7a8c866a  
    6161       
    6262        /* Initialize dispatch table */
     63        exception_init();
    6364        interrupt_init();
    6465
  • generic/src/mm/heap.c

    re5fcf00 r7a8c866a  
    3535#include <arch/asm.h>
    3636#include <arch.h>
     37#include <align.h>
    3738
    3839/*
     
    6364        ipl_t ipl;
    6465        chunk_t *x, *y, *z;
     66
     67        size = ALIGN_UP(size, sizeof(__native));
    6568
    6669        if (size == 0)
Note: See TracChangeset for help on using the changeset viewer.