Changes in uspace/drv/bus/isa/isa.c [d9cf684a:5960b48] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/isa.c
rd9cf684a r5960b48 2 2 * Copyright (c) 2010 Lenka Trochtova 3 3 * Copyright (c) 2011 Jiri Svoboda 4 * Copyright (c) 2011 Jan Vesely5 4 * All rights reserved. 6 5 * … … 52 51 #include <dirent.h> 53 52 #include <fcntl.h> 54 #include <sys/stat.h>55 53 #include <ipc/irc.h> 56 54 #include <ipc/services.h> 57 55 #include <sysinfo.h> 58 56 #include <ns.h> 57 #include <sys/stat.h> 59 58 60 59 #include <ddf/driver.h> … … 66 65 #include <device/hw_res.h> 67 66 68 #include "i8237.h"69 70 67 #define NAME "isa" 71 68 #define CHILD_FUN_CONF_PATH "/drv/isa/isa.dev" … … 77 74 #define ISA_FUN(fun) ((isa_fun_t *) ((fun)->driver_data)) 78 75 79 #define ISA_MAX_HW_RES 576 #define ISA_MAX_HW_RES 4 80 77 81 78 typedef struct { … … 109 106 sysarg_t apic; 110 107 sysarg_t i8259; 111 108 112 109 async_sess_t *irc_sess = NULL; 113 110 114 111 if (((sysinfo_get_value("apic", &apic) == EOK) && (apic)) 115 112 || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) { … … 117 114 SERVICE_IRC, 0, 0); 118 115 } 119 116 120 117 if (!irc_sess) 121 118 return false; 122 119 123 120 assert(isa_fun); 124 121 const hw_resource_list_t *res = &isa_fun->hw_resources; … … 127 124 if (res->resources[i].type == INTERRUPT) { 128 125 const int irq = res->resources[i].res.interrupt.irq; 129 126 130 127 async_exch_t *exch = async_exchange_begin(irc_sess); 131 128 const int rc = 132 129 async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq); 133 130 async_exchange_end(exch); 134 131 135 132 if (rc != EOK) { 136 133 async_hangup(irc_sess); … … 139 136 } 140 137 } 141 138 142 139 async_hangup(irc_sess); 143 140 return true; 144 141 } 145 142 146 static int isa_dma_channel_fun_setup(ddf_fun_t *fnode,147 unsigned int channel, uint32_t pa, uint16_t size, uint8_t mode)148 {149 assert(fnode);150 isa_fun_t *isa_fun = fnode->driver_data;151 const hw_resource_list_t *res = &isa_fun->hw_resources;152 assert(res);153 154 const unsigned int ch = channel;155 for (size_t i = 0; i < res->count; ++i) {156 if (((res->resources[i].type == DMA_CHANNEL_16) &&157 (res->resources[i].res.dma_channel.dma16 == ch)) ||158 ((res->resources[i].type == DMA_CHANNEL_8) &&159 (res->resources[i].res.dma_channel.dma8 == ch))) {160 return dma_setup_channel(channel, pa, size, mode);161 }162 }163 164 return EINVAL;165 }166 167 143 static hw_res_ops_t isa_fun_hw_res_ops = { 168 .get_resource_list = isa_get_fun_resources, 169 .enable_interrupt = isa_enable_fun_interrupt, 170 .dma_channel_setup = isa_dma_channel_fun_setup, 144 &isa_get_fun_resources, 145 &isa_enable_fun_interrupt 171 146 }; 172 147 … … 339 314 } 340 315 341 static void isa_fun_set_dma(isa_fun_t *fun, int dma)342 {343 size_t count = fun->hw_resources.count;344 hw_resource_t *resources = fun->hw_resources.resources;345 346 if (count < ISA_MAX_HW_RES) {347 if ((dma > 0) && (dma < 4)) {348 resources[count].type = DMA_CHANNEL_8;349 resources[count].res.dma_channel.dma8 = dma;350 351 fun->hw_resources.count++;352 ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,353 fun->fnode->name);354 355 return;356 }357 358 if ((dma > 4) && (dma < 8)) {359 resources[count].type = DMA_CHANNEL_16;360 resources[count].res.dma_channel.dma16 = dma;361 362 fun->hw_resources.count++;363 ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma,364 fun->fnode->name);365 366 return;367 }368 369 ddf_msg(LVL_WARN, "Skipped dma 0x%x for function %s", dma,370 fun->fnode->name);371 }372 }373 374 316 static void isa_fun_set_io_range(isa_fun_t *fun, size_t addr, size_t len) 375 317 { … … 397 339 398 340 val = skip_spaces(val); 399 irq = (int)strtol(val, &end, 0x10);341 irq = (int)strtol(val, &end, 10); 400 342 401 343 if (val != end) 402 344 isa_fun_set_irq(fun, irq); 403 }404 405 static void fun_parse_dma(isa_fun_t *fun, char *val)406 {407 unsigned int dma = 0;408 char *end = NULL;409 410 val = skip_spaces(val);411 dma = (unsigned int) strtol(val, &end, 10);412 413 if (val != end)414 isa_fun_set_dma(fun, dma);415 345 } 416 346 … … 506 436 if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) && 507 437 !prop_parse(fun, line, "irq", &fun_parse_irq) && 508 !prop_parse(fun, line, "dma", &fun_parse_dma) &&509 438 !prop_parse(fun, line, "match", &fun_parse_match_id)) { 510 439 … … 517 446 { 518 447 fun->hw_resources.resources = 519 (hw_resource_t *) 448 (hw_resource_t *)malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES); 520 449 } 521 450 … … 701 630 702 631 703 static void isa_init() 632 static void isa_init() 704 633 { 705 634 ddf_log_init(NAME, LVL_ERROR);
Note:
See TracChangeset
for help on using the changeset viewer.