Commit bb721a7a authored by Andy Grover's avatar Andy Grover Committed by Andy Grover

ACPI driver updates

Better IRQ routing
ACPI 2.0-enumerated processor perf state support
ACPI poweroff via magic sysrq
parent 7a47fa52
......@@ -9,7 +9,7 @@ export ACPI_CFLAGS
ACPI_CFLAGS := -D_LINUX -I$(CURDIR)/include
ifdef CONFIG_ACPI_DEBUG
ACPI_CFLAGS += -DACPI_DEBUG -Wno-unused
ACPI_CFLAGS += -DACPI_DEBUG
endif
EXTRA_CFLAGS += $(ACPI_CFLAGS)
......
/*
* acpi_ac.c - ACPI AC Adapter Driver ($Revision: 22 $)
* acpi_ac.c - ACPI AC Adapter Driver ($Revision: 23 $)
*
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
......@@ -296,6 +296,7 @@ acpi_ac_remove (
struct acpi_ac *ac = NULL;
ACPI_FUNCTION_TRACE("acpi_ac_remove");
if (!device || !acpi_driver_data(device))
return_VALUE(-EINVAL);
......
/*
* acpi_battery.c - ACPI Battery Driver ($Revision: 31 $)
* acpi_battery.c - ACPI Battery Driver ($Revision: 32 $)
*
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
......@@ -112,8 +112,9 @@ acpi_battery_get_info (
struct acpi_battery *battery,
struct acpi_battery_info **bif)
{
int result = 0;
acpi_status status = 0;
acpi_buffer buffer = {0, NULL};
acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BIF),
ACPI_BATTERY_FORMAT_BIF};
acpi_buffer data = {0, NULL};
......@@ -126,9 +127,11 @@ acpi_battery_get_info (
/* Evalute _BIF */
status = acpi_evaluate(battery->handle, "_BIF", NULL, &buffer);
if (ACPI_FAILURE(status))
status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BIF\n"));
return_VALUE(-ENODEV);
}
package = (acpi_object *) buffer.pointer;
......@@ -136,29 +139,33 @@ acpi_battery_get_info (
status = acpi_extract_package(package, &format, &data);
if (status != AE_BUFFER_OVERFLOW) {
kfree(buffer.pointer);
return_VALUE(-ENODEV);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n"));
result = -ENODEV;
goto end;
}
data.pointer = kmalloc(data.length, GFP_KERNEL);
if (!data.pointer) {
kfree(buffer.pointer);
return_VALUE(-ENOMEM);
result = -ENOMEM;
goto end;
}
memset(data.pointer, 0, data.length);
status = acpi_extract_package(package, &format, &data);
if (ACPI_FAILURE(status)) {
kfree(buffer.pointer);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n"));
kfree(data.pointer);
return_VALUE(-ENODEV);
result = -ENODEV;
goto end;
}
end:
kfree(buffer.pointer);
(*bif) = data.pointer;
if (0 == result)
(*bif) = (struct acpi_battery_info *) data.pointer;
return_VALUE(0);
return_VALUE(result);
}
static int
......@@ -166,8 +173,9 @@ acpi_battery_get_status (
struct acpi_battery *battery,
struct acpi_battery_status **bst)
{
int result = 0;
acpi_status status = 0;
acpi_buffer buffer = {0, NULL};
acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
acpi_buffer format = {sizeof(ACPI_BATTERY_FORMAT_BST),
ACPI_BATTERY_FORMAT_BST};
acpi_buffer data = {0, NULL};
......@@ -180,9 +188,11 @@ acpi_battery_get_status (
/* Evalute _BST */
status = acpi_evaluate(battery->handle, "_BST", NULL, &buffer);
if (ACPI_FAILURE(status))
status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BST\n"));
return_VALUE(-ENODEV);
}
package = (acpi_object *) buffer.pointer;
......@@ -190,29 +200,33 @@ acpi_battery_get_status (
status = acpi_extract_package(package, &format, &data);
if (status != AE_BUFFER_OVERFLOW) {
kfree(buffer.pointer);
return_VALUE(-ENODEV);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n"));
result = -ENODEV;
goto end;
}
data.pointer = kmalloc(data.length, GFP_KERNEL);
if (!data.pointer) {
kfree(buffer.pointer);
return_VALUE(-ENOMEM);
result = -ENOMEM;
goto end;
}
memset(data.pointer, 0, data.length);
status = acpi_extract_package(package, &format, &data);
if (ACPI_FAILURE(status)) {
kfree(buffer.pointer);
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n"));
kfree(data.pointer);
return_VALUE(-ENODEV);
result = -ENODEV;
goto end;
}
end:
kfree(buffer.pointer);
(*bst) = data.pointer;
if (0 == result)
(*bst) = (struct acpi_battery_status *) data.pointer;
return_VALUE(0);
return_VALUE(result);
}
......@@ -328,7 +342,7 @@ acpi_battery_read_info (
{
int result = 0;
struct acpi_battery *battery = (struct acpi_battery *) data;
struct acpi_battery_info *bif = 0;
struct acpi_battery_info *bif = NULL;
char *units = "?";
char *p = page;
int len = 0;
......@@ -403,8 +417,7 @@ acpi_battery_read_info (
bif->oem_info);
end:
if (bif)
kfree(bif);
kfree(bif);
len = (p - page);
if (len <= off+count) *eof = 1;
......@@ -490,8 +503,7 @@ acpi_battery_read_state (
(u32) bst->present_voltage);
end:
if (bst)
kfree(bst);
kfree(bst);
len = (p - page);
if (len <= off+count) *eof = 1;
......
This diff is collapsed.
/*
* acpi_bus.h - ACPI Bus Driver ($Revision: 17 $)
* acpi_bus.h - ACPI Bus Driver ($Revision: 19 $)
*
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
......@@ -96,8 +96,9 @@ typedef int (*acpi_op_stop) (struct acpi_device *device, int type);
typedef int (*acpi_op_suspend) (struct acpi_device *device, int state);
typedef int (*acpi_op_resume) (struct acpi_device *device, int state);
typedef int (*acpi_op_scan) (struct acpi_device *device);
typedef int (*acpi_op_bind) (struct acpi_device *device);
struct acpi_driver_ops {
struct acpi_device_ops {
acpi_op_add add;
acpi_op_remove remove;
acpi_op_lock lock;
......@@ -106,6 +107,7 @@ struct acpi_driver_ops {
acpi_op_suspend suspend;
acpi_op_resume resume;
acpi_op_scan scan;
acpi_op_bind bind;
};
struct acpi_driver {
......@@ -114,7 +116,7 @@ struct acpi_driver {
char class[80];
int references;
char *ids; /* Supported Hardware IDs */
struct acpi_driver_ops ops;
struct acpi_device_ops ops;
};
enum acpi_blacklist_predicates
......@@ -157,14 +159,18 @@ struct acpi_device_status {
/* Flags */
struct acpi_device_flags {
u8 dynamic_status:1;
u8 compatible_ids:1;
u8 removable:1;
u8 ejectable:1;
u8 lockable:1;
u8 suprise_removal_ok:1;
u8 power_manageable:1;
u8 performance_manageable:1;
u32 dynamic_status:1;
u32 hardware_id:1;
u32 compatible_ids:1;
u32 bus_address:1;
u32 unique_id:1;
u32 removable:1;
u32 ejectable:1;
u32 lockable:1;
u32 suprise_removal_ok:1;
u32 power_manageable:1;
u32 performance_manageable:1;
u32 reserved:21;
};
......@@ -206,13 +212,13 @@ struct acpi_device_pnp {
/* Power Management */
struct acpi_device_power_flags {
u8 explicit_get:1; /* _PSC present? */
u8 power_resources:1; /* Power resources */
u8 inrush_current:1; /* Serialize Dx->D0 */
u8 wake_capable:1; /* Wakeup supported? */
u8 wake_enabled:1; /* Enabled for wakeup */
u8 power_removed:1; /* Optimize Dx->D0 */
u8 reserved:2;
u32 explicit_get:1; /* _PSC present? */
u32 power_resources:1; /* Power resources */
u32 inrush_current:1; /* Serialize Dx->D0 */
u32 wake_capable:1; /* Wakeup supported? */
u32 wake_enabled:1; /* Enabled for wakeup */
u32 power_removed:1; /* Optimize Dx->D0 */
u32 reserved:26;
};
struct acpi_device_power_state {
......@@ -270,6 +276,7 @@ struct acpi_device {
struct acpi_device_power power;
struct acpi_device_perf performance;
struct acpi_device_dir dir;
struct acpi_device_ops ops;
struct acpi_driver *driver;
void *driver_data;
#ifdef CONFIG_LDM
......
/*
* acpi_button.c - ACPI Button Driver ($Revision: 22 $)
* acpi_button.c - ACPI Button Driver ($Revision: 24 $)
*
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
......@@ -69,7 +69,7 @@ struct acpi_button {
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
struct proc_dir_entry *acpi_button_dir = NULL;
static struct proc_dir_entry *acpi_button_dir = NULL;
static int
......@@ -81,7 +81,6 @@ acpi_button_read_info (
int *eof,
void *data)
{
int result = 0;
struct acpi_button *button = (struct acpi_button *) data;
char *p = page;
int len = 0;
......@@ -111,22 +110,42 @@ acpi_button_add_fs (
struct acpi_device *device)
{
struct proc_dir_entry *entry = NULL;
struct acpi_button *button = NULL;
ACPI_FUNCTION_TRACE("acpi_button_add_fs");
if (!device || !acpi_driver_data(device))
return_VALUE(-EINVAL);
button = acpi_driver_data(device);
if (!acpi_button_dir) {
acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
if (!acpi_button_dir)
return_VALUE(-ENODEV);
}
if (!acpi_device_dir(device)) {
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
switch (button->type) {
case ACPI_BUTTON_TYPE_POWER:
case ACPI_BUTTON_TYPE_POWERF:
entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER,
acpi_button_dir);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
break;
case ACPI_BUTTON_TYPE_SLEEP:
case ACPI_BUTTON_TYPE_SLEEPF:
entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
acpi_button_dir);
break;
case ACPI_BUTTON_TYPE_LID:
entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
acpi_button_dir);
break;
}
acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
if (!acpi_device_dir(device))
return_VALUE(-ENODEV);
/* 'info' [R] */
entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
S_IRUGO, acpi_device_dir(device));
......@@ -227,37 +246,46 @@ acpi_button_add (
button->device = device;
button->handle = device->handle;
sprintf(acpi_device_class(device), "%s", ACPI_BUTTON_CLASS);
acpi_driver_data(device) = button;
/*
* Determine the button type (via hid), as fixed-feature buttons
* need to be handled a bit differently than generic-space.
*/
if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) {
button->type = ACPI_BUTTON_TYPE_POWERF;
sprintf(acpi_device_name(device), "%s",
ACPI_BUTTON_DEVICE_NAME_POWERF);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) {
button->type = ACPI_BUTTON_TYPE_SLEEPF;
sprintf(acpi_device_name(device), "%s",
ACPI_BUTTON_DEVICE_NAME_SLEEPF);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) {
if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) {
button->type = ACPI_BUTTON_TYPE_POWER;
sprintf(acpi_device_name(device), "%s",
ACPI_BUTTON_DEVICE_NAME_POWER);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) {
button->type = ACPI_BUTTON_TYPE_POWERF;
sprintf(acpi_device_name(device), "%s",
ACPI_BUTTON_DEVICE_NAME_POWERF);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) {
button->type = ACPI_BUTTON_TYPE_SLEEP;
sprintf(acpi_device_name(device), "%s",
ACPI_BUTTON_DEVICE_NAME_SLEEP);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) {
button->type = ACPI_BUTTON_TYPE_SLEEPF;
sprintf(acpi_device_name(device), "%s",
ACPI_BUTTON_DEVICE_NAME_SLEEPF);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
}
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) {
button->type = ACPI_BUTTON_TYPE_LID;
sprintf(acpi_device_name(device), "%s",
ACPI_BUTTON_DEVICE_NAME_LID);
sprintf(acpi_device_class(device), "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
}
else {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n",
......
/*
* acpi_drivers.h ($Revision: 17 $)
* acpi_drivers.h ($Revision: 23 $)
*
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
......@@ -30,7 +30,7 @@
#include "acpi_bus.h"
#define ACPI_DRIVER_VERSION 0x20020308
#define ACPI_DRIVER_VERSION 0x20020404
#define ACPI_MAX_STRING 80
......@@ -84,26 +84,32 @@
-------------------------------------------------------------------------- */
#define ACPI_BUTTON_COMPONENT 0x00080000
#define ACPI_BUTTON_CLASS "button"
#define ACPI_BUTTON_HID_LID "PNP0C0D"
#define ACPI_BUTTON_HID_POWER "PNP0C0C"
#define ACPI_BUTTON_HID_POWERF "ACPI_FPB"
#define ACPI_BUTTON_HID_SLEEP "PNP0C0E"
#define ACPI_BUTTON_HID_SLEEPF "ACPI_FSB"
#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver"
#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button"
#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button"
#define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button"
#define ACPI_BUTTON_DEVICE_NAME_SLEEPF "Sleep Button"
#define ACPI_BUTTON_DEVICE_NAME_LID "Lid Switch"
#define ACPI_BUTTON_CLASS "button"
#define ACPI_BUTTON_FILE_INFO "info"
#define ACPI_BUTTON_TYPE_UNKNOWN 0x00
#define ACPI_BUTTON_NOTIFY_STATUS 0x80
#define ACPI_BUTTON_SUBCLASS_POWER "power"
#define ACPI_BUTTON_HID_POWER "PNP0C0C"
#define ACPI_BUTTON_HID_POWERF "ACPI_FPB"
#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)"
#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)"
#define ACPI_BUTTON_TYPE_POWER 0x01
#define ACPI_BUTTON_TYPE_POWERF 0x02
#define ACPI_BUTTON_SUBCLASS_SLEEP "sleep"
#define ACPI_BUTTON_HID_SLEEP "PNP0C0E"
#define ACPI_BUTTON_HID_SLEEPF "ACPI_FSB"
#define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button (CM)"
#define ACPI_BUTTON_DEVICE_NAME_SLEEPF "Sleep Button (FF)"
#define ACPI_BUTTON_TYPE_SLEEP 0x03
#define ACPI_BUTTON_TYPE_SLEEPF 0x04
#define ACPI_BUTTON_SUBCLASS_LID "lid"
#define ACPI_BUTTON_HID_LID "PNP0C0D"
#define ACPI_BUTTON_DEVICE_NAME_LID "Lid Switch"
#define ACPI_BUTTON_TYPE_LID 0x05
#define ACPI_BUTTON_NOTIFY_STATUS 0x80
/* --------------------------------------------------------------------------
......@@ -217,7 +223,7 @@ void acpi_power_exit (void);
#define ACPI_PROCESSOR_LIMIT_INCREMENT 0x01
#define ACPI_PROCESSOR_LIMIT_DECREMENT 0x02
int acpi_processor_set_limit(acpi_handle handle, int flags, int *state);
int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
/* --------------------------------------------------------------------------
......
/*
* acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 27 $)
* acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 28 $)
*
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
......@@ -345,7 +345,7 @@ acpi_ec_gpe_handler (
if (0 != acpi_ec_query(ec, &value))
return;
query_data = kmalloc(sizeof(struct acpi_ec_query_data), GFP_KERNEL);
query_data = kmalloc(sizeof(struct acpi_ec_query_data), GFP_ATOMIC);
if (!query_data)
return;
query_data->handle = ec->handle;
......
/*
* acpi_osl.c - OS-dependent functions ($Revision: 65 $)
* acpi_osl.c - OS-dependent functions ($Revision: 69 $)
*
* Copyright (C) 2000 Andrew Henroid
* Copyright (C) 2001 Andrew Grover
......@@ -125,13 +125,13 @@ acpi_os_vprintf(const NATIVE_CHAR *fmt, va_list args)
}
void *
acpi_os_allocate(u32 size)
acpi_os_allocate(ACPI_SIZE size)
{
return kmalloc(size, GFP_KERNEL);
}
void *
acpi_os_callocate(u32 size)
acpi_os_callocate(ACPI_SIZE size)
{
void *ptr = acpi_os_allocate(size);
if (ptr)
......@@ -148,21 +148,22 @@ acpi_os_free(void *ptr)
acpi_status
acpi_os_get_root_pointer(u32 flags, ACPI_PHYSICAL_ADDRESS *phys_addr)
acpi_os_get_root_pointer(u32 flags, ACPI_POINTER *addr)
{
#ifndef CONFIG_ACPI_EFI
if (ACPI_FAILURE(acpi_find_root_pointer(flags, phys_addr))) {
if (ACPI_FAILURE(acpi_find_root_pointer(flags, addr))) {
printk(KERN_ERR PREFIX "System description tables not found\n");
return AE_NOT_FOUND;
}
#else /*CONFIG_ACPI_EFI*/
addr->pointer_type = ACPI_PHYSICAL_POINTER;
if (efi.acpi20)
*phys_addr = (ACPI_PHYSICAL_ADDRESS) efi.acpi20;
addr->pointer.physical = (ACPI_PHYSICAL_ADDRESS) efi.acpi20;
else if (efi.acpi)
*phys_addr = (ACPI_PHYSICAL_ADDRESS) efi.acpi;
addr->pointer.physical = (ACPI_PHYSICAL_ADDRESS) efi.acpi;
else {
printk(KERN_ERR PREFIX "System description tables not found\n");
*phys_addr = 0;
addr->pointer.physical = 0;
return AE_NOT_FOUND;
}
#endif /*CONFIG_ACPI_EFI*/
......@@ -171,7 +172,7 @@ acpi_os_get_root_pointer(u32 flags, ACPI_PHYSICAL_ADDRESS *phys_addr)
}
acpi_status
acpi_os_map_memory(ACPI_PHYSICAL_ADDRESS phys, u32 size, void **virt)
acpi_os_map_memory(ACPI_PHYSICAL_ADDRESS phys, ACPI_SIZE size, void **virt)
{
if (phys > ULONG_MAX) {
printk(KERN_ERR PREFIX "Cannot map memory that high\n");
......@@ -189,7 +190,7 @@ acpi_os_map_memory(ACPI_PHYSICAL_ADDRESS phys, u32 size, void **virt)
}
void
acpi_os_unmap_memory(void *virt, u32 size)
acpi_os_unmap_memory(void *virt, ACPI_SIZE size)
{
iounmap(virt);
}
......@@ -441,14 +442,14 @@ acpi_os_load_module (
ACPI_FUNCTION_TRACE ("os_load_module");
if (!module_name)
return AE_BAD_PARAMETER;
return_ACPI_STATUS (AE_BAD_PARAMETER);
if (0 > request_module(module_name)) {
ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Unable to load module [%s].\n", module_name));
return AE_ERROR;
return_ACPI_STATUS (AE_ERROR);
}
return AE_OK;
return_ACPI_STATUS (AE_OK);
}
acpi_status
......@@ -481,7 +482,7 @@ acpi_os_queue_exec (
strcpy(current->comm, "kacpidpc");
if (!dpc || !dpc->function)
return AE_BAD_PARAMETER;
return_ACPI_STATUS (AE_BAD_PARAMETER);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Executing function [%p(%p)].\n", dpc->function, dpc->context));
......@@ -489,7 +490,7 @@ acpi_os_queue_exec (
kfree(dpc);
return 1;
return_ACPI_STATUS (AE_OK);
}
static void
......@@ -504,7 +505,7 @@ acpi_os_schedule_exec (
dpc = (ACPI_OS_DPC*)context;
if (!dpc) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid (NULL) context.\n"));
return;
return_VOID;
}
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Creating new thread to run function [%p(%p)].\n", dpc->function, dpc->context));
......@@ -515,6 +516,7 @@ acpi_os_schedule_exec (
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Call to kernel_thread() failed.\n"));
acpi_os_free(dpc);
}
return_VOID;
}
acpi_status
......@@ -531,7 +533,7 @@ acpi_os_queue_for_execution(
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Scheduling function [%p(%p)] for deferred execution.\n", function, context));
if (!function)
return AE_BAD_PARAMETER;
return_ACPI_STATUS (AE_BAD_PARAMETER);
/*
* Queue via DPC:
......@@ -554,7 +556,7 @@ acpi_os_queue_for_execution(
*/
dpc = kmalloc(sizeof(ACPI_OS_DPC), GFP_ATOMIC);
if (!dpc)
return AE_NO_MEMORY;
return_ACPI_STATUS (AE_NO_MEMORY);
dpc->function = function;
dpc->context = context;
......@@ -578,7 +580,7 @@ acpi_os_queue_for_execution(
*/
dpc = kmalloc(sizeof(ACPI_OS_DPC), GFP_KERNEL);
if (!dpc)
return AE_NO_MEMORY;
return_ACPI_STATUS (AE_NO_MEMORY);
dpc->function = function;
dpc->context = context;
......@@ -587,7 +589,7 @@ acpi_os_queue_for_execution(
break;
}
return status;
return_ACPI_STATUS (status);
}
......@@ -603,7 +605,7 @@ acpi_os_create_semaphore(
sem = acpi_os_callocate(sizeof(struct semaphore));
if (!sem)
return AE_NO_MEMORY;
return_ACPI_STATUS (AE_NO_MEMORY);
sema_init(sem, initial_units);
......@@ -611,7 +613,7 @@ acpi_os_create_semaphore(
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Creating semaphore[%p|%d].\n", *handle, initial_units));
return AE_OK;
return_ACPI_STATUS (AE_OK);
}
......@@ -631,13 +633,13 @@ acpi_os_delete_semaphore(
ACPI_FUNCTION_TRACE ("os_delete_semaphore");
if (!sem)
return AE_BAD_PARAMETER;
return_ACPI_STATUS (AE_BAD_PARAMETER);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting semaphore[%p].\n", handle));
acpi_os_free(sem); sem = NULL;
return AE_OK;
return_ACPI_STATUS (AE_OK);
}
......@@ -663,10 +665,10 @@ acpi_os_wait_semaphore(
ACPI_FUNCTION_TRACE ("os_wait_semaphore");
if (!sem || (units < 1))
return AE_BAD_PARAMETER;
return_ACPI_STATUS (AE_BAD_PARAMETER);
if (units > 1)
return AE_SUPPORT;
return_ACPI_STATUS (AE_SUPPORT);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Waiting for semaphore[%p|%d|%d]\n", handle, units, timeout));
......@@ -724,7 +726,7 @@ acpi_os_wait_semaphore(
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Acquired semaphore[%p|%d|%d]\n", handle, units, timeout));
}
return status;
return_ACPI_STATUS (status);
}
......@@ -741,16 +743,16 @@ acpi_os_signal_semaphore(
ACPI_FUNCTION_TRACE ("os_signal_semaphore");
if (!sem || (units < 1))
return AE_BAD_PARAMETER;
return_ACPI_STATUS (AE_BAD_PARAMETER);
if (units > 1)
return AE_SUPPORT;
return_ACPI_STATUS (AE_SUPPORT);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Signaling semaphore[%p|%d]\n", handle, units));
up(sem);
return AE_OK;
return_ACPI_STATUS (AE_OK);
}
u32
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* acpi_system.c - ACPI System Driver ($Revision: 40 $)
* acpi_system.c - ACPI System Driver ($Revision: 45 $)
*
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
......@@ -31,6 +31,7 @@
#include <linux/spinlock.h>
#include <linux/poll.h>
#include <linux/delay.h>
#include <linux/sysrq.h>
#include <linux/pm.h>
#include <asm/uaccess.h>
#include <asm/acpi.h>
......@@ -86,9 +87,8 @@ static void
acpi_power_off (void)
{
acpi_enter_sleep_state_prep(ACPI_STATE_S5);
acpi_disable_irqs();
ACPI_DISABLE_IRQS();
acpi_enter_sleep_state(ACPI_STATE_S5);
acpi_disable_irqs();
}
#endif /*CONFIG_PM*/
......@@ -123,7 +123,7 @@ acpi_system_restore_state (
device_resume(RESUME_POWER_ON);
/* enable interrupts once again */
acpi_enable_irqs();
ACPI_ENABLE_IRQS();
/* restore device context */
device_resume(RESUME_RESTORE_STATE);
......@@ -200,7 +200,7 @@ acpi_system_save_state(
* But, we want it done early, so we don't get any suprises during
* the device suspend sequence.
*/
acpi_disable_irqs();
ACPI_DISABLE_IRQS();
/* Unconditionally turn off devices.
* Obvious if we enter a sleep state.
......@@ -304,7 +304,7 @@ acpi_suspend (
return status;
/* disable interrupts and flush caches */
acpi_disable_irqs();
ACPI_DISABLE_IRQS();
wbinvd();
/* perform OS-specific sleep actions */
......@@ -318,7 +318,7 @@ acpi_suspend (
acpi_leave_sleep_state(state);
/* make sure interrupts are enabled */
acpi_enable_irqs();
ACPI_ENABLE_IRQS();
/* reset firmware waking vector */
acpi_set_firmware_waking_vector((ACPI_PHYSICAL_ADDRESS) 0);
......@@ -570,7 +570,6 @@ acpi_system_read_debug (
{
char *p = page;
int size = 0;
u32 var;
if (off != 0)
goto end;
......@@ -607,7 +606,6 @@ acpi_system_write_debug (
void *data)
{
char debug_string[12] = {'\0'};
u32 *pvar;
ACPI_FUNCTION_TRACE("acpi_system_write_debug");
......@@ -1126,6 +1124,23 @@ acpi_system_remove_fs (
Driver Interface
-------------------------------------------------------------------------- */
#if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_PM)
/* Simple wrapper calling power down function. */
static void acpi_sysrq_power_off(int key, struct pt_regs *pt_regs,
struct kbd_struct *kbd, struct tty_struct *tty)
{
acpi_power_off();
}
struct sysrq_key_op sysrq_acpi_poweroff_op = {
handler: &acpi_sysrq_power_off,
help_msg: "Off",
action_msg: "Power Off\n"
};
#endif /* CONFIG_MAGIC_SYSRQ */
static int
acpi_system_add (
struct acpi_device *device)
......@@ -1168,8 +1183,10 @@ acpi_system_add (
#ifdef CONFIG_PM
/* Install the soft-off (S5) handler. */
if (system->states[ACPI_STATE_S5])
if (system->states[ACPI_STATE_S5]) {
pm_power_off = acpi_power_off;
register_sysrq_key('o', &sysrq_acpi_poweroff_op);
}
#endif
end:
......@@ -1196,8 +1213,10 @@ acpi_system_remove (
#ifdef CONFIG_PM
/* Remove the soft-off (S5) handler. */
if (system->states[ACPI_STATE_S5])
if (system->states[ACPI_STATE_S5]) {
unregister_sysrq_key('o', &sysrq_acpi_poweroff_op);
pm_power_off = NULL;
}
#endif
acpi_system_remove_fs(device);
......
/*
* acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 33 $)
* acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 36 $)
*
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
......@@ -78,7 +78,6 @@ struct acpi_thermal_state {
u8 passive:1;
u8 active:1;
u8 reserved:4;
int passive_index; /* a.k.a. limit state */
int active_index;
};
......@@ -467,15 +466,23 @@ acpi_thermal_passive (
*/
if (tz->temperature >= passive->temperature) {
trend = (passive->tc1 * (tz->temperature - tz->last_temperature)) + (passive->tc2 * (tz->temperature - passive->temperature));
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n", trend, passive->tc1, tz->temperature, tz->last_temperature, passive->tc2, tz->temperature, passive->temperature));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n",
trend, passive->tc1, tz->temperature,
tz->last_temperature, passive->tc2,
tz->temperature, passive->temperature));
/* Heating up? */
if (trend > 0)
for (i=0; i<passive->devices.count; i++)
acpi_processor_set_limit(passive->devices.handles[i], ACPI_PROCESSOR_LIMIT_INCREMENT, &tz->state.passive_index);
acpi_processor_set_thermal_limit(
passive->devices.handles[i],
ACPI_PROCESSOR_LIMIT_INCREMENT);
/* Cooling off? */
else if (trend < 0)
for (i=0; i<passive->devices.count; i++)
acpi_processor_set_limit(passive->devices.handles[i], ACPI_PROCESSOR_LIMIT_DECREMENT, &tz->state.passive_index);
acpi_processor_set_thermal_limit(
passive->devices.handles[i],
ACPI_PROCESSOR_LIMIT_DECREMENT);
}
/*
......@@ -487,10 +494,13 @@ acpi_thermal_passive (
*/
else if (tz->trips.passive.flags.enabled) {
for (i=0; i<passive->devices.count; i++)
acpi_processor_set_limit(passive->devices.handles[i], ACPI_PROCESSOR_LIMIT_DECREMENT, &tz->state.passive_index);
if (0 == tz->state.passive_index) {
result = acpi_processor_set_thermal_limit(
passive->devices.handles[i],
ACPI_PROCESSOR_LIMIT_DECREMENT);
if (1 == result) {
tz->trips.passive.flags.enabled = 0;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabling passive cooling (zone is cool)\n"));
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Disabling passive cooling (zone is cool)\n"));
}
}
......@@ -671,7 +681,7 @@ acpi_thermal_check (
if (timer_pending(&(tz->timer)))
mod_timer(&(tz->timer), (HZ * sleep_time) / 1000);
else {
tz->timer.data = (u32) tz;
tz->timer.data = (unsigned long) tz;
tz->timer.function = acpi_thermal_run;
tz->timer.expires = jiffies + (HZ * sleep_time) / 1000;
add_timer(&(tz->timer));
......@@ -720,7 +730,7 @@ acpi_thermal_read_state (
if (tz->state.hot)
p += sprintf(p, "hot ");
if (tz->state.passive)
p += sprintf(p, "passive[%d] ", tz->state.passive_index);
p += sprintf(p, "passive ");
if (tz->state.active)
p += sprintf(p, "active[%d]", tz->state.active_index);
p += sprintf(p, "\n");
......@@ -810,9 +820,10 @@ acpi_thermal_read_trip_points (
tz->trips.passive.tc1,
tz->trips.passive.tc2,
tz->trips.passive.tsp);
for (j=0; j<tz->trips.passive.devices.count; j++)
p += sprintf(p, "0x%p ",
tz->trips.passive.devices.handles[j]);
for (j=0; j<tz->trips.passive.devices.count; j++) {
p += sprintf(p, "0x%p ", tz->trips.passive.devices.handles[j]);
}
p += sprintf(p, "\n");
}
......
/******************************************************************************
*
* Name: acenv.h - Generation environment specific items
* $Revision: 85 $
* $Revision: 86 $
*
*****************************************************************************/
......@@ -284,11 +284,9 @@ typedef char *va_list;
#define ACPI_INTERNAL_VAR_XFACE
#define ACPI_ASM_MACROS
#define causeinterrupt(level)
#define BREAKPOINT3
#define acpi_disable_irqs()
#define acpi_enable_irqs()
#define halt()
#define ACPI_DISABLE_IRQS()
#define ACPI_ENABLE_IRQS()
#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq)
#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq)
......@@ -299,9 +297,7 @@ typedef char *va_list;
/* Don't want software interrupts within a ring3 application */
#undef causeinterrupt
#undef BREAKPOINT3
#define causeinterrupt(level)
#define BREAKPOINT3
#endif
......
/******************************************************************************
*
* Name: acgcc.h - GCC specific defines, etc.
* $Revision: 19 $
* $Revision: 22 $
*
*****************************************************************************/
......@@ -30,7 +30,8 @@
#ifdef __ia64__
#define _IA64
#define COMPILER_DEPENDENT_UINT64 unsigned long
#define COMPILER_DEPENDENT_INT64 long
#define COMPILER_DEPENDENT_UINT64 unsigned long
/*
* Calling conventions:
......@@ -52,10 +53,9 @@
/* Asm macros */
#define ACPI_ASM_MACROS
#define causeinterrupt(level)
#define BREAKPOINT3
#define acpi_disable_irqs() __cli()
#define acpi_enable_irqs() __sti()
#define ACPI_DISABLE_IRQS() __cli()
#define ACPI_ENABLE_IRQS() __sti()
/*! [Begin] no source code translation */
......@@ -111,7 +111,8 @@
#else /* DO IA32 */
#define COMPILER_DEPENDENT_UINT64 unsigned long long
#define COMPILER_DEPENDENT_INT64 long long
#define COMPILER_DEPENDENT_UINT64 unsigned long long
/*
* Calling conventions:
......@@ -129,11 +130,9 @@
/* Asm macros */
#define ACPI_ASM_MACROS
#define causeinterrupt(level)
#define BREAKPOINT3
#define acpi_disable_irqs() __cli()
#define acpi_enable_irqs() __sti()
#define halt() __asm__ __volatile__ ("sti; hlt":::"memory")
#define ACPI_DISABLE_IRQS() __cli()
#define ACPI_ENABLE_IRQS() __sti()
/*! [Begin] no source code translation
*
......
/******************************************************************************
*
* Name: aclinux.h - OS specific defines, etc.
* $Revision: 15 $
* $Revision: 19 $
*
*****************************************************************************/
......@@ -42,14 +42,20 @@
#define strtoul simple_strtoul
#ifdef _IA64
#define ACPI_FLUSH_CPU_CACHE()
#else
#define ACPI_FLUSH_CPU_CACHE() wbinvd()
#endif
#else /* !__KERNEL__ */
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#endif
#endif /* __KERNEL__ */
/* Linux uses GCC */
......
......@@ -33,9 +33,12 @@
/* Fixmap pages to reserve for ACPI boot-time tables (see fixmap.h) */
#define FIX_ACPI_PAGES 4
extern int acpi_mp_config;
char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
extern int acpi_find_rsdp (unsigned long *phys_addr);
extern int acpi_parse_madt (unsigned long phys_addr, unsigned long size);
extern int acpi_boot_init (char *cmdline);
#endif /*CONFIG_ACPI_BOOT*/
......
......@@ -29,6 +29,12 @@
#define _LINUX
#endif
/*
* YES this is ugly.
* But, moving all of ACPI's private headers to include/acpi isn't the right
* answer either.
* Please just ignore it for now.
*/
#include "../../drivers/acpi/include/acpi.h"
#include <asm/acpi.h>
......@@ -270,7 +276,7 @@ struct acpi_table_slit {
struct acpi_table_header header;
u64 localities;
u8 entry[1]; /* real size = localities^2 */
};
} __attribute__ ((packed));
/* Smart Battery Description Table (SBST) */
......@@ -283,7 +289,6 @@ struct acpi_table_sbst {
/* Embedded Controller Boot Resources Table (ECDT) */
/* TBD: acpi_generic_address
struct acpi_table_ecdt {
struct acpi_table_header header;
acpi_generic_address ec_control;
......@@ -292,7 +297,6 @@ struct acpi_table_ecdt {
u8 gpe_bit;
char *ec_id;
} __attribute__ ((packed));
*/
/* Table Handlers */
......@@ -343,9 +347,9 @@ void acpi_table_print_madt_entry (acpi_table_entry_header *);
#ifdef CONFIG_ACPI_PCI
#define ACPI_PCI_ROUTING_PIC 0
#define ACPI_PCI_ROUTING_IOAPIC 1
#define ACPI_PCI_ROUTING_IOSAPIC 2
#define ACPI_INT_MODEL_PIC 0
#define ACPI_INT_MODEL_IOAPIC 1
#define ACPI_INT_MODEL_IOSAPIC 2
struct acpi_prt_entry {
struct list_head node;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment