GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
channel.h
Go to the documentation of this file.
1/*
2 * channel.h - generic CPU<->peripheral line bundle for an integrated channel.
3 *
4 * The GE-120 integrated peripherals hang off the CPU's organisation phase over a
5 * small set of hardware lines: a cycle-request, a data bus + "char ready" strobe,
6 * an end-of-transfer line, and a command/order byte. Channel 2 (CAN2) carries the
7 * integrated reader (input) AND the printer/typewriter (output); per dwg
8 * 14023130, the channel-2 transfer micro-states (rSI low nibble 0C/0E input,
9 * 02/03 printer-output, 0A/0B end-print) read/drive exactly these lines.
10 *
11 * `struct ge_channel` generalises `ge_integrated_reader` (lu08/data/fini) and
12 * `ge_connector` (te10/te20/data/fine) into one line bundle so the reader,
13 * keyboard, and .cap feeder (input) and the printer (output) all attach the same
14 * way: a peripheral registers via ge_register_peri and, in its callbacks, either
15 * offers input characters on the lines (input) or is handed output characters by
16 * the CPU microcode through `sink` (output). The machine's own microcode moves
17 * the data — the peripheral only presents/consumes characters on the lines.
18 *
19 * This header introduces the abstraction; wiring the microcode (Phase 3) and
20 * migrating the reader onto it (Phase 4) follow. See docs/peripherals.md.
21 */
22#ifndef CHANNEL_H
23#define CHANNEL_H
24
25#include <stdint.h>
26
27struct ge;
28struct ge_channel;
29
30/* Output: the CPU hands a character to the peripheral (printer "Load Printer
31 * Buffer", command CE16 in transfer state 02|03). */
32typedef void (*ge_channel_sink)(struct ge *, struct ge_channel *, uint8_t ch);
33/* Input: the peripheral offers the next character on the bus; returns 1 if a
34 * character is available (and sets *ch, *end), 0 if not ready this cycle. */
35typedef int (*ge_channel_source)(struct ge *, struct ge_channel *,
36 uint8_t *ch, uint8_t *end);
37
38struct ge_channel {
39 const char *name;
40
41 /* peripheral -> CPU cycle request (generalises LU08; printer OR'd via RIMZA) */
42 uint8_t req:1;
43 /* data bus + "character ready" strobe (generalises lu08 / te10|te20) */
44 uint8_t data;
45 uint8_t data_valid:1;
46 /* peripheral end-of-transfer (drives the RF10x chain -> RIG1) */
47 uint8_t fini:1;
48 /* last order/command byte delivered to the peripheral (from rRE) */
49 uint8_t cmd;
50 /* transfer direction for the in-flight operation: 1 = OUTPUT (CPU->peri,
51 * L207), 0 = INPUT (peri->CPU). */
52 uint8_t out:1;
53
54 ge_channel_sink sink; /* CPU->peri character (output) */
55 ge_channel_source source; /* peri->CPU character (input) */
56 void *ctx; /* peripheral private state */
57};
58
59/* Input line ops (generalise reader_setup_to_send / reader_clear_sending). */
60void channel_offer_input(struct ge *, struct ge_channel *, uint8_t data, uint8_t end);
61void channel_clear_input(struct ge *, struct ge_channel *);
62/* Output line op: deliver one character from the CPU to the peripheral sink. */
63void channel_accept_output(struct ge *, struct ge_channel *, uint8_t ch);
64
65/* Line reads (feed the request/data/end signals). */
66uint8_t channel_get_req(struct ge_channel *);
67uint8_t channel_get_data(struct ge_channel *);
68uint8_t channel_get_fini(struct ge_channel *);
69
70#endif /* CHANNEL_H */
uint8_t channel_get_fini(struct ge_channel *)
Definition channel.c:39
void channel_offer_input(struct ge *, struct ge_channel *, uint8_t data, uint8_t end)
Definition channel.c:12
int(* ge_channel_source)(struct ge *, struct ge_channel *, uint8_t *ch, uint8_t *end)
Definition channel.h:35
uint8_t channel_get_data(struct ge_channel *)
Definition channel.c:38
void channel_clear_input(struct ge *, struct ge_channel *)
Definition channel.c:22
void channel_accept_output(struct ge *, struct ge_channel *, uint8_t ch)
Definition channel.c:31
uint8_t channel_get_req(struct ge_channel *)
Definition channel.c:37
void(* ge_channel_sink)(struct ge *, struct ge_channel *, uint8_t ch)
Definition channel.h:32
void * ctx
Definition channel.h:56
uint8_t out
Definition channel.h:52
uint8_t data
Definition channel.h:44
uint8_t cmd
Definition channel.h:49
uint8_t data_valid
Definition channel.h:45
const char * name
Definition channel.h:39
ge_channel_source source
Definition channel.h:55
ge_channel_sink sink
Definition channel.h:54
uint8_t req
Definition channel.h:42
uint8_t fini
Definition channel.h:47
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition ge.h:96