Ignore:
File:
1 edited

Legend:

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

    r181a746 r8f4f444  
    5050#include <panic.h>
    5151#include <print.h>
     52#include <stdarg.h>
    5253#include <symtab.h>
    5354#include <proc/thread.h>
     
    110111        }
    111112       
    112         /* Account CPU usage if it woke up from sleep */
    113         if (CPU && CPU->idle) {
     113        /* Account CPU usage if it has waked up from sleep */
     114        if (CPU) {
    114115                irq_spinlock_lock(&CPU->lock, false);
    115                 uint64_t now = get_cycle();
    116                 CPU->idle_cycles += now - CPU->last_cycle;
    117                 CPU->last_cycle = now;
    118                 CPU->idle = 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                }
    119122                irq_spinlock_unlock(&CPU->lock, false);
    120123        }
     
    163166}
    164167
    165 /** Terminate thread and task if exception came from userspace.
    166  *
    167  */
    168 NO_TRACE void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)
    169 {
    170         if (!istate_from_uspace(istate))
    171                 return;
    172        
     168static NO_TRACE void fault_from_uspace_core(istate_t *istate, const char *fmt, va_list args)
     169{
    173170        printf("Task %s (%" PRIu64 ") killed due to an exception at "
    174171            "program counter %p.\n", TASK->name, TASK->taskid,
     
    179176       
    180177        printf("Kill message: ");
     178        vprintf(fmt, args);
     179        printf("\n");
     180       
     181        task_kill_self(true);
     182}
     183
     184/** Terminate thread and task after the exception came from userspace.
     185 *
     186 */
     187NO_TRACE void fault_from_uspace(istate_t *istate, const char *fmt, ...)
     188{
     189        va_list args;
     190
     191        va_start(args, fmt);
     192        fault_from_uspace_core(istate, fmt, args);
     193        va_end(args);
     194}
     195
     196/** Terminate thread and task if exception came from userspace.
     197 *
     198 */
     199NO_TRACE void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)
     200{
     201        if (!istate_from_uspace(istate))
     202                return;
    181203       
    182204        va_list args;
    183205        va_start(args, fmt);
    184         vprintf(fmt, args);
     206        fault_from_uspace_core(istate, fmt, args);
    185207        va_end(args);
    186         printf("\n");
    187        
    188         task_kill_self(true);
    189208}
    190209
Note: See TracChangeset for help on using the changeset viewer.