Converted the ATA bus manager to the new driver architecture; did not test it

yet, though, as this machine takes a bit longer compiling...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25668 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-05-26 21:09:35 +00:00
parent 4584521e0b
commit ef850bad9b
4 changed files with 58 additions and 78 deletions
+8 -20
View File
@@ -4,8 +4,6 @@
*/ */
/* /*
Part of Open IDE bus manager
Manager of IDE controllers Manager of IDE controllers
Whenever a new IDE channel is reported, a new SIM is Whenever a new IDE channel is reported, a new SIM is
@@ -23,12 +21,11 @@
#define TRACE dprintf #define TRACE dprintf
/** called when an IDE channel was registered by a controller driver */ /*! Called when an IDE channel was registered by a controller driver */
static status_t static status_t
ide_channel_added(device_node_handle parent) ide_channel_added(device_node *parent)
{ {
char *controller_name = NULL; const char *controller_name = NULL;
uint32 channel_id; uint32 channel_id;
TRACE("ide_channel_added, parent is %p\n", parent); TRACE("ide_channel_added, parent is %p\n", parent);
@@ -49,8 +46,7 @@ ide_channel_added(device_node_handle parent)
{ {
device_attr attrs[] = device_attr attrs[] =
{ {
{ B_DRIVER_MODULE, B_STRING_TYPE, { string: IDE_SIM_MODULE_NAME }}, { B_DEVICE_FIXED_CHILD, B_STRING_TYPE, { string: SCSI_FOR_SIM_MODULE_NAME }},
{ B_DRIVER_FIXED_CHILD, B_STRING_TYPE, { string: SCSI_FOR_SIM_MODULE_NAME }},
{ SCSI_DESCRIPTION_CONTROLLER_NAME, B_STRING_TYPE, { SCSI_DESCRIPTION_CONTROLLER_NAME, B_STRING_TYPE,
{ string: controller_name }}, { string: controller_name }},
@@ -67,25 +63,17 @@ ide_channel_added(device_node_handle parent)
// in ide_sim.c! // in ide_sim.c!
{ B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: 255 }}, { B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: 255 }},
{ IDE_CHANNEL_ID_ITEM, B_UINT32_TYPE, { ui32: channel_id }}, { IDE_CHANNEL_ID_ITEM, B_UINT32_TYPE, { ui32: channel_id }},
{ PNP_MANAGER_ID_GENERATOR, B_STRING_TYPE, { string: IDE_CHANNEL_ID_GENERATOR }}, // { PNP_MANAGER_ID_GENERATOR, B_STRING_TYPE, { string: IDE_CHANNEL_ID_GENERATOR }},
{ PNP_MANAGER_AUTO_ID, B_UINT32_TYPE, { ui32: channel_id }}, // { PNP_MANAGER_AUTO_ID, B_UINT32_TYPE, { ui32: channel_id }},
{ NULL } { NULL }
}; };
device_node_handle node; return pnp->register_node(parent, IDE_SIM_MODULE_NAME, attrs, NULL,
status_t res; NULL);
res = pnp->register_device(parent, attrs, NULL, &node);
free(controller_name);
return res;
} }
err: err:
free(controller_name);
return B_NO_MEMORY; return B_NO_MEMORY;
} }
@@ -5,18 +5,13 @@
#ifndef __IDE_INTERNAL_H__ #ifndef __IDE_INTERNAL_H__
#define __IDE_INTERNAL_H__ #define __IDE_INTERNAL_H__
/*
Part of Open IDE bus manager
Internal structures
*/
#include <bus/IDE.h> #include <bus/IDE.h>
#include <bus/SCSI.h> #include <bus/SCSI.h>
#include "ide_device_infoblock.h"
#include <ide_types.h>
#include <device_manager.h> #include <device_manager.h>
#include <ide_types.h>
#include "ide_device_infoblock.h"
#include "ata_request.h" #include "ata_request.h"
#define debug_level_error 2 #define debug_level_error 2
@@ -39,7 +34,7 @@
// node item containing channel id (uint32) // node item containing channel id (uint32)
#define IDE_CHANNEL_ID_ITEM "ide/channel_id" #define IDE_CHANNEL_ID_ITEM "ide/channel_id"
// SIM interface // SIM interface
#define IDE_SIM_MODULE_NAME "bus_managers/ide/sim/v1" #define IDE_SIM_MODULE_NAME "bus_managers/ide/sim/driver_v1"
extern device_manager_info *pnp; extern device_manager_info *pnp;
@@ -61,8 +56,6 @@ typedef struct ide_bus_timer_info {
} ide_bus_timer_info; } ide_bus_timer_info;
typedef struct ide_device_info { typedef struct ide_device_info {
struct ide_bus_info *bus; struct ide_bus_info *bus;
@@ -78,7 +71,6 @@ typedef struct ide_device_info {
uint8 DMA_failures; // DMA failures in a row uint8 DMA_failures; // DMA failures in a row
uint8 num_failed_send; // number of consequetive send problems uint8 num_failed_send; // number of consequetive send problems
struct ata_request * requestActive; struct ata_request * requestActive;
struct ata_request * requestFree; struct ata_request * requestFree;
@@ -137,7 +129,6 @@ typedef enum {
struct ide_bus_info { struct ide_bus_info {
// controller // controller
ide_controller_interface *controller; ide_controller_interface *controller;
void *channel_cookie; void *channel_cookie;
@@ -163,7 +154,7 @@ struct ide_bus_info {
uchar path_id; uchar path_id;
device_node_handle node; // our pnp node device_node *node; // our pnp node
// restrictions, read from controller node // restrictions, read from controller node
uint8 max_devices; uint8 max_devices;
+28 -27
View File
@@ -1,13 +1,11 @@
/* /*
* Copyright 2004-2006, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2008, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
* *
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
/* /*
Part of Open IDE bus manager
Interface between ide bus manager and scsi bus manager. Interface between ide bus manager and scsi bus manager.
The IDE bus manager has a bit unusual structure as it The IDE bus manager has a bit unusual structure as it
@@ -103,7 +101,7 @@ err_disconnected:
static uchar static uchar
sim_path_inquiry(ide_bus_info *bus, scsi_path_inquiry *info) sim_path_inquiry(ide_bus_info *bus, scsi_path_inquiry *info)
{ {
char *controller_name; const char *controller_name;
FLOW("sim_path_inquiry, bus %p\n", bus); FLOW("sim_path_inquiry, bus %p\n", bus);
@@ -128,7 +126,6 @@ sim_path_inquiry(ide_bus_info *bus, scsi_path_inquiry *info)
if (pnp->get_attr_string(bus->node, SCSI_DESCRIPTION_CONTROLLER_NAME, if (pnp->get_attr_string(bus->node, SCSI_DESCRIPTION_CONTROLLER_NAME,
&controller_name, true) == B_OK) { &controller_name, true) == B_OK) {
strlcpy(info->hba_vid, controller_name, SCSI_HBA_ID); strlcpy(info->hba_vid, controller_name, SCSI_HBA_ID);
free(controller_name);
} else } else
strlcpy(info->hba_vid, "", SCSI_HBA_ID); strlcpy(info->hba_vid, "", SCSI_HBA_ID);
@@ -199,6 +196,17 @@ scan_bus(ide_bus_info *bus)
TRACE("ATA: scan_bus: bus %p finished\n", bus); TRACE("ATA: scan_bus: bus %p finished\n", bus);
} }
static void
sim_set_scsi_bus(ide_bus_info *bus, scsi_bus scsi)
{
bus->scsi_cookie = scsi;
// detect devices
scan_bus(bus);
}
static uchar static uchar
sim_rescan_bus(ide_bus_info *bus) sim_rescan_bus(ide_bus_info *bus)
{ {
@@ -253,9 +261,9 @@ sim_reset_device(ide_bus_info *bus, uchar target_id, uchar target_lun)
static status_t static status_t
ide_sim_init_bus(device_node_handle node, void *user_cookie, void **cookie) ide_sim_init_bus(device_node *node, void **cookie)
{ {
device_node_handle parent; device_node *parent;
ide_bus_info *bus; ide_bus_info *bus;
bool dmaDisabled = false; bool dmaDisabled = false;
status_t status; status_t status;
@@ -280,7 +288,6 @@ ide_sim_init_bus(device_node_handle node, void *user_cookie, void **cookie)
sprintf(bus->name, "ide_bus %d", (int)channel_id); sprintf(bus->name, "ide_bus %d", (int)channel_id);
} }
bus->scsi_cookie = user_cookie;
bus->timer.bus = bus; bus->timer.bus = bus;
if ((status = scsi->alloc_dpc(&bus->irq_dpc)) < B_OK) if ((status = scsi->alloc_dpc(&bus->irq_dpc)) < B_OK)
@@ -324,19 +331,16 @@ ide_sim_init_bus(device_node_handle node, void *user_cookie, void **cookie)
SHOW_FLOW(2, "can_dma: %d", bus->can_DMA); SHOW_FLOW(2, "can_dma: %d", bus->can_DMA);
parent = pnp->get_parent(node); parent = pnp->get_parent_node(node);
status = pnp->init_driver(parent, bus, (driver_module_info **)&bus->controller, status = pnp->get_driver(parent, (driver_module_info **)&bus->controller,
(void **)&bus->channel_cookie); (void **)&bus->channel_cookie);
pnp->put_device_node(parent); pnp->put_node(parent);
if (status != B_OK) if (status != B_OK)
goto err5; goto err5;
*cookie = bus; *cookie = bus;
// detect devices
scan_bus(bus);
return B_OK; return B_OK;
err5: err5:
@@ -350,28 +354,20 @@ err1:
} }
static status_t static void
ide_sim_uninit_bus(ide_bus_info *bus) ide_sim_uninit_bus(ide_bus_info *bus)
{ {
device_node_handle parent;
FLOW("ide_sim_uninit_bus: bus %p\n", bus); FLOW("ide_sim_uninit_bus: bus %p\n", bus);
parent = pnp->get_parent(bus->node);
pnp->uninit_driver(parent);
pnp->put_device_node(parent);
DELETE_BEN(&bus->status_report_ben); DELETE_BEN(&bus->status_report_ben);
scsi->free_dpc(bus->irq_dpc); scsi->free_dpc(bus->irq_dpc);
free(bus); free(bus);
return B_OK;
} }
static void static void
ide_sim_bus_removed(device_node_handle node, ide_bus_info *bus) ide_sim_bus_removed(ide_bus_info *bus)
{ {
FLOW("ide_sim_bus_removed\n"); FLOW("ide_sim_bus_removed\n");
@@ -495,11 +491,16 @@ scsi_sim_interface ide_sim_module = {
NULL, // supported devices NULL, // supported devices
NULL, // register node NULL, // register node
(status_t (*)(device_node_handle, void *, void **))ide_sim_init_bus, (status_t (*)(device_node *, void **)) ide_sim_init_bus,
(status_t (*)(void *) ) ide_sim_uninit_bus, (void (*)(void *)) ide_sim_uninit_bus,
(void (*)(device_node_handle, void *)) ide_sim_bus_removed NULL, // register child devices
NULL, // rescan
(void (*)(void *)) ide_sim_bus_removed,
NULL, // suspend
NULL // resume
}, },
(void (*)(scsi_sim_cookie, scsi_bus)) sim_set_scsi_bus,
(void (*)(scsi_sim_cookie, scsi_ccb *)) sim_scsi_io, (void (*)(scsi_sim_cookie, scsi_ccb *)) sim_scsi_io,
(uchar (*)(scsi_sim_cookie, scsi_ccb *)) sim_abort, (uchar (*)(scsi_sim_cookie, scsi_ccb *)) sim_abort,
(uchar (*)(scsi_sim_cookie, uchar, uchar)) sim_reset_device, (uchar (*)(scsi_sim_cookie, uchar, uchar)) sim_reset_device,