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:
@@ -4,12 +4,10 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
Part of Open IDE bus manager
|
||||
|
||||
Manager of IDE controllers
|
||||
|
||||
Whenever a new IDE channel is reported, a new SIM is
|
||||
registered at the SCSI bus manager.
|
||||
registered at the SCSI bus manager.
|
||||
*/
|
||||
|
||||
#include "ide_internal.h"
|
||||
@@ -23,12 +21,11 @@
|
||||
#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
|
||||
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;
|
||||
|
||||
TRACE("ide_channel_added, parent is %p\n", parent);
|
||||
@@ -49,10 +46,9 @@ ide_channel_added(device_node_handle parent)
|
||||
{
|
||||
device_attr attrs[] =
|
||||
{
|
||||
{ B_DRIVER_MODULE, B_STRING_TYPE, { string: IDE_SIM_MODULE_NAME }},
|
||||
{ B_DRIVER_FIXED_CHILD, B_STRING_TYPE, { string: SCSI_FOR_SIM_MODULE_NAME }},
|
||||
{ B_DEVICE_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 }},
|
||||
// maximum number of blocks per transmission:
|
||||
// - ATAPI uses packets, i.e. normal SCSI limits apply
|
||||
@@ -61,31 +57,23 @@ ide_channel_added(device_node_handle parent)
|
||||
// - some broken disk's firmware (read: IBM DTTA drives)
|
||||
// don't like 256 blocks in command queuing mode
|
||||
// -> use 255 blocks as a least common nominator
|
||||
// (this is still 127.5K for HDs and 510K for CDs,
|
||||
// (this is still 127.5K for HDs and 510K for CDs,
|
||||
// which should be sufficient)
|
||||
// Note: to fix specific drive bugs, use ide_sim_get_restrictions()
|
||||
// in ide_sim.c!
|
||||
{ B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: 255 }},
|
||||
{ IDE_CHANNEL_ID_ITEM, B_UINT32_TYPE, { ui32: channel_id }},
|
||||
{ PNP_MANAGER_ID_GENERATOR, B_STRING_TYPE, { string: IDE_CHANNEL_ID_GENERATOR }},
|
||||
{ PNP_MANAGER_AUTO_ID, B_UINT32_TYPE, { ui32: channel_id }},
|
||||
// { PNP_MANAGER_ID_GENERATOR, B_STRING_TYPE, { string: IDE_CHANNEL_ID_GENERATOR }},
|
||||
// { PNP_MANAGER_AUTO_ID, B_UINT32_TYPE, { ui32: channel_id }},
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
device_node_handle node;
|
||||
status_t res;
|
||||
|
||||
res = pnp->register_device(parent, attrs, NULL, &node);
|
||||
|
||||
free(controller_name);
|
||||
|
||||
return res;
|
||||
return pnp->register_node(parent, IDE_SIM_MODULE_NAME, attrs, NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
err:
|
||||
free(controller_name);
|
||||
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,18 +5,13 @@
|
||||
#ifndef __IDE_INTERNAL_H__
|
||||
#define __IDE_INTERNAL_H__
|
||||
|
||||
/*
|
||||
Part of Open IDE bus manager
|
||||
|
||||
Internal structures
|
||||
*/
|
||||
|
||||
|
||||
#include <bus/IDE.h>
|
||||
#include <bus/SCSI.h>
|
||||
#include "ide_device_infoblock.h"
|
||||
#include <ide_types.h>
|
||||
#include <device_manager.h>
|
||||
|
||||
#include <ide_types.h>
|
||||
|
||||
#include "ide_device_infoblock.h"
|
||||
#include "ata_request.h"
|
||||
|
||||
#define debug_level_error 2
|
||||
@@ -39,7 +34,7 @@
|
||||
// node item containing channel id (uint32)
|
||||
#define IDE_CHANNEL_ID_ITEM "ide/channel_id"
|
||||
// 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;
|
||||
@@ -61,8 +56,6 @@ typedef struct ide_bus_timer_info {
|
||||
} ide_bus_timer_info;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct ide_device_info {
|
||||
struct ide_bus_info *bus;
|
||||
|
||||
@@ -73,12 +66,11 @@ typedef struct ide_device_info {
|
||||
uint8 DMA_enabled : 1; // DMA enabled
|
||||
uint8 is_device1 : 1; // true for slave, false for master
|
||||
|
||||
uint8 last_lun; // last LUN
|
||||
uint8 last_lun; // last LUN
|
||||
|
||||
uint8 DMA_failures; // DMA failures in a row
|
||||
uint8 num_failed_send; // number of consequetive send problems
|
||||
|
||||
|
||||
struct ata_request * requestActive;
|
||||
struct ata_request * requestFree;
|
||||
|
||||
@@ -93,7 +85,7 @@ typedef struct ide_device_info {
|
||||
// ata from here on
|
||||
uint64 total_sectors; // size in sectors
|
||||
|
||||
// atapi from here on
|
||||
// atapi from here on
|
||||
uint8 packet[12]; // atapi command packet
|
||||
|
||||
struct {
|
||||
@@ -113,7 +105,7 @@ typedef struct ide_device_info {
|
||||
bool has_odd_byte; // remaining odd byte
|
||||
int odd_byte; // content off odd byte
|
||||
|
||||
ide_device_infoblock infoblock; // infoblock of device
|
||||
ide_device_infoblock infoblock; // infoblock of device
|
||||
} ide_device_info;
|
||||
|
||||
|
||||
@@ -137,7 +129,6 @@ typedef enum {
|
||||
|
||||
|
||||
struct ide_bus_info {
|
||||
|
||||
// controller
|
||||
ide_controller_interface *controller;
|
||||
void *channel_cookie;
|
||||
@@ -163,7 +154,7 @@ struct ide_bus_info {
|
||||
|
||||
uchar path_id;
|
||||
|
||||
device_node_handle node; // our pnp node
|
||||
device_node *node; // our pnp node
|
||||
|
||||
// restrictions, read from controller node
|
||||
uint8 max_devices;
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Part of Open IDE bus manager
|
||||
|
||||
Interface between ide bus manager and scsi bus manager.
|
||||
|
||||
The IDE bus manager has a bit unusual structure as it
|
||||
consists of a single level only. In fact it is no bus manager
|
||||
in terms of the PnP structure at all but a driver that maps
|
||||
one SCSI bus onto one IDE controller.
|
||||
|
||||
|
||||
This structure does not allow us to publish IDE devices
|
||||
as they can be accessed via the SCSI bus node only. Therefore
|
||||
we do a full bus scan every time the IDE bus node is loaded.
|
||||
@@ -103,7 +101,7 @@ err_disconnected:
|
||||
static uchar
|
||||
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);
|
||||
|
||||
@@ -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,
|
||||
&controller_name, true) == B_OK) {
|
||||
strlcpy(info->hba_vid, controller_name, SCSI_HBA_ID);
|
||||
free(controller_name);
|
||||
} else
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sim_set_scsi_bus(ide_bus_info *bus, scsi_bus scsi)
|
||||
{
|
||||
bus->scsi_cookie = scsi;
|
||||
|
||||
// detect devices
|
||||
scan_bus(bus);
|
||||
}
|
||||
|
||||
|
||||
static uchar
|
||||
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
|
||||
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;
|
||||
bool dmaDisabled = false;
|
||||
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);
|
||||
}
|
||||
|
||||
bus->scsi_cookie = user_cookie;
|
||||
bus->timer.bus = bus;
|
||||
|
||||
if ((status = scsi->alloc_dpc(&bus->irq_dpc)) < B_OK)
|
||||
@@ -293,7 +300,7 @@ ide_sim_init_bus(device_node_handle node, void *user_cookie, void **cookie)
|
||||
bus->devices[1] = NULL;
|
||||
|
||||
status = INIT_BEN(&bus->status_report_ben, "ide_status_report");
|
||||
if (status < B_OK)
|
||||
if (status < B_OK)
|
||||
goto err4;
|
||||
|
||||
{
|
||||
@@ -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);
|
||||
|
||||
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);
|
||||
|
||||
pnp->put_device_node(parent);
|
||||
pnp->put_node(parent);
|
||||
if (status != B_OK)
|
||||
goto err5;
|
||||
|
||||
*cookie = bus;
|
||||
|
||||
// detect devices
|
||||
scan_bus(bus);
|
||||
return B_OK;
|
||||
|
||||
err5:
|
||||
@@ -350,28 +354,20 @@ err1:
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
static void
|
||||
ide_sim_uninit_bus(ide_bus_info *bus)
|
||||
{
|
||||
device_node_handle parent;
|
||||
|
||||
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);
|
||||
scsi->free_dpc(bus->irq_dpc);
|
||||
|
||||
free(bus);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
|
||||
@@ -412,9 +408,9 @@ ide_sim_get_restrictions(ide_bus_info *bus, uchar target_id,
|
||||
*max_blocks = 255;
|
||||
|
||||
if (device->is_atapi) {
|
||||
if (strncmp(device->infoblock.model_number, "IOMEGA ZIP 100 ATAPI",
|
||||
if (strncmp(device->infoblock.model_number, "IOMEGA ZIP 100 ATAPI",
|
||||
strlen("IOMEGA ZIP 100 ATAPI")) == 0
|
||||
|| strncmp( device->infoblock.model_number, "IOMEGA Clik!",
|
||||
|| strncmp( device->infoblock.model_number, "IOMEGA Clik!",
|
||||
strlen( "IOMEGA Clik!")) == 0) {
|
||||
SHOW_ERROR0(2, "Found buggy ZIP/Clik! drive - restricting transmission size");
|
||||
*max_blocks = 64;
|
||||
@@ -493,13 +489,18 @@ scsi_sim_interface ide_sim_module = {
|
||||
std_ops,
|
||||
},
|
||||
|
||||
NULL, // supported devices
|
||||
NULL, // supported devices
|
||||
NULL, // register node
|
||||
(status_t (*)(device_node_handle, void *, void **))ide_sim_init_bus,
|
||||
(status_t (*)(void *) ) ide_sim_uninit_bus,
|
||||
(void (*)(device_node_handle, void *)) ide_sim_bus_removed
|
||||
(status_t (*)(device_node *, void **)) ide_sim_init_bus,
|
||||
(void (*)(void *)) ide_sim_uninit_bus,
|
||||
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,
|
||||
(uchar (*)(scsi_sim_cookie, scsi_ccb *)) sim_abort,
|
||||
(uchar (*)(scsi_sim_cookie, uchar, uchar)) sim_reset_device,
|
||||
@@ -508,8 +509,8 @@ scsi_sim_interface ide_sim_module = {
|
||||
(uchar (*)(scsi_sim_cookie, scsi_path_inquiry *))sim_path_inquiry,
|
||||
(uchar (*)(scsi_sim_cookie)) sim_rescan_bus,
|
||||
(uchar (*)(scsi_sim_cookie)) sim_reset_bus,
|
||||
|
||||
(void (*)(scsi_sim_cookie, uchar,
|
||||
|
||||
(void (*)(scsi_sim_cookie, uchar,
|
||||
bool*, bool *, uint32 *)) ide_sim_get_restrictions,
|
||||
|
||||
(status_t (*)(scsi_sim_cookie, uint8, uint32, void *, size_t))ide_sim_ioctl,
|
||||
|
||||
@@ -129,7 +129,7 @@ ide_irq_handler(ide_bus_info *bus, uint8 status)
|
||||
IDE_UNLOCK(bus);
|
||||
|
||||
scsi->schedule_dpc(bus->scsi_cookie, bus->irq_dpc, ide_dpc, bus);
|
||||
return B_INVOKE_SCHEDULER;
|
||||
return B_INVOKE_SCHEDULER;
|
||||
|
||||
case ide_state_idle:
|
||||
TRACE(("state: idle, num_running_reqs %d\n", bus->num_running_reqs));
|
||||
@@ -319,7 +319,7 @@ ide_timeout(timer *arg)
|
||||
|
||||
default:
|
||||
// this case also happens if a timeout fires too late;
|
||||
// unless there is a bug, the timeout should always be canceled
|
||||
// unless there is a bug, the timeout should always be canceled
|
||||
// before declaring bus as being idle
|
||||
dprintf("BUG: unknown state (%d)\n", (int)bus->state);
|
||||
|
||||
@@ -333,7 +333,7 @@ ide_timeout(timer *arg)
|
||||
|
||||
|
||||
|
||||
/** finish bus access;
|
||||
/** finish bus access;
|
||||
* check if any device wants to service pending commands + execute synced_pc
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user