3 Device Bus
| (require ledum/define/bus) | package: ledum-definers |
This module provides all the common bindings required to implement and use devices connected to the bus emulation layer.
Specifically it reprovides the following procedures: bus-attach!, bus-detach!, bus-write!, bus-read.
3.1 Bus Structs
| (require ledum/define/bus/struct) | package: ledum-definers |
Only the rudimentary bus interface and registered device structs are provided with some auxiliary functionality as well.
struct
adrbw : exact-positive-integer? datbw : exact-positive-integer? devs : (listof busreg?)
struct
start : exact-nonnegative-integer? end : exact-nonnegative-integer? dev : device?
procedure
(match-busreg-addr br addr) → boolean?
br : busreg? addr : exact-nonnegative-integer?
3.2 Generic Device Interface
| (require ledum/define/bus/device) | package: ledum-definers |
Any device connecting to the bus must conform to the generic interface specified in this module. The implementation does not need to be complete - only the device-capabilities must be implemented and then only the generic methods for which the device has a capability have to be implemented as well.
generic interface
(device-read device addr)
(device-write device addr value)
(device-blockread device addr buf)
(device-blockwrite device addr buf)
(device-attach device bus)
(device-detach device)
(device-capabilities device)
(device-dma device addr size)
See the bus-watcher implementation for a simple device example.
procedure
(device-read device addr) → exact-nonnegative-integer?
device : device? addr : exact-nonnegative-integer?
procedure
(device-write device addr value) → void?
device : device? addr : exact-nonnegative-integer? value : exact-nonnegative-integer?
procedure
(device-blockread device addr buf) → void?
device : device? addr : exact-nonnegative-integer? buf : (vectorof exact-nonnegative-integer?)
Fills the given buffer buf with device data starting at address addr.
procedure
(device-blockwrite device addr buf) → void?
device : device? addr : exact-nonnegative-integer? buf : (vectorof exact-nonnegative-integer?)
Sets the device data starting at address addr to the contents of the buffer buf.
procedure
(device-attach device bus) → void?
device : device? bus : busintf?
procedure
(device-detach device) → void?
device : device?
procedure
(device-capabilities device) → (listof symbol?)
device : device?
procedure
(device-dma device addr size) →
vector? exact-nonnegative-integer? exact-positive-integer? device : device? addr : exact-nonnegative-integer? size : exact-positive-integer?
procedure
(device-has-capability? dev cap) → boolean?
dev : device? cap : symbol?
procedure
(device-has-read? dev) → boolean?
dev : device?
procedure
(device-has-write? dev) → boolean?
dev : device?
procedure
(device-has-blockread? dev) → boolean?
dev : device?
procedure
(device-has-blockwrite? dev) → boolean?
dev : device?
procedure
(device-has-attach? dev) → boolean?
dev : device?
procedure
(device-has-detach? dev) → boolean?
dev : device?
3.3 Bus Core
| (require ledum/define/bus/core) | package: ledum-definers |
This module provides the core procedures to create and use the bus.
procedure
(make-bus addr data) → busintf?
addr : exact-positive-integer? data : exact-positive-integer?
procedure
(busintf-attach! bus start end dev) → void?
bus : busintf? start : exact-nonnegative-integer? end : exact-nonnegative-integer? dev : device?
procedure
(busintf-write! bus addr value) → void?
bus : busintf? addr : exact-nonnegative-integer? value : exact-nonnegative-integer?
If no device on the bus accepts the write, exn:ledum:bus is raised with offending address addr and informative value.
procedure
(busintf-read bus addr) → exact-nonnegative-integer?
bus : busintf? addr : exact-nonnegative-integer?
If no device on the bus serves the read, exn:ledum:bus is raised with offending address addr.
procedure
(busintf-blockwrite! bus addr buf) → void?
bus : busintf? addr : exact-nonnegative-integer? buf : (vectorof exact-nonnegative-integer?)
This should not be used for standard inter-device communication but mainly as an optimization of the emulation layer for data-intensive tasks like video output.
procedure
(busintf-blockread bus addr buf) → void?
bus : busintf? addr : exact-nonnegative-integer? buf : (vectorof exact-nonnegative-integer?)
This should not be used for standard inter-device communication but mainly as an optimization of the emulation layer for data-intensive tasks like video output.
procedure
(busintf-dma bus addr size) →
vector? exact-nonnegative-integer? exact-positive-integer? bus : busintf? addr : exact-nonnegative-integer? size : exact-positive-integer?
3.4 Bus Environment
| (require ledum/define/bus/env) | package: ledum-definers |
This module provides the parameterizable environment to be used by both ISA specification and computer system emulator.
parameter
(current-bus) → busintf?
(current-bus bus) → void? bus : busintf?
procedure
(bus-attach! start end dev) → void?
start : exact-nonnegative-integer? end : exact-nonnegative-integer? dev : device?
procedure
(bus-detach! dev) → void?
dev : device?
procedure
(bus-read addr) → exact-nonnegative-integer?
addr : exact-nonnegative-integer?
procedure
(bus-write! addr value) → void?
addr : exact-nonnegative-integer? value : exact-nonnegative-integer?