Deleted Added
full compact
acpi_wmi.c (227843) acpi_wmi.c (241537)
1/*-
2 * Copyright (c) 2009 Michael Gmelin <freebsd@grem.de>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009 Michael Gmelin <freebsd@grem.de>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/acpi_support/acpi_wmi.c 227843 2011-11-22 21:28:20Z marius $");
28__FBSDID("$FreeBSD: head/sys/dev/acpi_support/acpi_wmi.c 241537 2012-10-14 09:31:11Z avg $");
29
30/*
31 * Driver for acpi-wmi mapping, provides an interface for vendor specific
32 * implementations (e.g. HP and Acer laptops).
33 * Inspired by the ACPI-WMI mapping driver (c) 2008-2008 Carlos Corbacho which
34 * implements this functionality for Linux.
35 *
36 * WMI and ACPI: http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx

--- 32 unchanged lines hidden (view full) ---

69struct acpi_wmi_softc {
70 device_t wmi_dev; /* wmi device id */
71 ACPI_HANDLE wmi_handle; /* handle of the PNP0C14 node */
72 device_t ec_dev; /* acpi_ec0 */
73 struct cdev *wmistat_dev_t; /* wmistat device handle */
74 struct sbuf wmistat_sbuf; /* sbuf for /dev/wmistat output */
75 pid_t wmistat_open_pid; /* pid operating on /dev/wmistat */
76 int wmistat_bufptr; /* /dev/wmistat ptr to buffer position */
29
30/*
31 * Driver for acpi-wmi mapping, provides an interface for vendor specific
32 * implementations (e.g. HP and Acer laptops).
33 * Inspired by the ACPI-WMI mapping driver (c) 2008-2008 Carlos Corbacho which
34 * implements this functionality for Linux.
35 *
36 * WMI and ACPI: http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx

--- 32 unchanged lines hidden (view full) ---

69struct acpi_wmi_softc {
70 device_t wmi_dev; /* wmi device id */
71 ACPI_HANDLE wmi_handle; /* handle of the PNP0C14 node */
72 device_t ec_dev; /* acpi_ec0 */
73 struct cdev *wmistat_dev_t; /* wmistat device handle */
74 struct sbuf wmistat_sbuf; /* sbuf for /dev/wmistat output */
75 pid_t wmistat_open_pid; /* pid operating on /dev/wmistat */
76 int wmistat_bufptr; /* /dev/wmistat ptr to buffer position */
77 TAILQ_HEAD(wmi_info_list_head, wmi_info) wmi_info_list;
77};
78
79/*
80 * Struct that holds information about
81 * about a single GUID entry in _WDG
82 */
83struct guid_info {
84 char guid[16]; /* 16 byte non human readable GUID */

--- 15 unchanged lines hidden (view full) ---

100 */
101struct wmi_info {
102 TAILQ_ENTRY(wmi_info) wmi_list;
103 struct guid_info ginfo; /* information on guid */
104 ACPI_NOTIFY_HANDLER event_handler;/* client provided event handler */
105 void *event_handler_user_data; /* ev handler cookie */
106};
107
78};
79
80/*
81 * Struct that holds information about
82 * about a single GUID entry in _WDG
83 */
84struct guid_info {
85 char guid[16]; /* 16 byte non human readable GUID */

--- 15 unchanged lines hidden (view full) ---

101 */
102struct wmi_info {
103 TAILQ_ENTRY(wmi_info) wmi_list;
104 struct guid_info ginfo; /* information on guid */
105 ACPI_NOTIFY_HANDLER event_handler;/* client provided event handler */
106 void *event_handler_user_data; /* ev handler cookie */
107};
108
108TAILQ_HEAD(wmi_info_list_head, wmi_info)
109 wmi_info_list = TAILQ_HEAD_INITIALIZER(wmi_info_list);
110
111ACPI_SERIAL_DECL(acpi_wmi, "ACPI-WMI Mapping");
112
113/* public interface - declaration */
114/* standard device interface*/
115static int acpi_wmi_probe(device_t dev);
116static int acpi_wmi_attach(device_t dev);
117static int acpi_wmi_detach(device_t dev);

--- 21 unchanged lines hidden (view full) ---

139/* callbacks */
140static void acpi_wmi_notify_handler(ACPI_HANDLE h, UINT32 notify,
141 void *context);
142static ACPI_STATUS acpi_wmi_ec_handler(UINT32 function,
143 ACPI_PHYSICAL_ADDRESS address, UINT32 width,
144 UINT64 *value, void *context,
145 void *region_context);
146/* helpers */
109
110ACPI_SERIAL_DECL(acpi_wmi, "ACPI-WMI Mapping");
111
112/* public interface - declaration */
113/* standard device interface*/
114static int acpi_wmi_probe(device_t dev);
115static int acpi_wmi_attach(device_t dev);
116static int acpi_wmi_detach(device_t dev);

--- 21 unchanged lines hidden (view full) ---

138/* callbacks */
139static void acpi_wmi_notify_handler(ACPI_HANDLE h, UINT32 notify,
140 void *context);
141static ACPI_STATUS acpi_wmi_ec_handler(UINT32 function,
142 ACPI_PHYSICAL_ADDRESS address, UINT32 width,
143 UINT64 *value, void *context,
144 void *region_context);
145/* helpers */
147static ACPI_STATUS acpi_wmi_read_wdg_blocks(ACPI_HANDLE h);
146static ACPI_STATUS acpi_wmi_read_wdg_blocks(struct acpi_wmi_softc *sc, ACPI_HANDLE h);
148static ACPI_STATUS acpi_wmi_toggle_we_event_generation(device_t dev,
149 struct wmi_info *winfo,
150 enum event_generation_state state);
151static int acpi_wmi_guid_string_to_guid(const UINT8 *guid_string,
152 UINT8 *guid);
147static ACPI_STATUS acpi_wmi_toggle_we_event_generation(device_t dev,
148 struct wmi_info *winfo,
149 enum event_generation_state state);
150static int acpi_wmi_guid_string_to_guid(const UINT8 *guid_string,
151 UINT8 *guid);
153static struct wmi_info* acpi_wmi_lookup_wmi_info_by_guid_string(
152static struct wmi_info* acpi_wmi_lookup_wmi_info_by_guid_string(struct acpi_wmi_softc *sc,
154 const char *guid_string);
155
156static d_open_t acpi_wmi_wmistat_open;
157static d_close_t acpi_wmi_wmistat_close;
158static d_read_t acpi_wmi_wmistat_read;
159
160/* handler /dev/wmistat device */
161static struct cdevsw wmistat_cdevsw = {

--- 71 unchanged lines hidden (view full) ---

233
234 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
235 sc = device_get_softc(dev);
236 ret = ENXIO;
237
238 ACPI_SERIAL_BEGIN(acpi_wmi);
239 sc->wmi_dev = dev;
240 sc->wmi_handle = acpi_get_handle(dev);
153 const char *guid_string);
154
155static d_open_t acpi_wmi_wmistat_open;
156static d_close_t acpi_wmi_wmistat_close;
157static d_read_t acpi_wmi_wmistat_read;
158
159/* handler /dev/wmistat device */
160static struct cdevsw wmistat_cdevsw = {

--- 71 unchanged lines hidden (view full) ---

232
233 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
234 sc = device_get_softc(dev);
235 ret = ENXIO;
236
237 ACPI_SERIAL_BEGIN(acpi_wmi);
238 sc->wmi_dev = dev;
239 sc->wmi_handle = acpi_get_handle(dev);
241 TAILQ_INIT(&wmi_info_list);
240 TAILQ_INIT(&sc->wmi_info_list);
242 /* XXX Only works with one EC, but nearly all systems only have one. */
243 if ((sc->ec_dev = devclass_get_device(devclass_find("acpi_ec"), 0))
244 == NULL)
245 device_printf(dev, "cannot find EC device\n");
246 else if (ACPI_FAILURE((status = AcpiInstallNotifyHandler(sc->wmi_handle,
247 ACPI_DEVICE_NOTIFY, acpi_wmi_notify_handler, sc))))
248 device_printf(sc->wmi_dev, "couldn't install notify handler - %s\n",
249 AcpiFormatException(status));
250 else if (ACPI_FAILURE((status = AcpiInstallAddressSpaceHandler(
251 sc->wmi_handle, ACPI_ADR_SPACE_EC, acpi_wmi_ec_handler,
252 NULL, sc)))) {
253 device_printf(sc->wmi_dev, "couldn't install EC handler - %s\n",
254 AcpiFormatException(status));
255 AcpiRemoveNotifyHandler(sc->wmi_handle, ACPI_DEVICE_NOTIFY,
256 acpi_wmi_notify_handler);
241 /* XXX Only works with one EC, but nearly all systems only have one. */
242 if ((sc->ec_dev = devclass_get_device(devclass_find("acpi_ec"), 0))
243 == NULL)
244 device_printf(dev, "cannot find EC device\n");
245 else if (ACPI_FAILURE((status = AcpiInstallNotifyHandler(sc->wmi_handle,
246 ACPI_DEVICE_NOTIFY, acpi_wmi_notify_handler, sc))))
247 device_printf(sc->wmi_dev, "couldn't install notify handler - %s\n",
248 AcpiFormatException(status));
249 else if (ACPI_FAILURE((status = AcpiInstallAddressSpaceHandler(
250 sc->wmi_handle, ACPI_ADR_SPACE_EC, acpi_wmi_ec_handler,
251 NULL, sc)))) {
252 device_printf(sc->wmi_dev, "couldn't install EC handler - %s\n",
253 AcpiFormatException(status));
254 AcpiRemoveNotifyHandler(sc->wmi_handle, ACPI_DEVICE_NOTIFY,
255 acpi_wmi_notify_handler);
257 } else if (ACPI_FAILURE((status = acpi_wmi_read_wdg_blocks(
256 } else if (ACPI_FAILURE((status = acpi_wmi_read_wdg_blocks(sc,
258 sc->wmi_handle)))) {
259 device_printf(sc->wmi_dev, "couldn't parse _WDG - %s\n",
260 AcpiFormatException(status));
261 AcpiRemoveNotifyHandler(sc->wmi_handle, ACPI_DEVICE_NOTIFY,
262 acpi_wmi_notify_handler);
263 AcpiRemoveAddressSpaceHandler(sc->wmi_handle, ACPI_ADR_SPACE_EC,
264 acpi_wmi_ec_handler);
265 } else {

--- 34 unchanged lines hidden (view full) ---

300
301 if (sc->wmistat_open_pid != 0) {
302 ret = EBUSY;
303 } else {
304 AcpiRemoveNotifyHandler(sc->wmi_handle, ACPI_DEVICE_NOTIFY,
305 acpi_wmi_notify_handler);
306 AcpiRemoveAddressSpaceHandler(sc->wmi_handle,
307 ACPI_ADR_SPACE_EC, acpi_wmi_ec_handler);
257 sc->wmi_handle)))) {
258 device_printf(sc->wmi_dev, "couldn't parse _WDG - %s\n",
259 AcpiFormatException(status));
260 AcpiRemoveNotifyHandler(sc->wmi_handle, ACPI_DEVICE_NOTIFY,
261 acpi_wmi_notify_handler);
262 AcpiRemoveAddressSpaceHandler(sc->wmi_handle, ACPI_ADR_SPACE_EC,
263 acpi_wmi_ec_handler);
264 } else {

--- 34 unchanged lines hidden (view full) ---

299
300 if (sc->wmistat_open_pid != 0) {
301 ret = EBUSY;
302 } else {
303 AcpiRemoveNotifyHandler(sc->wmi_handle, ACPI_DEVICE_NOTIFY,
304 acpi_wmi_notify_handler);
305 AcpiRemoveAddressSpaceHandler(sc->wmi_handle,
306 ACPI_ADR_SPACE_EC, acpi_wmi_ec_handler);
308 TAILQ_FOREACH_SAFE(winfo, &wmi_info_list, wmi_list, tmp) {
307 TAILQ_FOREACH_SAFE(winfo, &sc->wmi_info_list, wmi_list, tmp) {
309 if (winfo->event_handler)
310 acpi_wmi_toggle_we_event_generation(dev,
311 winfo, EVENT_GENERATION_OFF);
308 if (winfo->event_handler)
309 acpi_wmi_toggle_we_event_generation(dev,
310 winfo, EVENT_GENERATION_OFF);
312 TAILQ_REMOVE(&wmi_info_list, winfo, wmi_list);
311 TAILQ_REMOVE(&sc->wmi_info_list, winfo, wmi_list);
313 free(winfo, M_ACPIWMI);
314 }
315 if (sc->wmistat_bufptr != -1) {
316 sbuf_delete(&sc->wmistat_sbuf);
317 sc->wmistat_bufptr = -1;
318 }
319 sc->wmistat_open_pid = 0;
320 destroy_dev(sc->wmistat_dev_t);

--- 8 unchanged lines hidden (view full) ---

329/*
330 * Check if the given GUID string (human readable format
331 * AABBCCDD-EEFF-GGHH-IIJJ-KKLLMMNNOOPP)
332 * exists within _WDG
333 */
334static int
335acpi_wmi_provides_guid_string_method(device_t dev, const char *guid_string)
336{
312 free(winfo, M_ACPIWMI);
313 }
314 if (sc->wmistat_bufptr != -1) {
315 sbuf_delete(&sc->wmistat_sbuf);
316 sc->wmistat_bufptr = -1;
317 }
318 sc->wmistat_open_pid = 0;
319 destroy_dev(sc->wmistat_dev_t);

--- 8 unchanged lines hidden (view full) ---

328/*
329 * Check if the given GUID string (human readable format
330 * AABBCCDD-EEFF-GGHH-IIJJ-KKLLMMNNOOPP)
331 * exists within _WDG
332 */
333static int
334acpi_wmi_provides_guid_string_method(device_t dev, const char *guid_string)
335{
336 struct acpi_wmi_softc *sc;
337 struct wmi_info *winfo;
338 int ret;
339
337 struct wmi_info *winfo;
338 int ret;
339
340 sc = device_get_softc(dev);
340 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
341 ACPI_SERIAL_BEGIN(acpi_wmi);
341 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
342 ACPI_SERIAL_BEGIN(acpi_wmi);
342 winfo = acpi_wmi_lookup_wmi_info_by_guid_string(guid_string);
343 winfo = acpi_wmi_lookup_wmi_info_by_guid_string(sc, guid_string);
343 ret = (winfo == NULL)?0:winfo->ginfo.max_instance+1;
344 ACPI_SERIAL_END(acpi_wmi);
345
346 return (ret);
347}
348
349/*
350 * Call a method "method_id" on the given GUID block

--- 9 unchanged lines hidden (view full) ---

360 struct wmi_info *winfo;
361 struct acpi_wmi_softc *sc;
362 ACPI_STATUS status;
363
364 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
365
366 sc = device_get_softc(dev);
367 ACPI_SERIAL_BEGIN(acpi_wmi);
344 ret = (winfo == NULL)?0:winfo->ginfo.max_instance+1;
345 ACPI_SERIAL_END(acpi_wmi);
346
347 return (ret);
348}
349
350/*
351 * Call a method "method_id" on the given GUID block

--- 9 unchanged lines hidden (view full) ---

361 struct wmi_info *winfo;
362 struct acpi_wmi_softc *sc;
363 ACPI_STATUS status;
364
365 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
366
367 sc = device_get_softc(dev);
368 ACPI_SERIAL_BEGIN(acpi_wmi);
368 if ((winfo = acpi_wmi_lookup_wmi_info_by_guid_string(guid_string))
369 if ((winfo = acpi_wmi_lookup_wmi_info_by_guid_string(sc, guid_string))
369 == NULL)
370 status = AE_NOT_FOUND;
371 else if (!(winfo->ginfo.flags & ACPI_WMI_REGFLAG_METHOD))
372 status = AE_BAD_DATA;
373 else if (instance > winfo->ginfo.max_instance)
374 status = AE_BAD_PARAMETER;
375 else {
376 params[0].Type = ACPI_TYPE_INTEGER;

--- 25 unchanged lines hidden (view full) ---

402 * provided *data will be passed on callback
403 * If there is already an existing event handler registered it will be silently
404 * discarded
405 */
406static ACPI_STATUS
407acpi_wmi_install_event_handler_method(device_t dev, const char *guid_string,
408 ACPI_NOTIFY_HANDLER event_handler, void *data)
409{
370 == NULL)
371 status = AE_NOT_FOUND;
372 else if (!(winfo->ginfo.flags & ACPI_WMI_REGFLAG_METHOD))
373 status = AE_BAD_DATA;
374 else if (instance > winfo->ginfo.max_instance)
375 status = AE_BAD_PARAMETER;
376 else {
377 params[0].Type = ACPI_TYPE_INTEGER;

--- 25 unchanged lines hidden (view full) ---

403 * provided *data will be passed on callback
404 * If there is already an existing event handler registered it will be silently
405 * discarded
406 */
407static ACPI_STATUS
408acpi_wmi_install_event_handler_method(device_t dev, const char *guid_string,
409 ACPI_NOTIFY_HANDLER event_handler, void *data)
410{
411 struct acpi_wmi_softc *sc = device_get_softc(dev);
410 struct wmi_info *winfo;
411 ACPI_STATUS status;
412
413 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
414
415 status = AE_OK;
416 ACPI_SERIAL_BEGIN(acpi_wmi);
417 if (guid_string == NULL || event_handler == NULL)
418 status = AE_BAD_PARAMETER;
412 struct wmi_info *winfo;
413 ACPI_STATUS status;
414
415 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
416
417 status = AE_OK;
418 ACPI_SERIAL_BEGIN(acpi_wmi);
419 if (guid_string == NULL || event_handler == NULL)
420 status = AE_BAD_PARAMETER;
419 else if ((winfo = acpi_wmi_lookup_wmi_info_by_guid_string(guid_string))
421 else if ((winfo = acpi_wmi_lookup_wmi_info_by_guid_string(sc, guid_string))
420 == NULL)
421 status = AE_NOT_EXIST;
422 else if (winfo->event_handler != NULL ||
423 (status = acpi_wmi_toggle_we_event_generation(dev, winfo,
424 EVENT_GENERATION_ON)) == AE_OK) {
425 winfo->event_handler = event_handler;
426 winfo->event_handler_user_data = data;
427 }

--- 5 unchanged lines hidden (view full) ---

433/*
434 * Remove a previously installed event handler from the given GUID
435 * If there was none installed, this call is silently discarded and
436 * reported as AE_OK
437 */
438static ACPI_STATUS
439acpi_wmi_remove_event_handler_method(device_t dev, const char *guid_string)
440{
422 == NULL)
423 status = AE_NOT_EXIST;
424 else if (winfo->event_handler != NULL ||
425 (status = acpi_wmi_toggle_we_event_generation(dev, winfo,
426 EVENT_GENERATION_ON)) == AE_OK) {
427 winfo->event_handler = event_handler;
428 winfo->event_handler_user_data = data;
429 }

--- 5 unchanged lines hidden (view full) ---

435/*
436 * Remove a previously installed event handler from the given GUID
437 * If there was none installed, this call is silently discarded and
438 * reported as AE_OK
439 */
440static ACPI_STATUS
441acpi_wmi_remove_event_handler_method(device_t dev, const char *guid_string)
442{
443 struct acpi_wmi_softc *sc = device_get_softc(dev);
441 struct wmi_info *winfo;
442 ACPI_STATUS status;
443
444 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
445
446 status = AE_OK;
447 ACPI_SERIAL_BEGIN(acpi_wmi);
448 if (guid_string &&
444 struct wmi_info *winfo;
445 ACPI_STATUS status;
446
447 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
448
449 status = AE_OK;
450 ACPI_SERIAL_BEGIN(acpi_wmi);
451 if (guid_string &&
449 (winfo = acpi_wmi_lookup_wmi_info_by_guid_string(guid_string))
452 (winfo = acpi_wmi_lookup_wmi_info_by_guid_string(sc, guid_string))
450 != NULL && winfo->event_handler) {
451 status = acpi_wmi_toggle_we_event_generation(dev, winfo,
452 EVENT_GENERATION_OFF);
453 winfo->event_handler = NULL;
454 winfo->event_handler_user_data = NULL;
455 }
456 ACPI_SERIAL_END(acpi_wmi);
457

--- 18 unchanged lines hidden (view full) ---

476
477 sc = device_get_softc(dev);
478 status = AE_NOT_FOUND;
479 ACPI_SERIAL_BEGIN(acpi_wmi);
480 params[0].Type = ACPI_TYPE_INTEGER;
481 params[0].Integer.Value = event_id;
482 input.Pointer = params;
483 input.Count = 1;
453 != NULL && winfo->event_handler) {
454 status = acpi_wmi_toggle_we_event_generation(dev, winfo,
455 EVENT_GENERATION_OFF);
456 winfo->event_handler = NULL;
457 winfo->event_handler_user_data = NULL;
458 }
459 ACPI_SERIAL_END(acpi_wmi);
460

--- 18 unchanged lines hidden (view full) ---

479
480 sc = device_get_softc(dev);
481 status = AE_NOT_FOUND;
482 ACPI_SERIAL_BEGIN(acpi_wmi);
483 params[0].Type = ACPI_TYPE_INTEGER;
484 params[0].Integer.Value = event_id;
485 input.Pointer = params;
486 input.Count = 1;
484 TAILQ_FOREACH(winfo, &wmi_info_list, wmi_list) {
487 TAILQ_FOREACH(winfo, &sc->wmi_info_list, wmi_list) {
485 if ((winfo->ginfo.flags & ACPI_WMI_REGFLAG_EVENT) &&
486 ((UINT8) winfo->ginfo.oid[0] == event_id)) {
487 status = AcpiEvaluateObject(sc->wmi_handle, "_WED",
488 &input, out);
489 break;
490 }
491 }
492 ACPI_SERIAL_END(acpi_wmi);

--- 27 unchanged lines hidden (view full) ---

520
521 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
522
523 sc = device_get_softc(dev);
524 wc_status = AE_ERROR;
525 ACPI_SERIAL_BEGIN(acpi_wmi);
526 if (guid_string == NULL || out == NULL)
527 status = AE_BAD_PARAMETER;
488 if ((winfo->ginfo.flags & ACPI_WMI_REGFLAG_EVENT) &&
489 ((UINT8) winfo->ginfo.oid[0] == event_id)) {
490 status = AcpiEvaluateObject(sc->wmi_handle, "_WED",
491 &input, out);
492 break;
493 }
494 }
495 ACPI_SERIAL_END(acpi_wmi);

--- 27 unchanged lines hidden (view full) ---

523
524 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
525
526 sc = device_get_softc(dev);
527 wc_status = AE_ERROR;
528 ACPI_SERIAL_BEGIN(acpi_wmi);
529 if (guid_string == NULL || out == NULL)
530 status = AE_BAD_PARAMETER;
528 else if ((winfo = acpi_wmi_lookup_wmi_info_by_guid_string(guid_string))
531 else if ((winfo = acpi_wmi_lookup_wmi_info_by_guid_string(sc, guid_string))
529 == NULL)
530 status = AE_ERROR;
531 else if (instance > winfo->ginfo.max_instance)
532 status = AE_BAD_PARAMETER;
533 else if ((winfo->ginfo.flags & ACPI_WMI_REGFLAG_EVENT) ||
534 (winfo->ginfo.flags & ACPI_WMI_REGFLAG_METHOD))
535 status = AE_ERROR;
536 else {

--- 47 unchanged lines hidden (view full) ---

584 ACPI_STATUS status;
585
586 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
587
588 sc = device_get_softc(dev);
589 ACPI_SERIAL_BEGIN(acpi_wmi);
590 if (guid_string == NULL || in == NULL)
591 status = AE_BAD_DATA;
532 == NULL)
533 status = AE_ERROR;
534 else if (instance > winfo->ginfo.max_instance)
535 status = AE_BAD_PARAMETER;
536 else if ((winfo->ginfo.flags & ACPI_WMI_REGFLAG_EVENT) ||
537 (winfo->ginfo.flags & ACPI_WMI_REGFLAG_METHOD))
538 status = AE_ERROR;
539 else {

--- 47 unchanged lines hidden (view full) ---

587 ACPI_STATUS status;
588
589 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
590
591 sc = device_get_softc(dev);
592 ACPI_SERIAL_BEGIN(acpi_wmi);
593 if (guid_string == NULL || in == NULL)
594 status = AE_BAD_DATA;
592 else if ((winfo = acpi_wmi_lookup_wmi_info_by_guid_string(guid_string))
595 else if ((winfo = acpi_wmi_lookup_wmi_info_by_guid_string(sc, guid_string))
593 == NULL)
594 status = AE_ERROR;
595 else if (instance > winfo->ginfo.max_instance)
596 status = AE_BAD_PARAMETER;
597 else if ((winfo->ginfo.flags & ACPI_WMI_REGFLAG_EVENT) ||
598 (winfo->ginfo.flags & ACPI_WMI_REGFLAG_METHOD))
599 status = AE_ERROR;
600 else {

--- 17 unchanged lines hidden (view full) ---

618
619/*
620 * Handle events received and dispatch them to
621 * stakeholders that registered through ACPI_WMI_INSTALL_EVENT_HANDLER
622 */
623static void
624acpi_wmi_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
625{
596 == NULL)
597 status = AE_ERROR;
598 else if (instance > winfo->ginfo.max_instance)
599 status = AE_BAD_PARAMETER;
600 else if ((winfo->ginfo.flags & ACPI_WMI_REGFLAG_EVENT) ||
601 (winfo->ginfo.flags & ACPI_WMI_REGFLAG_METHOD))
602 status = AE_ERROR;
603 else {

--- 17 unchanged lines hidden (view full) ---

621
622/*
623 * Handle events received and dispatch them to
624 * stakeholders that registered through ACPI_WMI_INSTALL_EVENT_HANDLER
625 */
626static void
627acpi_wmi_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context)
628{
629 struct acpi_wmi_softc *sc = context;
626 ACPI_NOTIFY_HANDLER handler;
627 void *handler_data;
628 struct wmi_info *winfo;
629
630 ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, notify);
631
632 handler = NULL;
633 handler_data = NULL;
634 ACPI_SERIAL_BEGIN(acpi_wmi);
630 ACPI_NOTIFY_HANDLER handler;
631 void *handler_data;
632 struct wmi_info *winfo;
633
634 ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, notify);
635
636 handler = NULL;
637 handler_data = NULL;
638 ACPI_SERIAL_BEGIN(acpi_wmi);
635 TAILQ_FOREACH(winfo, &wmi_info_list, wmi_list) {
639 TAILQ_FOREACH(winfo, &sc->wmi_info_list, wmi_list) {
636 if ((winfo->ginfo.flags & ACPI_WMI_REGFLAG_EVENT) &&
637 ((UINT8) winfo->ginfo.oid[0] == notify)) {
638 if (winfo->event_handler) {
639 handler = winfo->event_handler;
640 handler_data = winfo->event_handler_user_data;
641 break;
642 }
643 }

--- 56 unchanged lines hidden (view full) ---

700 return (status);
701}
702
703/*
704 * Read GUID blocks from the _WDG node
705 * into wmi_info_list.
706 */
707static ACPI_STATUS
640 if ((winfo->ginfo.flags & ACPI_WMI_REGFLAG_EVENT) &&
641 ((UINT8) winfo->ginfo.oid[0] == notify)) {
642 if (winfo->event_handler) {
643 handler = winfo->event_handler;
644 handler_data = winfo->event_handler_user_data;
645 break;
646 }
647 }

--- 56 unchanged lines hidden (view full) ---

704 return (status);
705}
706
707/*
708 * Read GUID blocks from the _WDG node
709 * into wmi_info_list.
710 */
711static ACPI_STATUS
708acpi_wmi_read_wdg_blocks(ACPI_HANDLE h)
712acpi_wmi_read_wdg_blocks(struct acpi_wmi_softc *sc, ACPI_HANDLE h)
709{
710 ACPI_BUFFER out = {ACPI_ALLOCATE_BUFFER, NULL};
711 struct guid_info *ginfo;
712 ACPI_OBJECT *obj;
713 struct wmi_info *winfo;
714 UINT32 i;
715 UINT32 wdg_block_count;
716 ACPI_STATUS status;

--- 14 unchanged lines hidden (view full) ---

731 for (i = 0; i < wdg_block_count; ++i) {
732 if ((winfo = malloc(sizeof(struct wmi_info), M_ACPIWMI,
733 M_NOWAIT | M_ZERO)) == NULL) {
734 AcpiOsFree(out.Pointer);
735 free(ginfo, M_ACPIWMI);
736 return (AE_NO_MEMORY);
737 }
738 winfo->ginfo = ginfo[i];
713{
714 ACPI_BUFFER out = {ACPI_ALLOCATE_BUFFER, NULL};
715 struct guid_info *ginfo;
716 ACPI_OBJECT *obj;
717 struct wmi_info *winfo;
718 UINT32 i;
719 UINT32 wdg_block_count;
720 ACPI_STATUS status;

--- 14 unchanged lines hidden (view full) ---

735 for (i = 0; i < wdg_block_count; ++i) {
736 if ((winfo = malloc(sizeof(struct wmi_info), M_ACPIWMI,
737 M_NOWAIT | M_ZERO)) == NULL) {
738 AcpiOsFree(out.Pointer);
739 free(ginfo, M_ACPIWMI);
740 return (AE_NO_MEMORY);
741 }
742 winfo->ginfo = ginfo[i];
739 TAILQ_INSERT_TAIL(&wmi_info_list, winfo, wmi_list);
743 TAILQ_INSERT_TAIL(&sc->wmi_info_list, winfo, wmi_list);
740 }
741 AcpiOsFree(out.Pointer);
742 free(ginfo, M_ACPIWMI);
743
744 return (status);
745}
746
747/*

--- 93 unchanged lines hidden (view full) ---

841}
842
843/*
844 * Lookup a wmi_info structure in wmi_list based on a
845 * human readable GUID
846 * Return NULL if the GUID is unknown in the _WDG
847 */
848static struct wmi_info*
744 }
745 AcpiOsFree(out.Pointer);
746 free(ginfo, M_ACPIWMI);
747
748 return (status);
749}
750
751/*

--- 93 unchanged lines hidden (view full) ---

845}
846
847/*
848 * Lookup a wmi_info structure in wmi_list based on a
849 * human readable GUID
850 * Return NULL if the GUID is unknown in the _WDG
851 */
852static struct wmi_info*
849acpi_wmi_lookup_wmi_info_by_guid_string(const char *guid_string)
853acpi_wmi_lookup_wmi_info_by_guid_string(struct acpi_wmi_softc *sc, const char *guid_string)
850{
851 char guid[16];
852 struct wmi_info *winfo;
853
854 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
855
856 ACPI_SERIAL_ASSERT(acpi_wmi);
857
858 if (!acpi_wmi_guid_string_to_guid(guid_string, guid)) {
854{
855 char guid[16];
856 struct wmi_info *winfo;
857
858 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
859
860 ACPI_SERIAL_ASSERT(acpi_wmi);
861
862 if (!acpi_wmi_guid_string_to_guid(guid_string, guid)) {
859 TAILQ_FOREACH(winfo, &wmi_info_list, wmi_list) {
863 TAILQ_FOREACH(winfo, &sc->wmi_info_list, wmi_list) {
860 if (!memcmp(winfo->ginfo.guid, guid, 16)) {
861 return (winfo);
862 }
863 }
864 }
865
866 return (NULL);
867}

--- 82 unchanged lines hidden (view full) ---

950 sc->wmistat_bufptr == -1) {
951 ret = EBADF;
952 }
953 else {
954 if (!sbuf_done(&sc->wmistat_sbuf)) {
955 sbuf_printf(&sc->wmistat_sbuf, "GUID "
956 " INST EXPE METH STR "
957 "EVENT OID\n");
864 if (!memcmp(winfo->ginfo.guid, guid, 16)) {
865 return (winfo);
866 }
867 }
868 }
869
870 return (NULL);
871}

--- 82 unchanged lines hidden (view full) ---

954 sc->wmistat_bufptr == -1) {
955 ret = EBADF;
956 }
957 else {
958 if (!sbuf_done(&sc->wmistat_sbuf)) {
959 sbuf_printf(&sc->wmistat_sbuf, "GUID "
960 " INST EXPE METH STR "
961 "EVENT OID\n");
958 TAILQ_FOREACH(winfo, &wmi_info_list, wmi_list) {
962 TAILQ_FOREACH(winfo, &sc->wmi_info_list, wmi_list) {
959 guid = (UINT8*)winfo->ginfo.guid;
960 sbuf_printf(&sc->wmistat_sbuf,
961 "{%02X%02X%02X%02X-%02X%02X-"
962 "%02X%02X-%02X%02X-%02X%02X"
963 "%02X%02X%02X%02X} %3d %-5s",
964 guid[3], guid[2], guid[1], guid[0],
965 guid[5], guid[4],
966 guid[7], guid[6],

--- 50 unchanged lines hidden ---
963 guid = (UINT8*)winfo->ginfo.guid;
964 sbuf_printf(&sc->wmistat_sbuf,
965 "{%02X%02X%02X%02X-%02X%02X-"
966 "%02X%02X-%02X%02X-%02X%02X"
967 "%02X%02X%02X%02X} %3d %-5s",
968 guid[3], guid[2], guid[1], guid[0],
969 guid[5], guid[4],
970 guid[7], guid[6],

--- 50 unchanged lines hidden ---