summaryrefslogtreecommitdiff
path: root/include/z80-if.h
blob: 676d37d9b23e9121d8e4b623cb02f0b4d8c3486c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

#define ZST_ACQUIRED	0x01
#define ZST_RUNNING	0x02

typedef enum {
	RESET		= 0x00,
	RESET_AQRD	= ZST_ACQUIRED,
	RUNNING		= ZST_RUNNING,
	RUNNING_AQRD	= ZST_RUNNING | ZST_ACQUIRED,
} zstate_t;

typedef enum {
	Reset,
	Request,
	Release,
	Run,
	Restart,
	M_Cycle
} bus_cmd_t;

typedef enum {LOW, HIGH} level_t;

zstate_t z80_bus_state(void);
zstate_t z80_bus_cmd(bus_cmd_t cmd);
void z80_setup_bus(void);
int z80_stat_reset(void);
//void z80_busreq(level_t level);
int z80_stat_halt(void);


void z80_write(uint32_t addr, uint8_t data);
uint8_t z80_read(uint32_t addr);
void z80_memset(uint32_t addr, uint8_t data, uint32_t length);
void z80_write_block_P(const FLASH uint8_t *src, uint32_t dest, uint32_t length);
void z80_write_block(const uint8_t *src, uint32_t dest, uint32_t length);
void z80_read_block (uint8_t *dest, uint32_t src, size_t length);


typedef enum fifo_t {
		fifo_msgin, fifo_msgout,
		fifo_conin, fifo_conout,
		NUM_FIFOS
	} fifo_t;

void z80_memfifo_init(const fifo_t f, uint32_t adr);
int z80_memfifo_is_empty(const fifo_t f);
int z80_memfifo_is_full(const fifo_t f);
int z80_memfifo_getc(const fifo_t f);
uint8_t z80_memfifo_getc_wait(const fifo_t f);
void z80_memfifo_putc(fifo_t f, uint8_t val);