Ticket #6164: 0003-Fix-OpenPIC.patch

File 0003-Fix-OpenPIC.patch, 4.3 KB (added by andreasf, 10 years ago)

draft patch: clean up OpenPIC

  • src/add-ons/kernel/interrupt_controllers/openpic/openpic.cpp

    From d74a4855e6b0275f5f9ad96a4f76091cefc7fb79 Mon Sep 17 00:00:00 2001
    From: Andreas Faerber <andreas.faerber@web.de>
    Date: Sun, 13 Jun 2010 04:36:52 +0200
    Subject: [PATCH 3/3] Fix OpenPIC
    
    ---
     .../interrupt_controllers/openpic/openpic.cpp      |   89 +++++++------------
     1 files changed, 33 insertions(+), 56 deletions(-)
    
    diff --git a/src/add-ons/kernel/interrupt_controllers/openpic/openpic.cpp b/src/add-ons/kernel/interrupt_controllers/openpic/openpic.cpp
    index a25b3de..0450732 100644
    a b openpic_supports_device(device_node *parent)  
    312312static status_t
    313313openpic_register_device(device_node *parent)
    314314{
    315 #if 0 //XXX: what do I do ?
    316   // get interface to PCI device
    317   pci_device_module_info *pci;
    318   pci_device *device;
    319   driver_module_info *driver;
    320   void *cookie;
    321   status_t error;
    322   error = sDeviceManager->get_driver(parent, &driver, &cookie);
    323   if (error < B_OK)
    324     return error;
    325   error = driver->init_driver(parent, cookie);
    326   // (driver_module_info**)&pci, (void**)&device); // wtf?
    327   if (error != B_OK)
    328     return error;
    329 
    330   sDeviceManager->uninit_driver(parent);
    331 #endif
    332   device_node *newNode;
    333   device_attr attrs[] = {
    334     // info about ourself
    335     //{ B_DRIVER_MODULE, B_STRING_TYPE, { string: OPENPIC_MODULE_NAME }},
    336     //XXX: that's inconsistent with the header!
    337     //{ B_DEVICE_TYPE, B_STRING_TYPE,
    338     //  { string: B_INTERRUPT_CONTROLLER_DRIVER_TYPE }},
    339 
    340     {}
    341   };
    342 
    343   // HACK: to get it compiled, I will break anything.
    344   return sDeviceManager->register_node(parent, NULL, attrs, NULL, &newNode);
     315    device_node *newNode;
     316    device_attr attrs[] = {
     317        // info about ourself
     318        { B_DEVICE_TYPE, B_UINT16_TYPE, { ui16: PCI_base_peripheral }},
     319        { B_DEVICE_SUB_TYPE, B_UINT16_TYPE, { ui16: PCI_pic }},
     320        // TODO How do we identify ourselves as OpenPIC?
     321        { B_DEVICE_INTERFACE, B_UINT16_TYPE, { ui16: PCI_pic_8259 }},
     322        {}
     323    };
     324    io_resource resources[] = {
     325        // TODO Fill in whatever necessary
     326        {}
     327    };
     328
     329    return sDeviceManager->register_node(parent, OPENPIC_MODULE_NAME,
     330        attrs, resources, &newNode);
    345331}
    346332
    347333
    348334static status_t
    349335openpic_init_driver(device_node *node, void **cookie)
    350336{
    351     // OK, this module is broken for now. But it compiles.
    352     return B_ERROR;
    353337    openpic_info *info = new(nothrow) openpic_info;
    354338    if (!info)
    355339        return B_NO_MEMORY;
    openpic_init_driver(device_node *node, void **cookie)  
    359343
    360344    // get interface to PCI device
    361345    void *aCookie;
    362     void *anotherCookie; // possibly the same cookie.
    363     driver_module_info *driver;
    364346    status_t status = sDeviceManager->get_driver(sDeviceManager->get_parent_node(node),
    365                                                  &driver, &aCookie);
     347                                                 (driver_module_info**)&info->pci, &aCookie);
    366348    if (status != B_OK)
    367349        return status;
    368350
    369     driver->init_driver(node, &anotherCookie);
    370 
    371     /* status = sDeviceManager->init_driver(
    372         sDeviceManager->get_parent(node), NULL,
    373         (driver_module_info**)&info->pci, (void**)&info->device);
    374         if (status != B_OK)
    375         return status; */
     351    info->pci->info.init_driver(node, (void**)&info->device);
    376352
    377353    // get the pci info for the device
    378354    pci_info pciInfo;
    openpic_uninit_driver(void *cookie)  
    439415}
    440416
    441417
    442 static void
    443 openpic_device_removed(void *driverCookie)
     418static status_t
     419openpic_register_child_devices(void *cookie)
    444420{
    445     // TODO: ...
     421    return B_OK;
    446422}
    447423
    448424
    449 // FIXME: I don't think this is needed...
    450 /*static void
    451 openpic_get_paths(const char **_bus, const char **_device)
     425static status_t
     426openpic_rescan_child_devices(void *cookie)
    452427{
    453     static const char *kBus[] = { "pci", NULL };
    454 //  static const char *kDevice[] = { "drivers/dev/disk/ide", NULL };
     428    return B_OK;
     429}
     430
    455431
    456     *_bus = kBus;
    457 //  *_device = kDevice;
    458     *_device = NULL;
    459 }*/
     432static void
     433openpic_device_removed(void *driverCookie)
     434{
     435    // TODO: ...
     436}
    460437
    461438
    462439// #pragma mark - interrupt_controller interface
    static interrupt_controller_module_info sControllerModuleInfo = {  
    530507        openpic_register_device,
    531508        openpic_init_driver,
    532509        openpic_uninit_driver,
    533         NULL, // HACK: register_child_devices
    534         NULL, // HACK: rescan_child_devices
     510        openpic_register_child_devices,
     511        openpic_rescan_child_devices,
    535512        openpic_device_removed,
    536513        NULL,   // suspend
    537514        NULL // resume