如何保存在x86_64寄存器用于中断服务例程? [英] How to save the registers on x86_64 for an interrupt service routine?

查看:453
本文介绍了如何保存在x86_64寄存器用于中断服务例程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在看一些老code,从一个学校项目,并在试图编译它在我​​的笔记本电脑,我遇到了一些问题。它最初被写了为海湾合作委员会的一个旧的32位版本。反正我是想一些组件的转换到64位兼容code和打了几个障碍。

I am looking at some old code from a school project, and in trying to compile it on my laptop I ran into some problems. It was originally written for an old 32 bit version of gcc. Anyway I was trying to convert some of the assembly over to 64 bit compatible code and hit a few snags.

下面是原来的code:

Here is the original code:

pusha
pushl   %ds
pushl   %es
pushl   %fs
pushl   %gs
pushl   %ss

PUSHA 是不是在64位模式有效。那么,什么将是x86_64的装配,而在64位模式?

pusha is not valid in 64 bit mode. So what would be the proper way to do this in x86_64 assembly while in 64 bit mode?

有一定是有原因的 PUSHA 是不是在64位模式下有效,所以我有一种感觉手动按所有寄存器可能不是一个好主意。

There has got to be a reason why pusha is not valid in 64 bit mode, so I have a feeling manually pushing all the registers may not be a good idea.

推荐答案

从现有的code,做这种事情了解。例如:

Learn from existing code that does this kind of thing. For example:


  • 的Linux(搜索 SAVE_ARGS_IRQ ):<一href=\"http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=arch/x86/kernel/entry_64.S\"相对=nofollow> entry_64.S

  • 的OpenSolaris(搜索 INTR_PUSH )的 privregs.h

  • 的FreeBSD(搜索 IDT_VEC )的 exception.S (类似于是的 vector.S NetBSD中)

  • Linux (search for SAVE_ARGS_IRQ): entry_64.S
  • OpenSolaris (search for INTR_PUSH): privregs.h
  • FreeBSD (search for IDT_VEC): exception.S (similar is vector.S in NetBSD)

在事实上,手动推的暂存器是因为 PUSHA AMD64上唯一的方式不存在那里。 AMD64是不是在这方面独特的 - 大多数非x86处理器确实需要登记,由寄存器保存在某些点/恢复以及

In fact, "manually pushing" the regs is the only way on AMD64 since PUSHA doesn't exist there. AMD64 isn't unique in this aspect - most non-x86 CPUs do require register-by-register saves/restores as well at some point.

但是,如果你检查引用源$ C ​​$ C观察你会发现,并非所有的中断处理程序需要保存/恢复整个寄存器集,所以有空间的优化。

But if you inspect the referenced sourcecode closely you'll find that not all interrupt handlers require to save/restore the entire register set, so there is room for optimizations.

这篇关于如何保存在x86_64寄存器用于中断服务例程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