写一个操作系统:Intel Software Developer's Manual Volume 3 文档翻译

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32862515/article/details/84654077

1.关于这个手册

1.3.5 Segmented Addressing

处理器使用字节寻址。这表明内存被看作是字节的序列或数组。
The range of memory that can be addressed is called an address space.

2.系统结构总览

62页

2.1.1 GDT 和 LDT

当操作系统在保护模式的时候,所有的内存访问要经过GDT或者LDT。这些table包含了段描述符。段描述符提供了段的基地址和访问权限、类型、作用等信息。
每一个段描述符都有一个与之对应的段选择子(SEGMENT SELECTOR)。一个段选择子提供给软件一个GDT或LDT的索引、一个标志位来区分GDT和LDT、访问权限信息。
为了访问段内的一个字节,必须有一个段选择子和偏移。段选择子提供访问段需要的段描述符。通过这个段描述符,处理器得到了段在线性地址空间中的基地址。The offset then provides the location of the byte relative to the base address.这种方式可以用于访问所有有效的代码、数据和栈段,如果要访问的段可以被当前处理器使用的特权级(CPL)访问。CPL被定义为当前正在执行的代码段的保护级别。
The linear address of the base of the GDT is contained in the GDT register (GDTR); the linear address of the LDT is
contained in the LDT register (LDTR).

2.1.2 System Segments, Segment Descriptors, and Gates

除了代码、数据和堆栈段组成了正在执行的程序的环境,体系定义了两种系统段:the task-state segment (TSS) and the LDT。
GDT不被认为是一个段,因为它不需要通过段选择子和段描述符来访问。TSSs and LDTs have segment descriptors defined for them.
体系还定义了一类特殊的描述符叫做门(call gates, interrupt gates, trap gates, and task gates),分别是调用门、中断门、陷阱门和任务门。These provide protected gateways to system procedures and handlers that may operate at a different
privilege level than application programs and most procedures.
例如,对调用门的调用可以使得当前代码段访问特权级更高的代码段中的程序(特权级数值越小,权限越大。)。为了通过调用门访问一个程序,调用程序提供选择子给调用门。The processor then performs an access rights check on the call gate, comparing the CPL with the privilege level of the call gate and the destination code segment pointed to by the call gate.
如果对目的代码的访问是允许的,处理器从调用门那里得到目的代码段的段选择子和偏移。如果这个调用需要进行特权级的变化,处理器也将栈变化到相应的级别。The segment selector for the new stack is obtained from the TSS for the currently running task. Gates also facilitate transitions between 16-bit and 32-bit code segments, and vice versa.
写到这里,我对门的理解就是可以越级访问。

2.1.3 Task-State Segments and Task Gates

TSS定义了一个程序的执行环境的状态。It includes the state of general-purpose registers, segment registers, the EFLAGS register, the EIP register, and segment selectors with stack
pointers for three stack segments (one stack for each privilege level).The TSS also includes the segment selector for the LDT associated with the task and the base address of the paging-structure hierarchy.
A task can also be accessed through a task gate. A task gate is similar to a call gate, except that it provides access
(through a segment selector) to a TSS rather than a code segment.
这里没看懂。

2.1.4 Interrupt and Exception Handling

外部中断、软件中断和异常由the interrupt descriptor table (IDT)处理。IDT存储了很多门描述符来访问中断和异常处理程序。和GDT一样,IDT也不是一个段。IDT的线性地址存储在IDT register(IDTR)中。
IDT中的门描述符可以是中断门、陷阱门、任务门。为了访问一个中断或异常程序,处理器首先从内部的硬件中获得一个中断向量,一个外部中断控制器或者是从软件那里获得INT N这种形式等。中断向量提供了IDT内的一个索引。如果被选择的门描述符是一个中断门或者陷阱门,the associated handler procedure
is accessed in a manner similar to calling a procedure through a call gate.如果是任务门,处理程序通过任务切换被访问。

2.1.5 内存管理

系统体系支持直接物理寻址或者是通过分页的虚拟内存管理。当物理寻址时,线性地址就是物理地址。When paging is used: all code, data, stack, and system segments (including the GDT and IDT) can be paged with only the most recently accessed pages being held in physical memory.
The location of pages (sometimes called page frames) in physical memory is contained in the paging structures.
These structures reside in physical memory.

5

5.5

6

猜你喜欢

转载自blog.csdn.net/qq_32862515/article/details/84654077