操作系统学习笔记(22)--全局描述符表
来源:互联网 发布:编程用什么软件 编辑:程序博客网 时间:2024/05/09 18:25
在保护模式下访问内存步骤:
1 获取段选择子
2 根据GDTR寄存器获得基地址
3 和偏移地址结合获得线性地址
与内存有关的描述符
align 8, db 0 (内存对齐)
GDT_Pointer:
dw 3; limit
dd 0xAAAAAAAA +GDT ; base address
lgdt [GDT_Pointer] ; 装载GDTR
LGDT Load global descriptor table (GDT) register
On power up or reset of the processor, the base address is set to the default value of 0 and
the limit is set to FFFFH
A segment descriptor provides the base address of a segment and access rights, type, and usage information. Each segment descriptor has a segment selector associated with it. The segment selector provides an index into the GDT
or LDT (to its associated segment descriptor), a global/local flag (that determines whether the segment selector points to the GDT or the LDT), and access rights information.
1<<3 ; kernel code segment is GDT entry 1
2<<3 ; kernel data segment is GDT entry 2
分别对应下列的段选择子(Segment Selector)说明:
0000000000001000
0000000000010000
对应上面的代码的代码段和数据段
段描述符内容格式如下:对应6个字节
可对应上面的代码检查。
实例:比较92和9A的不同
可参考位置为Type
2:Read/Write Data Descriptor Type
A:Execute/Read Code Descriptor Type
G (granularity) flag
Determines the scaling of the segment limit field. When the granularity flag is
clear, the segment limit is interpreted in byte units; when flag is set, the
segment limit is interpreted in 4-KByte units. (This flag does not affect the
granularity of the base address; it is always byte granular.) When the granularity
flag is set, the twelve least significant bits of an offset are not tested when
checking the offset against the segment limit. For example, when the granularity
flag is set, a limit of 0 results in valid offsets from 0 to 4095.
上面设置为1,则后面的segment limit是作为4K为基数的。
/*
* The general format of a segment descriptor.
*/
struct Segment_Descriptor {
ushort_t sizeLow PACKED ;
uint_t baseLow : 24 PACKED ;
uint_t type : 4 PACKED ;
uint_t system : 1 PACKED ;
uint_t dpl : 2 PACKED ;
uint_t present : 1 PACKED ;
uint_t sizeHigh : 4 PACKED ;
uint_t avail : 1 PACKED ;
uint_t reserved : 1 PACKED ; /* set to zero */
uint_t dbBit : 1 PACKED ;
uint_t granularity : 1 PACKED ;
uchar_t baseHigh PACKED ;
};
15 3 2 1 0
TI
Index
Table Indicator
0 = GDT
1 = LDT
Requested Privilege Level (RPL)
RPL
/**
* Construct a segment selector.
* @param rpl requestor privilege level; should be KERNEL_PRIVILEGE
* for kernel segments and USER_PRIVILEGE for user segments
* @param segmentIsInGDT true if the referenced segment descriptor
* is defined in the GDT, false if it is defined in the LDT
* @param index index of the segment descriptor
* @return the segment selector
*/
static __inline__ ushort_t Selector(int rpl, bool segmentIsInGDT, int index)
{
ushort_t selector = 0;
selector = (rpl & 0x3) | ((segmentIsInGDT ? 0 : 1) << 2) | ((index & 0x1FFF) << 3);
return selector;
}
- 操作系统学习笔记(22)--全局描述符表
- 操作系统学习笔记(21)--中断描述符表设置
- 全局描述符表
- 全局描述符表
- 《一个操作系统的实现》笔记一,GDT(全局描述符)
- 《现代操作系统》学习笔记(2)之文件描述符(关键词:操作系统/文件描述符)
- 全局描述符表GDT
- 加载全局/中断描述符表
- GDT详解(全局描述符表)
- GDT 全局描述符表 数据结构
- 操作系统学习笔记------进程描述与进程状态变化
- GDT(全局描述表)
- 获取全局描述符表GDT的内容
- 9.全局描述符表与分页机制
- GDT(Global Descriptor Table)全局描述符表
- GDT(Global Descriptor Table)全局描述符表
- GDT(全局描述符表)和LDT(局部描述符表)
- GDT(全局描述符表)和LDT(局部描述符表)
- [VC编程] CEdit改变字体大小的方法
- kill掉android应用的bat
- 字符串字典排序
- VC++常见问题总结(1)
- 一首歌一种感动
- 操作系统学习笔记(22)--全局描述符表
- SSH Tunnel扫盲
- applicationContext.xml_版本2.0
- yiboyuan多用usb电池充电器
- hibernate.cfg.xml_版本3.0
- Tessellation of sphere by a recursive method
- android:程序中安装APK方法
- 关于Windows和Unix系统的一点讨论
- VC++常见问题(2)