summaryrefslogtreecommitdiff
path: root/riff/DumpArea.cpp
blob: 2f7fcf6aa0c585e3611cc66f1028179087861e63 (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
/*
 * DumpArea.cpp
 *
 * Copyright (C) ST-Ericsson SA 2011
 * Authors: Srimanta Panda <srimanta.panda@stericsson.com>,
 *          Ola Borgelin <ola.borgelin@stericsson.com>,
 *          Karin Hedlund <karin.hedlund@stericsson.com>,
 *          Markus Andersson <markus.m.andersson@stericsson.com> for ST-Ericsson.
 * License terms: 3-clause BSD license
 *
 */

/*
 * @addtogroup Commands
 * @{
 */

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "DumpArea.h"
#include <stdlib.h>
#include <cstring>
#include "LCDriver.h"
using namespace flash;

DumpArea::DumpArea(const char* path, uint64 start, uint64 length, const char* filepath, uint32 redundant, int useBulk):
		logger_("DumpArea")
{
    pchPath = path;
    uiStart = start;
    uiLength = length;
    pchFilePath = filepath;
    uiRedundantArea = redundant;
    iUseBulk = useBulk;;
}

int DumpArea::run(DUT* dut)
{
	logger_.log(Logger::PROGRESS, "Dumping area...");
	logger_.log(Logger::PROGRESS, "Dump path is %s", pchFilePath);
	int error = checkInput();
	if (error == -1) {
		return error;
	}
	error = Flash_DumpArea(dut->getLCDContext(), pchPath, uiStart, uiLength, pchFilePath, uiRedundantArea, iUseBulk);
	if (0 != error)
	{
		logger_.log(Logger::ERROR,"LCD ERROR: Dump area failed %d", error);
		return error;
	}
	// Need a new line braek after the progress bar
        logger_.logRaw("\n");
	logger_.log(Logger::INFO, "Dump area finished successfully");
	return error;
}

int DumpArea::checkInput()
{
	if (uiLength <= 0) {
		logger_.log(Logger::ERROR, "Length of the dump not specified. Use -l or --length option");
		return -1;
	}
	return 0;
}

const char * DumpArea::get_command_name()
{
    return (char *)"DUMPAREA";
}


/* @} */