李庚睿的毕业论文(保护模式) - 图文 下载本文

标题 作者 说明 毕业论文 李超 ?所有版权作者保留 题目 时间 页数 80386保护模式与Linux内核引导分析 2005-4-1 共91页 路漫漫其修远兮,吾将上下而求所。

To assist in initializing the processor and controlling system operations, the system architecture provides system flags in the EFLAGS register and several system registers: ? The system flags and IOPL field in the EFLAGS register control task and mode switching , interrupt handling, instruction tracing, and access rights. ? The control registers (CR0, CR2, CR3, and CR4) contain a variety of flags and data fields for controlling system-level operations. Other flags in these registers are used to indicate support for specific processor capabilities within the operating system or executive. ? The debug registers allow the setting of breakpoints for use in debugging programs and systems software. ? The GDTR, LDTR, and IDTR registers contain the linear addresses and sizes (limits) of their respective tables. ? The task register contains the linear address and size of the TSS for the current task. 系统寄存器 为了帮助处理器初始化及控制系统的操作,系统架构提拱了系统标志寄存器EFLAGS和几个系统寄存器: ·在EFLAGS寄存器中的系统标志和IOPL域控制着任务和模式的交换、中断控制、指令跟踪及访问权限。 ·控制寄存器(CR0、CR2、CR3及CR4)包含着控制系统级操作的各种标志和数据域。在这些寄存器中,其它的标志用于指出操作系统或管理程序,支持特殊处理机的能力 ·调试软件或系统软件可以使用调试寄存器为程序设置断点。 ·GDTR、LDTR及IDTR寄存器包含他们各自表的线性地址和尺寸(界限)。 ·任务寄存器包含当前任务TSS的线性地址和尺寸。 第25页

标题 作者 说明 毕业论文 李超 ?所有版权作者保留 题目 时间 页数 80386保护模式与Linux内核引导分析 2005-4-1 共91页 路漫漫其修远兮,吾将上下而求所。

标志位寄存器(EFLAGS)

SYSTEM FLAGS AND FIELDS IN THE EFLAGS REGISTER The system flags and IOPL field of the EFLAGS register control I/O, maskable hardware interrupts, debugging, task switching, and the virtual-8086 mode (see Figure 2-3). Only privileged code (typically operating system or executive code) should be allowed to modify these bits. The functions of the system flags and IOPL are as follows: 在EFLAGS寄存器中的系统标志和域 EFLAGS寄存器中的系统标志和IOPL域控制着I/O、可屏蔽硬件中断、调试、任务切换及虚拟86模式。只有特权级代码(典型的如操作系统或管理程序)才允许修改这些位。系统标志和IOPL的功能如下: TF Trap (bit 8). Set to enable single-step mode for debugging; clear to disable single-step mode. In single-step mode, the processor generates a debug exception after each instruction, which allows the execution state of a program to be inspected after each instruction. If an application program sets the TF flag using a POPF, POPFD, or IRET instruction, a debug exception is generated after the instruction that follows the POPF,POPFD, or IRET instruction. TF 陷阱(第8位)。当为1时能使用单步模式进行调试。当为0时,不能使用单步模式。在单步模式下,在每条指令后,处理器都产生一个调试异常,这种方式允许在每条指令后都能检测程序的状态。如果应用程序使用POPF、POPFD或IRET指令将TF设置成1,在POPF、POPFD、IRET指令之后的指令将产生调试异常。 第26页

标题 作者 说明 毕业论文 李超 ?所有版权作者保留 题目 时间 页数 80386保护模式与Linux内核引导分析 2005-4-1 共91页 路漫漫其修远兮,吾将上下而求所。

