Changes because of renaming various data structures (pnp_node -> device_node, ...).

Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10673 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-01-11 23:28:38 +00:00
parent 08ec614080
commit 9c4f4c037d
41 changed files with 924 additions and 880 deletions

View File

@ -24,7 +24,7 @@
/** called when an IDE channel was registered by a controller driver */
static status_t
ide_channel_added(pnp_node_handle parent)
ide_channel_added(device_node_handle parent)
{
char *str = NULL, *controller_name = NULL;
uint32 channel_id;
@ -50,7 +50,7 @@ ide_channel_added(pnp_node_handle parent)
}
{
pnp_node_attr attrs[] =
device_attr attrs[] =
{
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: IDE_SIM_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: SCSI_SIM_TYPE_NAME }},
@ -76,7 +76,7 @@ ide_channel_added(pnp_node_handle parent)
{ NULL }
};
pnp_node_handle node;
device_node_handle node;
status_t res;
res = pnp->register_device(parent, attrs, NULL, &node);

View File

@ -1,7 +1,9 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __IDE_INTERNAL_H__
#define __IDE_INTERNAL_H__
/*
Part of Open IDE bus manager
@ -9,8 +11,6 @@
Internal structures
*/
#ifndef __IDE_INTERNAL_H__
#define __IDE_INTERNAL_H__
#include <bus/IDE.h>
#include <bus/SCSI.h>
@ -227,7 +227,7 @@ struct ide_bus_info {
uchar path_id;
pnp_node_handle node; // our pnp node
device_node_handle node; // our pnp node
// restrictions, read from controller node
uint8 max_devices;
@ -425,4 +425,4 @@ status_t ide_irq_handler(ide_bus_info *bus, uint8 status);
status_t ide_timeout(timer *arg);
#endif
#endif /* __IDE_INTERNAL_H__ */

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
@ -539,7 +539,7 @@ finish_all_requests(ide_device_info *device, ide_qrequest *ignore,
static status_t
ide_sim_init_bus(pnp_node_handle node, void *user_cookie, void **cookie)
ide_sim_init_bus(device_node_handle node, void *user_cookie, void **cookie)
{
ide_bus_info *bus;
int res;
@ -636,7 +636,7 @@ ide_sim_init_bus(pnp_node_handle node, void *user_cookie, void **cookie)
}
res = pnp->load_driver(pnp->get_parent(node), bus,
(pnp_driver_info **)&bus->controller,
(driver_module_info **)&bus->controller,
(void **)&bus->channel);
if (res != B_OK)
goto err5;
@ -706,7 +706,7 @@ disconnect_worker(ide_bus_info *bus, void *arg)
static void
ide_sim_bus_removed(pnp_node_handle node, ide_bus_info *bus)
ide_sim_bus_removed(device_node_handle node, ide_bus_info *bus)
{
if (bus == NULL)
// driver not loaded - no manual intervention needed
@ -784,11 +784,11 @@ scsi_sim_interface ide_sim_module = {
std_ops,
},
(status_t (*)( pnp_node_handle, void *, void **))ide_sim_init_bus,
(status_t (*)(device_node_handle, void *, void **))ide_sim_init_bus,
(status_t (*)( void *)) ide_sim_uninit_bus,
NULL,
(void (*)( pnp_node_handle , void *)) ide_sim_bus_removed
(void (*)(device_node_handle, void *)) ide_sim_bus_removed
},
(void (*)( scsi_sim_cookie, scsi_ccb * )) sim_scsi_io,

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
ISA bus manager
@ -137,7 +137,7 @@ unlock_isa_dma_channel(long channel)
static status_t
isa_init_device(pnp_node_handle node, void *user_cookie, void **cookie)
isa_init_device(device_node_handle node, void *user_cookie, void **cookie)
{
*cookie = NULL;
return B_OK;
@ -152,9 +152,9 @@ isa_uninit_device(void *cookie)
static status_t
isa_device_added(pnp_node_handle parent)
isa_device_added(device_node_handle parent)
{
static const pnp_node_attr attrs[] = {
static const device_attr attrs[] = {
// info about ourself
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: ISA_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: ISA_DEVICE_TYPE_NAME }},
@ -170,11 +170,11 @@ isa_device_added(pnp_node_handle parent)
{ PNP_DRIVER_DYNAMIC_CONSUMER, B_STRING_TYPE, { string: ISA_DRIVERS_DIR "/" }},
{ NULL }
};
pnp_node_handle node;
device_node_handle node;
char *parent_type;
status_t res;
// make sure parent is really pnp root
if (pnp->get_attr_string( parent, PNP_DRIVER_TYPE, &parent_type, false))
return B_ERROR;

View File

@ -27,63 +27,65 @@
typedef struct bus_raw_info {
scsi_bus_interface *interface;
scsi_bus cookie;
pnp_node_handle node;
device_node_handle node;
} bus_raw_info;
static status_t scsi_bus_raw_init_device(
pnp_node_handle node, void *user_cookie, void **cookie )
static status_t
scsi_bus_raw_init_device(device_node_handle node,
void *userCookie, void **cookie)
{
bus_raw_info *bus;
scsi_bus_interface *interface;
scsi_bus bus_cookie;
status_t res;
res = pnp->load_driver( pnp->get_parent( node ), NULL,
(pnp_driver_info **)&interface, (void **)&bus_cookie );
if( res != B_OK )
status_t res = pnp->load_driver(pnp->get_parent(node), NULL,
(driver_module_info **)&interface, (void **)&bus_cookie);
if (res != B_OK)
return res;
bus = malloc( sizeof( *bus ));
bus = malloc(sizeof(*bus));
bus->interface = interface;
bus->cookie = bus_cookie;
bus->node = node;
*cookie = bus;
return B_OK;
}
static status_t scsi_bus_raw_uninit_device( bus_raw_info *bus )
static status_t
scsi_bus_raw_uninit_device(bus_raw_info *bus)
{
status_t res;
res = pnp->unload_driver( pnp->get_parent( bus->node ));
if( res != B_OK )
res = pnp->unload_driver(pnp->get_parent(bus->node));
if (res != B_OK)
return res;
free( bus );
free(bus);
return B_OK;
}
static status_t scsi_bus_raw_probe( pnp_node_handle parent )
static status_t
scsi_bus_raw_probe(device_node_handle parent)
{
uint8 path_id;
char *name;
if( pnp->get_attr_uint8( parent, SCSI_BUS_PATH_ID_ITEM, &path_id, false ) != B_OK )
if (pnp->get_attr_uint8(parent, SCSI_BUS_PATH_ID_ITEM, &path_id, false) != B_OK)
return B_ERROR;
// put that on heap to not overflow the limited kernel stack
name = malloc( PATH_MAX + 1 );
if( name == NULL )
name = malloc(PATH_MAX + 1);
if (name == NULL)
return B_NO_MEMORY;
sprintf( name, "bus/scsi/%d/bus_raw", path_id );
snprintf(name, PATH_MAX + 1, "bus/scsi/%d/bus_raw", path_id);
{
pnp_node_attr attributes[] = {
device_attr attributes[] = {
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: SCSI_BUS_RAW_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: PNP_DEVFS_TYPE_NAME }},
{ PNP_DRIVER_FIXED_CONSUMER, B_STRING_TYPE, { string: PNP_DEVFS_MODULE_NAME }},
@ -94,63 +96,67 @@ static status_t scsi_bus_raw_probe( pnp_node_handle parent )
{ PNP_DEVFS_FILENAME, B_STRING_TYPE, { string: name }},
{}
};
pnp_node_handle node;
status_t res;
res = pnp->register_device( parent, attributes, NULL, &node );
free( name );
device_node_handle node;
status_t res = pnp->register_device(parent, attributes, NULL, &node);
free(name);
return res;
}
}
static status_t scsi_bus_raw_open( bus_raw_info *bus, uint32 flags,
bus_raw_info **handle_cookie )
static status_t
scsi_bus_raw_open(bus_raw_info *bus, uint32 flags,
bus_raw_info **handle_cookie)
{
*handle_cookie = bus;
return B_ERROR;
}
static status_t scsi_bus_raw_close( void *cookie )
static status_t
scsi_bus_raw_close(void *cookie)
{
return B_OK;
}
static status_t scsi_bus_raw_free( void *cookie )
static status_t
scsi_bus_raw_free(void *cookie)
{
return B_ERROR;
}
static status_t scsi_bus_raw_control( bus_raw_info *bus, uint32 op, void *data,
size_t len )
static status_t
scsi_bus_raw_control(bus_raw_info *bus, uint32 op, void *data,
size_t len)
{
switch( op ) {
case B_SCSI_BUS_RAW_RESET:
return bus->interface->reset_bus( bus->cookie );
case B_SCSI_BUS_RAW_PATH_INQUIRY:
return bus->interface->path_inquiry( bus->cookie, data );
switch (op) {
case B_SCSI_BUS_RAW_RESET:
return bus->interface->reset_bus(bus->cookie);
case B_SCSI_BUS_RAW_PATH_INQUIRY:
return bus->interface->path_inquiry(bus->cookie, data);
}
return B_ERROR;
}
static status_t scsi_bus_raw_read( void *cookie, off_t position, void *data,
size_t *numBytes )
static status_t
scsi_bus_raw_read(void *cookie, off_t position, void *data,
size_t *numBytes)
{
*numBytes = 0;
return B_ERROR;
}
static status_t scsi_bus_raw_write( void *cookie, off_t position,
const void *data, size_t *numBytes )
static status_t
scsi_bus_raw_write(void *cookie, off_t position,
const void *data, size_t *numBytes)
{
*numBytes = 0;
return B_ERROR;

View File

@ -85,7 +85,7 @@ scsi_service_threadproc(void *arg)
static scsi_bus_info *
scsi_create_bus(pnp_node_handle node, uint8 path_id)
scsi_create_bus(device_node_handle node, uint8 path_id)
{
scsi_bus_info *bus;
int res;
@ -180,7 +180,7 @@ scsi_destroy_bus(scsi_bus_info *bus)
static status_t
scsi_init_bus(pnp_node_handle node, void *user_cookie, void **cookie)
scsi_init_bus(device_node_handle node, void *user_cookie, void **cookie)
{
uint8 path_id;
scsi_bus_info *bus;
@ -240,8 +240,7 @@ scsi_init_bus(pnp_node_handle node, void *user_cookie, void **cookie)
}
res = pnp->load_driver(pnp->get_parent(node), bus,
(pnp_driver_info **)&bus->interface,
(void **)&bus->sim_cookie);
(driver_module_info **)&bus->interface, (void **)&bus->sim_cookie);
if (res != B_OK)
goto err;

View File

@ -118,7 +118,7 @@ scsi_register_device(scsi_bus_info *bus, uchar target_id,
char vendor_ident[sizeof( inquiry_data->vendor_ident ) + 1];
char product_ident[sizeof( inquiry_data->product_ident ) + 1];
char product_rev[sizeof( inquiry_data->product_rev ) + 1];
pnp_node_attr attrs[] = {
device_attr attrs[] = {
// info about driver
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: SCSI_DEVICE_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: SCSI_DEVICE_TYPE_NAME }},
@ -161,7 +161,7 @@ scsi_register_device(scsi_bus_info *bus, uchar target_id,
{ SCSI_DEVICE_MANUAL_AUTOSENSE_ITEM, B_UINT8_TYPE, { ui8: manual_autosense }},
{ NULL }
};
pnp_node_handle node;
device_node_handle node;
status_t res;
beautify_string(vendor_ident, inquiry_data->vendor_ident, sizeof(vendor_ident));
@ -179,7 +179,7 @@ scsi_register_device(scsi_bus_info *bus, uchar target_id,
// create data structure for a device
static scsi_device_info *
scsi_create_device( pnp_node_handle node, scsi_bus_info *bus,
scsi_create_device( device_node_handle node, scsi_bus_info *bus,
int target_id, int target_lun)
{
scsi_device_info *device;
@ -272,45 +272,42 @@ static status_t scsi_create_autosense_request( scsi_device_info *device )
return B_OK;
err:
scsi_free_ccb( request );
scsi_free_ccb(request);
return B_NO_MEMORY;
}
#define SET_BIT( field, bit ) field[(bit) >> 3] |= 1 << ((bit) & 7)
#define SET_BIT(field, bit) field[(bit) >> 3] |= 1 << ((bit) & 7)
static status_t
scsi_init_device(pnp_node_handle node, void *user_cookie, void **cookie)
scsi_init_device(device_node_handle node, void *user_cookie, void **cookie)
{
scsi_res_inquiry *inquiry_data = NULL;
uint8 target_id, target_lun, path_id;
scsi_bus_info *bus;
scsi_device_info *device;
status_t res;
pnp_driver_info *bus_interface;
driver_module_info *bus_interface;
size_t inquiry_data_len;
uint8 is_atapi, manual_autosense;
SHOW_FLOW0( 3, "" );
SHOW_FLOW0(3, "");
if( pnp->get_attr_uint8( node, SCSI_DEVICE_TARGET_ID_ITEM, &target_id, false ) != B_OK ||
pnp->get_attr_uint8( node, SCSI_DEVICE_TARGET_LUN_ITEM, &target_lun, false ) != B_OK ||
pnp->get_attr_uint8( node, SCSI_DEVICE_IS_ATAPI_ITEM, &is_atapi, false ) != B_OK ||
pnp->get_attr_uint8( node, SCSI_DEVICE_MANUAL_AUTOSENSE_ITEM, &manual_autosense, false ) != B_OK ||
pnp->get_attr_raw( node, SCSI_DEVICE_INQUIRY_ITEM,
(void **)&inquiry_data, &inquiry_data_len, false ) != B_OK ||
inquiry_data_len != sizeof( *inquiry_data ))
{
if (pnp->get_attr_uint8( node, SCSI_DEVICE_TARGET_ID_ITEM, &target_id, false) != B_OK
|| pnp->get_attr_uint8( node, SCSI_DEVICE_TARGET_LUN_ITEM, &target_lun, false) != B_OK
|| pnp->get_attr_uint8( node, SCSI_DEVICE_IS_ATAPI_ITEM, &is_atapi, false) != B_OK
|| pnp->get_attr_uint8( node, SCSI_DEVICE_MANUAL_AUTOSENSE_ITEM, &manual_autosense, false) != B_OK
|| pnp->get_attr_raw( node, SCSI_DEVICE_INQUIRY_ITEM,
(void **)&inquiry_data, &inquiry_data_len, false) != B_OK
|| inquiry_data_len != sizeof(*inquiry_data)) {
res = B_ERROR;
goto err3;
}
dprintf("**** b ****\n");
res = pnp->load_driver(pnp->get_parent(node), NULL, &bus_interface,
(void **)&bus);
if (res != B_OK)
goto err3;
dprintf("**** b! ****\n");
device = scsi_create_device(node, bus, target_id, target_lun);
if (device == NULL) {
@ -323,141 +320,142 @@ dprintf("**** b! ****\n");
pnp->get_attr_uint8(node, SCSI_BUS_PATH_ID_ITEM, &path_id, true);
sprintf( device->name, "scsi_device %u:%u:%u", path_id, target_id, target_lun );
sprintf(device->name, "scsi_device %u:%u:%u", path_id, target_id, target_lun);
device->log = fast_log->start_log( device->name, scsi_device_events );
if( device->log == NULL ) {
device->log = fast_log->start_log(device->name, scsi_device_events);
if (device->log == NULL) {
res = B_NO_MEMORY;
goto err;
}
device->inquiry_data = *inquiry_data;
// save restrictions
device->is_atapi = is_atapi;
device->manual_autosense = manual_autosense;
// size of device queue must be detected by trial and error, so
// we start with a really high number and see when the device chokes
device->total_slots = 4096;
// disable queuing if bus doesn't support it
if( (bus->inquiry_data.hba_inquiry & SCSI_PI_TAG_ABLE) == 0 )
if ((bus->inquiry_data.hba_inquiry & SCSI_PI_TAG_ABLE) == 0)
device->total_slots = 1;
// if there is no autosense, disable queuing to make sure autosense is
// not overtaken by other requests
if( device->manual_autosense )
if (device->manual_autosense)
device->total_slots = 1;
device->left_slots = device->total_slots;
// get autosense request if required
if( device->manual_autosense ) {
if( scsi_create_autosense_request( device ) != B_OK ) {
if (device->manual_autosense) {
if (scsi_create_autosense_request(device) != B_OK) {
res = B_NO_MEMORY;
goto err;
}
}
// if this is an ATAPI device, we need an emulation buffer
if( scsi_init_emulation_buffer( device, SCSI_ATAPI_BUFFER_SIZE ) != B_OK ) {
if (scsi_init_emulation_buffer(device, SCSI_ATAPI_BUFFER_SIZE) != B_OK) {
res = B_NO_MEMORY;
goto err;
}
memset( device->emulation_map, 0, sizeof( device->emulation_map ));
if( device->is_atapi ) {
SET_BIT( device->emulation_map, SCSI_OP_READ_6 );
SET_BIT( device->emulation_map, SCSI_OP_WRITE_6 );
SET_BIT( device->emulation_map, SCSI_OP_MODE_SENSE_6 );
SET_BIT( device->emulation_map, SCSI_OP_MODE_SELECT_6 );
SET_BIT( device->emulation_map, SCSI_OP_INQUIRY );
memset(device->emulation_map, 0, sizeof(device->emulation_map));
if (device->is_atapi) {
SET_BIT(device->emulation_map, SCSI_OP_READ_6);
SET_BIT(device->emulation_map, SCSI_OP_WRITE_6);
SET_BIT(device->emulation_map, SCSI_OP_MODE_SENSE_6);
SET_BIT(device->emulation_map, SCSI_OP_MODE_SELECT_6);
SET_BIT(device->emulation_map, SCSI_OP_INQUIRY);
}
free( inquiry_data );
*cookie = device;
free(inquiry_data);
*cookie = device;
return B_OK;
err:
scsi_free_device( device );
scsi_free_device(device);
err2:
pnp->unload_driver( pnp->get_parent( node ));
pnp->unload_driver(pnp->get_parent(node));
err3:
if( inquiry_data != NULL )
free( inquiry_data );
if (inquiry_data != NULL)
free(inquiry_data);
return res;
}
static status_t
scsi_uninit_device(scsi_device_info *device)
{
pnp_node_handle node = device->node;
device_node_handle node = device->node;
SHOW_FLOW0(3, "");
scsi_free_device(device);
SHOW_FLOW0( 3, "" );
scsi_free_device( device );
// must unload parent at last as scsi_free_device access it
pnp->unload_driver( pnp->get_parent( node ));
pnp->unload_driver(pnp->get_parent(node));
return B_OK;
}
static void
scsi_device_removed(pnp_node_handle node, scsi_device_info *device)
scsi_device_removed(device_node_handle node, scsi_device_info *device)
{
SHOW_FLOW0( 3, "" );
if( device == NULL )
SHOW_FLOW0(3, "");
if (device == NULL)
return;
// this must be atomic as no lock is used
device->valid = false;
}
// get device info; create a temporary one if it's not registered
// (used during detection)
// on success, scan_lun_lock of bus is hold
status_t scsi_force_get_device( scsi_bus_info *bus,
uchar target_id, uchar target_lun, scsi_device_info **res_device )
/** get device info; create a temporary one if it's not registered
* (used during detection)
* on success, scan_lun_lock of bus is hold
*/
status_t
scsi_force_get_device( scsi_bus_info *bus, uchar target_id,
uchar target_lun, scsi_device_info **res_device)
{
pnp_node_attr attrs[] = {
device_attr attrs[] = {
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: SCSI_DEVICE_TYPE_NAME }},
{ SCSI_DEVICE_TARGET_ID_ITEM, B_UINT8_TYPE, { ui8: target_id }},
{ SCSI_DEVICE_TARGET_LUN_ITEM, B_UINT8_TYPE, { ui8: target_lun }},
{ NULL }
};
pnp_node_handle node;
device_node_handle node;
status_t res;
pnp_driver_info *driver_interface;
driver_module_info *driver_interface;
scsi_device device;
SHOW_FLOW0( 3, "" );
SHOW_FLOW0(3, "");
// very important: only one can use a forced device to avoid double detection
acquire_sem( bus->scan_lun_lock );
acquire_sem(bus->scan_lun_lock);
// check whether device registered already
node = pnp->find_device( bus->node, attrs );
node = pnp->find_device(bus->node, attrs);
SHOW_FLOW( 3, "%p", node );
if( node != NULL ) {
SHOW_FLOW(3, "%p", node);
if (node != NULL) {
// there is one - get it
res = pnp->load_driver( node, NULL, &driver_interface,
(void **)&device );
res = pnp->load_driver(node, NULL, &driver_interface,
(void **)&device);
} else {
// device doesn't exist yet - create a temporary one
device = scsi_create_device( NULL, bus, target_id, target_lun );
if( device == NULL )
device = scsi_create_device(NULL, bus, target_id, target_lun);
if (device == NULL)
res = B_NO_MEMORY;
else
res = B_OK;
@ -465,40 +463,45 @@ status_t scsi_force_get_device( scsi_bus_info *bus,
*res_device = device;
if( res != B_OK )
release_sem( bus->scan_lun_lock );
if (res != B_OK)
release_sem(bus->scan_lun_lock);
return res;
}
// cleanup device received from scsi_force_get_device
// on return, scan_lun_lock of bus is released
void scsi_put_forced_device( scsi_device_info *device )
/** cleanup device received from scsi_force_get_device
* on return, scan_lun_lock of bus is released
*/
void
scsi_put_forced_device(scsi_device_info *device)
{
scsi_bus_info *bus = device->bus;
SHOW_FLOW0( 3, "" );
if( device->node != NULL )
SHOW_FLOW0(3, "");
if (device->node != NULL)
// device is registered
pnp->unload_driver( device->node );
pnp->unload_driver(device->node);
else
// device is temporary
scsi_free_device( device );
release_sem( bus->scan_lun_lock );
scsi_free_device(device);
release_sem(bus->scan_lun_lock);
}
static uchar scsi_reset_device( scsi_device_info *device )
static uchar
scsi_reset_device(scsi_device_info *device)
{
SHOW_FLOW0( 3, "" );
if( device->node == NULL )
SHOW_FLOW0(3, "");
if (device->node == NULL)
return SCSI_DEV_NOT_THERE;
return device->bus->interface->reset_device(
device->bus->sim_cookie, device->target_id, device->target_lun );
return device->bus->interface->reset_device(device->bus->sim_cookie,
device->target_id, device->target_lun);
}
@ -523,8 +526,7 @@ std_ops(int32 op, ...)
}
scsi_device_interface scsi_device_module =
{
scsi_device_interface scsi_device_module = {
{
{
SCSI_DEVICE_MODULE_NAME,
@ -533,9 +535,9 @@ scsi_device_interface scsi_device_module =
},
scsi_init_device,
(status_t (*)( void * )) scsi_uninit_device,
(status_t (*)(void *)) scsi_uninit_device,
NULL,
(void (*)( pnp_node_handle, void * )) scsi_device_removed
(void (*)(device_node_handle, void *)) scsi_device_removed
},
scsi_alloc_ccb,

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI bus manager
@ -55,7 +55,7 @@ status_t
scsi_init_emulation_buffer(scsi_device_info *device, size_t buffer_size)
{
physical_entry map[1];
void *unaligned_phys, *aligned_phys, *aligned_addr, *unaligned_addr;
addr_t unaligned_phys, aligned_phys, aligned_addr, unaligned_addr;
size_t total_size;
SHOW_FLOW0(3, "");
@ -71,7 +71,7 @@ scsi_init_emulation_buffer(scsi_device_info *device, size_t buffer_size)
// to satisfy alignment, we must allocate a buffer twice its required size
// and find the properly aligned part of it, ouch!
device->buffer_area = create_area("ATAPI buffer", &unaligned_addr, B_ANY_KERNEL_ADDRESS,
device->buffer_area = create_area("ATAPI buffer", (void *)&unaligned_addr, B_ANY_KERNEL_ADDRESS,
2 * total_size, B_CONTIGUOUS, 0);
if (device->buffer_area < 0) {
SHOW_ERROR( 1, "cannot create DMA buffer (%s)", strerror(device->buffer_area));
@ -80,21 +80,21 @@ scsi_init_emulation_buffer(scsi_device_info *device, size_t buffer_size)
return device->buffer_area;
}
get_memory_map(unaligned_addr, B_PAGE_SIZE, map, 1);
get_memory_map((void *)unaligned_addr, B_PAGE_SIZE, map, 1);
// get aligned part
unaligned_phys = (char *)map[0].address;
aligned_phys = (char *)(((int32)unaligned_phys + buffer_size - 1) & ~(buffer_size - 1));
unaligned_phys = (addr_t)map[0].address;
aligned_phys = (unaligned_phys + buffer_size - 1) & ~(buffer_size - 1);
aligned_addr = unaligned_addr + (aligned_phys - unaligned_phys);
SHOW_FLOW(3, "unaligned_phys=%p, aligned_phys=%p, unaligned_addr=%p, aligned_addr=%p",
SHOW_FLOW(3, "unaligned_phys = %#lx, aligned_phys = %#lx, unaligned_addr = %#lx, aligned_addr = %#lx",
unaligned_phys, aligned_phys, unaligned_addr, aligned_addr);
device->buffer = aligned_addr;
device->buffer = (void *)aligned_addr;
device->buffer_size = buffer_size;
// s/g list is directly after buffer
device->buffer_sg_list = aligned_addr + buffer_size;
device->buffer_sg_list[0].address = aligned_phys;
device->buffer_sg_list = (void *)(aligned_addr + buffer_size);
device->buffer_sg_list[0].address = (void *)aligned_phys;
device->buffer_sg_list[0].size = buffer_size;
device->buffer_sg_cnt = 1;
@ -471,21 +471,21 @@ copy_sg_data(scsi_ccb *request, uint offset, uint allocation_length,
// copy one S/G entry at a time
for (; size > 0 && req_size > 0 && sg_cnt > 0; ++sg_list, --sg_cnt) {
size_t bytes;
void *virt_addr;
addr_t virt_addr;
bytes = min(size, req_size);
bytes = min(bytes, sg_list->size);
if (map_mainmemory((addr_t)sg_list->address, &virt_addr) != B_OK)
if (map_mainmemory((addr_t)sg_list->address, (void *)&virt_addr) != B_OK)
return false;
SHOW_FLOW(0, "buffer=%p, virt_addr=%p, bytes=%d, to_buffer=%d",
buffer, virt_addr + offset, (int)bytes, to_buffer);
SHOW_FLOW(0, "buffer = %p, virt_addr = %#lx, bytes = %lu, to_buffer = %d",
buffer, virt_addr + offset, bytes, to_buffer);
if (to_buffer)
memcpy(buffer, virt_addr + offset, bytes);
memcpy(buffer, (void *)(virt_addr + offset), bytes);
else
memcpy(virt_addr + offset, buffer, bytes);
memcpy((void *)(virt_addr + offset), buffer, bytes);
#if 0
{
@ -504,7 +504,7 @@ copy_sg_data(scsi_ccb *request, uint offset, uint allocation_length,
}
#endif
unmap_mainmemory(virt_addr);
unmap_mainmemory((void *)virt_addr);
(char *)buffer += bytes;
size -= bytes;

View File

@ -1,7 +1,9 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __SCSI_INTERNAL_H__
#define __SCSI_INTERNAL_H__
/*
Part of Open SCSI bus manager
@ -9,8 +11,6 @@
Internal structures/definitions
*/
#ifndef __SCSI_INTERNAL_H__
#define __SCSI_INTERNAL_H__
#include <bus/SCSI.h>
@ -131,7 +131,7 @@ typedef struct scsi_bus_info {
locked_pool_cookie ccb_pool; // ccb pool (one per bus)
pnp_node_handle node; // pnp node of bus
device_node_handle node; // pnp node of bus
dma_params dma_params; // dma restrictions of controller
@ -195,7 +195,7 @@ typedef struct scsi_device_info {
// and thus must be emulated
scsi_res_inquiry inquiry_data;
pnp_node_handle node; // device node
device_node_handle node; // device node
benaphore dma_buffer_lock; // lock between DMA buffer user and clean-up daemon
sem_id dma_buffer_owner; // to be acquired before using DMA buffer

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI bus manager
@ -25,46 +25,44 @@
*/
static status_t
scsi_controller_added(pnp_node_handle parent)
scsi_controller_added(device_node_handle parent)
{
int path_id;
char *str, *controller_name;
SHOW_FLOW0( 4, "" );
if( pnp->get_attr_string( parent, PNP_DRIVER_TYPE, &str, false ) != B_OK )
SHOW_FLOW0(4, "");
if (pnp->get_attr_string(parent, PNP_DRIVER_TYPE, &str, false) != B_OK)
return B_ERROR;
if (strcmp(str, SCSI_SIM_TYPE_NAME) != 0) {
free(str);
return B_ERROR;
}
free( str );
if( pnp->get_attr_string( parent, SCSI_DESCRIPTION_CONTROLLER_NAME,
&controller_name, false ) != B_OK )
{
pnp->get_attr_string( parent, PNP_DRIVER_DRIVER, &str, false );
SHOW_ERROR( 0, "Ignored controller managed by %s - controller name missing",
str );
free(str);
if (pnp->get_attr_string(parent, SCSI_DESCRIPTION_CONTROLLER_NAME,
&controller_name, false) != B_OK) {
pnp->get_attr_string(parent, PNP_DRIVER_DRIVER, &str, false);
SHOW_ERROR(0, "Ignored controller managed by %s - controller name missing",
str);
return B_ERROR;
}
path_id = pnp->create_id( SCSI_PATHID_GENERATOR );
if( path_id < 0 ) {
SHOW_ERROR( 0, "Cannot register SCSI controller %s - out of path IDs",
controller_name );
free( controller_name );
path_id = pnp->create_id(SCSI_PATHID_GENERATOR);
if (path_id < 0) {
SHOW_ERROR(0, "Cannot register SCSI controller %s - out of path IDs",
controller_name);
free(controller_name);
return B_ERROR;
}
free(controller_name);
{
pnp_node_attr attrs[] =
{
device_attr attrs[] = {
// general information
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: SCSI_BUS_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: SCSI_BUS_TYPE_NAME }},
@ -87,9 +85,9 @@ scsi_controller_added(pnp_node_handle parent)
{ NULL, 0 }
};
pnp_node_handle node;
device_node_handle node;
return pnp->register_device( parent, attrs, NULL, &node );
return pnp->register_device(parent, attrs, NULL, &node);
}
}

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Generic IDE PCI controller driver
@ -33,103 +33,125 @@ static ide_adapter_interface *ide_adapter;
device_manager_info *pnp;
static int write_command_block_regs( ide_adapter_channel_info *channel, ide_task_file *tf,
ide_reg_mask mask )
static int
write_command_block_regs(ide_adapter_channel_info *channel, ide_task_file *tf,
ide_reg_mask mask)
{
return ide_adapter->write_command_block_regs( channel, tf, mask );
return ide_adapter->write_command_block_regs(channel, tf, mask);
}
static status_t read_command_block_regs( ide_adapter_channel_info *channel, ide_task_file *tf,
ide_reg_mask mask )
static status_t
read_command_block_regs(ide_adapter_channel_info *channel, ide_task_file *tf,
ide_reg_mask mask)
{
return ide_adapter->read_command_block_regs( channel, tf, mask );
return ide_adapter->read_command_block_regs(channel, tf, mask);
}
static uint8 get_altstatus( ide_adapter_channel_info *channel)
static uint8
get_altstatus(ide_adapter_channel_info *channel)
{
return ide_adapter->get_altstatus( channel );
return ide_adapter->get_altstatus(channel);
}
static status_t write_device_control( ide_adapter_channel_info *channel, uint8 val )
static status_t
write_device_control(ide_adapter_channel_info *channel, uint8 val)
{
return ide_adapter->write_device_control( channel, val );
return ide_adapter->write_device_control(channel, val);
}
static status_t write_pio( ide_adapter_channel_info *channel, uint16 *data, int count,
bool force_16bit )
static status_t
write_pio(ide_adapter_channel_info *channel, uint16 *data, int count,
bool force_16bit)
{
return ide_adapter->write_pio( channel, data, count, force_16bit );
return ide_adapter->write_pio(channel, data, count, force_16bit);
}
static status_t read_pio( ide_adapter_channel_info *channel, uint16 *data, int count,
bool force_16bit )
static status_t
read_pio(ide_adapter_channel_info *channel, uint16 *data, int count,
bool force_16bit)
{
return ide_adapter->read_pio( channel, data, count, force_16bit );
return ide_adapter->read_pio(channel, data, count, force_16bit);
}
static status_t prepare_dma( ide_adapter_channel_info *channel,
static status_t
prepare_dma(ide_adapter_channel_info *channel,
const physical_entry *sg_list, size_t sg_list_count,
bool to_device )
bool to_device)
{
return ide_adapter->prepare_dma( channel, sg_list, sg_list_count, to_device );
}
static status_t start_dma( ide_adapter_channel_info *channel )
{
return ide_adapter->start_dma( channel );
return ide_adapter->prepare_dma(channel, sg_list, sg_list_count, to_device);
}
static status_t finish_dma( ide_adapter_channel_info *channel )
static status_t
start_dma(ide_adapter_channel_info *channel)
{
return ide_adapter->finish_dma( channel );
return ide_adapter->start_dma(channel);
}
static status_t init_channel( pnp_node_handle node, ide_channel ide_channel,
ide_adapter_channel_info **cookie )
static status_t
finish_dma(ide_adapter_channel_info *channel)
{
return ide_adapter->init_channel( node, ide_channel, cookie,
sizeof( ide_adapter_channel_info ), ide_adapter->inthand );
return ide_adapter->finish_dma(channel);
}
static status_t uninit_channel( ide_adapter_channel_info *channel )
static status_t
init_channel(device_node_handle node, ide_channel ide_channel,
ide_adapter_channel_info **cookie)
{
return ide_adapter->uninit_channel( channel );
return ide_adapter->init_channel(node, ide_channel, cookie,
sizeof(ide_adapter_channel_info), ide_adapter->inthand);
}
static void channel_removed( pnp_node_handle node, ide_adapter_channel_info *channel )
static status_t
uninit_channel(ide_adapter_channel_info *channel)
{
return ide_adapter->channel_removed( node, channel );
return ide_adapter->uninit_channel(channel);
}
static status_t init_controller( pnp_node_handle node, void *user_cookie,
ide_adapter_controller_info **cookie )
static void
channel_removed(device_node_handle node, ide_adapter_channel_info *channel)
{
return ide_adapter->init_controller( node, user_cookie, cookie,
sizeof( ide_adapter_controller_info ));
return ide_adapter->channel_removed(node, channel);
}
static status_t uninit_controller( ide_adapter_controller_info *controller )
static status_t
init_controller(device_node_handle node, void *user_cookie,
ide_adapter_controller_info **cookie)
{
return ide_adapter->uninit_controller( controller );
return ide_adapter->init_controller(node, user_cookie, cookie,
sizeof( ide_adapter_controller_info));
}
static void controller_removed(
pnp_node_handle node, ide_adapter_controller_info *controller )
static status_t
uninit_controller(ide_adapter_controller_info *controller)
{
return ide_adapter->controller_removed( node, controller );
return ide_adapter->uninit_controller(controller);
}
static status_t probe_controller( pnp_node_handle parent )
static void
controller_removed(device_node_handle node, ide_adapter_controller_info *controller)
{
return ide_adapter->probe_controller( parent,
return ide_adapter->controller_removed(node, controller);
}
static status_t
probe_controller(device_node_handle parent)
{
return ide_adapter->probe_controller(parent,
GENERIC_IDE_PCI_CONTROLLER_MODULE_NAME, "generic_ide_pci",
"Generic IDE PCI Controller",
GENERIC_IDE_PCI_CHANNEL_MODULE_NAME,
@ -138,8 +160,7 @@ static status_t probe_controller( pnp_node_handle parent )
1, // assume 16 bit alignment is enough
0xffff, // boundary is on 64k according to spec
0x10000, // up to 64k per S/G block according to spec
true // by default, compatibility mode is used
);
true); // by default, compatibility mode is used
}
@ -174,10 +195,10 @@ static ide_controller_interface channel_interface = {
module_std_ops
},
(status_t (*)( pnp_node_handle , void *, void ** )) init_channel,
(status_t (*)( device_node_handle , void *, void ** )) init_channel,
(status_t (*)( void * )) uninit_channel,
NULL,
(void (*)( pnp_node_handle , void * )) channel_removed
(void (*)( device_node_handle , void * )) channel_removed
},
(status_t (*)(ide_channel_cookie,
@ -198,17 +219,17 @@ static ide_controller_interface channel_interface = {
};
static pnp_driver_info controller_interface = {
static driver_module_info controller_interface = {
{
GENERIC_IDE_PCI_CONTROLLER_MODULE_NAME,
0,
module_std_ops
},
(status_t (*)( pnp_node_handle, void *, void ** )) init_controller,
(status_t (*)( device_node_handle, void *, void ** )) init_controller,
(status_t (*)( void * )) uninit_controller,
probe_controller,
(void (*)( pnp_node_handle, void * )) controller_removed
(void (*)( device_node_handle, void * )) controller_removed
};
#if !_BUILDING_kernel && !BOOT

View File

@ -56,7 +56,7 @@ typedef struct channel_info {
// be accessed anymore
ide_channel ide_channel;
pnp_node_handle node;
device_node_handle node;
} channel_info;
@ -224,7 +224,7 @@ finish_dma(void *channel)
static status_t
init_channel(pnp_node_handle node, ide_channel ide_channel, channel_info **cookie)
init_channel(device_node_handle node, ide_channel ide_channel, channel_info **cookie)
{
channel_info *channel;
isa2_module_info *isa;
@ -239,7 +239,7 @@ init_channel(pnp_node_handle node, ide_channel ide_channel, channel_info **cooki
|| pnp->get_attr_uint8(node, IDE_ISA_INTNUM, &irq, false) != B_OK)
return B_ERROR;
if (pnp->load_driver(pnp->get_parent(node), NULL, (pnp_driver_info **)&isa, &dummy) != B_OK)
if (pnp->load_driver(pnp->get_parent(node), NULL, (driver_module_info **)&isa, &dummy) != B_OK)
return B_ERROR;
channel = (channel_info *)malloc(sizeof(channel_info));
@ -303,10 +303,10 @@ uninit_channel(channel_info *channel)
// publish node of ide channel
static status_t
publish_channel(pnp_node_handle parent, io_resource_handle *resources, uint16 command_block_base,
publish_channel(device_node_handle parent, io_resource_handle *resources, uint16 command_block_base,
uint16 control_block_base, uint8 intnum, const char *name)
{
pnp_node_attr attrs[] = {
device_attr attrs[] = {
// info about ourself and our consumer
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: IDE_ISA_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: IDE_BUS_TYPE_NAME }},
@ -333,7 +333,7 @@ publish_channel(pnp_node_handle parent, io_resource_handle *resources, uint16 co
{ IDE_ISA_INTNUM, B_UINT8_TYPE, { ui8: intnum }},
{ NULL }
};
pnp_node_handle node;
device_node_handle node;
SHOW_FLOW0(2, "");
@ -343,7 +343,7 @@ publish_channel(pnp_node_handle parent, io_resource_handle *resources, uint16 co
// detect IDE channel
static status_t
probe_channel(pnp_node_handle parent,
probe_channel(device_node_handle parent,
uint16 command_block_base, uint16 control_block_base,
int intnum, const char *name)
{
@ -370,7 +370,7 @@ probe_channel(pnp_node_handle parent,
static status_t
scan_parent(pnp_node_handle node)
scan_parent(device_node_handle node)
{
SHOW_FLOW0( 3, "" );
@ -384,7 +384,7 @@ scan_parent(pnp_node_handle node)
static void
channel_removed(pnp_node_handle node, channel_info *channel)
channel_removed(device_node_handle node, channel_info *channel)
{
SHOW_FLOW0( 3, "" );
@ -425,10 +425,10 @@ ide_controller_interface isa_controller_interface = {
std_ops
},
(status_t (*)(pnp_node_handle, void *, void **)) init_channel,
(status_t (*)(device_node_handle, void *, void **)) init_channel,
(status_t (*)(void *)) uninit_channel,
scan_parent,
(void (*)(pnp_node_handle, void *)) channel_removed
(void (*)(device_node_handle, void *)) channel_removed
},
(status_t (*)(ide_channel_cookie,

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002-04, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Promise TX2 series IDE controller driver
@ -138,7 +138,7 @@ finish_dma(ide_adapter_channel_info *channel)
static status_t
init_channel(pnp_node_handle node, ide_channel ide_channel,
init_channel(device_node_handle node, ide_channel ide_channel,
ide_adapter_channel_info **cookie)
{
return ide_adapter->init_channel(node, ide_channel, cookie,
@ -153,14 +153,14 @@ uninit_channel(ide_adapter_channel_info *channel)
}
static void channel_removed(pnp_node_handle node, ide_adapter_channel_info *channel)
static void channel_removed(device_node_handle node, ide_adapter_channel_info *channel)
{
return ide_adapter->channel_removed(node, channel);
}
static status_t
init_controller(pnp_node_handle node, void *user_cookie,
init_controller(device_node_handle node, void *user_cookie,
ide_adapter_controller_info **cookie)
{
return ide_adapter->init_controller(node, user_cookie, cookie,
@ -176,7 +176,7 @@ uninit_controller(ide_adapter_controller_info *controller)
static void
controller_removed(pnp_node_handle node, ide_adapter_controller_info *controller)
controller_removed(device_node_handle node, ide_adapter_controller_info *controller)
{
return ide_adapter->controller_removed(node, controller);
}
@ -185,10 +185,10 @@ controller_removed(pnp_node_handle node, ide_adapter_controller_info *controller
// publish node of ide controller
static status_t
publish_controller(pnp_node_handle parent, uint16 bus_master_base, uint8 intnum,
io_resource_handle *resources, pnp_node_handle *node)
publish_controller(device_node_handle parent, uint16 bus_master_base, uint8 intnum,
io_resource_handle *resources, device_node_handle *node)
{
pnp_node_attr attrs[] = {
device_attr attrs[] = {
// info about ourself and our consumer
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: PROMISE_TX2_CONTROLLER_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: PROMISE_TX2_CONTROLLER_TYPE_NAME }},
@ -233,8 +233,8 @@ publish_controller(pnp_node_handle parent, uint16 bus_master_base, uint8 intnum,
static status_t
detect_controller(pci_device_module_info *pci, pci_device pci_device,
pnp_node_handle parent, uint16 bus_master_base, int8 intnum,
pnp_node_handle *node)
device_node_handle parent, uint16 bus_master_base, int8 intnum,
device_node_handle *node)
{
io_resource_handle resource_handles[2];
@ -260,20 +260,20 @@ detect_controller(pci_device_module_info *pci, pci_device pci_device,
static status_t
probe_controller(pnp_node_handle parent)
probe_controller(device_node_handle parent)
{
pci_device_module_info *pci;
pci_device device;
uint16 command_block_base[2];
uint16 control_block_base[2];
uint16 bus_master_base;
pnp_node_handle controller_node, channels[2];
device_node_handle controller_node, channels[2];
uint8 intnum;
status_t res;
SHOW_FLOW0(3, "");
if (pnp->load_driver(parent, NULL, (pnp_driver_info **)&pci, (void **)&device) != B_OK)
if (pnp->load_driver(parent, NULL, (driver_module_info **)&pci, (void **)&device) != B_OK)
return B_ERROR;
command_block_base[0] = pci->read_pci_config(device, PCI_base_registers, 4);
@ -338,10 +338,10 @@ static ide_controller_interface channel_interface = {
std_ops
},
(status_t (*)( pnp_node_handle , void *, void ** )) init_channel,
(status_t (*)( device_node_handle , void *, void ** )) init_channel,
(status_t (*)( void * )) uninit_channel,
NULL,
(void (*)( pnp_node_handle , void * )) channel_removed
(void (*)( device_node_handle , void * )) channel_removed
},
(status_t (*)(ide_channel_cookie,
@ -362,17 +362,17 @@ static ide_controller_interface channel_interface = {
};
static pnp_driver_info controller_interface = {
static driver_module_info controller_interface = {
{
PROMISE_TX2_CONTROLLER_MODULE_NAME,
0,
std_ops
},
(status_t (*)( pnp_node_handle, void *, void ** )) init_controller,
(status_t (*)( void * )) uninit_controller,
(status_t (*)(device_node_handle, void *, void **)) init_controller,
(status_t (*)(void *)) uninit_controller,
probe_controller,
(void (*)( pnp_node_handle, void * )) controller_removed
(void (*)(device_node_handle, void *)) controller_removed
};
#if !_BUILDING_kernel && !BOOT

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI raw driver.
@ -67,7 +67,7 @@ raw_write(void *cookie, off_t position, const void *data, size_t *numBytes)
}
/** !!!keep this in sync with scsi_periph module!!! */
/** !!! keep this in sync with scsi_periph module !!! */
static status_t
raw_command(raw_device_info *device, raw_device_command *cmd)
@ -93,23 +93,23 @@ raw_command(raw_device_info *device, raw_device_command *cmd)
request->sort = -1;
request->timeout = cmd->timeout;
memcpy( request->cdb, cmd->command, SCSI_MAX_CDB_SIZE );
memcpy(request->cdb, cmd->command, SCSI_MAX_CDB_SIZE);
request->cdb_len = cmd->command_length;
device->scsi->sync_io( request );
device->scsi->sync_io(request);
// TBD: should we call standard error handler here, or may the
// actions done there (like starting the unit) confuse the application?
cmd->cam_status = request->subsys_status;
cmd->scsi_status = request->device_status;
if( (request->subsys_status & SCSI_AUTOSNS_VALID) != 0 && cmd->sense_data ) {
memcpy( cmd->sense_data, request->sense,
min( cmd->sense_data_length, SCSI_MAX_SENSE_SIZE - request->sense_resid ));
if ((request->subsys_status & SCSI_AUTOSNS_VALID) != 0 && cmd->sense_data) {
memcpy(cmd->sense_data, request->sense,
min((int32)cmd->sense_data_length, SCSI_MAX_SENSE_SIZE - request->sense_resid));
}
if( (cmd->flags & B_RAW_DEVICE_REPORT_RESIDUAL) != 0 ) {
if ((cmd->flags & B_RAW_DEVICE_REPORT_RESIDUAL) != 0) {
// this is a bit strange, see Be's sample code where I pinched this from;
// normally, residual means "number of unused bytes left"
// but here, we have to return "number of used bytes", which is the opposite
@ -117,60 +117,58 @@ raw_command(raw_device_info *device, raw_device_command *cmd)
cmd->sense_data_length = SCSI_MAX_SENSE_SIZE - request->sense_resid;
}
device->scsi->free_ccb( request );
device->scsi->free_ccb(request);
return B_OK;
}
static status_t
raw_ioctl(raw_device_info *device, int op, void *buf, size_t len)
raw_ioctl(raw_device_info *device, int op, void *buffer, size_t length)
{
status_t res;
switch( op ) {
case B_RAW_DEVICE_COMMAND:
res = raw_command( device, buf );
// __asm( "int $3" : : );
break;
default:
res = B_DEV_INVALID_IOCTL;
switch (op) {
case B_RAW_DEVICE_COMMAND:
res = raw_command(device, buffer);
break;
default:
res = B_DEV_INVALID_IOCTL;
}
SHOW_FLOW( 4, "%x: %s", op, strerror( res ));
SHOW_FLOW(4, "%x: %s", op, strerror(res));
return res;
}
static status_t
raw_init_device(pnp_node_handle node, void *user_cookie, void **cookie)
raw_init_device(device_node_handle node, void *user_cookie, void **cookie)
{
raw_device_info *device;
status_t res;
SHOW_FLOW0( 3, "" );
device = (raw_device_info *)calloc( 1, sizeof( *device ));
if( device == NULL )
SHOW_FLOW0(3, "");
device = (raw_device_info *)calloc(1, sizeof(*device));
if (device == NULL)
return B_NO_MEMORY;
device->node = node;
// register it everywhere
res = pnp->load_driver( pnp->get_parent( node ), NULL,
(pnp_driver_info **)&device->scsi, (void **)&device->scsi_device );
if( res != B_OK )
// register it everywhere
res = pnp->load_driver(pnp->get_parent(node), NULL,
(driver_module_info **)&device->scsi, (void **)&device->scsi_device);
if (res != B_OK)
goto err;
SHOW_FLOW0( 3, "done" );
SHOW_FLOW0(3, "done");
*cookie = device;
return B_OK;
err:
free( device );
free(device);
return res;
}
@ -190,45 +188,41 @@ raw_uninit_device(raw_device_info *device)
*/
static status_t
raw_device_added(pnp_node_handle node)
raw_device_added(device_node_handle node)
{
char *str;
uint8 path_id, target_id, target_lun;
char name[100];
SHOW_FLOW0( 3, "" );
char *str;
SHOW_FLOW0(3, "");
// make sure we can handle this parent device
if( pnp->get_attr_string( node, PNP_DRIVER_TYPE, &str, false ) != B_OK )
if (pnp->get_attr_string(node, PNP_DRIVER_TYPE, &str, false) != B_OK)
return B_ERROR;
if( strcmp( str, SCSI_DEVICE_TYPE_NAME ) != 0 ) {
free( str );
if (strcmp(str, SCSI_DEVICE_TYPE_NAME) != 0) {
free(str);
return B_ERROR;
}
free( str );
free(str);
// compose name
if( pnp->get_attr_uint8( node,
SCSI_BUS_PATH_ID_ITEM, &path_id, true ) != B_OK ||
pnp->get_attr_uint8( node,
SCSI_DEVICE_TARGET_ID_ITEM, &target_id, true ) != B_OK ||
pnp->get_attr_uint8( node,
SCSI_DEVICE_TARGET_LUN_ITEM, &target_lun, true ) != B_OK )
if (pnp->get_attr_uint8(node, SCSI_BUS_PATH_ID_ITEM, &path_id, true) != B_OK
|| pnp->get_attr_uint8(node, SCSI_DEVICE_TARGET_ID_ITEM, &target_id, true) != B_OK
|| pnp->get_attr_uint8(node, SCSI_DEVICE_TARGET_LUN_ITEM, &target_lun, true) != B_OK)
return B_ERROR;
sprintf( name, "bus/scsi/%d/%d/%d/raw",
path_id, target_id, target_lun );
sprintf(name, "bus/scsi/%d/%d/%d/raw",
path_id, target_id, target_lun);
SHOW_FLOW( 3, "name=%s", name );
SHOW_FLOW(3, "name=%s", name);
// ready to register
{
pnp_node_attr attrs[] =
{
device_attr attrs[] = {
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: SCSI_RAW_MODULE_NAME }},
// default connection is used by peripheral drivers, and as we don't
// want to kick them out, we use concurrent "raw" connection
// (btw: this shows nicely that something goes wrong: one device
@ -244,7 +238,7 @@ raw_device_added(pnp_node_handle node)
{ NULL }
};
return pnp->register_device( node, attrs, NULL, &node );
return pnp->register_device(node, attrs, NULL, &node);
}
}
@ -281,27 +275,23 @@ pnp_devfs_driver_info scsi_raw_module = {
raw_device_added,
NULL
},
(status_t (*)( void *, uint32, void ** )) &raw_open,
(status_t (*)(void *, uint32, void **)) &raw_open,
raw_close,
raw_free,
(status_t (*)( void *, uint32, void *, size_t )) &raw_ioctl,
(status_t (*)(void *, uint32, void *, size_t)) &raw_ioctl,
raw_read,
raw_write,
NULL,
NULL,
NULL,
NULL
};
#if !_BUILDING_kernel && !BOOT
_EXPORT
module_info *modules[] =
{
module_info *modules[] = {
(module_info *)&scsi_raw_module,
NULL
};
#endif

View File

@ -1,14 +1,14 @@
/*
** Copyright 2003, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SCSI_RAW_H
#define _SCSI_RAW_H
/*
Part of Open SCSI Raw Driver
*/
#ifndef _SCSI_RAW_H
#define _SCSI_RAW_H
#include <device_manager.h>
#include <bus/SCSI.h>
@ -23,7 +23,7 @@
typedef struct raw_device_info {
pnp_node_handle node;
device_node_handle node;
scsi_device scsi_device;
scsi_device_interface *scsi;
} raw_device_info;
@ -31,4 +31,4 @@ typedef struct raw_device_info {
#define SCSI_RAW_MODULE_NAME "drivers/bus/scsi/scsi_raw/"SCSI_DEVICE_TYPE_NAME
#endif
#endif /* _SCSI_RAW_H */

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
**/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI Disk Driver
@ -17,81 +17,86 @@
#include <string.h>
status_t cd_init_device( pnp_node_handle node, void *user_cookie, void **cookie )
status_t
cd_init_device(device_node_handle node, void *user_cookie, void **cookie)
{
cd_device_info *device;
status_t res;
bool removable;
SHOW_FLOW0( 3, "" );
device = (cd_device_info *)malloc( sizeof( *device ));
if( device == NULL )
SHOW_FLOW0(3, "");
device = (cd_device_info *)malloc(sizeof(*device));
if (device == NULL)
return B_NO_MEMORY;
memset( device, 0, sizeof( *device ));
memset(device, 0, sizeof(*device));
device->blkman_device = user_cookie;
device->node = node;
res = pnp->get_attr_uint8( node, "removable",
&removable, false );
if( res != B_OK )
res = pnp->get_attr_uint8(node, "removable",
&removable, false);
if (res != B_OK)
goto err1;
device->removable = removable;
res = pnp->get_attr_uint8( node, SCSI_DEVICE_TYPE_ITEM,
&device->device_type, true );
if( res != B_OK )
res = pnp->get_attr_uint8(node, SCSI_DEVICE_TYPE_ITEM,
&device->device_type, true);
if (res != B_OK)
goto err1;
// we don't verify type - in worst case, the device doesn't work
// register it everywhere
res = pnp->load_driver( pnp->get_parent( node ), NULL, (pnp_driver_info **)&device->scsi,
(void **)&device->scsi_device );
if( res != B_OK )
res = pnp->load_driver(pnp->get_parent(node), NULL, (driver_module_info **)&device->scsi,
(void **)&device->scsi_device);
if (res != B_OK)
goto err2;
res = scsi_periph->register_device(
(periph_device_cookie)device, &callbacks, device->scsi_device,
device->scsi, device->node, removable, &device->scsi_periph_device );
if( res != B_OK )
res = scsi_periph->register_device((periph_device_cookie)device, &callbacks,
device->scsi_device, device->scsi, device->node, removable,
&device->scsi_periph_device);
if (res != B_OK)
goto err3;
// set capacity to zero, so it get checked on first opened handle
device->capacity = 0;
device->block_size = 0;
SHOW_FLOW0( 3, "done" );
SHOW_FLOW0(3, "done");
*cookie = device;
return B_OK;
err3:
pnp->unload_driver( pnp->get_parent( node ));
pnp->unload_driver(pnp->get_parent(node));
err2:
err1:
free( device );
free(device);
return res;
}
status_t cd_uninit_device( cd_device_info *device )
status_t
cd_uninit_device(cd_device_info *device)
{
scsi_periph->unregister_device( device->scsi_periph_device );
pnp->unload_driver( pnp->get_parent( device->node ));
free( device );
scsi_periph->unregister_device(device->scsi_periph_device);
pnp->unload_driver(pnp->get_parent(device->node));
free(device);
return B_OK;
}
// called whenever a new device was added to system;
// if we really support it, we create a new node that gets
// server by blkdev
status_t cd_device_added( pnp_node_handle node )
/** called whenever a new device was added to system;
* if we really support it, we create a new node that gets
* server by blkdev
*/
status_t
cd_device_added(device_node_handle node)
{
char *str = NULL;
uint8 device_type;
@ -127,20 +132,19 @@ status_t cd_device_added( pnp_node_handle node )
// using 10 byte commands, at most 0xffff blocks can be transmitted at once
// (sadly, we cannot update this value later on if only 6 byte commands
// are supported, but the blkdev can live with truncated transfers)
max_blocks = min( max_blocks, 0xffff );
name = scsi_periph->compose_device_name( node, "disk/scsi" );
if( name == NULL ) {
SHOW_ERROR0( 2, "Cannot compose device name" );
max_blocks = min(max_blocks, 0xffff);
name = scsi_periph->compose_device_name(node, "disk/scsi");
if (name == NULL) {
SHOW_ERROR0(2, "Cannot compose device name");
goto err;
}
SHOW_FLOW( 3, "name=%s", name );
SHOW_FLOW(3, "name = %s", name);
// ready to register
{
pnp_node_attr attrs[] =
{
device_attr attrs[] = {
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: SCSI_CD_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: BLKDEV_TYPE_NAME }},
// we always want blkdev on top of us
@ -155,21 +159,18 @@ status_t cd_device_added( pnp_node_handle node )
};
status_t res;
res = pnp->register_device( node, attrs, NULL, &node );
free( name );
free( str );
free( device_inquiry );
res = pnp->register_device(node, attrs, NULL, &node);
free(name);
free(str);
free(device_inquiry);
return res;
}
err:
if( str != NULL )
free( str );
if( device_inquiry != NULL )
free( device_inquiry );
free(str);
free(device_inquiry);
return B_ERROR;
}

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open IDE CD-ROM driver
@ -22,7 +22,7 @@
typedef struct cd_device_info {
pnp_node_handle node;
device_node_handle node;
scsi_periph_device scsi_periph_device;
scsi_device scsi_device;
scsi_device_interface *scsi;
@ -48,13 +48,13 @@ extern blkman_for_driver_interface *blkman;
// device_mgr.c
status_t cd_init_device( pnp_node_handle node, void *user_cookie, void **cookie );
status_t cd_uninit_device( cd_device_info *device );
status_t cd_device_added( pnp_node_handle node );
status_t cd_init_device(device_node_handle node, void *user_cookie, void **cookie);
status_t cd_uninit_device(cd_device_info *device);
status_t cd_device_added(device_node_handle node);
// handle_mgr.c
status_t cd_open( cd_device_info *device, cd_handle_info **handle_out );
status_t cd_close( cd_handle_info *handle );
status_t cd_free( cd_handle_info *handle );
status_t cd_open(cd_device_info *device, cd_handle_info **handle_out);
status_t cd_close(cd_handle_info *handle);
status_t cd_free(cd_handle_info *handle);

View File

@ -18,7 +18,7 @@
status_t
das_init_device(pnp_node_handle node, void *user_cookie, void **cookie)
das_init_device(device_node_handle node, void *user_cookie, void **cookie)
{
das_device_info *device;
status_t res;
@ -41,7 +41,7 @@ das_init_device(pnp_node_handle node, void *user_cookie, void **cookie)
goto err1;
// register it everywhere
res = pnp->load_driver(pnp->get_parent(node), NULL, (pnp_driver_info **)&device->scsi,
res = pnp->load_driver(pnp->get_parent(node), NULL, (driver_module_info **)&device->scsi,
(void **)&device->scsi_device);
if (res != B_OK)
goto err2;
@ -96,7 +96,7 @@ das_uninit_device(das_device_info *device)
*/
status_t
das_device_added(pnp_node_handle node)
das_device_added(device_node_handle node)
{
char *str = NULL;
scsi_res_inquiry *device_inquiry = NULL;
@ -140,7 +140,7 @@ das_device_added(pnp_node_handle node)
// ready to register
{
pnp_node_attr attrs[] = {
device_attr attrs[] = {
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: SCSI_DSK_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: BLKDEV_TYPE_NAME }},
// we always want blkdev on top of us

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the Haiku License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI Disk Driver
@ -24,7 +24,7 @@
typedef struct das_device_info {
pnp_node_handle node;
device_node_handle node;
scsi_periph_device scsi_periph_device;
scsi_device scsi_device;
scsi_device_interface *scsi;
@ -49,9 +49,9 @@ extern blkman_for_driver_interface *blkman;
// device_mgr.c
status_t das_init_device(pnp_node_handle node, void *user_cookie, void **cookie);
status_t das_init_device(device_node_handle node, void *user_cookie, void **cookie);
status_t das_uninit_device(das_device_info *device);
status_t das_device_added(pnp_node_handle node);
status_t das_device_added(device_node_handle node);
// handle_mgr.c

View File

@ -140,7 +140,7 @@ err:
static status_t
store_bios_drive_in_node(blkman_device_info *device)
{
pnp_node_attr attribute = {
device_attr attribute = {
BLKDEV_BIOS_ID, B_UINT8_TYPE, { ui8:
device->bios_drive != NULL ? device->bios_drive->bios_id : 0 }
};
@ -340,7 +340,7 @@ blkman_ioctl(blkman_handle_info *handle, uint32 op, void *buf, size_t len)
static status_t
blkman_probe(pnp_node_handle parent)
blkman_probe(device_node_handle parent)
{
char *str;
@ -359,8 +359,7 @@ blkman_probe(pnp_node_handle parent)
// ready to register at devfs
{
pnp_node_attr attrs[] =
{
device_attr attrs[] = {
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: BLKMAN_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: PNP_DEVFS_TYPE_NAME }},
// we always want devfs on top of us
@ -369,7 +368,7 @@ blkman_probe(pnp_node_handle parent)
{ NULL }
};
pnp_node_handle node;
device_node_handle node;
return pnp->register_device(parent, attrs, NULL, &node);
}
@ -377,7 +376,7 @@ blkman_probe(pnp_node_handle parent)
static void
blkman_remove(pnp_node_handle node, void *cookie)
blkman_remove(device_node_handle node, void *cookie)
{
uint8 bios_id;
//bios_drive *drive;
@ -403,15 +402,13 @@ blkman_remove(pnp_node_handle node, void *cookie)
static status_t
blkman_init_device(pnp_node_handle node, void *user_cookie, void **cookie)
blkman_init_device(device_node_handle node, void *user_cookie, void **cookie)
{
blkman_device_info *device;
blkdev_params params;
char *name, *tmp_name;
uint8 is_bios_drive;
status_t res;
// blkdev_interface *interface;
// blkdev_device_cookie dev_cookie;
TRACE(("blkman_init_device()\n"));
@ -509,7 +506,7 @@ blkman_init_device(pnp_node_handle node, void *user_cookie, void **cookie)
device->is_bios_drive = is_bios_drive != 0;
res = pnp->load_driver(pnp->get_parent(node), device,
(pnp_driver_info **)&device->interface, (void **)&device->cookie);
(driver_module_info **)&device->interface, (void **)&device->cookie);
if (res != B_OK)
goto err4;
@ -683,7 +680,7 @@ blkman_for_driver_interface blkman_for_driver_module = {
};
module_info *modules[] = {
&blkman_module.dinfo.minfo,
&blkman_module.info.info,
&blkman_for_driver_module.minfo,
NULL
};

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open block device manager
@ -32,7 +32,7 @@ typedef struct blkdev_params {
// device info
typedef struct blkman_device_info {
pnp_node_handle node;
device_node_handle node;
blkdev_interface *interface;
blkdev_device_cookie cookie;
@ -80,11 +80,11 @@ extern device_manager_info *pnp;
// io.c
status_t blkman_readv( blkman_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, size_t *len );
status_t blkman_read( blkman_handle_info *handle, off_t pos, void *buf, size_t *len );
ssize_t blkman_writev( blkman_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, ssize_t *len );
ssize_t blkman_write( blkman_handle_info *handle, off_t pos, void *buf, size_t *len );
void blkman_set_media_params( blkman_device_info *device,
uint32 block_size, uint32 ld_block_size, uint64 capacity );
status_t blkman_readv(blkman_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, size_t *len);
status_t blkman_read(blkman_handle_info *handle, off_t pos, void *buf, size_t *len);
ssize_t blkman_writev(blkman_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, ssize_t *len);
ssize_t blkman_write(blkman_handle_info *handle, off_t pos, void *buf, size_t *len);
void blkman_set_media_params(blkman_device_info *device,
uint32 block_size, uint32 ld_block_size, uint64 capacity);

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open block device manager
@ -31,6 +31,7 @@
#include "blkman_int.h"
#include "KernelExport_ext.h"
#include <thread_types.h>
/** get sg list of iovecs, taking dma boundaries and maximum size of
@ -661,7 +662,7 @@ blkman_readwritev(blkman_handle_info *handle, off_t pos, struct iovec *vec,
status_t
blkman_readv(blkman_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, size_t *len)
{
{
/* SHOW_FLOW( 4, "len=%d", (int)*len );
for( cur_vec = vec, left = vec_count; left > 0; ++cur_vec, --left ) {
@ -683,8 +684,11 @@ blkman_read(blkman_handle_info *handle, off_t pos, void *buf, size_t *len)
SHOW_FLOW0( 3, "" );
// TBD: this assumes that the thread stack is not paged,
// else you want to use blkman_readv
// This assumes that the thread stack is not paged,
// else you want to use blkman_readv
// But this is not a problem, since kernel stacks
// are always paged in (since they can be used by
// an interrupt at any time)
return blkman_readv_int(handle, pos, vec, 1, len, true);
}

View File

@ -104,7 +104,7 @@ uint32 fast_log_buffer_offset_alloc;
// offset of end of last write
uint32 fast_log_buffer_offset_filled;
// size of one half of log buffer
int fast_log_buffer_size = /*512*/ 32*1024;
int fast_log_buffer_size = /*512*/ 16*1024;
// ToDo: cut down because of current allocator...

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Fast logging facilities.
@ -23,7 +23,7 @@
// Devfs node
pnp_node_handle fast_log_devfs_node;
device_node_handle fast_log_devfs_node;
static status_t
@ -80,7 +80,7 @@ static status_t
fast_log_create_devfs_entry(void)
{
status_t res;
pnp_node_attr attrs[] = {
device_attr attrs[] = {
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: FAST_LOG_DEVFS_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: PNP_DEVFS_TYPE_NAME }},
{ PNP_DRIVER_FIXED_CONSUMER, B_STRING_TYPE, { string: PNP_DEVFS_MODULE_NAME }},
@ -99,7 +99,7 @@ fast_log_create_devfs_entry(void)
static status_t
fast_log_devfs_init_device(pnp_node_handle node, void *user_cookie, void **cookie)
fast_log_devfs_init_device(device_node_handle node, void *user_cookie, void **cookie)
{
*cookie = NULL;
return B_OK;

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002-04, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Generic IDE adapter library.
@ -133,7 +133,7 @@ ide_adapter_write_pio(ide_adapter_channel_info *channel, uint16 *data,
if ((count & 1) != 0 || force_16bit) {
for (; count > 0; --count)
pci->write_io_16( device, ioaddr, *(data++));
pci->write_io_16(device, ioaddr, *(data++));
} else {
uint32 *cur_data = (uint32 *)data;
@ -316,7 +316,7 @@ ide_adapter_finish_dma(ide_adapter_channel_info *channel)
static status_t
ide_adapter_init_channel(pnp_node_handle node, ide_channel ide_channel,
ide_adapter_init_channel(device_node_handle node, ide_channel ide_channel,
ide_adapter_channel_info **cookie, size_t total_data_size,
int32 (*inthand)(void *arg))
{
@ -420,7 +420,7 @@ ide_adapter_uninit_channel(ide_adapter_channel_info *channel)
static void
ide_adapter_channel_removed(pnp_node_handle node, ide_adapter_channel_info *channel)
ide_adapter_channel_removed(device_node_handle node, ide_adapter_channel_info *channel)
{
SHOW_FLOW0( 3, "" );
@ -433,13 +433,13 @@ ide_adapter_channel_removed(pnp_node_handle node, ide_adapter_channel_info *chan
/** publish node of ide channel */
static status_t
ide_adapter_publish_channel(pnp_node_handle controller_node,
ide_adapter_publish_channel(device_node_handle controller_node,
const char *channel_module_name, uint16 command_block_base,
uint16 control_block_base, uint8 intnum, bool can_dma,
bool is_primary, const char *name, io_resource_handle *resources,
pnp_node_handle *node)
device_node_handle *node)
{
pnp_node_attr attrs[] = {
device_attr attrs[] = {
// info about ourself and our consumer
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: channel_module_name }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: IDE_BUS_TYPE_NAME }},
@ -469,10 +469,10 @@ ide_adapter_publish_channel(pnp_node_handle controller_node,
static status_t
ide_adapter_detect_channel(pci_device_module_info *pci, pci_device pci_device,
pnp_node_handle controller_node, const char *channel_module_name,
device_node_handle controller_node, const char *channel_module_name,
bool controller_can_dma, uint16 command_block_base, uint16 control_block_base,
uint16 bus_master_base, uint8 intnum, bool is_primary, const char *name,
pnp_node_handle *node, bool supports_compatibility_mode)
device_node_handle *node, bool supports_compatibility_mode)
{
uint8 api;
ide_bm_status status;
@ -545,7 +545,7 @@ ide_adapter_detect_channel(pci_device_module_info *pci, pci_device pci_device,
static status_t
ide_adapter_init_controller(pnp_node_handle node, void *user_cookie,
ide_adapter_init_controller(device_node_handle node, void *user_cookie,
ide_adapter_controller_info **cookie, size_t total_data_size)
{
pci_device_module_info *pci;
@ -557,7 +557,7 @@ ide_adapter_init_controller(pnp_node_handle node, void *user_cookie,
if (pnp->get_attr_uint16(node, IDE_ADAPTER_BUS_MASTER_BASE, &bus_master_base, false) != B_OK)
return B_ERROR;
if (pnp->load_driver(pnp->get_parent(node), NULL, (pnp_driver_info **)&pci, (void **)&device) != B_OK)
if (pnp->load_driver(pnp->get_parent(node), NULL, (driver_module_info **)&pci, (void **)&device) != B_OK)
return B_ERROR;
controller = (ide_adapter_controller_info *)malloc(total_data_size);
@ -588,7 +588,7 @@ ide_adapter_uninit_controller(ide_adapter_controller_info *controller)
static void
ide_adapter_controller_removed(pnp_node_handle node, ide_adapter_controller_info *controller)
ide_adapter_controller_removed(device_node_handle node, ide_adapter_controller_info *controller)
{
SHOW_FLOW0( 3, "" );
@ -601,13 +601,13 @@ ide_adapter_controller_removed(pnp_node_handle node, ide_adapter_controller_info
/** publish node of ide controller */
static status_t
ide_adapter_publish_controller(pnp_node_handle parent, uint16 bus_master_base,
ide_adapter_publish_controller(device_node_handle parent, uint16 bus_master_base,
io_resource_handle *resources, const char *controller_driver,
const char *controller_driver_type, const char *controller_name, bool can_dma,
bool can_cq, uint32 dma_alignment, uint32 dma_boundary, uint32 max_sg_block_size,
pnp_node_handle *node)
device_node_handle *node)
{
pnp_node_attr attrs[] = {
device_attr attrs[] = {
// info about ourself and our consumer
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: controller_driver }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: controller_driver_type }},
@ -652,10 +652,10 @@ ide_adapter_publish_controller(pnp_node_handle parent, uint16 bus_master_base,
static status_t
ide_adapter_detect_controller(pci_device_module_info *pci, pci_device pci_device,
pnp_node_handle parent, uint16 bus_master_base, const char *controller_driver,
device_node_handle parent, uint16 bus_master_base, const char *controller_driver,
const char *controller_driver_type, const char *controller_name, bool can_dma,
bool can_cq, uint32 dma_alignment, uint32 dma_boundary, uint32 max_sg_block_size,
pnp_node_handle *node)
device_node_handle *node)
{
io_resource_handle resource_handles[2];
@ -683,7 +683,7 @@ ide_adapter_detect_controller(pci_device_module_info *pci, pci_device pci_device
static status_t
ide_adapter_probe_controller(pnp_node_handle parent, const char *controller_driver,
ide_adapter_probe_controller(device_node_handle parent, const char *controller_driver,
const char *controller_driver_type, const char *controller_name,
const char *channel_module_name, bool can_dma, bool can_cq, uint32 dma_alignment,
uint32 dma_boundary, uint32 max_sg_block_size, bool supports_compatibility_mode)
@ -693,13 +693,13 @@ ide_adapter_probe_controller(pnp_node_handle parent, const char *controller_driv
uint16 command_block_base[2];
uint16 control_block_base[2];
uint16 bus_master_base;
pnp_node_handle controller_node, channels[2];
device_node_handle controller_node, channels[2];
uint8 intnum;
status_t res;
SHOW_FLOW0( 3, "" );
if (pnp->load_driver(parent, NULL, (pnp_driver_info **)&pci, (void **)&device) != B_OK)
if (pnp->load_driver(parent, NULL, (driver_module_info **)&pci, (void **)&device) != B_OK)
return B_ERROR;
command_block_base[0] = pci->read_pci_config(device, PCI_base_registers, 4 );
@ -801,7 +801,7 @@ static ide_adapter_interface adapter_interface = {
#if !_BUILDING_kernel && !BOOT
_EXPORT
module_info *modules[] = {
&adapter_interface.minfo,
&adapter_interface.info,
NULL
};
#endif

View File

@ -43,15 +43,15 @@
#endif
#ifndef debug_level_flow
# define debug_level_flow 3
# define debug_level_flow 4
#endif
#ifndef debug_level_info
# define debug_level_info 2
# define debug_level_info 4
#endif
#ifndef debug_level_error
# define debug_level_error 1
# define debug_level_error 4
#endif
#define FUNC_NAME DEBUG_MSG_PREFIX __FUNCTION__ ": "

View File

@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI Peripheral Driver
@ -22,7 +22,7 @@
char *
periph_compose_device_name(pnp_node_handle node, const char *prefix)
periph_compose_device_name(device_node_handle node, const char *prefix)
{
uint8 path_id, target_id, target_lun;
@ -42,7 +42,7 @@ periph_compose_device_name(pnp_node_handle node, const char *prefix)
status_t
periph_register_device(periph_device_cookie periph_device, scsi_periph_callbacks *callbacks,
scsi_device scsi_device, scsi_device_interface *scsi, pnp_node_handle node,
scsi_device scsi_device, scsi_device_interface *scsi, device_node_handle node,
bool removable, scsi_periph_device *driver)
{
scsi_periph_device_info *device;

View File

@ -1,11 +1,11 @@
/*
** Copyright 2002, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2002, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __SCSI_PERIPH_INT_H__
#define __SCSI_PERIPH_INT_H__
#include <stddef.h>
#include <bus/scsi/scsi_periph.h>
#include <blkman.h>
@ -19,7 +19,7 @@ typedef struct scsi_periph_device_info {
scsi_device scsi_device;
scsi_device_interface *scsi;
periph_device_cookie periph_device;
pnp_node_handle node;
device_node_handle node;
bool removal_requested;
@ -78,9 +78,9 @@ status_t periph_check_capacity(scsi_periph_device_info *device, scsi_ccb *ccb);
status_t periph_register_device(periph_device_cookie periph_device,
scsi_periph_callbacks *callbacks, scsi_device scsi_device, scsi_device_interface *scsi,
pnp_node_handle node, bool removable, scsi_periph_device *driver);
device_node_handle node, bool removable, scsi_periph_device *driver);
status_t periph_unregister_device(scsi_periph_device_info *driver);
char *periph_compose_device_name(pnp_node_handle device_node, const char *prefix);
char *periph_compose_device_name(device_node_handle device_node, const char *prefix);
// io.c
@ -107,4 +107,4 @@ status_t periph_simple_exec(scsi_periph_device_info *device, void *cdb,
status_t periph_get_icon(icon_type type, device_icon *data);
#endif
#endif /* __SCSI_PERIPH_INT_H__ */

View File

@ -1,10 +1,12 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
Part of Device Manager
Node attributes handling.
*/
@ -22,7 +24,7 @@ static bool is_fixed_attribute(const char *name);
status_t
pnp_get_attr_uint8(pnp_node_handle node, const char *name,
pnp_get_attr_uint8(device_node_handle node, const char *name,
uint8 *value, bool recursive)
{
status_t status;
@ -36,10 +38,10 @@ pnp_get_attr_uint8(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_uint8_nolock(pnp_node_handle node, const char *name,
pnp_get_attr_uint8_nolock(device_node_handle node, const char *name,
uint8 *value, bool recursive)
{
pnp_node_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_UINT8_TYPE);
device_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_UINT8_TYPE);
if (attr == NULL)
return B_NAME_NOT_FOUND;
@ -49,7 +51,7 @@ pnp_get_attr_uint8_nolock(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_uint16(pnp_node_handle node, const char *name,
pnp_get_attr_uint16(device_node_handle node, const char *name,
uint16 *value, bool recursive)
{
status_t status;
@ -63,10 +65,10 @@ pnp_get_attr_uint16(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_uint16_nolock(pnp_node_handle node, const char *name,
pnp_get_attr_uint16_nolock(device_node_handle node, const char *name,
uint16 *value, bool recursive)
{
pnp_node_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_UINT16_TYPE);
device_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_UINT16_TYPE);
if (attr == NULL)
return B_NAME_NOT_FOUND;
@ -76,7 +78,7 @@ pnp_get_attr_uint16_nolock(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_uint32(pnp_node_handle node, const char *name,
pnp_get_attr_uint32(device_node_handle node, const char *name,
uint32 *value, bool recursive)
{
status_t status;
@ -90,10 +92,10 @@ pnp_get_attr_uint32(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_uint32_nolock(pnp_node_handle node, const char *name,
pnp_get_attr_uint32_nolock(device_node_handle node, const char *name,
uint32 *value, bool recursive)
{
pnp_node_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_UINT32_TYPE);
device_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_UINT32_TYPE);
if (attr == NULL)
return B_NAME_NOT_FOUND;
@ -103,7 +105,7 @@ pnp_get_attr_uint32_nolock(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_uint64(pnp_node_handle node, const char *name,
pnp_get_attr_uint64(device_node_handle node, const char *name,
uint64 *value, bool recursive)
{
status_t status;
@ -117,10 +119,10 @@ pnp_get_attr_uint64(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_uint64_nolock(pnp_node_handle node, const char *name,
pnp_get_attr_uint64_nolock(device_node_handle node, const char *name,
uint64 *value, bool recursive)
{
pnp_node_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_UINT64_TYPE);
device_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_UINT64_TYPE);
if (attr == NULL)
return B_NAME_NOT_FOUND;
@ -130,7 +132,7 @@ pnp_get_attr_uint64_nolock(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_string(pnp_node_handle node, const char *name,
pnp_get_attr_string(device_node_handle node, const char *name,
char **value, bool recursive)
{
status_t status;
@ -152,10 +154,10 @@ pnp_get_attr_string(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_string_nolock(pnp_node_handle node, const char *name,
pnp_get_attr_string_nolock(device_node_handle node, const char *name,
const char **value, bool recursive)
{
pnp_node_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_STRING_TYPE);
device_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_STRING_TYPE);
if (attr == NULL)
return B_NAME_NOT_FOUND;
@ -165,7 +167,7 @@ pnp_get_attr_string_nolock(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_raw(pnp_node_handle node, const char *name,
pnp_get_attr_raw(device_node_handle node, const char *name,
void **data, size_t *len, bool recursive)
{
const void *orig_data;
@ -191,10 +193,10 @@ pnp_get_attr_raw(pnp_node_handle node, const char *name,
status_t
pnp_get_attr_raw_nolock(pnp_node_handle node, const char *name,
pnp_get_attr_raw_nolock(device_node_handle node, const char *name,
const void **data, size_t *len, bool recursive)
{
pnp_node_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_RAW_TYPE);
device_attr_info *attr = pnp_find_attr_nolock(node, name, recursive, B_RAW_TYPE);
if (attr == NULL)
return B_NAME_NOT_FOUND;
@ -207,7 +209,7 @@ pnp_get_attr_raw_nolock(pnp_node_handle node, const char *name,
// free node attribute
void
pnp_free_node_attr(pnp_node_attr_info *attr)
pnp_free_node_attr(device_attr_info *attr)
{
free((char *)attr->attr.name);
@ -227,9 +229,9 @@ pnp_free_node_attr(pnp_node_attr_info *attr)
// duplicate node attribute
status_t
pnp_duplicate_node_attr(const pnp_node_attr *src, pnp_node_attr_info **dest_out)
pnp_duplicate_node_attr(const device_attr *src, device_attr_info **dest_out)
{
pnp_node_attr_info *dest;
device_attr_info *dest;
status_t res;
dest = malloc(sizeof(*dest));
@ -286,9 +288,9 @@ err:
// public: get first/next attribute of node
status_t
pnp_get_next_attr(pnp_node_handle node, pnp_node_attr_handle *attr)
pnp_get_next_attr(device_node_handle node, device_attr_handle *attr)
{
pnp_node_attr_info *next;
device_attr_info *next;
benaphore_lock(&gNodeLock);
@ -314,7 +316,7 @@ pnp_get_next_attr(pnp_node_handle node, pnp_node_attr_handle *attr)
// public: release attribute of node explicitely
status_t
pnp_release_attr(pnp_node_handle node,pnp_node_attr_handle attr)
pnp_release_attr(device_node_handle node, device_attr_handle attr)
{
benaphore_lock(&gNodeLock);
@ -329,7 +331,7 @@ pnp_release_attr(pnp_node_handle node,pnp_node_attr_handle attr)
// public: retrieve data of attribute
status_t
pnp_retrieve_attr(pnp_node_attr_handle attr, const pnp_node_attr **attr_content)
pnp_retrieve_attr(device_attr_handle attr, const device_attr **attr_content)
{
*attr_content = &attr->attr;
return B_OK;
@ -340,7 +342,7 @@ pnp_retrieve_attr(pnp_node_attr_handle attr, const pnp_node_attr **attr_content)
// node_lock must be hold
void
pnp_remove_attr_int(pnp_node_handle node, pnp_node_attr_info *attr)
pnp_remove_attr_int(device_node_handle node, device_attr_info *attr)
{
REMOVE_DL_LIST(attr, node->attributes, );
@ -352,9 +354,9 @@ pnp_remove_attr_int(pnp_node_handle node, pnp_node_attr_info *attr)
// public: remove attribute from node
status_t
pnp_remove_attr(pnp_node_handle node, const char *name)
pnp_remove_attr(device_node_handle node, const char *name)
{
pnp_node_attr_info *attr;
device_attr_info *attr;
// don't remove holy attributes
if (is_fixed_attribute(name))
@ -378,9 +380,9 @@ pnp_remove_attr(pnp_node_handle node, const char *name)
// public: modify attribute's content
status_t
pnp_write_attr(pnp_node_handle node, const pnp_node_attr *attr)
pnp_write_attr(device_node_handle node, const device_attr *attr)
{
pnp_node_attr_info *old_attr, *new_attr;
device_attr_info *old_attr, *new_attr;
status_t res;
// don't touch holy attributes
@ -423,7 +425,7 @@ pnp_write_attr(pnp_node_handle node, const pnp_node_attr *attr)
if (node->attributes == NULL) {
ADD_DL_LIST_HEAD(new_attr, node->attributes, );
} else {
pnp_node_attr_info *last_attr;
device_attr_info *last_attr;
for (last_attr = node->attributes; last_attr->next != NULL; last_attr = last_attr->next)
;
@ -465,12 +467,12 @@ is_fixed_attribute(const char *name)
// same as pnp_find_attr(), but node_lock must be hold and is never released
pnp_node_attr_info *
pnp_find_attr_nolock(pnp_node_handle node, const char *name,
bool recursive, type_code type )
device_attr_info *
pnp_find_attr_nolock(device_node_handle node, const char *name,
bool recursive, type_code type)
{
do {
pnp_node_attr_info *attr;
device_attr_info *attr;
for (attr = node->attributes; attr != NULL; attr = attr->next) {
if (type != B_ANY_TYPE && attr->attr.type != type)

View File

@ -1,12 +1,12 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
**
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
Part of Device Manager
Main file.
*/
@ -26,7 +26,7 @@
#endif
pnp_node_info *node_list;
device_node_info *gNodeList;
bool disable_useraddons;
@ -63,7 +63,10 @@ std_ops(int32 op, ...)
// ToDo: the device manager exports these for now, so that Thomas's driver
// can work on both R5 and OpenBeOS without too much hassle
// can work on both R5 and Haiku without too much hassle.
// We might also want to keep it in order to have the possibility to make
// substantial changes without breaking compatibility, and eventually
// separate it from the kernel for whatever reason.
device_manager_info gDeviceManagerModule = {
{
@ -142,10 +145,10 @@ device_manager_init(struct kernel_args *args)
{
// dump root node
pnp_node_info *node = node_list;
device_node_info *node = gNodeList;
while (node && node->parent != NULL)
node = node->parent;
dump_pnp_node_info(node, 0);
dump_device_node_info(node, 0);
}
// build initial device tree; register all root bus_managers

View File

@ -1,7 +1,9 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the Haiku License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-04, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
#ifndef DEVICE_MANAGER_PRIVATE
#define DEVICE_MANAGER_PRIVATE
@ -43,29 +45,26 @@ typedef struct id_generator {
// info about a node attribute
typedef struct pnp_node_attr_info {
struct pnp_node_attr_info *prev, *next;
int ref_count; // reference count
pnp_node_attr attr;
} pnp_node_attr_info;
typedef struct device_attr_info {
struct device_attr_info *prev, *next;
int32 ref_count; // reference count
device_attr attr;
} device_attr_info;
// I/O resource
typedef struct io_resource_info {
struct io_resource_info *prev, *next;
pnp_node_info *owner; // associated node; NULL for temporary allocation
io_resource resource; // info about actual resource
device_node_info *owner; // associated node; NULL for temporary allocation
io_resource resource; // info about actual resource
} io_resource_info;
extern status_t id_generator_init(void);
extern status_t nodes_init(void);
// global lock
// whenever you do something in terms of nodes, grab it
extern benaphore gNodeLock;
// list of nodes (includes removed devices!)
extern pnp_node_info *node_list;
extern device_node_info *gNodeList;
// true, if user addons are disabled via safemode
extern bool disable_useraddons;
@ -88,42 +87,46 @@ extern io_resource_info *io_mem_list, *io_port_list, *isa_dma_list;
int pnp_fs_emulation_nesting;
#ifdef __cplusplus
extern "C" {
#endif
// attributes.c
pnp_node_attr_info *pnp_find_attr_nolock(pnp_node_handle node, const char *name,
device_attr_info *pnp_find_attr_nolock(device_node_handle node, const char *name,
bool recursive, type_code type);
status_t pnp_get_attr_uint8(pnp_node_handle node, const char *name,
status_t pnp_get_attr_uint8(device_node_handle node, const char *name,
uint8 *value, bool recursive);
status_t pnp_get_attr_uint8_nolock(pnp_node_handle node, const char *name,
status_t pnp_get_attr_uint8_nolock(device_node_handle node, const char *name,
uint8 *value, bool recursive);
status_t pnp_get_attr_uint16(pnp_node_handle node, const char *name,
status_t pnp_get_attr_uint16(device_node_handle node, const char *name,
uint16 *value, bool recursive);
status_t pnp_get_attr_uint16_nolock(pnp_node_handle node, const char *name,
status_t pnp_get_attr_uint16_nolock(device_node_handle node, const char *name,
uint16 *value, bool recursive);
status_t pnp_get_attr_uint32(pnp_node_handle node, const char *name,
status_t pnp_get_attr_uint32(device_node_handle node, const char *name,
uint32 *value, bool recursive);
status_t pnp_get_attr_uint32_nolock(pnp_node_handle node, const char *name,
status_t pnp_get_attr_uint32_nolock(device_node_handle node, const char *name,
uint32 *value, bool recursive);
status_t pnp_get_attr_uint64(pnp_node_handle node, const char *name,
status_t pnp_get_attr_uint64(device_node_handle node, const char *name,
uint64 *value, bool recursive);
status_t pnp_get_attr_uint64_nolock(pnp_node_handle node, const char *name,
status_t pnp_get_attr_uint64_nolock(device_node_handle node, const char *name,
uint64 *value, bool recursive);
status_t pnp_get_attr_string(pnp_node_handle node, const char *name,
status_t pnp_get_attr_string(device_node_handle node, const char *name,
char **value, bool recursive);
status_t pnp_get_attr_string_nolock(pnp_node_handle node, const char *name,
status_t pnp_get_attr_string_nolock(device_node_handle node, const char *name,
const char **value, bool recursive);
status_t pnp_get_attr_raw(pnp_node_handle node, const char *name,
status_t pnp_get_attr_raw(device_node_handle node, const char *name,
void **data, size_t *len, bool recursive);
status_t pnp_get_attr_raw_nolock(pnp_node_handle node, const char *name,
status_t pnp_get_attr_raw_nolock(device_node_handle node, const char *name,
const void **data, size_t *len, bool recursive);
void pnp_free_node_attr(pnp_node_attr_info *attr);
status_t pnp_duplicate_node_attr(const pnp_node_attr *src, pnp_node_attr_info **dest_out);
status_t pnp_get_next_attr(pnp_node_handle node, pnp_node_attr_handle *attr);
status_t pnp_release_attr(pnp_node_handle node, pnp_node_attr_handle attr);
status_t pnp_retrieve_attr(pnp_node_attr_handle attr, const pnp_node_attr **attr_content);
status_t pnp_write_attr(pnp_node_handle node, const pnp_node_attr *attr);
void pnp_remove_attr_int(pnp_node_handle node, pnp_node_attr_info *attr);
status_t pnp_remove_attr(pnp_node_handle node, const char *name);
void pnp_free_node_attr(device_attr_info *attr);
status_t pnp_duplicate_node_attr(const device_attr *src, device_attr_info **dest_out);
status_t pnp_get_next_attr(device_node_handle node, device_attr_handle *attr);
status_t pnp_release_attr(device_node_handle node, device_attr_handle attr);
status_t pnp_retrieve_attr(device_attr_handle attr, const device_attr **attr_content);
status_t pnp_write_attr(device_node_handle node, const device_attr *attr);
void pnp_remove_attr_int(device_node_handle node, device_attr_info *attr);
status_t pnp_remove_attr(device_node_handle node, const char *name);
// boot_hack.c
@ -140,76 +143,78 @@ struct dirent *pnp_boot_safe_readdir( DIR *dirp );
// driver_loader.c
status_t pnp_load_driver(pnp_node_handle node, void *user_cookie,
pnp_driver_info **interface, void **cookie);
status_t pnp_unload_driver(pnp_node_handle node);
void pnp_unblock_load(pnp_node_info *node);
void pnp_load_driver_automatically(pnp_node_info *node, bool after_rescan);
void pnp_unload_driver_automatically(pnp_node_info *node, bool before_rescan);
status_t pnp_load_driver(device_node_handle node, void *user_cookie,
driver_module_info **interface, void **cookie);
status_t pnp_unload_driver(device_node_handle node);
void pnp_unblock_load(device_node_info *node);
void pnp_load_driver_automatically(device_node_info *node, bool after_rescan);
void pnp_unload_driver_automatically(device_node_info *node, bool before_rescan);
// id_generator.c
int32 pnp_create_id(const char *name);
status_t pnp_free_id(const char *name, uint32 id);
extern status_t id_generator_init(void);
// io_resources.c
status_t pnp_acquire_io_resources(io_resource *resources, io_resource_handle *handles);
status_t pnp_release_io_resources(const io_resource_handle *handles);
void pnp_assign_io_resources(pnp_node_info *node, const io_resource_handle *handles);
void pnp_release_node_resources(pnp_node_info *node);
void pnp_assign_io_resources(device_node_info *node, const io_resource_handle *handles);
void pnp_release_node_resources(device_node_info *node);
// nodes.c
status_t pnp_alloc_node(const pnp_node_attr *attrs, const io_resource_handle *resources,
pnp_node_info **new_node);
void pnp_create_node_links(pnp_node_info *node, pnp_node_info *parent);
void pnp_add_node_ref(pnp_node_info *node);
void pnp_remove_node_ref(pnp_node_info *node);
void pnp_remove_node_ref_nolock(pnp_node_info *node);
pnp_node_handle pnp_find_device(pnp_node_handle parent, const pnp_node_attr *attrs);
pnp_node_handle pnp_get_parent(pnp_node_handle node);
void dump_pnp_node_info(pnp_node_info *node, int32 level);
status_t pnp_alloc_node(const device_attr *attrs, const io_resource_handle *resources,
device_node_info **new_node);
void pnp_create_node_links(device_node_info *node, device_node_info *parent);
void pnp_add_node_ref(device_node_info *node);
void pnp_remove_node_ref(device_node_info *node);
void pnp_remove_node_ref_nolock(device_node_info *node);
device_node_handle pnp_find_device(device_node_handle parent, const device_attr *attrs);
device_node_handle pnp_get_parent(device_node_handle node);
void dump_device_node_info(device_node_info *node, int32 level);
extern status_t nodes_init(void);
// notifications.c
status_t pnp_notify_probe_by_module(pnp_node_info *node,
status_t pnp_notify_probe_by_module(device_node_info *node,
const char *consumer_name);
void pnp_notify_unregistration(pnp_node_info *notify_list);
void pnp_start_hook_call(pnp_node_info *node);
void pnp_start_hook_call_nolock(pnp_node_info *node);
void pnp_finish_hook_call(pnp_node_info *node);
void pnp_finish_hook_call_nolock(pnp_node_info *node);
void pnp_notify_unregistration(device_node_info *notify_list);
void pnp_start_hook_call(device_node_info *node);
void pnp_start_hook_call_nolock(device_node_info *node);
void pnp_finish_hook_call(device_node_info *node);
void pnp_finish_hook_call_nolock(device_node_info *node);
// patterns.c
status_t pnp_expand_pattern(pnp_node_info *node, const char *pattern,
status_t pnp_expand_pattern(device_node_info *node, const char *pattern,
char *dest, char *buffer, size_t *term_array, int *num_parts);
status_t pnp_expand_pattern_attr(pnp_node_info *node, const char *attr_name,
status_t pnp_expand_pattern_attr(device_node_info *node, const char *attr_name,
char **expanded);
// probe.c
status_t pnp_notify_fixed_consumers(pnp_node_handle node);
status_t pnp_notify_dynamic_consumers(pnp_node_info *node);
status_t pnp_notify_fixed_consumers(device_node_handle node);
status_t pnp_notify_dynamic_consumers(device_node_info *node);
// registration.c
status_t pnp_register_device(pnp_node_handle parent, const pnp_node_attr *attrs,
const io_resource_handle *resources, pnp_node_handle *node);
status_t pnp_unregister_device(pnp_node_handle node);
void pnp_unregister_node_rec(pnp_node_info *node, pnp_node_info **dependency_list);
void pnp_unref_unregistered_nodes(pnp_node_info *node_list);
void pnp_defer_probing_of_children_nolock(pnp_node_info *node);
void pnp_defer_probing_of_children(pnp_node_info *node);
void pnp_probe_waiting_children_nolock(pnp_node_info *node);
void pnp_probe_waiting_children(pnp_node_info *node);
status_t pnp_register_device(device_node_handle parent, const device_attr *attrs,
const io_resource_handle *resources, device_node_handle *node);
status_t pnp_unregister_device(device_node_handle node);
void pnp_unregister_node_rec(device_node_info *node, device_node_info **dependency_list);
void pnp_unref_unregistered_nodes(device_node_info *node_list);
void pnp_defer_probing_of_children_nolock(device_node_info *node);
void pnp_defer_probing_of_children(device_node_info *node);
void pnp_probe_waiting_children_nolock(device_node_info *node);
void pnp_probe_waiting_children(device_node_info *node);
// root_node.c
@ -219,9 +224,13 @@ extern void pnp_root_rescan_root(void);
// scan.c
status_t pnp_rescan(pnp_node_handle node, uint depth);
status_t pnp_rescan_int(pnp_node_info *node, uint depth,
status_t pnp_rescan(device_node_handle node, uint32 depth);
status_t pnp_rescan_int(device_node_info *node, uint32 depth,
bool ignore_fixed_consumers);
status_t pnp_initial_scan(pnp_node_info *node);
status_t pnp_initial_scan(device_node_info *node);
#ifdef __cplusplus
}
#endif
#endif /* DEVICE_MANAGER_PRIVATE_H */

View File

@ -1,12 +1,14 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
Part of Device Manager
PnP Driver loader.
device driver loader.
*/
#include "device_manager_private.h"
@ -30,7 +32,7 @@
*/
void
pnp_unblock_load(pnp_node_info *node)
pnp_unblock_load(device_node_info *node)
{
if (--node->load_block_count == 0 && node->num_blocked_loads > 0) {
TRACE(("Releasing blocked loads of %p\n", node));
@ -48,7 +50,7 @@ pnp_unblock_load(pnp_node_info *node)
*/
static void
pnp_wait_load_block(pnp_node_info *node)
pnp_wait_load_block(device_node_info *node)
{
if (node->load_block_count > 0) {
TRACE(("Loading of %p is blocked - wait until unblock\n", node));
@ -70,11 +72,11 @@ pnp_wait_load_block(pnp_node_info *node)
/** load driver automatically after registration/rescan of node. */
void
pnp_load_driver_automatically(pnp_node_info *node, bool after_rescan)
pnp_load_driver_automatically(device_node_info *node, bool after_rescan)
{
uint8 always_loaded;
status_t res;
pnp_driver_info *interface;
driver_module_info *interface;
void *cookie;
benaphore_lock(&gNodeLock);
@ -120,7 +122,7 @@ err:
/** unload driver that got loaded automatically. */
void
pnp_unload_driver_automatically(pnp_node_info *node, bool before_rescan)
pnp_unload_driver_automatically(device_node_info *node, bool before_rescan)
{
uint8 always_loaded;
status_t res;
@ -169,10 +171,10 @@ err:
*/
static status_t
load_driver_int(pnp_node_info *node, void *user_cookie)
load_driver_int(device_node_info *node, void *user_cookie)
{
char *module_name;
pnp_driver_info *driver;
driver_module_info *driver;
void *cookie;
status_t res;
@ -220,8 +222,8 @@ err:
/** public: load driver */
status_t
pnp_load_driver(pnp_node_handle node, void *user_cookie,
pnp_driver_info **interface, void **cookie)
pnp_load_driver(device_node_handle node, void *user_cookie,
driver_module_info **interface, void **cookie)
{
status_t res;
@ -333,11 +335,11 @@ pnp_load_driver(pnp_node_handle node, void *user_cookie,
/** unload driver for real */
static status_t
unload_driver_int(pnp_node_info *node)
unload_driver_int(device_node_info *node)
{
driver_module_info *driver = node->driver;
char *module_name;
status_t res;
pnp_driver_info *driver = node->driver;
res = pnp_get_attr_string(node, PNP_DRIVER_DRIVER, &module_name, false);
if (res != B_OK)
@ -379,7 +381,7 @@ err:
/** public: unload driver */
status_t
pnp_unload_driver(pnp_node_handle node)
pnp_unload_driver(device_node_handle node)
{
status_t res;
@ -414,7 +416,7 @@ pnp_unload_driver(pnp_node_handle node)
} else {
// concurrent load/unload either unloaded the driver or
// increased load_count so unload is not necessary or forbidden
TRACE(("don't unload as current load_count is %d\n",
TRACE(("don't unload as current load_count is %ld\n",
node->load_count));
res = B_OK;
}

View File

@ -1,5 +1,7 @@
/*
* Copyright 2002-04, Thomas Kurschel. All rights reserved.
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/

View File

@ -1,10 +1,12 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
Part of Device Manager
I/O resource manager.
@ -130,7 +132,7 @@ acquire_range(io_resource_info **list, io_resource_info *resource)
// we need the "base + len - 1" trick to avoid wrap around at 4 GB
if (cur->resource.base >= base
&& cur->resource.base + len - 1 <= base + len - 1) {
pnp_node_info *owner = cur->owner;
device_node_info *owner = cur->owner;
TRACE(("collision\n"));
@ -282,7 +284,7 @@ release_range(io_resource_info **list, io_resource_info *resource, io_resource_i
// we need the "base + len - 1" trick to avoid wrap around at 4 GB
if (cur->resource.base >= base && cur->resource.base + len - 1 <= base + len - 1) {
pnp_node_info *owner = cur->owner;
device_node_info *owner = cur->owner;
TRACE(("unblock\n"));
@ -452,7 +454,7 @@ unregister_colliding_nodes(const io_resource_handle *resources)
}
// unregister device nodes that collide with I/O resource
/** unregister device nodes that collide with I/O resource */
static void
unregister_colliding_node_range(io_resource_info *list, io_resource_info *resource)
@ -470,7 +472,7 @@ unregister_colliding_node_range(io_resource_info *list, io_resource_info *resour
// we need the "base + len - 1" trick to avoid wrap around at 4 GB
if (cur->resource.base >= base
&& cur->resource.base + len - 1 <= base + len - 1) {
pnp_node_handle owner = cur->owner;
device_node_handle owner = cur->owner;
if (owner == NULL)
panic("Transfer of I/O resources from temporary to device node collided with other temporary allocation");
@ -502,7 +504,7 @@ unregister_colliding_node_range(io_resource_info *list, io_resource_info *resour
// colliding devices are unregistered
void
pnp_assign_io_resources(pnp_node_info *node, const io_resource_handle *resources)
pnp_assign_io_resources(device_node_info *node, const io_resource_handle *resources)
{
io_resource_handle *resource;
@ -549,7 +551,7 @@ unblock_temporary_allocation(void)
// node_lock must be hold
void
pnp_release_node_resources(pnp_node_info *node)
pnp_release_node_resources(device_node_info *node)
{
io_resource_handle *resource;

View File

@ -1,12 +1,14 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
Part of Device Manager
PnP node handling.
device node handling.
To make sure that nodes persist as long as somebody is using them, we
maintain a reference count (ref_count) which is increased
@ -43,7 +45,7 @@ benaphore gNodeLock;
// increase ref_count of node
void
pnp_add_node_ref(pnp_node_info *node)
pnp_add_node_ref(device_node_info *node)
{
TRACE(("add_node_ref(%p)\n", node));
@ -60,9 +62,9 @@ pnp_add_node_ref(pnp_node_info *node)
// if an attribute is still in use, it's deletion is postponed
static void
free_node_attrs(pnp_node_info *node)
free_node_attrs(device_node_info *node)
{
pnp_node_attr_info *attr, *next_attr;
device_attr_info *attr, *next_attr;
for (attr = node->attributes; attr != NULL; attr = next_attr) {
next_attr = attr->next;
@ -78,7 +80,7 @@ free_node_attrs(pnp_node_info *node)
// (resources must have been released already)
static void
free_node_resources(pnp_node_info *node)
free_node_resources(device_node_info *node)
{
free(node->io_resources);
node->io_resources = NULL;
@ -89,7 +91,7 @@ free_node_resources(pnp_node_info *node)
// (node lock must be hold)
static void
free_node(pnp_node_info *node)
free_node(device_node_info *node)
{
const char *generator_name, *driver_name, *type;
uint32 auto_id;
@ -114,7 +116,7 @@ free_node(pnp_node_info *node)
pnp_release_node_resources(node);
//list_remove_link(node);
REMOVE_DL_LIST( node, node_list, );
REMOVE_DL_LIST( node, gNodeList, );
delete_sem(node->hook_sem);
delete_sem(node->load_block_sem);
@ -129,12 +131,12 @@ free_node(pnp_node_info *node)
// (node_lock must be hold)
void
pnp_remove_node_ref_nolock(pnp_node_info *node)
pnp_remove_node_ref_nolock(device_node_info *node)
{
do {
pnp_node_info *parent;
device_node_info *parent;
TRACE(("pnp_remove_node_ref_internal(ref_count of %p: %d)\n", node, node->ref_count - 1));
TRACE(("pnp_remove_node_ref_internal(ref_count of %p: %ld)\n", node, node->ref_count - 1));
// unregistered devices loose their I/O resources as soon as they
// are unloaded
@ -151,7 +153,7 @@ pnp_remove_node_ref_nolock(pnp_node_info *node)
if (parent != NULL)
// list_remove_item(&parent->children, node);
REMOVE_DL_LIST(node, parent->children, children_ );
REMOVE_DL_LIST(node, parent->children, siblings_ );
free_node(node);
@ -164,7 +166,7 @@ pnp_remove_node_ref_nolock(pnp_node_info *node)
// remove node reference and clean it up if necessary
void
pnp_remove_node_ref(pnp_node_info *node)
pnp_remove_node_ref(device_node_info *node)
{
TRACE(("pnp_remove_node_ref(%p)\n", node));
@ -177,11 +179,11 @@ pnp_remove_node_ref(pnp_node_info *node)
// copy node attributes into node's attribute list
static status_t
copy_node_attrs(pnp_node_info *node, const pnp_node_attr *src)
copy_node_attrs(device_node_info *node, const device_attr *src)
{
status_t res;
const pnp_node_attr *src_attr;
pnp_node_attr_info *last_attr = NULL;
const device_attr *src_attr;
device_attr_info *last_attr = NULL;
node->attributes = NULL;
@ -189,7 +191,7 @@ copy_node_attrs(pnp_node_info *node, const pnp_node_attr *src)
// this is (currently) not necessary but a naive implementation would
// reverse order, which looks a bit odd (at least for the driver writer)
for (src_attr = src; src_attr->name != NULL; ++src_attr) {
pnp_node_attr_info *new_attr;
device_attr_info *new_attr;
res = pnp_duplicate_node_attr( src_attr, &new_attr );
if (res != B_OK)
@ -214,7 +216,7 @@ err:
// later on, resources aren't transferred to node
static status_t
allocate_node_resource_array(pnp_node_info *node, const io_resource_handle *resources)
allocate_node_resource_array(device_node_info *node, const io_resource_handle *resources)
{
const io_resource_handle *resource;
int num_resources = 0;
@ -239,10 +241,10 @@ allocate_node_resource_array(pnp_node_info *node, const io_resource_handle *reso
// initially, ref_count is one to make sure node won't get destroyed by mistake
status_t
pnp_alloc_node(const pnp_node_attr *attrs, const io_resource_handle *resources,
pnp_node_info **new_node)
pnp_alloc_node(const device_attr *attrs, const io_resource_handle *resources,
device_node_info **new_node)
{
pnp_node_info *node;
device_node_info *node;
status_t res;
TRACE(("pnp_alloc_node()\n"));
@ -287,7 +289,7 @@ pnp_alloc_node(const pnp_node_attr *attrs, const io_resource_handle *resources,
// make public (well, almost: it's not officially registered yet)
benaphore_lock(&gNodeLock);
ADD_DL_LIST_HEAD(node, node_list, );
ADD_DL_LIST_HEAD(node, gNodeList, );
benaphore_unlock(&gNodeLock);
@ -310,7 +312,7 @@ err:
// create links to parent node
void
pnp_create_node_links(pnp_node_info *node, pnp_node_info *parent)
pnp_create_node_links(device_node_info *node, device_node_info *parent)
{
TRACE(("pnp_create_node_links(%p, parent=%p)\n", node, parent));
@ -327,7 +329,7 @@ pnp_create_node_links(pnp_node_info *node, pnp_node_info *parent)
// tell parent about us, so we get unregistered automatically if parent
// gets unregistered
ADD_DL_LIST_HEAD(node, parent->children, children_ );
ADD_DL_LIST_HEAD(node, parent->children, siblings_ );
benaphore_unlock(&gNodeLock);
}
@ -335,8 +337,8 @@ pnp_create_node_links(pnp_node_info *node, pnp_node_info *parent)
// public: get parent of node
pnp_node_handle
pnp_get_parent(pnp_node_handle node)
device_node_handle
pnp_get_parent(device_node_handle node)
{
return node->parent;
}
@ -344,23 +346,23 @@ pnp_get_parent(pnp_node_handle node)
// public: find node with some node attributes given
pnp_node_info *
pnp_find_device(pnp_node_info *parent, const pnp_node_attr *attrs)
device_node_info *
pnp_find_device(device_node_info *parent, const device_attr *attrs)
{
pnp_node_info *node, *found_node;
device_node_info *node, *found_node;
found_node = NULL;
benaphore_lock(&gNodeLock);
for (node = node_list; node; node = node->next) {
const pnp_node_attr *attr;
for (node = gNodeList; node; node = node->next) {
const device_attr *attr;
// list contains removed devices too, so skip them
if (!node->registered)
continue;
if (parent != (pnp_node_info *)-1 && parent != node->parent)
if (parent != (device_node_info *)-1 && parent != node->parent)
continue;
for (attr = attrs; attr && attr->name; ++attr) {
@ -448,7 +450,7 @@ put_level(int32 level)
static void
dump_attribute(pnp_node_attr_info *attr, int32 level)
dump_attribute(device_attr_info *attr, int32 level)
{
if (attr == NULL)
return;
@ -481,17 +483,17 @@ dump_attribute(pnp_node_attr_info *attr, int32 level)
void
dump_pnp_node_info(pnp_node_info *node, int32 level)
dump_device_node_info(device_node_info *node, int32 level)
{
if (node == NULL)
return;
put_level(level);
dprintf("(%ld) @%p \"%s\"\n", level, node, node->driver ? node->driver->minfo.name : "---");
dprintf("(%ld) @%p \"%s\"\n", level, node, node->driver ? node->driver->info.name : "---");
dump_attribute(node->attributes, level);
dump_pnp_node_info(node->children, level + 1);
dump_pnp_node_info(node->children_next, level);
dump_device_node_info(node->children, level + 1);
dump_device_node_info(node->siblings_next, level);
}

View File

@ -1,10 +1,12 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
Part of Device Manager
Execution and synchronization of driver hook calls.
*/
@ -31,9 +33,9 @@
*/
status_t
pnp_notify_probe_by_module(pnp_node_info *node, const char *consumer_name)
pnp_notify_probe_by_module(device_node_info *node, const char *consumer_name)
{
pnp_driver_info *consumer;
driver_module_info *consumer;
status_t res;
TRACE(("pnp_notify_probe_by_module(node %p, consumer: %s)\n", node, consumer_name));
@ -67,11 +69,11 @@ exit:
/** notify driver that it's device got removed */
static status_t
notify_device_removed(pnp_node_info *node)
notify_device_removed(device_node_info *node)
{
driver_module_info *driver;
bool loaded;
char *module_name;
pnp_driver_info *driver;
void *cookie;
status_t res;
@ -140,9 +142,9 @@ err:
/** notify all drivers in <notify_list> that their node got removed */
void
pnp_notify_unregistration(pnp_node_info *notify_list)
pnp_notify_unregistration(device_node_info *notify_list)
{
pnp_node_info *node;
device_node_info *node;
TRACE(("pnp_notify_unregistration()\n"));
@ -156,7 +158,7 @@ pnp_notify_unregistration(pnp_node_info *notify_list)
*/
void
pnp_start_hook_call(pnp_node_info *node)
pnp_start_hook_call(device_node_info *node)
{
bool blocked;
@ -179,7 +181,7 @@ pnp_start_hook_call(pnp_node_info *node)
*/
void
pnp_start_hook_call_nolock(pnp_node_info *node)
pnp_start_hook_call_nolock(device_node_info *node)
{
if (++node->num_waiting_hooks > 1) {
benaphore_unlock(&gNodeLock);
@ -197,7 +199,7 @@ pnp_start_hook_call_nolock(pnp_node_info *node)
*/
void
pnp_finish_hook_call(pnp_node_info *node)
pnp_finish_hook_call(device_node_info *node)
{
benaphore_lock(&gNodeLock);
@ -216,7 +218,7 @@ pnp_finish_hook_call(pnp_node_info *node)
*/
void
pnp_finish_hook_call_nolock(pnp_node_info *node)
pnp_finish_hook_call_nolock(device_node_info *node)
{
if (--node->num_waiting_hooks > 1) {
TRACE(("Releasing other hook calls of %p\n", node));

View File

@ -1,10 +1,12 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
Part of Device Manager
Expansion of patterns.
Used to expand consumer/connector/device names etc.
@ -39,9 +41,9 @@
*/
static status_t
expand_attr(pnp_node_info *node, const char **pattern, char *buffer, char *dst)
expand_attr(device_node_info *node, const char **pattern, char *buffer, char *dst)
{
pnp_node_attr_info *attr;
device_attr_info *attr;
const char *str;
int buffer_len;
@ -133,7 +135,7 @@ expand_attr(pnp_node_info *node, const char **pattern, char *buffer, char *dst)
*/
status_t
pnp_expand_pattern(pnp_node_info *node, const char *pattern, char *dest,
pnp_expand_pattern(device_node_info *node, const char *pattern, char *dest,
char *buffer, size_t *term_array, int *num_parts)
{
const char *str;
@ -213,7 +215,7 @@ pnp_expand_pattern(pnp_node_info *node, const char *pattern, char *dest,
*/
status_t
pnp_expand_pattern_attr(pnp_node_info *node, const char *attr_name,
pnp_expand_pattern_attr(device_node_info *node, const char *attr_name,
char **expanded)
{
const char *pattern;

View File

@ -1,10 +1,12 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
Part of Device Manager
Probing for consumers.
Here is all the core logic how consumers are found for one node.
@ -56,7 +58,7 @@ static const char *modules_dirs[2] = {
*/
static status_t
notify_probe_by_file(pnp_node_info *node, const char *consumer_name)
notify_probe_by_file(device_node_info *node, const char *consumer_name)
{
char *type;
char *resolved_path;
@ -134,7 +136,7 @@ err:
*/
static status_t
compose_driver_names(pnp_node_info *node, const char *dir,
compose_driver_names(device_node_info *node, const char *dir,
const char *filename_pattern, int num_parts,
char *path, char *buffer, size_t **res_term_array)
{
@ -184,7 +186,7 @@ err:
*/
static status_t
try_drivers(pnp_node_info *node, char *directory,
try_drivers(device_node_info *node, char *directory,
bool tell_all, char *buffer)
{
DIR *dir;
@ -241,7 +243,7 @@ try_drivers(pnp_node_info *node, char *directory,
*/
static status_t
find_normal_consumer(pnp_node_info *node, const char *dir,
find_normal_consumer(device_node_info *node, const char *dir,
const char *filename_pattern, int num_parts,
char *path, char *buffer, bool *found_normal_driver)
{
@ -406,7 +408,7 @@ preprocess_consumer_names(const char *pattern, char *buffer,
*/
static status_t
notify_dynamic_consumer(pnp_node_info *node, const char *pattern,
notify_dynamic_consumer(device_node_info *node, const char *pattern,
bool *has_normal_driver)
{
status_t res;
@ -468,7 +470,7 @@ err:
*/
status_t
pnp_notify_dynamic_consumers(pnp_node_info *node)
pnp_notify_dynamic_consumers(device_node_info *node)
{
int i;
char *buffer;
@ -532,7 +534,7 @@ err:
*/
status_t
pnp_notify_fixed_consumers(pnp_node_info *node)
pnp_notify_fixed_consumers(device_node_info *node)
{
int i;
char *buffer;

View File

@ -1,12 +1,14 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
Part of Device Manager
PnP Node Registration.
Device Node Registration.
*/
@ -30,9 +32,9 @@
// decrease ref_count of unregistered nodes, specified by <node_list>
void
pnp_unref_unregistered_nodes(pnp_node_info *node_list)
pnp_unref_unregistered_nodes(device_node_info *node_list)
{
pnp_node_info *node, *next_node;
device_node_info *node, *next_node;
for (node = node_list; node; node = next_node) {
next_node = node->notify_next;
@ -45,7 +47,7 @@ pnp_unref_unregistered_nodes(pnp_node_info *node_list)
// mark node being registered, so it can be accessed via load_driver()
static status_t
mark_node_registered(pnp_node_info *node)
mark_node_registered(device_node_info *node)
{
status_t res;
@ -74,9 +76,9 @@ mark_node_registered(pnp_node_info *node)
// the node must not yet be linked into parent node's children list
static status_t
is_device_redetected(pnp_node_info *node, pnp_node_info *parent, bool *redetected)
is_device_redetected(device_node_info *node, device_node_info *parent, bool *redetected)
{
pnp_node_info *sibling;
device_node_info *sibling;
status_t res;
bool found = false;
bool same_device = false;
@ -109,7 +111,7 @@ is_device_redetected(pnp_node_info *node, pnp_node_info *parent, bool *redetecte
TRACE(("connection: %s, device_identifier: %s\n", connection, device_identifier));
// ...and compare it with our siblings
for (sibling = parent->children; sibling != NULL; sibling = sibling->children_next) {
for (sibling = parent->children; sibling != NULL; sibling = sibling->siblings_next) {
char *sibling_connection, *sibling_device_identifier;
bool same_connection;
@ -223,7 +225,7 @@ err:
// return: true, if postponed
static bool
pnp_postpone_probing(pnp_node_info *node)
pnp_postpone_probing(device_node_info *node)
{
benaphore_lock(&gNodeLock);
@ -250,10 +252,10 @@ pnp_postpone_probing(pnp_node_info *node)
// them would be complicated
status_t
pnp_register_device(pnp_node_handle parent, const pnp_node_attr *attrs,
const io_resource_handle *io_resources, pnp_node_handle *node)
pnp_register_device(device_node_handle parent, const device_attr *attrs,
const io_resource_handle *io_resources, device_node_handle *node)
{
pnp_node_info *node_inf;
device_node_info *node_inf;
bool redetected;
status_t res = B_OK;
@ -350,9 +352,9 @@ err:
// public: unregister device node
status_t
pnp_unregister_device(pnp_node_info *node)
pnp_unregister_device(device_node_info *node)
{
pnp_node_info *dependency_list = NULL;
device_node_info *dependency_list = NULL;
TRACE(("pnp_unregister_device(%p)\n", node));
@ -381,9 +383,9 @@ pnp_unregister_device(pnp_node_info *node)
// (node_lock must be hold)
void
pnp_unregister_node_rec(pnp_node_info *node, pnp_node_info **dependency_list)
pnp_unregister_node_rec(device_node_info *node, device_node_info **dependency_list)
{
pnp_node_info *child, *next_child;
device_node_info *child, *next_child;
TRACE(("pnp_unregister_node_rec(%p)\n", node));
@ -416,7 +418,7 @@ err:
// unregister children recursively
for (child = node->children; child; child = next_child) {
next_child = child->children_next;
next_child = child->siblings_next;
pnp_unregister_node_rec(child, dependency_list);
}
}
@ -426,7 +428,7 @@ err:
// node_lock must be hold
void
pnp_defer_probing_of_children_nolock(pnp_node_info *node)
pnp_defer_probing_of_children_nolock(device_node_info *node)
{
++node->defer_probing;
}
@ -435,7 +437,7 @@ pnp_defer_probing_of_children_nolock(pnp_node_info *node)
// defer probing of children
void
pnp_defer_probing_of_children(pnp_node_info *node)
pnp_defer_probing_of_children(device_node_info *node)
{
benaphore_lock(&gNodeLock);
@ -449,7 +451,7 @@ pnp_defer_probing_of_children(pnp_node_info *node)
// (node_lock must be hold)
void
pnp_probe_waiting_children_nolock(pnp_node_info *node)
pnp_probe_waiting_children_nolock(device_node_info *node)
{
if (--node->defer_probing > 0 && node->unprobed_children != 0)
return;
@ -457,7 +459,7 @@ pnp_probe_waiting_children_nolock(pnp_node_info *node)
TRACE(("execute deferred probing of parent %p\n", node));
while (node->unprobed_children) {
pnp_node_info *child = node->unprobed_children;
device_node_info *child = node->unprobed_children;
REMOVE_DL_LIST(child, node->unprobed_children, unprobed_);
@ -483,7 +485,7 @@ pnp_probe_waiting_children_nolock(pnp_node_info *node)
// execute deferred probing of children
void
pnp_probe_waiting_children(pnp_node_info *node)
pnp_probe_waiting_children(device_node_info *node)
{
benaphore_lock(&gNodeLock);

View File

@ -1,19 +1,17 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002/2003, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP devfs
Part of Device Manager
Interface of PnP root module.
Interface of device root module.
This module creates the root devices (PCI and ISA) to initiate
the PnP device scan. It is calles by pnp_boot_helper but should
probably be moved into kernel for simplification.
In the future, we want to check hardware configuration before we
start loading ISA and PCI bus manager.
This module creates the root devices (usually PCI and ISA) to
initiate the PnP device scan.
*/
@ -22,10 +20,6 @@
#include "device_manager_private.h"
//#include <pnp/pnp_manager.h>
/*#include <bus/ISA2.h>
#include <bus/PCI2.h>*/
#define TRACE_ROOT_NODE
#ifdef TRACE_ROOT_NODE
@ -45,13 +39,13 @@
#define PNP_ROOT_MODULE_NAME "sys/pnp_root/v1"
static pnp_node_handle sRootNode;
static device_node_handle sRootNode;
void
pnp_root_init_root(void)
{
pnp_node_attr attrs[] = {
device_attr attrs[] = {
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: PNP_ROOT_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: PNP_ROOT_TYPE_NAME }},
@ -105,7 +99,7 @@ pnp_root_rescan_root(void)
static status_t
pnp_root_init_device(pnp_node_handle node, void *user_cookie, void **cookie)
pnp_root_init_device(device_node_handle node, void *user_cookie, void **cookie)
{
*cookie = NULL;
return B_OK;
@ -120,11 +114,11 @@ pnp_root_uninit_device(void *cookie)
/*
static status_t pnp_root_device_added(
pnp_node_handle parent )
device_node_handle parent )
{
char *tmp;
status_t res;
pnp_node_handle loader_node;
device_node_handle loader_node;
// make sure parent is really root
if( pnp->get_attr_string( parent, PNP_DRIVER_TYPE, &tmp, false ))
@ -140,7 +134,7 @@ static status_t pnp_root_device_added(
// load ISA bus manager
// if you don't want ISA, remove this registration
{
pnp_node_attr attrs[] = {
device_attr attrs[] = {
// info about ourself
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: PNP_ROOT_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: "pnp/isa_loader" }},
@ -159,7 +153,7 @@ static status_t pnp_root_device_added(
// load PCI bus manager
{
pnp_node_attr attrs[] = {
device_attr attrs[] = {
// info about ourself
{ PNP_DRIVER_DRIVER, B_STRING_TYPE, { string: PNP_ROOT_MODULE_NAME }},
{ PNP_DRIVER_TYPE, B_STRING_TYPE, { string: "pnp/pci_loader" }},
@ -195,7 +189,7 @@ std_ops(int32 op, ...)
}
pnp_driver_info gDeviceRootModule = {
driver_module_info gDeviceRootModule = {
{
PNP_ROOT_MODULE_NAME,
0,

View File

@ -1,7 +1,9 @@
/*
** Copyright 2002-04, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2002-2004, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
/*
Part of PnP Manager
@ -33,7 +35,7 @@
/** public function: rescan PnP node */
status_t
pnp_rescan(pnp_node_info *node, uint depth)
pnp_rescan(device_node_info *node, uint32 depth)
{
return pnp_rescan_int(node, depth, false);
}
@ -42,7 +44,7 @@ pnp_rescan(pnp_node_info *node, uint depth)
/** execute registration of fully constructed node */
status_t
pnp_initial_scan(pnp_node_info *node)
pnp_initial_scan(device_node_info *node)
{
pnp_start_hook_call(node);
@ -60,16 +62,16 @@ pnp_initial_scan(pnp_node_info *node)
*/
static bool
is_rescan_sensible(pnp_node_info *node)
is_rescan_sensible(device_node_info *node)
{
uint depth;
pnp_node_info *child;
device_node_info *child;
TRACE(("is_rescan_sensible(node: %p)\n", node));
// if a child is being scanned, abort our rescan to avoid
// concurrent scans by the same driver on the same device
for (child = node->children; child != NULL; child = child->children_next) {
for (child = node->children; child != NULL; child = child->siblings_next) {
if (child->rescan_depth > 0) {
TRACE(("child %p is being scanned\n", child));
return false;
@ -100,16 +102,16 @@ is_rescan_sensible(pnp_node_info *node)
*/
static void
mark_children_scanned(pnp_node_info *node)
mark_children_scanned(device_node_info *node)
{
pnp_node_info *child, *next_child;
device_node_info *child, *next_child;
TRACE(("mark_children_scanned()\n"));
for (child = node->children; child != NULL; child = next_child) {
uint8 never_rescan, no_live_rescan;
next_child = child->children_next;
next_child = child->siblings_next;
// ignore dead children
if (!child->registered)
@ -161,16 +163,16 @@ mark_children_scanned(pnp_node_info *node)
/** stop children verification, resetting associated flag and unblocking loads. */
static void
reset_children_verification(pnp_node_info *node)
reset_children_verification(device_node_info *node)
{
pnp_node_info *child, *next_child;
device_node_info *child, *next_child;
TRACE(("reset_children_verification()\n"));
benaphore_lock(&gNodeLock);
for (child = node->children; child != NULL; child = next_child) {
next_child = child->children_next;
next_child = child->siblings_next;
if (!child->verifying)
continue;
@ -202,16 +204,16 @@ reset_children_verification(pnp_node_info *node)
/** unregister child nodes that weren't detected anymore */
static void
unregister_lost_children(pnp_node_info *node)
unregister_lost_children(device_node_info *node)
{
pnp_node_info *child, *dependency_list;
device_node_info *child, *dependency_list;
TRACE(("unregister_lost_children()\n"));
benaphore_lock(&gNodeLock);
for (child = node->children, dependency_list = NULL; child != NULL;
child = child->children_next) {
child = child->siblings_next) {
if (child->verifying && !child->redetected) {
TRACE(("removing lost device %p\n", child));
// child wasn't detected anymore - put it onto remove list
@ -239,9 +241,9 @@ unregister_lost_children(pnp_node_info *node)
*/
static status_t
recursive_scan(pnp_node_info *node, uint depth)
recursive_scan(device_node_info *node, uint depth)
{
pnp_node_info *child, *next_child;
device_node_info *child, *next_child;
status_t res;
TRACE(("recursive_scan(node: %p, depth=%d)\n", node, depth));
@ -253,7 +255,7 @@ recursive_scan(pnp_node_info *node, uint depth)
++child->ref_count;
for (; child != NULL; child = next_child) {
next_child = child->children_next;
next_child = child->siblings_next;
// lock next child, so its node is still valid after rescan
if (next_child != NULL)
@ -290,10 +292,10 @@ err:
/** ask bus to (re-)scan for connected devices */
static void
rescan_bus(pnp_node_info *node)
rescan_bus(device_node_info *node)
{
// busses can register their children themselves
pnp_bus_info *interface;
bus_module_info *interface;
void *cookie;
bool defer_probe;
uint8 defer_probe_var;
@ -309,7 +311,7 @@ rescan_bus(pnp_node_info *node)
}
// load driver during rescan
pnp_load_driver(node, NULL, (pnp_driver_info **)&interface, &cookie);
pnp_load_driver(node, NULL, (driver_module_info **)&interface, &cookie);
TRACE(("scan bus\n"));
@ -336,14 +338,14 @@ rescan_bus(pnp_node_info *node)
*/
status_t
pnp_rescan_int(pnp_node_info *node, uint depth,
pnp_rescan_int(device_node_info *node, uint32 depth,
bool ignore_fixed_consumers)
{
bool is_bus;
uint8 dummy;
status_t res = B_OK;
TRACE(("pnp_rescan_int(node: %p, depth=%d)\n", node, depth));
TRACE(("pnp_rescan_int(node: %p, depth = %ld)\n", node, depth));
//pnp_load_boot_links();