BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / bus_managers / isa / isa.cpp
blob7ba86b705216f5193f78db201a7eade783f1969f
1 /*
2 * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Copyright 2002/03, Thomas Kurschel. All rights reserved.
5 * Distributed under the terms of the MIT License.
6 */
8 /*
9 ISA bus manager
11 Implementation.
15 #include <ISA.h>
16 #include <bus/ISA.h>
17 #include <KernelExport.h>
18 #include <device_manager.h>
19 #include <arch/cpu.h>
21 #include <stdlib.h>
22 #include <string.h>
24 #include "isa_arch.h"
26 //#define TRACE_ISA
27 #ifdef TRACE_ISA
28 # define TRACE(x) dprintf x
29 #else
30 # define TRACE(x) ;
31 #endif
33 // ToDo: this is architecture dependent and should be made differently!
34 // (for example, the Pegasos (PPC based) also has an ISA bus)
37 #define ISA_MODULE_NAME "bus_managers/isa/root/driver_v1"
39 device_manager_info *pnp;
42 static long
43 make_isa_dma_table(const void *buffer, long buffer_size, ulong num_bits,
44 isa_dma_entry *table, long num_entries)
46 // ToDo: implement this?!
47 return ENOSYS;
51 static long
52 start_scattered_isa_dma(long channel, const isa_dma_entry *table,
53 uchar mode, uchar emode)
55 // ToDo: implement this?!
56 return ENOSYS;
60 static status_t
61 lock_isa_dma_channel(long channel)
63 // ToDo: implement this?!
64 return B_NOT_ALLOWED;
68 static status_t
69 unlock_isa_dma_channel(long channel)
71 // ToDo: implement this?!
72 return B_ERROR;
76 // #pragma mark - driver module API
79 static status_t
80 isa_init_driver(device_node *node, void **cookie)
82 *cookie = node;
83 return B_OK;
87 static void
88 isa_uninit_driver(void *cookie)
93 static float
94 isa_supports_device(device_node *parent)
96 const char *bus;
98 // make sure parent is really pnp root
99 if (pnp->get_attr_string(parent, B_DEVICE_BUS, &bus, false))
100 return B_ERROR;
102 if (strcmp(bus, "root"))
103 return 0.0;
105 return 1.0;
109 static status_t
110 isa_register_device(device_node *parent)
112 static const device_attr attrs[] = {
113 // tell where to look for child devices
114 {B_DEVICE_BUS, B_STRING_TYPE, {string: "isa" }},
115 {B_DEVICE_FLAGS, B_UINT32_TYPE,
116 {ui32: B_FIND_CHILD_ON_DEMAND | B_FIND_MULTIPLE_CHILDREN}},
120 return pnp->register_node(parent, ISA_MODULE_NAME, attrs, NULL, NULL);
124 static status_t
125 std_ops(int32 op, ...)
127 switch (op) {
128 case B_MODULE_INIT:
129 return arch_isa_init();
130 case B_MODULE_UNINIT:
131 return B_OK;
133 default:
134 return B_ERROR;
139 module_dependency module_dependencies[] = {
140 { B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&pnp },
144 static isa_module_info isa_module = {
147 B_ISA_MODULE_NAME,
148 B_KEEP_LOADED,
149 std_ops
151 NULL // rescan
153 &arch_isa_read_io_8,
154 &arch_isa_write_io_8,
155 &arch_isa_read_io_16,
156 &arch_isa_write_io_16,
157 &arch_isa_read_io_32,
158 &arch_isa_write_io_32,
159 &arch_isa_ram_address,
160 &make_isa_dma_table,
161 &arch_start_isa_dma,
162 &start_scattered_isa_dma,
163 &lock_isa_dma_channel,
164 &unlock_isa_dma_channel
167 static isa2_module_info isa2_module = {
170 ISA_MODULE_NAME,
172 std_ops
175 isa_supports_device,
176 isa_register_device,
177 isa_init_driver,
178 isa_uninit_driver,
179 NULL, // removed device
180 NULL, // register child devices
181 NULL, // rescan bus
184 arch_isa_read_io_8, arch_isa_write_io_8,
185 arch_isa_read_io_16, arch_isa_write_io_16,
186 arch_isa_read_io_32, arch_isa_write_io_32,
188 arch_isa_ram_address,
190 arch_start_isa_dma,
193 module_info *modules[] = {
194 (module_info *)&isa_module,
195 (module_info *)&isa2_module,
196 NULL