1 /******************************************************************************
3 * Module Name: bmrequest.c
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 Andrew Grover
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #define _COMPONENT ACPI_BUS_MANAGER
30 MODULE_NAME ("bmrequest")
33 /****************************************************************************
35 ****************************************************************************/
37 /****************************************************************************
39 * FUNCTION: bm_generate_request
47 ****************************************************************************/
54 ACPI_STATUS status
= AE_OK
;
56 FUNCTION_TRACE("bm_generate_request");
58 if (!node
|| !request
) {
59 return_ACPI_STATUS(AE_BAD_PARAMETER
);
62 DEBUG_PRINT(ACPI_INFO
, ("Sending request [0x%02x] to device [0x%02x].\n", request
->command
, node
->device
.handle
));
64 if (!(node
->device
.flags
& BM_FLAGS_DRIVER_CONTROL
) ||
65 !(node
->driver
.request
)) {
66 DEBUG_PRINT(ACPI_WARN
, ("No driver installed for device [0x%02x].\n", node
->device
.handle
));
67 return_ACPI_STATUS(AE_NOT_EXIST
);
70 status
= node
->driver
.request(request
, node
->driver
.context
);
72 return_ACPI_STATUS(status
);
76 /****************************************************************************
78 * FUNCTION: bm_request
86 ****************************************************************************/
92 ACPI_STATUS status
= AE_OK
;
94 BM_DEVICE
*device
= NULL
;
96 FUNCTION_TRACE("bm_request");
99 * Must have a valid request structure.
102 return_ACPI_STATUS(AE_BAD_PARAMETER
);
105 DEBUG_PRINT(ACPI_INFO
, ("Received request for device [0x%02x] command [0x%08x].\n", request
->handle
, request
->command
));
110 status
= bm_get_node(request
->handle
, 0, &node
);
111 if (ACPI_FAILURE(status
)) {
112 return_ACPI_STATUS(status
);
115 device
= &(node
->device
);
118 * Device-Specific Request?
119 * ------------------------
120 * If a device-specific command (>=0x80) forward this request to
121 * the appropriate driver.
123 if (request
->command
& BM_COMMAND_DEVICE_SPECIFIC
) {
124 status
= bm_generate_request(node
, request
);
125 return_ACPI_STATUS(status
);
129 * Bus-Specific Requests:
130 * ----------------------
132 switch (request
->command
) {
134 case BM_COMMAND_GET_POWER_STATE
:
135 status
= bm_get_power_state(node
);
136 if (ACPI_FAILURE(status
)) {
139 status
= bm_copy_to_buffer(&(request
->buffer
),
140 &(device
->power
.state
), sizeof(BM_POWER_STATE
));
143 case BM_COMMAND_SET_POWER_STATE
:
145 BM_POWER_STATE
*power_state
= NULL
;
147 status
= bm_cast_buffer(&(request
->buffer
),
148 (void**)&power_state
, sizeof(BM_POWER_STATE
));
149 if (ACPI_FAILURE(status
)) {
152 status
= bm_set_power_state(node
, *power_state
);
158 request
->status
= AE_SUPPORT
;
162 return_ACPI_STATUS(status
);