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

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

还包括任务的LDT(局部描述符表)基址和页表基址。 在保护模式下,任务上下文内执行的程序称为当前任务。对于当前任务的TSS的段选子存储在任务寄存器(TR)中。交换任务最简单的方法是调用或跳转到另一个任务。这里,对于新任务的TSS的段选子是由CALL或JUMP指令给出的。在交换任务时,处理器执行下面的活动: ·存储当前任务的状态到TSS中。 ·使用段选子把新任务导入到任务寄存器。 ·通过GDT中的段描述符来访问新的TSS ·从TSS导入新任务的状态到通用寄存器、段寄存器、LDTR、CR3寄存器(存放页表基址),EFLAGS寄存器及EIP寄存器中。 ·开始执行新的任务。 任务还可以通过任务门来访问。任务门是访问TSS的,而调用门是访问代码段的。除此以外任务门与调用门没有什么区别。 下面给了任务门描述符的结构及TSS的结构图:

第21页

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

中断与异常处理

Interrupt and Exception Handling External interrupts, software interrupts, and exceptions are handled through the interrupt descriptor table (IDT). The IDT contains a collection of gate descriptors, which provide access to interrupt and exception handlers. Like the GDT, the IDT is not a segment. The linear 第22页

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

address of the base of the IDT is contained in the IDT register (IDTR). The gate descriptors in the IDT can be of the interrupt-, trap-, or task-gate type. To access an interrupt or exception handler, the processor must first receive an interrupt vector (interrupt number) from internal hardware, an external interrupt controller, or from software by means of an INT, INTO, INT 3, or BOUND instruction. The interrupt vector provides an index into the IDT to a gate descriptor. If the selected gate descriptor is an interrupt gate or a trap gate, the associated handler procedure is accessed in a manner very similar to calling a procedure through a call gate. If the descriptor is a task gate, the handler is accessed through a task switch. 中断与异常处理 外部中断、内部中断和异常是由中断描述符表(IDT)控制的。IDT是一个门描述符的集合,它提供中断和异常服务。和GDT一样,IDT也不是一个段。IDT的线性基址存储在IDT寄存器(IDTR)中。 在IDT中的门描述符可以是中断、陷阱或任务门类型。要想访问中断或异常服务,处理器首先必须从内部硬件、外部中断控制器或通过INT、INTO、INT3或BOUND指令的软中断中,收取中断向量(中断号)。中断向量提供了对IDT中门描述符的索引。如果选择的门描述符是一个中断门或陷阱门,那么访问服务过程的方式与通过调用门调用一个过程的方式是相似的。如果描述符是一个任务门,那么要通过任务交换才能进行访问服务。 内存管理

Memory Management The system architecture supports either direct physical addressing of memory or virtual memory (through paging). When physical addressing is used, a linear address is treated as a physical address. When paging is used, all the code, data, stack, and system segments and the GDT and IDT can be paged, with only the most recently accessed pages being held in physical memory. The location of pages (or page frames as they are sometimes called 第23页

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

in the IA-32 architecture) in physical memory is contained in two types of system data structures (a page directory and a set of page tables), both of which reside in physical memory (see Figure 2-1). An entry in a page directory contains the physical address of the base of a page table, access rights, and memory management information. An entry in a page table contains the physical address of a page frame, access rights, and memory management information. The base physical address of the page directory is contained in control register CR3. To use this paging mechanism, a linear address is broken into three parts, providing separate offsets into the page directory, the page table, and the page frame. A system can have a single page directory or several. For example, each task can have its own page directory. 内存管理 系统架构支持直接物理内存寻址和虚拟内存寻址(通过分页来实现虚拟内存寻址)两种访问内存的方式。当使用物理寻址时,线性地址就是物理地址。当使用分页时,所有的代码、数据、堆栈和系统段及GDT和IDT能够被分页。而只有最近访问过的页保留在物理内存中。 在物理内存中,页(有时在IA-32框架中也称为页框)的位置包括两种系统数据结构类型(页目录和一系列页表),两个都驻留在物理内存中。页目录中的表项包含页表基址的首地址,访问权限及内存管理信息。在页表中的每一个表项包含页框的物理地址,访问权限及物理管理信息。页目录的物理基地址保存在控制寄存器CR3中。 如果使用分页机制,那么线性地址被分成了三个部分。分别提供页目录(10位)、页表(10位)及页框的偏移量(12位)。 一个系统可以简单的只有一个页目录也可以复杂的有多个页目录。例如,每一个任务可以有它自己的页目录。 系统寄存器

System Registers 第24页