freebsd device drivers [electronic resource] a guide for the intrepid

353 1.1K 0
freebsd device drivers [electronic resource] a guide for the intrepid

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... from the device d_write Called to write data to the device d_ioctl Called to perform an operation other than a read or a write d_poll Called to check the device to see whether data is available for reading or space is available for writing d_mmap Called to map a device offset into a memory address d_kqfilter Called to register the device with a kernel event list d_strategy Called to start a read or... self-explanatory Now, let’s do something more interesting Character Drivers Character drivers are basically KLDs that create character devices As mentioned previously, character devices provide either a character-streamoriented I/O interface or, alternatively, an unstructured (raw) interface These (character -device) interfaces establish the conventions for accessing a device, which include the set of... that can be called to do I/O operations (McKusick and Neville-Neil, 2005) In short, character drivers produce character devices, which provide device access For example, the lpt(4) driver creates the /dev/lpt0 character device, which is used to access the parallel port printer In FreeBSD 4.0 and later, most devices have a character -device interface In general, three components are common to all character... emulates the behavior of a device using only software (that is, without any underlying hardware) Loadable Kernel Modules A device driver can be either statically compiled into the system or dynamically loaded using a loadable kernel module (KLD) NOTE Most operating systems call a loadable kernel module an LKM FreeBSD just had to be different A KLD is a kernel subsystem that can be loaded, unloaded, started,... They’re maintained by a much broader spectrum of developers Some device driver authors have extensive experience with a particular operating system, while others have detailed knowledge of specific hardware components and are tasked with maintaining device drivers for those components across multiple systems Too, device drivers are often somewhat self-contained, so that a developer can maintain a device. .. viewing other parts of the system as a black box Of course, that black box still has an interface, and each operating system provides its own set of interfaces to device drivers Device drivers on all systems need to perform many common tasks, such as discovering devices, allocating resources for connected devices, and managing asynchronous events However, each operating system has its own ways of dealing... Baldwin has been working on various portions of the FreeBSD operating system for 12 years His main areas of interest include SMP, PCI, ACPI, and support for x86 He has served as a member of both the FreeBSD core team and the release engineering team FOREWORD While most portions of an operating system are maintained and developed by individuals who specialize in a given operating system, device drivers are... character drivers:  The d_foo functions  A character device switch table  A make_dev and destroy_dev function call d_foo Functions The d_foo functions, whose function prototypes are defined in the header, are the I/O operations that a process can execute on a device These I/O operations are mostly associated with the file I/O system calls and are accordingly named d_open, d_read, and so on A. .. Neville-Neil and Michael W Lucas for your advice Thanks, Dad, for lending me your expertise on hardware and for lending me actual hardware, which made it possible for me to write this book Thanks, Mom, for your love and support I know you pray for me every day Thanks also go to my friends for their support And last but not least, thanks to the open source software and FreeBSD communities for your willingness... interfaces, including attaching to eligible devices and managing device resources, as well as higher-level interfaces, such as interfacing with the network and storage stacks In addition, the book’s coverage of several of the APIs available in the kernel environment, such as allocating memory, timers, and synchronization primitives, will be useful to anyone working with the FreeBSD kernel This book is a . 200 bus_dmamap_load_mbuf Function 201 bus_dmamap_load_mbuf_sg Function 201 bus_dmamap_load_uio Function 202 bus_dmamap_unload Function 202 DMA Map Management Routines, Part 2 202 A Straightforward Example. of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark. device drivers are often somewhat self-contained, so that a developer can maintain a device driver while viewing other parts of the system as a black box. Of course, that black box still has

Ngày đăng: 29/05/2014, 23:56

Từ khóa liên quan

Mục lục

  • Brief Contents

  • About the Author and the Technical Reviewer

  • Foreword

  • Acknowledgments

  • Introduction

    • Who Is This Book For?

    • Prerequisites

    • Contents at a Glance

    • Welcome Aboard!

    • 1: Building and Running Modules

      • Types of Device Drivers

      • Loadable Kernel Modules

        • Module Event Handler

        • DECLARE_MODULE Macro

        • Hello, world!

        • Compiling and Loading

        • Character Drivers

          • d_foo Functions

          • Character Device Switch Table

          • make_dev and destroy_dev Functions

          • Mostly Harmless

            • echo_write Function

            • echo_read Function

            • echo_modevent Function

            • DEV_MODULE Macro

Tài liệu cùng người dùng

Tài liệu liên quan