device_if.m revision 36973
11590Srgrimes# 21590Srgrimes# Copyright (c) 1998 Doug Rabson 31590Srgrimes# All rights reserved. 497377Sdes# 597377Sdes# Redistribution and use in source and binary forms, with or without 61590Srgrimes# modification, are permitted provided that the following conditions 797377Sdes# are met: 897377Sdes# 1. Redistributions of source code must retain the above copyright 997377Sdes# notice, this list of conditions and the following disclaimer. 1097377Sdes# 2. Redistributions in binary form must reproduce the above copyright 1197377Sdes# notice, this list of conditions and the following disclaimer in the 121590Srgrimes# documentation and/or other materials provided with the distribution. 131590Srgrimes# 141590Srgrimes# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 151590Srgrimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 161590Srgrimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 171590Srgrimes# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 181590Srgrimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 191590Srgrimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 201590Srgrimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 211590Srgrimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 221590Srgrimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 231590Srgrimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 241590Srgrimes# SUCH DAMAGE. 251590Srgrimes# 261590Srgrimes# $Id$ 271590Srgrimes# 281590Srgrimes 291590SrgrimesINTERFACE device 301590Srgrimes 311590Srgrimes# 321590Srgrimes# Probe to see if the device is present. Return 0 if the device exists, 331590Srgrimes# ENXIO if it cannot be found. 341590Srgrimes# 351590Srgrimes# Devices which implement busses should use this method to probe for 361590Srgrimes# the existence of devices attached to the bus and add them as 371590Srgrimes# children. If this is combined with the use of bus_generic_attach, 381590Srgrimes# the child devices will be automatically probed and attached. 391590Srgrimes# 401590SrgrimesMETHOD int probe { 411590Srgrimes device_t dev; 4214440Smarkm}; 431590Srgrimes 441590Srgrimes# 451590Srgrimes# Attach a device to the system. The probe method will have been 461590Srgrimes# called and will have indicated that the device exists. This routine 471590Srgrimes# should initialise the hardware and allocate other system resources 4828099Scharnier# (such as devfs entries). Returns 0 on success. 491590Srgrimes# 5028099ScharnierMETHOD int attach { 5114440Smarkm device_t dev; 5250477Speter}; 531590Srgrimes 541590Srgrimes# 551590Srgrimes# Detach a device. This can be called if the user is replacing the 561590Srgrimes# driver software or if a device is about to be physically removed 571590Srgrimes# from the system (e.g. for pccard devices). Returns 0 on success. 5877220Smarkm# 591590SrgrimesMETHOD int detach { 601590Srgrimes device_t dev; 611590Srgrimes}; 621590Srgrimes 6377220Smarkm# 6477220Smarkm# This is called during system shutdown to allow the driver to put the 651590Srgrimes# hardware into a consistent state for rebooting the computer. 661590Srgrimes# 6777220SmarkmMETHOD int shutdown { 681590Srgrimes device_t dev; 691590Srgrimes}; 701590Srgrimes