summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo C2015-06-05 08:46:35 +0200
committerLeo C2015-06-05 08:46:35 +0200
commit215ec4b2e6066ba845bfb4d3c95c7b01cd4492ce (patch)
tree1113cf5c52517ec68dbbb61610affcd49b498ef6
parent50939dece93115ee500261129f311a840ca21a81 (diff)
downloadz180-stamp-215ec4b2e6066ba845bfb4d3c95c7b01cd4492ce.zip
change message buffer initialization
-rw-r--r--avr/z180-serv.c47
-rw-r--r--z180/config.inc3
-rw-r--r--z180/init.1804
3 files changed, 26 insertions, 28 deletions
diff --git a/avr/z180-serv.c b/avr/z180-serv.c
index 929cd97..b5d8140 100644
--- a/avr/z180-serv.c
+++ b/avr/z180-serv.c
@@ -581,35 +581,38 @@ int msg_handling(int state)
pending = (Stat & S_MSG_PENDING) != 0;
Stat &= ~S_MSG_PENDING;
}
-/*
- * TODO: if pending but no message chr --> special condition. ie init,...
- */
if (pending) {
- switch (state) {
- case 0: /* need init */
+ uint8_t init_request;
+ z80_bus_cmd(Request);
+ init_request = z80_read(0x43);
+ z80_bus_cmd(Release);
+ if ( init_request != 0) {
/* Get address of fifo_list */
+ uint32_t fifo_addr = 0;
z80_bus_cmd(Request);
uint32_t fifo_list = z80_read(0x40) +
- ((uint16_t) z80_read(0x41) << 8) +
- ((uint32_t) z80_read(0x42) << 16);
- z80_bus_cmd(Release);
+ ((uint16_t) z80_read(0x41) << 8) +
+ ((uint32_t) z80_read(0x42) << 16);
if (fifo_list != 0) {
/* Get address of fifo 0 */
- z80_bus_cmd(Request);
- uint32_t fifo_addr = z80_read(fifo_list) +
- ((uint16_t) z80_read(fifo_list+1) << 8) +
- ((uint32_t) z80_read(fifo_list+2) << 16);
- z80_bus_cmd(Release);
- if (fifo_addr != 0) {
- z80_memfifo_init(fifo_msgin, fifo_addr);
- state = 1;
- }
+ fifo_addr = z80_read(fifo_list) +
+ ((uint16_t) z80_read(fifo_list+1) << 8);
+ /* TODO: log to phys addr translation
+ ((uint32_t) z80_read(fifo_list+2) << 16);
+ */
}
- break;
- case 1: /* awaiting messages */
+ z80_write(0x43, 0);
+ z80_bus_cmd(Release);
+
+ if (fifo_addr != 0) {
+ z80_memfifo_init(fifo_msgin, fifo_addr);
+ state = 1;
+ } else
+ state = 0;
+
+ } else {
check_msg_fifo();
- break;
}
}
@@ -629,9 +632,7 @@ void setup_z180_serv(void)
void restart_z180_serv(void)
{
z80_bus_cmd(Request);
- z80_write(0x40, 0);
- z80_write(0x41, 0);
- z80_write(0x42, 0);
+ z80_memset(0x40, 0, 4);
z80_bus_cmd(Release);
for (int i = 0; i < NUM_FIFOS; i++)
diff --git a/z180/config.inc b/z180/config.inc
index b5a5319..ffab6e6 100644
--- a/z180/config.inc
+++ b/z180/config.inc
@@ -170,7 +170,8 @@ mkbuf macro id,name,size
name&.mask equ ;wrong size error
else
db id
- ds 3
+ db size-1
+ ds 2
name:: ds size
name&.mask equ low (size-1)
if size ne 0
diff --git a/z180/init.180 b/z180/init.180
index d56975e..4c7bd77 100644
--- a/z180/init.180
+++ b/z180/init.180
@@ -233,7 +233,6 @@ syscbr: db 0
buf.init:
ld (ix+o.in_idx),0
ld (ix+o.out_idx),0
- ld (ix+o.mask),a
ld a,(ix+o.id)
cp 4
@@ -247,10 +246,8 @@ buf.init:
ld d,0
add hl,de
add hl,de
- add hl,de
push ix
pop de
-; TODO: address translation
ld (hl),e
inc hl
ld (hl),d
@@ -270,7 +267,6 @@ bufi_ex:
fifo_list:
rept 4
dw 0
- db 0
endm
;----------------------------------------------------------------------