当前位置 博文首页 > baidu_25474831的专栏:我的学习之旅(42)asm.s
asm.s只要实现软、硬中断发生后的响应。代码主要模仿linux的asm.s实现。
asm.s:
-------------
.globl default_handle, timer_interrupt, restore_esp, system_call_interrupt /*全局变量*/
default_handle: /*中断发生后的默认处理*/
?call do_default_handle
?iret
.align 2
timer_interrupt:/*硬件定时器中断*/
/*保留当前所有的寄存器,保留现场*/
?push %ds
?push %es
?push %fs
?push %gs
?pushl %ebp??
?pushl %edi??
?pushl %esi?
?
?pushl %edx??
?pushl %ecx??
?pushl %ebx??
?pushl %eax
?incl jiffies/*刷新jiffies计数器并结束中断*/
?movb $0x020, %al
?outb %al, $0x20
/*esp保存在eax,并将eax值刷新到当前任务current->current_esp*/
?mov %esp, %eax
?call save_esp
/*调用定时器处理函数并做任务调度并将current指向新任务*/
?call do_timer
/*将curret->current_esp的值刷新到esp中*/
?call restore_esp
?mov %eax, %esp
?/*此时已经是新任务的esp了,可以恢复现场并中断返回了。*/
?popl %eax
?popl %ebx
?popl %ecx
?popl %edx
?popl %edi
?popl %esi
?popl %ebp
?pop %gs
?pop %fs
?pop %es
?pop %ds
?
?iret