📄 introduction to device drivers.htm
字号:
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>1.7.1 A Read Request Is Made to the Device Driver
</H3>
<P>A user program issues a <TT>read</TT> system call (C-1). <A
name=nx_id_32></A>The figure shows that the <TT>read</TT> system call passes
three arguments: a file descriptor (the <TT>fd</TT> argument), the character
pointer to where the information is stored (the <TT>buf</TT> argument), and an
integer (the value 1) that tells the driver's <TT>read</TT> interface how many
bytes to read. The calling sequence is blocked inside the device driver's
<TT>read</TT> interface because the buffer where the data is stored is empty,
indicating that there are currently no characters available to satisfy the read.
The kernel's <TT>read</TT> interface makes a request of the device driver's
<TT>read</TT> interface to perform a read of the character based on the
arguments passed by the <TT>read</TT> system call (C-2). Essentially, the driver
<TT>read</TT> interface is waiting for a character to be typed at the terminal's
keyboard. The currently blocked process that caused the kernel to call the
driver's <TT>read</TT> interface is not running in the CPU (C-3). <A
name=acharcap_byhard></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#IntrotoDevDrv"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#areadreq_ismade"><IMG
alt="[Previous Section]" src="Introduction to Device Drivers_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#ainterupt_isgen"><IMG
alt="[Next Section]" src="Introduction to Device Drivers_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>1.7.2 The Character Is Captured by the Hardware </H3>
<P>Later, a user types the letter k on the terminal keyboard (I-4). The letter
is stored in the device's data register (I-5). <A name=ainterupt_isgen></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#IntrotoDevDrv"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#acharcap_byhard"><IMG
alt="[Previous Section]" src="Introduction to Device Drivers_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#ainterupt_handles"><IMG
alt="[Next Section]" src="Introduction to Device Drivers_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>1.7.3 The Interrupt Is Generated </H3>
<P>When the user types a key, the console keyboard controller alters some
signals on the bus. This action notifies the CPU that something has changed
inside the console keyboard controller. This condition causes the CPU to
immediately start running the console keyboard controller's interrupt handler
(I-6). The state of the interrupted process (either some other process or the
idle loop) is saved so that the process can be returned to its original state as
though it had never been interrupted in the first place.
<P><A name=ainterupt_handles></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#IntrotoDevDrv"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#ainterupt_isgen"><IMG
alt="[Previous Section]" src="Introduction to Device Drivers_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#thechar_isreturned"><IMG
alt="[Next Section]" src="Introduction to Device Drivers_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>1.7.4 The Interrupt Handler Services the Interrupt
</H3>
<P>The console device driver's interrupt handler first checks the state of the
driver and notices that a pending read operation exists for the original
process. The console device driver manipulates the controller hardware by way of
the bus hardware in order to obtain the value of the character that was typed.
This character value was stored somewhere inside the console controller's
hardware (I-7). In this case, the value 107 (the ASCII representation for the k
character) is stored. The interrupt handler stores this character value into a
buffer that is in a location known to the rest of the console driver interfaces
(I-8). It then awakens the original, currently sleeping, process so that it is
ready to run again (I-9). The interrupt handler returns, in effect restoring the
interrupted process (not the original process yet) so that it may continue where
it left off. <A name=thechar_isreturned></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#IntrotoDevDrv"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#ainterupt_handles"><IMG
alt="[Previous Section]" src="Introduction to Device Drivers_files/PREV.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#sum_ofexample"><IMG
alt="[Next Section]" src="Introduction to Device Drivers_files/NEXT.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>1.7.5 The Character Is Returned </H3>
<P>Later, the kernel's process scheduler notices that the original process is
ready to run, and so allows it to run. After the original process resumes
running (after the location where it was first blocked), it knows which buffer
to look at to obtain the typed character (C-10). It removes the character from
this buffer and puts it into the user's address space (C-11). The device
driver's <TT>read</TT> interface returns control to the kernel's <TT>read</TT>
interface (C-12). The kernel <TT>read</TT> interface returns control to the user
program that previously initiated the read request (C-13). <A
name=sum_ofexample></A>
<P>
<HR>
<P align=center><A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/Digital_UNIX_Bookshelf.html"><IMG
alt="[Return to Library]"
src="Introduction to Device Drivers_files/BOOKSHELF.gif" border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/TOC.html"><IMG
alt=[Contents] src="Introduction to Device Drivers_files/TOC.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#IntrotoDevDrv"><IMG
alt="[Previous Chapter]" src="Introduction to Device Drivers_files/REW.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut3.html#thechar_isreturned"><IMG
alt="[Previous Section]" src="Introduction to Device Drivers_files/PREV.gif"
border=0></A> <IMG src="Introduction to Device Drivers_files/BLANK.gif"
border=0> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/drivertut4.html"><IMG
alt="[Next Chapter]" src="Introduction to Device Drivers_files/FF.gif"
border=0></A> <A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-PUBVD-TE_html/INDEX.html"><IMG
alt=[Index] src="Introduction to Device Drivers_files/INDEX.gif" border=0></A>
<A
href="http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/HELP.html"><IMG
alt=[Help] src="Introduction to Device Drivers_files/HELP.gif" border=0></A>
<P>
<HR>
<P>
<H3>1.7.6 Summary of the Example </H3>
<P>Although this example presents a somewhat simplified view of character
processing, it does illustrate how control passes from a user program to the
kernel to the device driver. It also shows clearly that interrupt processing
occurs asynchronously from other device driver activity. <!--Metrics Tag --><!-- Updated April 22, 2003 --><!-- SiteCatalyst code version: G.0. w/dev site filtering
Copyright 1997-2003 Omniture, Inc. More info available at
http://www.omniture.com -->
<SCRIPT language=JavaScript><!--
/* Specify the Report Suite ID(s) to track here */
var s_account="HPHQGlobal,hphqWWesg,hphqbcs,hphqtru64"
/* Dynamic Report Suite ID Selection Config */
var s_dynamicAccountSelection = true
var s_dynamicAccountList = "hphqwwtrash=dec.com,cpqcorp.net,hpqcorp.net"
/* You may give each page an identifying user friendly name in place of urls. */
var s_pageName="Tru64-" + document.title;
if ( location.pathname.indexOf('/docs' ) != -1 ) { s_pageName = "Tru64-docs-" + document.title; }
/* Regionally assigned variables. */
var s_server=""
var s_channel=""
var s_pageType=""
var s_prop1="Tru64 UNIX"
if ( location.pathname.indexOf('/docs' ) != -1 ) { s_prop
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -