summaryrefslogtreecommitdiffstats
path: root/src/build/debug/Hostboot/BlData.pm
blob: 91d2f89d318c60063712accbc3d6eb63d87d66da (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/build/debug/Hostboot/BlData.pm $
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2017
# [+] International Business Machines Corp.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG

use strict;

package Hostboot::BlData;
use Exporter;
our @EXPORT_OK = ('main');

sub formatData
{
    my $data = shift;
    my $dataRaw = "";

    for (my $i = 0; $i < length($data); $i++)
    {
        my $dataHexStr = sprintf("%02X", ord(substr($data, $i, 1)));
        $dataRaw .= $dataHexStr;

        if ($i % 16 == 15)
        {
            $dataRaw .= "\n";
        }
        elsif ($i % 4 == 3)
        {
            $dataRaw .= "   ";
        }
    }

    return $dataRaw."\n";
}

sub main
{
    ::setBootloader();

    my $btLdrHrmor  = 0x0000000008200000;

    my ($dataSym, $dataSize) = ::findSymbolAddress("Bootloader::g_blData");
    if (not defined $dataSym) { ::userDisplay "Cannot find symbol.\n"; die; }
    my $dataSymStr = sprintf("0x%08X", $dataSym);

    ::userDisplay "------------Bootloader Data------------";
    ::userDisplay "\nData Symbol Address: ";
    ::userDisplay $dataSymStr;

    my ($scratchSym, $scratchSize) =
        ::findSymbolAddress("Bootloader::g_blScratchSpace");
    if (not defined $scratchSym) { ::userDisplay "Cannot find symbol.\n"; die; }
    my $scratchSymStr = sprintf("0x%08X", $scratchSym);

    ::userDisplay "\nScratch Space Symbol Address: ";
    ::userDisplay $scratchSymStr;
    ::userDisplay "\n--------------------------------------------\n";

    my $dataAddr = 0x0000000008208000;

    my $traceAddr = $dataAddr;
    my $traceAddrStr = sprintf("0x%08X", $traceAddr);
    ::sendIPCMsg("read-data", "$traceAddr,64"); # Trace buffer is 64 bytes
    my ($type1, $trace) = ::recvIPCMsg();
    my $traceData = formatData($trace);

    ::userDisplay "\nTrace Buffer Address: ";
    ::userDisplay $traceAddrStr;
    ::userDisplay "\n\nTrace Data:\n";
    ::userDisplay $traceData;
    ::userDisplay "\n--------------------------------------------\n";


    my $indexAddr = $dataAddr + 64;
    my $indexAddrStr = sprintf("0x%08X", $indexAddr);
    ::sendIPCMsg("read-data", "$indexAddr,1"); # Trace index is 1 byte
    my ($type2, $index) = ::recvIPCMsg();
    $index =~ s/\0+//g; #strip off nulls
    my $indexStr = sprintf("0x%02X", ord($index));

    ::userDisplay "\nTrace Index Address: ";
    ::userDisplay $indexAddrStr;
    ::userDisplay "\n\nTrace Index (Next Entry): ";
    ::userDisplay $indexStr;
    ::userDisplay "\n\n--------------------------------------------\n";


    my $tiDataAreaAddr = $dataAddr + 80;
    my $tiDataAreaAddrStr = sprintf("0x%08X", $tiDataAreaAddr);
    ::sendIPCMsg("read-data", "$tiDataAreaAddr,48"); # TI Data Area is 48 bytes
    my ($type6, $tiDataArea) = ::recvIPCMsg();
    my $tiDataAreaData = formatData($tiDataArea);

    ::userDisplay "\nTI Data Area Address: ";
    ::userDisplay $tiDataAreaAddrStr;
    ::userDisplay "\n\nTI Data Area:\n";
    ::userDisplay $tiDataAreaData;
    ::userDisplay "\n--------------------------------------------\n";


    my $hbbPnorSecAddr = $dataAddr + 128;
    my $hbbPnorSecAddrStr = sprintf("0x%08X", $hbbPnorSecAddr);
    ::sendIPCMsg("read-data", "$hbbPnorSecAddr,32"); # Section data is 32 bytes
    my ($type5, $hbbPnorSec) = ::recvIPCMsg();
    my $hbbPnorSecData = formatData($hbbPnorSec);

    ::userDisplay "\nHBB PNOR Section Data Address: ";
    ::userDisplay $hbbPnorSecAddrStr;
    ::userDisplay "\n\nHBB PNOR Section Data:\n";
    ::userDisplay $hbbPnorSecData;
    ::userDisplay "\n--------------------------------------------\n";


    my $secRomValAddr = $dataAddr + 160;
    my $secRomValAddrStr = sprintf("0x%08X", $secRomValAddr);
    ::sendIPCMsg("read-data", "$secRomValAddr,1"); # Secure ROM Valid is 1 byte
    my ($type4, $secRomVal) = ::recvIPCMsg();
    $secRomVal =~ s/\0+//g; #strip off nulls
    my $secRomValStr = sprintf("0x%02X", ord($secRomVal));

    ::userDisplay "\nSecure ROM Valid Address: ";
    ::userDisplay $secRomValAddrStr;
    ::userDisplay "\n\nSecure ROM Valid: ";
    ::userDisplay $secRomValStr;
    ::userDisplay "\n\n--------------------------------------------\n";


    my $blToHbAddr = $dataAddr + 176;
    my $blToHbAddrStr = sprintf("0x%08X", $blToHbAddr);
    ::sendIPCMsg("read-data", "$blToHbAddr,89"); # BL to HB data is 89 bytes
    my ($type3, $blToHb) = ::recvIPCMsg();
    my $blToHbData = formatData($blToHb);

    ::userDisplay "\nBL to HB Data Address: ";
    ::userDisplay $blToHbAddrStr;
    ::userDisplay "\n\nBootloader to Hostboot Data:\n";
    ::userDisplay $blToHbData;
    ::userDisplay "\n--------------------------------------------\n";

    ::clearBootloader();
}

sub helpInfo
{
    my %info = (
        name => "BlData",
        intro => ["Displays Bootloader data."],
    );
}
OpenPOWER on IntegriCloud