[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 |
|
---|
[b7fd2a0] | 132 | static errno_t isa_fun_enable_interrupt(ddf_fun_t *fnode, int irq)
|
---|
[d51838f] | 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 |
|
---|
[b7fd2a0] | 142 | static errno_t isa_fun_disable_interrupt(ddf_fun_t *fnode, int irq)
|
---|
[d51838f] | 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 |
|
---|
[b7fd2a0] | 152 | static errno_t isa_fun_clear_interrupt(ddf_fun_t *fnode, int irq)
|
---|
[d51838f] | 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 |
|
---|
[b7fd2a0] | 162 | static errno_t 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 |
|
---|
[b7fd2a0] | 184 | static errno_t 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 |
|
---|
[1433ecda] | 229 | static ddf_dev_ops_t isa_fun_ops = {
|
---|
[b28dabe] | 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 |
|
---|
[b7fd2a0] | 234 | static errno_t isa_dev_add(ddf_dev_t *dev);
|
---|
| 235 | static errno_t isa_dev_remove(ddf_dev_t *dev);
|
---|
| 236 | static errno_t isa_fun_online(ddf_fun_t *fun);
|
---|
| 237 | static errno_t 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;
|
---|
[b7fd2a0] | 279 | errno_t rc;
|
---|
[8e3498b] | 280 | size_t nread;
|
---|
[39330200] | 281 | vfs_stat_t st;
|
---|
[032e0bb] | 282 |
|
---|
[f77c1c9] | 283 | rc = vfs_lookup_open(conf_path, WALK_REGULAR, MODE_READ, &fd);
|
---|
| 284 | if (rc != EOK) {
|
---|
[ebcb05a] | 285 | ddf_msg(LVL_ERROR, "Unable to open %s", conf_path);
|
---|
[c1a8ae52] | 286 | goto cleanup;
|
---|
[032e0bb] | 287 | }
|
---|
| 288 |
|
---|
| 289 | opened = true;
|
---|
| 290 |
|
---|
[23a0368] | 291 | if (vfs_stat(fd, &st) != EOK) {
|
---|
| 292 | ddf_msg(LVL_ERROR, "Unable to vfs_stat %d", fd);
|
---|
[58898d1d] | 293 | goto cleanup;
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 | len = st.size;
|
---|
[6efd162] | 297 | if (len == 0) {
|
---|
[ebcb05a] | 298 | ddf_msg(LVL_ERROR, "Configuration file '%s' is empty.",
|
---|
[fc51296] | 299 | conf_path);
|
---|
[032e0bb] | 300 | goto cleanup;
|
---|
[c1a8ae52] | 301 | }
|
---|
[032e0bb] | 302 |
|
---|
[6efd162] | 303 | buf = malloc(len + 1);
|
---|
[c1a8ae52] | 304 | if (buf == NULL) {
|
---|
[ebcb05a] | 305 | ddf_msg(LVL_ERROR, "Memory allocation failed.");
|
---|
[c1a8ae52] | 306 | goto cleanup;
|
---|
[032e0bb] | 307 | }
|
---|
| 308 |
|
---|
[1433ecda] | 309 | rc = vfs_read(fd, (aoff64_t []) { 0 }, buf, len, &nread);
|
---|
[8e3498b] | 310 | if (rc != EOK) {
|
---|
[6efd162] | 311 | ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
|
---|
| 312 | goto cleanup;
|
---|
| 313 | }
|
---|
[032e0bb] | 314 |
|
---|
[8e3498b] | 315 | buf[nread] = 0;
|
---|
[032e0bb] | 316 |
|
---|
[c1a8ae52] | 317 | suc = true;
|
---|
[032e0bb] | 318 |
|
---|
[c1a8ae52] | 319 | cleanup:
|
---|
[032e0bb] | 320 | if (!suc && buf != NULL) {
|
---|
| 321 | free(buf);
|
---|
[c1a8ae52] | 322 | buf = NULL;
|
---|
| 323 | }
|
---|
[032e0bb] | 324 |
|
---|
| 325 | if (opened)
|
---|
[9c4cf0d] | 326 | vfs_put(fd);
|
---|
[032e0bb] | 327 |
|
---|
| 328 | return buf;
|
---|
[c1a8ae52] | 329 | }
|
---|
| 330 |
|
---|
[032e0bb] | 331 | static char *str_get_line(char *str, char **next)
|
---|
| 332 | {
|
---|
[5dc9622] | 333 | char *line = str;
|
---|
[cf56332] | 334 | *next = NULL;
|
---|
[032e0bb] | 335 |
|
---|
| 336 | if (str == NULL) {
|
---|
[f928a8a] | 337 | return NULL;
|
---|
| 338 | }
|
---|
[032e0bb] | 339 |
|
---|
| 340 | while (*str != '\0' && *str != '\n') {
|
---|
[5dc9622] | 341 | str++;
|
---|
[032e0bb] | 342 | }
|
---|
| 343 |
|
---|
| 344 | if (*str != '\0') {
|
---|
[5dc9622] | 345 | *next = str + 1;
|
---|
[032e0bb] | 346 | }
|
---|
| 347 |
|
---|
| 348 | *str = '\0';
|
---|
[5dc9622] | 349 | return line;
|
---|
[c1a8ae52] | 350 | }
|
---|
| 351 |
|
---|
| 352 | static bool line_empty(const char *line)
|
---|
| 353 | {
|
---|
[032e0bb] | 354 | while (line != NULL && *line != 0) {
|
---|
| 355 | if (!isspace(*line))
|
---|
[c1a8ae52] | 356 | return false;
|
---|
[032e0bb] | 357 | line++;
|
---|
| 358 | }
|
---|
| 359 |
|
---|
| 360 | return true;
|
---|
[c1a8ae52] | 361 | }
|
---|
| 362 |
|
---|
[032e0bb] | 363 | static char *get_device_name(char *line)
|
---|
| 364 | {
|
---|
| 365 | /* Skip leading spaces. */
|
---|
| 366 | while (*line != '\0' && isspace(*line)) {
|
---|
[c1a8ae52] | 367 | line++;
|
---|
| 368 | }
|
---|
[032e0bb] | 369 |
|
---|
| 370 | /* Get the name part of the rest of the line. */
|
---|
[ee3f6f6] | 371 | str_tok(line, ":", NULL);
|
---|
[3d4ad475] | 372 | return line;
|
---|
[c1a8ae52] | 373 | }
|
---|
| 374 |
|
---|
[b5f305b] | 375 | static inline const char *skip_spaces(const char *line)
|
---|
[c1a8ae52] | 376 | {
|
---|
[032e0bb] | 377 | /* Skip leading spaces. */
|
---|
| 378 | while (*line != '\0' && isspace(*line))
|
---|
[c1a8ae52] | 379 | line++;
|
---|
| 380 |
|
---|
[032e0bb] | 381 | return line;
|
---|
| 382 | }
|
---|
[c1a8ae52] | 383 |
|
---|
[82e4005] | 384 | static void isa_fun_add_irq(isa_fun_t *fun, int irq)
|
---|
[c1a8ae52] | 385 | {
|
---|
[68414f4a] | 386 | size_t count = fun->hw_resources.count;
|
---|
| 387 | hw_resource_t *resources = fun->hw_resources.resources;
|
---|
[032e0bb] | 388 |
|
---|
[5dc9622] | 389 | if (count < ISA_MAX_HW_RES) {
|
---|
| 390 | resources[count].type = INTERRUPT;
|
---|
| 391 | resources[count].res.interrupt.irq = irq;
|
---|
[032e0bb] | 392 |
|
---|
[68414f4a] | 393 | fun->hw_resources.count++;
|
---|
[032e0bb] | 394 |
|
---|
[ebcb05a] | 395 | ddf_msg(LVL_NOTE, "Added irq 0x%x to function %s", irq,
|
---|
[56fd7cf] | 396 | ddf_fun_get_name(fun->fnode));
|
---|
[032e0bb] | 397 | }
|
---|
[5dc9622] | 398 | }
|
---|
| 399 |
|
---|
[82e4005] | 400 | static void isa_fun_add_dma(isa_fun_t *fun, int dma)
|
---|
[55a8e0cb] | 401 | {
|
---|
| 402 | size_t count = fun->hw_resources.count;
|
---|
| 403 | hw_resource_t *resources = fun->hw_resources.resources;
|
---|
[a35b458] | 404 |
|
---|
[55a8e0cb] | 405 | if (count < ISA_MAX_HW_RES) {
|
---|
[d9cf684a] | 406 | if ((dma > 0) && (dma < 4)) {
|
---|
[55a8e0cb] | 407 | resources[count].type = DMA_CHANNEL_8;
|
---|
| 408 | resources[count].res.dma_channel.dma8 = dma;
|
---|
[a35b458] | 409 |
|
---|
[55a8e0cb] | 410 | fun->hw_resources.count++;
|
---|
| 411 | ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,
|
---|
[56fd7cf] | 412 | ddf_fun_get_name(fun->fnode));
|
---|
[a35b458] | 413 |
|
---|
[55a8e0cb] | 414 | return;
|
---|
| 415 | }
|
---|
| 416 |
|
---|
[d9cf684a] | 417 | if ((dma > 4) && (dma < 8)) {
|
---|
[55a8e0cb] | 418 | resources[count].type = DMA_CHANNEL_16;
|
---|
| 419 | resources[count].res.dma_channel.dma16 = dma;
|
---|
[a35b458] | 420 |
|
---|
[55a8e0cb] | 421 | fun->hw_resources.count++;
|
---|
| 422 | ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,
|
---|
[56fd7cf] | 423 | ddf_fun_get_name(fun->fnode));
|
---|
[a35b458] | 424 |
|
---|
[55a8e0cb] | 425 | return;
|
---|
| 426 | }
|
---|
[a35b458] | 427 |
|
---|
[55a8e0cb] | 428 | ddf_msg(LVL_WARN, "Skipped dma 0x%x for function %s", dma,
|
---|
[56fd7cf] | 429 | ddf_fun_get_name(fun->fnode));
|
---|
[55a8e0cb] | 430 | }
|
---|
| 431 | }
|
---|
| 432 |
|
---|
[82e4005] | 433 | static void isa_fun_add_io_range(isa_fun_t *fun, size_t addr, size_t len)
|
---|
[5dc9622] | 434 | {
|
---|
[68414f4a] | 435 | size_t count = fun->hw_resources.count;
|
---|
| 436 | hw_resource_t *resources = fun->hw_resources.resources;
|
---|
[032e0bb] | 437 |
|
---|
[0a428943] | 438 | isa_bus_t *isa = isa_bus(ddf_fun_get_dev(fun->fnode));
|
---|
| 439 |
|
---|
[5dc9622] | 440 | if (count < ISA_MAX_HW_RES) {
|
---|
| 441 | resources[count].type = IO_RANGE;
|
---|
| 442 | resources[count].res.io_range.address = addr;
|
---|
[0a428943] | 443 | resources[count].res.io_range.address += isa->pio_win.io.base;
|
---|
[5dc9622] | 444 | resources[count].res.io_range.size = len;
|
---|
[9e470c0] | 445 | resources[count].res.io_range.relative = false;
|
---|
[032e0bb] | 446 | resources[count].res.io_range.endianness = LITTLE_ENDIAN;
|
---|
| 447 |
|
---|
[68414f4a] | 448 | fun->hw_resources.count++;
|
---|
[032e0bb] | 449 |
|
---|
[fc51296] | 450 | ddf_msg(LVL_NOTE, "Added io range (addr=0x%x, size=0x%x) to "
|
---|
[ebcb05a] | 451 | "function %s", (unsigned int) addr, (unsigned int) len,
|
---|
[56fd7cf] | 452 | ddf_fun_get_name(fun->fnode));
|
---|
[032e0bb] | 453 | }
|
---|
[c1a8ae52] | 454 | }
|
---|
| 455 |
|
---|
[b446b02] | 456 | static void isa_fun_add_mem_range(isa_fun_t *fun, uintptr_t addr, size_t len)
|
---|
| 457 | {
|
---|
| 458 | size_t count = fun->hw_resources.count;
|
---|
| 459 | hw_resource_t *resources = fun->hw_resources.resources;
|
---|
| 460 |
|
---|
| 461 | isa_bus_t *isa = isa_bus(ddf_fun_get_dev(fun->fnode));
|
---|
| 462 |
|
---|
| 463 | if (count < ISA_MAX_HW_RES) {
|
---|
| 464 | resources[count].type = MEM_RANGE;
|
---|
| 465 | resources[count].res.mem_range.address = addr;
|
---|
| 466 | resources[count].res.mem_range.address += isa->pio_win.mem.base;
|
---|
| 467 | resources[count].res.mem_range.size = len;
|
---|
| 468 | resources[count].res.mem_range.relative = true;
|
---|
| 469 | resources[count].res.mem_range.endianness = LITTLE_ENDIAN;
|
---|
| 470 |
|
---|
| 471 | fun->hw_resources.count++;
|
---|
| 472 |
|
---|
| 473 | ddf_msg(LVL_NOTE, "Added mem range (addr=0x%zx, size=0x%x) to "
|
---|
| 474 | "function %s", (uintptr_t) addr, (unsigned int) len,
|
---|
| 475 | ddf_fun_get_name(fun->fnode));
|
---|
| 476 | }
|
---|
| 477 | }
|
---|
| 478 |
|
---|
[b5f305b] | 479 | static void fun_parse_irq(isa_fun_t *fun, const char *val)
|
---|
[c1a8ae52] | 480 | {
|
---|
| 481 | int irq = 0;
|
---|
| 482 | char *end = NULL;
|
---|
[032e0bb] | 483 |
|
---|
[8b1e15ac] | 484 | val = skip_spaces(val);
|
---|
[5cc9eba] | 485 | irq = (int) strtol(val, &end, 10);
|
---|
[032e0bb] | 486 |
|
---|
| 487 | if (val != end)
|
---|
[82e4005] | 488 | isa_fun_add_irq(fun, irq);
|
---|
[c1a8ae52] | 489 | }
|
---|
| 490 |
|
---|
[b5f305b] | 491 | static void fun_parse_dma(isa_fun_t *fun, const char *val)
|
---|
[55a8e0cb] | 492 | {
|
---|
| 493 | char *end = NULL;
|
---|
[a35b458] | 494 |
|
---|
[55a8e0cb] | 495 | val = skip_spaces(val);
|
---|
[1ec394e] | 496 | const int dma = strtol(val, &end, 10);
|
---|
[a35b458] | 497 |
|
---|
[55a8e0cb] | 498 | if (val != end)
|
---|
[82e4005] | 499 | isa_fun_add_dma(fun, dma);
|
---|
[55a8e0cb] | 500 | }
|
---|
| 501 |
|
---|
[b5f305b] | 502 | static void fun_parse_io_range(isa_fun_t *fun, const char *val)
|
---|
[c1a8ae52] | 503 | {
|
---|
[5dc9622] | 504 | size_t addr, len;
|
---|
| 505 | char *end = NULL;
|
---|
[032e0bb] | 506 |
|
---|
[8b1e15ac] | 507 | val = skip_spaces(val);
|
---|
[5dc9622] | 508 | addr = strtol(val, &end, 0x10);
|
---|
[032e0bb] | 509 |
|
---|
| 510 | if (val == end)
|
---|
[5dc9622] | 511 | return;
|
---|
[032e0bb] | 512 |
|
---|
[8b1e15ac] | 513 | val = skip_spaces(end);
|
---|
[5dc9622] | 514 | len = strtol(val, &end, 0x10);
|
---|
[032e0bb] | 515 |
|
---|
| 516 | if (val == end)
|
---|
[5dc9622] | 517 | return;
|
---|
[032e0bb] | 518 |
|
---|
[82e4005] | 519 | isa_fun_add_io_range(fun, addr, len);
|
---|
[c1a8ae52] | 520 | }
|
---|
| 521 |
|
---|
[b446b02] | 522 | static void fun_parse_mem_range(isa_fun_t *fun, const char *val)
|
---|
| 523 | {
|
---|
| 524 | uintptr_t addr;
|
---|
| 525 | size_t len;
|
---|
| 526 | char *end = NULL;
|
---|
| 527 |
|
---|
| 528 | val = skip_spaces(val);
|
---|
| 529 | addr = strtoul(val, &end, 0x10);
|
---|
| 530 |
|
---|
| 531 | if (val == end)
|
---|
| 532 | return;
|
---|
| 533 |
|
---|
| 534 | val = skip_spaces(end);
|
---|
| 535 | len = strtol(val, &end, 0x10);
|
---|
| 536 |
|
---|
| 537 | if (val == end)
|
---|
| 538 | return;
|
---|
| 539 |
|
---|
| 540 | isa_fun_add_mem_range(fun, addr, len);
|
---|
| 541 | }
|
---|
| 542 |
|
---|
[b5f305b] | 543 | static void get_match_id(char **id, const char *val)
|
---|
[c1a8ae52] | 544 | {
|
---|
[b5f305b] | 545 | const char *end = val;
|
---|
[032e0bb] | 546 |
|
---|
| 547 | while (!isspace(*end))
|
---|
[5dc9622] | 548 | end++;
|
---|
[032e0bb] | 549 |
|
---|
[f928a8a] | 550 | size_t size = end - val + 1;
|
---|
[5dc9622] | 551 | *id = (char *)malloc(size);
|
---|
[032e0bb] | 552 | str_cpy(*id, size, val);
|
---|
[5dc9622] | 553 | }
|
---|
| 554 |
|
---|
[b5f305b] | 555 | static void fun_parse_match_id(isa_fun_t *fun, const char *val)
|
---|
[032e0bb] | 556 | {
|
---|
[5dc9622] | 557 | char *id = NULL;
|
---|
| 558 | char *end = NULL;
|
---|
[032e0bb] | 559 |
|
---|
[68414f4a] | 560 | val = skip_spaces(val);
|
---|
[032e0bb] | 561 |
|
---|
[cf56332] | 562 | int score = (int)strtol(val, &end, 10);
|
---|
[5dc9622] | 563 | if (val == end) {
|
---|
[fc51296] | 564 | ddf_msg(LVL_ERROR, "Cannot read match score for function "
|
---|
[56fd7cf] | 565 | "%s.", ddf_fun_get_name(fun->fnode));
|
---|
[5dc9622] | 566 | return;
|
---|
| 567 | }
|
---|
[032e0bb] | 568 |
|
---|
[bab6388] | 569 | val = skip_spaces(end);
|
---|
[5dc9622] | 570 | get_match_id(&id, val);
|
---|
[032e0bb] | 571 | if (id == NULL) {
|
---|
[ebcb05a] | 572 | ddf_msg(LVL_ERROR, "Cannot read match ID for function %s.",
|
---|
[56fd7cf] | 573 | ddf_fun_get_name(fun->fnode));
|
---|
[5dc9622] | 574 | return;
|
---|
| 575 | }
|
---|
[032e0bb] | 576 |
|
---|
[fc51296] | 577 | ddf_msg(LVL_DEBUG, "Adding match id '%s' with score %d to "
|
---|
[56fd7cf] | 578 | "function %s", id, score, ddf_fun_get_name(fun->fnode));
|
---|
[cd0684d] | 579 |
|
---|
[b7fd2a0] | 580 | errno_t rc = ddf_fun_add_match_id(fun->fnode, id, score);
|
---|
[fc51296] | 581 | if (rc != EOK) {
|
---|
[ebcb05a] | 582 | ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
|
---|
[fc51296] | 583 | str_error(rc));
|
---|
| 584 | }
|
---|
[ef9460b] | 585 |
|
---|
| 586 | free(id);
|
---|
[c1a8ae52] | 587 | }
|
---|
| 588 |
|
---|
[b5f305b] | 589 | static bool prop_parse(isa_fun_t *fun, const char *line, const char *prop,
|
---|
| 590 | void (*read_fn)(isa_fun_t *, const char *))
|
---|
[5fe1c32] | 591 | {
|
---|
| 592 | size_t proplen = str_size(prop);
|
---|
[032e0bb] | 593 |
|
---|
| 594 | if (str_lcmp(line, prop, proplen) == 0) {
|
---|
[5fe1c32] | 595 | line += proplen;
|
---|
| 596 | line = skip_spaces(line);
|
---|
[8b1e15ac] | 597 | (*read_fn)(fun, line);
|
---|
[032e0bb] | 598 |
|
---|
[5fe1c32] | 599 | return true;
|
---|
| 600 | }
|
---|
[032e0bb] | 601 |
|
---|
| 602 | return false;
|
---|
[5fe1c32] | 603 | }
|
---|
| 604 |
|
---|
[b5f305b] | 605 | static void fun_prop_parse(isa_fun_t *fun, const char *line)
|
---|
[c1a8ae52] | 606 | {
|
---|
[032e0bb] | 607 | /* Skip leading spaces. */
|
---|
[c1a8ae52] | 608 | line = skip_spaces(line);
|
---|
[032e0bb] | 609 |
|
---|
[68414f4a] | 610 | if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) &&
|
---|
[b446b02] | 611 | !prop_parse(fun, line, "mem_range", &fun_parse_mem_range) &&
|
---|
[68414f4a] | 612 | !prop_parse(fun, line, "irq", &fun_parse_irq) &&
|
---|
[55a8e0cb] | 613 | !prop_parse(fun, line, "dma", &fun_parse_dma) &&
|
---|
[fc51296] | 614 | !prop_parse(fun, line, "match", &fun_parse_match_id)) {
|
---|
| 615 |
|
---|
[ebcb05a] | 616 | ddf_msg(LVL_ERROR, "Undefined device property at line '%s'",
|
---|
[fc51296] | 617 | line);
|
---|
[032e0bb] | 618 | }
|
---|
[c1a8ae52] | 619 | }
|
---|
| 620 |
|
---|
[f278930] | 621 | static char *isa_fun_read_info(char *fun_conf, isa_bus_t *isa)
|
---|
[c1a8ae52] | 622 | {
|
---|
| 623 | char *line;
|
---|
[032e0bb] | 624 |
|
---|
| 625 | /* Skip empty lines. */
|
---|
[1de97fe6] | 626 | do {
|
---|
[8b1e15ac] | 627 | line = str_get_line(fun_conf, &fun_conf);
|
---|
[032e0bb] | 628 |
|
---|
| 629 | if (line == NULL) {
|
---|
| 630 | /* no more lines */
|
---|
[c1a8ae52] | 631 | return NULL;
|
---|
| 632 | }
|
---|
[032e0bb] | 633 |
|
---|
[1de97fe6] | 634 | } while (line_empty(line));
|
---|
[032e0bb] | 635 |
|
---|
| 636 | /* Get device name. */
|
---|
[3d4ad475] | 637 | const char *fun_name = get_device_name(line);
|
---|
[8b1e15ac] | 638 | if (fun_name == NULL)
|
---|
[c1a8ae52] | 639 | return NULL;
|
---|
[032e0bb] | 640 |
|
---|
[f278930] | 641 | isa_fun_t *fun = isa_fun_create(isa, fun_name);
|
---|
[8b1e15ac] | 642 | if (fun == NULL) {
|
---|
[c1a8ae52] | 643 | return NULL;
|
---|
| 644 | }
|
---|
[032e0bb] | 645 |
|
---|
| 646 | /* Get properties of the device (match ids, irq and io range). */
|
---|
| 647 | while (true) {
|
---|
[8b1e15ac] | 648 | line = str_get_line(fun_conf, &fun_conf);
|
---|
[032e0bb] | 649 |
|
---|
[5dc9622] | 650 | if (line_empty(line)) {
|
---|
[032e0bb] | 651 | /* no more device properties */
|
---|
[5dc9622] | 652 | break;
|
---|
| 653 | }
|
---|
[032e0bb] | 654 |
|
---|
| 655 | /*
|
---|
| 656 | * Get the device's property from the configuration line
|
---|
| 657 | * and store it in the device structure.
|
---|
| 658 | */
|
---|
[68414f4a] | 659 | fun_prop_parse(fun, line);
|
---|
[c1a8ae52] | 660 | }
|
---|
[032e0bb] | 661 |
|
---|
| 662 | /* Set device operations to the device. */
|
---|
[56fd7cf] | 663 | ddf_fun_set_ops(fun->fnode, &isa_fun_ops);
|
---|
[97a62fe] | 664 |
|
---|
[56fd7cf] | 665 | ddf_msg(LVL_DEBUG, "Binding function %s.", ddf_fun_get_name(fun->fnode));
|
---|
[032e0bb] | 666 |
|
---|
[97a62fe] | 667 | /* XXX Handle error */
|
---|
| 668 | (void) ddf_fun_bind(fun->fnode);
|
---|
[032e0bb] | 669 |
|
---|
[f278930] | 670 | list_append(&fun->bus_link, &isa->functions);
|
---|
| 671 |
|
---|
[8b1e15ac] | 672 | return fun_conf;
|
---|
[c1a8ae52] | 673 | }
|
---|
| 674 |
|
---|
[0d7eb0f] | 675 | static void isa_functions_add(isa_bus_t *isa)
|
---|
[c1a8ae52] | 676 | {
|
---|
[7e9e652] | 677 | #define BASE_CLASS_BRIDGE 0x06
|
---|
| 678 | #define SUB_CLASS_BRIDGE_ISA 0x01
|
---|
| 679 | bool isa_bridge = ((isa->pci_class == BASE_CLASS_BRIDGE) &&
|
---|
| 680 | (isa->pci_subclass == SUB_CLASS_BRIDGE_ISA));
|
---|
| 681 |
|
---|
[3c5b86c] | 682 | #define VENDOR_ID_SUN 0x108e
|
---|
| 683 | #define DEVICE_ID_EBUS 0x1000
|
---|
[7e9e652] | 684 | bool ebus = ((isa->pci_vendor_id == VENDOR_ID_SUN) &&
|
---|
| 685 | (isa->pci_device_id == DEVICE_ID_EBUS));
|
---|
[3c5b86c] | 686 |
|
---|
[7e9e652] | 687 | const char *conf_path = NULL;
|
---|
| 688 | if (isa_bridge)
|
---|
[3c5b86c] | 689 | conf_path = ISA_CHILD_FUN_CONF_PATH;
|
---|
[7e9e652] | 690 | else if (ebus)
|
---|
| 691 | conf_path = EBUS_CHILD_FUN_CONF_PATH;
|
---|
[3c5b86c] | 692 |
|
---|
| 693 | char *conf = fun_conf_read(conf_path);
|
---|
[032e0bb] | 694 | while (conf != NULL && *conf != '\0') {
|
---|
[f278930] | 695 | conf = isa_fun_read_info(conf, isa);
|
---|
[032e0bb] | 696 | }
|
---|
[0d7eb0f] | 697 | free(conf);
|
---|
[c1a8ae52] | 698 | }
|
---|
[892e4e1] | 699 |
|
---|
[b7fd2a0] | 700 | static errno_t isa_dev_add(ddf_dev_t *dev)
|
---|
[892e4e1] | 701 | {
|
---|
[0a428943] | 702 | async_sess_t *sess;
|
---|
[b7fd2a0] | 703 | errno_t rc;
|
---|
[0a428943] | 704 |
|
---|
[0c0f823b] | 705 | ddf_msg(LVL_DEBUG, "isa_dev_add, device handle = %d",
|
---|
[56fd7cf] | 706 | (int) ddf_dev_get_handle(dev));
|
---|
[032e0bb] | 707 |
|
---|
[cf56332] | 708 | isa_bus_t *isa = ddf_dev_data_alloc(dev, sizeof(isa_bus_t));
|
---|
[f278930] | 709 | if (isa == NULL)
|
---|
| 710 | return ENOMEM;
|
---|
| 711 |
|
---|
| 712 | fibril_mutex_initialize(&isa->mutex);
|
---|
| 713 | isa->dev = dev;
|
---|
| 714 | list_initialize(&isa->functions);
|
---|
| 715 |
|
---|
[2fd26bb] | 716 | sess = ddf_dev_parent_sess_get(dev);
|
---|
[0a428943] | 717 | if (sess == NULL) {
|
---|
| 718 | ddf_msg(LVL_ERROR, "isa_dev_add failed to connect to the "
|
---|
| 719 | "parent driver.");
|
---|
| 720 | return ENOENT;
|
---|
| 721 | }
|
---|
| 722 |
|
---|
[7e9e652] | 723 | rc = pci_config_space_read_16(sess, PCI_VENDOR_ID, &isa->pci_vendor_id);
|
---|
| 724 | if (rc != EOK)
|
---|
| 725 | return rc;
|
---|
| 726 | rc = pci_config_space_read_16(sess, PCI_DEVICE_ID, &isa->pci_device_id);
|
---|
| 727 | if (rc != EOK)
|
---|
| 728 | return rc;
|
---|
| 729 | rc = pci_config_space_read_8(sess, PCI_BASE_CLASS, &isa->pci_class);
|
---|
[3c5b86c] | 730 | if (rc != EOK)
|
---|
| 731 | return rc;
|
---|
[7e9e652] | 732 | rc = pci_config_space_read_8(sess, PCI_SUB_CLASS, &isa->pci_subclass);
|
---|
[3c5b86c] | 733 | if (rc != EOK)
|
---|
| 734 | return rc;
|
---|
[a35b458] | 735 |
|
---|
[0a428943] | 736 | rc = pio_window_get(sess, &isa->pio_win);
|
---|
| 737 | if (rc != EOK) {
|
---|
| 738 | ddf_msg(LVL_ERROR, "isa_dev_add failed to get PIO window "
|
---|
| 739 | "for the device.");
|
---|
| 740 | return rc;
|
---|
[1b20da0] | 741 | }
|
---|
[0a428943] | 742 |
|
---|
[8b1e15ac] | 743 | /* Make the bus device more visible. Does not do anything. */
|
---|
[ebcb05a] | 744 | ddf_msg(LVL_DEBUG, "Adding a 'ctl' function");
|
---|
[8b1e15ac] | 745 |
|
---|
[f278930] | 746 | fibril_mutex_lock(&isa->mutex);
|
---|
| 747 |
|
---|
| 748 | isa->fctl = ddf_fun_create(dev, fun_exposed, "ctl");
|
---|
| 749 | if (isa->fctl == NULL) {
|
---|
[ebcb05a] | 750 | ddf_msg(LVL_ERROR, "Failed creating control function.");
|
---|
[97a62fe] | 751 | return EXDEV;
|
---|
| 752 | }
|
---|
| 753 |
|
---|
[f278930] | 754 | if (ddf_fun_bind(isa->fctl) != EOK) {
|
---|
| 755 | ddf_fun_destroy(isa->fctl);
|
---|
[ebcb05a] | 756 | ddf_msg(LVL_ERROR, "Failed binding control function.");
|
---|
[97a62fe] | 757 | return EXDEV;
|
---|
| 758 | }
|
---|
[8b1e15ac] | 759 |
|
---|
[68414f4a] | 760 | /* Add functions as specified in the configuration file. */
|
---|
[f278930] | 761 | isa_functions_add(isa);
|
---|
[ebcb05a] | 762 | ddf_msg(LVL_NOTE, "Finished enumerating legacy functions");
|
---|
[032e0bb] | 763 |
|
---|
[f278930] | 764 | fibril_mutex_unlock(&isa->mutex);
|
---|
| 765 |
|
---|
| 766 | return EOK;
|
---|
| 767 | }
|
---|
| 768 |
|
---|
[b7fd2a0] | 769 | static errno_t isa_dev_remove(ddf_dev_t *dev)
|
---|
[f278930] | 770 | {
|
---|
[56fd7cf] | 771 | isa_bus_t *isa = isa_bus(dev);
|
---|
[f278930] | 772 |
|
---|
| 773 | fibril_mutex_lock(&isa->mutex);
|
---|
| 774 |
|
---|
| 775 | while (!list_empty(&isa->functions)) {
|
---|
| 776 | isa_fun_t *fun = list_get_instance(list_first(&isa->functions),
|
---|
| 777 | isa_fun_t, bus_link);
|
---|
| 778 |
|
---|
[b7fd2a0] | 779 | errno_t rc = ddf_fun_offline(fun->fnode);
|
---|
[f278930] | 780 | if (rc != EOK) {
|
---|
| 781 | fibril_mutex_unlock(&isa->mutex);
|
---|
[56fd7cf] | 782 | ddf_msg(LVL_ERROR, "Failed offlining %s", ddf_fun_get_name(fun->fnode));
|
---|
[f278930] | 783 | return rc;
|
---|
| 784 | }
|
---|
| 785 |
|
---|
| 786 | rc = ddf_fun_unbind(fun->fnode);
|
---|
| 787 | if (rc != EOK) {
|
---|
| 788 | fibril_mutex_unlock(&isa->mutex);
|
---|
[56fd7cf] | 789 | ddf_msg(LVL_ERROR, "Failed unbinding %s", ddf_fun_get_name(fun->fnode));
|
---|
[f278930] | 790 | return rc;
|
---|
| 791 | }
|
---|
| 792 |
|
---|
| 793 | list_remove(&fun->bus_link);
|
---|
| 794 |
|
---|
| 795 | ddf_fun_destroy(fun->fnode);
|
---|
| 796 | }
|
---|
| 797 |
|
---|
| 798 | if (ddf_fun_unbind(isa->fctl) != EOK) {
|
---|
| 799 | fibril_mutex_unlock(&isa->mutex);
|
---|
| 800 | ddf_msg(LVL_ERROR, "Failed unbinding control function.");
|
---|
| 801 | return EXDEV;
|
---|
| 802 | }
|
---|
| 803 |
|
---|
| 804 | fibril_mutex_unlock(&isa->mutex);
|
---|
| 805 |
|
---|
[df747b9c] | 806 | return EOK;
|
---|
[892e4e1] | 807 | }
|
---|
| 808 |
|
---|
[b7fd2a0] | 809 | static errno_t isa_fun_online(ddf_fun_t *fun)
|
---|
[5b68e0c] | 810 | {
|
---|
| 811 | ddf_msg(LVL_DEBUG, "isa_fun_online()");
|
---|
| 812 | return ddf_fun_online(fun);
|
---|
| 813 | }
|
---|
| 814 |
|
---|
[b7fd2a0] | 815 | static errno_t isa_fun_offline(ddf_fun_t *fun)
|
---|
[5b68e0c] | 816 | {
|
---|
| 817 | ddf_msg(LVL_DEBUG, "isa_fun_offline()");
|
---|
| 818 | return ddf_fun_offline(fun);
|
---|
| 819 | }
|
---|
| 820 |
|
---|
[892e4e1] | 821 | int main(int argc, char *argv[])
|
---|
| 822 | {
|
---|
[032e0bb] | 823 | printf(NAME ": HelenOS ISA bus driver\n");
|
---|
[03362fbd] | 824 | ddf_log_init(NAME);
|
---|
[83a2f43] | 825 | return ddf_driver_main(&isa_driver);
|
---|
[892e4e1] | 826 | }
|
---|
| 827 |
|
---|
| 828 | /**
|
---|
| 829 | * @}
|
---|
| 830 | */
|
---|