"); //-->
When writing drivers, a programmer should pay particular attention to this funda-
mental concept: write kernel code to access the hardware, but don’t force particular
policies on the user, since different users have different needs. The driver should deal
with making the hardware available, leaving all the issues about how to use the hard-
ware to the applications. A driver, then, is flexible if it offers access to the hardware
capabilities without adding constraints. Sometimes, however, some policy decisions
must be made. For example, a digital I/O driver may only offer byte-wide access to
the hardware in order to avoid the extra code needed to handle individual bits.
在编写驱动时, 程序员应当特别注意这个基础的概念: 编写内核代码来存取硬件, 但是不能强加特
别的策略给用户, 因为不同的用户有不同的需求. 驱动应当做到使硬件可用, 将所有关于如何使用
硬件的事情留给应用程序. 一个驱动, 这样, 就是灵活的, 如果它提供了对硬件能力的存取, 没有增加
约束. 然而, 有时必须作出一些策略的决定. 例如, 一个数字 I/O 驱动也许只提供对硬件的字符存取,
以便避免额外的代码处理单个位.
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。