root/kernel/asm.s

/* [previous][next][first][last][top][bottom][index][help] */
   1 /*
   2  *  linux/kernel/asm.s
   3  *
   4  *  (C) 1991  Linus Torvalds
   5  */
   6 
   7 /*
   8  * asm.s contains the low-level code for most hardware faults.
   9  * page_exception is handled by the mm, so that isn't here. This
  10  * file also handles (hopefully) fpu-exceptions due to TS-bit, as
  11  * the fpu must be properly saved/resored. This hasn't been tested.
  12  */
  13 
  14 .globl _divide_error,_debug,_nmi,_int3,_overflow,_bounds,_invalid_op
  15 .globl _device_not_available,_double_fault,_coprocessor_segment_overrun
  16 .globl _invalid_TSS,_segment_not_present,_stack_segment
  17 .globl _general_protection,_coprocessor_error,_irq13,_reserved
  18 
  19 _divide_error:
  20         pushl $_do_divide_error
  21 no_error_code:
  22         xchgl %eax,(%esp)
  23         pushl %ebx
  24         pushl %ecx
  25         pushl %edx
  26         pushl %edi
  27         pushl %esi
  28         pushl %ebp
  29         push %ds
  30         push %es
  31         push %fs
  32         pushl $0                # "error code"
  33         lea 44(%esp),%edx
  34         pushl %edx
  35         movl $0x10,%edx
  36         mov %dx,%ds
  37         mov %dx,%es
  38         mov %dx,%fs
  39         call *%eax
  40         addl $8,%esp
  41         pop %fs
  42         pop %es
  43         pop %ds
  44         popl %ebp
  45         popl %esi
  46         popl %edi
  47         popl %edx
  48         popl %ecx
  49         popl %ebx
  50         popl %eax
  51         iret
  52 
  53 _debug:
  54         pushl $_do_int3         # _do_debug
  55         jmp no_error_code
  56 
  57 _nmi:
  58         pushl $_do_nmi
  59         jmp no_error_code
  60 
  61 _int3:
  62         pushl $_do_int3
  63         jmp no_error_code
  64 
  65 _overflow:
  66         pushl $_do_overflow
  67         jmp no_error_code
  68 
  69 _bounds:
  70         pushl $_do_bounds
  71         jmp no_error_code
  72 
  73 _invalid_op:
  74         pushl $_do_invalid_op
  75         jmp no_error_code
  76 
  77 math_emulate:
  78         popl %eax
  79         pushl $_do_device_not_available
  80         jmp no_error_code
  81 _device_not_available:
  82         pushl %eax
  83         movl %cr0,%eax
  84         testl $0x4,%eax                 # EM (math emulation bit)
  85         jne math_emulate
  86         clts                            # clear TS so that we can use math
  87         pushl %ecx
  88         pushl %edx
  89         push %ds
  90         movl $0x10,%eax
  91         mov %ax,%ds
  92         call _math_state_restore
  93         pop %ds
  94         popl %edx
  95         popl %ecx
  96         popl %eax
  97         iret
  98 
  99 _coprocessor_segment_overrun:
 100         pushl $_do_coprocessor_segment_overrun
 101         jmp no_error_code
 102 
 103 _reserved:
 104         pushl $_do_reserved
 105         jmp no_error_code
 106 
 107 _irq13:
 108         pushl %eax
 109         xorb %al,%al
 110         outb %al,$0xF0
 111         movb $0x20,%al
 112         outb %al,$0x20
 113         jmp 1f
 114 1:      jmp 1f
 115 1:      outb %al,$0xA0
 116         popl %eax
 117 _coprocessor_error:
 118         fnclex
 119         pushl $_do_coprocessor_error
 120         jmp no_error_code
 121 
 122 _double_fault:
 123         pushl $_do_double_fault
 124 error_code:
 125         xchgl %eax,4(%esp)              # error code <-> %eax
 126         xchgl %ebx,(%esp)               # &function <-> %ebx
 127         pushl %ecx
 128         pushl %edx
 129         pushl %edi
 130         pushl %esi
 131         pushl %ebp
 132         push %ds
 133         push %es
 134         push %fs
 135         pushl %eax                      # error code
 136         lea 44(%esp),%eax               # offset
 137         pushl %eax
 138         movl $0x10,%eax
 139         mov %ax,%ds
 140         mov %ax,%es
 141         mov %ax,%fs
 142         call *%ebx
 143         addl $8,%esp
 144         pop %fs
 145         pop %es
 146         pop %ds
 147         popl %ebp
 148         popl %esi
 149         popl %edi
 150         popl %edx
 151         popl %ecx
 152         popl %ebx
 153         popl %eax
 154         iret
 155 
 156 _invalid_TSS:
 157         pushl $_do_invalid_TSS
 158         jmp error_code
 159 
 160 _segment_not_present:
 161         pushl $_do_segment_not_present
 162         jmp error_code
 163 
 164 _stack_segment:
 165         pushl $_do_stack_segment
 166         jmp error_code
 167 
 168 _general_protection:
 169         pushl $_do_general_protection
 170         jmp error_code
 171 

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