TOC PREV NEXT INDEX

Writing Device Drivers for LynxOS

Preface

For More Information

Typographical Conventions

Special Notes

Technical Support

LynuxWorks U.S. Headquarters

LynuxWorks Europe

World Wide Web

Chapter 1 Device Driver Basics

What is a Device Driver?

Types of Device Drivers

Device Drivers and Devices

LynxOS Device Driver Components

Entry Point Functions

Data Structures

Handling Interrupts

Other Components

LynxOS Kernel Support Functions

Device Driver Development and Installation

Referencing Device Drivers

Major and Minor Device Designations

Referencing Driver and Device IDs Under LynxOS

Application Access to Devices and Drivers

Chapter 2 Entry Point Functions

Entry Point Functions

Required Functions

Declaring the Entry Point Functions

install()

uninstall()

open()

close()

read()

write()

ioctl()

select()

strategy()

Chapter 3 Memory Management

LynxOS Virtual Memory Model

DMA Transfers

LynxOS Address Types

Allocating Memory

Memory Locking

mem_lock()

mem_unlock()

Address Translation

Virtual Address Conversion

Validating Addresses

Accessing User Space from Interrupt Handlers and Kernel Threads

Accessing Hardware

Using permap()

Device Access on x86 Systems

Device Access on PowerPC Systems

Chapter 4 Synchronization

Introduction

What is Synchronization?

Kernel Semaphores

Other Kernel Semaphore Functions

Using Kernel Semaphores for Mutual Exclusion

Priority Inheritance Semaphores

Event Synchronization

Handling Signals

Using sreset() with Event Synchronization Semaphores

Resource Pool Management

Combining Synchronization Mechanisms

Manipulating a Free List

Signal Handling and Real-Time Response

Chapter 5 Interrupt and Timeout Handling

Introduction

Timeout Interrupts

Interrupts and Real-Time Response

LynxOS Interrupt Handlers

iointset()

iointclr()

Sharing IRQs

Interrupt Vector Values

Interrupt Levels

Implementing an Interrupt Handler

Use of Queues

Interrupt Handler Considerations

Example Code

x86 IRQ Device Defaults

Timeout Handlers

Chapter 6 Kernel Threads and Priority Tracking

Device Drivers in LynxOS

Interrupt Latency

Interrupt Dispatch Time

Driver Response Time

Task Response Time

Task Completion Time

Real-Time Response

Kernel Threads

Creating Kernel Threads

Structure of a Kernel Thread

Exclusive Access

Multiple Access

Priority Tracking

User and Kernel Priorities

Exclusive Access

Multiple Access

Non-Atomic Requests

Controlling Interrupts

Chapter 7 Network Device Drivers

Kernel Data Structures

struct ether_header

struct arpcom

struct sockaddr

struct sockaddr_in

struct in_addr

struct ifnet

struct mbuf

Statics Structure

Packet Queues

Driver Entry Points

install Entry Point

Initializing the Ethernet Address

Initializing the ifnet Structure

Packet Output

ether_output Function

Kernel Thread Processing

Packet Input

Determining Packet Type

Copying Data to mbufs

Enqueueing Packet

Statistics Counters

ioctl Entry Point

SIOCSIFADDR

SIOCSIFFLAGS

watchdog Entry Point

reset Entry Point

Kernel Thread

Priority Tracking

Driver Configuration File

IP Multicasting Support

ether_multi Structure

Chapter 8 Installation and Debugging

Static Versus Dynamic Installation

Static Installation

Dynamic Installation

Static Installation Procedure

Driver Source Code

Device and Driver Configuration File

Configuration File: CONFIG.TBL

Rebuilding the Kernel

Dynamic Installation Procedure

Driver Source Code

Driver Installation

Device Information Definition and Declaration

Device Installation

Node Creation

Device and Driver Uninstallation

Common Error Messages During Dynamic Installation

Debugging

Communicating with the Device Driver

Simple Kernel Debugger (SKDB)

Handling Bus Errors

Probing for Devices

Additional Notes

Chapter 9 Device Resource Manager (DRM)

DRM Concepts

Device Tree

DRM Components

DRM Nodes

DRM Node States

DRM Initialization

DRM Service Routines

Interface Specification

Using DRM Facilities from Device Drivers

Device Identification

Device Interrupt Management

Device Address Space Management

Device I/O

DRM Tree Traversal

Device Insertion/Removal

Using DRM Facilities from Applications

Hot Swap Management Applications

Example Driver

Sample Application

Chapter 10 Writing Flash Memory Technology Drivers (MTDs)

Cache Management

Interface Overview

Registering with flash_mgr

MTD Registration Data

Deregistering from flash_mgr

Writing Callback Routines

Operation Code

Flash Virtual Base

Operation Parameter

MTD-Specific Data

Return Code

Synchronization

Chapter 11 Writing PC Card Client Drivers

Card Services Overview

Card Services Initialization

Logical Sockets

Card Services Groups

Card Services Calling Conventions

Header Files

Synopsis

Client Structure

Detecting the Presence of Card Services

Client Registration

PC Card Identification

PC Card Configuration

Client Deregistration

Sample Client Drivers

Card Services Reference

AccessConfigReg

DeregisterClient

ErrorName

GetCardServicesInfo

GetConfigurationInfo

GetFirstTuple

GetNextTuple

ParseTuple

RegisterClient

ReleaseConfiguration

ReleaseIO

ReleaseIRQ

RequestConfiguration

RequestIO

RequestIRQ

ServiceName

PC Card Support

Installing and Removing PC Card Support

PC Card Support Architecture

Socket Services

Card Services

Client Device Drivers

PC Card Enabler

PC Card Utilities

Using a PC Card

Supported Cards

Hot Swapping

Adding Support for a New PC Card

Adding Support to PC Card Enabler

Create New Device Driver

Adding Support for a New PCMCIA Adapter

Supported PCMCIA Adapters

Troubleshooting

Writing PC Card Socket Services

Socket Services Overview

Socket Services Groups

Socket Services Structure

Header Files

Registration

Event Notification

Socket Services Callback

Socket Services Reference

SS_GetInfo

SS_InquireSocket

SS_SetSocket

SS_GetSocket

SS_InquireWindow

SS_SetWindow

SS_GetWindow

Appendix A Porting Linux Drivers to LynxOS

GPL Issues

Driver Installation

Using a Device

Major and Minor Numbers

Accessing a Device

Driver Entry Points

System Call Processing

Preemption

Signal Handling

Interrupts

How Linux Handles Interrupts

How LynxOS Handles Interrupts

Registering Interrupts

Blocking and Non-Blocking I/O

Bottom-Halves and Kernel Threads

Kernel Support

Kernel Timer Support

Semaphore Support

LynxOS Semaphore Support

Address Translation

Address Translation for Linux

Address Translation for LynxOS

Driver Problem Reporting

Communications with Applications

Scheduling Differences

Linux Scheduling

LynxOS Scheduling

Differences in Setting up a Driver

Setup

Installation

Device Access: open() and close()

Device Access: read() and write():

Device Access: Control

Appendix B Porting UNIX Drivers to LynxOS

Kernel and Driver Design Goals

Porting Strategy

Driver Structure

Overall Structure

Global Variables

Major and Minor Device Numbers

Driver Interface with Kernel

Driver Service Calls

Initialization Routine

Probing for Devices

Interrupt Handling

U Structure

u_base, u_count, u_offset

u_fmode

u_error

u_segflg

u_procp

u_tsav, u_nofault

Reentrance and Synchronization

Critical Code Regions

Event Synchronization

Driver Interface with User Applications

Entry Points

Major and Minor Device Numbers

open/close

read/write

ioctl

select

Accessing User Space

Returning Errors to User Application

LynxOS Kernel Threads

Dynamic Installation

POSIX Programming Model

Asynchronous I/O

Synchronous I/O Multiplexing and Polling

Appendix C Sample Device Driver

Header Files

ptrinfo.h

prtioclt.h

Driver Code

Index




LynuxWorks, Inc.
855 Branham Lane East
San Jose, CA 95138
http://www.lynuxworks.com
1.800.255.5969
TOC PREV NEXT INDEX