Changeset 1864948 in mainline
- Timestamp:
- 2012-08-18T14:24:40Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b28dabe
- Parents:
- 6fd365d
- Location:
- uspace/drv/bus/isa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/i8237.c
r6fd365d r1864948 429 429 } 430 430 431 extern int dma_channel_remain(unsigned channel, uint16_t *size) 432 { 433 assert(size); 434 if ((channel == 0) || (channel == 4)) 435 return ENOTSUP; 436 437 if (channel > 7) 438 return ENOENT; 439 440 fibril_mutex_lock(&guard); 441 if (!controller_8237.initialized) { 442 fibril_mutex_unlock(&guard); 443 return EIO; 444 } 445 446 const dma_channel_t dma_channel = controller_8237.channels[channel]; 447 /* Get size - reset flip-flop */ 448 pio_write_8(dma_channel.flip_flop_address, 0); 449 450 /* Low byte */ 451 const uint8_t value_low = pio_read_8(dma_channel.size_reg_address); 452 ddf_msg(LVL_DEBUG2, "Read size low byte: %p:%zx.", 453 dma_channel.size_reg_address, value_low); 454 455 /* High byte */ 456 const uint8_t value_high = pio_read_8(dma_channel.size_reg_address); 457 ddf_msg(LVL_DEBUG2, "Read size high byte: %p:%zx.", 458 dma_channel.size_reg_address, value_high); 459 fibril_mutex_unlock(&guard); 460 461 const int remain = (value_high << 8 | value_low) + 1; 462 /* 16 bit DMA size is in words */ 463 *size = channel >= 4 ? remain << 1 : remain; 464 return EOK; 465 } 431 466 /** 432 467 * @} -
uspace/drv/bus/isa/i8237.h
r6fd365d r1864948 39 39 40 40 extern int dma_channel_setup(unsigned, uint32_t, uint16_t, uint8_t); 41 extern int dma_channel_remain(unsigned, uint16_t *); 41 42 42 43 #endif -
uspace/drv/bus/isa/isa.c
r6fd365d r1864948 169 169 } 170 170 171 static int isa_fun_remain_dma(ddf_fun_t *fnode, 172 unsigned channel, uint16_t *size) 173 { 174 assert(size); 175 assert(fnode); 176 isa_fun_t *isa_fun = fnode->driver_data; 177 assert(isa_fun); 178 const hw_resource_list_t *res = &isa_fun->hw_resources; 179 assert(res); 180 181 for (size_t i = 0; i < res->count; ++i) { 182 /* Check for assigned channel */ 183 if (((res->resources[i].type == DMA_CHANNEL_16) && 184 (res->resources[i].res.dma_channel.dma16 == channel)) || 185 ((res->resources[i].type == DMA_CHANNEL_8) && 186 (res->resources[i].res.dma_channel.dma8 == channel))) { 187 return dma_channel_remain(channel, size); 188 } 189 } 190 191 return EINVAL; 192 } 193 171 194 static hw_res_ops_t isa_fun_hw_res_ops = { 172 195 .get_resource_list = isa_fun_get_resources, 173 196 .enable_interrupt = isa_fun_enable_interrupt, 174 197 .dma_channel_setup = isa_fun_setup_dma, 198 .dma_channel_remain = isa_fun_remain_dma, 175 199 }; 176 200
Note:
See TracChangeset
for help on using the changeset viewer.