A minor device is a "personality" of a major device. For example, on
my
laptop, under /devices, we have:
drwxr-xr-x 6 root sys 13 Nov 25 21:48 pci@0,0/
crw------- 1 root sys 183, 255 Dec 26 20:44 pci@0,0:devctl
crw------- 1 root sys 183, 252 Dec 26 20:44 pci@0,0:intr
crw------- 1 root sys 183, 253 Dec 26 20:44 pci@0,0:reg
drwxr-xr-x 2 root sys 2 Dec 25 01:17 pci@2,0/
crw------- 1 root sys 86, 255 Dec 26 20:44 pci@2,0:devctl
crw------- 1 root sys 86, 252 Dec 26 20:44 pci@2,0:intr
crw------- 1 root sys 86, 253 Dec 26 20:44 pci@2,0:reg
pci@0,0:devctl, pci@0,0:intr, and pci@0,0:reg are all minor devices
of major device pci@0,0. When a minor device is opened, its
corresponding major device's driver is asked to service the call.
The driver, however, automatically gets an ID code which
differentiates the call from other "personalities".
In this particular example, we use the "intr" interface to manage
all the interrupts related ioctl calls, which would allow registered
interrupts to be displayed, or rerouted to different CPUs. The "reg"
interface is used by a pcitool-like applications to arbitrarily
read or write any device's register (obviously an extremely dangerous
but useful thing to do). The two interfaces reasonably separates
operations that are moderate from that are dangerous (helpful
in requiring certain credentials). Internally, the two interfaces
are implemented very differently since the "intr" interface need
to interact with the local APICs and "regs" deals with createing
VM mappings for device registers.
laptop, under /devices, we have:
drwxr-xr-x 6 root sys 13 Nov 25 21:48 pci@0,0/
crw------- 1 root sys 183, 255 Dec 26 20:44 pci@0,0:devctl
crw------- 1 root sys 183, 252 Dec 26 20:44 pci@0,0:intr
crw------- 1 root sys 183, 253 Dec 26 20:44 pci@0,0:reg
drwxr-xr-x 2 root sys 2 Dec 25 01:17 pci@2,0/
crw------- 1 root sys 86, 255 Dec 26 20:44 pci@2,0:devctl
crw------- 1 root sys 86, 252 Dec 26 20:44 pci@2,0:intr
crw------- 1 root sys 86, 253 Dec 26 20:44 pci@2,0:reg
pci@0,0:devctl, pci@0,0:intr, and pci@0,0:reg are all minor devices
of major device pci@0,0. When a minor device is opened, its
corresponding major device's driver is asked to service the call.
The driver, however, automatically gets an ID code which
differentiates the call from other "personalities".
In this particular example, we use the "intr" interface to manage
all the interrupts related ioctl calls, which would allow registered
interrupts to be displayed, or rerouted to different CPUs. The "reg"
interface is used by a pcitool-like applications to arbitrarily
read or write any device's register (obviously an extremely dangerous
but useful thing to do). The two interfaces reasonably separates
operations that are moderate from that are dangerous (helpful
in requiring certain credentials). Internally, the two interfaces
are implemented very differently since the "intr" interface need
to interact with the local APICs and "regs" deals with createing
VM mappings for device registers.
次要设备作为主要设备的不同个性存在,在操作系统中扮演关键角色。例如,PCI设备可以通过不同的接口如intr管理和reg读写设备寄存器,这些操作通过相应的主设备驱动程序实现,并且每个接口都有独特的ID代码来区分请求。intr接口用于处理中断相关的ioctl调用,而reg接口允许应用程序任意读写设备寄存器。
2844

被折叠的 条评论
为什么被折叠?



