Ignore:
Timestamp:
2011-04-13T14:45:41Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
88634420
Parents:
cefb126 (diff), 17279ead (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/interrupt/interrupt.c

    rcefb126 r89c57b6  
    4545#include <console/console.h>
    4646#include <console/cmd.h>
    47 #include <ipc/event.h>
    4847#include <synch/mutex.h>
    4948#include <time/delay.h>
     
    5554#include <arch/cycle.h>
    5655#include <str.h>
     56#include <trace.h>
    5757
    5858exc_table_t exc_table[IVT_ITEMS];
     
    9797 *
    9898 */
    99 void exc_dispatch(unsigned int n, istate_t *istate)
    100 {
    101         ASSERT(CPU);
    102        
     99NO_TRACE void exc_dispatch(unsigned int n, istate_t *istate)
     100{
    103101#if (IVT_ITEMS > 0)
    104102        ASSERT(n < IVT_ITEMS);
     
    113111       
    114112        /* Account CPU usage if it has waked up from sleep */
    115         irq_spinlock_lock(&CPU->lock, false);
    116         if (CPU->idle) {
    117                 uint64_t now = get_cycle();
    118                 CPU->idle_cycles += now - CPU->last_cycle;
    119                 CPU->last_cycle = now;
    120                 CPU->idle = false;
    121         }
    122         irq_spinlock_unlock(&CPU->lock, false);
     113        if (CPU) {
     114                irq_spinlock_lock(&CPU->lock, false);
     115                if (CPU->idle) {
     116                        uint64_t now = get_cycle();
     117                        CPU->idle_cycles += now - CPU->last_cycle;
     118                        CPU->last_cycle = now;
     119                        CPU->idle = false;
     120                }
     121                irq_spinlock_unlock(&CPU->lock, false);
     122        }
    123123       
    124124        uint64_t begin_cycle = get_cycle();
     
    159159 *
    160160 */
    161 static void exc_undef(unsigned int n, istate_t *istate)
     161NO_TRACE static void exc_undef(unsigned int n, istate_t *istate)
    162162{
    163163        fault_if_from_uspace(istate, "Unhandled exception %u.", n);
    164         panic("Unhandled exception %u.", n);
     164        panic_badtrap(istate, n, "Unhandled exception %u.", n);
    165165}
    166166
     
    168168 *
    169169 */
    170 void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)
     170NO_TRACE void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)
    171171{
    172172        if (!istate_from_uspace(istate))
     
    175175        printf("Task %s (%" PRIu64 ") killed due to an exception at "
    176176            "program counter %p.\n", TASK->name, TASK->taskid,
    177             istate_get_pc(istate));
     177            (void *) istate_get_pc(istate));
    178178       
    179179        stack_trace_istate(istate);
     
    187187        printf("\n");
    188188       
     189        task_kill_self(true);
     190}
     191
     192/** Get istate structure of a thread.
     193 *
     194 * Get pointer to the istate structure at the bottom of the kernel stack.
     195 *
     196 * This function can be called in interrupt or user context. In interrupt
     197 * context the istate structure is created by the low-level exception
     198 * handler. In user context the istate structure is created by the
     199 * low-level syscall handler.
     200 */
     201istate_t *istate_get(thread_t *thread)
     202{
    189203        /*
    190          * Userspace can subscribe for FAULT events to take action
    191          * whenever a thread faults. (E.g. take a dump, run a debugger).
    192          * The notification is always available, but unless Udebug is enabled,
    193          * that's all you get.
     204         * The istate structure should be right at the bottom of the kernel
     205         * stack.
    194206         */
    195         if (event_is_subscribed(EVENT_FAULT)) {
    196                 /* Notify the subscriber that a fault occurred. */
    197                 event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid),
    198                     UPPER32(TASK->taskid), (unative_t) THREAD);
    199                
    200 #ifdef CONFIG_UDEBUG
    201                 /* Wait for a debugging session. */
    202                 udebug_thread_fault();
    203 #endif
    204         }
    205        
    206         task_kill(TASK->taskid);
    207         thread_exit();
     207        return (istate_t *) ((uint8_t *) thread->kstack + THREAD_STACK_SIZE -
     208            sizeof(istate_t));
    208209}
    209210
     
    215216 *
    216217 */
    217 static int cmd_exc_print(cmd_arg_t *argv)
     218NO_TRACE static int cmd_exc_print(cmd_arg_t *argv)
    218219{
    219220        bool excs_all;
     
    262263               
    263264                const char *symbol =
    264                     symtab_fmt_name_lookup((unative_t) exc_table[i].handler);
     265                    symtab_fmt_name_lookup((sysarg_t) exc_table[i].handler);
    265266               
    266267#ifdef __32_BITS__
Note: See TracChangeset for help on using the changeset viewer.