summaryrefslogtreecommitdiff
path: root/src/mem/ruby/simics/interface.cc
blob: 92c30c23e962912c859160a9ac4a78a1dd517a68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935

/*
 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met: redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer;
 * redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution;
 * neither the name of the copyright holders nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * $Id: interface.C 1.39 05/01/19 13:12:31-06:00 mikem@maya.cs.wisc.edu $
 *
 */

#include "Global.hh"
#include "System.hh"
#include "OpalInterface.hh"
#include "EventQueue.hh"
#include "mf_api.hh"
#include "interface.hh"
#include "Sequencer.hh"
// #include "TransactionInterfaceManager.hh"

#ifdef CONTIGUOUS_ADDRESSES
#include "ContiguousAddressTranslator.hh"

/* Also used in init.C, commands.C */
ContiguousAddressTranslator * g_p_ca_translator = NULL;

#endif // #ifdef CONTIGUOUS_ADDRESSES

////////////////////////   Local helper functions //////////////////////

// Callback when exception occur
static void core_exception_callback(void *data, void *cpu,
                                    integer_t exc)
{
  // SimicsDriver *simics_intf = dynamic_cast<SimicsDriver*>(g_system_ptr->getDriver());
  // ASSERT( simics_intf );
  // simics_intf->exceptionCallback(cpu, exc);
  assert(0);
}

#ifdef SPARC
// Callback when asi accesses occur
// static exception_type_t core_asi_callback(void * cpu, generic_transaction_t *g)
// {
//   SimicsDriver *simics_intf = dynamic_cast<SimicsDriver*>(g_system_ptr->getDriver());
//   assert( simics_intf );
//   return simics_intf->asiCallback(cpu, g);
// }
#endif

static void runRubyEventQueue(void* obj, void* arg)
{
  Time time = g_eventQueue_ptr->getTime() + 1;
  DEBUG_EXPR(NODE_COMP, HighPrio, time);
  g_eventQueue_ptr->triggerEvents(time);
//   void* obj_ptr = (void*) SIM_proc_no_2_ptr(0);  // Maurice
//   SIM_time_post_cycle(obj_ptr, SIMICS_RUBY_MULTIPLIER, Sim_Sync_Processor, &runRubyEventQueue, NULL);  // Maurice
  assert(0);
}

////////////////////////   Simics API functions //////////////////////

int SIMICS_number_processors()
{
//   return SIM_number_processors();  // Maurice
  assert(0);
  return 0;
}

void SIMICS_wakeup_ruby()
{
//   void* obj_ptr = (void*) SIM_proc_no_2_ptr(0);  // Maurice
//   SIM_time_post_cycle(obj_ptr, SIMICS_RUBY_MULTIPLIER, Sim_Sync_Processor, &runRubyEventQueue, NULL);  // Maurice
  assert(0);
}

// an analogue to wakeup ruby, this function ends the callbacks ruby normally
// recieves from simics. (it removes ruby from simics's event queue). This
// function should only be called when opal is installed. Opal advances ruby's
// event queue independently of simics.
void SIMICS_remove_ruby_callback( void )
{
//   void* obj_ptr = (void*) SIM_proc_no_2_ptr(0);  // Maurice
//   SIM_time_clean( obj_ptr, Sim_Sync_Processor, &runRubyEventQueue, NULL);  // Maurice
  assert(0);
}

// Install ruby as the timing model (analogous code exists in ruby/ruby.c)
void SIMICS_install_timing_model( void )
{
// //   void *phys_mem0 = SIM_get_object("phys_mem0");  // Maurice
//   attr_value_t   val;
// //   val.kind     = Sim_Val_String;  // Maurice
//   val.u.string = "ruby0";
//   set_error_t install_error;
//
//   if(phys_mem0==NULL) {
//     /* Look for "phys_mem" instead */
// //     SIM_clear_exception();  // Maurice
// //     phys_mem0 = SIM_get_object("phys_mem");  // Maurice
//   }
//
//   if(phys_mem0==NULL) {
//     /* Okay, now panic... can't install ruby without a physical memory object */
//     WARN_MSG( "Cannot Install Ruby... no phys_mem0 or phys_mem object found" );
//     WARN_MSG( "Ruby is NOT installed." );
// //     SIM_clear_exception();  // Maurice
//     return;
//   }
//
// //   install_error = SIM_set_attribute(phys_mem0, "timing_model", &val);  // Maurice
//
// //   if (install_error == Sim_Set_Ok) {  // Maurice
//     WARN_MSG( "successful installation of the ruby timing model" );
//   } else {
//     WARN_MSG( "error installing ruby timing model" );
// //     WARN_MSG( SIM_last_error() );  // Maurice
//   }

  assert(0);
}