IF Interrupt enable (bit 9). Controls the response of the processor to maskable hardware interrupt requests. Set to respond to maskable hardware interrupts; cleared to inhibit maskable hardware interrupts. The IF flag does not affect the generation of exceptions or nonmaskable interrupts (NMI interrupts). The CPL, IOPL, and the state of the VME flag in control register CR4 determine whether the IF flag can be modified by the CLI, STI, POPF, POPFD, and IRET instructions. IF 可中断(第9位)。控制处理器对可屏蔽硬件中断请求的响应。当为1时,响应可屏蔽中断。当为0时,禁止可屏蔽硬件中断。IF标志不影响异常或不可屏蔽中断(NMI中断)的产生。在控制寄存器CR4里,CPL、IOPL及VME标志的状态决定,是否IF标志能被CLI,STI,POPF,POPFD及IRET指令修改。 IOPL I/O privilege level field (bits 12 and 13). Indicates the I/O privilege level (IOPL) of the currently running program or task. The CPL of the currently running program or task must be less than or equal to the IOPL to access the I/O address space. This field can only be modified by the POPF and IRET instructions when operating at a CPL of 0. The IOPL is also one of the mechanisms that controls the modification of the IF flag and the handling of interrupts in virtual-8086 mode when the virtual mode extensions are in effect (the VME flag in control register CR4 is set). IOPL,IO特权级域(第12位和第13位),指出当前运行程序或任务的I/O特权级。当前运行程序或任务的CPL必须小于或等于访问I/O地址空间的IOPL。这个域仅能当CPL=0时,由指令POPF和IRET修改。当虚模式扩展生效时(控制寄存器CR4中的VME为1),IOPL也是控制IF标志位的修改和在v86模式下控制中断处理的机第27页

标题 作者 说明 毕业论文 李超 ?所有版权作者保留 题目 时间 页数 80386保护模式与Linux内核引导分析 2005-4-1 共91页 路漫漫其修远兮,吾将上下而求所。

制之一。 NT Nested task (bit 14). Controls the chaining of interrupted and called tasks. The processor sets this flag on calls to a task initiated with a CALL instruction, an interrupt, or an exception. It examines and modifies this flag on returns from a task initiated with the IRET instruction. The flag can be explicitly set or cleared with the POPF/POPFD instructions; however, changing to the state of this flag can generate unexpected exceptions in application programs. NT 嵌套任务(第14位)。控制中断及被调任务链。当用CALL指令调用一个新任务、中断或异常时处理器将这个标志位设为1。当用IRET指令从新任务返回时它检查并且修改这个标志位。这个标志位能使用POPF/POPFD明确的置1或清0。然而,改变这个标志位的状态可能在应用程序中产生不可预料的异常。 RF Resume (bit 16). Controls the processor’s response to instruction-breakpoint conditions. When set, this flag temporarily disables debug exceptions (#DE) from being generated for instruction breakpoints; although, other exception conditions can cause an exception to be generated. When clear, instruction breakpoints will generate debug exceptions. The primary function of the RF flag is to allow the restarting of an instruction following a debug exception that was caused by an instruction breakpoint condition. Here, debugger software must set this flag in the EFLAGS image on the stack just prior to returning to the interrupted program with the IRETD instruction, to prevent the instruction breakpoint from causing another debug exception. The processor then automatically clears this flag after the instruction returned to has been successfully executed, enabling instruction breakpoint faults again. RF 唤醒(第16位)。控制处理器对指令断点条件的响应。当为1时,这个标志位暂时不能调试从指令断点产生的异常(#DE)。但是,其它异常条件仍然能够产生异常。当为0时,指令断点将产生调试异常。RF标志位的主要功能是允许重新开始调试异常之后的指令。调试异常是由指令断点产生的。这里,当使用IRETD指令返回中断程序之前,调试器软件必须将EFLAGS寄存器中的这个标志位置为1,来阻止指令断点引起其它的调试异常。然后处理器在指令成功的返回后自动清除这个标志位。保指令断点再次成为默认。 VM Virtual-8086 mode (bit 17). Set to enable virtual-8086 mode; clear to return to protected mode. VM 虚拟86模式(第17位)。当为1时进入虚拟86模式,当为0时,返回第28页