linux/arch/avr32/include/asm/thread_info.h
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2004-2006 Atmel Corporation
   3 *
   4 * This program is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License version 2 as
   6 * published by the Free Software Foundation.
   7 */
   8#ifndef __ASM_AVR32_THREAD_INFO_H
   9#define __ASM_AVR32_THREAD_INFO_H
  10
  11#include <asm/page.h>
  12
  13#define THREAD_SIZE_ORDER       1
  14#define THREAD_SIZE             (PAGE_SIZE << THREAD_SIZE_ORDER)
  15
  16#ifndef __ASSEMBLY__
  17#include <asm/types.h>
  18
  19struct task_struct;
  20
  21struct thread_info {
  22        struct task_struct      *task;          /* main task structure */
  23        unsigned long           flags;          /* low level flags */
  24        __u32                   cpu;
  25        __s32                   preempt_count;  /* 0 => preemptable, <0 => BUG */
  26        __u32                   rar_saved;      /* return address... */
  27        __u32                   rsr_saved;      /* ...and status register
  28                                                   saved by debug handler
  29                                                   when setting up
  30                                                   trampoline */
  31        __u8                    supervisor_stack[0];
  32};
  33
  34#define INIT_THREAD_INFO(tsk)                                           \
  35{                                                                       \
  36        .task           = &tsk,                                         \
  37        .flags          = 0,                                            \
  38        .cpu            = 0,                                            \
  39        .preempt_count  = INIT_PREEMPT_COUNT,                           \
  40}
  41
  42#define init_thread_info        (init_thread_union.thread_info)
  43#define init_stack              (init_thread_union.stack)
  44
  45/*
  46 * Get the thread information struct from C.
  47 * We do the usual trick and use the lower end of the stack for this
  48 */
  49static inline struct thread_info *current_thread_info(void)
  50{
  51        unsigned long addr = ~(THREAD_SIZE - 1);
  52
  53        asm("and %0, sp" : "=r"(addr) : "0"(addr));
  54        return (struct thread_info *)addr;
  55}
  56
  57#define get_thread_info(ti) get_task_struct((ti)->task)
  58#define put_thread_info(ti) put_task_struct((ti)->task)
  59
  60#endif /* !__ASSEMBLY__ */
  61
  62/*
  63 * Thread information flags
  64 * - these are process state flags that various assembly files may need to access
  65 * - pending work-to-be-done flags are in LSW
  66 * - other flags in MSW
  67 */
  68#define TIF_SYSCALL_TRACE       0       /* syscall trace active */
  69#define TIF_SIGPENDING          1       /* signal pending */
  70#define TIF_NEED_RESCHED        2       /* rescheduling necessary */
  71#define TIF_BREAKPOINT          4       /* enter monitor mode on return */
  72#define TIF_SINGLE_STEP         5       /* single step in progress */
  73#define TIF_MEMDIE              6       /* is terminating due to OOM killer */
  74#define TIF_RESTORE_SIGMASK     7       /* restore signal mask in do_signal */
  75#define TIF_CPU_GOING_TO_SLEEP  8       /* CPU is entering sleep 0 mode */
  76#define TIF_NOTIFY_RESUME       9       /* callback before returning to user */
  77#define TIF_DEBUG               30      /* debugging enabled */
  78#define TIF_USERSPACE           31      /* true if FS sets userspace */
  79
  80#define _TIF_SYSCALL_TRACE      (1 << TIF_SYSCALL_TRACE)
  81#define _TIF_SIGPENDING         (1 << TIF_SIGPENDING)
  82#define _TIF_NEED_RESCHED       (1 << TIF_NEED_RESCHED)
  83#define _TIF_BREAKPOINT         (1 << TIF_BREAKPOINT)
  84#define _TIF_SINGLE_STEP        (1 << TIF_SINGLE_STEP)
  85#define _TIF_MEMDIE             (1 << TIF_MEMDIE)
  86#define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
  87#define _TIF_NOTIFY_RESUME      (1 << TIF_NOTIFY_RESUME)
  88
  89/* Note: The masks below must never span more than 16 bits! */
  90
  91/* work to do on interrupt/exception return */
  92#define _TIF_WORK_MASK                          \
  93        (_TIF_SIGPENDING                        \
  94         | _TIF_NOTIFY_RESUME                   \
  95         | _TIF_NEED_RESCHED                    \
  96         | _TIF_BREAKPOINT)
  97
  98/* work to do on any return to userspace */
  99#define _TIF_ALLWORK_MASK       (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE)
 100/* work to do on return from debug mode */
 101#define _TIF_DBGWORK_MASK       (_TIF_WORK_MASK & ~_TIF_BREAKPOINT)
 102
 103#endif /* __ASM_AVR32_THREAD_INFO_H */
 104