Changes in uspace/drv/bus/isa/isa.c [85c4cc45:0bbd13e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/isa.c
r85c4cc45 r0bbd13e 52 52 #include <dirent.h> 53 53 #include <fcntl.h> 54 #include <ipc/irc.h> 55 #include <ipc/services.h> 56 #include <sysinfo.h> 57 #include <ns.h> 54 58 #include <sys/stat.h> 55 59 #include <ipc/irc.h> … … 62 66 #include <ops/hw_res.h> 63 67 64 #include <devman.h>65 #include <ipc/devman.h>66 68 #include <device/hw_res.h> 67 69 68 #include " dma_controller.h"70 #include "i8237.h" 69 71 70 72 #define NAME "isa" … … 89 91 fibril_mutex_t mutex; 90 92 ddf_fun_t *fnode; 91 hw_resource_t resources[ISA_MAX_HW_RES];92 93 hw_resource_list_t hw_resources; 93 94 link_t bus_link; … … 146 147 147 148 static int isa_dma_channel_fun_setup(ddf_fun_t *fnode, 148 unsigned channel, uint32_t pa, uint16_t size, uint8_t mode)149 unsigned int channel, uint32_t pa, uint16_t size, uint8_t mode) 149 150 { 150 151 assert(fnode); … … 152 153 const hw_resource_list_t *res = &isa_fun->hw_resources; 153 154 assert(res); 154 const int ch = channel; 155 156 const unsigned int ch = channel; 155 157 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)) {158 if (((res->resources[i].type == DMA_CHANNEL_16) && 159 (res->resources[i].res.dma_channel.dma16 == ch)) || 160 ((res->resources[i].type == DMA_CHANNEL_8) && 161 (res->resources[i].res.dma_channel.dma8 == ch))) { 160 162 return dma_setup_channel(channel, pa, size, mode); 161 163 } 162 164 } 165 163 166 return EINVAL; 164 167 } … … 172 175 static ddf_dev_ops_t isa_fun_ops; 173 176 174 static int isa_ add_device(ddf_dev_t *dev);177 static int isa_dev_add(ddf_dev_t *dev); 175 178 static int isa_dev_remove(ddf_dev_t *dev); 176 179 static int isa_fun_online(ddf_fun_t *fun); … … 179 182 /** The isa device driver's standard operations */ 180 183 static driver_ops_t isa_ops = { 181 . add_device = &isa_add_device,184 .dev_add = &isa_dev_add, 182 185 .dev_remove = &isa_dev_remove, 183 186 .fun_online = &isa_fun_online, … … 198 201 199 202 isa_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(isa_fun_t)); 200 if (fun == NULL) 203 if (fun == NULL) { 204 ddf_fun_destroy(fnode); 201 205 return NULL; 206 } 202 207 203 208 fibril_mutex_initialize(&fun->mutex); 204 fun->hw_resources.resources = fun->resources;205 206 209 fun->fnode = fnode; 207 210 return fun; … … 344 347 size_t count = fun->hw_resources.count; 345 348 hw_resource_t *resources = fun->hw_resources.resources; 346 349 347 350 if (count < ISA_MAX_HW_RES) { 348 if ( dma > 0 && dma < 4) {351 if ((dma > 0) && (dma < 4)) { 349 352 resources[count].type = DMA_CHANNEL_8; 350 353 resources[count].res.dma_channel.dma8 = dma; 351 354 352 355 fun->hw_resources.count++; 353 356 ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma, 354 357 fun->fnode->name); 358 355 359 return; 356 360 } 357 361 358 if ( dma > 4 && dma < 8) {362 if ((dma > 4) && (dma < 8)) { 359 363 resources[count].type = DMA_CHANNEL_16; 360 364 resources[count].res.dma_channel.dma16 = dma; 361 365 362 366 fun->hw_resources.count++; 363 367 ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma, 364 368 fun->fnode->name); 369 365 370 return; 366 371 } 367 372 368 373 ddf_msg(LVL_WARN, "Skipped dma 0x%x for function %s", dma, 369 374 fun->fnode->name); … … 396 401 397 402 val = skip_spaces(val); 398 irq = (int) strtol(val, &end, 0x10);403 irq = (int) strtol(val, &end, 10); 399 404 400 405 if (val != end) … … 404 409 static void fun_parse_dma(isa_fun_t *fun, char *val) 405 410 { 406 int dma = 0;411 unsigned int dma = 0; 407 412 char *end = NULL; 408 413 409 414 val = skip_spaces(val); 410 dma = ( int)strtol(val, &end, 10);411 415 dma = (unsigned int) strtol(val, &end, 10); 416 412 417 if (val != end) 413 418 isa_fun_set_dma(fun, dma); … … 513 518 } 514 519 520 static void fun_hw_res_alloc(isa_fun_t *fun) 521 { 522 fun->hw_resources.resources = 523 (hw_resource_t *) malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES); 524 } 525 526 static void fun_hw_res_free(isa_fun_t *fun) 527 { 528 free(fun->hw_resources.resources); 529 fun->hw_resources.resources = NULL; 530 } 531 515 532 static char *isa_fun_read_info(char *fun_conf, isa_bus_t *isa) 516 533 { … … 541 558 return NULL; 542 559 } 560 561 /* Allocate buffer for the list of hardware resources of the device. */ 562 fun_hw_res_alloc(fun); 543 563 544 564 /* Get properties of the device (match ids, irq and io range). */ … … 589 609 } 590 610 591 static int isa_ add_device(ddf_dev_t *dev)611 static int isa_dev_add(ddf_dev_t *dev) 592 612 { 593 613 isa_bus_t *isa; 594 614 595 ddf_msg(LVL_DEBUG, "isa_ add_device, device handle = %d",615 ddf_msg(LVL_DEBUG, "isa_dev_add, device handle = %d", 596 616 (int) dev->handle); 597 617 … … 657 677 list_remove(&fun->bus_link); 658 678 679 fun_hw_res_free(fun); 659 680 ddf_fun_destroy(fun->fnode); 660 681 }
Note:
See TracChangeset
for help on using the changeset viewer.