Skip to content

Instantly share code, notes, and snippets.

@tomgalvin594
Created August 17, 2013 12:30
Show Gist options
  • Save tomgalvin594/6256688 to your computer and use it in GitHub Desktop.
Save tomgalvin594/6256688 to your computer and use it in GitHub Desktop.
A proposed hardware spec for the DCPU-16 that would allow hot swapping of DCPU-16 hardware without relaxing the condition in the official spec.
Name: Generic Hot-Swap Hardware
ID: 0x110753A9
Version: 2
Interrupts do different things depending on contents of the A register:
A | BEHAVIOR
---+----------------------------------------------------------------------------
0 | Query the device that is currently connected.
| This is equivalent of the HWQ command if the device was directly connected
| to the DCPU-16.
1 | If register B is non-zero, turn on interrupts with message B. If B is zero,
| disable interrupts.
2 | If register B is non-zero, turn on the external light indicating that the
| device has been connected and should not be disconnected. If register B is
| zero, turn off this light.
3 | Register B is copied into an internal register (called AX), and then puts
| this device into forwarding mode.
---+----------------------------------------------------------------------------
The purpose of this device is to allow hot swapping of DCPU-16 hardware without
invoking undefined behavior. In order to achieve this, this device will connect
to the DCPU-16 and present itself as a single hardware device, while a port is
available on the device in which another DCPU-16 hardware device can be
connected.
If interrupts have been enabled, this device will trigger an interrupt whenever
a device is connected or disconnected from it.
In order to aid the user of this device, a status light has been placed on the
front of the device which would indicate whether the device is in use or able
to be disconnected safely. NOTE: This device will allow the connected hardware
to be disconnected at any time, regardless of the light's state. It is also the
job of the programmer of the DCPU-16 to turn the light on and off to indicate if
the hardware may be disconnected or not.
When this device receives an interrupt with register A that equals 3, it goes
into a special mode where all interrupts sent to this device from the DCPU-16
will be forwarded to the connected hardware (at an extra delay of 2 cycles),
and any interrupts sent by the connected device will be forwarded to the
DCPU-16. HWQ requests are also forwarded to the connected device, with no delay.
This mode is stopped if either the connected device is disconnected, or an
interrupt is sent from the DCPU-16 with the registers A, B, and C containing
the value from register AX.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment