acpi_if.m revision 132212
1131276Snjl#
2131276Snjl# Copyright (c) 2004 Nate Lawson
3131276Snjl# All rights reserved.
4131276Snjl#
5131276Snjl# Redistribution and use in source and binary forms, with or without
6131276Snjl# modification, are permitted provided that the following conditions
7131276Snjl# are met:
8131276Snjl# 1. Redistributions of source code must retain the above copyright
9131276Snjl#    notice, this list of conditions and the following disclaimer.
10131276Snjl# 2. Redistributions in binary form must reproduce the above copyright
11131276Snjl#    notice, this list of conditions and the following disclaimer in the
12131276Snjl#    documentation and/or other materials provided with the distribution.
13131276Snjl#
14131276Snjl# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15131276Snjl# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16131276Snjl# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17131276Snjl# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18131276Snjl# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19131276Snjl# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20131276Snjl# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21131276Snjl# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22131276Snjl# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23131276Snjl# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24131276Snjl# SUCH DAMAGE.
25131276Snjl#
26131276Snjl# $FreeBSD: head/sys/dev/acpica/acpi_if.m 132212 2004-07-15 16:29:08Z njl $
27131276Snjl#
28131276Snjl
29131276Snjl#include <sys/bus.h>
30131276Snjl#include <sys/types.h>
31131276Snjl#include "acpi.h"
32131276Snjl
33131276SnjlINTERFACE acpi;
34131276Snjl
35131276Snjl#
36132212Snjl# Callback function for each child handle traversed in acpi_scan_children().
37131276Snjl#
38132212Snjl# ACPI_HANDLE h:  current child device being considered
39132212Snjl#
40132212Snjl# device_t *dev:  pointer to the child's original device_t or NULL if there
41132212Snjl#   was none.  The callback should store a new device in *dev if it has
42132212Snjl#   created one.  The method implementation will automatically clean up the
43132212Snjl#   previous device and properly associate the current ACPI_HANDLE with it.
44132212Snjl#
45132212Snjl# level:  current level being scanned
46132212Snjl#
47132212Snjl# void *arg:  argument passed in original call to acpi_scan_children()
48132212Snjl#
49132212Snjl# Returns:  AE_OK if the scan should continue, otherwise an error
50132212Snjl#
51132212SnjlHEADER {
52132212Snjl	typedef ACPI_STATUS (*acpi_scan_cb_t)(ACPI_HANDLE h, device_t *dev,
53132212Snjl	    int level, void *arg);
54132212Snjl};
55132212Snjl
56132212Snjl#
57132212Snjl# Default implementation for acpi_id_probe().
58132212Snjl#
59131276SnjlCODE {
60131276Snjl	static char *
61131276Snjl	acpi_generic_id_probe(device_t bus, device_t dev, char **ids)
62131276Snjl	{
63131276Snjl		return (NULL);
64131276Snjl	}
65131276Snjl};
66131276Snjl
67131276Snjl#
68132212Snjl# Check a device for a match in a list of ID strings.  The strings can be
69132212Snjl# EISA PNP IDs or ACPI _HID/_CID values.
70131276Snjl#
71132212Snjl# device_t bus:  parent bus for the device
72132212Snjl#
73132212Snjl# device_t dev:  device being considered
74132212Snjl#
75132212Snjl# char **ids:  array of ID strings to consider
76132212Snjl#
77132212Snjl# Returns:  ID string matched or NULL if no match
78132212Snjl#
79131276SnjlMETHOD char * id_probe {
80131276Snjl	device_t	bus;
81131276Snjl	device_t	dev;
82131276Snjl	char		**ids;
83131276Snjl} DEFAULT acpi_generic_id_probe;
84131276Snjl
85131276Snjl#
86132212Snjl# Evaluate an ACPI method or object, given its path.
87131276Snjl#
88132212Snjl# device_t bus:  parent bus for the device
89132212Snjl#
90132212Snjl# device_t dev:  evaluate the object relative to this device's handle.
91132212Snjl#   Specify NULL to begin the search at the ACPI root.
92132212Snjl#
93132212Snjl# ACPI_STRING pathname:  absolute or relative path to this object
94132212Snjl#
95132212Snjl# ACPI_OBJECT_LIST *parameters:  array of arguments to pass to the object.
96132212Snjl#   Specify NULL if there are none.
97132212Snjl#
98132212Snjl# ACPI_BUFFER *ret:  the result (if any) of the evaluation
99132212Snjl#   Specify NULL if there is none.
100132212Snjl#
101132212Snjl# Returns:  AE_OK or an error value
102132212Snjl#
103131276SnjlMETHOD ACPI_STATUS evaluate_object {
104131276Snjl	device_t	bus;
105131276Snjl	device_t	dev;
106131276Snjl	ACPI_STRING 	pathname;
107131276Snjl	ACPI_OBJECT_LIST *parameters;
108131276Snjl	ACPI_BUFFER	*ret;
109131276Snjl};
110131276Snjl
111131276Snjl#
112132212Snjl# Rescan a subtree and optionally reattach devices to handles.  Users
113132212Snjl# specify a callback that is called for each ACPI_HANDLE of type Device
114132212Snjl# that is a child of "dev".
115131276Snjl#
116132212Snjl# device_t bus:  parent bus for the device
117132212Snjl#
118132212Snjl# device_t dev:  begin the scan starting with this device's handle.
119132212Snjl#   Specify NULL to begin the scan at the ACPI root.
120132212Snjl# 
121132212Snjl# int max_depth:  number of levels to traverse (i.e., 1 means just the
122132212Snjl#   immediate children.
123132212Snjl#
124132212Snjl# acpi_scan_cb_t user_fn:  called for each child handle
125132212Snjl#
126132212Snjl# void *arg:  argument to pass to the callback function
127132212Snjl#
128132212Snjl# Returns:  AE_OK or an error value, based on the callback return value
129132212Snjl#
130132212SnjlMETHOD ACPI_STATUS scan_children {
131131276Snjl	device_t	bus;
132131276Snjl	device_t	dev;
133132212Snjl	int		max_depth;
134132212Snjl	acpi_scan_cb_t	user_fn;
135132212Snjl	void		*arg;
136131276Snjl};
137