// Removes ruby as the timing model interface
void SIMICS_remove_timing_model( void )
{
//   void *phys_mem0 = SIM_get_object("phys_mem0");  // Maurice
//   attr_value_t   val;
//   memset( &val, 0, sizeof(attr_value_t) );
// //   val.kind = Sim_Val_Nil;  // Maurice
//
//   if(phys_mem0==NULL) {
//     /* Look for "phys_mem" instead */
// //     SIM_clear_exception();  // Maurice
// //     phys_mem0 = SIM_get_object("phys_mem");  // Maurice
//   }
//
//   if(phys_mem0==NULL) {
//     /* Okay, now panic... can't uninstall ruby without a physical memory object */
//     WARN_MSG( "Cannot Uninstall Ruby... no phys_mem0 or phys_mem object found" );
//     WARN_MSG( "Uninstall NOT performed." );
// //     SIM_clear_exception();  // Maurice
//     return;
//   }
//
// //   SIM_set_attribute(phys_mem0, "timing_model", &val);  // Maurice
  assert(0);
}

// Installs the (SimicsDriver) function to recieve the exeception callback
void SIMICS_install_exception_callback( void )
{
  // install exception callback
  // s_exception_hap_handle =
//     SIM_hap_add_callback("Core_Exception",  // Maurice
     //                    (obj_hap_func_t)core_exception_callback, NULL );
  assert(0);
}

// removes the exception callback
void SIMICS_remove_exception_callback( void )
{
  // uninstall exception callback
//   SIM_hap_delete_callback_id( "Core_Exception",  // Maurice
    //                          s_exception_hap_handle );
  assert(0);
}

#ifdef SPARC
// Installs the (SimicsDriver) function to recieve the asi callback
void SIMICS_install_asi_callback( void )
{
//   for(int i = 0; i < SIM_number_processors(); i++) {  // Maurice
 //   sparc_v9_interface_t *v9_interface = (sparc_v9_interface_t *)
//       SIM_get_interface(SIM_proc_no_2_ptr(i), SPARC_V9_INTERFACE);  // Maurice

    // init asi callbacks, 16bit ASI
  //  for(int j = 0; j < MAX_ADDRESS_SPACE_ID; j++) {
    //  v9_interface->install_user_asi_handler(core_asi_callback, j);
 //   }
  // }
  assert(0);
}

// removes the asi callback
void SIMICS_remove_asi_callback( void )
{
//   for(int i = 0; i < SIM_number_processors(); i++) {  // Maurice
//    sparc_v9_interface_t *v9_interface = (sparc_v9_interface_t *)
//       SIM_get_interface(SIM_proc_no_2_ptr(i), SPARC_V9_INTERFACE);  // Maurice

    // disable asi callback
  //  for(int j = 0; j < MAX_ADDRESS_SPACE_ID; j++) {
  //    v9_interface->remove_user_asi_handler(core_asi_callback, j);
  //  }
 // }
  assert(0);
}
#endif

// Query simics for the presence of the opal object.
// returns its interface if found, NULL otherwise
mf_opal_api_t *SIMICS_get_opal_interface( void )
{
//   void *opal = SIM_get_object("opal0");  // Maurice
  //if (opal != NULL) {
//     mf_opal_api_t *opal_intf  = (mf_opal_api_t *) SIM_get_interface( opal, "mf-opal-api" );  // Maurice
   // if ( opal_intf != NULL ) {
   //   return opal_intf;
//     } else {
//       WARN_MSG("error: OpalInterface: opal does not implement mf-opal-api interface.\n");
//       return NULL;
//     }
//   }
//   SIM_clear_exception();     // Maurice
  assert(0);
  return NULL;
}

void * SIMICS_current_processor(){
//   return SIM_current_processor();  // Maurice
  assert(0);
  return NULL;
}

int SIMICS_current_processor_number()
{
//   return (SIM_get_proc_no((processor_t *) SIM_current_processor()));  // Maurice
  assert(0);
  return 0;
}

integer_t SIMICS_get_insn_count(int cpuNumber)
{
  // NOTE: we already pass in the logical cpuNumber (ie Simics simulated cpu number)
  int num_smt_threads = RubyConfig::numberofSMTThreads();
  integer_t total_insn = 0;
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   total_insn += SIM_step_count((void*) cpu);   // Maurice
  assert(0);
  return total_insn;
}

integer_t SIMICS_get_cycle_count(int cpuNumber)
{
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   integer_t result =  SIM_cycle_count((void*) cpu);   // Maurice
  assert(0);
  return 0;
}

void SIMICS_unstall_proc(int cpuNumber)
{
//   void* proc_ptr = (void *) SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   SIM_stall_cycle(proc_ptr, 0);  // Maurice
  assert(0);
}

