cynix

x86 UNIX-like OS
git clone git://git.2f30.org/cynix
Log | Files | Refs | README | LICENSE

x86_asm.S (5513B)


      1 .text
      2 .globl gdt_flush
      3 .type	gdt_flush, @function
      4 gdt_flush:
      5 	movl 4(%esp), %eax
      6 	lgdt (%eax)
      7 
      8 	movw $0x10, %ax
      9 	movw %ax, %ds
     10 	movw %ax, %es
     11 	movw %ax, %fs
     12 	movw %ax, %gs
     13 	movw %ax, %ss
     14 
     15 	ljmp $(0x08), $flush
     16 flush:
     17 	ret
     18 
     19 .text
     20 .globl tss_flush
     21 .type tss_flush, @function
     22 tss_flush:
     23 	movw $0x28, %ax
     24 	ltrw %ax
     25 	ret
     26 
     27 .globl idt_flush
     28 .type	idt_flush, @function
     29 idt_flush:
     30 	movl 4(%esp), %eax
     31 	lidt (%eax)
     32 	ret
     33 
     34 .globl isr0
     35 .type isr0, @function
     36 isr0:
     37 	cli
     38 	pushl  $0x0
     39 	pushl  $0x0
     40 	jmp	isr_handler
     41 
     42 .globl isr1
     43 .type isr1, @function
     44 isr1:
     45 	cli
     46 	pushl  $0x0
     47 	pushl  $0x1
     48 	jmp	isr_handler
     49 
     50 .globl isr2
     51 .type isr2, @function
     52 isr2:
     53 	cli
     54 	pushl  $0x0
     55 	pushl  $0x2
     56 	jmp	isr_handler
     57 
     58 .globl isr3
     59 .type isr3, @function
     60 isr3:
     61 	cli
     62 	pushl  $0x0
     63 	pushl  $0x3
     64 	jmp	isr_handler
     65 
     66 .globl isr4
     67 .type isr4, @function
     68 isr4:
     69 	cli
     70 	pushl  $0x0
     71 	pushl  $0x4
     72 	jmp	isr_handler
     73 
     74 .globl isr5
     75 .type isr5, @function
     76 isr5:
     77 	cli
     78 	pushl  $0x0
     79 	pushl  $0x5
     80 	jmp	isr_handler
     81 
     82 .globl isr6
     83 .type isr6, @function
     84 isr6:
     85 	cli
     86 	pushl  $0x0
     87 	pushl  $0x6
     88 	jmp	isr_handler
     89 
     90 .globl isr7
     91 .type isr7, @function
     92 isr7:
     93 	cli
     94 	pushl  $0x0
     95 	pushl  $0x7
     96 	jmp	isr_handler
     97 
     98 .globl isr8
     99 .type isr8, @function
    100 isr8:
    101 	cli
    102 	pushl  $0x8
    103 	jmp	isr_handler
    104 
    105 .globl isr9
    106 .type isr9, @function
    107 isr9:
    108 	cli
    109 	pushl  $0x0
    110 	pushl  $0x9
    111 	jmp	isr_handler
    112 
    113 .globl isr10
    114 .type isr10, @function
    115 isr10:
    116 	cli
    117 	pushl  $0xa
    118 	jmp	isr_handler
    119 
    120 .globl isr11
    121 .type isr11, @function
    122 isr11:
    123 	cli
    124 	pushl  $0xb
    125 	jmp	isr_handler
    126 
    127 .globl isr12
    128 .type isr12, @function
    129 isr12:
    130 	cli
    131 	pushl  $0xc
    132 	jmp	isr_handler
    133 
    134 .globl isr13
    135 .type isr13, @function
    136 isr13:
    137 	cli
    138 	pushl  $0xd
    139 	jmp	isr_handler
    140 
    141 .globl isr14
    142 .type isr14, @function
    143 isr14:
    144 	cli
    145 	pushl  $0xe
    146 	jmp	isr_handler
    147 
    148 .globl isr15
    149 .type isr15, @function
    150 isr15:
    151 	cli
    152 	pushl  $0x0
    153 	pushl  $0xf
    154 	jmp	isr_handler
    155 
    156 .globl isr16
    157 .type isr16, @function
    158 isr16:
    159 	cli
    160 	pushl  $0x0
    161 	pushl  $0x10
    162 	jmp	isr_handler
    163 
    164 .globl isr17
    165 .type isr17, @function
    166 isr17:
    167 	cli
    168 	pushl  $0x0
    169 	pushl  $0x11
    170 	jmp	isr_handler
    171 
    172 .globl isr18
    173 .type isr18, @function
    174 isr18:
    175 	cli
    176 	pushl  $0x0
    177 	pushl  $0x12
    178 	jmp	isr_handler
    179 
    180 .globl isr19
    181 .type isr19, @function
    182 isr19:
    183 	cli
    184 	pushl  $0x0
    185 	pushl  $0x13
    186 	jmp	isr_handler
    187 
    188 .globl isr20
    189 .type isr20, @function
    190 isr20:
    191 	cli
    192 	pushl  $0x0
    193 	pushl  $0x14
    194 	jmp	isr_handler
    195 
    196 .globl isr21
    197 .type isr21, @function
    198 isr21:
    199 	cli
    200 	pushl  $0x0
    201 	pushl  $0x15
    202 	jmp	isr_handler
    203 
    204 .globl isr22
    205 .type isr22, @function
    206 isr22:
    207 	cli
    208 	pushl  $0x0
    209 	pushl  $0x16
    210 	jmp	isr_handler
    211 
    212 .globl isr23
    213 .type isr23, @function
    214 isr23:
    215 	cli
    216 	pushl  $0x0
    217 	pushl  $0x17
    218 	jmp	isr_handler
    219 
    220 .globl isr24
    221 .type isr24, @function
    222 isr24:
    223 	cli
    224 	pushl  $0x0
    225 	pushl  $0x18
    226 	jmp	isr_handler
    227 
    228 .globl isr25
    229 .type isr25, @function
    230 isr25:
    231 	cli
    232 	pushl  $0x0
    233 	pushl  $0x19
    234 	jmp	isr_handler
    235 
    236 .globl isr26
    237 .type isr26, @function
    238 isr26:
    239 	cli
    240 	pushl  $0x0
    241 	pushl  $0x1a
    242 	jmp	isr_handler
    243 
    244 .globl isr27
    245 .type isr27, @function
    246 isr27:
    247 	cli
    248 	pushl  $0x0
    249 	pushl  $0x1b
    250 	jmp	isr_handler
    251 
    252 .globl isr28
    253 .type isr28, @function
    254 isr28:
    255 	cli
    256 	pushl  $0x0
    257 	pushl  $0x1c
    258 	jmp	isr_handler
    259 
    260 .globl isr29
    261 .type isr29, @function
    262 isr29:
    263 	cli
    264 	pushl  $0x0
    265 	pushl  $0x1d
    266 	jmp	isr_handler
    267 
    268 .globl isr30
    269 .type isr30, @function
    270 isr30:
    271 	cli
    272 	pushl  $0x0
    273 	pushl  $0x1e
    274 	jmp	isr_handler
    275 
    276 .globl isr31
    277 .type isr31, @function
    278 isr31:
    279 	cli
    280 	pushl  $0x0
    281 	pushl  $0x1f
    282 	jmp	isr_handler
    283 
    284 .globl isr32
    285 .type isr32, @function
    286 isr32:
    287 	;cli
    288 	pushl  $0x0
    289 	pushl  $0x20
    290 	jmp isr_handler
    291 
    292 .globl isr33
    293 .type isr33, @function
    294 isr33:
    295 	;cli
    296 	pushl  $0x0
    297 	pushl  $0x21
    298 	jmp	isr_handler
    299 
    300 .globl isr34
    301 .type isr34, @function
    302 isr34:
    303 	;cli
    304 	pushl  $0x0
    305 	pushl  $0x22
    306 	jmp	isr_handler
    307 
    308 .globl isr35
    309 .type isr35, @function
    310 isr35:
    311 	;cli
    312 	pushl  $0x0
    313 	pushl  $0x23
    314 	jmp	isr_handler
    315 
    316 .globl isr36
    317 .type isr36, @function
    318 isr36:
    319 	;cli
    320 	pushl  $0x0
    321 	pushl  $0x24
    322 	jmp	isr_handler
    323 
    324 .globl isr37
    325 .type isr37, @function
    326 isr37:
    327 	;cli
    328 	pushl  $0x0
    329 	pushl  $0x25
    330 	jmp	isr_handler
    331 
    332 .globl isr38
    333 .type isr38, @function
    334 isr38:
    335 	;cli
    336 	pushl  $0x0
    337 	pushl  $0x26
    338 	jmp	isr_handler
    339 
    340 .globl isr39
    341 .type isr39, @function
    342 isr39:
    343 	;cli
    344 	pushl  $0x0
    345 	pushl  $0x27
    346 	jmp	isr_handler
    347 
    348 .globl isr40
    349 .type isr40, @function
    350 isr40:
    351 	;cli
    352 	pushl  $0x0
    353 	pushl  $0x28
    354 	jmp	isr_handler
    355 
    356 .globl isr41
    357 .type isr41, @function
    358 isr41:
    359 	;cli
    360 	pushl  $0x0
    361 	pushl  $0x29
    362 	jmp	isr_handler
    363 
    364 .globl isr42
    365 .type isr42, @function
    366 isr42:
    367 	;cli
    368 	pushl  $0x0
    369 	pushl  $0x2a
    370 	jmp	isr_handler
    371 
    372 .globl isr43
    373 .type isr43, @function
    374 isr43:
    375 	;cli
    376 	pushl  $0x0
    377 	pushl  $0x2b
    378 	jmp	isr_handler
    379 
    380 .globl isr44
    381 .type isr44, @function
    382 isr44:
    383 	;cli
    384 	pushl  $0x0
    385 	pushl  $0x2c
    386 	jmp	isr_handler
    387 
    388 .globl isr45
    389 .type isr45, @function
    390 isr45:
    391 	;cli
    392 	pushl  $0x0
    393 	pushl  $0x2d
    394 	jmp	isr_handler
    395 
    396 .globl isr46
    397 .type isr46, @function
    398 isr46:
    399 	;cli
    400 	pushl  $0x0
    401 	pushl  $0x2e
    402 	jmp	isr_handler
    403 
    404 .globl isr47
    405 .type isr47, @function
    406 isr47:
    407 	;cli
    408 	pushl  $0x0
    409 	pushl  $0x2f
    410 	jmp	isr_handler
    411 
    412 .globl isr128
    413 .type isr128, @function
    414 isr128:
    415 	cli
    416 	pushl  $0x0
    417 	pushl  $0x80
    418 	jmp isr_handler
    419 
    420 .globl isr_handler
    421 .type isr_handler, @function
    422 isr_handler:
    423 	pushal
    424 	pushl %ds
    425 	xorl %eax, %eax
    426 	movw $0x10, %ax
    427 	movw %ax, %ds
    428 	movw %ax, %es
    429 	movw %ax, %fs
    430 	movw %ax, %gs
    431 	cld
    432 	movl %esp, %eax
    433 	pushl %eax
    434 	call handle_interrupt
    435 	movl %eax, %esp
    436 	popl %ebx
    437 	movw %bx, %ds
    438 	movw %bx, %es
    439 	movw %bx, %fs
    440 	movw %bx, %gs
    441 	popal
    442 	add $0x8, %esp
    443 	iret
    444 
    445 .globl save_flags
    446 .type save_flags, @function
    447 save_flags:
    448 	pushf
    449 	popl %eax
    450 	movl 4(%esp), %ecx
    451 	movl %eax, (%ecx)
    452 	ret
    453 
    454 .globl load_flags
    455 .type load_flags, @function
    456 load_flags:
    457 	movl 4(%esp), %eax
    458 	pushl %eax
    459 	popf
    460 	ret
    461 
    462 .globl fetch_eip
    463 .type fetch_eip, @function
    464 fetch_eip:
    465 	popl %eax
    466 	jmp *%eax
    467