Previous 199869 Revisions Next

r26158 Thursday 14th November, 2013 at 15:39:29 UTC by Jürgen Buchmüller
Slowly getting somewhere with AM_DEVICE16/32 entries in the driver address maps.
[/branches/alto2/src/emu/cpu/alto2]a2mem.c alto2.c alto2.h
[/branches/alto2/src/mess/drivers]alto2.c
[/branches/alto2/src/mess/includes]alto2.h

branches/alto2/src/emu/cpu/alto2/alto2.c
r26157r26158
1717//**************************************************************************
1818
1919const device_type ALTO2 = &device_creator<alto2_cpu_device>;
20
21ADDRESS_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
24ADDRESS_MAP_END
25
2620//**************************************************************************
2721//  LIVE DEVICE
2822//**************************************************************************
2923
24DEVICE_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 )
27ADDRESS_MAP_END
28
29DEVICE_ADDRESS_MAP_START( const_map, 16, alto2_cpu_device )
30   AM_RANGE(0,                    ALTO2_CONST_SIZE - 1)      AM_READ     ( const_r )
31ADDRESS_MAP_END
32
33DEVICE_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 )
36ADDRESS_MAP_END
37
3038//-------------------------------------------------
3139//  alto2_cpu_device - constructor
3240//-------------------------------------------------
r26157r26158
3846   m_log_level(9),
3947   m_log_newline(true),
4048#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 ),
4352   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),
4660   m_icount(0),
4761   m_task_mpc(),
4862   m_task_next2(),
r26157r26158
117131}
118132
119133//-------------------------------------------------
120// driver interface to RAM
121//-------------------------------------------------
122
123UINT16 alto2_cpu_device::read_ram(offs_t offset)
124{
125   return debug_read_mem(offset);
126}
127
128void alto2_cpu_device::write_ram(offs_t offset, UINT16 data)
129{
130   debug_write_mem(offset, data);
131}
132
133//-------------------------------------------------
134134// driver interface to set diablo_hd_device
135135//-------------------------------------------------
136136
r26157r26158
144144//-------------------------------------------------
145145
146146ROM_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
151147   ROM_REGION( 16 * 02000, "ucode_proms", 0 )
152148   ROM_LOAD( "55x.3",     0*02000, 0x400, CRC(de870d75) SHA1(2b98cc769d8302cb39948711424d987d94e4159b) )   //!< 00000-01777 RSEL(0)',RSEL(1)',RSEL(2)',RSEL(3)'
153149   ROM_LOAD( "64x.3",     1*02000, 0x400, CRC(51b444c0) SHA1(8756e51f7f3253a55d75886465beb7ee1be6e1c4) )   //!< 00000-01777 RSEL(4)',ALUF(0)',ALUF(1)',ALUF(2)'
r26157r26158
249245{
250246   if (AS_0 == spacenum)
251247      return &m_ucode_config;
248   if (AS_1 == spacenum)
249      return &m_const_config;
250   if (AS_2 == spacenum)
251      return &m_iomem_config;
252252   return NULL;
253253}
254254
r26157r26158
855855void alto2_cpu_device::device_start()
856856{
857857   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);
875860
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);
889863
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
890873   m_disp_a38 = prom_load(&pl_displ_a38, memregion("displ_a38")->base());
891874   m_disp_a63 = prom_load(&pl_displ_a63, memregion("displ_a63")->base());
892875   m_disp_a66 = prom_load(&pl_displ_a66, memregion("displ_a66")->base());
r26157r26158
11111094   hard_reset();
11121095}
11131096
1097//! read microcode CROM
1098READ32_MEMBER ( alto2_cpu_device::crom_r )
1099{
1100   return *reinterpret_cast<UINT32 *>(m_ucode_crom + offset * 4);
1101}
1102
1103//! read microcode CRAM
1104READ32_MEMBER ( alto2_cpu_device::cram_r )
1105{
1106   return *reinterpret_cast<UINT32 *>(m_ucode_cram + offset * 4);
1107}
1108
1109//! write microcode CRAM
1110WRITE32_MEMBER( alto2_cpu_device::cram_w )
1111{
1112   *reinterpret_cast<UINT32 *>(m_ucode_cram + offset * 4) = data;
1113}
1114
1115//! read constants PROM
1116READ16_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
1127READ16_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
1134WRITE16_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
1144READ16_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
1152WRITE16_MEMBER( alto2_cpu_device::mmio_w )
1153{
1154   if (mmio_write_fn[offset])
1155      return ((*this).*mmio_write_fn[offset])(offset, data);
1156}
1157
11141158//-------------------------------------------------
11151159//  device_reset - device-specific reset
11161160//-------------------------------------------------
r26157r26158
24782522       */
24792523      if (!do_bs || bs >= 4) {
24802524         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));
24822526         LOG((LOG_CPU,2,"   %#o; BUS &= CONST[%03o]\n", data, addr));
24832527         m_bus &= data;
24842528      }
r26157r26158
29683012
29693013   init_disk();
29703014   init_disp();
3015   init_memory();
29713016   init_hardware();
29723017   init_kbd();
29733018
branches/alto2/src/emu/cpu/alto2/alto2.h
r26157r26158
208208   // construction/destruction
209209   alto2_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
210210
211   //! driver interface to RAM
212   UINT16 read_ram(offs_t offset);
213   void write_ram(offs_t offset, UINT16 data);
214
215211   //! driver interface to set diablo_hd_device
216212   void set_diablo(int unit, diablo_hd_device* ptr);
217213
218214   void next_sector(int unit);
219215
216   DECLARE_ADDRESS_MAP( ucode_map, 32 );
217   DECLARE_ADDRESS_MAP( const_map, 16 );
218   DECLARE_ADDRESS_MAP( iomem_map, 16 );
219
220220protected:
221221   //! device-level override for start
222222   virtual void device_start();
r26157r26158
286286   void fatal(int level, const char *format, ...);
287287
288288   address_space_config m_ucode_config;
289   address_space_config m_const_config;
290   address_space_config m_iomem_config;
289291
290   required_memory_region m_ucode_map;
291
292292   address_space *m_ucode;
293   UINT16* m_const;
293   address_space *m_const;
294   address_space *m_iomem;
294295
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;
297299
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
298324   int m_icount;
299325
300326   static const UINT8 m_ether_id = 0121;
r26157r26158
17231749   };
17241750
17251751   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
17281754      UINT32 mar;                     //!< memory address register
17291755      UINT32 rmdd;                  //!< read memory data double-word
17301756      UINT32 wmdd;                  //!< write memory data double-word
branches/alto2/src/emu/cpu/alto2/a2mem.c
r26157r26158
837837      mmio_write_fn[addr] = &alto2_cpu_device::bad_mmio_write_fn;
838838   }
839839
840   // allocate 128KB of main memory
841   m_mem.ram = global_alloc_array(UINT32, ALTO2_RAM_SIZE);
842   m_mem.hpb = global_alloc_array(UINT8,  ALTO2_RAM_SIZE);
843
840844   /**
841845    * <PRE>
842846    * TODO: use madr.a65 and madr.a64 to determine the actual I/O address ranges
branches/alto2/src/mess/drivers/alto2.c
r26157r26158
88
99#include "includes/alto2.h"
1010
11// FIXME: Is this required? The driver does not have/need access to RAM
12READ16_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
18WRITE16_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
25ADDRESS_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 */
28ADDRESS_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)
31ADDRESS_MAP_END
32
33
3411/* Video */
3512
3613UINT32 alto2_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r26157r26158
232209
233210/* ROM */
234211ROM_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)
238215ROM_END
239216
217//**************************************************************************
218//  ADDRESS MAPS
219//**************************************************************************
220
221ADDRESS_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 )
223ADDRESS_MAP_END
224
225ADDRESS_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 )
227ADDRESS_MAP_END
228
229ADDRESS_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 )
231ADDRESS_MAP_END
232
233
240234/* Palette Initialization */
241235
242236void alto2_state::palette_init()
r26157r26158
249243   /* basic machine hardware */
250244   MCFG_CPU_ADD("maincpu", ALTO2, XTAL_20_16MHz)
251245   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)
253248
254249   /* video hardware */
255250   MCFG_SCREEN_ADD("screen", RASTER)
r26157r26158
266261
267262DRIVER_INIT_MEMBER( alto2_state, alto2 )
268263{
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
272264   // make the diablo drives known to the CPU core
273265   alto2_cpu_device* cpu = downcast<alto2_cpu_device *>(m_maincpu.target());
274266   cpu->set_diablo(0, downcast<diablo_hd_device *>(machine().device(DIABLO_HD_0)));
275267   cpu->set_diablo(1, downcast<diablo_hd_device *>(machine().device(DIABLO_HD_1)));
276268
277269#define   UNICODE_TESTING   0
278#ifdef   UNICODE_TESTING
270#if   UNICODE_TESTING
279271   const char* filename = "docs/UnicodeData.txt";
280272   int res = unicode_data_load(filename);
281273   logerror("%s: unicode_data_load(\"%s\") result %d\n", filename, __FUNCTION__, res);
branches/alto2/src/mess/includes/alto2.h
r26157r26158
3232
3333   bitmap_ind16 m_bitmap;
3434
35   DECLARE_READ16_MEMBER(alto2_ram_r);
36   DECLARE_WRITE16_MEMBER(alto2_ram_w);
3735   DECLARE_DRIVER_INIT(alto2);
3836
3937   virtual void palette_init();

Previous 199869 Revisions Next


© 1997-2024 The MAME Team