void SIMICS_unstall_proc(int cpuNumber, int cycles)
{
//   void* proc_ptr = (void *) SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   SIM_stall_cycle(proc_ptr, cycles);  // Maurice
  assert(0);
}

void SIMICS_stall_proc(int cpuNumber, int cycles)
{
//   void* proc_ptr = (void*) SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   if (SIM_stalled_until(proc_ptr) != 0){  // Maurice
//     cout << cpuNumber << " Trying to stall. Stall Count currently at " << SIM_stalled_until(proc_ptr) << endl;  // Maurice
//  }
//   SIM_stall_cycle(proc_ptr, cycles);  // Maurice
  assert(0);
}

void SIMICS_post_stall_proc(int cpuNumber, int cycles)
{
//   void* proc_ptr = (void*) SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   SIM_stacked_post(proc_ptr, ruby_stall_proc, (void *) cycles);  // Maurice
  assert(0);
}

integer_t SIMICS_read_physical_memory( int procID, physical_address_t address,
                                       int len )
{
// //   SIM_clear_exception();        // Maurice
//   ASSERT( len <= 8 );
// #ifdef CONTIGUOUS_ADDRESSES
//   if(g_p_ca_translator != NULL) {
//     address = g_p_ca_translator->TranslateRubyToSimics( address );
//   }
// #endif // #ifdef CONTIGUOUS_ADDRESSES
// //   integer_t result = SIM_read_phys_memory( SIM_proc_no_2_ptr(procID),  // Maurice
// // //                                           address, len );
// //
// // //   int isexcept = SIM_get_pending_exception();  // Maurice
// //   if ( !(isexcept == SimExc_No_Exception || isexcept == SimExc_Break) ) {
// // //     sim_exception_t except_code = SIM_clear_exception();  // Maurice
// //     WARN_MSG( "SIMICS_read_physical_memory: raised exception." );
// // //     WARN_MSG( SIM_last_error() );  // Maurice
// //     WARN_MSG( Address(address) );
// //     WARN_MSG( procID );
// //     ASSERT(0);
// //   }
// //   return ( result );
  assert(0);
   return 0;
}
//
// /*
//  * Read data into a buffer and assume the buffer is already allocated
//  */
void SIMICS_read_physical_memory_buffer(int procID, physical_address_t addr,
                                         char* buffer, int len ) {
// // //   processor_t* obj = SIM_proc_no_2_ptr(procID);  // Maurice
// //
// //   assert( obj != NULL);
// //   assert( buffer != NULL );
// //
// // #ifdef CONTIGUOUS_ADDRESSES
// //   if(g_p_ca_translator != NULL) {
// //     addr = g_p_ca_translator->TranslateRubyToSimics( addr );
// //   }
// // #endif // #ifdef CONTIGUOUS_ADDRESSES
// //
// //   int buffer_pos = 0;
// //   physical_address_t start = addr;
// //   do {
// //     int size = (len < 8)? len:8;
// // //     integer_t result = SIM_read_phys_memory( obj, start, size );  // Maurice
// // //     int isexcept = SIM_get_pending_exception();  // Maurice
// //     if ( !(isexcept == SimExc_No_Exception || isexcept == SimExc_Break) ) {
// // //       sim_exception_t except_code = SIM_clear_exception();  // Maurice
// //       WARN_MSG( "SIMICS_read_physical_memory_buffer: raised exception." );
// // //       WARN_MSG( SIM_last_error() );  // Maurice
// //       WARN_MSG( addr );
// //       WARN_MSG( procID );
// //       ASSERT( 0 );
// //     }
// //
// // #ifdef SPARC
// //     // assume big endian (i.e. SPARC V9 target)
// //     for(int i = size-1; i >= 0; i--) {
// // #else
// //     // assume little endian (i.e. x86 target)
// //     for(int i = 0; i<size; i++) {
// // #endif
// //       buffer[buffer_pos++] = (char) ((result>>(i<<3))&0xff);
// //     }
// //
// //     len -= size;
// //     start += size;
// //   } while(len != 0);
  assert(0);
}
//
void SIMICS_write_physical_memory( int procID, physical_address_t address,
                                    integer_t value, int len )
 {
// //   ASSERT( len <= 8 );
// //
// // //   SIM_clear_exception();  // Maurice
// //
// // //   processor_t* obj = SIM_proc_no_2_ptr(procID);  // Maurice
// //
// // #ifdef CONTIGUOUS_ADDRESSES
// //   if(g_p_ca_translator != NULL) {
// //     address = g_p_ca_translator->TranslateRubyToSimics( address );
// //   }
// // #endif // #ifdef CONTIGUOUS_ADDRESSES
// //
// // //   int isexcept = SIM_get_pending_exception();  // Maurice
// //   if ( !(isexcept == SimExc_No_Exception || isexcept == SimExc_Break) ) {
// // //     sim_exception_t except_code = SIM_clear_exception();  // Maurice
// //     WARN_MSG( "SIMICS_write_physical_memory 1: raised exception." );
// // //     WARN_MSG( SIM_last_error() );  // Maurice
// //     WARN_MSG( address );
// //   }
// //
// // //   SIM_write_phys_memory(obj, address, value, len );  // Maurice
// //
// // //   isexcept = SIM_get_pending_exception();  // Maurice
// //   if ( !(isexcept == SimExc_No_Exception || isexcept == SimExc_Break) ) {
// // //     sim_exception_t except_code = SIM_clear_exception();  // Maurice
// //     WARN_MSG( "SIMICS_write_physical_memory 2: raised exception." );
// // //     WARN_MSG( SIM_last_error() );  // Maurice
// //     WARN_MSG( address );
// //   }
  assert(0);
}
//
// /*
//  * write data to simics memory from a buffer (assumes the buffer is valid)
//  */
void SIMICS_write_physical_memory_buffer(int procID, physical_address_t addr,
                                         char* buffer, int len ) {
// //   processor_t* obj = SIM_proc_no_2_ptr(procID);  // Maurice
//
//   assert( obj != NULL);
//   assert( buffer != NULL );
//
// #ifdef CONTIGUOUS_ADDRESSES
//   if(g_p_ca_translator != NULL) {
//     addr = g_p_ca_translator->TranslateRubyToSimics( addr );
//   }
// #endif // #ifdef CONTIGUOUS_ADDRESSES
//
//   int buffer_pos = 0;
//   physical_address_t start = addr;
//   do {
//     int size = (len < 8)? len:8;
// //     //integer_t result = SIM_read_phys_memory( obj, start, size );  // Maurice
//     integer_t value = 0;
// #ifdef SPARC
//     // assume big endian (i.e. SPARC V9 target)
//     for(int i = size-1; i >= 0; i--) {
// #else
//     // assume little endian (i.e. x86 target)
//     for(int i = 0; i<size; i++) {
// #endif
//       integer_t mask = buffer[buffer_pos++];
//       value |= ((mask)<<(i<<3));
//     }
//
//
// //     SIM_write_phys_memory( obj, start, value, size);  // Maurice
// //     int isexcept = SIM_get_pending_exception();  // Maurice
//     if ( !(isexcept == SimExc_No_Exception || isexcept == SimExc_Break) ) {
// //       sim_exception_t except_code = SIM_clear_exception();  // Maurice
//       WARN_MSG( "SIMICS_write_physical_memory_buffer: raised exception." );
// //       WARN_MSG( SIM_last_error() );  // Maurice
//       WARN_MSG( addr );
//     }
//
//     len -= size;
//     start += size;
//   } while(len != 0);
  assert(0);
}

