[892e4e1] | 1 | /*
|
---|
| 2 | * Copyright (c) 2010 Lenka Trochtova
|
---|
[68414f4a] | 3 | * Copyright (c) 2011 Jiri Svoboda
|
---|
[ec388d7] | 4 | * Copyright (c) 2011 Jan Vesely
|
---|
[892e4e1] | 5 | * All rights reserved.
|
---|
| 6 | *
|
---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
---|
| 8 | * modification, are permitted provided that the following conditions
|
---|
| 9 | * are met:
|
---|
| 10 | *
|
---|
| 11 | * - Redistributions of source code must retain the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer.
|
---|
| 13 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 14 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 15 | * documentation and/or other materials provided with the distribution.
|
---|
| 16 | * - The name of the author may not be used to endorse or promote products
|
---|
| 17 | * derived from this software without specific prior written permission.
|
---|
| 18 | *
|
---|
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 | /**
|
---|
| 32 | * @defgroup isa ISA bus driver.
|
---|
| 33 | * @brief HelenOS ISA bus driver.
|
---|
| 34 | * @{
|
---|
| 35 | */
|
---|
| 36 |
|
---|
| 37 | /** @file
|
---|
| 38 | */
|
---|
| 39 |
|
---|
[f278930] | 40 | #include <adt/list.h>
|
---|
[892e4e1] | 41 | #include <assert.h>
|
---|
| 42 | #include <stdio.h>
|
---|
| 43 | #include <errno.h>
|
---|
[3e6a98c5] | 44 | #include <stdbool.h>
|
---|
[892e4e1] | 45 | #include <fibril_synch.h>
|
---|
| 46 | #include <stdlib.h>
|
---|
[c47e1a8] | 47 | #include <str.h>
|
---|
[cd0684d] | 48 | #include <str_error.h>
|
---|
[892e4e1] | 49 | #include <ctype.h>
|
---|
| 50 | #include <macros.h>
|
---|
[38d150e] | 51 | #include <stdlib.h>
|
---|
[c1a8ae52] | 52 | #include <dirent.h>
|
---|
[5960b48] | 53 | #include <ipc/irc.h>
|
---|
| 54 | #include <ipc/services.h>
|
---|
[23a0368] | 55 | #include <vfs/vfs.h>
|
---|
[ebc9c2c] | 56 | #include <irc.h>
|
---|
[1a11a16] | 57 | #include <ns.h>
|
---|
[892e4e1] | 58 |
|
---|
[af6b5157] | 59 | #include <ddf/driver.h>
|
---|
[fc51296] | 60 | #include <ddf/log.h>
|
---|
[41b56084] | 61 | #include <ops/hw_res.h>
|
---|
[ff97957] | 62 | #include <ops/pio_window.h>
|
---|
[5dc9622] | 63 |
|
---|
| 64 | #include <device/hw_res.h>
|
---|
[0a428943] | 65 | #include <device/pio_window.h>
|
---|
[892e4e1] | 66 |
|
---|
[3c5b86c] | 67 | #include <pci_dev_iface.h>
|
---|
| 68 |
|
---|
[d9cf684a] | 69 | #include "i8237.h"
|
---|
[ec388d7] | 70 |
|
---|
[892e4e1] | 71 | #define NAME "isa"
|
---|
[3c5b86c] | 72 | #define ISA_CHILD_FUN_CONF_PATH "/drv/isa/isa.dev"
|
---|
| 73 | #define EBUS_CHILD_FUN_CONF_PATH "/drv/isa/ebus.dev"
|
---|
[892e4e1] | 74 |
|
---|
[55a8e0cb] | 75 | #define ISA_MAX_HW_RES 5
|
---|
[5dc9622] | 76 |
|
---|
[f278930] | 77 | typedef struct {
|
---|
| 78 | fibril_mutex_t mutex;
|
---|
[7e9e652] | 79 | uint16_t pci_vendor_id;
|
---|
| 80 | uint16_t pci_device_id;
|
---|
| 81 | uint8_t pci_class;
|
---|
| 82 | uint8_t pci_subclass;
|
---|
[f278930] | 83 | ddf_dev_t *dev;
|
---|
| 84 | ddf_fun_t *fctl;
|
---|
[0a428943] | 85 | pio_window_t pio_win;
|
---|
[f278930] | 86 | list_t functions;
|
---|
| 87 | } isa_bus_t;
|
---|
| 88 |
|
---|
[68414f4a] | 89 | typedef struct isa_fun {
|
---|
[f278930] | 90 | fibril_mutex_t mutex;
|
---|
[83a2f43] | 91 | ddf_fun_t *fnode;
|
---|
[85c4cc45] | 92 | hw_resource_t resources[ISA_MAX_HW_RES];
|
---|
[032e0bb] | 93 | hw_resource_list_t hw_resources;
|
---|
[f278930] | 94 | link_t bus_link;
|
---|
[68414f4a] | 95 | } isa_fun_t;
|
---|
[5dc9622] | 96 |
|
---|
[56fd7cf] | 97 | /** Obtain soft-state from device node */
|
---|
| 98 | static isa_bus_t *isa_bus(ddf_dev_t *dev)
|
---|
| 99 | {
|
---|
| 100 | return ddf_dev_data_get(dev);
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /** Obtain soft-state from function node */
|
---|
| 104 | static isa_fun_t *isa_fun(ddf_fun_t *fun)
|
---|
| 105 | {
|
---|
| 106 | return ddf_fun_data_get(fun);
|
---|
| 107 | }
|
---|
| 108 |
|
---|
[ff97957] | 109 | static hw_resource_list_t *isa_fun_get_resources(ddf_fun_t *fnode)
|
---|
[5dc9622] | 110 | {
|
---|
[ff97957] | 111 | isa_fun_t *fun = isa_fun(fnode);
|
---|
| 112 | assert(fun);
|
---|
[032e0bb] | 113 |
|
---|
[ff97957] | 114 | return &fun->hw_resources;
|
---|
[5dc9622] | 115 | }
|
---|
| 116 |
|
---|
[d51838f] | 117 | static bool isa_fun_owns_interrupt(isa_fun_t *fun, int irq)
|
---|
[5dc9622] | 118 | {
|
---|
[ff97957] | 119 | const hw_resource_list_t *res = &fun->hw_resources;
|
---|
[1a11a16] | 120 |
|
---|
[cccd60c3] | 121 | /* Check that specified irq really belongs to the function */
|
---|
| 122 | for (size_t i = 0; i < res->count; ++i) {
|
---|
| 123 | if (res->resources[i].type == INTERRUPT &&
|
---|
| 124 | res->resources[i].res.interrupt.irq == irq) {
|
---|
[d51838f] | 125 | return true;
|
---|
[1a11a16] | 126 | }
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[d51838f] | 129 | return false;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | static int isa_fun_enable_interrupt(ddf_fun_t *fnode, int irq)
|
---|
| 133 | {
|
---|
| 134 | isa_fun_t *fun = isa_fun(fnode);
|
---|
| 135 |
|
---|
| 136 | if (!isa_fun_owns_interrupt(fun, irq))
|
---|
[cccd60c3] | 137 | return EINVAL;
|
---|
| 138 |
|
---|
| 139 | return irc_enable_interrupt(irq);
|
---|
[5dc9622] | 140 | }
|
---|
| 141 |
|
---|
[d51838f] | 142 | static int isa_fun_disable_interrupt(ddf_fun_t *fnode, int irq)
|
---|
| 143 | {
|
---|
| 144 | isa_fun_t *fun = isa_fun(fnode);
|
---|
| 145 |
|
---|
| 146 | if (!isa_fun_owns_interrupt(fun, irq))
|
---|
| 147 | return EINVAL;
|
---|
| 148 |
|
---|
| 149 | return irc_disable_interrupt(irq);
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | static int isa_fun_clear_interrupt(ddf_fun_t *fnode, int irq)
|
---|
| 153 | {
|
---|
| 154 | isa_fun_t *fun = isa_fun(fnode);
|
---|
| 155 |
|
---|
| 156 | if (!isa_fun_owns_interrupt(fun, irq))
|
---|
| 157 | return EINVAL;
|
---|
| 158 |
|
---|
| 159 | return irc_clear_interrupt(irq);
|
---|
| 160 | }
|
---|
| 161 |
|
---|
[bc6762f] | 162 | static int isa_fun_setup_dma(ddf_fun_t *fnode,
|
---|
[301032a] | 163 | unsigned int channel, uint32_t pa, uint32_t size, uint8_t mode)
|
---|
[ec388d7] | 164 | {
|
---|
| 165 | assert(fnode);
|
---|
[ff97957] | 166 | isa_fun_t *fun = isa_fun(fnode);
|
---|
| 167 | assert(fun);
|
---|
| 168 | const hw_resource_list_t *res = &fun->hw_resources;
|
---|
[ec388d7] | 169 | assert(res);
|
---|
[03362fbd] | 170 |
|
---|
[ec388d7] | 171 | for (size_t i = 0; i < res->count; ++i) {
|
---|
[1ec394e] | 172 | /* Check for assigned channel */
|
---|
[d9cf684a] | 173 | if (((res->resources[i].type == DMA_CHANNEL_16) &&
|
---|
[1ec394e] | 174 | (res->resources[i].res.dma_channel.dma16 == channel)) ||
|
---|
[d9cf684a] | 175 | ((res->resources[i].type == DMA_CHANNEL_8) &&
|
---|
[1ec394e] | 176 | (res->resources[i].res.dma_channel.dma8 == channel))) {
|
---|
| 177 | return dma_channel_setup(channel, pa, size, mode);
|
---|
[ec388d7] | 178 | }
|
---|
| 179 | }
|
---|
[03362fbd] | 180 |
|
---|
[ec388d7] | 181 | return EINVAL;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
[1864948] | 184 | static int isa_fun_remain_dma(ddf_fun_t *fnode,
|
---|
[3869c596] | 185 | unsigned channel, size_t *size)
|
---|
[1864948] | 186 | {
|
---|
| 187 | assert(size);
|
---|
| 188 | assert(fnode);
|
---|
[ff97957] | 189 | isa_fun_t *fun = isa_fun(fnode);
|
---|
| 190 | assert(fun);
|
---|
| 191 | const hw_resource_list_t *res = &fun->hw_resources;
|
---|
[1864948] | 192 | assert(res);
|
---|
[03362fbd] | 193 |
|
---|
[1864948] | 194 | for (size_t i = 0; i < res->count; ++i) {
|
---|
| 195 | /* Check for assigned channel */
|
---|
| 196 | if (((res->resources[i].type == DMA_CHANNEL_16) &&
|
---|
| 197 | (res->resources[i].res.dma_channel.dma16 == channel)) ||
|
---|
| 198 | ((res->resources[i].type == DMA_CHANNEL_8) &&
|
---|
| 199 | (res->resources[i].res.dma_channel.dma8 == channel))) {
|
---|
| 200 | return dma_channel_remain(channel, size);
|
---|
| 201 | }
|
---|
| 202 | }
|
---|
[03362fbd] | 203 |
|
---|
[1864948] | 204 | return EINVAL;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
[8b1e15ac] | 207 | static hw_res_ops_t isa_fun_hw_res_ops = {
|
---|
[ff97957] | 208 | .get_resource_list = isa_fun_get_resources,
|
---|
[bc6762f] | 209 | .enable_interrupt = isa_fun_enable_interrupt,
|
---|
[d51838f] | 210 | .disable_interrupt = isa_fun_disable_interrupt,
|
---|
| 211 | .clear_interrupt = isa_fun_clear_interrupt,
|
---|
[bc6762f] | 212 | .dma_channel_setup = isa_fun_setup_dma,
|
---|
[1864948] | 213 | .dma_channel_remain = isa_fun_remain_dma,
|
---|
[5dc9622] | 214 | };
|
---|
| 215 |
|
---|
[ff97957] | 216 | static pio_window_t *isa_fun_get_pio_window(ddf_fun_t *fnode)
|
---|
| 217 | {
|
---|
| 218 | ddf_dev_t *dev = ddf_fun_get_dev(fnode);
|
---|
| 219 | isa_bus_t *isa = isa_bus(dev);
|
---|
| 220 | assert(isa);
|
---|
| 221 |
|
---|
| 222 | return &isa->pio_win;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | static pio_window_ops_t isa_fun_pio_window_ops = {
|
---|
| 226 | .get_pio_window = isa_fun_get_pio_window
|
---|
| 227 | };
|
---|
| 228 |
|
---|
[b28dabe] | 229 | static ddf_dev_ops_t isa_fun_ops= {
|
---|
| 230 | .interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops,
|
---|
[ff97957] | 231 | .interfaces[PIO_WINDOW_DEV_IFACE] = &isa_fun_pio_window_ops,
|
---|
[b28dabe] | 232 | };
|
---|
[5dc9622] | 233 |
|
---|
[0c0f823b] | 234 | static int isa_dev_add(ddf_dev_t *dev);
|
---|
[f278930] | 235 | static int isa_dev_remove(ddf_dev_t *dev);
|
---|
[5b68e0c] | 236 | static int isa_fun_online(ddf_fun_t *fun);
|
---|
| 237 | static int isa_fun_offline(ddf_fun_t *fun);
|
---|
[892e4e1] | 238 |
|
---|
[032e0bb] | 239 | /** The isa device driver's standard operations */
|
---|
[892e4e1] | 240 | static driver_ops_t isa_ops = {
|
---|
[0c0f823b] | 241 | .dev_add = &isa_dev_add,
|
---|
[f278930] | 242 | .dev_remove = &isa_dev_remove,
|
---|
[5b68e0c] | 243 | .fun_online = &isa_fun_online,
|
---|
| 244 | .fun_offline = &isa_fun_offline
|
---|
[892e4e1] | 245 | };
|
---|
| 246 |
|
---|
[032e0bb] | 247 | /** The isa device driver structure. */
|
---|
[892e4e1] | 248 | static driver_t isa_driver = {
|
---|
| 249 | .name = NAME,
|
---|
| 250 | .driver_ops = &isa_ops
|
---|
| 251 | };
|
---|
| 252 |
|
---|
[f278930] | 253 | static isa_fun_t *isa_fun_create(isa_bus_t *isa, const char *name)
|
---|
[c1a8ae52] | 254 | {
|
---|
[f278930] | 255 | ddf_fun_t *fnode = ddf_fun_create(isa->dev, fun_inner, name);
|
---|
| 256 | if (fnode == NULL)
|
---|
[c1a8ae52] | 257 | return NULL;
|
---|
[032e0bb] | 258 |
|
---|
[f278930] | 259 | isa_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(isa_fun_t));
|
---|
[0bbd13e] | 260 | if (fun == NULL) {
|
---|
| 261 | ddf_fun_destroy(fnode);
|
---|
[c1a8ae52] | 262 | return NULL;
|
---|
[0bbd13e] | 263 | }
|
---|
[032e0bb] | 264 |
|
---|
[f278930] | 265 | fibril_mutex_initialize(&fun->mutex);
|
---|
[85c4cc45] | 266 | fun->hw_resources.resources = fun->resources;
|
---|
| 267 |
|
---|
[68414f4a] | 268 | fun->fnode = fnode;
|
---|
[8b1e15ac] | 269 | return fun;
|
---|
[c1a8ae52] | 270 | }
|
---|
| 271 |
|
---|
[68414f4a] | 272 | static char *fun_conf_read(const char *conf_path)
|
---|
[032e0bb] | 273 | {
|
---|
| 274 | bool suc = false;
|
---|
[c1a8ae52] | 275 | char *buf = NULL;
|
---|
| 276 | bool opened = false;
|
---|
[032e0bb] | 277 | int fd;
|
---|
[6efd162] | 278 | size_t len;
|
---|
[c0393db] | 279 | ssize_t r;
|
---|
[58898d1d] | 280 | struct stat st;
|
---|
[032e0bb] | 281 |
|
---|
[b19e892] | 282 | fd = vfs_lookup_open(conf_path, WALK_REGULAR, MODE_READ);
|
---|
[c1a8ae52] | 283 | if (fd < 0) {
|
---|
[ebcb05a] | 284 | ddf_msg(LVL_ERROR, "Unable to open %s", conf_path);
|
---|
[c1a8ae52] | 285 | goto cleanup;
|
---|
[032e0bb] | 286 | }
|
---|
| 287 |
|
---|
| 288 | opened = true;
|
---|
| 289 |
|
---|
[23a0368] | 290 | if (vfs_stat(fd, &st) != EOK) {
|
---|
| 291 | ddf_msg(LVL_ERROR, "Unable to vfs_stat %d", fd);
|
---|
[58898d1d] | 292 | goto cleanup;
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 | len = st.size;
|
---|
[6efd162] | 296 | if (len == 0) {
|
---|
[ebcb05a] | 297 | ddf_msg(LVL_ERROR, "Configuration file '%s' is empty.",
|
---|
[fc51296] | 298 | conf_path);
|
---|
[032e0bb] | 299 | goto cleanup;
|
---|
[c1a8ae52] | 300 | }
|
---|
[032e0bb] | 301 |
|
---|
[6efd162] | 302 | buf = malloc(len + 1);
|
---|
[c1a8ae52] | 303 | if (buf == NULL) {
|
---|
[ebcb05a] | 304 | ddf_msg(LVL_ERROR, "Memory allocation failed.");
|
---|
[c1a8ae52] | 305 | goto cleanup;
|
---|
[032e0bb] | 306 | }
|
---|
| 307 |
|
---|
[ce04ea44] | 308 | r = vfs_read(fd, (aoff64_t []) {0}, buf, len);
|
---|
[6efd162] | 309 | if (r < 0) {
|
---|
| 310 | ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
|
---|
| 311 | goto cleanup;
|
---|
| 312 | }
|
---|
[032e0bb] | 313 |
|
---|
[6efd162] | 314 | buf[len] = 0;
|
---|
[032e0bb] | 315 |
|
---|
[c1a8ae52] | 316 | suc = true;
|
---|
[032e0bb] | 317 |
|
---|
[c1a8ae52] | 318 | cleanup:
|
---|
[032e0bb] | 319 | if (!suc && buf != NULL) {
|
---|
| 320 | free(buf);
|
---|
[c1a8ae52] | 321 | buf = NULL;
|
---|
| 322 | }
|
---|
[032e0bb] | 323 |
|
---|
| 324 | if (opened)
|
---|
[9c4cf0d] | 325 | vfs_put(fd);
|
---|
[032e0bb] | 326 |
|
---|
| 327 | return buf;
|
---|
[c1a8ae52] | 328 | }
|
---|
| 329 |
|
---|
[032e0bb] | 330 | static char *str_get_line(char *str, char **next)
|
---|
| 331 | {
|
---|
[5dc9622] | 332 | char *line = str;
|
---|
[cf56332] | 333 | *next = NULL;
|
---|
[032e0bb] | 334 |
|
---|
| 335 | if (str == NULL) {
|
---|
[f928a8a] | 336 | return NULL;
|
---|
| 337 | }
|
---|
[032e0bb] | 338 |
|
---|
| 339 | while (*str != '\0' && *str != '\n') {
|
---|
[5dc9622] | 340 | str++;
|
---|
[032e0bb] | 341 | }
|
---|
| 342 |
|
---|
| 343 | if (*str != '\0') {
|
---|
[5dc9622] | 344 | *next = str + 1;
|
---|
[032e0bb] | 345 | }
|
---|
| 346 |
|
---|
| 347 | *str = '\0';
|
---|
[5dc9622] | 348 | return line;
|
---|
[c1a8ae52] | 349 | }
|
---|
| 350 |
|
---|
| 351 | static bool line_empty(const char *line)
|
---|
| 352 | {
|
---|
[032e0bb] | 353 | while (line != NULL && *line != 0) {
|
---|
| 354 | if (!isspace(*line))
|
---|
[c1a8ae52] | 355 | return false;
|
---|
[032e0bb] | 356 | line++;
|
---|
| 357 | }
|
---|
| 358 |
|
---|
| 359 | return true;
|
---|
[c1a8ae52] | 360 | }
|
---|
| 361 |
|
---|
[032e0bb] | 362 | static char *get_device_name(char *line)
|
---|
| 363 | {
|
---|
| 364 | /* Skip leading spaces. */
|
---|
| 365 | while (*line != '\0' && isspace(*line)) {
|
---|
[c1a8ae52] | 366 | line++;
|
---|
| 367 | }
|
---|
[032e0bb] | 368 |
|
---|
| 369 | /* Get the name part of the rest of the line. */
|
---|
[ee3f6f6] | 370 | str_tok(line, ":", NULL);
|
---|
[3d4ad475] | 371 | return line;
|
---|
[c1a8ae52] | 372 | }
|
---|
| 373 |
|
---|
[b5f305b] | 374 | static inline const char *skip_spaces(const char *line)
|
---|
[c1a8ae52] | 375 | {
|
---|
[032e0bb] | 376 | /* Skip leading spaces. */
|
---|
| 377 | while (*line != '\0' && isspace(*line))
|
---|
[c1a8ae52] | 378 | line++;
|
---|
| 379 |
|
---|
[032e0bb] | 380 | return line;
|
---|
| 381 | }
|
---|
[c1a8ae52] | 382 |
|
---|
[82e4005] | 383 | static void isa_fun_add_irq(isa_fun_t *fun, int irq)
|
---|
[c1a8ae52] | 384 | {
|
---|
[68414f4a] | 385 | size_t count = fun->hw_resources.count;
|
---|
| 386 | hw_resource_t *resources = fun->hw_resources.resources;
|
---|
[032e0bb] | 387 |
|
---|
[5dc9622] | 388 | if (count < ISA_MAX_HW_RES) {
|
---|
| 389 | resources[count].type = INTERRUPT;
|
---|
| 390 | resources[count].res.interrupt.irq = irq;
|
---|
[032e0bb] | 391 |
|
---|
[68414f4a] | 392 | fun->hw_resources.count++;
|
---|
[032e0bb] | 393 |
|
---|
[ebcb05a] | 394 | ddf_msg(LVL_NOTE, "Added irq 0x%x to function %s", irq,
|
---|
[56fd7cf] | 395 | ddf_fun_get_name(fun->fnode));
|
---|
[032e0bb] | 396 | }
|
---|
[5dc9622] | 397 | }
|
---|
| 398 |
|
---|
[82e4005] | 399 | static void isa_fun_add_dma(isa_fun_t *fun, int dma)
|
---|
[55a8e0cb] | 400 | {
|
---|
| 401 | size_t count = fun->hw_resources.count;
|
---|
| 402 | hw_resource_t *resources = fun->hw_resources.resources;
|
---|
[d9cf684a] | 403 |
|
---|
[55a8e0cb] | 404 | if (count < ISA_MAX_HW_RES) {
|
---|
[d9cf684a] | 405 | if ((dma > 0) && (dma < 4)) {
|
---|
[55a8e0cb] | 406 | resources[count].type = DMA_CHANNEL_8;
|
---|
| 407 | resources[count].res.dma_channel.dma8 = dma;
|
---|
[d9cf684a] | 408 |
|
---|
[55a8e0cb] | 409 | fun->hw_resources.count++;
|
---|
| 410 | ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,
|
---|
[56fd7cf] | 411 | ddf_fun_get_name(fun->fnode));
|
---|
[d9cf684a] | 412 |
|
---|
[55a8e0cb] | 413 | return;
|
---|
| 414 | }
|
---|
| 415 |
|
---|
[d9cf684a] | 416 | if ((dma > 4) && (dma < 8)) {
|
---|
[55a8e0cb] | 417 | resources[count].type = DMA_CHANNEL_16;
|
---|
| 418 | resources[count].res.dma_channel.dma16 = dma;
|
---|
[d9cf684a] | 419 |
|
---|
[55a8e0cb] | 420 | fun->hw_resources.count++;
|
---|
| 421 | ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,
|
---|
[56fd7cf] | 422 | ddf_fun_get_name(fun->fnode));
|
---|
[d9cf684a] | 423 |
|
---|
[55a8e0cb] | 424 | return;
|
---|
| 425 | }
|
---|
[d9cf684a] | 426 |
|
---|
[55a8e0cb] | 427 | ddf_msg(LVL_WARN, "Skipped dma 0x%x for function %s", dma,
|
---|
[56fd7cf] | 428 | ddf_fun_get_name(fun->fnode));
|
---|
[55a8e0cb] | 429 | }
|
---|
| 430 | }
|
---|
| 431 |
|
---|
[82e4005] | 432 | static void isa_fun_add_io_range(isa_fun_t *fun, size_t addr, size_t len)
|
---|
[5dc9622] | 433 | {
|
---|
[68414f4a] | 434 | size_t count = fun->hw_resources.count;
|
---|
| 435 | hw_resource_t *resources = fun->hw_resources.resources;
|
---|
[032e0bb] | 436 |
|
---|
[0a428943] | 437 | isa_bus_t *isa = isa_bus(ddf_fun_get_dev(fun->fnode));
|
---|
| 438 |
|
---|
[5dc9622] | 439 | if (count < ISA_MAX_HW_RES) {
|
---|
| 440 | resources[count].type = IO_RANGE;
|
---|
| 441 | resources[count].res.io_range.address = addr;
|
---|
[0a428943] | 442 | resources[count].res.io_range.address += isa->pio_win.io.base;
|
---|
[5dc9622] | 443 | resources[count].res.io_range.size = len;
|
---|
[9e470c0] | 444 | resources[count].res.io_range.relative = false;
|
---|
[032e0bb] | 445 | resources[count].res.io_range.endianness = LITTLE_ENDIAN;
|
---|
| 446 |
|
---|
[68414f4a] | 447 | fun->hw_resources.count++;
|
---|
[032e0bb] | 448 |
|
---|
[fc51296] | 449 | ddf_msg(LVL_NOTE, "Added io range (addr=0x%x, size=0x%x) to "
|
---|
[ebcb05a] | 450 | "function %s", (unsigned int) addr, (unsigned int) len,
|
---|
[56fd7cf] | 451 | ddf_fun_get_name(fun->fnode));
|
---|
[032e0bb] | 452 | }
|
---|
[c1a8ae52] | 453 | }
|
---|
| 454 |
|
---|
[b446b02] | 455 | static void isa_fun_add_mem_range(isa_fun_t *fun, uintptr_t addr, size_t len)
|
---|
| 456 | {
|
---|
| 457 | size_t count = fun->hw_resources.count;
|
---|
| 458 | hw_resource_t *resources = fun->hw_resources.resources;
|
---|
| 459 |
|
---|
| 460 | isa_bus_t *isa = isa_bus(ddf_fun_get_dev(fun->fnode));
|
---|
| 461 |
|
---|
| 462 | if (count < ISA_MAX_HW_RES) {
|
---|
| 463 | resources[count].type = MEM_RANGE;
|
---|
| 464 | resources[count].res.mem_range.address = addr;
|
---|
| 465 | resources[count].res.mem_range.address += isa->pio_win.mem.base;
|
---|
| 466 | resources[count].res.mem_range.size = len;
|
---|
| 467 | resources[count].res.mem_range.relative = true;
|
---|
| 468 | resources[count].res.mem_range.endianness = LITTLE_ENDIAN;
|
---|
| 469 |
|
---|
| 470 | fun->hw_resources.count++;
|
---|
| 471 |
|
---|
| 472 | ddf_msg(LVL_NOTE, "Added mem range (addr=0x%zx, size=0x%x) to "
|
---|
| 473 | "function %s", (uintptr_t) addr, (unsigned int) len,
|
---|
| 474 | ddf_fun_get_name(fun->fnode));
|
---|
| 475 | }
|
---|
| 476 | }
|
---|
| 477 |
|
---|
[b5f305b] | 478 | static void fun_parse_irq(isa_fun_t *fun, const char *val)
|
---|
[c1a8ae52] | 479 | {
|
---|
| 480 | int irq = 0;
|
---|
| 481 | char *end = NULL;
|
---|
[032e0bb] | 482 |
|
---|
[8b1e15ac] | 483 | val = skip_spaces(val);
|
---|
[5cc9eba] | 484 | irq = (int) strtol(val, &end, 10);
|
---|
[032e0bb] | 485 |
|
---|
| 486 | if (val != end)
|
---|
[82e4005] | 487 | isa_fun_add_irq(fun, irq);
|
---|
[c1a8ae52] | 488 | }
|
---|
| 489 |
|
---|
[b5f305b] | 490 | static void fun_parse_dma(isa_fun_t *fun, const char *val)
|
---|
[55a8e0cb] | 491 | {
|
---|
| 492 | char *end = NULL;
|
---|
[d9cf684a] | 493 |
|
---|
[55a8e0cb] | 494 | val = skip_spaces(val);
|
---|
[1ec394e] | 495 | const int dma = strtol(val, &end, 10);
|
---|
[d9cf684a] | 496 |
|
---|
[55a8e0cb] | 497 | if (val != end)
|
---|
[82e4005] | 498 | isa_fun_add_dma(fun, dma);
|
---|
[55a8e0cb] | 499 | }
|
---|
| 500 |
|
---|
[b5f305b] | 501 | static void fun_parse_io_range(isa_fun_t *fun, const char *val)
|
---|
[c1a8ae52] | 502 | {
|
---|
[5dc9622] | 503 | size_t addr, len;
|
---|
| 504 | char *end = NULL;
|
---|
[032e0bb] | 505 |
|
---|
[8b1e15ac] | 506 | val = skip_spaces(val);
|
---|
[5dc9622] | 507 | addr = strtol(val, &end, 0x10);
|
---|
[032e0bb] | 508 |
|
---|
| 509 | if (val == end)
|
---|
[5dc9622] | 510 | return;
|
---|
[032e0bb] | 511 |
|
---|
[8b1e15ac] | 512 | val = skip_spaces(end);
|
---|
[5dc9622] | 513 | len = strtol(val, &end, 0x10);
|
---|
[032e0bb] | 514 |
|
---|
| 515 | if (val == end)
|
---|
[5dc9622] | 516 | return;
|
---|
[032e0bb] | 517 |
|
---|
[82e4005] | 518 | isa_fun_add_io_range(fun, addr, len);
|
---|
[c1a8ae52] | 519 | }
|
---|
| 520 |
|
---|
[b446b02] | 521 | static void fun_parse_mem_range(isa_fun_t *fun, const char *val)
|
---|
| 522 | {
|
---|
| 523 | uintptr_t addr;
|
---|
| 524 | size_t len;
|
---|
| 525 | char *end = NULL;
|
---|
| 526 |
|
---|
| 527 | val = skip_spaces(val);
|
---|
| 528 | addr = strtoul(val, &end, 0x10);
|
---|
| 529 |
|
---|
| 530 | if (val == end)
|
---|
| 531 | return;
|
---|
| 532 |
|
---|
| 533 | val = skip_spaces(end);
|
---|
| 534 | len = strtol(val, &end, 0x10);
|
---|
| 535 |
|
---|
| 536 | if (val == end)
|
---|
| 537 | return;
|
---|
| 538 |
|
---|
| 539 | isa_fun_add_mem_range(fun, addr, len);
|
---|
| 540 | }
|
---|
| 541 |
|
---|
[b5f305b] | 542 | static void get_match_id(char **id, const char *val)
|
---|
[c1a8ae52] | 543 | {
|
---|
[b5f305b] | 544 | const char *end = val;
|
---|
[032e0bb] | 545 |
|
---|
| 546 | while (!isspace(*end))
|
---|
[5dc9622] | 547 | end++;
|
---|
[032e0bb] | 548 |
|
---|
[f928a8a] | 549 | size_t size = end - val + 1;
|
---|
[5dc9622] | 550 | *id = (char *)malloc(size);
|
---|
[032e0bb] | 551 | str_cpy(*id, size, val);
|
---|
[5dc9622] | 552 | }
|
---|
| 553 |
|
---|
[b5f305b] | 554 | static void fun_parse_match_id(isa_fun_t *fun, const char *val)
|
---|
[032e0bb] | 555 | {
|
---|
[5dc9622] | 556 | char *id = NULL;
|
---|
| 557 | char *end = NULL;
|
---|
[032e0bb] | 558 |
|
---|
[68414f4a] | 559 | val = skip_spaces(val);
|
---|
[032e0bb] | 560 |
|
---|
[cf56332] | 561 | int score = (int)strtol(val, &end, 10);
|
---|
[5dc9622] | 562 | if (val == end) {
|
---|
[fc51296] | 563 | ddf_msg(LVL_ERROR, "Cannot read match score for function "
|
---|
[56fd7cf] | 564 | "%s.", ddf_fun_get_name(fun->fnode));
|
---|
[5dc9622] | 565 | return;
|
---|
| 566 | }
|
---|
[032e0bb] | 567 |
|
---|
[bab6388] | 568 | val = skip_spaces(end);
|
---|
[5dc9622] | 569 | get_match_id(&id, val);
|
---|
[032e0bb] | 570 | if (id == NULL) {
|
---|
[ebcb05a] | 571 | ddf_msg(LVL_ERROR, "Cannot read match ID for function %s.",
|
---|
[56fd7cf] | 572 | ddf_fun_get_name(fun->fnode));
|
---|
[5dc9622] | 573 | return;
|
---|
| 574 | }
|
---|
[032e0bb] | 575 |
|
---|
[fc51296] | 576 | ddf_msg(LVL_DEBUG, "Adding match id '%s' with score %d to "
|
---|
[56fd7cf] | 577 | "function %s", id, score, ddf_fun_get_name(fun->fnode));
|
---|
[cd0684d] | 578 |
|
---|
[cf56332] | 579 | int rc = ddf_fun_add_match_id(fun->fnode, id, score);
|
---|
[fc51296] | 580 | if (rc != EOK) {
|
---|
[ebcb05a] | 581 | ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
|
---|
[fc51296] | 582 | str_error(rc));
|
---|
| 583 | }
|
---|
[ef9460b] | 584 |
|
---|
| 585 | free(id);
|
---|
[c1a8ae52] | 586 | }
|
---|
| 587 |
|
---|
[b5f305b] | 588 | static bool prop_parse(isa_fun_t *fun, const char *line, const char *prop,
|
---|
| 589 | void (*read_fn)(isa_fun_t *, const char *))
|
---|
[5fe1c32] | 590 | {
|
---|
| 591 | size_t proplen = str_size(prop);
|
---|
[032e0bb] | 592 |
|
---|
| 593 | if (str_lcmp(line, prop, proplen) == 0) {
|
---|
[5fe1c32] | 594 | line += proplen;
|
---|
| 595 | line = skip_spaces(line);
|
---|
[8b1e15ac] | 596 | (*read_fn)(fun, line);
|
---|
[032e0bb] | 597 |
|
---|
[5fe1c32] | 598 | return true;
|
---|
| 599 | }
|
---|
[032e0bb] | 600 |
|
---|
| 601 | return false;
|
---|
[5fe1c32] | 602 | }
|
---|
| 603 |
|
---|
[b5f305b] | 604 | static void fun_prop_parse(isa_fun_t *fun, const char *line)
|
---|
[c1a8ae52] | 605 | {
|
---|
[032e0bb] | 606 | /* Skip leading spaces. */
|
---|
[c1a8ae52] | 607 | line = skip_spaces(line);
|
---|
[032e0bb] | 608 |
|
---|
[68414f4a] | 609 | if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) &&
|
---|
[b446b02] | 610 | !prop_parse(fun, line, "mem_range", &fun_parse_mem_range) &&
|
---|
[68414f4a] | 611 | !prop_parse(fun, line, "irq", &fun_parse_irq) &&
|
---|
[55a8e0cb] | 612 | !prop_parse(fun, line, "dma", &fun_parse_dma) &&
|
---|
[fc51296] | 613 | !prop_parse(fun, line, "match", &fun_parse_match_id)) {
|
---|
| 614 |
|
---|
[ebcb05a] | 615 | ddf_msg(LVL_ERROR, "Undefined device property at line '%s'",
|
---|
[fc51296] | 616 | line);
|
---|
[032e0bb] | 617 | }
|
---|
[c1a8ae52] | 618 | }
|
---|
| 619 |
|
---|
[f278930] | 620 | static char *isa_fun_read_info(char *fun_conf, isa_bus_t *isa)
|
---|
[c1a8ae52] | 621 | {
|
---|
| 622 | char *line;
|
---|
[032e0bb] | 623 |
|
---|
| 624 | /* Skip empty lines. */
|
---|
[1de97fe6] | 625 | do {
|
---|
[8b1e15ac] | 626 | line = str_get_line(fun_conf, &fun_conf);
|
---|
[032e0bb] | 627 |
|
---|
| 628 | if (line == NULL) {
|
---|
| 629 | /* no more lines */
|
---|
[c1a8ae52] | 630 | return NULL;
|
---|
| 631 | }
|
---|
[032e0bb] | 632 |
|
---|
[1de97fe6] | 633 | } while (line_empty(line));
|
---|
[032e0bb] | 634 |
|
---|
| 635 | /* Get device name. */
|
---|
[3d4ad475] | 636 | const char *fun_name = get_device_name(line);
|
---|
[8b1e15ac] | 637 | if (fun_name == NULL)
|
---|
[c1a8ae52] | 638 | return NULL;
|
---|
[032e0bb] | 639 |
|
---|
[f278930] | 640 | isa_fun_t *fun = isa_fun_create(isa, fun_name);
|
---|
[8b1e15ac] | 641 | if (fun == NULL) {
|
---|
[c1a8ae52] | 642 | return NULL;
|
---|
| 643 | }
|
---|
[032e0bb] | 644 |
|
---|
| 645 | /* Get properties of the device (match ids, irq and io range). */
|
---|
| 646 | while (true) {
|
---|
[8b1e15ac] | 647 | line = str_get_line(fun_conf, &fun_conf);
|
---|
[032e0bb] | 648 |
|
---|
[5dc9622] | 649 | if (line_empty(line)) {
|
---|
[032e0bb] | 650 | /* no more device properties */
|
---|
[5dc9622] | 651 | break;
|
---|
| 652 | }
|
---|
[032e0bb] | 653 |
|
---|
| 654 | /*
|
---|
| 655 | * Get the device's property from the configuration line
|
---|
| 656 | * and store it in the device structure.
|
---|
| 657 | */
|
---|
[68414f4a] | 658 | fun_prop_parse(fun, line);
|
---|
[c1a8ae52] | 659 | }
|
---|
[032e0bb] | 660 |
|
---|
| 661 | /* Set device operations to the device. */
|
---|
[56fd7cf] | 662 | ddf_fun_set_ops(fun->fnode, &isa_fun_ops);
|
---|
[97a62fe] | 663 |
|
---|
[56fd7cf] | 664 | ddf_msg(LVL_DEBUG, "Binding function %s.", ddf_fun_get_name(fun->fnode));
|
---|
[032e0bb] | 665 |
|
---|
[97a62fe] | 666 | /* XXX Handle error */
|
---|
| 667 | (void) ddf_fun_bind(fun->fnode);
|
---|
[032e0bb] | 668 |
|
---|
[f278930] | 669 | list_append(&fun->bus_link, &isa->functions);
|
---|
| 670 |
|
---|
[8b1e15ac] | 671 | return fun_conf;
|
---|
[c1a8ae52] | 672 | }
|
---|
| 673 |
|
---|
[0d7eb0f] | 674 | static void isa_functions_add(isa_bus_t *isa)
|
---|
[c1a8ae52] | 675 | {
|
---|
[7e9e652] | 676 | #define BASE_CLASS_BRIDGE 0x06
|
---|
| 677 | #define SUB_CLASS_BRIDGE_ISA 0x01
|
---|
| 678 | bool isa_bridge = ((isa->pci_class == BASE_CLASS_BRIDGE) &&
|
---|
| 679 | (isa->pci_subclass == SUB_CLASS_BRIDGE_ISA));
|
---|
| 680 |
|
---|
[3c5b86c] | 681 | #define VENDOR_ID_SUN 0x108e
|
---|
| 682 | #define DEVICE_ID_EBUS 0x1000
|
---|
[7e9e652] | 683 | bool ebus = ((isa->pci_vendor_id == VENDOR_ID_SUN) &&
|
---|
| 684 | (isa->pci_device_id == DEVICE_ID_EBUS));
|
---|
[3c5b86c] | 685 |
|
---|
[7e9e652] | 686 | const char *conf_path = NULL;
|
---|
| 687 | if (isa_bridge)
|
---|
[3c5b86c] | 688 | conf_path = ISA_CHILD_FUN_CONF_PATH;
|
---|
[7e9e652] | 689 | else if (ebus)
|
---|
| 690 | conf_path = EBUS_CHILD_FUN_CONF_PATH;
|
---|
[3c5b86c] | 691 |
|
---|
| 692 | char *conf = fun_conf_read(conf_path);
|
---|
[032e0bb] | 693 | while (conf != NULL && *conf != '\0') {
|
---|
[f278930] | 694 | conf = isa_fun_read_info(conf, isa);
|
---|
[032e0bb] | 695 | }
|
---|
[0d7eb0f] | 696 | free(conf);
|
---|
[c1a8ae52] | 697 | }
|
---|
[892e4e1] | 698 |
|
---|
[0c0f823b] | 699 | static int isa_dev_add(ddf_dev_t *dev)
|
---|
[892e4e1] | 700 | {
|
---|
[0a428943] | 701 | async_sess_t *sess;
|
---|
| 702 | int rc;
|
---|
| 703 |
|
---|
[0c0f823b] | 704 | ddf_msg(LVL_DEBUG, "isa_dev_add, device handle = %d",
|
---|
[56fd7cf] | 705 | (int) ddf_dev_get_handle(dev));
|
---|
[032e0bb] | 706 |
|
---|
[cf56332] | 707 | isa_bus_t *isa = ddf_dev_data_alloc(dev, sizeof(isa_bus_t));
|
---|
[f278930] | 708 | if (isa == NULL)
|
---|
| 709 | return ENOMEM;
|
---|
| 710 |
|
---|
| 711 | fibril_mutex_initialize(&isa->mutex);
|
---|
| 712 | isa->dev = dev;
|
---|
| 713 | list_initialize(&isa->functions);
|
---|
| 714 |
|
---|
[2fd26bb] | 715 | sess = ddf_dev_parent_sess_get(dev);
|
---|
[0a428943] | 716 | if (sess == NULL) {
|
---|
| 717 | ddf_msg(LVL_ERROR, "isa_dev_add failed to connect to the "
|
---|
| 718 | "parent driver.");
|
---|
| 719 | return ENOENT;
|
---|
| 720 | }
|
---|
| 721 |
|
---|
[7e9e652] | 722 | rc = pci_config_space_read_16(sess, PCI_VENDOR_ID, &isa->pci_vendor_id);
|
---|
| 723 | if (rc != EOK)
|
---|
| 724 | return rc;
|
---|
| 725 | rc = pci_config_space_read_16(sess, PCI_DEVICE_ID, &isa->pci_device_id);
|
---|
| 726 | if (rc != EOK)
|
---|
| 727 | return rc;
|
---|
| 728 | rc = pci_config_space_read_8(sess, PCI_BASE_CLASS, &isa->pci_class);
|
---|
[3c5b86c] | 729 | if (rc != EOK)
|
---|
| 730 | return rc;
|
---|
[7e9e652] | 731 | rc = pci_config_space_read_8(sess, PCI_SUB_CLASS, &isa->pci_subclass);
|
---|
[3c5b86c] | 732 | if (rc != EOK)
|
---|
| 733 | return rc;
|
---|
| 734 |
|
---|
[0a428943] | 735 | rc = pio_window_get(sess, &isa->pio_win);
|
---|
| 736 | if (rc != EOK) {
|
---|
| 737 | ddf_msg(LVL_ERROR, "isa_dev_add failed to get PIO window "
|
---|
| 738 | "for the device.");
|
---|
| 739 | return rc;
|
---|
| 740 | }
|
---|
| 741 |
|
---|
[8b1e15ac] | 742 | /* Make the bus device more visible. Does not do anything. */
|
---|
[ebcb05a] | 743 | ddf_msg(LVL_DEBUG, "Adding a 'ctl' function");
|
---|
[8b1e15ac] | 744 |
|
---|
[f278930] | 745 | fibril_mutex_lock(&isa->mutex);
|
---|
| 746 |
|
---|
| 747 | isa->fctl = ddf_fun_create(dev, fun_exposed, "ctl");
|
---|
| 748 | if (isa->fctl == NULL) {
|
---|
[ebcb05a] | 749 | ddf_msg(LVL_ERROR, "Failed creating control function.");
|
---|
[97a62fe] | 750 | return EXDEV;
|
---|
| 751 | }
|
---|
| 752 |
|
---|
[f278930] | 753 | if (ddf_fun_bind(isa->fctl) != EOK) {
|
---|
| 754 | ddf_fun_destroy(isa->fctl);
|
---|
[ebcb05a] | 755 | ddf_msg(LVL_ERROR, "Failed binding control function.");
|
---|
[97a62fe] | 756 | return EXDEV;
|
---|
| 757 | }
|
---|
[8b1e15ac] | 758 |
|
---|
[68414f4a] | 759 | /* Add functions as specified in the configuration file. */
|
---|
[f278930] | 760 | isa_functions_add(isa);
|
---|
[ebcb05a] | 761 | ddf_msg(LVL_NOTE, "Finished enumerating legacy functions");
|
---|
[032e0bb] | 762 |
|
---|
[f278930] | 763 | fibril_mutex_unlock(&isa->mutex);
|
---|
| 764 |
|
---|
| 765 | return EOK;
|
---|
| 766 | }
|
---|
| 767 |
|
---|
| 768 | static int isa_dev_remove(ddf_dev_t *dev)
|
---|
| 769 | {
|
---|
[56fd7cf] | 770 | isa_bus_t *isa = isa_bus(dev);
|
---|
[f278930] | 771 |
|
---|
| 772 | fibril_mutex_lock(&isa->mutex);
|
---|
| 773 |
|
---|
| 774 | while (!list_empty(&isa->functions)) {
|
---|
| 775 | isa_fun_t *fun = list_get_instance(list_first(&isa->functions),
|
---|
| 776 | isa_fun_t, bus_link);
|
---|
| 777 |
|
---|
[cf56332] | 778 | int rc = ddf_fun_offline(fun->fnode);
|
---|
[f278930] | 779 | if (rc != EOK) {
|
---|
| 780 | fibril_mutex_unlock(&isa->mutex);
|
---|
[56fd7cf] | 781 | ddf_msg(LVL_ERROR, "Failed offlining %s", ddf_fun_get_name(fun->fnode));
|
---|
[f278930] | 782 | return rc;
|
---|
| 783 | }
|
---|
| 784 |
|
---|
| 785 | rc = ddf_fun_unbind(fun->fnode);
|
---|
| 786 | if (rc != EOK) {
|
---|
| 787 | fibril_mutex_unlock(&isa->mutex);
|
---|
[56fd7cf] | 788 | ddf_msg(LVL_ERROR, "Failed unbinding %s", ddf_fun_get_name(fun->fnode));
|
---|
[f278930] | 789 | return rc;
|
---|
| 790 | }
|
---|
| 791 |
|
---|
| 792 | list_remove(&fun->bus_link);
|
---|
| 793 |
|
---|
| 794 | ddf_fun_destroy(fun->fnode);
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | if (ddf_fun_unbind(isa->fctl) != EOK) {
|
---|
| 798 | fibril_mutex_unlock(&isa->mutex);
|
---|
| 799 | ddf_msg(LVL_ERROR, "Failed unbinding control function.");
|
---|
| 800 | return EXDEV;
|
---|
| 801 | }
|
---|
| 802 |
|
---|
| 803 | fibril_mutex_unlock(&isa->mutex);
|
---|
| 804 |
|
---|
[df747b9c] | 805 | return EOK;
|
---|
[892e4e1] | 806 | }
|
---|
| 807 |
|
---|
[5b68e0c] | 808 | static int isa_fun_online(ddf_fun_t *fun)
|
---|
| 809 | {
|
---|
| 810 | ddf_msg(LVL_DEBUG, "isa_fun_online()");
|
---|
| 811 | return ddf_fun_online(fun);
|
---|
| 812 | }
|
---|
| 813 |
|
---|
| 814 | static int isa_fun_offline(ddf_fun_t *fun)
|
---|
| 815 | {
|
---|
| 816 | ddf_msg(LVL_DEBUG, "isa_fun_offline()");
|
---|
| 817 | return ddf_fun_offline(fun);
|
---|
| 818 | }
|
---|
| 819 |
|
---|
[892e4e1] | 820 | int main(int argc, char *argv[])
|
---|
| 821 | {
|
---|
[032e0bb] | 822 | printf(NAME ": HelenOS ISA bus driver\n");
|
---|
[03362fbd] | 823 | ddf_log_init(NAME);
|
---|
[83a2f43] | 824 | return ddf_driver_main(&isa_driver);
|
---|
[892e4e1] | 825 | }
|
---|
| 826 |
|
---|
| 827 | /**
|
---|
| 828 | * @}
|
---|
| 829 | */
|
---|