BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / bus_managers / ide / channels.c
blob45686041ca698d96ff19ec0d3f7fe8f399a285d4
1 /*
2 * Copyright 2002/03, Thomas Kurschel. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
6 /*
7 Part of Open IDE bus manager
9 Manager of IDE controllers
11 Whenever a new IDE channel is reported, a new SIM is
12 registered at the SCSI bus manager.
15 #include "ide_internal.h"
16 #include "ide_sim.h"
18 #include <string.h>
19 #include <malloc.h>
22 /** called when an IDE channel was registered by a controller driver */
24 static status_t
25 ide_channel_added(device_node *parent)
27 const char *controller_name = NULL;
28 uint32 channel_id;
30 SHOW_FLOW0(2, "");
32 if (pnp->get_attr_string(parent, IDE_CONTROLLER_CONTROLLER_NAME_ITEM,
33 &controller_name, true) != B_OK) {
34 dprintf("ide: ignored controller - controller name missing\n");
35 goto err;
38 channel_id = pnp->create_id(IDE_CHANNEL_ID_GENERATOR);
40 if (channel_id < 0) {
41 SHOW_ERROR(0, "Cannot register IDE controller %s - out of IDs", controller_name);
42 goto err;
46 device_attr attrs[] =
48 { B_DEVICE_FIXED_CHILD, B_STRING_TYPE, { string: SCSI_FOR_SIM_MODULE_NAME }},
50 { SCSI_DESCRIPTION_CONTROLLER_NAME, B_STRING_TYPE,
51 { string: controller_name }},
52 // maximum number of blocks per transmission:
53 // - ATAPI uses packets, i.e. normal SCSI limits apply
54 // but I'm not sure about controller restrictions
55 // - ATA allows up to 256 blocks
56 // - some broken disk's firmware (read: IBM DTTA drives)
57 // don't like 256 blocks in command queuing mode
58 // -> use 255 blocks as a least common nominator
59 // (this is still 127.5K for HDs and 510K for CDs,
60 // which should be sufficient)
61 // Note: to fix specific drive bugs, use ide_sim_get_restrictions()
62 // in ide_sim.c!
63 { B_DMA_MAX_TRANSFER_BLOCKS, B_UINT32_TYPE, { ui32: 255 }},
64 { IDE_CHANNEL_ID_ITEM, B_UINT32_TYPE, { ui32: channel_id }},
65 // { PNP_MANAGER_ID_GENERATOR, B_STRING_TYPE, { string: IDE_CHANNEL_ID_GENERATOR }},
66 // { PNP_MANAGER_AUTO_ID, B_UINT32_TYPE, { ui32: channel_id }},
68 { NULL }
71 return pnp->register_node(parent, IDE_SIM_MODULE_NAME, attrs, NULL,
72 NULL);
75 err:
76 return B_NO_MEMORY;
80 static status_t
81 std_ops(int32 op, ...)
83 switch (op) {
84 case B_MODULE_INIT:
85 case B_MODULE_UNINIT:
86 return B_OK;
88 default:
89 return B_ERROR;
94 ide_for_controller_interface ide_for_controller_module = {
97 IDE_FOR_CONTROLLER_MODULE_NAME,
99 &std_ops
102 NULL, // supported devices
103 ide_channel_added,
104 NULL,
105 NULL,
106 NULL
109 ide_irq_handler