summaryrefslogtreecommitdiffstats
path: root/src/build/debug/Hostboot/PrintVMM.pm
blob: fcb3a223067ec0fca15d70fba8b4a967864340cc (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
#  IBM_PROLOG_BEGIN_TAG
#  This is an automatically generated prolog.
#
#  $Source: src/build/debug/Hostboot/PrintVMM.pm $
#
#  IBM CONFIDENTIAL
#
#  COPYRIGHT International Business Machines Corp. 2012
#
#  p1
#
#  Object Code Only (OCO) source materials
#  Licensed Internal Code Source Materials
#  IBM HostBoot Licensed Internal Code
#
#  The source code for this program is not published or other-
#  wise divested of its trade secrets, irrespective of what has
#  been deposited with the U.S. Copyright Office.
#
#  Origin: 30
#
#  IBM_PROLOG_END_TAGuse strict;

use strict;
use Hostboot::_DebugFrameworkVMM;
package Hostboot::PrintVMM;
use Exporter;
use integer;
our @EXPORT_OK = ('main');



sub main
{
    ::userDisplay "PrintVMM module.\n";

    my ($packName,$args) = @_;

    my $phyAddr = Hostboot::_DebugFrameworkVMM::NotFound;
    my $debug = 0;
    my $displaySPTE = 0;
    my $displayAll = 1;
    my $displayBase = 0;
    my $displayStack = 0;
    my $displayDevice = 0;

    if (defined $args->{"debug"})
    {
        $debug = 1;
    }

    if (defined $args->{"base"})
    {
        $displayBase = 1;
        $displayAll = 0;
    }

    if (defined $args->{"stack"})
    {
        $displayStack = 1;
        $displayAll = 0;
    }

    if (defined $args->{"device"})
    {
        $displayDevice = 1;
        $displayAll = 0;
    }

    # Get the device segment address
    my @segment_manager_addr =
          ::findSymbolAddress("Singleton<SegmentManager>::instance()::instance");

    if (not defined @segment_manager_addr)
    {
	::userDisplay "   VirtualToPhy: Cannot find Device Segment symbol.\n"; die;
    }

    my $baseSegmentPtr =
         ::read64 ($segment_manager_addr[0] +
                   Hostboot::_DebugFrameworkVMM::SEGMGR_BASE_SEGMENT_OFFSET, 8);

    my $StackSegmentPtr =
         ::read64 ($segment_manager_addr[0] +
                   Hostboot::_DebugFrameworkVMM::SEGMGR_STACK_SEGMENT_OFFSET, 8);

    my $DeviceSegmentPtr = 
         ::read64 ($segment_manager_addr[0] + 
                   Hostboot::_DebugFrameworkVMM::SEGMGR_FIRSTDEVICE_SEGMENT_OFFSET, 8);

    if (($displayBase) || ($displayAll))
    {
        ::userDisplay "\n-------------\n";
        ::userDisplay "BASE SEGMENT\n";
        ::userDisplay "-------------\n";


        if ($baseSegmentPtr == 0)
        {
            ::userDisplay "   PrintVMM:  No Segment Pointer. Have you run yet?\n"; die;
        }

        Hostboot::_DebugFrameworkVMM::printBaseSegment($baseSegmentPtr);
    }

    if (($displayStack) || ($displayAll))
    {

        ::userDisplay "\n-------------\n";
        ::userDisplay "STACK SEGMENT\n";
        ::userDisplay "-------------\n";

        if ($StackSegmentPtr == 0)
        {
            ::userDisplay "   PrintVMM:  No Segment Pointer. Have you run yet?\n"; die;
        }

        my $StackSegBaseAddr = ::read64($StackSegmentPtr +
                                        Hostboot::_DebugFrameworkVMM::STACKSEGMENT_BASEADDR_OFFSET, 8);

        ::userDisplay (sprintf "   Stack Segment base addr=%X\n" , $StackSegBaseAddr);

        my $firststackptr = ::read64 ($StackSegmentPtr +
                                      Hostboot::_DebugFrameworkVMM::STACKSEGMENT_FIRST_STACK_OFFSET, 8);

        Hostboot::_DebugFrameworkVMM::printStackSegment($firststackptr);
  
     }

    if (($displayDevice) || ($displayAll))
    {

        ::userDisplay "\n---------------\n";
        ::userDisplay "DEVICE SEGMENTS\n";
        ::userDisplay "---------------\n";

        if ($DeviceSegmentPtr == 0)
        {
            ::userDisplay "   PrintVMM:  No Segment Pointer. Have you run yet?\n"; die;
        }
        #Pass in address of the pointer to the first device segment in the segment manager
        # This routine will loop through all possible device semgnets and print their info.  
        Hostboot::_DebugFrameworkVMM::printDeviceSegments($segment_manager_addr[0] +
                   Hostboot::_DebugFrameworkVMM::SEGMGR_FIRSTDEVICE_SEGMENT_OFFSET);


     }

 return 0;
}



sub helpInfo
{
    my %info = (
        name => "PrintVMM",
        intro => ["Print out the VMM mapping. "],
        options => {
                    "debug" => ["More debug output."],
                    "base" => ["Prints out BASE segment info."],
                    "stack" => ["Prints out STACK segment info."],
                    "device" => ["Prints out Device segment info."],
                   },

    );
}
OpenPOWER on IntegriCloud