@@ -124,7 +124,7 @@ class m68010_tekmmu_device : public m68010_device
124
124
LOG (" map_r: bus error: PID(%d) %08x fc(%d) pc(%08x)\n " , BIT (m_map[(offset >> 11 ) & 0x7ff ], 11 , 3 ), OFF16_TO_OFF8 (offset), get_fc (), pc ());
125
125
set_input_line (M68K_LINE_BUSERROR, ASSERT_LINE);
126
126
set_input_line (M68K_LINE_BUSERROR, CLEAR_LINE);
127
- set_buserror_details (offset, 0 , get_fc ());
127
+ set_buserror_details (offset, true , get_fc ());
128
128
return 0 ;
129
129
}
130
130
}
@@ -155,9 +155,9 @@ class m68010_tekmmu_device : public m68010_device
155
155
{
156
156
// page 2.1-54 implies that this can only be read in user mode
157
157
158
- LOGMASKED (LOG_MMU, " mapcntl_r(%02x) cpuWr(%d ) BlockAccess(%d ) SysWrEn(%d) PID(%d) pc(%08x)\n " ,m_map_control,
159
- BIT (m_map_control, MAP_CPU_WR) ? 1 : 0 ,
160
- BIT (m_map_control, MAP_BLOCK_ACCESS) ? 1 : 0 ,
158
+ LOGMASKED (LOG_MMU, " mapcntl_r(%02x) cpuWr(%s ) BlockAccess(%s ) SysWrEn(%d) PID(%d) pc(%08x)\n " ,m_map_control,
159
+ BIT (m_map_control, MAP_CPU_WR) ? " WRITE " : " READ " ,
160
+ BIT (m_map_control, MAP_BLOCK_ACCESS) ? " NO " : " YES " ,
161
161
BIT (m_map_control, MAP_SYS_WR_ENABLE) ? 1 : 0 ,
162
162
m_map_control & 15 ,
163
163
pc ());
@@ -176,7 +176,7 @@ class m68010_tekmmu_device : public m68010_device
176
176
void mapcntl_w (u8 data)
177
177
{
178
178
// copied on user mode read/write
179
- m_latched_map_control = data & 0x3f ;
179
+ m_latched_map_control = ( data & 0x3f ) ;
180
180
181
181
if (m_map_control != m_latched_map_control)
182
182
{
@@ -336,7 +336,7 @@ class m68010_tekmmu_device : public m68010_device
336
336
if (!BIT (*m_map_control_ptr, MAP_SYS_WR_ENABLE))
337
337
{
338
338
LOG (" PTEread: bus error: PID(%d) %08x fc(%d) pc(%08x)\n " , BIT (m_map_ptr[(address >> 12 ) & 0x7ff ], 11 , 3 ), (address), get_fc (), pc ());
339
- set_buserror_details (address, 1 , get_fc (), false );
339
+ set_buserror_details (address, true , get_fc (), false );
340
340
set_input_line (M68K_LINE_BUSERROR, ASSERT_LINE);
341
341
set_input_line (M68K_LINE_BUSERROR, CLEAR_LINE);
342
342
return 0 ;
@@ -726,7 +726,6 @@ void tek440x_state::machine_reset()
726
726
m_u244latch = 0 ;
727
727
m_led_disk = 1 ;
728
728
m_keyboard->kdo_w (1 );
729
- m_latched_map_control = 0 ;
730
729
mapcntl_w (0 );
731
730
videocntl_w (0 );
732
731
videoaddr_w (0 ,0 );
@@ -789,22 +788,22 @@ u16 tek440x_state::memory_r(offs_t offset, u16 mem_mask)
789
788
{
790
789
if ((m_maincpu->get_fc () & 4 ) == 0 ) // User mode access updates map_control from write latch
791
790
{
792
- if (m_latched_map_control != (m_map_control & 0x3f ))
791
+ if (( m_latched_map_control & 0x1f ) != (m_map_control & 0x1f ))
793
792
{
794
793
LOG (" memory_r: m_map_control updated 0x%04x\n " , m_latched_map_control);
795
- m_map_control &= ~0x3f ;
796
- m_map_control |= m_latched_map_control;
797
794
}
795
+ m_map_control &= ~0x1f ;
796
+ m_map_control |= (m_latched_map_control & 0x1f );
798
797
}
799
798
800
799
const offs_t offset0 = offset;
801
800
802
801
#ifndef USE_MMU
803
802
if (!inbuserr) // not in buserr interrupt
804
803
if ((m_maincpu->get_fc () & 4 ) == 0 ) // only in User mode
805
- if (BIT (m_map_control, MAP_VM_ENABLE))
804
+ if (BIT (m_map_control, MAP_VM_ENABLE) )
806
805
{
807
-
806
+
808
807
// is !cpuWr
809
808
m_map_control &= ~(1 << MAP_CPU_WR);
810
809
@@ -813,15 +812,17 @@ u16 tek440x_state::memory_r(offs_t offset, u16 mem_mask)
813
812
{
814
813
m_map_control &= ~(1 << MAP_BLOCK_ACCESS);
815
814
815
+ // FIXME: if this is a prefetch, it will be cancelled in src/devices/cpu/m68000/m68kcpu.h, but we've changed m_map_control..
816
+
816
817
inbuserr = 1 ;
817
818
818
- LOG (" memory_r: %06x: bus error: PTE PID %d != current PID %d fc(%d) pc(%08x) berr(%d)\n " , offset<<1 ,
819
+ LOG (" memory_r: %06x: bus error: PTE_PID(%d) != mapcntl_PID(%d) fc(%d) pc(%08x) berr(%d) map_control(%02x) latch(%02x )\n " , offset<<1 ,
819
820
BIT (m_map[offset >> 11 ], 11 , 3 ), (m_map_control & 7 ), m_maincpu->get_fc (), m_maincpu->pc (),
820
- inbuserr);
821
- m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), 1 , m_maincpu->get_fc (), true );
821
+ inbuserr, m_map_control, m_latched_map_control );
822
+ m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), true , m_maincpu->get_fc (), true );
822
823
823
824
mem_mask = 0 ;
824
- return 0xffff ;
825
+ return 0 ;
825
826
826
827
}
827
828
else
@@ -838,14 +839,14 @@ u16 tek440x_state::memory_r(offs_t offset, u16 mem_mask)
838
839
// NB byte memory limit, offset is *word* offset
839
840
if (offset >= OFF8_TO_OFF16 (MAXRAM) && offset < OFF8_TO_OFF16 (0x600000 ))
840
841
{
841
- LOG (" memory_r: bus error: NOMEM %08x fc(%d) pc(%08x)\n " , OFF16_TO_OFF8 (offset), m_maincpu->get_fc (), m_maincpu->pc ());
842
- m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), 1 , m_maincpu->get_fc (), true );
842
+ LOG (" memory_r: %08x bus error: NOMEM fc(%d) pc(%08x)\n " , OFF16_TO_OFF8 (offset), m_maincpu->get_fc (), m_maincpu->pc ());
843
+ m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), true , m_maincpu->get_fc (), true );
843
844
}
844
845
}
845
846
846
847
if (inbuserr && (m_maincpu->get_fc () & 4 ))
847
848
{
848
- LOG (" berr reset(r) %06x\n " , offset<< 1 );
849
+ LOG (" berr reset(r) %06x\n " , OFF16_TO_OFF8 ( offset) );
849
850
inbuserr = 0 ;
850
851
}
851
852
@@ -856,53 +857,62 @@ void tek440x_state::memory_w(offs_t offset, u16 data, u16 mem_mask)
856
857
{
857
858
if ((m_maincpu->get_fc () & 4 ) == 0 ) // User mode access updates map_control from write latch
858
859
{
859
- if (m_latched_map_control != (m_map_control & 0x3f ))
860
+ if (( m_latched_map_control & 0x1f ) != (m_map_control & 0x1f ))
860
861
{
861
862
LOG (" memory_w: m_map_control updated 0x%04x\n " , m_latched_map_control);
862
- m_map_control &= ~0x3f ;
863
- m_map_control |= m_latched_map_control;
864
863
}
864
+ m_map_control &= ~0x1f ;
865
+ m_map_control |= (m_latched_map_control & 0x1f );
865
866
}
866
867
867
868
const offs_t offset0 = offset;
869
+
868
870
#ifndef USE_MMU
869
871
if ((m_maincpu->get_fc () & 4 ) == 0 ) // only in User mode
870
872
if (BIT (m_map_control, MAP_VM_ENABLE))
871
873
{
872
874
// LOG("memory_w: m_map(0x%04x)\n", m_map[offset >> 11]);
873
875
874
876
// is cpuWr
875
- m_map_control |= (1 << MAP_CPU_WR);
877
+ if (!inbuserr)
878
+ m_map_control |= (1 << MAP_CPU_WR);
876
879
877
880
// matching pid?
878
881
if ( (BIT (m_map[offset >> 11 ], 11 , 3 ) != (m_map_control & 7 )))
879
882
{
880
- // NB active low
881
- m_map_control &= ~(1 << MAP_BLOCK_ACCESS);
883
+ if (!inbuserr)
884
+ {
885
+ // NB active low
886
+ m_map_control &= ~(1 << MAP_BLOCK_ACCESS);
882
887
883
- inbuserr = 1 ;
888
+ LOG (" memory_w: %06x bus error: PTE_PID(%d) != mapcntl_PID(%d) fc(%d)\n " , OFF16_TO_OFF8 (offset), BIT (m_map[offset >> 11 ], 11 , 3 ), (m_map_control & 7 ), m_maincpu->get_fc ());
889
+ m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), false , m_maincpu->get_fc (), true );
890
+ }
884
891
885
- LOG (" memory_w: bus error: PID(%d) != %d %08x fc(%d)\n " , BIT (m_map[offset >> 11 ], 11 , 3 ), (m_map_control & 7 ), OFF16_TO_OFF8 (offset), m_maincpu->get_fc ());
886
- m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), 0 , m_maincpu->get_fc (), true );
887
-
888
- mem_mask = 0 ; // disable write
892
+ inbuserr = 1 ;
889
893
}
890
894
else if (!inbuserr)
891
895
{
892
896
m_map_control |= (1 << MAP_BLOCK_ACCESS);
893
897
}
894
- else mem_mask = 0 ;
898
+
899
+ if (inbuserr)
900
+ mem_mask = 0 ; // disable write
895
901
896
902
// write-enabled page?
897
903
if (mem_mask)
898
904
if (BIT (m_map[offset >> 11 ], 14 ) == 0 )
899
905
{
900
906
m_map_control &= ~(1 << MAP_BLOCK_ACCESS);
907
+
908
+ // is this right?
909
+ m_map_control &= ~(1 << MAP_SYS_WR_ENABLE);
910
+
901
911
902
912
inbuserr = 1 ;
903
913
904
- LOG (" memory_w: bus error: READONLY %08x fc(%d) pc(%08x)\n " , OFF16_TO_OFF8 (offset), m_maincpu->get_fc (), m_maincpu->pc ());
905
- m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), 0 , m_maincpu->get_fc (), true );
914
+ LOG (" memory_w: %06x bus error: READONLY fc(%d) pc(%08x)\n " , OFF16_TO_OFF8 (offset), m_maincpu->get_fc (), m_maincpu->pc ());
915
+ m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), false , m_maincpu->get_fc (), true );
906
916
907
917
mem_mask = 0 ; // disable write
908
918
return ;
@@ -912,10 +922,13 @@ void tek440x_state::memory_w(offs_t offset, u16 data, u16 mem_mask)
912
922
if (mem_mask)
913
923
{
914
924
if (!(m_map[offset >> 11 ] & 0x8000 ))
915
- LOG (" memory_w: DIRTY m_map(0x%04x) m_map_control(%02x) berr(%d)\n " , m_map[offset >> 11 ], m_map_control, inbuserr);
925
+ LOG (" memory_w: DIRTY m_map(0x%04x) m_map_control(%02x) berr(%d) fc(%d) \n " , m_map[offset >> 11 ], m_map_control, inbuserr, m_maincpu-> get_fc () );
916
926
m_map[offset >> 11 ] |= 0x8000 ;
917
927
}
918
928
929
+ // if (mem_mask)
930
+ // LOG("memory_w: map %08x => paddr(%08x) berr(%d) fc(%d) pc(%08x)\n",OFF16_TO_OFF8(offset), OFF16_TO_OFF8(BIT(offset, 0, 11) | BIT(m_map[offset >> 11], 0, 11) << 11), inbuserr, m_maincpu->get_fc(), m_maincpu->pc());
931
+
919
932
offset = BIT (offset, 0 , 11 ) | (BIT (m_map[offset >> 11 ], 0 , 11 ) << 11 );
920
933
}
921
934
#endif
@@ -924,12 +937,12 @@ void tek440x_state::memory_w(offs_t offset, u16 data, u16 mem_mask)
924
937
if (offset >= OFF8_TO_OFF16 (MAXRAM) && offset < OFF8_TO_OFF16 (0x600000 ) && !machine ().side_effects_disabled ())
925
938
{
926
939
LOG (" memory_w: bus error: NOMEM %08x fc(%d)\n " , OFF16_TO_OFF8 (offset), m_maincpu->get_fc ());
927
- m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), 0 , m_maincpu->get_fc (), true );
940
+ m_maincpu->set_buserror_details (OFF16_TO_OFF8 (offset0), false , m_maincpu->get_fc (), true );
928
941
}
929
942
930
943
if (inbuserr && (m_maincpu->get_fc () & 4 ))
931
944
{
932
- LOG (" berr reset(w) %06x\n " , offset<< 1 );
945
+ LOG (" berr reset(w) %06x\n " , OFF16_TO_OFF8 ( offset) );
933
946
inbuserr = 0 ;
934
947
}
935
948
@@ -941,13 +954,16 @@ u16 tek440x_state::map_r(offs_t offset)
941
954
if (!machine ().side_effects_disabled ())
942
955
{
943
956
if ((offset>>11 ) < 0x20 )
957
+ {
944
958
LOGMASKED (LOG_MMU, " map_r 0x%08x => %04x\n " ,offset>>11 , m_map[(offset >> 11 )&0x7ff ] );
959
+ }
945
960
946
961
// selftest does a read and expects it to fail iff !MAP_SYS_WR_ENABLE; its not WR enable, its enable..
947
- if (!BIT (m_map_control, MAP_SYS_WR_ENABLE))
962
+ // NB page 2.1-52 shows WrMapEn coming from latch
963
+ if (!BIT (m_latched_map_control, MAP_SYS_WR_ENABLE))
948
964
{
949
965
LOGMASKED (LOG_MMU, " map_r: bus error: PID(%d) %08x fc(%d) pc(%08x)\n " , BIT (m_map[(offset >> 11 ) & 0x7ff ], 11 , 3 ), OFF16_TO_OFF8 (offset), m_maincpu->get_fc (), m_maincpu->pc ());
950
- m_maincpu->set_buserror_details (offset, 1 , m_maincpu->get_fc (), true );
966
+ m_maincpu->set_buserror_details (offset, true , m_maincpu->get_fc (), true );
951
967
return 0 ;
952
968
}
953
969
}
@@ -970,6 +986,10 @@ void tek440x_state::map_w(offs_t offset, u16 data, u16 mem_mask)
970
986
{
971
987
COMBINE_DATA (&m_map[(offset >> 11 ) & 0x7ff ]);
972
988
}
989
+ else
990
+ {
991
+ LOGMASKED (LOG_MMU, " map_w: %08x !MAP_SYS_WR_ENABLE\n " , (offset >> 11 ) & 0x7ff );
992
+ }
973
993
}
974
994
975
995
u8 tek440x_state::mapcntl_r ()
@@ -978,10 +998,11 @@ u8 tek440x_state::mapcntl_r()
978
998
{
979
999
// page 2.1-54 implies that this can only be read in user mode
980
1000
981
- LOG (" mapcntl_r(%02x) cpuWr(%d ) BlockAccess(%d ) SysWrEn(%d) PID(%d) pc(%08x)\n " ,m_map_control,
982
- BIT (m_map_control, MAP_CPU_WR) ? 1 : 0 ,
983
- BIT (m_map_control, MAP_BLOCK_ACCESS) ? 1 : 0 ,
1001
+ LOG (" mapcntl_r(%02x) cpuWr(%s ) BlockAccess(%s ) SysWrEn(%d) VMenable (%d) PID(%d) pc(%08x)\n " ,m_map_control,
1002
+ BIT (m_map_control, MAP_CPU_WR) ? " WRITE " : " READ " ,
1003
+ BIT (m_map_control, MAP_BLOCK_ACCESS) ? " NO " : " YES " ,
984
1004
BIT (m_map_control, MAP_SYS_WR_ENABLE) ? 1 : 0 ,
1005
+ BIT (m_map_control, MAP_VM_ENABLE) ? 1 : 0 ,
985
1006
m_map_control & 15 ,
986
1007
m_maincpu->pc ());
987
1008
@@ -1000,22 +1021,31 @@ u8 tek440x_state::mapcntl_r()
1000
1021
void tek440x_state::mapcntl_w (u8 data)
1001
1022
{
1002
1023
// copied on user mode read/write
1003
- m_latched_map_control = data & 0x3f ;
1024
+ m_latched_map_control = ( data & 0x3f ) ;
1004
1025
1005
- if (m_map_control != m_latched_map_control)
1026
+ if (( m_map_control & 0x1f ) != ( m_latched_map_control & 0x1f ) )
1006
1027
{
1007
- LOGMASKED (LOG_MMU, " mapcntl_w(%02x) cpuWr(%d) BlockAccess(%d) SysWrEn(%d) PID(%d) pc(%08x)\n " ,m_latched_map_control,
1008
- BIT (m_latched_map_control, MAP_CPU_WR) ? 1 : 0 ,
1009
- BIT (m_latched_map_control, MAP_BLOCK_ACCESS) ? 1 : 0 ,
1010
- BIT (m_latched_map_control, MAP_SYS_WR_ENABLE) ? 1 : 0 ,
1011
- m_latched_map_control & 15 ,
1012
- m_maincpu->pc ());
1028
+ LOGMASKED (LOG_MMU, " mapcntl_w(%02x) " ,m_latched_map_control);
1029
+ if (BIT (m_latched_map_control, MAP_SYS_WR_ENABLE) != BIT (m_map_control, MAP_SYS_WR_ENABLE))
1030
+ {
1031
+ LOGMASKED (LOG_MMU, " SysWrEn(%d => %d) " , BIT (m_map_control, MAP_SYS_WR_ENABLE), BIT (m_latched_map_control, MAP_SYS_WR_ENABLE));
1032
+ }
1033
+ if (BIT (m_latched_map_control, MAP_VM_ENABLE) != BIT (m_map_control, MAP_VM_ENABLE))
1034
+ {
1035
+ LOGMASKED (LOG_MMU, " VMenable(%d => %d) " , BIT (m_map_control, MAP_VM_ENABLE), BIT (m_latched_map_control, MAP_VM_ENABLE));
1036
+ }
1037
+ if ((m_latched_map_control & 15 ) != (m_map_control & 15 ))
1038
+ {
1039
+ LOGMASKED (LOG_MMU, " PID(%d => %d) " , (m_map_control & 15 ),(m_latched_map_control & 15 ));
1040
+ }
1041
+ LOGMASKED (LOG_MMU, " pc(%08x)\n " , m_maincpu->pc ());
1013
1042
1043
+ if (0 )
1014
1044
if (BIT (data, MAP_VM_ENABLE) && (data & 15 ))
1015
1045
for (uint32_t i=0 ; i<2048 ; i++)
1016
1046
{
1017
1047
if (m_map[i])
1018
- LOGMASKED (LOG_MMU, " XXXmapcntl_w : %08x -> paddr(%08x) PID(%d) dirty(%d) write_enable(%d)\n " ,
1048
+ LOGMASKED (LOG_MMU, " mapcntl_w : %08x -> paddr(%08x) PID(%d) dirty(%d) write_enable(%d)\n " ,
1019
1049
OFF16_TO_OFF8 (i << 11 ), OFF16_TO_OFF8 (BIT (m_map[i], 0 , 11 )<<11 ),
1020
1050
BIT (m_map[i], 11 , 3 ), m_map[i] & 0x8000 ? 1 : 0 , m_map[i] & 0x4000 ? 1 : 0 );
1021
1051
}
@@ -1025,7 +1055,8 @@ void tek440x_state::mapcntl_w(u8 data)
1025
1055
// NB bit 6 & 7 is not used
1026
1056
1027
1057
// disable using latched state below
1028
- // m_map_control = data & 0x3f;
1058
+ m_map_control &= 0xc0 ;
1059
+ m_map_control |= m_latched_map_control;
1029
1060
1030
1061
}
1031
1062
@@ -1085,7 +1116,7 @@ u16 tek440x_state::fpu_r(offs_t offset)
1085
1116
if (m_fpu_finished)
1086
1117
{
1087
1118
result = m_fpu->slow_status ();
1088
- // LOGMASKED(LOG_FPU,"fpu_r: status = 0x%04x\n", result);
1119
+ LOGMASKED (LOG_FPU," fpu_r: status = 0x%04x\n " , result);
1089
1120
}
1090
1121
else
1091
1122
{
0 commit comments