Changeset 153cc76a in mainline for uspace/drv/bus
- Timestamp:
- 2011-12-23T16:42:22Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e1b130
- Parents:
- 4291215 (diff), 2f0dd2a (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
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/Makefile
r4291215 r153cc76a 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/isa.c
r4291215 r153cc76a 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 * … … 52 53 #include <fcntl.h> 53 54 #include <sys/stat.h> 55 #include <ipc/irc.h> 56 #include <ipc/services.h> 57 #include <sysinfo.h> 58 #include <ns.h> 54 59 55 60 #include <ddf/driver.h> … … 61 66 #include <device/hw_res.h> 62 67 68 #include "i8237.h" 69 63 70 #define NAME "isa" 64 71 #define CHILD_FUN_CONF_PATH "/drv/isa/isa.dev" … … 70 77 #define ISA_FUN(fun) ((isa_fun_t *) ((fun)->driver_data)) 71 78 72 #define ISA_MAX_HW_RES 479 #define ISA_MAX_HW_RES 5 73 80 74 81 typedef struct { … … 96 103 static bool isa_enable_fun_interrupt(ddf_fun_t *fnode) 97 104 { 98 /* TODO */ 99 100 return false; 105 /* This is an old ugly way, copied from pci driver */ 106 assert(fnode); 107 isa_fun_t *isa_fun = fnode->driver_data; 108 109 sysarg_t apic; 110 sysarg_t i8259; 111 112 async_sess_t *irc_sess = NULL; 113 114 if (((sysinfo_get_value("apic", &apic) == EOK) && (apic)) 115 || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) { 116 irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 117 SERVICE_IRC, 0, 0); 118 } 119 120 if (!irc_sess) 121 return false; 122 123 assert(isa_fun); 124 const hw_resource_list_t *res = &isa_fun->hw_resources; 125 assert(res); 126 for (size_t i = 0; i < res->count; ++i) { 127 if (res->resources[i].type == INTERRUPT) { 128 const int irq = res->resources[i].res.interrupt.irq; 129 130 async_exch_t *exch = async_exchange_begin(irc_sess); 131 const int rc = 132 async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq); 133 async_exchange_end(exch); 134 135 if (rc != EOK) { 136 async_hangup(irc_sess); 137 return false; 138 } 139 } 140 } 141 142 async_hangup(irc_sess); 143 return true; 144 } 145 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; 101 165 } 102 166 103 167 static hw_res_ops_t isa_fun_hw_res_ops = { 104 &isa_get_fun_resources, 105 &isa_enable_fun_interrupt 168 .get_resource_list = isa_get_fun_resources, 169 .enable_interrupt = isa_enable_fun_interrupt, 170 .dma_channel_setup = isa_dma_channel_fun_setup, 106 171 }; 107 172 … … 274 339 } 275 340 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 276 374 static void isa_fun_set_io_range(isa_fun_t *fun, size_t addr, size_t len) 277 375 { … … 303 401 if (val != end) 304 402 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); 305 415 } 306 416 … … 396 506 if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) && 397 507 !prop_parse(fun, line, "irq", &fun_parse_irq) && 508 !prop_parse(fun, line, "dma", &fun_parse_dma) && 398 509 !prop_parse(fun, line, "match", &fun_parse_match_id)) { 399 510 … … 406 517 { 407 518 fun->hw_resources.resources = 408 (hw_resource_t *) malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES);519 (hw_resource_t *) malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES); 409 520 } 410 521 … … 590 701 591 702 592 static void isa_init() 703 static void isa_init() 593 704 { 594 705 ddf_log_init(NAME, LVL_ERROR); -
uspace/drv/bus/isa/isa.dev
r4291215 r153cc76a 18 18 irq 5 19 19 io_range 300 20 20 21 sb16: 22 match 100 isa/sb16 23 io_range 220 20 24 io_range 330 2 25 irq 5 26 dma 1 27 dma 5 -
uspace/drv/bus/pci/pciintel/pci.c
r4291215 r153cc76a 187 187 188 188 static hw_res_ops_t pciintel_hw_res_ops = { 189 &pciintel_get_resources,190 &pciintel_enable_interrupt189 .get_resource_list = &pciintel_get_resources, 190 .enable_interrupt = &pciintel_enable_interrupt, 191 191 }; 192 192 -
uspace/drv/bus/usb/ohci/utils/malloc32.h
r4291215 r153cc76a 56 56 uintptr_t result; 57 57 int ret = as_get_physical_mapping(addr, &result); 58 58 59 59 if (ret != EOK) 60 60 return 0; 61 return (result | ((uintptr_t)addr & 0xfff)); 61 62 return result; 62 63 } 63 64 /*----------------------------------------------------------------------------*/ -
uspace/drv/bus/usb/uhci/utils/malloc32.h
r4291215 r153cc76a 54 54 if (addr == NULL) 55 55 return 0; 56 56 57 57 uintptr_t result; 58 58 const int ret = as_get_physical_mapping(addr, &result); 59 59 if (ret != EOK) 60 60 return 0; 61 return (result | ((uintptr_t)addr & 0xfff)); 61 62 return result; 62 63 } 63 64 /*----------------------------------------------------------------------------*/ … … 97 98 static inline void * get_page(void) 98 99 { 99 void *free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE); 100 if (free_address == 0) 100 void *address = as_area_create((void *) -1, UHCI_REQUIRED_PAGE_SIZE, 101 AS_AREA_READ | AS_AREA_WRITE); 102 if (address == (void *) -1) 101 103 return NULL; 102 void *address = as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE, 103 AS_AREA_READ | AS_AREA_WRITE); 104 if (address != free_address) 105 return NULL; 104 106 105 return address; 107 106 } -
uspace/drv/bus/usb/usbmast/main.c
r4291215 r153cc76a 300 300 return; 301 301 } 302 303 comm_buf = as_get_mappable_page(comm_size);304 if (comm_buf == NULL) {302 303 (void) async_share_out_finalize(callid, &comm_buf); 304 if (comm_buf == (void *) -1) { 305 305 async_answer_0(callid, EHANGUP); 306 306 return; 307 307 } 308 309 (void) async_share_out_finalize(callid, comm_buf); 310 308 311 309 mfun = (usbmast_fun_t *) ((ddf_fun_t *)arg)->driver_data; 312 310
Note:
See TracChangeset
for help on using the changeset viewer.