io_device.cc (8832:247fee427324) | io_device.cc (8851:7e966326ef5b) |
---|---|
1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 41 unchanged lines hidden (view full) --- 50AddrRangeList 51PioPort::getAddrRanges() 52{ 53 return device->getAddrRanges(); 54} 55 56 57PioDevice::PioDevice(const Params *p) | 1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 41 unchanged lines hidden (view full) --- 50AddrRangeList 51PioPort::getAddrRanges() 52{ 53 return device->getAddrRanges(); 54} 55 56 57PioDevice::PioDevice(const Params *p) |
58 : MemObject(p), sys(p->system), pioPort(NULL) | 58 : MemObject(p), sys(p->system), pioPort(this, sys) |
59{} 60 61PioDevice::~PioDevice() 62{ | 59{} 60 61PioDevice::~PioDevice() 62{ |
63 if (pioPort) 64 delete pioPort; | |
65} 66 67void 68PioDevice::init() 69{ | 63} 64 65void 66PioDevice::init() 67{ |
70 if (!pioPort) | 68 if (!pioPort.isConnected()) |
71 panic("Pio port of %s not connected to anything!", name()); | 69 panic("Pio port of %s not connected to anything!", name()); |
72 pioPort->sendRangeChange(); | 70 pioPort.sendRangeChange(); |
73} 74 75Port * 76PioDevice::getPort(const std::string &if_name, int idx) 77{ 78 if (if_name == "pio") { | 71} 72 73Port * 74PioDevice::getPort(const std::string &if_name, int idx) 75{ 76 if (if_name == "pio") { |
79 if (pioPort != NULL) 80 fatal("%s: pio port already connected to %s", 81 name(), pioPort->getPeer()->name()); 82 pioPort = new PioPort(this, sys); 83 return pioPort; | 77 return &pioPort; |
84 } | 78 } |
79 panic("PioDevice %s has no port named %s\n", name(), if_name); |
|
85 return NULL; 86} 87 88unsigned int 89PioDevice::drain(Event *de) 90{ 91 unsigned int count; | 80 return NULL; 81} 82 83unsigned int 84PioDevice::drain(Event *de) 85{ 86 unsigned int count; |
92 count = pioPort->drain(de); | 87 count = pioPort.drain(de); |
93 if (count) 94 changeState(Draining); 95 else 96 changeState(Drained); 97 return count; 98} 99 100BasicPioDevice::BasicPioDevice(const Params *p) --- 79 unchanged lines hidden (view full) --- 180 } else { 181 panic("Got packet without sender state... huh?\n"); 182 } 183 184 return true; 185} 186 187DmaDevice::DmaDevice(const Params *p) | 88 if (count) 89 changeState(Draining); 90 else 91 changeState(Drained); 92 return count; 93} 94 95BasicPioDevice::BasicPioDevice(const Params *p) --- 79 unchanged lines hidden (view full) --- 175 } else { 176 panic("Got packet without sender state... huh?\n"); 177 } 178 179 return true; 180} 181 182DmaDevice::DmaDevice(const Params *p) |
188 : PioDevice(p), dmaPort(NULL) | 183 : PioDevice(p), dmaPort(this, sys, params()->min_backoff_delay, 184 params()->max_backoff_delay) |
189{ } 190 | 185{ } 186 |
187void 188DmaDevice::init() 189{ 190 if (!dmaPort.isConnected()) 191 panic("DMA port of %s not connected to anything!", name()); 192 PioDevice::init(); 193} 194 |
|
191unsigned int 192DmaDevice::drain(Event *de) 193{ 194 unsigned int count; | 195unsigned int 196DmaDevice::drain(Event *de) 197{ 198 unsigned int count; |
195 count = pioPort->drain(de) + dmaPort->drain(de); | 199 count = pioPort.drain(de) + dmaPort.drain(de); |
196 if (count) 197 changeState(Draining); 198 else 199 changeState(Drained); 200 return count; 201} 202 203unsigned int --- 153 unchanged lines hidden (view full) --- 357 } 358 359 } else 360 panic("Unknown memory command state."); 361} 362 363DmaDevice::~DmaDevice() 364{ | 200 if (count) 201 changeState(Draining); 202 else 203 changeState(Drained); 204 return count; 205} 206 207unsigned int --- 153 unchanged lines hidden (view full) --- 361 } 362 363 } else 364 panic("Unknown memory command state."); 365} 366 367DmaDevice::~DmaDevice() 368{ |
365 if (dmaPort) 366 delete dmaPort; | |
367} 368 369 370Port * 371DmaDevice::getPort(const std::string &if_name, int idx) 372{ 373 if (if_name == "dma") { | 369} 370 371 372Port * 373DmaDevice::getPort(const std::string &if_name, int idx) 374{ 375 if (if_name == "dma") { |
374 if (dmaPort != NULL) 375 fatal("%s: dma port already connected to %s", 376 name(), dmaPort->getPeer()->name()); 377 dmaPort = new DmaPort(this, sys, params()->min_backoff_delay, 378 params()->max_backoff_delay); 379 return dmaPort; | 376 return &dmaPort; |
380 } 381 return PioDevice::getPort(if_name, idx); 382} 383 | 377 } 378 return PioDevice::getPort(if_name, idx); 379} 380 |