mirror of
https://github.com/rdolbeau/NuBusFPGA.git
synced 2025-01-03 11:29:46 +00:00
DMA
This commit is contained in:
parent
cbfc0cad6d
commit
0f20034ce3
@ -100,7 +100,7 @@ OSErr cNuBusFPGARAMDskOpen(IOParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
|
|||||||
ctx->dma_blk_size = revb( read_reg(dce, DMA_BLK_SIZE) );
|
ctx->dma_blk_size = revb( read_reg(dce, DMA_BLK_SIZE) );
|
||||||
ctx->dma_blk_size_mask = ctx->dma_blk_size - 1; // size is Po2
|
ctx->dma_blk_size_mask = ctx->dma_blk_size - 1; // size is Po2
|
||||||
ctx->dma_blk_size_shift = 0;
|
ctx->dma_blk_size_shift = 0;
|
||||||
while ((1 << ctx->dma_blk_size_shift) < ctx->dma_blk_size)
|
while ((1 << ctx->dma_blk_size_shift) < ctx->dma_blk_size) // fixme
|
||||||
ctx->dma_blk_size_shift++;
|
ctx->dma_blk_size_shift++;
|
||||||
ctx->dma_blk_base = revb( read_reg(dce, DMA_BLK_BASE) );
|
ctx->dma_blk_base = revb( read_reg(dce, DMA_BLK_BASE) );
|
||||||
ctx->dma_mem_size = revb( read_reg(dce, DMA_MEM_SIZE) );
|
ctx->dma_mem_size = revb( read_reg(dce, DMA_MEM_SIZE) );
|
||||||
|
@ -52,30 +52,40 @@ OSErr cNuBusFPGARAMDskPrime(IOParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
|
|||||||
if ((((unsigned long)pb->ioBuffer & ctx->dma_blk_size_mask) == 0) &&
|
if ((((unsigned long)pb->ioBuffer & ctx->dma_blk_size_mask) == 0) &&
|
||||||
(((unsigned long)pb->ioReqCount & ctx->dma_blk_size_mask) == 0) &&
|
(((unsigned long)pb->ioReqCount & ctx->dma_blk_size_mask) == 0) &&
|
||||||
(((unsigned long)abs_offset & ctx->dma_blk_size_mask) == 0)) {
|
(((unsigned long)abs_offset & ctx->dma_blk_size_mask) == 0)) {
|
||||||
|
unsigned long blk_todo = (pb->ioReqCount >> ctx->dma_blk_size_shift), blk_doing, blk_done;
|
||||||
unsigned long count, max_count, delay;
|
unsigned long count, max_count, delay;
|
||||||
unsigned long blk_cnt, status;
|
unsigned long blk_cnt, status;
|
||||||
blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF;
|
blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF;
|
||||||
status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS;
|
status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS;
|
||||||
max_count = 4096 + 16 * blk_cnt;
|
blk_done = 0;
|
||||||
/* if (max_count < 32) */
|
while (blk_todo > 0) {
|
||||||
/* max_count = 32; */
|
blk_doing = blk_todo;
|
||||||
delay = 16 * blk_cnt;
|
if (blk_doing > 65535) { // fixme: read HW max
|
||||||
if (delay > 4096)
|
blk_doing = 32768; // nice Po2
|
||||||
delay = 4096;
|
}
|
||||||
|
max_count = 32 * blk_doing;
|
||||||
|
delay = (blk_doing >> 4);
|
||||||
|
if (delay > 65536)
|
||||||
|
delay = 65536;
|
||||||
if ((blk_cnt == 0) && (status == 0)) {
|
if ((blk_cnt == 0) && (status == 0)) {
|
||||||
write_reg(dce, DMA_BLK_ADDR, revb(ctx->dma_blk_base + (abs_offset >> ctx->dma_blk_size_shift)));
|
write_reg(dce, DMA_BLK_ADDR, revb(ctx->dma_blk_base + (abs_offset >> ctx->dma_blk_size_shift) + blk_done));
|
||||||
write_reg(dce, DMA_DMA_ADDR, revb(pb->ioBuffer));
|
write_reg(dce, DMA_DMA_ADDR, revb(pb->ioBuffer + (blk_done << ctx->dma_blk_size_shift)));
|
||||||
write_reg(dce, DMA_BLK_CNT, revb(0x00000000ul | (pb->ioReqCount >> ctx->dma_blk_size_shift)));
|
write_reg(dce, DMA_BLK_CNT, revb(0x00000000ul | blk_doing));
|
||||||
|
waitSome(delay);
|
||||||
count = 0;
|
count = 0;
|
||||||
while (((blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF) != 0) && (count < max_count)) {
|
blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF;
|
||||||
|
status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS;
|
||||||
|
while (((blk_cnt != 0) ||
|
||||||
|
(status != 0)) &&
|
||||||
|
(count < max_count)) {
|
||||||
count ++;
|
count ++;
|
||||||
waitSome(delay);
|
waitSome(delay);
|
||||||
|
if (blk_cnt) blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF;
|
||||||
|
if (status) status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS;
|
||||||
}
|
}
|
||||||
count = 0;
|
|
||||||
while ((((status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS)) != 0) && (count < max_count)) {
|
|
||||||
count ++;
|
|
||||||
waitSome(delay);
|
|
||||||
}
|
}
|
||||||
|
blk_done += blk_doing;
|
||||||
|
blk_todo -= blk_doing;
|
||||||
}
|
}
|
||||||
if (blk_cnt || status) {
|
if (blk_cnt || status) {
|
||||||
return readErr;
|
return readErr;
|
||||||
@ -130,30 +140,40 @@ OSErr cNuBusFPGARAMDskPrime(IOParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
|
|||||||
if ((((unsigned long)pb->ioBuffer & ctx->dma_blk_size_mask) == 0) &&
|
if ((((unsigned long)pb->ioBuffer & ctx->dma_blk_size_mask) == 0) &&
|
||||||
(((unsigned long)pb->ioReqCount & ctx->dma_blk_size_mask) == 0) &&
|
(((unsigned long)pb->ioReqCount & ctx->dma_blk_size_mask) == 0) &&
|
||||||
(((unsigned long)abs_offset & ctx->dma_blk_size_mask) == 0)) {
|
(((unsigned long)abs_offset & ctx->dma_blk_size_mask) == 0)) {
|
||||||
|
unsigned long blk_todo = (pb->ioReqCount >> ctx->dma_blk_size_shift), blk_doing, blk_done;
|
||||||
unsigned long count, max_count, delay;
|
unsigned long count, max_count, delay;
|
||||||
unsigned long blk_cnt, status;
|
unsigned long blk_cnt, status;
|
||||||
blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF;
|
blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF;
|
||||||
status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS;
|
status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS;
|
||||||
max_count = 4096 + 16 * blk_cnt;
|
blk_done = 0;
|
||||||
/* if (max_count < 32) */
|
while (blk_todo > 0) {
|
||||||
/* max_count = 32; */
|
blk_doing = blk_todo;
|
||||||
delay = 16 * blk_cnt;
|
if (blk_doing > 65535) { // fixme: read HW max
|
||||||
if (delay > 4096)
|
blk_doing = 32768; // nice Po2
|
||||||
delay = 4096;
|
}
|
||||||
|
max_count = 32 * blk_doing;
|
||||||
|
delay = (blk_doing >> 4);
|
||||||
|
if (delay > 65536)
|
||||||
|
delay = 65536;
|
||||||
if ((blk_cnt == 0) && (status == 0)) {
|
if ((blk_cnt == 0) && (status == 0)) {
|
||||||
write_reg(dce, DMA_BLK_ADDR, revb(ctx->dma_blk_base + (abs_offset >> ctx->dma_blk_size_shift)));
|
write_reg(dce, DMA_BLK_ADDR, revb(ctx->dma_blk_base + (abs_offset >> ctx->dma_blk_size_shift) + blk_done));
|
||||||
write_reg(dce, DMA_DMA_ADDR, revb(pb->ioBuffer));
|
write_reg(dce, DMA_DMA_ADDR, revb(pb->ioBuffer + (blk_done << ctx->dma_blk_size_shift)));
|
||||||
write_reg(dce, DMA_BLK_CNT, revb(0x80000000ul | (pb->ioReqCount >> ctx->dma_blk_size_shift)));
|
write_reg(dce, DMA_BLK_CNT, revb(0x80000000ul | blk_doing));
|
||||||
|
waitSome(delay);
|
||||||
count = 0;
|
count = 0;
|
||||||
while (((blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF) != 0) && (count < max_count)) {
|
blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF;
|
||||||
|
status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS;
|
||||||
|
while (((blk_cnt != 0) ||
|
||||||
|
(status != 0)) &&
|
||||||
|
(count < max_count)) {
|
||||||
count ++;
|
count ++;
|
||||||
waitSome(delay);
|
waitSome(delay);
|
||||||
|
if (blk_cnt) blk_cnt = revb(read_reg(dce, DMA_BLK_CNT)) & 0xFFFF;
|
||||||
|
if (status) status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS;
|
||||||
}
|
}
|
||||||
count = 0;
|
|
||||||
while ((((status = revb(read_reg(dce, DMA_STATUS)) & DMA_STATUS_CHECK_BITS)) != 0) && (count < max_count)) {
|
|
||||||
count ++;
|
|
||||||
waitSome(delay);
|
|
||||||
}
|
}
|
||||||
|
blk_done += blk_doing;
|
||||||
|
blk_todo -= blk_doing;
|
||||||
}
|
}
|
||||||
if (blk_cnt || status) {
|
if (blk_cnt || status) {
|
||||||
return writErr;
|
return writErr;
|
||||||
|
Loading…
Reference in New Issue
Block a user