Previous 199869 Revisions Next

r22645 Thursday 2nd May, 2013 at 17:28:10 UTC by David Haywood
coax the code into doing a little more (nw)
[src/emu/machine]mcf5206e.c mcf5206e.h
[src/mame/drivers]bfm_sc5.c
[src/mame/includes]bfm_sc5.h

trunk/src/emu/machine/mcf5206e.c
r22644r22645
4848
4949   AM_RANGE(0x100, 0x103) AM_READWRITE16(TMR1_r, TMR1_w, 0xffffffff)
5050   AM_RANGE(0x104, 0x107) AM_READWRITE16(TRR1_r, TRR1_w, 0xffffffff)
51   AM_RANGE(0x110, 0x113) AM_READWRITE8(TER1_r, TER1_w, 0xffffffff)
5152
5253
5354   AM_RANGE(0x1c4, 0x1c7) AM_READWRITE8(PPDDR_r, PPDDR_w, 0xffffffff)
r22644r22645
5859ADDRESS_MAP_END
5960
6061
62
6163READ8_MEMBER( mcf5206e_peripheral_device::ICR1_ICR2_ICR3_ICR4_r )
6264{
6365   switch (offset)
6466   {
6567   case 0: // 0x014
6668      printf("(External IRQ1/IPL1 Interrupt Vector) ICR1_r\n");
67      return m_ICR1;
69      return m_ICR[ICR1];
6870   case 1: // 0x015
6971      printf("(External IPL2 Interrupt Vector) ICR2_r\n");
70      return m_ICR2;
72      return m_ICR[ICR2];
7173   case 2: // 0x016
7274      printf("(External IPL3 Interrupt Vector) ICR3_r\n");
73      return m_ICR3;
75      return m_ICR[ICR3];
7476   case 3: // 0x017
7577      printf("(External IRQ4/IPL4 Interrupt Vector) ICR4_r\n");
76      return m_ICR4;
78      return m_ICR[ICR4];
7779   }
7880
7981   return 0;
r22644r22645
8486   switch (offset)
8587   {
8688   case 0: // 0x014
87      m_ICR1 = data;
89      m_ICR[ICR1] = data;
8890      printf("(External IRQ1/IPL1 Interrupt Vector) ICR1_w %02x\n",data);
91      ICR_info(m_ICR[ICR1]);
8992      break;
9093   case 1: // 0x015
91      m_ICR2 = data;
94      m_ICR[ICR2] = data;
9295      printf("(External IPL2 Interrupt Vector) ICR2_w %02x\n",data);
96      ICR_info(m_ICR[ICR2]);
9397      break;
9498   case 2: // 0x016
95      m_ICR3 = data;
99      m_ICR[ICR3] = data;
96100      printf("(External IPL3 Interrupt Vector) ICR3_w %02x\n",data);
101      ICR_info(m_ICR[ICR3]);
97102      break;
98103   case 3: // 0x017
99      m_ICR4 = data;
104      m_ICR[ICR4] = data;
100105      printf("(External IRQ4/IPL4 Interrupt Vector) ICR4_w %02x\n",data);
106      ICR_info(m_ICR[ICR4]);
101107      break;
102108   }
103109}
r22644r22645
108114   {
109115   case 0: // 0x01c
110116      printf("(Timer 1 Interrupt Vector) ICR9_r\n");
111      return m_ICR9;
117      return m_ICR[ICR9];
112118   case 1: // 0x01d
113119      printf("(Timer 2 Interrupt Vector) ICR10_r\n");
114      return m_ICR10;
120      return m_ICR[ICR10];
115121   case 2: // 0x01e
116122      printf("(MBUS Interrupt Vector) ICR11_r\n");
117      return m_ICR11;
123      return m_ICR[ICR11];
118124   case 3: // 0x01f
119125      printf("(UART1 Interrupt Vector) ICR12_r\n");
120      return m_ICR12;
126      return m_ICR[ICR12];
121127   }
122128
123129   return 0;
r22644r22645
128134   switch (offset)
129135   {
130136   case 0: // 0x01c
131      m_ICR9 = data;
137      m_ICR[ICR9] = data;
132138      printf("(Timer 1 Interrupt Vector) ICR9_w %02x\n",data);
139      ICR_info(m_ICR[ICR9]);
133140      break;
134141   case 1: // 0x01d
135      m_ICR10 = data;
142      m_ICR[ICR10] = data;
136143      printf("(Timer 2 Interrupt Vector) ICR10_w %02x\n",data);
144      ICR_info(m_ICR[ICR10]);
137145      break;
138146   case 2: // 0x01e
139      m_ICR11 = data;
147      m_ICR[ICR11] = data;
140148      printf("(MBUS Interrupt Vector) ICR11_w %02x\n",data);
149      ICR_info(m_ICR[ICR11]);
141150      break;
142151   case 3: // 0x01f
143      m_ICR12 = data;
152      m_ICR[ICR12] = data;
144153      printf("(UART1 Interrupt Vector) ICR12_w %02x\n",data);
154      ICR_info(m_ICR[ICR12]);
145155      break;
146156   }
147157}
r22644r22645
152162   {
153163   case 0: // 0x020
154164      printf("(UART2 Interrupt Vector) ICR13_r\n");
155      return m_ICR13;
165      return m_ICR[ICR13];
156166   case 1:
157167   case 2:
158168   case 3:
r22644r22645
168178   switch (offset)
169179   {
170180   case 0: // 0x020
171      m_ICR13 = data;
181      m_ICR[ICR13] = data;
172182      printf("(UART2 Interrupt Vector) ICR13_w %02x\n",data);
183      ICR_info(m_ICR[ICR13]);
173184      break;
174185   case 1:
175186   case 2:
r22644r22645
540551   }
541552}
542553
554void mcf5206e_peripheral_device::ICR_info(UINT8 ICR)
555{
556   printf("   (AutoVector) AVEC : %01x | ", (ICR&0x80)>>7);
557   printf("(Interrupt Level) IL : %01x | ", (ICR&0x1c)>>2); // if autovector (AVEC) is used then the vectors referenced are at +24 (+0x18) + IL, ie the standard 68k autovectors, otherwise vector must be provided by device
558   printf("(Interrupt Priority) IP : %01x |", (ICR&0x03)>>0);
559   printf("(Unused bits) : %01x\n", (ICR&0x60)>>5);
560}
543561
562/* The timer module seems practically the same as the 68307 one, possibly make into a common device once the code isn't a hardcoded piece of junk ;-) */
544563
564TIMER_CALLBACK_MEMBER(mcf5206e_peripheral_device::timer1_callback)
565{
566   UINT8 ICR = m_ICR[ICR9];
567
568   // technically we should do the vector check in the IRQ callback as well as various checks based on the IRQ masks before asserting the interrupt
569   if (ICR & 0x80) // AVEC
570   {
571      m_cpu->set_input_line((ICR&0x1c)>>2, HOLD_LINE);
572   }
573
574   printf("timer1_callback\n");
575   
576   timer1->adjust(attotime::from_seconds(1)); // completely made up value just to fire our timers for now
577}
578
579
545580READ16_MEMBER( mcf5206e_peripheral_device::TMR1_r)
546581{
547582   switch (offset)
r22644r22645
564599   case 0:
565600      COMBINE_DATA(&m_TMR1);
566601      printf("TMR1_w %04x %04x\n",data, mem_mask);
602
603      printf("   (Prescale) PS : %02x  (Capture Edge/Interrupt) CE : %01x (Output Mode) OM : %01x  (Output Reference Interrupt En) ORI : %01x   Free Run (FRR) : %01x  Input Clock Source (ICLK) : %01x  (Reset Timer) RST : %01x  \n",
604         (m_TMR1 & 0xff00)>>8, (m_TMR1 & 0x00c0)>>6,  (m_TMR1 & 0x0020)>>5, (m_TMR1 & 0x0010)>>4, (m_TMR1 & 0x0008)>>3, (m_TMR1 & 0x0006)>>1, (m_TMR1 & 0x0001)>>0);   
605     
606      if (m_TMR1 & 0x0001)
607      {
608         timer1->adjust(attotime::from_seconds(1)); // completely made up value just to fire our timers for now
609      }
610      else
611      {
612         timer1->adjust(attotime::never);
613      }
614     
615     
567616      break;
568617   case 1:
569618      printf("invalid TMR1_w %d, %04x %04x\n", offset, data, mem_mask);
r22644r22645
603652}
604653
605654
655
656READ8_MEMBER( mcf5206e_peripheral_device::TER1_r)
657{
658   switch (offset)
659   {
660   case 1:
661      printf("TER1_r\n");
662      return 2; // hack, timer events should set bits, this just stops the code going crazy for now
663   case 0:
664   case 2:
665   case 3:
666      printf("invalid TER1_r %d\n", offset);
667      return 0;
668   }
669
670   return 0;
671}
672
673WRITE8_MEMBER( mcf5206e_peripheral_device::TER1_w)
674{
675   switch (offset)
676   {
677   case 1:
678      m_TER1 = data; // writes should clear the bits..
679      printf("TER1_w %02x\n",data);
680      break;
681   case 0:
682   case 2:
683   case 3:
684      printf("invalid TER1_w %d, %02x\n", offset, data);
685      break;
686
687   }
688}
689
690
606691//**************************************************************************
607692//  LIVE DEVICE
608693//**************************************************************************
r22644r22645
644729void mcf5206e_peripheral_device::device_start()
645730{
646731   init_regs(true);
732
733   timer1 = machine().scheduler().timer_alloc( timer_expired_delegate( FUNC( mcf5206e_peripheral_device::timer1_callback ), this) );
734
647735}
648736
737void mcf5206e_peripheral_device::device_reset()
738{
739   m_cpu = (cpu_device*)machine().device(":maincpu"); // hack. this device should really be attached to a modern CPU core
649740
741   init_regs(false);
742   timer1->adjust(attotime::never);
743}
650744
651745READ32_MEMBER(mcf5206e_peripheral_device::dev_r)
652746{
r22644r22645
692786
693787void mcf5206e_peripheral_device::init_regs(bool first_init)
694788{
695   m_ICR1 =   0x04;
696   m_ICR2 =    0x08;
697   m_ICR3 =    0x0C;
698   m_ICR4 =    0x10;
699   m_ICR5 =    0x14;
700   m_ICR6 =    0x18;
701   m_ICR7 =    0x1C;
702   m_ICR8 =    0x1C;
703   m_ICR9 =   0x80;
704   m_ICR10 =    0x80;
705   m_ICR11 =    0x80;
706   m_ICR12 =     0x00;
707   m_ICR13 =    0x00;
789   m_ICR[ICR1] =   0x04;
790   m_ICR[ICR2] =    0x08;
791   m_ICR[ICR3] =    0x0C;
792   m_ICR[ICR4] =    0x10;
793   m_ICR[ICR5] =    0x14;
794   m_ICR[ICR6] =    0x18;
795   m_ICR[ICR7] =    0x1C;
796   m_ICR[ICR8] =    0x1C;
797   m_ICR[ICR9] =   0x80;
798   m_ICR[ICR10] =    0x80;
799   m_ICR[ICR11] =    0x80;
800   m_ICR[ICR12] =     0x00;
801   m_ICR[ICR13] =    0x00;
708802
709803   m_CSAR[0] =   0x0000;
710804   m_CSMR[0] =   0x00000000;
trunk/src/emu/machine/mcf5206e.h
r22644r22645
2626
2727// ======================> mcf5206e_peripheral_device
2828
29enum
30{
31   ICR1 = 0,
32   ICR2,
33   ICR3,
34   ICR4,
35   ICR5,
36   ICR6,
37   ICR7,
38   ICR8,
39   ICR9,
40   ICR10,
41   ICR11,
42   ICR12,
43   ICR13,
44   MAX_ICR
45};
46
2947class mcf5206e_peripheral_device :  public device_t,
3048                           public device_memory_interface
3149{
3250public:
3351   // construction/destruction
3452   mcf5206e_peripheral_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
53   
54   void ICR_info(UINT8 ICR);
3555
3656   DECLARE_READ32_MEMBER( dev_r );
3757   DECLARE_WRITE32_MEMBER( dev_w );
r22644r22645
111131   DECLARE_WRITE16_MEMBER( TMR1_w );
112132   DECLARE_READ16_MEMBER( TRR1_r );
113133   DECLARE_WRITE16_MEMBER( TRR1_w );
134   DECLARE_READ8_MEMBER( TER1_r );
135   DECLARE_WRITE8_MEMBER(TER1_w );
114136
115137   DECLARE_READ8_MEMBER( PPDDR_r );
116138   DECLARE_WRITE8_MEMBER( PPDDR_w );
r22644r22645
126148   DECLARE_READ8_MEMBER( MBSR_r );
127149   DECLARE_WRITE8_MEMBER( MBSR_w );
128150   
151   cpu_device* m_cpu;
129152
130153protected:
131154   // device-level overrides
132155   virtual void device_config_complete();
133156   virtual void device_start();
134   virtual void device_reset() { }
157   virtual void device_reset();
135158   virtual void device_post_load() { }
136159   virtual void device_clock_changed() { }
137160   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
r22644r22645
142165   
143166   void init_regs(bool first_init);
144167
145   UINT8 m_ICR1;
146   UINT8 m_ICR2;
147   UINT8 m_ICR3;
148   UINT8 m_ICR4;
149   UINT8 m_ICR5;
150   UINT8 m_ICR6;
151   UINT8 m_ICR7;
152   UINT8 m_ICR8;
153   UINT8 m_ICR9;
154   UINT8 m_ICR10;
155   UINT8 m_ICR11;
156   UINT8 m_ICR12;
157   UINT8 m_ICR13;
168   UINT8 m_ICR[MAX_ICR];
158169
159170   UINT16 m_CSAR[8];
160171   UINT32 m_CSMR[8];
r22644r22645
163174   UINT16 m_DMCR;
164175   UINT16 m_PAR;
165176
177   emu_timer *timer1;
166178   UINT16 m_TMR1;
167179   UINT16 m_TRR1;
180   UINT8 m_TER1;
181   TIMER_CALLBACK_MEMBER(timer1_callback);
168182
183
169184   UINT8 m_PPDDR;
170185   UINT8 m_PPDAT;
171186
trunk/src/mame/includes/bfm_sc5.h
r22644r22645
1515   required_device<cpu_device> m_maincpu;
1616public:
1717   DECLARE_DRIVER_INIT(sc5);
18   INTERRUPT_GEN_MEMBER(sc5_fake_timer_int);
1918   DECLARE_WRITE_LINE_MEMBER(bfm_sc5_ym_irqhandler);
2019
2120};
trunk/src/mame/drivers/bfm_sc5.c
r22644r22645
3838};
3939
4040
41INTERRUPT_GEN_MEMBER(bfm_sc5_state::sc5_fake_timer_int)
42{
43   // this should be coming from the Timer / SIM modules of the Coldfire
44   //m_maincpu->set_input_line_and_vector(5, HOLD_LINE, 0x8c);
45}
46
4741MACHINE_CONFIG_START( bfm_sc5, bfm_sc5_state )
4842   MCFG_CPU_ADD("maincpu", MCF5206E, 40000000) /* MCF5206eFT */
4943   MCFG_CPU_PROGRAM_MAP(sc5_map)
50   MCFG_CPU_PERIODIC_INT_DRIVER(bfm_sc5_state, sc5_fake_timer_int, 1000)
5144   MCFG_MCF5206E_PERIPHERAL_ADD("maincpu_onboard")
5245
5346   /* sound hardware */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team