* Fixed module leak in case there was an error during init when used on BeOS.
* Check safemode settings only when it's not already disabled (doesn't make sense to check those then). * Minor cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22408 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -62,26 +62,29 @@ struct acpi_module_info acpi_module = {
|
|||||||
status_t
|
status_t
|
||||||
acpi_std_ops(int32 op,...)
|
acpi_std_ops(int32 op,...)
|
||||||
{
|
{
|
||||||
ACPI_STATUS Status;
|
switch (op) {
|
||||||
|
case B_MODULE_INIT:
|
||||||
|
{
|
||||||
|
ACPI_STATUS status;
|
||||||
bool acpiDisabled = false;
|
bool acpiDisabled = false;
|
||||||
void *settings;
|
void *settings;
|
||||||
|
|
||||||
switch(op) {
|
|
||||||
case B_MODULE_INIT:
|
|
||||||
// check if safemode settings disable DMA
|
|
||||||
|
|
||||||
settings = load_driver_settings("kernel");
|
settings = load_driver_settings("kernel");
|
||||||
if (settings != NULL) {
|
if (settings != NULL) {
|
||||||
acpiDisabled = !get_driver_boolean_parameter(settings, "acpi", true, true);
|
acpiDisabled = !get_driver_boolean_parameter(settings, "acpi",
|
||||||
|
true, true);
|
||||||
unload_driver_settings(settings);
|
unload_driver_settings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acpiDisabled) {
|
||||||
|
// check if safemode settings disable DMA
|
||||||
settings = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS);
|
settings = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS);
|
||||||
if (settings != NULL) {
|
if (settings != NULL) {
|
||||||
acpiDisabled = get_driver_boolean_parameter(settings, B_SAFEMODE_DISABLE_ACPI,
|
acpiDisabled = get_driver_boolean_parameter(settings,
|
||||||
acpiDisabled, acpiDisabled);
|
B_SAFEMODE_DISABLE_ACPI, false, false);
|
||||||
unload_driver_settings(settings);
|
unload_driver_settings(settings);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (acpiDisabled) {
|
if (acpiDisabled) {
|
||||||
ERROR("ACPI disabled");
|
ERROR("ACPI disabled");
|
||||||
@@ -95,10 +98,15 @@ acpi_std_ops(int32 op,...)
|
|||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
status = get_module(B_DPC_MODULE_NAME, (module_info **)&gDPC);
|
status = get_module(B_DPC_MODULE_NAME, (module_info **)&gDPC);
|
||||||
if (status != B_OK) return status;
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
status = get_module(B_PCI_MODULE_NAME, (module_info **) &gPCIManager);
|
status = get_module(B_PCI_MODULE_NAME,
|
||||||
if (status != B_OK) return status;
|
(module_info **)&gPCIManager);
|
||||||
|
if (status != B_OK) {
|
||||||
|
put_module(B_DPC_MODULE_NAME);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -109,37 +117,49 @@ acpi_std_ops(int32 op,...)
|
|||||||
AcpiDbgLayer = ACPI_ALL_COMPONENTS;
|
AcpiDbgLayer = ACPI_ALL_COMPONENTS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Status = AcpiInitializeSubsystem();
|
status = AcpiInitializeSubsystem();
|
||||||
if (Status != AE_OK) {
|
if (status != AE_OK) {
|
||||||
ERROR("AcpiInitializeSubsystem failed (%s)\n", AcpiFormatException(Status));
|
ERROR("AcpiInitializeSubsystem failed (%s)\n",
|
||||||
return B_ERROR;
|
AcpiFormatException(status));
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = AcpiInitializeTables(NULL, 0, TRUE);
|
status = AcpiInitializeTables(NULL, 0, TRUE);
|
||||||
if (Status != AE_OK) {
|
if (status != AE_OK) {
|
||||||
ERROR("AcpiInitializeTables failed (%s)\n", AcpiFormatException(Status));
|
ERROR("AcpiInitializeTables failed (%s)\n",
|
||||||
return B_ERROR;
|
AcpiFormatException(status));
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = AcpiLoadTables();
|
status = AcpiLoadTables();
|
||||||
if (Status != AE_OK) {
|
if (status != AE_OK) {
|
||||||
ERROR("AcpiLoadTables failed (%s)\n", AcpiFormatException(Status));
|
ERROR("AcpiLoadTables failed (%s)\n",
|
||||||
return B_ERROR;
|
AcpiFormatException(status));
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION);
|
status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION);
|
||||||
if (Status != AE_OK) {
|
if (status != AE_OK) {
|
||||||
ERROR("AcpiEnableSubsystem failed (%s)\n", AcpiFormatException(Status));
|
ERROR("AcpiEnableSubsystem failed (%s)\n",
|
||||||
return B_ERROR;
|
AcpiFormatException(status));
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Phew. Now in ACPI mode */
|
/* Phew. Now in ACPI mode */
|
||||||
TRACE("ACPI initialized\n");
|
TRACE("ACPI initialized\n");
|
||||||
break;
|
return B_OK;
|
||||||
|
|
||||||
|
err:
|
||||||
|
#ifndef __HAIKU__
|
||||||
|
put_module(B_DPC_MODULE_NAME);
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
#endif
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
case B_MODULE_UNINIT:
|
case B_MODULE_UNINIT:
|
||||||
Status = AcpiTerminate();
|
{
|
||||||
if (Status != AE_OK)
|
if (AcpiTerminate() != AE_OK)
|
||||||
ERROR("Could not bring system out of ACPI mode. Oh well.\n");
|
ERROR("Could not bring system out of ACPI mode. Oh well.\n");
|
||||||
|
|
||||||
/* This isn't so terrible. We'll just fail silently */
|
/* This isn't so terrible. We'll just fail silently */
|
||||||
@@ -154,8 +174,9 @@ acpi_std_ops(int32 op,...)
|
|||||||
put_module(B_DPC_MODULE_NAME);
|
put_module(B_DPC_MODULE_NAME);
|
||||||
put_module(B_PCI_MODULE_NAME);
|
put_module(B_PCI_MODULE_NAME);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user