|
|
| version 1.4, 2004/02/20 16:09:04 | version 1.12, 2012/01/08 18:25:34 |
|---|---|
| Line 1 | Line 1 |
| /* $Id$ */ | |
| /* | /* |
| * Copyright (c) 2003 NONAKA Kimihiro | * Copyright (c) 2003 NONAKA Kimihiro |
| * All rights reserved. | * All rights reserved. |
| Line 12 | Line 10 |
| * 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the |
| * documentation and/or other materials provided with the distribution. | * documentation and/or other materials provided with the distribution. |
| * 3. The name of the author may not be used to endorse or promote products | |
| * derived from this software without specific prior written permission. | |
| * | * |
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| Line 28 | Line 24 |
| */ | */ |
| #include "compiler.h" | #include "compiler.h" |
| #include "cpu.h" | #include "cpu.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "memory.h" | |
| static void CPUCALL check_io(UINT port, UINT len); | |
| static void | static void CPUCALL |
| check_io(UINT port, UINT len) | check_io(UINT port, UINT len) |
| { | { |
| UINT off; | UINT off; |
| UINT8 bit; | UINT16 map; |
| UINT8 map; | UINT16 mask; |
| if (CPU_STAT_IOLIMIT == 0) { | if (CPU_STAT_IOLIMIT == 0) { |
| VERBOSE(("check_io: CPU_STAT_IOLIMIT == 0 (port = %04x, len = %d)", port, len)); | VERBOSE(("check_io: CPU_STAT_IOLIMIT == 0 (port = %04x, len = %d)", port, len)); |
| EXCEPTION(GP_EXCEPTION, 0); | EXCEPTION(GP_EXCEPTION, 0); |
| } | } |
| if ((port + len) / 8 >= CPU_STAT_IOLIMIT) { | |
| VERBOSE(("check_io: out of range: CPU_STAT_IOLIMIT(%08x) (port = %04x, len = %d)", CPU_STAT_IOLIMIT, port, len)); | |
| EXCEPTION(GP_EXCEPTION, 0); | |
| } | |
| off = port / 8; | off = port / 8; |
| bit = 1 << (port % 8); | mask = ((1 << len) - 1) << (port % 8); |
| for (; len > 0; ++off, bit = 0x01) { | map = cpu_kmemoryread_w(CPU_STAT_IOADDR + off); |
| if (off >= CPU_STAT_IOLIMIT) { | if (map & mask) { |
| VERBOSE(("check_io: off(%08x) >= CPU_STAT_IOLIMIT(%08x) (port = %04x, len = %d)", off, CPU_STAT_IOLIMIT, port, len)); | VERBOSE(("check_io: (bitmap(0x%04x) & bit(0x%04x)) != 0 (CPU_STAT_IOADDR=0x%08x, offset=0x%04x, port = 0x%04x, len = %d)", map, mask, CPU_STAT_IOADDR, off, port, len)); |
| EXCEPTION(GP_EXCEPTION, 0); | EXCEPTION(GP_EXCEPTION, 0); |
| } | |
| map = cpu_kmemoryread(CPU_STAT_IOADDR + off); | |
| for (; (len > 0) && (bit != 0x00); bit <<= 1, --len) { | |
| if (map & bit) { | |
| VERBOSE(("check_io: (bitmap(0x%02x) & bit(0x%02x)) != 0 (port = %04x, len = %d)", map, bit, port, len)); | |
| EXCEPTION(GP_EXCEPTION, 0); | |
| } | |
| } | |
| } | } |
| } | } |
| UINT8 | UINT8 IOINPCALL |
| cpu_in(UINT port) | cpu_in(UINT port) |
| { | { |
| Line 73 cpu_in(UINT port) | Line 68 cpu_in(UINT port) |
| return iocore_inp8(port); | return iocore_inp8(port); |
| } | } |
| UINT16 | UINT16 IOINPCALL |
| cpu_in_w(UINT port) | cpu_in_w(UINT port) |
| { | { |
| Line 83 cpu_in_w(UINT port) | Line 78 cpu_in_w(UINT port) |
| return iocore_inp16(port); | return iocore_inp16(port); |
| } | } |
| UINT32 | UINT32 IOINPCALL |
| cpu_in_d(UINT port) | cpu_in_d(UINT port) |
| { | { |
| Line 93 cpu_in_d(UINT port) | Line 88 cpu_in_d(UINT port) |
| return iocore_inp32(port); | return iocore_inp32(port); |
| } | } |
| void | void IOOUTCALL |
| cpu_out(UINT port, UINT8 data) | cpu_out(UINT port, UINT8 data) |
| { | { |
| Line 103 cpu_out(UINT port, UINT8 data) | Line 98 cpu_out(UINT port, UINT8 data) |
| iocore_out8(port, data); | iocore_out8(port, data); |
| } | } |
| void | void IOOUTCALL |
| cpu_out_w(UINT port, UINT16 data) | cpu_out_w(UINT port, UINT16 data) |
| { | { |
| Line 113 cpu_out_w(UINT port, UINT16 data) | Line 108 cpu_out_w(UINT port, UINT16 data) |
| iocore_out16(port, data); | iocore_out16(port, data); |
| } | } |
| void | void IOOUTCALL |
| cpu_out_d(UINT port, UINT32 data) | cpu_out_d(UINT port, UINT32 data) |
| { | { |