Motorola MCP750 Specifications Page 153

  • Download
  • Add to my manuals
  • Print
  • Page
    / 344
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 152
Developing a Device Drive
r
10-
7
Each type of entry point is briefly described as follows.
Initialization Routines 10
Typically, there are some initialization tasks that must be performed before the device is
ready to operate within the system. Typically, the initialization tasks include initializing
the device hardware, allocating control and data buffers, registering interrupt handlers, and
so on. These routines can perform these tasks: init(D2) and start(D2).
I/O Service Routines 10
Once the driver and associated devices have been initialized, the system is ready to inter-
face to the device via I/O service routines. The I/O service routines consist of several man-
datory and optional entry points. All character device driver entry points must have an
open() and close() entry point. Other entry points are optional—for example,
read(), write(), ioctl(), mmap() and chpoll(). These entry points are speci-
fied in the driver’s Master(4) configuration file. The driver’s I/O service routines are
called at program level.
Interrupt Service Routines 10
If the device for which you are developing a driver generates interrupts, the driver might
have one or more interrupt service routines. The driver’s interrupt service routines are
called at interrupt level. Typically, an interrupt service routine is invoked to handle the
completion of a data transfer or to signal an error condition or any other type of I/O event.
Developing the Driver Header File and Data Structures 10
Typically, a device drivers’s header file is used to declare device-dependent structures,
define symbolic constants and macros.
Most device drivers are written to control a piece of hardware plugged into the I/O back-
plane of the computer. Most boards are designed to have a set of control registers starting
at memory location zero of the board’s memory. This memory is mapped into the virtual
address space of the kernel at boot time. Because the registers on the board are accessed
frequently, it is helpful to declare a structure that represents those registers, declare a
pointer to this type of structure, and have the pointer point to the virtual address of the
board.
When declaring this structure, you must be aware of certain alignment considerations. The
simple data types and their alignment restrictions are described in Chapter 9 (“Under-
standing the Kernel Environment”).
Page view 152
1 2 ... 148 149 150 151 152 153 154 155 156 157 158 ... 343 344

Comments to this Manuals

No comments