# HG changeset patch # User Paul Boddie # Date 1717711027 -7200 # Node ID 31a89347c36e9fb2a6886a43c76b88fc1946c300 # Parent 787033879a7ec1d708273bca8fbdf74c035d7e43 Added automatic error clearing. Supported descriptor transfers on the X1600. diff -r 787033879a7e -r 31a89347c36e pkg/devices/lib/dma/include/dma-generic.h --- a/pkg/devices/lib/dma/include/dma-generic.h Wed Jun 05 13:51:55 2024 +0200 +++ b/pkg/devices/lib/dma/include/dma-generic.h Thu Jun 06 23:57:07 2024 +0200 @@ -66,6 +66,10 @@ (void) channel; } + virtual void clear_errors() + { + } + virtual bool error() { return false; diff -r 787033879a7e -r 31a89347c36e pkg/devices/lib/dma/include/dma-jz4730.h --- a/pkg/devices/lib/dma/include/dma-jz4730.h Wed Jun 05 13:51:55 2024 +0200 +++ b/pkg/devices/lib/dma/include/dma-jz4730.h Thu Jun 06 23:57:07 2024 +0200 @@ -148,6 +148,8 @@ void ack_irq(); + void clear_errors(); + bool completed(); bool error(); diff -r 787033879a7e -r 31a89347c36e pkg/devices/lib/dma/include/dma-jz4780.h --- a/pkg/devices/lib/dma/include/dma-jz4780.h Wed Jun 05 13:51:55 2024 +0200 +++ b/pkg/devices/lib/dma/include/dma-jz4780.h Thu Jun 06 23:57:07 2024 +0200 @@ -1,7 +1,7 @@ /* * DMA support for the JZ4780. * - * Copyright (C) 2021, 2023 Paul Boddie + * Copyright (C) 2021, 2023, 2024 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -133,6 +133,8 @@ void ack_irq(); + void clear_errors(); + bool completed(); bool error(); @@ -167,6 +169,8 @@ void ack_irq(uint8_t channel); + void clear_errors(); + bool error(); bool halted(); diff -r 787033879a7e -r 31a89347c36e pkg/devices/lib/dma/include/dma-x1600.h --- a/pkg/devices/lib/dma/include/dma-x1600.h Wed Jun 05 13:51:55 2024 +0200 +++ b/pkg/devices/lib/dma/include/dma-x1600.h Thu Jun 06 23:57:07 2024 +0200 @@ -1,7 +1,7 @@ /* * DMA support for the X1600. * - * Copyright (C) 2021, 2023 Paul Boddie + * Copyright (C) 2021, 2023, 2024 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -129,6 +129,8 @@ void ack_irq(); + void clear_errors(); + bool completed(); bool error(); @@ -162,6 +164,8 @@ void ack_irq(uint8_t channel); + void clear_errors(); + bool error(); bool halted(); diff -r 787033879a7e -r 31a89347c36e pkg/devices/lib/dma/src/jz4730.cc --- a/pkg/devices/lib/dma/src/jz4730.cc Wed Jun 05 13:51:55 2024 +0200 +++ b/pkg/devices/lib/dma/src/jz4730.cc Thu Jun 06 23:57:07 2024 +0200 @@ -251,7 +251,10 @@ // Ensure an absence of address error and halt conditions globally and in this channel. if (error() || halted()) - return 0; + { + printf("Cleared:%s%s\n", error() ? " error" : "", halted() ? " halted" : ""); + clear_errors(); + } // Ensure an absence of transaction completed and zero transfer count for this channel. @@ -371,6 +374,14 @@ _regs[Dma_control_status] = _regs[Dma_control_status] & ~Dma_trans_completed; } +// Clear error conditions. + +void +Dma_jz4730_channel::clear_errors() +{ + _regs[Dma_control_status] = _regs[Dma_control_status] & ~(Dma_address_error | Dma_trans_halted); +} + // Return whether a transfer has completed. bool diff -r 787033879a7e -r 31a89347c36e pkg/devices/lib/dma/src/jz4780.cc --- a/pkg/devices/lib/dma/src/jz4780.cc Wed Jun 05 13:51:55 2024 +0200 +++ b/pkg/devices/lib/dma/src/jz4780.cc Thu Jun 06 23:57:07 2024 +0200 @@ -275,7 +275,10 @@ // Ensure an absence of address error and halt conditions globally and in this channel. if (error() || halted()) - return 0; + { + printf("Cleared:%s%s\n", error() ? " error" : "", halted() ? " halted" : ""); + clear_errors(); + } // Ensure a zero transfer count for this channel. @@ -427,6 +430,15 @@ _chip->ack_irq(_channel); } +// Clear error conditions. + +void +Dma_jz4780_channel::clear_errors() +{ + _regs[Dma_control_status] = _regs[Dma_control_status] & ~(Dma_address_error | Dma_trans_halted); + _chip->clear_errors(); +} + // Return whether a transfer has completed. bool @@ -510,6 +522,14 @@ _regs[Dma_irq_pending] = _regs[Dma_irq_pending] & ~(1 << channel); } +// Clear error conditions. + +void +Dma_jz4780_chip::clear_errors() +{ + _regs[Dma_control] = _regs[Dma_control] & ~(Dma_control_address_error | Dma_control_trans_halted); +} + // Return whether an address error condition has arisen. bool diff -r 787033879a7e -r 31a89347c36e pkg/devices/lib/dma/src/x1600.cc --- a/pkg/devices/lib/dma/src/x1600.cc Wed Jun 05 13:51:55 2024 +0200 +++ b/pkg/devices/lib/dma/src/x1600.cc Thu Jun 06 23:57:07 2024 +0200 @@ -259,7 +259,10 @@ // Ensure an absence of address error and halt conditions globally and in this channel. if (error() || halted()) - return 0; + { + printf("Cleared:%s%s\n", error() ? " error" : "", halted() ? " halted" : ""); + clear_errors(); + } // Ensure a zero transfer count for this channel. @@ -336,7 +339,8 @@ // Enable the channel with descriptor transfer configured if appropriate. - _regs[Dma_control_status] = Dma_no_descriptor_transfer | + _regs[Dma_control_status] = (desc_vaddr ? Dma_8word_descriptor : + Dma_no_descriptor_transfer) | Dma_channel_enable; // Return the number of units to transfer. @@ -409,6 +413,15 @@ _chip->ack_irq(_channel); } +// Clear error conditions. + +void +Dma_x1600_channel::clear_errors() +{ + _regs[Dma_control_status] = _regs[Dma_control_status] & ~(Dma_address_error | Dma_trans_halted); + _chip->clear_errors(); +} + // Return whether a transfer has completed. bool @@ -492,6 +505,14 @@ _regs[Dma_irq_pending] = _regs[Dma_irq_pending] & ~(1UL << channel); } +// Clear error conditions. + +void +Dma_x1600_chip::clear_errors() +{ + _regs[Dma_control] = _regs[Dma_control] & ~(Dma_control_address_error | Dma_control_trans_halted); +} + // Return whether an address error condition has arisen. bool