Mercurial > hg > Members > kono > os9 > sbc09
diff io.c @ 7:a6db579d8c11
level 2 rom preparing...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 05 Jul 2018 02:00:14 +0900 |
parents | 6159cc57d44e |
children | cb7aa75418b8 |
line wrap: on
line diff
--- a/io.c Thu Jul 05 00:02:54 2018 +0900 +++ b/io.c Thu Jul 05 02:00:14 2018 +0900 @@ -1,4 +1,4 @@ -/* 6809 Simulator V09. +/* 6808 Simulator V09. created 1993,1994 by L.C. Benschop. copyleft (c) 1994-2014 by the sbc09 team, see AUTHORS for more details. @@ -46,25 +46,17 @@ /* * IO Map ( can be overrupped by ROM ) * - * IOPAGE ~ IOPAGE+0xff + * IOPAGE ~ IOPAGE+0x7f + * for OS9 level2 + * IOPAGE 0xff80 means ioport beging 0xff80 but IOPAGE itself starts 0xff00 + * 0xff00-0xff7f, 0xffe0-0xffff can be used as ROM in fixed area * * IOPAGE + 0x00 ACIA control * IOPAGE + 0x01 ACIA data * - * IOPAGE + 0x10 Timer control 0x8f start timer/0x80 stop timer/0x04 update date - * IOPAGE + 0x11- YY/MM/DD/HH/MM/SS - * - * IOPAGE + 0x20 Disk control 0x81 read/0x55 write 0 ... ok / 0xff .. error - * IOPAGE + 0x21 drive no - * IOPAGE + 0x22 LSN2 - * IOPAGE + 0x23 LSN1 - * IOPAGE + 0x24 LSN0 - * IOPAGE + 0x25 ADR2 - * IOPAGE + 0x26 ADR1 - * - * IOPAGE + 0x91 MMU Taskreg 0 system map, 1 user map - * IOPAGE + 0xa0-0xa7 MMU reg system map - * IOPAGE + 0xa8-0xaf MMU reg user map + * IOPAGE + 0x11 MMU Taskreg 0 system map, 1 user map + * IOPAGE + 0x20-0x27 MMU reg system map + * IOPAGE + 0x28-0x2f MMU reg user map * * on reset tr==0 and only IOPAGE is valid * translatation occur only on non-IOPAGE @@ -73,6 +65,18 @@ * tr=0 mmu=IOPAGE+0xa0 * tr=1 mmu=IOPAGE+0xa8 * + * IOPAGE + 0x30 Timer control 0x8f start timer/0x80 stop timer/0x04 update date + * IOPAGE + 0x31- YY/MM/DD/HH/MM/SS + * + * IOPAGE + 0x40 Disk control 0x81 read/0x55 write 0 ... ok / 0xff .. error + * IOPAGE + 0x41 drive no + * IOPAGE + 0x42 LSN2 + * IOPAGE + 0x43 LSN1 + * IOPAGE + 0x44 LSN0 + * IOPAGE + 0x45 ADR2 + * IOPAGE + 0x46 ADR1 + * + * */ #define SECSIZE 256 @@ -178,13 +182,13 @@ int do_input( a) { static int c, f = EOF; - if (a == 0) { + if (a == 0+(IOPAGE&0xff)) { if (f == EOF) f = char_input(); if (f != EOF) c = f; return 2 + (f != EOF); - } else if (a == 1) { /*data port*/ + } else if (a == 1+(IOPAGE&0xff)) { /*data port*/ if (f == EOF) f = char_input(); if (f != EOF) { @@ -198,7 +202,7 @@ void do_output(int a, int c) { int i, sum; - if (a == 1) { /* ACIA data port,ignore address */ + if (a == 1+(IOPAGE&0xff)) { /* ACIA data port,ignore address */ if (!xmstat) { if (logfile && c != 127 && (c >= ' ' || c == '\n')) putc(c, logfile); @@ -244,12 +248,12 @@ xidx = 0; } } - } else if (a >= 0x90) { /* mmu */ + } else if (a >= 0x10+(IOPAGE&0xff)) { /* mmu */ do_mmu(a,c); - } else if (a >= 0x20) { /* disk */ + } else if (a >= 0x30+(IOPAGE&0xff)) { /* timer */ + do_timer(a,c); + } else if (a >= 0x40+(IOPAGE&0xff)) { /* disk */ do_disk(a,c); - } else if (a >= 0x10) { /* disk */ - do_timer(a,c); } } @@ -266,38 +270,38 @@ void do_timer(int a, int c) { struct itimerval timercontrol; - if (a==0x10 && c==0x8f) { + if (a==0x30 && c==0x8f) { timercontrol.it_interval.tv_sec = 0; timercontrol.it_interval.tv_usec = 20000; timercontrol.it_value.tv_sec = 0; timercontrol.it_value.tv_usec = 20000; setitimer(ITIMER_REAL, &timercontrol, NULL); - } else if (a==0x10 && c==0x80) { + } else if (a==0x30 && c==0x80) { timercontrol.it_interval.tv_sec = 0; timercontrol.it_interval.tv_usec = 0; setitimer(ITIMER_REAL, &timercontrol, NULL); - } else if (a==0x10 && c==0x04) { + } else if (a==0x30 && c==0x04) { time_t tm = time(0); struct tm *t = localtime(&tm); - mem[IOPAGE+0x11] = t->tm_year; - mem[IOPAGE+0x12] = t->tm_mon; - mem[IOPAGE+0x13] = t->tm_mday; - mem[IOPAGE+0x14] = t->tm_hour; - mem[IOPAGE+0x15] = t->tm_min; - mem[IOPAGE+0x16] = t->tm_sec; + mem[IOPAGE+0x31] = t->tm_year; + mem[IOPAGE+0x32] = t->tm_mon; + mem[IOPAGE+0x33] = t->tm_mday; + mem[IOPAGE+0x34] = t->tm_hour; + mem[IOPAGE+0x35] = t->tm_min; + mem[IOPAGE+0x36] = t->tm_sec; } else { mem[IOPAGE+a]=c; } } void do_disk(int a, int c) { - if (a!=0x20) { + if (a!=0x40) { mem[IOPAGE+a]=c; return; } - int drv = mem[IOPAGE+0x21]; - int lsn = (mem[IOPAGE+0x22]<<16) + (mem[IOPAGE+0x23]<<8) + mem[IOPAGE+0x24]; - int buf = (mem[IOPAGE+0x25]<<8) + mem[IOPAGE+0x26]; + int drv = mem[IOPAGE+0x41]; + int lsn = (mem[IOPAGE+0x42]<<16) + (mem[IOPAGE+0x43]<<8) + mem[IOPAGE+0x44]; + int buf = (mem[IOPAGE+0x45]<<8) + mem[IOPAGE+0x46]; if (drv > 1 || disk[drv]==0) goto error; if (c==0x81) { if (lseek(fileno(disk[drv]),lsn*SECSIZE,SEEK_SET)==-1) goto error; @@ -306,24 +310,24 @@ if (lseek(fileno(disk[drv]),lsn*SECSIZE,SEEK_SET)==-1) goto error; if (write(fileno(disk[drv]),&mem[buf],SECSIZE)==-1) goto error; } - mem[IOPAGE+0x20] = 0; + mem[IOPAGE+0x40] = 0; return; error : - mem[IOPAGE+0x20] = 0xff; + mem[IOPAGE+0x40] = 0xff; } void do_mmu(int a, int c) { #ifdef USE_MMU - if (a==0x91) { + if (a==0x11) { if (c&0) { mmu = phymem+memsize-0x10000+0xffa0; } else { mmu = phymem+memsize-0x10000+0xffa8; } mem[IOPAGE+a] = c; - } if (0xa0 <= a && a <= 0xaf) { + } if (0x20 <= a && a <= 0x2f) { mem[IOPAGE+a] = c; }