Changeset b4857bc in mainline
- Timestamp:
- 2011-10-23T21:39:15Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 25f8e5d
- Parents:
- ac149d5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dma_controller.c
rac149d5 rb4857bc 37 37 #include <libarch/ddi.h> 38 38 39 #include "ddf_log.h" 39 40 #include "dma_controller.h" 40 41 … … 76 77 #define DMA_MODE_CHAN_AUTO_FLAG (1 << 4) 77 78 #define DMA_MODE_CHAN_DOWN_FLAG (1 << 5) 78 #define DMA_MODE_CHAN_MOD _MASK (0x3)79 #define DMA_MODE_CHAN_MOD _SHIFT (6)80 #define DMA_MODE_CHAN_MOD _DEMAND (0)81 #define DMA_MODE_CHAN_MOD _SINGLE (1)82 #define DMA_MODE_CHAN_MOD _BLOCK (2)83 #define DMA_MODE_CHAN_MOD _CASCADE (3)79 #define DMA_MODE_CHAN_MODE_MASK (0x3) 80 #define DMA_MODE_CHAN_MODE_SHIFT (6) 81 #define DMA_MODE_CHAN_MODE_DEMAND (0) 82 #define DMA_MODE_CHAN_MODE_SINGLE (1) 83 #define DMA_MODE_CHAN_MODE_BLOCK (2) 84 #define DMA_MODE_CHAN_MODE_CASCADE (3) 84 85 85 86 uint8_t flip_flop; … … 163 164 } dma_controller_t; 164 165 166 167 /* http://zet.aluzina.org/index.php/8237_DMA_controller#DMA_Channel_Registers */ 165 168 static dma_controller_t controller_8237 = { 166 169 .channels = { … … 227 230 return EIO; 228 231 229 dma_channel_t dma_channel = controller_8237.channels[channel]; 230 232 /* 16 bit transfers are a bit special */ 233 ddf_log_debug("Unspoiled address and size: %p(%zu).\n", pa, size); 234 if (channel > 4) { 235 /* Size is the count of 16bit words */ 236 assert(size % 2 == 0); 237 size /= 2; 238 /* Address is fun: lower 16bits need to be shifted by 1 */ 239 pa = ((pa & 0xffff) >> 1) | (pa & 0xff0000); 240 } 241 242 const dma_channel_t dma_channel = controller_8237.channels[channel]; 243 244 ddf_log_debug("Setting channel %u, to address %p(%zu).\n", 245 channel, pa, size); 231 246 /* Mask DMA request */ 232 247 uint8_t value = DMA_SINGLE_MASK_CHAN_TO_REG(channel) … … 239 254 /* Low byte */ 240 255 value = pa & 0xff; 256 ddf_log_verbose("Writing address low byte: %hhx.\n", value); 241 257 pio_write_8(dma_channel.offset_reg_address, value); 242 258 243 259 /* High byte */ 244 260 value = (pa >> 8) & 0xff; 261 ddf_log_verbose("Writing address high byte: %hhx.\n", value); 245 262 pio_write_8(dma_channel.offset_reg_address, value); 246 263 247 264 /* Page address - third byte */ 248 265 value = (pa >> 16) & 0xff; 266 ddf_log_verbose("Writing address page byte: %hhx.\n", value); 249 267 pio_write_8(dma_channel.offset_reg_address, value); 250 268 … … 253 271 254 272 /* Low byte */ 255 value = size & 0xff; 273 value = (size - 1) & 0xff; 274 ddf_log_verbose("Writing size low byte: %hhx.\n", value); 256 275 pio_write_8(dma_channel.offset_reg_address, value); 257 276 258 277 /* High byte */ 259 value = (size >> 8) & 0xff; 278 value = ((size - 1) >> 8) & 0xff; 279 ddf_log_verbose("Writing size high byte: %hhx.\n", value); 260 280 pio_write_8(dma_channel.offset_reg_address, value); 261 281 … … 265 285 266 286 return EOK; 267 268 287 } 269 288 /*----------------------------------------------------------------------------*/ … … 291 310 << DMA_MODE_CHAN_TRA_SHIFT) 292 311 | (auto_mode ? DMA_MODE_CHAN_AUTO_FLAG : 0) 293 | (mode << DMA_MODE_CHAN_MOD_SHIFT); 312 | (mode << DMA_MODE_CHAN_MODE_SHIFT); 313 ddf_log_verbose("Setting mode: %hhx.\n", value); 294 314 pio_write_8(dma_channel.mode_address, value); 295 315
Note:
See TracChangeset
for help on using the changeset viewer.