【译】x86程序员手册29-第8章 输入输出
Chapter 8 Input/Output 输入/输出
This chapter presents the I/O features of the 80386 from the following perspectives:
本章从以下方面来介绍80386的I/O特性:
- Methods of addressing I/O ports
I/O端口的寻址方式
- Instructions that cause I/O operations
引起IO操作的指令
- Protection as it applies to the use of I/O instructions and I/O port addresses.
应用在IO指令和IO端口地址的保护措施。
8.1 I/O Addressing IO地址
The 80386 allows input/output to be performed in either of two ways:
80386允许输入/输出用以下两种方式运行:
- By means of a separate I/O address space (using specific I/O instructions)
通过独立的IO地址空间(使用特殊的IO指令)
- By means of memory-mapped I/O (using general-purpose operand manipulation instructions).
通过内存映射(使用通用目的操作数的操作指令)。
8.1.1 I/O Address Space IO地址空间
The 80386 provides a separate I/O address space, distinct from physical memory, that can be used to address the input/output ports that are used for external 16 devices. The I/O address space consists of 2^(16) (64K) individually addressable 8-bit ports; any two consecutive 8-bit ports can be treated as a 16-bit port; and four consecutive 8-bit ports can be treated as a 32-bit port. Thus, the I/O address space can accommodate up to 64K 8-bit ports, up to 32K 16-bit ports, or up to 16K 32-bit ports.
80386从物理内存上明确的提供一个独立的IO地址空间,它们可以用来对外部16位设备的输入输出端口进行寻址。IO地址空间由2^16(64K)大小的独立的可寻址的8位端口组成;任何两个连续的8位端口可以被视做16位端口;四个连接的8位商品可以被视做32位端口。这样,IO地址空间可以容纳最多64K个8位端口,或32K个16位商品,或16K个32位端口。
The program can specify the address of the port in two ways.程序可以使用两种方式指定端口的地址。
Using an immediate byte constant, the program can specify:
使用立即数据字节常量,程序可以指定:
- 256 8-bit ports numbered 0 through 255.
共256个,8位端口号0到255
- 128 16-bit ports numbered 0, 2, 4, . . . , 252, 254.
128个16位端口号,从0,2,4,直到252,254。
- 64 32-bit ports numbered 0, 4, 8, . . . , 248, 252.
64个32位端口号0,4,8,...,248,252。
Using a value in DX, the program can specify:
使用DX寄存器中的值,程序可以指定上:
- 8-bit ports numbered 0 through 65535
8位端口号,从0到65535
- 16-bit ports numbered 0, 2, 4, . . . , 65532, 65534
16位端口号,从0,2,4...,65532,65534
- 32-bit ports numbered 0, 4, 8, . . . , 65528, 65532
32位端口号,从0,4,8,...,65528,65532
The 80386 can transfer 32, 16, or 8 bits at a time to a device located in the I/O space. Like doublewords in memory, 32-bit ports should be aligned at addresses evenly divisible by four so that the 32 bits can be transferred in a single bus access. Like words in memory, 16-bit ports should be aligned at even-numbered addresses so that the 16 bits can be transferred in a single bus access. An 8-bit port may be located at either an even or odd address.
80386可以一次向位于IO空间的设备传送32、16或8位。就象内存中的双字一样,32位端口应当在能被4整除的地址上对齐,这样32位就能在一个单独的总线访问中被传送。就象内存中的字一样,16位端口应当在偶数对齐的地址上,这样16位就能在一个单独的总线访问中被传送。8位端口可以定位在奇数或偶数地址上。
The instructions IN and OUT move data between a register and a port in the I/O address space. The instructions INS and OUTS move strings of data between the memory address space and ports in the I/O address space.
指令IN和OUT通过IO地址空间,在寄存器和端口之间传输数据。指令INS和OUTS在内存地址与IO地址空间中的端口之间传送字符串数据。
8.1.2 Memory-Mapped I/O IO的内存映射
I/O devices also may be placed in the 80386 memory address space. As long as the devices respond like memory components, they are indistinguishable to the processor.
IO设备也可以被放在80386的内存地址空间。由于设备响应就象内存组件一样,对于处理器平说,几乎没有什么区别。
Memory-mapped I/O provides additional programming flexibility. Any instruction that references memory may be used to access an I/O port located in the memory space. For example, the MOV instruction can transfer data between any register and a port; and the AND, OR, and TEST instructions may be used to manipulate bits in the internal registers of a device (see Figure 8-1 ). Memory-mapped I/O performed via the full instruction set maintains the full complement of addressing modes for selecting the desired I/O device (e.g., direct address, indirect address, base register, index register, scaling).
IO内存映射提供额外的程序的便利性。任何内存引用指令都可以被用来访问一个被映射到内存空间的IO端口。例如,MOV指令可以在任何寄存器与端口之间传送数据;AND、OR和TEST指令也可被用来操作设备内部寄存器上的位(见图8-1)。IO内存映射通过全部指令集,对选定的需求IO设备允许使用全部可用的寻址模式(如:直接寻址,间接寻址,基址寄存器寻址,索引寄存器寻址,以比例因子寻址)。
Memory-mapped I/O, like any other memory reference, is subject to access protection and control when executing in protected mode. Refer to Chapter 6 for a discussion of memory protection.
IO内存映射,就象其他的内存引用一样,在保护模式下,也是访问控制和保护的主题。参见第6章关于内存保护的讨论。

【译】x86程序员手册29-第8章 输入输出的更多相关文章
- 【译】x86程序员手册10 - 第4章系统架构
1.1.2 Part II -- Systems Programming 系统编程 This part presents those aspects of the architecture that ...
- 【译】x86程序员手册01
Intel 80386 Reference Programmer's Manual 80386程序员参考手册 Chapter 1 -- Introduction to the 80386 第1章 - ...
- 【译】x86程序员手册03 - 2.1内存组织和分段
2.1 Memory Organization and Segmentation 内存组织和分段 The physical memory of an 80386 system is organized ...
- 【译】x86程序员手册00 - 翻译起因
从上一次学习MIT的操作系统课程又过去了一年.上次学习并没有坚持下去.想来虽有种种原因,其还在自身无法坚持罢了.故此次再鼓起勇气重新学习,发现课程都已由2014改版为2016了.但大部分内容并没有改变 ...
- 【译】x86程序员手册38-10.2实在址模式下的软件初始化
10.2 Software Initialization for Real-Address Mode 实地址模式的软件初始化 In real-address mode a few structur ...
- 【译】x86程序员手册09-第3章程序指令集
注:觉得本章内容与理解操作系统不直接相关,所以本章并未看完,也就没有翻译完,放在这里中是为了保证手册的完整.有兴趣的人可以去原址查看. https://pdos.csail.mit.edu/6.828 ...
- 【译】x86程序员手册05 - 2.3寄存器
2.3 Registers 寄存器 The 80386 contains a total of sixteen registers that are of interest to the applic ...
- 【译】x86程序员手册02 - 基本的程序模式
Chapter 2 -- Basic Programming Model: 基本的程序模式 Introduces the models of memory organization. Defines ...
- 【译】x86程序员手册40-10.5初始化的例子
10.5 Initialization Example初始化的例子 译注:本来想把这个例子全部注释完,但由于对intel汇编实不熟悉,有太多的伪指令,本人也是免强看懂,所以就不再做翻译了. $TITL ...
- 【译】x86程序员手册39-10.3切换到保护模式
10.3 Switching to Protected Mode 切换到保护模式 Setting the PE bit of the MSW in CR0 causes the 80386 to b ...
随机推荐
- Centos samba install
Ready Change Root Password passwd root 在提示下建立新密码 静态IP vi /etc/sysconfig/network-scripts/ifcfg-eth0 ...
- UVA10081-Tight Words(递推)
题目链接 题意:给出一个0到k的序列,要求出有每相邻的两个数之间的差不差过1的子序列的概率. 思路:递推.dp[i][j]表示长度为i而且j结尾的子序列的个数. 注意.假设用符合子序列个数除以从个数. ...
- 解决VS命令提示符 “Setting environment for using Microsoft Visual Studio. 此时不应有“系列错误
一.起因 近期在玩Boost库.当然首先是要进行Boost库的安装和配置.于是浅墨Google了一下boost库的安装配置攻略.下载了最新版1.55的boost库.就愉悦地開始进行配置了. 当进行到第 ...
- C#在Linux下获取文件夹信息(所在磁盘总大小,使用空间,已用空间,使用率)
1.第一种使用shell命令实现: private DiskInfo LinuxGetFolderDiskInfo(string path) { DiskInfo disk = new DiskInf ...
- 复合页( Compound Page )
复合页(Compound Page)就是将物理上连续的两个或多个页看成一个 独立的大页,它能够用来创建hugetlbfs中使用的大页(hugepage). 也能够用来创建透明大页( ...
- 【Android】使用 SwipeRefreshLayout 实现下拉刷新
今天在codepath 上看到一个开源项目 [点击查看]使用到了 SwipeRefreshLayout 实现了下拉刷新,但演示样例并不完整,于是自己就动手写了下.之前看到郭霖的博客上也有介绍下拉刷新, ...
- 【bzoj4034】[HAOI2015]T2
siz[v]表示以v为根的子树的节点数 top[v]表示v所在的重链的顶端节点 fa[v]表示v的父亲 pos[v]表示v的父边标号 mx[v]表示v的子树中边的标号最大的那条边 参考:http:// ...
- ios26--kvc
// // main.m // 13-KVC的使用 // /** KVC: Key Value Coding(键值编码):1.取值赋值.2.字典转模型. */ #import <Foundati ...
- linux常见基础问题
1,32位与64位的区别,怎么查看系统版本? 32位相比于64位处理速度更慢一些,64位同样也比32位更占内存.用户体验上没有区别:用uname -a 查看系统版本信息 2,swap分区的作用是什么 ...
- 如何在linux 32位机器编译64位程序
编译64位程序,不一定要编译机器是64位的,但是32位机器默认安装的gcc编译环境还是不能用来编译64位程序. 编译64位程序,需要加上-m64编译器参数,默认安装的gcc已经支持该参数,但是缺少64 ...