bool SIMICS_check_memory_value(int procID, physical_address_t addr,
                               char* buffer, int len) {
  char buf[len];
  SIMICS_read_physical_memory_buffer(procID, addr, buf, len);
  assert(0);
  return (memcmp(buffer, buf, len) == 0)? true:false;
}

physical_address_t SIMICS_translate_address( int procID, Address address ) {
//   SIM_clear_exception();        // Maurice
//   physical_address_t physical_addr = SIM_logical_to_physical(SIM_proc_no_2_ptr(procID), Sim_DI_Instruction, address.getAddress() );  // Maurice
//   int isexcept = SIM_get_pending_exception();  // Maurice
//  if ( !(isexcept == SimExc_No_Exception || isexcept == SimExc_Break) ) {
//     sim_exception_t except_code = SIM_clear_exception();  // Maurice
//     /*
//     WARN_MSG( "SIMICS_translate_address: raised exception." );
//     WARN_MSG( procID );
//     WARN_MSG( address );
// //     WARN_MSG( SIM_last_error() );  // Maurice
//     */
//     return 0;
//   }
//
// #ifdef CONTIGUOUS_ADDRESSES
//   if(g_p_ca_translator != NULL) {
//     physical_addr = g_p_ca_translator->TranslateSimicsToRuby( physical_addr );
//   }
// #endif // #ifdef CONTIGUOUS_ADDRESSES
//
//   return physical_addr;
  assert(0);
  return 0;
}

