c - Linux 更改 IDT,如何读取偏移量?
问题描述
我正在尝试编辑 linex 内核以更改 IDT,因此我编写了以下帮助功能:
#include <asm/desc.h>
unsigned long my_get_gate_offset(gate_desc *gate) {
unsigned long res = 0;
return result;
}
res
下面的方式怎么填写?
低 16 位应该得到offset_low
,中间 16offset_middle
位和高 32 位得到offset_high
如何在 C 中完成?
加上我怎样才能到达offset_low
,offset_middle
和offset_high
?它们被声明为gate_struct
not ingate_desc
解决方案
已经有一个功能gate_offset
可以完全满足您的要求:
static inline unsigned long gate_offset(const gate_desc *g)
{
#ifdef CONFIG_X86_64
return g->offset_low | ((unsigned long)g->offset_middle << 16) |
((unsigned long) g->offset_high << 32);
#else
return g->offset_low | ((unsigned long)g->offset_middle << 16);
#endif
}
推荐阅读
- python - 如何避免 if 条件的重复代码块?
- dataflow - 数据流管道python依赖安装但无法导入
- r - 用 R 中的矩阵列表编写一个文本文件
- teradata - 在“comm_pmreadddparse”操作期间收到 uty4014 访问模块错误 35:
- excel - Delphi - 将 ALT 键码传递给 Excel
- chainer - Chainer 模块“cupy.cudnn”没有属性“softmax_forward”
- apache-spark - spark.yarn.jars 和 spark.yarn.archive 都没有设置,回退到上传 SPARK_HOME 下的库吗?
- java - 删除时执行 JPA 托管实体的清理方法
- java - 自定义Java注解引入方法参数和执行代码
- java - 如何调用以 hashmap 作为参数的用户定义方法?