Ignore:
File:
1 edited

Legend:

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

    r5cac9cd re4d96e9  
    5050#include <panic.h>
    5151#include <print.h>
     52#include <stdarg.h>
    5253#include <symtab.h>
    5354#include <proc/thread.h>
    5455#include <arch/cycle.h>
     56#include <arch/stack.h>
    5557#include <str.h>
    5658#include <trace.h>
     
    165167}
    166168
    167 /** Terminate thread and task if exception came from userspace.
    168  *
    169  */
    170 NO_TRACE void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)
    171 {
    172         if (!istate_from_uspace(istate))
    173                 return;
    174        
     169static NO_TRACE
     170void fault_from_uspace_core(istate_t *istate, const char *fmt, va_list args)
     171{
    175172        printf("Task %s (%" PRIu64 ") killed due to an exception at "
    176173            "program counter %p.\n", TASK->name, TASK->taskid,
     
    181178       
    182179        printf("Kill message: ");
     180        vprintf(fmt, args);
     181        printf("\n");
     182       
     183        task_kill_self(true);
     184}
     185
     186/** Terminate thread and task after the exception came from userspace.
     187 *
     188 */
     189NO_TRACE void fault_from_uspace(istate_t *istate, const char *fmt, ...)
     190{
     191        va_list args;
     192
     193        va_start(args, fmt);
     194        fault_from_uspace_core(istate, fmt, args);
     195        va_end(args);
     196}
     197
     198/** Terminate thread and task if exception came from userspace.
     199 *
     200 */
     201NO_TRACE void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)
     202{
     203        if (!istate_from_uspace(istate))
     204                return;
    183205       
    184206        va_list args;
    185207        va_start(args, fmt);
    186         vprintf(fmt, args);
     208        fault_from_uspace_core(istate, fmt, args);
    187209        va_end(args);
    188         printf("\n");
    189        
    190         task_kill_self(true);
    191210}
    192211
     
    204223        /*
    205224         * The istate structure should be right at the bottom of the kernel
    206          * stack.
     225         * memory stack.
    207226         */
    208         return (istate_t *) ((uint8_t *)
    209             thread->kstack + STACK_SIZE - sizeof(istate_t));
     227        return (istate_t *) &thread->kstack[MEM_STACK_SIZE - sizeof(istate_t)];
    210228}
    211229
Note: See TracChangeset for help on using the changeset viewer.