physical_address_t SIMICS_translate_data_address( int procID, Address address ) {
//   SIM_clear_exception();        // Maurice
//   physical_address_t physical_addr = SIM_logical_to_physical(SIM_proc_no_2_ptr(procID), Sim_DI_Data, address.getAddress() );  // Maurice
//   int isexcept = SIM_get_pending_exception();  // Maurice
//  if ( !(isexcept == SimExc_No_Exception || isexcept == SimExc_Break) ) {
//     sim_exception_t except_code = SIM_clear_exception();  // Maurice
    /*
    WARN_MSG( "SIMICS_translate_data_address: raised exception." );
    WARN_MSG( procID );
    WARN_MSG( address );
//     WARN_MSG( SIM_last_error() );  // Maurice
    */
//  }
//  return physical_addr;
  assert(0);
  return 0;
}

#ifdef SPARC
bool SIMICS_is_ldda(const memory_transaction_t *mem_trans) {
//  void *cpu  = mem_trans->s.ini_ptr;
//  int            proc= SIMICS_get_proc_no(cpu);
//  Address        addr = SIMICS_get_program_counter(cpu);
//  physical_address_t phys_addr = SIMICS_translate_address( proc, addr );
//  uint32         instr= SIMICS_read_physical_memory( proc, phys_addr, 4 );
//
//  // determine if this is a "ldda" instruction (non-exclusive atomic)
//  // ldda bit mask:  1100 0001 1111 1000 == 0xc1f80000
//  // ldda match   :  1100 0000 1001 1000 == 0xc0980000
//  if ( (instr & 0xc1f80000) == 0xc0980000 ) {
//    // should exactly be ldda instructions
//    ASSERT(!strncmp(SIMICS_disassemble_physical(proc, phys_addr), "ldda", 4));
//    //cout << "SIMICS_is_ldda END" << endl;
//    return true;
//   }
//   return false;
  assert(0);
  return false;
}
#endif

const char *SIMICS_disassemble_physical( int procID, physical_address_t pa ) {
//#ifdef CONTIGUOUS_ADDRESSES
//  if(g_p_ca_translator != NULL) {
//    pa = g_p_ca_translator->TranslateRubyToSimics( pa );
//  }
//#endif // #ifdef CONTIGUOUS_ADDRESSES
//   return SIM_disassemble( SIM_proc_no_2_ptr(procID), pa , /* physical */ 0)->string;  // Maurice
  assert(0);
  return "There is no spoon";
}

Address SIMICS_get_program_counter(void *cpu) {
  assert(cpu != NULL);
//   return Address(SIM_get_program_counter((processor_t *) cpu));  // Maurice
  assert(0);
  return Address(0);
}

Address SIMICS_get_npc(int procID) {
//   void *cpu = SIM_proc_no_2_ptr(procID);  // Maurice
//   return Address(SIM_read_register(cpu, SIM_get_register_number(cpu, "npc")));  // Maurice
  assert(0);
  return Address(0);
}

Address SIMICS_get_program_counter(int procID) {
//   void *cpu = SIM_proc_no_2_ptr(procID);  // Maurice
//  assert(cpu != NULL);

//   Address addr = Address(SIM_get_program_counter(cpu));  // Maurice
  assert(0);
  return Address(0);
}

// /* NOTE: SIM_set_program_counter sets NPC to PC+4 */  // Maurice
void SIMICS_set_program_counter(int procID, Address newPC) {
//   void *cpu = SIM_proc_no_2_ptr(procID);  // Maurice
//  assert(cpu != NULL);

//   SIM_stacked_post(cpu, ruby_set_program_counter, (void*) newPC.getAddress());  // Maurice
  assert(0);
}

void SIMICS_set_pc(int procID, Address newPC) {
  // IMPORTANT: procID is the SIMICS simulated proc number (takes into account SMT)
//   void *cpu = SIM_proc_no_2_ptr(procID);  // Maurice
//  assert(cpu != NULL);
//
//   if(OpalInterface::isOpalLoaded() == false){
// //     SIM_set_program_counter(cpu, newPC.getAddress());  // Maurice
//   } else {
//     // explicitly change PC
//     ruby_set_pc( cpu, (void *) newPC.getAddress() );
//   }
// //   int isexcept = SIM_get_pending_exception();  // Maurice
//   if ( !(isexcept == SimExc_No_Exception || isexcept == SimExc_Break) ) {
// //     sim_exception_t except_code = SIM_clear_exception();  // Maurice
//     WARN_MSG( "SIMICS_set_pc: raised exception." );
// //     WARN_MSG( SIM_last_error() );  // Maurice
//     ASSERT(0);
//   }
  assert(0);
}

void SIMICS_set_next_program_counter(int procID, Address newNPC) {
//   void *cpu = SIM_proc_no_2_ptr(procID);  // Maurice
//  assert(cpu != NULL);

//   SIM_stacked_post(cpu, ruby_set_npc, (void*) newNPC.getAddress());  // Maurice
  assert(0);
}

