⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 devapi-device-driver-models.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/).                           --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission is obtained from the copyright holder.               --><HTML><HEAD><TITLE>Device Driver Models</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="Device Driver Interface to the Kernel"HREF="devapi-device-driver-interface-to-the-kernel.html"><LINKREL="PREVIOUS"TITLE="SMP Support"HREF="devapi-smp-support.html"><LINKREL="NEXT"TITLE="Synchronization Levels"HREF="devapi-synchronization-levels.html"></HEAD><BODYCLASS="SECTION"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="devapi-smp-support.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 18. Device Driver Interface to the Kernel</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="devapi-synchronization-levels.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECTION"><H1CLASS="SECTION"><ANAME="DEVAPI-DEVICE-DRIVER-MODELS">Device Driver Models</H1><P>There are several ways in which device driversmay be built. The exact model chosen will depend on the properties ofthe device and the behavior desired. There are three basic models thatmay be adopted.</P><P>The first model is to do all device processing in the ISR.  When it isinvoked the ISR programs the device hardware directly and accessesdata to be transferred directly in memory. The ISR should also call<TTCLASS="FUNCTION">cyg_drv_interrupt_acknowledge()</TT>.  When it isfinished it may optionally request that its DSR be invoked.  The DSRdoes nothing but call <TTCLASS="FUNCTION">cyg_drv_cond_signal()</TT> tocause a thread to be woken up. Thread level code must call<TTCLASS="FUNCTION">cyg_drv_isr_lock()</TT>, or<TTCLASS="FUNCTION">cyg_drv_interrupt_mask()</TT> to prevent ISRs runningwhile it manipulates shared memory.</P><P>The second model is to defer device processing to the DSR.  The ISRsimply prevents further delivery of interrupts by either programmingthe device, or by calling<TTCLASS="FUNCTION">cyg_drv_interrupt_mask()</TT>.  It must then call<TTCLASS="FUNCTION">cyg_drv_interrupt_acknowledge()</TT> to allow otherinterrupts to be delivered and then request that its DSR becalled. When the DSR runs it does the majority of the device handling,optionally signals a condition variable to wake a thread, and finishesby calling <TTCLASS="FUNCTION">cyg_drv_interrupt_unmask()</TT> to re-allowdevice interrupts. Thread level code uses<TTCLASS="FUNCTION">cyg_drv_dsr_lock()</TT> to prevent DSRs running whileit manipulates shared memory.  The eCos serial device drivers use thisapproach.</P><P>The third model is to defer device processing even further to athread. The ISR behaves exactly as in the previous model and simplyblocks and acknowledges the interrupt before request that the DSRrun. The DSR itself only calls<TTCLASS="FUNCTION">cyg_drv_cond_signal()</TT> to wake the thread. Whenthe thread awakens it performs all device processing, and has fullaccess to all kernel facilities while it does so. It should finish bycalling <TTCLASS="FUNCTION">cyg_drv_interrupt_unmask()</TT> to re-allowdevice interrupts.  The eCos ethernet device drivers are written tothis model.</P><P>The first model is good for devices that need immediate processing andinteract infrequently with thread level. The second model trades alittle latency in dealing with the device for a less intrusivesynchronization mechanism. The last model allows device processing tobe scheduled with other threads and permits more complex devicehandling.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="devapi-smp-support.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="devapi-synchronization-levels.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">SMP Support</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="devapi-device-driver-interface-to-the-kernel.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Synchronization Levels</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -