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