Ticket #4152: acpi_dpc_loading.patch

File acpi_dpc_loading.patch, 2.3 KB (added by tqh, 15 years ago)

move dpc loading earlier

  • acpi_module.c

     
    1313#include <dpc.h>
    1414#include <PCI.h>
    1515
    16 dpc_module_info* gDPC = NULL;
    17 void* gDPCHandle = NULL;
    18 
    1916//#define TRACE_ACPI_MODULE
    2017#ifdef TRACE_ACPI_MODULE
    2118#   define TRACE(x) dprintf x
     
    2320#   define TRACE(x) ;
    2421#endif
    2522
     23dpc_module_info* gDPC = NULL;
     24void* gDPCHandle = NULL;
     25
    2626device_manager_info *gDeviceManager = NULL;
    2727pci_module_info *gPCIManager = NULL;
    2828
    2929module_dependency module_dependencies[] = {
    3030    {B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&gDeviceManager},
    3131    {B_PCI_MODULE_NAME, (module_info **)&gPCIManager},
     32    {B_DPC_MODULE_NAME, (module_info **)&gDPC},
    3233    {}
    3334};
    3435
     
    172173static status_t
    173174acpi_module_init(device_node *node, void **_cookie)
    174175{
    175     if (get_module(B_DPC_MODULE_NAME, (module_info **)&gDPC) != B_OK) {
    176         dprintf("failed to get dpc module\n");
    177         return B_ERROR;
    178     }
    179     if (gDPC->new_dpc_queue(&gDPCHandle, "acpi_task",
    180         B_NORMAL_PRIORITY) != B_OK) {
    181         dprintf("failed to create os execution queue\n");
    182         return B_ERROR;
    183     }
    184            
    185176    *_cookie = node;
    186177    return B_OK;
    187178}
     
    190181static void
    191182acpi_module_uninit(void *cookie)
    192183{
    193     gDPC->delete_dpc_queue(gDPCHandle);
    194     gDPCHandle = NULL;
    195     put_module(B_DPC_MODULE_NAME);
    196     gDPC = NULL;
    197184}
    198185
    199186
     
    204191        case B_MODULE_INIT:
    205192        {
    206193            module_info *module;
     194
     195            if (get_module(B_DPC_MODULE_NAME, (module_info **)&gDPC) != B_OK) {
     196                dprintf("failed to get dpc module\n");
     197                return B_ERROR;
     198            }
     199            if (gDPC->new_dpc_queue(&gDPCHandle, "acpi_task",
     200                B_NORMAL_PRIORITY) != B_OK) {
     201                dprintf("failed to create os execution queue\n");
     202                return B_ERROR;
     203            }
     204
    207205            return get_module(B_ACPI_MODULE_NAME, &module);
    208206                // this serializes our module initialization
    209207        }
    210208
    211209        case B_MODULE_UNINIT:
    212             return put_module(B_ACPI_MODULE_NAME);
     210        {
     211            status_t result = put_module(B_ACPI_MODULE_NAME);
     212            gDPC->delete_dpc_queue(gDPCHandle);
     213            gDPCHandle = NULL;
     214            put_module(B_DPC_MODULE_NAME);
     215            gDPC = NULL;
     216            return result;
     217        }
    213218    }
    214219
    215220    return B_BAD_VALUE;
     
    260265    evaluate_method,
    261266};
    262267
    263 _EXPORT module_info *modules[] = {
     268module_info *modules[] = {
    264269    (module_info *)&gACPIModule,
    265270    (module_info *)&sACPIRootModule,
    266271    (module_info *)&acpi_ns_dump_module,