c - 如何确定外围设备的端口号?

标签 c assembly io operating-system

我知道外围设备,如硬驱动程序、软盘驱动程序等,是通过读取/写入设备 Controller 上的某些控制寄存器来控制的。

我想知道以下问题:

  • 当这些外围设备插入计算机时,它们的控制寄存器的地址(端口号)是否因此取决于它们如何连接到地址总线(即硬接线规则,而不是任何软的东西)?
  • 谁制定了端口号分配方案?
  • 如果给我一台裸机(没有操作系统和许多外围设备),我怎么能弄清楚端口号分配,以便我可以使用它们来控制外围设备。

  • 最后,和往常一样,感谢您的耐心和回复。 8^)

    最佳答案

    对于比较新的PC兼容机“裸机”,你可以在Conventional PCI中找到一些答案。描述:

    In a typical system, the firmware (or operating system) queries all PCI buses at startup time (via PCI Configuration Space) to find out what devices are present and what system resources (memory space, I/O space, interrupt lines, etc.) each needs. It then allocates the resources and tells each device what its allocation is.

    The PCI configuration space also contains a small amount of device type information, which helps an operating system choose device drivers for it, or at least to have a dialogue with a user about the system configuration.


    ...

    Finally, PCI configuration space provides access to 256 bytes of special configuration registers per PCI device. Each PCI slot gets its own configuration space address range. The registers are used to configure devices memory and I/O addresses ranges they should respond to from transaction initiators. When a computer is first turned on, all PCI devices respond only to their configuration space accesses. The computers BIOS scans for devices and assigns Memory and I/O address ranges to them.


    一旦为设备建立了 I/O 地址,实际的命令代码是高度特定于设备的。希望有厂商在线提供相关文档。

    关于c - 如何确定外围设备的端口号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2708263/

    相关文章:

    linux - 如何检查数字是否代表 NASM Assembly 中的大写字符?

    c++ - 为什么这个内联汇编中的 ror op 不能正常工作?

    c - 如何将数字表示为 15 位宽的字段?

    scanf() 能否将非零输入变为零

    assembly - 英特尔 x86-64 XSAVE/XRSTOR

    c++ - 如何在函数内部操作 char 数组(字符串)的指针,它在 c/c++ 中作为参数传递

    c - 提高在 C 中写入大量小文件的吞吐量

    java - Kryo 反序列化失败,返回 "KryoException: Buffer underflow"

    c - 数组内存分配

    c - 如何在c中的可执行文件上实现选项?