没有合适的资源?快使用搜索试试~ 我知道了~
AMD64 Architecture<br>Programmer’s Manual<br>Volume 2:<br>System Programming
资源推荐
资源详情
资源评论
AMD64 Technology
AMD64 Architecture
Programmer’s Manual
Volume 2:
System Programming
Publication No. Revision Date
24593 3.09 September 2003
AMD 64-Bit Technology 24593—Rev. 3.09—September 2003
Trademarks
AMD, the AMD Arrow logo, AMD Athlon, AMD Opteron and combinations thereof, 3DNow!, nX586, and nX686 are trademarks, and
AMD-K6 is a registered trademark of Advanced Micro Devices, Inc.
MMX is a trademark and Pentium is a registered trademark of Intel Corporation.
Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies.
© 2002, 2003 Advanced Micro Devices, Inc. All rights reserved.
The contents of this document are provided in connection with Advanced Micro Devices, Inc.
(“AMD”) products. AMD makes no representations or warranties with respect to the accuracy or
completeness of the contents of this publication and reserves the right to make changes to
specifications and product descriptions at any time without notice. No license, whether express,
implied, arising by estoppel or otherwise, to any intellectual property rights is granted by this
publication. Except as set forth in AMD’s Standard Terms and Conditions of Sale, AMD assumes
no liability whatsoever, and disclaims any express or implied warranty, relating to its products
including, but not limited to, the implied warranty of merchantability, fitness for a particular pur-
pose, or infringement of any intellectual property right.
AMD’s products are not designed, intended, authorized or warranted for use as components in
systems intended for surgical implant into the body, or in other applications intended to support
or sustain life, or in any other application in which the failure of AMD’s product could create a
situation where personal injury, death, or severe property or environmental damage may occur.
AMD reserves the right to discontinue or make changes to its products at any time without
notice.
Contents iii
24593—Rev. 3.09—September 2003 AMD 64-Bit Technology
Contents
Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii
Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiii
About This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiii
Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiii
Contact Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiii
Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiv
Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Related Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxxvi
1 System-Programming Overview . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Memory Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Memory Addressing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Memory Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Canonical Address Form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Paging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Mixing Segmentation and Paging . . . . . . . . . . . . . . . . . . . . . . 10
Real Addressing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3 Operating Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Long Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
64-Bit Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Compatibility Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Legacy Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
System Management Mode (SMM) . . . . . . . . . . . . . . . . . . . . . 17
1.4 System Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.5 System-Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.6 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.7 Additional System-Programming Facilities . . . . . . . . . . . . . . 24
Hardware Multitasking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Machine Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Software Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Performance Monitoring. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2 x86 and AMD64 Architecture Differences . . . . . . . . . . . . . . . 29
2.1 Operating Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Long Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Legacy Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
System-Management Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
iv Contents
AMD 64-Bit Technology 24593—Rev. 3.09—September 2003
2.2 Memory Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Memory Addressing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Page Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.3 Protection Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.4 Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
General-Purpose Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
128-Bit Media Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Flags Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Instruction Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Stack Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Control Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Debug Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Extended Feature Register (EFER) . . . . . . . . . . . . . . . . . . . . 37
Memory Type Range Registers (MTRRs) . . . . . . . . . . . . . . . . 37
Other Model-Specific Registers (MSRs) . . . . . . . . . . . . . . . . . 37
2.5 Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
REX Prefixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Segment-Override Prefixes in 64-Bit Mode. . . . . . . . . . . . . . . 38
Operands and Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Address Calculations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Instructions that Reference RSP . . . . . . . . . . . . . . . . . . . . . . . 39
Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
NOP Instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Single-Byte INC and DEC Instructions . . . . . . . . . . . . . . . . . . 43
MOVSXD Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Invalid Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
FXSAVE and FXRSTOR Instructions . . . . . . . . . . . . . . . . . . . 45
2.6 Interrupts and Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Interrupt Descriptor Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Stack Frame Pushes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Stack Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
IRET Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Task-Priority Register (CR8) . . . . . . . . . . . . . . . . . . . . . . . . . . 49
New Exception Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.7 Hardware Task Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.8 Long-Mode vs. Legacy-Mode Differences . . . . . . . . . . . . . . . . 50
3 System Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.1 System-Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
CR0 Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
CR2 and CR3 Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
CR4 Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
CR1 and CR5–CR7 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . 64
64-Bit-Mode Extended Control Registers . . . . . . . . . . . . . . . . 64
CR8 (Task Priority Register, TPR). . . . . . . . . . . . . . . . . . . . . . 64
RFLAGS Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Extended Feature Enable Register (EFER) . . . . . . . . . . . . . . 69
Contents v
24593—Rev. 3.09—September 2003 AMD 64-Bit Technology
3.2 Model-Specific Registers (MSRs) . . . . . . . . . . . . . . . . . . . . . . 71
System Configuration Register (SYSCFG) . . . . . . . . . . . . . . . 73
System-Linkage Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Memory-Typing Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Debug-Extension Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Performance-Monitoring Registers . . . . . . . . . . . . . . . . . . . . . 76
Machine-Check Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.3 Processor Feature Identification . . . . . . . . . . . . . . . . . . . . . . . 78
4 Segmented Virtual Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.1 Real Mode Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.2 Virtual-8086 Mode Segmentation . . . . . . . . . . . . . . . . . . . . . . 80
4.3 Protected Mode Segmented-Memory Models. . . . . . . . . . . . . 81
Multi-Segmented Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Flat-Memory Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Segmentation in 64-bit mode . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.4 Segmentation Data Structures and Registers . . . . . . . . . . . . 82
4.5 Segment Selectors and Registers . . . . . . . . . . . . . . . . . . . . . . 84
Segment Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Segment Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Segment Registers in 64-bit Mode . . . . . . . . . . . . . . . . . . . . . . 87
4.6 Descriptor Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Global Descriptor Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Global Descriptor-Table Register . . . . . . . . . . . . . . . . . . . . . . 91
Local Descriptor Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Local Descriptor-Table Register . . . . . . . . . . . . . . . . . . . . . . . 93
Interrupt Descriptor Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Interrupt Descriptor-Table Register . . . . . . . . . . . . . . . . . . . . 97
4.7 Legacy Segment Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Descriptor Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Code-Segment Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Data-Segment Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
System Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Gate Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
4.8 Long-Mode Segment Descriptors. . . . . . . . . . . . . . . . . . . . . . 108
Code-Segment Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Data-Segment Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
System Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Gate Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Long Mode Descriptor Summary . . . . . . . . . . . . . . . . . . . . . . 116
4.9 Segment-Protection Overview . . . . . . . . . . . . . . . . . . . . . . . . 118
Privilege-Level Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Privilege-Level Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
4.10 Data-Access Privilege Checks . . . . . . . . . . . . . . . . . . . . . . . . 121
Accessing Data Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Accessing Stack Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
4.11 Control-Transfer Privilege Checks . . . . . . . . . . . . . . . . . . . . 124
Direct Control Transfers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
剩余499页未读,继续阅读
资源评论
1yvt0s
- 粉丝: 11
- 资源: 42
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功