Motorola MCP750 Specifications Page 155

  • Download
  • Add to my manuals
  • Print
  • Page
    / 344
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 154
Developing a Device Drive
r
10-9
Typically, the types of activities performed by a driver’s init() or start() routine are
as follows:
1. Find the adapter’s entry in the array of adapter structures keying on the
adapter type and adapter number.
2. Read the device’s bus I/O address, and map the device into virtual address
space via physmap(D3).
3. Probe for the presence of the adapter at that address by calling
badaddr(D3).
4. If the device is present:
Initialize the hardware—typically by writing to control registers and
calling drv_usecwait(D3) to busy wait while the device resets.
If appropriate, allocate an interrupt vector by calling
ivec_alloc(D3), and register the interrupt handler via
ivec_init(D3).
Allocate and initialize any necessary control and data structures and buffers by calling
kmem_alloc(D3).
Further, the order in which the device drivers are initialized is not important. In rare cases,
some devices must be initialized before others. For this purpose, you must specify this
order in the Master(4) configuration files of the associated drivers.
To initialize dynamically linked device drivers, the system specifies distinct optional entry
points and kernel support routines, including the _load(D2) routine. In general, these
are called when the driver is initially invoked in order to load it into the running system.
Refer to Chapter 13 (“Loadable Modules”) for information on dynamically loadable mod-
ules.
Note that these routines execute on a single processor, do not have any user context, and
cannot cause the process to sleep.
The Init Routine 10
Specification
#include <sys/adapter.h>
void
xx
init (void)
Return Values
None.
To get started, the name of the init() entry point must be specified in the driver’s
Master(4) configuration file. Also the Sadapters(4) file must contain the hardware
attributes of the device.
You can take advantage of the fact that interrupts are disabled in the init() routine to
initialize your device without risk of receiving an inopportune device interrupt. In general,
all tasks that require the system services to be disabled must be coded in the init() rou-
Page view 154
1 2 ... 150 151 152 153 154 155 156 157 158 159 160 ... 343 344

Comments to this Manuals

No comments