On this page:
4.1 Bus Watcher
bus-watcher
make-bus-watcher
reset-bus-watcher!
4.2 Memory
memory
make-ram
make-rom
4.3 Video
4.4 Controller
controller
make-controller
4.5 LGA
lga
make-lga
9.2

4 Devices🔗

These modules provide certain devices used to built an emulated computer system.

4.1 Bus Watcher🔗

 (require ledum/define/bus/watcher) package: ledum-definers

This module provides a special device that can be attached to any address range on the bus to watch for writes.

struct

(struct bus-watcher (dirty?))

  dirty? : boolean?
This device provides only the write capability. Upon write, it sets the internal dirty? flag to #t.

The bus-watcher-dirty? field accessor should be used to determine whether something wrote to given range since the last reset-bus-watcher! call.

Creates a bus watcher which is in not-dirty state.

procedure

(reset-bus-watcher! bw)  void?

  bw : bus-watcher?
Resets the internal flag to #f.

4.2 Memory🔗

 (require ledum/define/memory) package: ledum-definers

struct

(struct memory (rw? size word data writer))

  rw? : boolean?
  size : exact-positive-integer?
  word : exact-positive-integer?
  data : (vectorof exact-positive-integer?)
  writer : 
(-> memory?
    exact-nonnegative-integer?
    exact-nonnegative-integer?
    void?)
This device represents a read-only or read-write memory. If the rw? flag is #t, the memory is writable. The size field is only for informative purposes. The word bit-width is used for contracting the writer procedure. This device implements the DMA generic (see device-dma for more information).

procedure

(make-ram [#:size size    
  #:word word    
  #:data data    
  #:file fname    
  #:base base])  memory?
  size : (or/c #f exact-positive-integer?) = #f
  word : (or/c #f exact-positive-integer?) = #f
  data : (or/c #f bytes?) = #f
  fname : (or/c #f path-string? path?) = #f
  base : exact-nonnegative-integer? = 0
Creates new random-access memory of given size and word bit-width. If data is provided, it is used as initial data of the memory created. If fname is provided, the initial data is loaded from given file. The data is preferred over fname.

If base is specified, the data loaded at given base offset.

procedure

(make-rom [#:size size    
  #:word word    
  #:data data    
  #:file fname    
  #:base base])  memory?
  size : (or/c #f exact-positive-integer?) = #f
  word : (or/c #f exact-positive-integer?) = #f
  data : (or/c #f bytes?) = #f
  fname : (or/c #f path-string? path?) = #f
  base : exact-nonnegative-integer? = 0
Creates new read-only memory. The arguments are the same as for make-ram.

4.3 Video🔗

 (require ledum/define/video) package: ledum-definers

A video framebuffer device using an already-attached memory on the same bus with procedures for using it in emulation layer.

4.4 Controller🔗

 (require ledum/define/controller) package: ledum-definers

A simple controller device providing arrow keys and four other buttons mapped to keyboard keys "a", "s", "z" and "x".

struct

(struct controller (mask))

  mask : exact-nonnegative-integer?
This is rather simple device which can be attached to the system bus and provides only a single address to read. Reading the 16-bit value is to be interpreted as follows:

Bit

Mask (hex)

Key

0

1

up

1

2

down

2

4

left

3

8

right

4

10

a

5

20

s

6

40

z

7

80

x

8

100

reserved

9

200

reserved

10

400

reserved

11

800

reserved

12

1000

reserved

13

2000

reserved

14

4000

reserved

15

8000

reserved

The with-emulator-window uses the gen:emuctrl on this device to provide actual key press and release event notifications. Based on these events the device updates the internal button press mask and the change is immediately visible from within the emulated system.

procedure

(make-controller)  controller?

Creates a new controller with no keys pressed initially.

4.5 LGA🔗

 (require ledum/define/lga) package: ledum-definers

Ledum Graphics Adapter is a video framebuffer device using already-attached memory on the same bus with procedures for using it in the emulation layer.

struct

(struct lga (width height gap base end start bus dirty?))

  width : exact-positive-integer?
  height : exact-positive-integer?
  gap : exact-nonnegative-integer?
  base : exact-nonnegative-integer?
  end : exact-nonnegative-integer?
  start : exact-nonnegative-integer?
  bus : busintf?
  dirty? : boolean?
The lga device attaches itself to the bus and has the following MMIO registers:

  • 0 - R/W upper word of the base address

  • 1 - R/W lower word of the base address

  • 2 - R/W upper word of the end address

  • 3 - R/W lower word of the end address

  • 4 - R/W upper word of the start offset

  • 5 - R/W lower word of the start offset

  • 6 - R/W scanline gap

  • 7 - R width

  • 8 - R height

The dirty? field is set to #t whenever any of the configuration registers is written to. See lga-dirty? and reset-emufb-dirty! for details.

procedure

(make-lga [width height addr])  videofb?

  width : exact-positive-integer? = 640
  height : exact-positive-integer? = 480
  addr : exact-nonnegative-integer? = 0
Creates a new lga device of given dimensions width \times height. The initial address addr of the framebuffer on the bus can also be specified.