GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
peripherical.c
Go to the documentation of this file.
1#include <stdlib.h>
2#include <string.h>
3
4#include "ge.h"
5#include "peripherical.h"
6
8{
9 struct ge_peri *p;
10 int r;
11
12 for (p = ge->peri; p != NULL; p = p->next) {
13 if (p->on_pulse == NULL)
14 continue;
15 r = p->on_pulse(ge, p->ctx);
16 if (r != 0)
17 return r;
18 }
19 return 0;
20}
21
23{
24 int r;
25 struct ge_peri *p;
26
27 for (p = ge->peri; p != NULL; p = p->next) {
28 if (p->on_clock == NULL)
29 continue;
30 r = p->on_clock(ge, p->ctx);
31 if (r != 0)
32 return r;
33 }
34 return 0;
35}
36
37int ge_peri_deinit(struct ge *ge)
38{
39 struct ge_peri *p, *p2;
40 int r;
41
42 for (p = ge->peri; p != NULL;) {
43 p2 = p;
44 p = p->next;
45 if (p2->deinit != NULL) {
46 r = p2->deinit(ge, p2->ctx);
47 if (r != 0)
48 return r;
49 }
50 }
51
52 return 0;
53}
54
55int ge_register_peri(struct ge *ge, struct ge_peri *p)
56{
57 struct ge_peri **prec_next = &ge->peri;
58 struct ge_peri *pp = ge->peri;
59
60 while (pp != NULL) {
61 prec_next = &pp->next;
62 pp = pp->next;
63 }
64 *prec_next = p;
65 p->next = NULL;
66
67 if (p->init != NULL)
68 return p->init(ge, p->ctx);
69
70 return 0;
71}
int ge_peri_on_pulses(struct ge *ge)
Definition peripherical.c:7
int ge_peri_deinit(struct ge *ge)
int ge_register_peri(struct ge *ge, struct ge_peri *p)
int ge_peri_on_clock(struct ge *ge)
Definition ge.h:732
int(* on_pulse)(struct ge *, void *)
Definition ge.h:735
void * ctx
Definition ge.h:738
struct ge_peri * next
Definition ge.h:733
int(* init)(struct ge *, void *)
Definition ge.h:734
int(* deinit)(struct ge *, void *)
Definition ge.h:737
int(* on_clock)(struct ge *, void *)
Definition ge.h:736
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition ge.h:96
struct ge_peri * peri
Definition ge.h:647