1/*
2 * Copyright (c) 2013-2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 72 unchanged lines hidden (view full) ---

81 writeLatency(p->write_lat),
82 eraseLatency(p->erase_lat),
83 dataDistribution(p->data_distribution),
84 numPlanes(p->num_planes),
85 pagesPerBlock(0),
86 pagesPerDisk(0),
87 blocksPerDisk(0),
88 planeMask(numPlanes - 1),
89 drainManager(NULL),
89 planeEventQueue(numPlanes),
90 planeEvent(this)
91{
92
93 /*
94 * Let 'a' be a power of two of n bits, written such that a-n is the msb
95 * and a-0 is the lsb. Since it is a power of two, only one bit (a-x,
96 * with 0 <= x <= n) is set. If we subtract one from this number the bits

--- 484 unchanged lines hidden (view full) ---

581 UNSERIALIZE_SCALAR(blockEmptyEntries[count]);
582
583};
584
585/**
586 * Drain; needed to enable checkpoints
587 */
588
590unsigned int
591FlashDevice::drain(DrainManager *dm)
589DrainState
590FlashDevice::drain()
591{
593 unsigned int count = 0;
594
592 if (planeEvent.scheduled()) {
596 count = 1;
597 drainManager = dm;
593 DPRINTF(Drain, "Flash device is draining...\n");
594 return DrainState::Draining;
595 } else {
596 DPRINTF(Drain, "Flash device in drained state\n");
597 return DrainState::Drained;
598 }
601
602 if (count) {
603 DPRINTF(Drain, "Flash device is draining...\n");
604 setDrainState(DrainState::Draining);
605 } else {
606 DPRINTF(Drain, "Flash device drained\n");
607 setDrainState(DrainState::Drained);
608 }
609 return count;
599}
600
601/**
602 * Checkdrain; needed to enable checkpoints
603 */
604
605void
606FlashDevice::checkDrain()
607{
619 if (drainManager == NULL) {
608 if (drainState() == DrainState::Draining)
609 return;
621 }
610
611 if (planeEvent.when() > curTick()) {
612 DPRINTF(Drain, "Flash device is still draining\n");
613 } else {
614 DPRINTF(Drain, "Flash device is done draining\n");
627 drainManager->signalDrainDone();
628 drainManager = NULL;
615 signalDrainDone();
616 }
617}