timer_a9global.cc (12077:3c014d139dc7) | timer_a9global.cc (13230:2988dc5d1d6f) |
---|---|
1/* 2 * Copyright (c) 2017 Gedare Bloom 3 * Copyright (c) 2010 ARM Limited 4 * All rights reserved 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating --- 80 unchanged lines hidden (view full) --- 89{ 90 DPRINTF(Timer, "Reading from A9GlobalTimer at offset: %#x\n", daddr); 91 uint64_t time; 92 93 switch(daddr) { 94 case CounterRegLow32: 95 time = getTimeCounterFromTicks(curTick()); 96 DPRINTF(Timer, "-- returning lower 32-bits of counter: %u\n", time); | 1/* 2 * Copyright (c) 2017 Gedare Bloom 3 * Copyright (c) 2010 ARM Limited 4 * All rights reserved 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating --- 80 unchanged lines hidden (view full) --- 89{ 90 DPRINTF(Timer, "Reading from A9GlobalTimer at offset: %#x\n", daddr); 91 uint64_t time; 92 93 switch(daddr) { 94 case CounterRegLow32: 95 time = getTimeCounterFromTicks(curTick()); 96 DPRINTF(Timer, "-- returning lower 32-bits of counter: %u\n", time); |
97 pkt->set | 97 pkt->setLE<uint32_t>(time); |
98 break; 99 case CounterRegHigh32: 100 time = getTimeCounterFromTicks(curTick()); 101 time >>= 32; 102 DPRINTF(Timer, "-- returning upper 32-bits of counter: %u\n", time); | 98 break; 99 case CounterRegHigh32: 100 time = getTimeCounterFromTicks(curTick()); 101 time >>= 32; 102 DPRINTF(Timer, "-- returning upper 32-bits of counter: %u\n", time); |
103 pkt->set | 103 pkt->setLE<uint32_t>(time); |
104 break; 105 case ControlReg: | 104 break; 105 case ControlReg: |
106 pkt->set | 106 pkt->setLE<uint32_t>(control); |
107 break; 108 case IntStatusReg: | 107 break; 108 case IntStatusReg: |
109 pkt->set | 109 pkt->setLE<uint32_t>(rawInt); |
110 break; 111 case CmpValRegLow32: 112 DPRINTF(Timer, "Event schedule for %d, clock=%d, prescale=%d\n", 113 cmpValEvent.when(), parent->clockPeriod(), control.prescalar); 114 if (cmpValEvent.scheduled()) { 115 time = getTimeCounterFromTicks(cmpValEvent.when() - curTick()); 116 } else { 117 time = 0; 118 } 119 DPRINTF(Timer, "-- returning lower 32-bits of comparator: %u\n", time); | 110 break; 111 case CmpValRegLow32: 112 DPRINTF(Timer, "Event schedule for %d, clock=%d, prescale=%d\n", 113 cmpValEvent.when(), parent->clockPeriod(), control.prescalar); 114 if (cmpValEvent.scheduled()) { 115 time = getTimeCounterFromTicks(cmpValEvent.when() - curTick()); 116 } else { 117 time = 0; 118 } 119 DPRINTF(Timer, "-- returning lower 32-bits of comparator: %u\n", time); |
120 pkt->set | 120 pkt->setLE<uint32_t>(time); |
121 break; 122 case CmpValRegHigh32: 123 DPRINTF(Timer, "Event schedule for %d, clock=%d, prescale=%d\n", 124 cmpValEvent.when(), parent->clockPeriod(), control.prescalar); 125 if (cmpValEvent.scheduled()) { 126 time = getTimeCounterFromTicks(cmpValEvent.when() - curTick()); 127 time >>= 32; 128 } else { 129 time = 0; 130 } 131 DPRINTF(Timer, "-- returning upper 32-bits of comparator: %u\n", time); | 121 break; 122 case CmpValRegHigh32: 123 DPRINTF(Timer, "Event schedule for %d, clock=%d, prescale=%d\n", 124 cmpValEvent.when(), parent->clockPeriod(), control.prescalar); 125 if (cmpValEvent.scheduled()) { 126 time = getTimeCounterFromTicks(cmpValEvent.when() - curTick()); 127 time >>= 32; 128 } else { 129 time = 0; 130 } 131 DPRINTF(Timer, "-- returning upper 32-bits of comparator: %u\n", time); |
132 pkt->set | 132 pkt->setLE<uint32_t>(time); |
133 break; 134 case AutoIncrementReg: | 133 break; 134 case AutoIncrementReg: |
135 pkt->set | 135 pkt->setLE<uint32_t>(autoIncValue); |
136 break; 137 default: 138 panic("Tried to read A9GlobalTimer at offset %#x\n", daddr); 139 break; 140 } 141 DPRINTF(Timer, "Reading %#x from A9GlobalTimer at offset: %#x\n", | 136 break; 137 default: 138 panic("Tried to read A9GlobalTimer at offset %#x\n", daddr); 139 break; 140 } 141 DPRINTF(Timer, "Reading %#x from A9GlobalTimer at offset: %#x\n", |
142 pkt->get | 142 pkt->getLE<uint32_t>(), daddr); |
143} 144 145Tick 146A9GlobalTimer::write(PacketPtr pkt) 147{ 148 assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 149 assert(pkt->getSize() == 4); 150 Addr daddr = pkt->getAddr() - pioAddr; --- 9 unchanged lines hidden (view full) --- 160 pkt->makeAtomicResponse(); 161 return pioDelay; 162} 163 164void 165A9GlobalTimer::Timer::write(PacketPtr pkt, Addr daddr) 166{ 167 DPRINTF(Timer, "Writing %#x to A9GlobalTimer at offset: %#x\n", | 143} 144 145Tick 146A9GlobalTimer::write(PacketPtr pkt) 147{ 148 assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 149 assert(pkt->getSize() == 4); 150 Addr daddr = pkt->getAddr() - pioAddr; --- 9 unchanged lines hidden (view full) --- 160 pkt->makeAtomicResponse(); 161 return pioDelay; 162} 163 164void 165A9GlobalTimer::Timer::write(PacketPtr pkt, Addr daddr) 166{ 167 DPRINTF(Timer, "Writing %#x to A9GlobalTimer at offset: %#x\n", |
168 pkt->get | 168 pkt->getLE<uint32_t>(), daddr); |
169 switch (daddr) { 170 case CounterRegLow32: 171 case CounterRegHigh32: 172 DPRINTF(Timer, "Ignoring unsupported write to Global Timer Counter\n"); 173 break; 174 case ControlReg: 175 bool old_enable; 176 bool old_cmpEnable; 177 old_enable = control.enable; 178 old_cmpEnable = control.cmpEnable; | 169 switch (daddr) { 170 case CounterRegLow32: 171 case CounterRegHigh32: 172 DPRINTF(Timer, "Ignoring unsupported write to Global Timer Counter\n"); 173 break; 174 case ControlReg: 175 bool old_enable; 176 bool old_cmpEnable; 177 old_enable = control.enable; 178 old_cmpEnable = control.cmpEnable; |
179 control = pkt->get | 179 control = pkt->getLE<uint32_t>(); |
180 if ((old_enable == 0) && control.enable) 181 restartCounter(); 182 if ((old_cmpEnable == 0) && control.cmpEnable) 183 restartCounter(); 184 break; 185 case IntStatusReg: 186 /* TODO: should check that '1' was written. */ 187 rawInt = false; 188 if (pendingInt) { 189 pendingInt = false; 190 DPRINTF(Timer, "Clearing interrupt\n"); 191 parent->gic->clearInt(intNum); 192 } 193 break; 194 case CmpValRegLow32: 195 cmpVal &= 0xFFFFFFFF00000000ULL; | 180 if ((old_enable == 0) && control.enable) 181 restartCounter(); 182 if ((old_cmpEnable == 0) && control.cmpEnable) 183 restartCounter(); 184 break; 185 case IntStatusReg: 186 /* TODO: should check that '1' was written. */ 187 rawInt = false; 188 if (pendingInt) { 189 pendingInt = false; 190 DPRINTF(Timer, "Clearing interrupt\n"); 191 parent->gic->clearInt(intNum); 192 } 193 break; 194 case CmpValRegLow32: 195 cmpVal &= 0xFFFFFFFF00000000ULL; |
196 cmpVal |= (uint64_t)pkt->get | 196 cmpVal |= (uint64_t)pkt->getLE<uint32_t>(); |
197 break; 198 case CmpValRegHigh32: 199 cmpVal &= 0x00000000FFFFFFFFULL; | 197 break; 198 case CmpValRegHigh32: 199 cmpVal &= 0x00000000FFFFFFFFULL; |
200 cmpVal |= ((uint64_t)pkt->get | 200 cmpVal |= ((uint64_t)pkt->getLE<uint32_t>() << 32); |
201 break; 202 case AutoIncrementReg: | 201 break; 202 case AutoIncrementReg: |
203 autoIncValue = pkt->get | 203 autoIncValue = pkt->getLE<uint32_t>(); |
204 break; 205 default: 206 panic("Tried to write A9GlobalTimer at offset %#x\n", daddr); 207 break; 208 } 209} 210 211void --- 108 unchanged lines hidden --- | 204 break; 205 default: 206 panic("Tried to write A9GlobalTimer at offset %#x\n", daddr); 207 break; 208 } 209} 210 211void --- 108 unchanged lines hidden --- |