16.317 Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2012 Lecture 15: Protected mode intro.

Slides:



Advertisements
Similar presentations
Memory Management Unit
Advertisements

O PERATING I N P ROTECTED M ODE Prof.P.C.Patil Department of Computer Engg Matoshri College of Engg.Nasik M ICROPROCESSOR A RCHITECTURE.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Memory Management and Protection Part 3:Virtual memory, mode switching,
Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU
FEATURES OF 80386: Two versions of are commonly available: 1) 80386DX
Unit 4 Chapter-1 Multitasking. The Task State Segment.
16.317: Microprocessor System Design I
Intel MP.
Microprocessors system architectures – IA32 real and virtual-8086 mode Jakub Yaghob.
CSC 221 Computer Organization and Assembly Language
Operating Systems: Segments 1 Segmentation Hardware Support single user program system: – wish somehow to relocate address 0 to after operating system.
IA-32 Processor Architecture
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
CS2422 Assembly Language & System Programming September 22, 2005.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 2: 80386DX Internal Architecture & Data Organization.
Microprocessor Systems Design I
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2013 Lecture 4: 80386DX memory, addressing.
Protected Mode. Protected Mode (1 of 2) 4 GB addressable RAM –( to FFFFFFFFh) Each program assigned a memory partition which is protected from.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2014 Lecture 4: x86 memory.
UNIT 2 Memory Management Unit and Segment Description and Paging
80386DX.
Intel MP (32-bit microprocessor) Designed to overcome the limits of its predecessor while maintaining the software compatibility with the.
Address Translation Mechanism of 80386
Microprocessor system architectures – IA32 segmentation Jakub Yaghob.
The Pentium Processor.
The Pentium Processor Chapter 3 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
The Pentium Processor Chapter 3 S. Dandamudi.
The Intel Microprocessors. Real Mode Memory Addressing Real mode, also called real address mode, is an operating mode of and later x86-compatible.
Multitasking Mr. Mahendra B. Salunke Asst. Prof. Dept. of Computer Engg., STES SITS, Narhe, Pune-41 STES Sinhgad Institute of Tech. & Science Dept. of.
System Address Registers/Memory Management Registers Four memory management registers are used to specify the locations of data structures which control.
80386DX.
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
The Microprocessor and Its Architecture A Course in Microprocessor Electrical Engineering Department University of Indonesia.
EFLAG Register of The The only new flag bit is the AC alignment check, used to indicate that the microprocessor has accessed a word at an odd.
Microprocessor system architectures – IA32 tasks Jakub Yaghob.
Segment Descriptor Segments are areas of memory defined by a programmer and can be a code, data or stack segment. In segments need not be all the.
1 Microprocessors CSE Protected Mode Memory Addressing Remember using real mode addressing we were previously able to address 1M Byte of memory.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
Chapter 2 The Microprocessor Architecture Microprocessors prepared by Dr. Mohamed A. Shohla.
Different Microprocessors Tamanna Haque Nipa Lecturer Dept. of Computer Science Stamford University Bangladesh.
Microprocessor and Assembly Language Addressing Models
Information Security - 2. Descriptor Tables Descriptors are stored in three tables: – Global descriptor table (GDT) Maintains a list of most segments.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Microprocessor Systems Design I
32- bit Microprocessor-Intel 80386
Lecture on Real Mode Memory Addressing
Descriptor Table & Register
16.317: Microprocessor System Design I
Microprocessor Systems Design I
MICROPROCESSOR BASED SYSTEM DESIGN
Microprocessor and Assembly Language
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Address Translation Mechanism of 80386
Microprocessor Systems Design I
143A: Principles of Operating Systems Lecture 5: Address translation
Microprocessor Systems Design I
x86 segmentation, page tables, and interrupts
Subject Name: Microprocesor Subject Code: 10CS45
Chapter 2: The Microprocessor and its Architecture
Operating Modes UQ: State and explain the operating modes of X86 family of processors. Show the mode transition diagram highlighting important features.(10.
CS 301 Fall 2002 Computer Organization
Microprocessor and Assembly Language Addressing Models
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
CS444/544 Operating Systems II Virtual Memory
Presentation transcript:

Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2012 Lecture 15: Protected mode intro

Lecture outline Announcements/reminders  Lab 1 posted; due 10/22  Exam 1 regrades due today Today’s lecture  Review: 80386DX subroutines, stack  Protected mode 7/2/2015 Microprocessors I: Lecture 14 2

Review Subroutines: low-level functions  When called, address of next instruction saved Return instruction ends routine; goes to that point  May need to save state on stack specifics  CALL : call procedure can be label (16-/32-bit imm), reg, mem  RET: return from procedure  Saving state to stack: push instructions Store data “above” current TOS; decrement SP Basic PUSH stores word or double word Directly storing flags: PUSHF Storing all 16-/32-bit general purpose registers: PUSHA/PUSHAD  Restoring state: POP/POPF/POPA/POPAD 7/2/2015 Microprocessors I: Lecture 7 3

Protected mode Common system features  Multitasking  Memory management Keep memory for different tasks separate Allow programs to “see” as much memory as needed Usually managed/supported in operating system 80386DX: hardware support in protected mode  Runs at higher privilege level  Controlled by single bit in control register  IP, flags extended to 32 bits (EIP, EFLAGS)  Addresses extended to 32 bits  Two general changes: Global vs local memory Variable segments 7/2/2015 Microprocessors I: Lecture 6 4

Protected Mode Benefits Memory management  Larger memory space (up to 4GB physical memory)  Flexible segment size in segmentation  Can also be organized as 4KB “pages”  Virtual memory (larger than physical memory size) Multitasking  Tasks sharing CPU, memory, I/O Protection  Safeguard against software bugs and integrity of OS Virtual mode  Allow execution of DOS applications 7/2/2015 Microprocessors I: Lecture 6 5

Global vs. local memory Multiple tasks  each task needs own state  Copies of registers  Range of memory to hold code and data Local memory: memory accessible for a single task System level  store info about:  Where each task’s register copies are saved  Where each task’s local memory is actually stored  Interrupts  Global memory: memory accessible by any task (and, usually, system level program) 7/2/2015 Microprocessors I: Lecture 6 6

Variable segments Fixed size: need to specify starting address  real mode: segment registers hold starting address Variable size: need to specify starting address and segment size  Information stored in descriptor  Descriptor holds 8 bytes: Segment base address (32 bits) Max segment offset (20 bits)  Segment size = (max offset) + 1  “Granularity bit”, if set, multiplies offset by 2 12  allows 20 bit offset to specify segment size up to 4 GB Access information (12 bits)  protected mode: segment registers point to descriptor for given segment 7/2/2015 Microprocessors I: Lecture 6 7

Memory accesses Real mode  Segment register indicates start of segment  Physical addr. = (shifted segment register) + (effective address) Protected mode  Segment selector register points to descriptor table entry  Descriptor indicates start (base) of segment  “Linear addr.” = (segment base) + (effective address) 7/2/2015 Microprocessors I: Lecture 6 8

Memory access questions How do we know if an access is global or local? How do we find the appropriate descriptor on a global memory access? How do we find the appropriate descriptor on a local memory access? 7/2/2015 Microprocessors I: Lecture 6 9

Selectors Segment registers now hold selectors  Index into table holding actual memory address Selector format  RPL: Requested privilege level 4 levels  0 highest, 3 lowest Used for checking access rights  TI: Table indicator Global (TI == 0) or local (TI == 1) data/code  Index: pointer into appropriate descriptor table 7/2/2015 Microprocessors I: Lecture 6 10 INDEXTIRPL

Descriptor tables Descriptors organized into “tables”  Memory ranges holding all descriptors Two memory types in protected mode  Global memory: accessible to all tasks Descriptors in global descriptor table (GDT) Starting address of GDT = GDTR  Local memory: memory accessible to only a single task Descriptors in local descriptor table (LDT) Each task has its own LDT Starting address of current LDT indicated by LDTR 7/2/2015 Microprocessors I: Lecture 6 11

Global Descriptor Table Register (GDTR) GDTR describes global descriptor table  Lower 2 bytes define LIMIT (or size)  Upper 4 bytes define base (starting address)  Initialized before switching to protected mode Example: GDTR = FFFH  GDT base = H,  GDT size = 0FFFH+1 = 1000H = 4096 bytes  # of descriptors = 4096/8 = 512  Highest address in GDT = 00100FFFH 7/2/2015 Microprocessors I: Lecture 6 12

GDTR questions What is the GDT base address and limit if  GDTR = FFH?  GDTR = FEDC1AB20007H?  GDTR = AABB11221F0FH? What is the size of the GDT and number of descriptors it holds in each of the examples above? What is the maximum GDT size and number of descriptors? 7/2/2015 Microprocessors I: Lecture 6 13

Illustrating global memory access 7/2/2015 Microprocessors I: Lecture 6 14 MOV AX, [10H]  Logical addr = DS:10H DS = 0013H = RPL = 3 TI = 0  global Index = 2 GDTR = FF Base Limit GDT H FFH Descriptor addr: (GDT base) + (selector index * 8) H+ (0002H * 8) H Desc. 2 Base = H Limit = 0FFFH Actual mem addr: (seg base) + (effective address) H+ 10H H

Microprocessors I: Lecture 6 15 Local Descriptor Table Register (LDTR) Local descriptor table  Defines local memory address space for the task  Each task has its own LDT  Contains local segment descriptors LDTR: 16 bit selector pointing into GDT  Each LDT is essentially a segment in global memory  LDTR cache automatically loads when LDTR changed LDTR cache: 48bit  Lower 2 bytes define LDT LIMIT (or size)  Upper 4 bytes define LDT base (physical address) 7/2/2015

Illustrating local memory access 7/2/2015 Microprocessors I: Lecture 6 16 MOV AX, [10H]  Logical addr = DS:10H DS = 0027H = RPL = 3 TI = 1  local Index = 4 GDTR = FF Base Limit GDT H FFH Descriptor addr: (GDT base) + (selector index * 8) H+ (0007H * 8) H Desc. 7 Base = H Limit = 001FH LDTR = 003BH =

Illustrating local memory access 7/2/2015 Microprocessors I: Lecture 6 17 MOV AX, [10H]  Logical addr = DS:10H DS = 0027H = RPL = 3 TI = 1  local Index = F Base Limit GDT H FFH LDT H FH Descriptor addr: (LDT base) + (selector index * 8) H+ (0004H * 8) H Desc. 4 Base = H Limit = 001FH GDT descriptor 3 describes LDT for this task  LDTR cache = Actual mem addr: (seg base) + (effective address) H H

Interrupt Descriptor Table Register (IDTR) Interrupt descriptor table  Up to 256 interrupt descriptors Describes segments holding interrupt service routines  Described by IDTR  Each entry (interrupt descriptor) takes 8 bytes IDTR: 48-bit  Lower 2 bytes define LIMIT (or size)  Upper 4 bytes define the base (physical address)  Initialized before switching to protected mode 7/2/2015 Microprocessors I: Lecture 6 18

Multitasking Most systems run multiple tasks  Different programs  Different threads in same program Task switch: save state of current task; transfer control to new task specifics  Task state segment (TSS): saved task state (picture at right) Every TSS resides in global memory  Task register (TR): selector pointing to descriptor in GDT for current TSS Limit, base of current TSS cached  Task switch = jump or call instruction that changes task 7/2/2015 Microprocessors I: Lecture 6 19 Figure from cs.usfca.edu/~cruse/cs630f06/lesson08.ppt

Final notes Next time: Protected mode intro Reminders:  Lab 1 posted; due 10/22  Exam 1 regrades due Friday, 10/12 7/2/2015 Microprocessors I: Lecture 14 20