Changeset b39eb79 in mainline for uspace/drv/bus/isa
- Timestamp:
- 2011-12-26T17:21:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9b56a8dd
- Parents:
- cf5c05c0 (diff), 7e1b130 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/drv/bus/isa
- Files:
-
- 1 added
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/Makefile
rcf5c05c0 rb39eb79 1 1 # 2 2 # Copyright (c) 2010 Lenka Trochtova 3 # Copyright (c) 2011 Jan Vesely 3 4 # All rights reserved. 4 5 # … … 33 34 34 35 SOURCES = \ 36 i8237.c \ 35 37 isa.c 36 38 -
uspace/drv/bus/isa/i8237.h
rcf5c05c0 rb39eb79 1 1 /* 2 * Copyright (c) 2011 Vojtech Horky2 * Copyright (c) 2011 Jan Vesely 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libusbdev29 /** @addtogroup isa 30 30 * @{ 31 31 */ 32 32 33 /** @file 33 * Library internal functions on USB pipes.34 * @brief DMA memory management 34 35 */ 35 #ifndef LIBUSBDEV_PIPEPRIV_H_36 #define LIBUSBDEV_PIPEPRIV_H_37 36 38 #i nclude <usb/dev/pipes.h>39 # include <bool.h>37 #ifndef DRV_BUS_ISA_I8237_H 38 #define DRV_BUS_ISA_I8237_H 40 39 41 void pipe_acquire(usb_pipe_t *); 42 void pipe_release(usb_pipe_t *); 43 44 void pipe_start_transaction(usb_pipe_t *); 45 void pipe_end_transaction(usb_pipe_t *); 46 47 int pipe_add_ref(usb_pipe_t *, bool); 48 void pipe_drop_ref(usb_pipe_t *); 49 40 extern int dma_setup_channel(unsigned int, uint32_t, uint16_t, uint8_t); 50 41 51 42 #endif 43 52 44 /** 53 45 * @} -
uspace/drv/bus/isa/isa.c
rcf5c05c0 rb39eb79 2 2 * Copyright (c) 2010 Lenka Trochtova 3 3 * Copyright (c) 2011 Jiri Svoboda 4 * Copyright (c) 2011 Jan Vesely 4 5 * All rights reserved. 5 6 * … … 56 57 #include <ns.h> 57 58 #include <sys/stat.h> 59 #include <ipc/irc.h> 60 #include <ipc/services.h> 61 #include <sysinfo.h> 62 #include <ns.h> 58 63 59 64 #include <ddf/driver.h> … … 65 70 #include <device/hw_res.h> 66 71 72 #include "i8237.h" 73 67 74 #define NAME "isa" 68 75 #define CHILD_FUN_CONF_PATH "/drv/isa/isa.dev" … … 74 81 #define ISA_FUN(fun) ((isa_fun_t *) ((fun)->driver_data)) 75 82 76 #define ISA_MAX_HW_RES 483 #define ISA_MAX_HW_RES 5 77 84 78 85 typedef struct { … … 141 148 } 142 149 150 static int isa_dma_channel_fun_setup(ddf_fun_t *fnode, 151 unsigned int channel, uint32_t pa, uint16_t size, uint8_t mode) 152 { 153 assert(fnode); 154 isa_fun_t *isa_fun = fnode->driver_data; 155 const hw_resource_list_t *res = &isa_fun->hw_resources; 156 assert(res); 157 158 const unsigned int ch = channel; 159 for (size_t i = 0; i < res->count; ++i) { 160 if (((res->resources[i].type == DMA_CHANNEL_16) && 161 (res->resources[i].res.dma_channel.dma16 == ch)) || 162 ((res->resources[i].type == DMA_CHANNEL_8) && 163 (res->resources[i].res.dma_channel.dma8 == ch))) { 164 return dma_setup_channel(channel, pa, size, mode); 165 } 166 } 167 168 return EINVAL; 169 } 170 143 171 static hw_res_ops_t isa_fun_hw_res_ops = { 144 &isa_get_fun_resources, 145 &isa_enable_fun_interrupt 172 .get_resource_list = isa_get_fun_resources, 173 .enable_interrupt = isa_enable_fun_interrupt, 174 .dma_channel_setup = isa_dma_channel_fun_setup, 146 175 }; 147 176 … … 314 343 } 315 344 345 static void isa_fun_set_dma(isa_fun_t *fun, int dma) 346 { 347 size_t count = fun->hw_resources.count; 348 hw_resource_t *resources = fun->hw_resources.resources; 349 350 if (count < ISA_MAX_HW_RES) { 351 if ((dma > 0) && (dma < 4)) { 352 resources[count].type = DMA_CHANNEL_8; 353 resources[count].res.dma_channel.dma8 = dma; 354 355 fun->hw_resources.count++; 356 ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma, 357 fun->fnode->name); 358 359 return; 360 } 361 362 if ((dma > 4) && (dma < 8)) { 363 resources[count].type = DMA_CHANNEL_16; 364 resources[count].res.dma_channel.dma16 = dma; 365 366 fun->hw_resources.count++; 367 ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma, 368 fun->fnode->name); 369 370 return; 371 } 372 373 ddf_msg(LVL_WARN, "Skipped dma 0x%x for function %s", dma, 374 fun->fnode->name); 375 } 376 } 377 316 378 static void isa_fun_set_io_range(isa_fun_t *fun, size_t addr, size_t len) 317 379 { … … 343 405 if (val != end) 344 406 isa_fun_set_irq(fun, irq); 407 } 408 409 static void fun_parse_dma(isa_fun_t *fun, char *val) 410 { 411 unsigned int dma = 0; 412 char *end = NULL; 413 414 val = skip_spaces(val); 415 dma = (unsigned int) strtol(val, &end, 10); 416 417 if (val != end) 418 isa_fun_set_dma(fun, dma); 345 419 } 346 420 … … 436 510 if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) && 437 511 !prop_parse(fun, line, "irq", &fun_parse_irq) && 512 !prop_parse(fun, line, "dma", &fun_parse_dma) && 438 513 !prop_parse(fun, line, "match", &fun_parse_match_id)) { 439 514 … … 446 521 { 447 522 fun->hw_resources.resources = 448 (hw_resource_t *) malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES);523 (hw_resource_t *) malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES); 449 524 } 450 525 … … 630 705 631 706 632 static void isa_init() 707 static void isa_init() 633 708 { 634 709 ddf_log_init(NAME, LVL_ERROR); -
uspace/drv/bus/isa/isa.dev
rcf5c05c0 rb39eb79 15 15 io_range 060 5 16 16 17 18 ne2k: 19 match 100 isa/ne2k 20 irq 5 21 io_range 300 20 22 23 sb16: 24 match 100 isa/sb16 25 io_range 220 20 26 io_range 330 2 27 irq 5 28 dma 1 29 dma 5
Note:
See TracChangeset
for help on using the changeset viewer.