void SIMICS_set_npc(int procID, Address newNPC) {
//   void *cpu = SIM_proc_no_2_ptr(procID);  // Maurice
//   assert(cpu != NULL);
//
//   if(OpalInterface::isOpalLoaded() == false){
// //     SIM_write_register(cpu, SIM_get_register_number(cpu, "npc"), newNPC.getAddress());  // Maurice
//   } else {
//     // explicitly change NPC
//     ruby_set_npc( cpu, (void *) newNPC.getAddress() );
//   }
//
// //   int isexcept = SIM_get_pending_exception();  // Maurice
//   if ( !(isexcept == SimExc_No_Exception || isexcept == SimExc_Break) ) {
// //     sim_exception_t except_code = SIM_clear_exception();  // Maurice
//     WARN_MSG( "SIMICS_set_npc: raised exception " );
// //     WARN_MSG( SIM_last_error() );  // Maurice
//     ASSERT(0);
//   }
  assert(0);
}

void SIMICS_post_continue_execution(int procID){
//   void *cpu = SIM_proc_no_2_ptr(procID);  // Maurice
//   assert(cpu != NULL);
//
//   if(OpalInterface::isOpalLoaded() == false){
// //     SIM_stacked_post(cpu, ruby_continue_execution, (void *) NULL);  // Maurice
//   } else{
//     ruby_continue_execution( cpu, (void *) NULL );
//   }
  assert(0);
}

void SIMICS_post_restart_transaction(int procID){
//   void *cpu = SIM_proc_no_2_ptr(procID);  // Maurice
//   assert(cpu != NULL);
//
//   if(OpalInterface::isOpalLoaded() == false){
// //     SIM_stacked_post(cpu, ruby_restart_transaction, (void *) NULL);  // Maurice
//   } else{
//     ruby_restart_transaction( cpu, (void *) NULL );
//   }
  assert(0);
}

// return -1 when fail
int SIMICS_get_proc_no(void *cpu) {
//   int proc_no = SIM_get_proc_no((processor_t *) cpu);  // Maurice
//  return proc_no;
  assert(0);
   return -1;
}

void SIMICS_disable_processor( int cpuNumber ) {
//   if(SIM_cpu_enabled(SIMICS_get_proc_ptr(cpuNumber))) {  // Maurice
//     SIM_disable_processor(SIMICS_get_proc_ptr(cpuNumber));  // Maurice
//   } else {
//     WARN_MSG(cpuNumber);
//     WARN_MSG( "Tried to disable a 'disabled' processor");
//     ASSERT(0);
//   }
  assert(0);
}

void SIMICS_post_disable_processor( int cpuNumber ) {
//   SIM_stacked_post(SIMICS_get_proc_ptr(cpuNumber), ruby_disable_processor, (void*) NULL);  // Maurice
  assert(0);
}

void SIMICS_enable_processor( int cpuNumber ) {
//   if(!SIM_cpu_enabled(SIMICS_get_proc_ptr(cpuNumber))) {  // Maurice
//     SIM_enable_processor(SIMICS_get_proc_ptr(cpuNumber));  // Maurice
//  } else {
//    WARN_MSG(cpuNumber);
//    WARN_MSG( "Tried to enable an 'enabled' processor");
//  }
  assert(0);
}

bool SIMICS_processor_enabled( int cpuNumber ) {
//   return SIM_cpu_enabled(SIMICS_get_proc_ptr(cpuNumber));  // Maurice
  assert(0);
  return false;
}

// return NULL when fail
void* SIMICS_get_proc_ptr(int cpuNumber) {
//   return (void *) SIM_proc_no_2_ptr(cpuNumber);  // Maurice
  assert(0);
  return NULL;
}

void SIMICS_print_version(ostream& out) {
//   const char* version = SIM_version();  // Maurice
//  if (version != NULL) {
//     out << "simics_version: " << SIM_version() << endl;  // Maurice
//  }
  out << "Mwa ha ha this is not Simics!!";
}

// KM -- From Nikhil's SN code
//these functions should be in interface.C ??

uinteger_t SIMICS_read_control_register(int cpuNumber, int registerNumber)
{
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   uinteger_t result = SIM_read_register(cpu, registerNumber);  // Maurice
//  return result;
  assert(0);
  return 0;
}

uinteger_t SIMICS_read_window_register(int cpuNumber, int window, int registerNumber)
{
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   uinteger_t result = SIM_read_register(cpu, registerNumber);  // Maurice
//  return result;
  assert(0);
  return 0;
}

uinteger_t SIMICS_read_global_register(int cpuNumber, int globals, int registerNumber)
{
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   uinteger_t result = SIM_read_register(cpu, registerNumber);  // Maurice
//  return result;
  assert(0);
  return 0;
}

