root/include/asm/system.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. tas

   1 #ifndef __ASM_SYSTEM_H
   2 #define __ASM_SYSTEM_H
   3 
   4 #include <linux/segment.h>
   5 
   6 #define move_to_user_mode() \
   7 __asm__ __volatile__ ("movl %%esp,%%eax\n\t" \
   8         "pushl %0\n\t" \
   9         "pushl %%eax\n\t" \
  10         "pushfl\n\t" \
  11         "pushl %1\n\t" \
  12         "pushl $1f\n\t" \
  13         "iret\n" \
  14         "1:\tmovl %0,%%eax\n\t" \
  15         "mov %%ax,%%ds\n\t" \
  16         "mov %%ax,%%es\n\t" \
  17         "mov %%ax,%%fs\n\t" \
  18         "mov %%ax,%%gs" \
  19         : /* no outputs */ :"i" (USER_DS), "i" (USER_CS):"ax")
  20 
  21 #define sti() __asm__ __volatile__ ("sti": : :"memory")
  22 #define cli() __asm__ __volatile__ ("cli": : :"memory")
  23 #define nop() __asm__ __volatile__ ("nop")
  24 
  25 /*
  26  * Clear and set 'TS' bit respectively
  27  */
  28 #define clts() __asm__ __volatile__ ("clts")
  29 #define stts() \
  30 __asm__ __volatile__ ( \
  31         "movl %%cr0,%%eax\n\t" \
  32         "orl $8,%%eax\n\t" \
  33         "movl %%eax,%%cr0" \
  34         : /* no outputs */ \
  35         : /* no inputs */ \
  36         :"ax")
  37 
  38 
  39 extern inline int tas(char * m)
     /* [previous][next][first][last][top][bottom][index][help] */
  40 {
  41         char res;
  42 
  43         __asm__("xchgb %0,%1":"=q" (res),"=m" (*m):"0" (0x1));
  44         return res;
  45 }
  46 
  47 #define save_flags(x) \
  48 __asm__ __volatile__("pushfl ; popl %0":"=r" (x): /* no input */ :"memory")
  49 
  50 #define restore_flags(x) \
  51 __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"r" (x):"memory")
  52 
  53 #define iret() __asm__ __volatile__ ("iret": : :"memory")
  54 
  55 #define _set_gate(gate_addr,type,dpl,addr) \
  56 __asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
  57         "movw %2,%%dx\n\t" \
  58         "movl %%eax,%0\n\t" \
  59         "movl %%edx,%1" \
  60         :"=m" (*((long *) (gate_addr))), \
  61          "=m" (*(1+(long *) (gate_addr))) \
  62         :"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
  63          "d" ((char *) (addr)),"a" (KERNEL_CS << 16) \
  64         :"ax","dx")
  65 
  66 #define set_intr_gate(n,addr) \
  67         _set_gate(&idt[n],14,0,addr)
  68 
  69 #define set_trap_gate(n,addr) \
  70         _set_gate(&idt[n],15,0,addr)
  71 
  72 #define set_system_gate(n,addr) \
  73         _set_gate(&idt[n],15,3,addr)
  74 
  75 #define set_call_gate(a,addr) \
  76         _set_gate(a,12,3,addr)
  77 
  78 #define _set_seg_desc(gate_addr,type,dpl,base,limit) {\
  79         *((gate_addr)+1) = ((base) & 0xff000000) | \
  80                 (((base) & 0x00ff0000)>>16) | \
  81                 ((limit) & 0xf0000) | \
  82                 ((dpl)<<13) | \
  83                 (0x00408000) | \
  84                 ((type)<<8); \
  85         *(gate_addr) = (((base) & 0x0000ffff)<<16) | \
  86                 ((limit) & 0x0ffff); }
  87 
  88 #define _set_tssldt_desc(n,addr,limit,type) \
  89 __asm__ __volatile__ ("movw $" #limit ",%1\n\t" \
  90         "movw %%ax,%2\n\t" \
  91         "rorl $16,%%eax\n\t" \
  92         "movb %%al,%3\n\t" \
  93         "movb $" type ",%4\n\t" \
  94         "movb $0x00,%5\n\t" \
  95         "movb %%ah,%6\n\t" \
  96         "rorl $16,%%eax" \
  97         : /* no output */ \
  98         :"a" (addr+0xc0000000), "m" (*(n)), "m" (*(n+2)), "m" (*(n+4)), \
  99          "m" (*(n+5)), "m" (*(n+6)), "m" (*(n+7)) \
 100         )
 101 
 102 #define set_tss_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),235,"0x89")
 103 #define set_ldt_desc(n,addr,size) \
 104         _set_tssldt_desc(((char *) (n)),((int)(addr)),((size << 3) - 1),"0x82")
 105 
 106 
 107 #endif

/* [previous][next][first][last][top][bottom][index][help] */