会计考友 发表于 2012-8-4 12:13:19

linux学习:LPI硬件和体系结构(四)

  清单 4. /proc/interrupts
  CPU0
  0: 226300426 XT-PIC timer
  1: 92913 XT-PIC keyboard
  2: 0 XT-PIC cascade
  5: 0 XT-PIC usb-uhci
  8: 1 XT-PIC rtc
  9: 2641134 XT-PIC ehci-hcd, eth0, Intel ICH4
  10: 0 XT-PIC usb-uhci
  11: 213632 XT-PIC usb-uhci
  14: 1944208 XT-PIC ide0
  15: 3562845 XT-PIC ide1
  NMI: 0
  ERR: 0
  这一次,中断数字是从 0 到 15 的十进制数。同样,将这些中断与清单 5 所示的 PC 标准 IRQ 分配进行比较。
  清单 5. 标准 IRQ 设置
  IRQ 0 - System Timer
  IRQ 1 - Keyboard
  IRQ 2(9) - Video Card
  IRQ 3 - COM2, COM4
  IRQ 4 - COM1, COM3
  IRQ 5 - Available (LPT2 or Sound Card)
  IRQ 6 - Floppy Disk Controller
  IRQ 7 - LPT1
  IRQ 8 - Real-Time Clock
  IRQ 9 - Redirected IRQ 2
  IRQ 10 - Available
  IRQ 11 - Available
  IRQ 12 - PS/2 Mouse
  IRQ 13 - Math Co-Processor
  IRQ 14 - Hard Disk Controller
  IRQ 15 - Available
  最初,每个设备都有自己的私有 IRQ。做为示例,注意,在清单 5 中,IRQ5 通常用于声卡 或者 第二个并行端口(打印机)。如果两个都要使用,那么不得不去寻找一个能够配置的卡(通常是通过硬件跳线设置)来使用另一个 IRQ,比如 IRQ1

会计考友 发表于 2012-8-4 12:13:20

linux学习:LPI硬件和体系结构(四)

5。

  目前的 PCI 设备是共享 IRQ 的,所以,当某个设备中断 CPU 时,会有一个中断处理程序检查它并判断那个中断是否为它所用的中断,如果不是,则将它传递给链中的下一个处理程序。清单 4 和 5 并没有向我们展示这种共享。在后面的教程中我们将会学习 grep 命令,不过,现在我们可以使用它来过滤 dmesg 命令的输出,来查看关于 IRQ 的引导消息,如清单 6 所示。在此突出显示了共享的中断。
  清单 6. 引导过程中发现的中断
  $ dmesg | grep -i irq
  PCI: Discovered primary peer bus 01
  PCI: Using IRQ router PIIX at 00:1f.0
  PCI: Found IRQ 5 for device 00:1f.1
  PCI: Sharing IRQ 5 with 00:1d.2
  Serial driver version 5.05c (2001-07-08) with MANY_PORTS MULTIPORT
  SHARE_IRQ SERIAL_PCI ISAPNP enabled
  ttyS0 at 0x03f8 (irq = 4) is a 16550A
  ttyS1 at 0x02f8 (irq = 3) is a 16550A
  PCI: Found IRQ 5 for device 00:1f.1
  PCI: Sharing IRQ 5 with 00:1d.2
  ICH4: not 100% native mode: will probe irqs later
  ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
  ide1 at 0x170-0x177,0x376 on irq 15
  PCI: Found IRQ 11 for device 00:1d.0
  PCI: Sharing IRQ 11 with 00:02.0
  usb-uhci.c: USB UHCI at I/O 0x1800, IRQ 11
  PCI: Found IRQ 10 for device 00:1d.1

会计考友 发表于 2012-8-4 12:13:21

linux学习:LPI硬件和体系结构(四)

usb-uhci.c: USB UHCI at I/O 0x1820, IRQ 10   PCI: Found IRQ 5 for device 00:1d.2
  PCI: Sharing IRQ 5 with 00:1f.1
  usb-uhci.c: USB UHCI at I/O 0x1840, IRQ 5
  PCI: Found IRQ 9 for device 00:1d.7
  ehci-hcd 00:1d.7: irq 9, pci mem f885d000
  parport0: irq 7 detected
  PCI: Found IRQ 9 for device 02:08.0
  PCI: Found IRQ 9 for device 02:08.0
  parport0: irq 7 detected
  PCI: Found IRQ 11 for device 00:02.0
  PCI: Sharing IRQ 11 with 00:1d.0
  PCI: Found IRQ 9 for device 00:1f.5
  PCI: Sharing IRQ 9 with 00:1f.3
  i810: Intel ICH4 found at IO 0x18c0 and 0x1c00, MEM 0xc0080c00 and
  0xc0080800, IRQ 9
  DMA
  先前提及的与外围设备通过 IO 端口进行的通信,每次传递一个或者两个字节。对于快速的设备,服务中断会用掉大量 CPU 处理能力。更快的方法是使用 直接内存访问(Direct Memory Access,DMA),使用很少 IO 指令告诉设备到 RAM 中哪个位置去读或写数据,然后 DMA 控制器提供 RAM 和外围设备之间数据实际传输的硬件管理。
  谁可以猜出在哪里可以找到关于正在使用的 DMA 通道的信息,请举手。如果您说它是在 /proc/dma 中,那么就说对了。运行 cat /proc/dma 命令,可以看到如清单 7 所示的输出。
  清单 7. /proc/dma
  4: cascade

会计考友 发表于 2012-8-4 12:13:22

linux学习:LPI硬件和体系结构(四)

,在我们的示例中 /proc/dma 经常看起来是几乎是空的。也可以像前面处理 IRQ 那样,扫描引导消息来查找具有 DMA 能力设备的证据。
  清单 8. /proc/dma
  $ dmesg | grep -i dma
  ide0: BM-DMA at 0x1860-0x1867, BIOS settings: hda:DMA, hdb:pio
  ide1: BM-DMA at 0x1868-0x186f, BIOS settings: hdc:DMA, hdd:DMA
  hda: 312581808 sectors (160042 MB) w/8192KiB Cache,
  CHS=19457/255/63, UDMA(100)
  hdc: 398297088 sectors (203928 MB) w/7936KiB Cache,
  CHS=24792/255/63, UDMA(33)
  ehci-hcd 00:1d.7: enabled 64bit PCI DMA
页: [1]
查看完整版本: linux学习:LPI硬件和体系结构(四)