/**
   uint64 SIMICS_read_fp_register_x(int cpuNumber, int registerNumber)
   {
//    processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//    return SIM_read_fp_register_x(cpu, registerNumber);  // Maurice
   }
**/

void SIMICS_write_control_register(int cpuNumber, int registerNumber, uinteger_t value)
{
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   SIM_write_register(cpu, registerNumber, value);  // Maurice
  assert(0);
}

void SIMICS_write_window_register(int cpuNumber, int window, int registerNumber, uinteger_t value)
{
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   SIM_write_register(cpu, registerNumber, value);  // Maurice
  assert(0);
}

void SIMICS_write_global_register(int cpuNumber, int globals, int registerNumber, uinteger_t value)
{
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   SIM_write_register(cpu, registerNumber, value);  // Maurice
  assert(0);
}

/***
    void SIMICS_write_fp_register_x(int cpuNumber, int registerNumber, uint64 value)
    {
//     processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//     SIM_write_fp_register_x(cpu, registerNumber, value);  // Maurice
    }
***/

// KM -- Functions using new APIs (update from Nikhil's original)

int SIMICS_get_register_number(int cpuNumber, const char * reg_name){
//   int result = SIM_get_register_number(SIM_proc_no_2_ptr(cpuNumber), reg_name);  // Maurice
//  return result;
  assert(0);
  return 0;
}

const char * SIMICS_get_register_name(int cpuNumber, int reg_num){
//   const char * result = SIM_get_register_name(SIM_proc_no_2_ptr(cpuNumber), reg_num);  // Maurice
//  return result;
  assert(0);
  return "Then we shall fight in the shade";
}

uinteger_t SIMICS_read_register(int cpuNumber, int registerNumber)
{
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   uinteger_t result = SIM_read_register(cpu, registerNumber);  // Maurice
//  return result;
  assert(0);
  return 0;
}

void SIMICS_write_register(int cpuNumber, int registerNumber, uinteger_t value)
{
//   processor_t* cpu = SIM_proc_no_2_ptr(cpuNumber);  // Maurice
//   SIM_write_register(cpu, registerNumber, value);  // Maurice
  assert(0);
}

// This version is called whenever we are about to jump to the SW handler
void ruby_set_pc(void *cpu, void *parameter){
//   physical_address_t paddr;
//   paddr = (physical_address_t) parameter;
//   // Simics' processor number
// //   int proc_no = SIM_get_proc_no((processor_t *) cpu);  // Maurice
//   int smt_proc_no = proc_no / RubyConfig::numberofSMTThreads();
// //   SIM_set_program_counter(cpu, paddr);  // Maurice
//   //cout << "ruby_set_pc setting cpu[ " << proc_no << " ] smt_cpu[ " << smt_proc_no << " ] PC[ " << hex << paddr << " ]" << dec << endl;
// //   physical_address_t newpc = SIM_get_program_counter(cpu);  // Maurice
// //   int pc_reg = SIM_get_register_number(cpu, "pc");  // Maurice
// //   int npc_reg = SIM_get_register_number( cpu, "npc");  // Maurice
// //   uinteger_t pc = SIM_read_register(cpu, pc_reg);  // Maurice
// //   uinteger_t npc = SIM_read_register(cpu, npc_reg);  // Maurice
//   //cout << "NEW PC[ 0x" << hex << newpc << " ]" << " PC REG[ 0x" << pc << " ] NPC REG[ 0x" << npc << " ]" << dec << endl;
//
//   if(XACT_MEMORY){
//     if( !OpalInterface::isOpalLoaded() ){
//       // using SimicsDriver
//       ASSERT( proc_no == smt_proc_no );
//       SimicsDriver *simics_intf = dynamic_cast<SimicsDriver*>(g_system_ptr->getDriver());
//       ASSERT( simics_intf );
//       simics_intf->notifyTrapStart( proc_no, Address(paddr), 0 /*dummy threadID*/, 0 /* Simics uses 1 thread */ );
//     }
//     else{
//       // notify Opal about changing pc to SW handler
//       //cout << "informing Opal via notifyTrapStart proc = " << proc_no << endl;
//       //g_system_ptr->getSequencer(smt_proc_no)->notifyTrapStart( proc_no, Address(paddr) );
//     }
//
//   if (XACT_DEBUG && XACT_DEBUG_LEVEL > 1){
//     cout <<  g_eventQueue_ptr->getTime() << " " << proc_no
//        << " ruby_set_pc PC: " << hex
// //        << SIM_get_program_counter(cpu) <<   // Maurice
// //       " NPC is: " << hex << SIM_read_register(cpu, 33) << " pc_val: " << paddr << dec << endl;   // Maurice
//   }
//   }
  assert(0);
}

