1 //
2 // Copyright (c) 2010-2018 Antmicro
3 // Copyright (c) 2011-2015 Realtime Embedded
4 //
5 // This file is licensed under the MIT License.
6 // Full license text is available in 'licenses/MIT.txt'.
7 //
8 using System;
9 using Antmicro.Renode.Core;
10 using Antmicro.Renode.Peripherals.Bus;
11 using Antmicro.Renode.Logging;
12 
13 namespace Antmicro.Renode.Peripherals.Video
14 {
15     public class TegraSyncpts : IDoubleWordPeripheral, IKnownSize
16     {
TegraSyncpts(IMachine machine)17         public TegraSyncpts(IMachine machine)
18         {
19   //          this.machine = machine;
20 
21 //            sync = new object();
22 
23             sync_pts = new uint[23];
24             for (int i = 0; i < sync_pts.Length; i++) sync_pts[i] = 0;
25         }
26 
27         public long Size
28         {
29             get
30             {
31                 return 0x4000;
32             }
33         }
34 
WriteDoubleWord(long address, uint value)35         public void WriteDoubleWord(long address, uint value)
36         {
37             this.Log(LogLevel.Warning, "Write to unknown offset {0:X}, value {1:X}",address,value);
38         }
39 
ReadDoubleWord(long offset)40         public uint ReadDoubleWord(long offset)
41         {
42             if ((offset >= 0x3400) && (offset <= 0x3458)) {
43                        uint sync_id = (uint)((offset - 0x3400) / 4);
44                        sync_pts[sync_id] += 1;
45                        return sync_pts[sync_id];
46             }
47             switch (offset) {
48                case 0x3040: // HOST1X_SYNC_SYNCPT_THRESH_CPU0_INT_STATUS_0
49                        this.Log(LogLevel.Warning, "Read from CPU0_INT_STATUS");
50                        return (1<<22) | (1<<13);
51                default:
52                        this.Log(LogLevel.Warning, "Read from unknown offset {0:X}, returning 0",offset);
53                        break;
54             }
55             return 0;
56         }
57 
Reset()58         public void Reset() {
59         }
60 
61         uint[] sync_pts;
62 
63 //        private object sync;
64 
65 //        private readonly IMachine machine;
66     }
67 }
68 
69