s-macke/jor1k — pull request #19 by angrave (2014-07-07 20:45:25+00:00)
Title: Improved uart flowcontrol - better idle-state support

An 'idle-aware', faster and hopefully robust uart.

There is a new method 'HaltPending' that cancel the intended halt. It may also raise an interrupt if there's more to do.
```
// UART can prevent the VM from going to idle/halt mode if there are still characters waiting to be sent to the kernel
UARTDev.prototype.HaltPending = function() {

if(this.rxbuf.length === 0) {
return true; // Allow halt - we have nothing more to give
}
this.ratelimitcounter = this.ratelimitmaxcount;
this.UpdateRx(); // May raise an interrupt
return !this.kernelcanreceive; // Deny halt if we have more
}
```
This is now tested on my i7 machine on Safari, FF and chrome using a 4KB and 44KB test file.

UpdateRX no longer decrements the counter (this is now only performed when a character is actually received - see ReadReg8()

With the new CPU idle state, the uart-kernel interaction is more reliable than before and the range of parameters that appear to work is much greater.

I've re-enabled burst mode (where the first 1024+ characters can be sent immediately without any delay) but can disable it if it causes problems. The actual number of characters can be more than this because echo'd characters also provide some 'payback' to the counter.

I assume the CPU entering IDLE is a good time to re-enable burst mode as it suggests the Kernal has finished processing the input characters, so in HaltPending() we raise the delaycounter to it's maximum value -
```
this.ratelimitcounter = this.ratelimitmaxcount;
```
(A more conservative value would be 1)