summaryrefslogtreecommitdiff
path: root/riff/InitializeDut.h
blob: 6e0ab311427c5e9f8b65ad277fd71dca0698b34d (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
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * InitializeDut.h
 *
 * 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
 * @{
 */

#pragma once
#include "Command.h"
#include "Config.h"
#include "DUT.h"
#include <string>
#include <cstdio>
using namespace std;

struct tocSection {
    int start;
    int size;
    int flags;
    int align;
    int loadAddress;
    char filename[12];
};

/**
 * @brief Class implementing command for DUT initialization.
 */
class InitializeDut : public Command
{
public:
    /**
     * @brief Default constructor taking a config file path as parameter.
     */
    InitializeDut(const char* configPath);

    /**
     * @brief Method that executes the DUT initialization.
     *
     * This method initializes new LCD context and sets the DUT in service mode.
     *
     * @param[in] dut - Specific DUT instance on which to execute the command.
     * @return int    - Command execution error (0 on success, non-0 otherwise).
     */
    int run(DUT* dut);

    const char * get_command_name();

private:
    const char* configPath_;
    const char* isswPath_;
    const char* xloaderPath_;
    const char* meminitPath_;
    const char* pwrmgmtPath_;
    const char* normalPath_;

    char tocArea[512];
    tocSection issw_, xload_, meminit_, normal_, pwrMgt_;

    Logger logger_;

    int commWrite2kChunks(Device_t device, void* buffer, size_t size);
    int sendTocIssw(Device_t device);
    int createTocEntry(tocSection* issw, tocSection* xload, tocSection* meminit, tocSection* normal, tocSection* pwrMgt);
    int createTocFile(tocSection* toc, const char* filePath, const char* tocName, int* offset);
    int getFileSize(const char* filePath);
    int readIsswFile(char* buf);
    int readSecondIsswFile(char* buf);
    int readPwrMgtFile(char* buf);
    int readMeminitFile(char* buf);
    int readNormal(char* buf);
    int initializeHardware(Device_t device);

};

/* @} */