branches/alto2/src/emu/cpu/alto2/alto2.c
| r26157 | r26158 | |
| 17 | 17 | //************************************************************************** |
| 18 | 18 | |
| 19 | 19 | const device_type ALTO2 = &device_creator<alto2_cpu_device>; |
| 20 | | |
| 21 | | ADDRESS_MAP_START( alto2_ucode_map, AS_0, 32, alto2_cpu_device ) |
| 22 | | AM_RANGE(0, ALTO2_UCODE_RAM_BASE-1) AM_ROM |
| 23 | | AM_RANGE(ALTO2_UCODE_RAM_BASE, ALTO2_UCODE_SIZE-1) AM_RAM |
| 24 | | ADDRESS_MAP_END |
| 25 | | |
| 26 | 20 | //************************************************************************** |
| 27 | 21 | // LIVE DEVICE |
| 28 | 22 | //************************************************************************** |
| 29 | 23 | |
| 24 | DEVICE_ADDRESS_MAP_START( ucode_map, 32, alto2_cpu_device ) |
| 25 | AM_RANGE(0, ALTO2_UCODE_RAM_BASE - 1) AM_READ ( crom_r ) |
| 26 | AM_RANGE(ALTO2_UCODE_RAM_BASE, ALTO2_UCODE_SIZE - 1) AM_READWRITE( cram_r, cram_w ) |
| 27 | ADDRESS_MAP_END |
| 28 | |
| 29 | DEVICE_ADDRESS_MAP_START( const_map, 16, alto2_cpu_device ) |
| 30 | AM_RANGE(0, ALTO2_CONST_SIZE - 1) AM_READ ( const_r ) |
| 31 | ADDRESS_MAP_END |
| 32 | |
| 33 | DEVICE_ADDRESS_MAP_START( iomem_map, 16, alto2_cpu_device ) |
| 34 | AM_RANGE(0, ALTO2_IO_PAGE_BASE - 1) AM_READWRITE( ioram_r, ioram_w ) |
| 35 | AM_RANGE(ALTO2_IO_PAGE_BASE, 0177777) AM_READWRITE( mmio_r, mmio_w ) |
| 36 | ADDRESS_MAP_END |
| 37 | |
| 30 | 38 | //------------------------------------------------- |
| 31 | 39 | // alto2_cpu_device - constructor |
| 32 | 40 | //------------------------------------------------- |
| r26157 | r26158 | |
| 38 | 46 | m_log_level(9), |
| 39 | 47 | m_log_newline(true), |
| 40 | 48 | #endif |
| 41 | | m_ucode_config("alto2", ENDIANNESS_BIG, 32, 14, -2, ADDRESS_MAP_NAME(alto2_ucode_map)), |
| 42 | | m_ucode_map(*this, ":maincpu:ucode"), |
| 49 | m_ucode_config("ucode", ENDIANNESS_BIG, 32, 12, -2 ), |
| 50 | m_const_config("const", ENDIANNESS_BIG, 16, 8, -1 ), |
| 51 | m_iomem_config("iomem", ENDIANNESS_BIG, 16, 17, -1 ), |
| 43 | 52 | m_ucode(0), |
| 44 | | m_ucode_proms(0), |
| 45 | | m_const_proms(0), |
| 53 | m_const(0), |
| 54 | m_iomem(0), |
| 55 | // m_ucode_map(*this, "^maincpu"), |
| 56 | // m_const_map(*this, "^const"), |
| 57 | // m_iomem_map(*this, "^iomem"), |
| 58 | m_ucode_crom(0), |
| 59 | m_const_data(0), |
| 46 | 60 | m_icount(0), |
| 47 | 61 | m_task_mpc(), |
| 48 | 62 | m_task_next2(), |
| r26157 | r26158 | |
| 117 | 131 | } |
| 118 | 132 | |
| 119 | 133 | //------------------------------------------------- |
| 120 | | // driver interface to RAM |
| 121 | | //------------------------------------------------- |
| 122 | | |
| 123 | | UINT16 alto2_cpu_device::read_ram(offs_t offset) |
| 124 | | { |
| 125 | | return debug_read_mem(offset); |
| 126 | | } |
| 127 | | |
| 128 | | void alto2_cpu_device::write_ram(offs_t offset, UINT16 data) |
| 129 | | { |
| 130 | | debug_write_mem(offset, data); |
| 131 | | } |
| 132 | | |
| 133 | | //------------------------------------------------- |
| 134 | 134 | // driver interface to set diablo_hd_device |
| 135 | 135 | //------------------------------------------------- |
| 136 | 136 | |
| r26157 | r26158 | |
| 144 | 144 | //------------------------------------------------- |
| 145 | 145 | |
| 146 | 146 | ROM_START( alto2_cpu ) |
| 147 | | // decoded micro code region |
| 148 | | ROM_REGION32_BE( sizeof(UINT32)*ALTO2_UCODE_SIZE, "ucode", 0 ) |
| 149 | | ROM_FILL(0, sizeof(UINT32)*ALTO2_UCODE_SIZE, ALTO2_UCODE_INVERTED) |
| 150 | | |
| 151 | 147 | ROM_REGION( 16 * 02000, "ucode_proms", 0 ) |
| 152 | 148 | ROM_LOAD( "55x.3", 0*02000, 0x400, CRC(de870d75) SHA1(2b98cc769d8302cb39948711424d987d94e4159b) ) //!< 00000-01777 RSEL(0)',RSEL(1)',RSEL(2)',RSEL(3)' |
| 153 | 149 | ROM_LOAD( "64x.3", 1*02000, 0x400, CRC(51b444c0) SHA1(8756e51f7f3253a55d75886465beb7ee1be6e1c4) ) //!< 00000-01777 RSEL(4)',ALUF(0)',ALUF(1)',ALUF(2)' |
| r26157 | r26158 | |
| 249 | 245 | { |
| 250 | 246 | if (AS_0 == spacenum) |
| 251 | 247 | return &m_ucode_config; |
| 248 | if (AS_1 == spacenum) |
| 249 | return &m_const_config; |
| 250 | if (AS_2 == spacenum) |
| 251 | return &m_iomem_config; |
| 252 | 252 | return NULL; |
| 253 | 253 | } |
| 254 | 254 | |
| r26157 | r26158 | |
| 855 | 855 | void alto2_cpu_device::device_start() |
| 856 | 856 | { |
| 857 | 857 | m_ucode = &space(AS_0); |
| 858 | | m_ucode_proms = prom_load(pl_ucode, memregion("ucode_proms")->base(), ALTO2_UCODE_ROM_PAGES, 8); |
| 859 | | UINT32* p_ucode = reinterpret_cast<UINT32 *>(memregion(":maincpu:ucode")->base()); |
| 860 | | for (offs_t offs = 0; offs < ALTO2_UCODE_RAM_BASE; offs++) { |
| 861 | | UINT32 data = (m_ucode_proms[4*offs+0] << 0) | (m_ucode_proms[4*offs+1] << 8) | |
| 862 | | (m_ucode_proms[4*offs+2] << 16) | (m_ucode_proms[4*offs+3] << 24); |
| 863 | | #if DEBUG_UCODE_CONST_DATA |
| 864 | | if (0 == offs % 8) |
| 865 | | printf("%04x:", offs); |
| 866 | | printf(" %08x", data); |
| 867 | | if (7 == offs % 8) |
| 868 | | printf("\n"); |
| 869 | | #endif |
| 870 | | p_ucode[offs] = data; |
| 871 | | } |
| 872 | | for (offs_t offs = ALTO2_UCODE_RAM_BASE; offs < ALTO2_UCODE_SIZE; offs++) { |
| 873 | | p_ucode[offs] = ALTO2_UCODE_INVERTED; |
| 874 | | } |
| 858 | m_const = &space(AS_1); |
| 859 | m_iomem = &space(AS_2); |
| 875 | 860 | |
| 876 | | m_const_proms = prom_load(pl_const, memregion("const_proms")->base(), 1, 4); |
| 877 | | m_const = reinterpret_cast<UINT16 *>(global_alloc_array(UINT16, ALTO2_CONST_SIZE)); |
| 878 | | for (offs_t offs = 0; offs < ALTO2_CONST_SIZE; offs++) { |
| 879 | | UINT16 data = (m_const_proms[2*offs+0] << 0) | (m_const_proms[2*offs+1] << 8); |
| 880 | | #if DEBUG_UCODE_CONST_DATA |
| 881 | | if (0 == offs % 8) |
| 882 | | printf("%04x:", offs); |
| 883 | | printf(" %04x", data); |
| 884 | | if (7 == offs % 8) |
| 885 | | printf("\n"); |
| 886 | | #endif |
| 887 | | m_const[offs] = data; |
| 888 | | } |
| 861 | // decode micro code PROMs to CROM |
| 862 | m_ucode_crom = prom_load(pl_ucode, memregion("ucode_proms")->base(), ALTO2_UCODE_ROM_PAGES, 8); |
| 889 | 863 | |
| 864 | // allocate micro code CRAM |
| 865 | m_ucode_cram = global_alloc_array(UINT8, sizeof(UINT32) * ALTO2_UCODE_RAM_PAGES * ALTO2_UCODE_PAGE_SIZE); |
| 866 | // fill with inverted bits value |
| 867 | for (offs_t offset = 0; offset < ALTO2_UCODE_RAM_PAGES * ALTO2_UCODE_PAGE_SIZE; offset++) |
| 868 | *reinterpret_cast<UINT32 *>(m_ucode_cram + offset * 4) = ALTO2_UCODE_INVERTED; |
| 869 | |
| 870 | // decode constant PROMs to const data |
| 871 | m_const_data = prom_load(pl_const, memregion("const_proms")->base(), 1, 4); |
| 872 | |
| 890 | 873 | m_disp_a38 = prom_load(&pl_displ_a38, memregion("displ_a38")->base()); |
| 891 | 874 | m_disp_a63 = prom_load(&pl_displ_a63, memregion("displ_a63")->base()); |
| 892 | 875 | m_disp_a66 = prom_load(&pl_displ_a66, memregion("displ_a66")->base()); |
| r26157 | r26158 | |
| 1111 | 1094 | hard_reset(); |
| 1112 | 1095 | } |
| 1113 | 1096 | |
| 1097 | //! read microcode CROM |
| 1098 | READ32_MEMBER ( alto2_cpu_device::crom_r ) |
| 1099 | { |
| 1100 | return *reinterpret_cast<UINT32 *>(m_ucode_crom + offset * 4); |
| 1101 | } |
| 1102 | |
| 1103 | //! read microcode CRAM |
| 1104 | READ32_MEMBER ( alto2_cpu_device::cram_r ) |
| 1105 | { |
| 1106 | return *reinterpret_cast<UINT32 *>(m_ucode_cram + offset * 4); |
| 1107 | } |
| 1108 | |
| 1109 | //! write microcode CRAM |
| 1110 | WRITE32_MEMBER( alto2_cpu_device::cram_w ) |
| 1111 | { |
| 1112 | *reinterpret_cast<UINT32 *>(m_ucode_cram + offset * 4) = data; |
| 1113 | } |
| 1114 | |
| 1115 | //! read constants PROM |
| 1116 | READ16_MEMBER ( alto2_cpu_device::const_r ) |
| 1117 | { |
| 1118 | return *reinterpret_cast<UINT16 *>(m_const_data + offset * 2); |
| 1119 | } |
| 1120 | |
| 1121 | #define PUT_EVEN(dword,word) A2_PUT32(dword,32, 0,15,word) |
| 1122 | #define GET_EVEN(dword) A2_GET32(dword,32, 0,15) |
| 1123 | #define PUT_ODD(dword,word) A2_PUT32(dword,32,16,31,word) |
| 1124 | #define GET_ODD(dword) A2_GET32(dword,32,16,31) |
| 1125 | |
| 1126 | //! read i/o space RAM |
| 1127 | READ16_MEMBER ( alto2_cpu_device::ioram_r ) |
| 1128 | { |
| 1129 | offs_t dword_addr = offset / 2; |
| 1130 | return offset & 1 ? GET_ODD(m_mem.ram[dword_addr]) : GET_EVEN(m_mem.ram[dword_addr]); |
| 1131 | } |
| 1132 | |
| 1133 | //! write i/o space RAM |
| 1134 | WRITE16_MEMBER( alto2_cpu_device::ioram_w ) |
| 1135 | { |
| 1136 | offs_t dword_addr = offset / 2; |
| 1137 | if (offset & 1) |
| 1138 | PUT_ODD(m_mem.ram[dword_addr], data); |
| 1139 | else |
| 1140 | PUT_EVEN(m_mem.ram[dword_addr], data); |
| 1141 | } |
| 1142 | |
| 1143 | //! read memory mapped i/o |
| 1144 | READ16_MEMBER ( alto2_cpu_device::mmio_r ) |
| 1145 | { |
| 1146 | if (mmio_read_fn[offset]) |
| 1147 | return ((*this).*mmio_read_fn[offset])(offset); |
| 1148 | return 0177777; |
| 1149 | } |
| 1150 | |
| 1151 | //! write memory mapped i/o |
| 1152 | WRITE16_MEMBER( alto2_cpu_device::mmio_w ) |
| 1153 | { |
| 1154 | if (mmio_write_fn[offset]) |
| 1155 | return ((*this).*mmio_write_fn[offset])(offset, data); |
| 1156 | } |
| 1157 | |
| 1114 | 1158 | //------------------------------------------------- |
| 1115 | 1159 | // device_reset - device-specific reset |
| 1116 | 1160 | //------------------------------------------------- |
| r26157 | r26158 | |
| 2478 | 2522 | */ |
| 2479 | 2523 | if (!do_bs || bs >= 4) { |
| 2480 | 2524 | int addr = 8 * m_rsel + bs; |
| 2481 | | UINT16 data = m_const[addr]; |
| 2525 | UINT16 data = m_const->read_dword(m_const->address_to_byte(addr)); |
| 2482 | 2526 | LOG((LOG_CPU,2," %#o; BUS &= CONST[%03o]\n", data, addr)); |
| 2483 | 2527 | m_bus &= data; |
| 2484 | 2528 | } |
| r26157 | r26158 | |
| 2968 | 3012 | |
| 2969 | 3013 | init_disk(); |
| 2970 | 3014 | init_disp(); |
| 3015 | init_memory(); |
| 2971 | 3016 | init_hardware(); |
| 2972 | 3017 | init_kbd(); |
| 2973 | 3018 | |
branches/alto2/src/emu/cpu/alto2/alto2.h
| r26157 | r26158 | |
| 208 | 208 | // construction/destruction |
| 209 | 209 | alto2_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 210 | 210 | |
| 211 | | //! driver interface to RAM |
| 212 | | UINT16 read_ram(offs_t offset); |
| 213 | | void write_ram(offs_t offset, UINT16 data); |
| 214 | | |
| 215 | 211 | //! driver interface to set diablo_hd_device |
| 216 | 212 | void set_diablo(int unit, diablo_hd_device* ptr); |
| 217 | 213 | |
| 218 | 214 | void next_sector(int unit); |
| 219 | 215 | |
| 216 | DECLARE_ADDRESS_MAP( ucode_map, 32 ); |
| 217 | DECLARE_ADDRESS_MAP( const_map, 16 ); |
| 218 | DECLARE_ADDRESS_MAP( iomem_map, 16 ); |
| 219 | |
| 220 | 220 | protected: |
| 221 | 221 | //! device-level override for start |
| 222 | 222 | virtual void device_start(); |
| r26157 | r26158 | |
| 286 | 286 | void fatal(int level, const char *format, ...); |
| 287 | 287 | |
| 288 | 288 | address_space_config m_ucode_config; |
| 289 | address_space_config m_const_config; |
| 290 | address_space_config m_iomem_config; |
| 289 | 291 | |
| 290 | | required_memory_region m_ucode_map; |
| 291 | | |
| 292 | 292 | address_space *m_ucode; |
| 293 | | UINT16* m_const; |
| 293 | address_space *m_const; |
| 294 | address_space *m_iomem; |
| 294 | 295 | |
| 295 | | UINT8* m_ucode_proms; |
| 296 | | UINT8* m_const_proms; |
| 296 | UINT8* m_ucode_crom; |
| 297 | UINT8* m_ucode_cram; |
| 298 | UINT8* m_const_data; |
| 297 | 299 | |
| 300 | //! read microcode CROM |
| 301 | DECLARE_READ32_MEMBER ( crom_r ); |
| 302 | |
| 303 | //! read microcode CRAM |
| 304 | DECLARE_READ32_MEMBER ( cram_r ); |
| 305 | |
| 306 | //! write microcode CRAM |
| 307 | DECLARE_WRITE32_MEMBER( cram_w ); |
| 308 | |
| 309 | //! read constants PROM |
| 310 | DECLARE_READ16_MEMBER ( const_r ); |
| 311 | |
| 312 | //! read i/o space RAM |
| 313 | DECLARE_READ16_MEMBER ( ioram_r ); |
| 314 | |
| 315 | //!< write i/o space RAM |
| 316 | DECLARE_WRITE16_MEMBER( ioram_w ); |
| 317 | |
| 318 | //!< read memory mapped i/o |
| 319 | DECLARE_READ16_MEMBER ( mmio_r ); |
| 320 | |
| 321 | //!< write memory mapped i/o |
| 322 | DECLARE_WRITE16_MEMBER( mmio_w ); |
| 323 | |
| 298 | 324 | int m_icount; |
| 299 | 325 | |
| 300 | 326 | static const UINT8 m_ether_id = 0121; |
| r26157 | r26158 | |
| 1723 | 1749 | }; |
| 1724 | 1750 | |
| 1725 | 1751 | struct { |
| 1726 | | UINT32 ram[ALTO2_RAM_SIZE/4]; //!< main memory organized as double-words |
| 1727 | | UINT8 hpb[ALTO2_RAM_SIZE/4]; //!< Hamming code (6) and Parity bits (1) per double word |
| 1752 | UINT32* ram; //!< main memory organized as double-words |
| 1753 | UINT8* hpb; //!< Hamming Code bits (6) and Parity bits (1) per double word |
| 1728 | 1754 | UINT32 mar; //!< memory address register |
| 1729 | 1755 | UINT32 rmdd; //!< read memory data double-word |
| 1730 | 1756 | UINT32 wmdd; //!< write memory data double-word |
branches/alto2/src/mess/drivers/alto2.c
| r26157 | r26158 | |
| 8 | 8 | |
| 9 | 9 | #include "includes/alto2.h" |
| 10 | 10 | |
| 11 | | // FIXME: Is this required? The driver does not have/need access to RAM |
| 12 | | READ16_MEMBER( alto2_state::alto2_ram_r ) |
| 13 | | { |
| 14 | | return downcast<alto2_cpu_device *>(m_maincpu.target())->read_ram(offset); |
| 15 | | } |
| 16 | | |
| 17 | | // FIXME: Is this required? The driver does not have/need access to RAM |
| 18 | | WRITE16_MEMBER( alto2_state::alto2_ram_w ) |
| 19 | | { |
| 20 | | downcast<alto2_cpu_device *>(m_maincpu.target())->write_ram(offset, data); |
| 21 | | } |
| 22 | | |
| 23 | | /* Memory Maps */ |
| 24 | | |
| 25 | | ADDRESS_MAP_EXTERN( alto2_ucode_map, 32 ); |
| 26 | | |
| 27 | | /* main memory and memory mapped i/o in range ALTO2_IO_PAGE_BASE ... ALTO2_IO_PAGE_BASE + ALTO2_IO_PAGE_SIZE - 1 */ |
| 28 | | ADDRESS_MAP_START( alto2_ram_map, AS_2, 16, alto2_state ) |
| 29 | | ADDRESS_MAP_UNMAP_HIGH |
| 30 | | AM_RANGE(0, ALTO2_RAM_SIZE-1) AM_READWRITE(alto2_ram_r, alto2_ram_w) |
| 31 | | ADDRESS_MAP_END |
| 32 | | |
| 33 | | |
| 34 | 11 | /* Video */ |
| 35 | 12 | |
| 36 | 13 | UINT32 alto2_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| r26157 | r26158 | |
| 232 | 209 | |
| 233 | 210 | /* ROM */ |
| 234 | 211 | ROM_START( alto2 ) |
| 235 | | // decoded micro code region - driver side view on the memory |
| 236 | | ROM_REGION32_BE( sizeof(UINT32)*ALTO2_UCODE_SIZE, "maincpu", 0 ) |
| 237 | | ROM_FILL(0, sizeof(UINT32)*ALTO2_UCODE_SIZE, ALTO2_UCODE_INVERTED) |
| 212 | // dummy region for the maincpu |
| 213 | ROM_REGION( 1, "maincpu", 0 ) |
| 214 | ROM_FILL(0, 1, ALTO2_UCODE_INVERTED) |
| 238 | 215 | ROM_END |
| 239 | 216 | |
| 217 | //************************************************************************** |
| 218 | // ADDRESS MAPS |
| 219 | //************************************************************************** |
| 220 | |
| 221 | ADDRESS_MAP_START( alto2_ucode_map, AS_0, 32, alto2_state ) |
| 222 | AM_RANGE(0, ALTO2_UCODE_SIZE-1) AM_DEVICE32( "maincpu", alto2_cpu_device, ucode_map, 0xffffffffUL ) |
| 223 | ADDRESS_MAP_END |
| 224 | |
| 225 | ADDRESS_MAP_START( alto2_const_map, AS_1, 16, alto2_state ) |
| 226 | AM_RANGE(0, ALTO2_CONST_SIZE-1) AM_DEVICE16( "maincpu", alto2_cpu_device, const_map, 0xffffU ) |
| 227 | ADDRESS_MAP_END |
| 228 | |
| 229 | ADDRESS_MAP_START( alto2_iomem_map, AS_2, 16, alto2_state ) |
| 230 | AM_RANGE(0, ALTO2_RAM_SIZE-1) AM_DEVICE16( "maincpu", alto2_cpu_device, iomem_map, 0xffffU ) |
| 231 | ADDRESS_MAP_END |
| 232 | |
| 233 | |
| 240 | 234 | /* Palette Initialization */ |
| 241 | 235 | |
| 242 | 236 | void alto2_state::palette_init() |
| r26157 | r26158 | |
| 249 | 243 | /* basic machine hardware */ |
| 250 | 244 | MCFG_CPU_ADD("maincpu", ALTO2, XTAL_20_16MHz) |
| 251 | 245 | MCFG_CPU_PROGRAM_MAP(alto2_ucode_map) |
| 252 | | MCFG_CPU_IO_MAP(alto2_ram_map) |
| 246 | MCFG_CPU_DATA_MAP(alto2_const_map) |
| 247 | MCFG_CPU_IO_MAP(alto2_iomem_map) |
| 253 | 248 | |
| 254 | 249 | /* video hardware */ |
| 255 | 250 | MCFG_SCREEN_ADD("screen", RASTER) |
| r26157 | r26158 | |
| 266 | 261 | |
| 267 | 262 | DRIVER_INIT_MEMBER( alto2_state, alto2 ) |
| 268 | 263 | { |
| 269 | | // make a copy for the front end, i.e. the driver view on the micro code |
| 270 | | memcpy(memregion("maincpu"), memregion("maincpu:ucode"), sizeof(UINT32)*ALTO2_UCODE_SIZE); |
| 271 | | |
| 272 | 264 | // make the diablo drives known to the CPU core |
| 273 | 265 | alto2_cpu_device* cpu = downcast<alto2_cpu_device *>(m_maincpu.target()); |
| 274 | 266 | cpu->set_diablo(0, downcast<diablo_hd_device *>(machine().device(DIABLO_HD_0))); |
| 275 | 267 | cpu->set_diablo(1, downcast<diablo_hd_device *>(machine().device(DIABLO_HD_1))); |
| 276 | 268 | |
| 277 | 269 | #define UNICODE_TESTING 0 |
| 278 | | #ifdef UNICODE_TESTING |
| 270 | #if UNICODE_TESTING |
| 279 | 271 | const char* filename = "docs/UnicodeData.txt"; |
| 280 | 272 | int res = unicode_data_load(filename); |
| 281 | 273 | logerror("%s: unicode_data_load(\"%s\") result %d\n", filename, __FUNCTION__, res); |