// This version is called whenever we are about to return from SW handler
void ruby_set_program_counter(void *cpu, void *parameter){
//  physical_address_t paddr;
//  paddr = (physical_address_t) parameter;
//  // Simics' processor number
////   int proc_no = SIM_get_proc_no((processor_t *) cpu);  // Maurice
//  // SMT proc number
//  int smt_proc_no = proc_no / RubyConfig::numberofSMTThreads();
//
////   // SIM_set_program_counter() also sets the NPC to PC+4.   // Maurice
//  // Need to ensure that NPC doesn't change especially for PCs in the branch delay slot
////   uinteger_t npc_val = SIM_read_register(cpu, SIM_get_register_number(cpu, "npc"));  // Maurice
////   SIM_set_program_counter(cpu, paddr);  // Maurice
////   SIM_write_register(cpu, SIM_get_register_number(cpu, "npc"), npc_val);  // Maurice
//
//  //LUKE - notify Opal of PC change (ie end of all register updates and abort complete)
//  //          I moved the register checkpoint restoration to here also, to jointly update the PC and the registers at the same time
//  if(XACT_MEMORY){
//    if( !OpalInterface::isOpalLoaded() ){
//      //using SimicsDriver
//      //we should only be running with 1 thread with Simics
//      ASSERT( proc_no == smt_proc_no );
//      SimicsDriver *simics_intf = dynamic_cast<SimicsDriver*>(g_system_ptr->getDriver());
//      ASSERT( simics_intf );
//      simics_intf->notifyTrapComplete(proc_no, Address( paddr ), 0 /* Simics uses 1 thread */ );
//   }
//   else{
//     //using OpalInterface
//     // g_system_ptr->getSequencer(smt_proc_no)->notifyTrapComplete( proc_no, Address(paddr) );
//   }
//  }
//  if (XACT_DEBUG && XACT_DEBUG_LEVEL > 1){
//    cout <<  g_eventQueue_ptr->getTime() << " " << proc_no
//       << " ruby_set_program_counter PC: " << hex
////        << SIM_get_program_counter(cpu) <<   // Maurice
////       " NPC is: " << hex << SIM_read_register(cpu, 33) << " pc_val: " << paddr << " npc_val: " << npc_val << dec << endl;   // Maurice
//  }
  assert(0);
}

void ruby_set_npc(void *cpu, void *parameter){
//   physical_address_t paddr;
//   paddr = (physical_address_t) parameter;
// //   int proc_no = SIM_get_proc_no((processor_t *) cpu);  // Maurice
//   // SMT proc number
//   int smt_proc_no = proc_no / RubyConfig::numberofSMTThreads();
//
// //   SIM_write_register(cpu, SIM_get_register_number(cpu, "npc"), paddr);  // Maurice
//   if (XACT_DEBUG && XACT_DEBUG_LEVEL > 1){
//     cout <<  g_eventQueue_ptr->getTime() << " " << proc_no
//          << " ruby_set_npc val: " << hex << paddr << " PC: " << hex
// //        << SIM_get_program_counter(cpu) <<   // Maurice
// //       " NPC is: " << hex << SIM_read_register(cpu, 33) << dec << endl;   // Maurice
//   }
  assert(0);
}

void ruby_continue_execution(void *cpu, void *parameter){
//   int logical_proc_no = SIM_get_proc_no((processor_t *) cpu);  // Maurice
//  int thread = logical_proc_no % RubyConfig::numberofSMTThreads();
//  int proc_no = logical_proc_no / RubyConfig::numberofSMTThreads();
//  g_system_ptr->getTransactionInterfaceManager(proc_no)->continueExecutionCallback(thread);
  assert(0);
}

void ruby_restart_transaction(void *cpu, void *parameter){
//   int logical_proc_no = SIM_get_proc_no((processor_t *) cpu);  // Maurice
//  int thread = logical_proc_no % RubyConfig::numberofSMTThreads();
//  int proc_no = logical_proc_no / RubyConfig::numberofSMTThreads();
//  g_system_ptr->getTransactionInterfaceManager(proc_no)->restartTransactionCallback(thread);
  assert(0);
}

void ruby_stall_proc(void *cpu, void *parameter){
//   int logical_proc_no = SIM_get_proc_no((processor_t*)cpu);  // Maurice
//  int cycles          = (uint64)parameter;

//  SIMICS_stall_proc(logical_proc_no, cycles);
  assert(0);
}

void ruby_disable_processor(void *cpu, void *parameter){
//   int logical_proc_no = SIM_get_proc_no((processor_t*)cpu);  // Maurice
//  SIMICS_disable_processor(logical_proc_no);
  assert(0);
}