summaryrefslogtreecommitdiff
path: root/libpeci/peci_cmds.c
blob: 9aafe063591451cd4c7def0a4617759e74be10bd (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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
/*
// Copyright (c) 2019 Intel Corporation
//
// 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.
*/
#include <inttypes.h>
#include <peci.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef ABS
#define ABS(_v_) (((_v_) > 0) ? (_v_) : -(_v_))
#endif

enum peci_cmd_subtype
{
    PECI_CMD_RD_END_PT_CFG_LOCAL_PCI = PECI_CMD_MAX + 1,
    PECI_CMD_RD_END_PT_CFG_PCI,
    PECI_CMD_RD_END_PT_CFG_MMIO,
    PECI_CMD_WR_END_PT_CFG_LOCAL_PCI,
    PECI_CMD_WR_END_PT_CFG_PCI,
};

extern EPECIStatus peci_GetDIB(uint8_t target, uint64_t* dib);

void Usage(char* progname)
{
    printf("Usage :\n");
    printf("\t%s [-a <addr>] [-s <size>] <command> [parameters]\n", progname);
    printf("\t\t-a  : Address of the target in decimal. Default is 48.\n");
    printf("\t\t-s  : Size of data to read or write in bytes. Default is 4.\n");
    printf("\t\t-b  : Display completion code.\n");
    printf("\t\t-n  : Ping the target.\n");
    printf("\t\t-t  : Get the temperature.\n");
    printf("\t\t-d  : Get the DIB.\n");
    printf(
        "\t\t-p  : PCI Read for specific hex address <Bus Dev Func [Reg]>.\n");
    printf("\t\t-pw : PCI Write for specific hex address <Bus Dev Func [Reg] "
           "Data>.\n");
    printf("\t\t-c  : Read Package Config <Index Parameter>.\n");
    printf("\t\t-cw : Write Package Config <Index Parameter Data>.\n");
    printf("\t\t-m  : MSR Read <Thread Address>.\n");
    printf("\t\t-l  : Local PCI Read for specific hex address <Bus Dev Func "
           "[Reg]>.\n");
    printf("\t\t-lw : Local PCI Write for specific hex address <Bus Dev Func "
           "[Reg] Data>.\n");
    printf("\t\t-e  : Endpoint Local PCI Config Read <Seg Bus Dev Func [Reg]>."
           "\n");
    printf("\t\t-ew : Endpoint Local PCI Config Write <Seg Bus Dev Func [Reg] "
           "Data>.\n");
    printf("\t\t-f  : Endpoint PCI Config Read <Seg Bus Dev Func [Reg]>.\n");
    printf("\t\t-fw : Endpoint PCI Config Write <Seg Bus Dev Func [Reg] Data>."
           "\n");
    printf("\t\t-g  : Endpoint MMIO Read <AType Bar Seg Bus Dev Func [Reg]>."
           "\n");
    printf("\n");
}

int main(int argc, char* argv[])
{
    int c;
    EPECIStatus ret;
    int cnt = 0;
    uint8_t u8Cmd = PECI_CMD_MAX;
    uint8_t address = 0x30; // use default address of 48d
    uint8_t u8Size = 4;     // default to a DWORD
    uint32_t u32PciReadVal = 0;
    uint8_t u8Seg = 0;
    uint8_t u8Bar = 0;
    uint8_t u8AddrType = 0;
    uint8_t u8PciBus = 0;
    uint8_t u8PciDev = 0;
    uint8_t u8PciFunc = 0;
    uint16_t u16PciReg = 0;
    uint64_t u64Offset = 0;
    uint32_t u32PciWriteVal = 0;
    uint8_t u8PkgIndex = 0;
    uint16_t u16PkgParam = 0;
    uint32_t u32PkgValue = 0;
    uint8_t u8MsrThread = 0;
    uint16_t u16MsrAddr = 0;
    uint64_t u64MsrVal = 0;
    short temperature;
    uint64_t dib;
    uint8_t u8Index = 0;
    uint8_t cc = 0;
    bool showCc = false;

    //
    // Parse arguments.
    //
    while (-1 != (c = getopt(argc, argv, "a:s:nbtdp::c::m::l::e::f::g")))
    {
        switch (c)
        {
            case 'a':
                if (optarg != NULL)
                    address = (unsigned char)atoi(optarg);
                break;

            case 's':
                if (optarg != NULL)
                    u8Size = (unsigned char)atoi(optarg);
                break;

            case 'b':
                showCc = true;
                break;

            case 'n':
                cnt++;
                u8Cmd = PECI_CMD_PING;
                break;

            case 't':
                cnt++;
                u8Cmd = PECI_CMD_GET_TEMP;
                break;

            case 'd':
                cnt++;
                u8Cmd = PECI_CMD_GET_DIB;
                break;

            case 'p':
                cnt++;
                u8Cmd = PECI_CMD_RD_PCI_CFG;
                if (optarg != NULL && optarg[0] == 'w')
                    u8Cmd = PECI_CMD_WR_PCI_CFG;
                break;

            case 'c':
                cnt++;
                u8Cmd = PECI_CMD_RD_PKG_CFG;
                if (optarg != NULL && optarg[0] == 'w')
                    u8Cmd = PECI_CMD_WR_PKG_CFG;
                break;

            case 'm':
                cnt++;
                u8Cmd = PECI_CMD_RD_IA_MSR;
                break;

            case 'l':
                cnt++;
                u8Cmd = PECI_CMD_RD_PCI_CFG_LOCAL;
                if (optarg != NULL && optarg[0] == 'w')
                    u8Cmd = PECI_CMD_WR_PCI_CFG_LOCAL;
                break;

            case 'e':
                cnt++;
                u8Cmd = PECI_CMD_RD_END_PT_CFG_LOCAL_PCI;
                if (optarg != NULL && optarg[0] == 'w')
                    u8Cmd = PECI_CMD_WR_END_PT_CFG_LOCAL_PCI;
                break;

            case 'f':
                cnt++;
                u8Cmd = PECI_CMD_RD_END_PT_CFG_PCI;
                if (optarg != NULL && optarg[0] == 'w')
                    u8Cmd = PECI_CMD_WR_END_PT_CFG_PCI;
                break;

            case 'g':
                cnt++;
                u8Cmd = PECI_CMD_RD_END_PT_CFG_MMIO;
                break;

            default:
                printf("ERROR: Unrecognized option \"-%c\".\n", optopt);
                goto ErrorExit;
                break;
        }
    }

    if (1 != cnt)
    {
        printf("ERROR: Invalid options.\n");
        goto ErrorExit;
    }

    //
    // Execute the command
    //
    printf("PECI target[%u]: ", (int)address);
    switch (u8Cmd)
    {
        case PECI_CMD_PING:
            printf("Pinging ... ");
            (0 == peci_Ping(address)) ? printf("Succeeded.\n")
                                      : printf("Failed.\n");
            break;

        case PECI_CMD_GET_TEMP:
            ret = peci_GetTemp(address, &temperature);
            if (0 != ret)
            {
                printf("ERROR: Retrieving temperature failed.\n");
                break;
            }
            printf("Temperature is %04xh (%c%d.%02dC).\n",
                   (int)(unsigned int)(unsigned short)temperature,
                   (0 > temperature) ? '-' : '+',
                   (int)((unsigned int)ABS(temperature) / 64),
                   (int)(((unsigned int)ABS(temperature) % 64) * 100) / 64);
            break;

        case PECI_CMD_GET_DIB:
            ret = peci_GetDIB(address, &dib);
            if (0 != ret)
            {
                printf("ERROR: Retrieving DIB failed.\n");
                break;
            }
            printf("GetDIB Returned: 0x%" PRIx64 "\n", dib);
            break;

        case PECI_CMD_RD_PCI_CFG:
            u8Index = argc;
            switch (argc - optind)
            {
                case 4:
                    u16PciReg = strtoul(argv[--u8Index], NULL, 16);
                case 3:
                    u8PciFunc = strtoul(argv[--u8Index], NULL, 16);
                case 2:
                    u8PciDev = strtoul(argv[--u8Index], NULL, 16);
                case 1:
                    u8PciBus = strtoul(argv[--u8Index], NULL, 16);
                    break;
                default:
                    printf("ERROR: Unsupported arguments for PCI Write\n");
                    goto ErrorExit;
                    break;
            }
            ret = peci_RdPCIConfig(address, u8PciBus, u8PciDev, u8PciFunc,
                                   u16PciReg, (uint8_t*)&u32PciReadVal, &cc);
            if (showCc)
                printf("PCI Read cc:0x%x\n", cc);
            if (0 != ret)
            {
                printf("ERROR: PCI Read failed or is not supported.\n");
                break;
            }
            printf("PCI Read of %02x:%02x:%02x Reg %02x: 0x%0*x\n", u8PciBus,
                   u8PciDev, u8PciFunc, u16PciReg, u8Size * 2, u32PciReadVal);
            break;

        case PECI_CMD_RD_PKG_CFG:
            u8Index = argc;
            switch (argc - optind)
            {
                case 2:
                    u16PkgParam = strtoul(argv[--u8Index], NULL, 16);
                    u8PkgIndex = strtoul(argv[--u8Index], NULL, 16);
                    break;
                default:
                    printf("ERROR: Unsupported arguments for Pkg Read\n");
                    goto ErrorExit;
                    break;
            }
            ret = peci_RdPkgConfig(address, u8PkgIndex, u16PkgParam, u8Size,
                                   (uint8_t*)&u32PkgValue, &cc);
            if (showCc)
                printf("Pkg Read cc:0x%x\n", cc);
            if (0 != ret)
            {
                printf("ERROR: Read Package failed or is not supported.\n");
                break;
            }
            printf("Pkg Read of Index %02x Param %04x: 0x%0*x\n", u8PkgIndex,
                   u16PkgParam, u8Size * 2, u32PkgValue);
            break;

        case PECI_CMD_WR_PKG_CFG:
            u8Index = argc;
            switch (argc - optind)
            {
                case 3:
                    u32PkgValue = strtoul(argv[--u8Index], NULL, 16);
                    u16PkgParam = strtoul(argv[--u8Index], NULL, 16);
                    u8PkgIndex = strtoul(argv[--u8Index], NULL, 16);
                    break;
                default:
                    printf("ERROR: Unsupported arguments for Pkg Write\n");
                    goto ErrorExit;
                    break;
            }
            printf("Pkg Write of Index %02x Param %04x: 0x%0*x\n", u8PkgIndex,
                   u16PkgParam, u8Size * 2, u32PkgValue);
            ret = peci_WrPkgConfig(address, u8PkgIndex, u16PkgParam,
                                   u32PkgValue, u8Size, &cc);
            if (showCc)
                printf("Pkg Write cc:0x%x\n", cc);
            (0 == ret) ? printf("Succeeded.\n")
                       : printf("Failed or not supported.\n");
            break;

        case PECI_CMD_RD_IA_MSR:
            u8Index = argc;
            switch (argc - optind)
            {
                case 2:
                    u16MsrAddr = strtoul(argv[--u8Index], NULL, 16);
                    u8MsrThread = strtoul(argv[--u8Index], NULL, 16);
                    break;
                default:
                    printf("ERROR: Unsupported arguments for MSR Read\n");
                    goto ErrorExit;
                    break;
            }
            ret =
                peci_RdIAMSR(address, u8MsrThread, u16MsrAddr, &u64MsrVal, &cc);
            if (showCc)
                printf("MSR Read cc:0x%x\n", cc);
            if (0 != ret)
            {
                printf("ERROR: Read MSR failed or is not supported. %x\n", ret);
                break;
            }
            printf("MSR Read of Thread %02x MSR %04x: 0x%0*" PRIx64 "\n",
                   u8MsrThread, u16MsrAddr, u8Size * 2, u64MsrVal);
            break;

        case PECI_CMD_RD_PCI_CFG_LOCAL:
            u8Index = argc;
            switch (argc - optind)
            {
                case 4:
                    u16PciReg = strtoul(argv[--u8Index], NULL, 16);
                case 3:
                    u8PciFunc = strtoul(argv[--u8Index], NULL, 16);
                case 2:
                    u8PciDev = strtoul(argv[--u8Index], NULL, 16);
                case 1:
                    u8PciBus = strtoul(argv[--u8Index], NULL, 16);
                    break;
                default:
                    printf(
                        "ERROR: Unsupported arguments for Local PCI Write\n");
                    goto ErrorExit;
                    break;
            }
            ret = peci_RdPCIConfigLocal(address, u8PciBus, u8PciDev, u8PciFunc,
                                        u16PciReg, u8Size,
                                        (uint8_t*)&u32PciReadVal, &cc);
            if (showCc)
                printf("Local PCI Read cc:0x%x\n", cc);
            if (0 != ret)
            {
                printf("ERROR: Local PCI Read failed or is not supported.\n");
                break;
            }
            printf("Local PCI Read of %02x:%02x:%02x Reg %02x: 0x%0*x\n",
                   u8PciBus, u8PciDev, u8PciFunc, u16PciReg, u8Size * 2,
                   u32PciReadVal);
            break;

        case PECI_CMD_WR_PCI_CFG_LOCAL:
            u8Index = argc;
            u32PciWriteVal = strtoul(argv[--u8Index], NULL, 16);
            switch (argc - optind)
            {
                case 5:
                    u16PciReg = strtoul(argv[--u8Index], NULL, 16);
                case 4:
                    u8PciFunc = strtoul(argv[--u8Index], NULL, 16);
                case 3:
                    u8PciDev = strtoul(argv[--u8Index], NULL, 16);
                case 2:
                    u8PciBus = strtoul(argv[--u8Index], NULL, 16);
                    break;
                default:
                    printf(
                        "ERROR: Unsupported arguments for Local PCI Write\n");
                    goto ErrorExit;
                    break;
            }
            printf("Local PCI Write of %02x:%02x:%02x Reg %02x: 0x%0*x\n",
                   u8PciBus, u8PciDev, u8PciFunc, u16PciReg, u8Size * 2,
                   u32PciWriteVal);
            ret = peci_WrPCIConfigLocal(address, u8PciBus, u8PciDev, u8PciFunc,
                                        u16PciReg, u8Size, u32PciWriteVal, &cc);
            if (showCc)
                printf("Local PCI Write cc:0x%x\n", cc);
            (0 == ret) ? printf("Succeeded.\n")
                       : printf("Failed or not supported.\n");
            break;

        case PECI_CMD_RD_END_PT_CFG_LOCAL_PCI:
            u8Index = argc;
            switch (argc - optind)
            {
                case 5:
                    u16PciReg = strtoul(argv[--u8Index], NULL, 16);
                    u8PciFunc = strtoul(argv[--u8Index], NULL, 16);
                    u8PciDev = strtoul(argv[--u8Index], NULL, 16);
                    u8PciBus = strtoul(argv[--u8Index], NULL, 16);
                    u8Seg = strtoul(argv[--u8Index], NULL, 16);
                    break;

                default:
                    printf("ERROR: Unsupported arguments for Endpoint Local"
                           "PCI Read\n");
                    goto ErrorExit;
            }

            ret = peci_RdEndPointConfigPciLocal(
                address, u8Seg, u8PciBus, u8PciDev, u8PciFunc, u16PciReg,
                u8Size, (uint8_t*)&u32PciReadVal, &cc);
            if (showCc)
            {
                printf("Endpoint Local PCI Read cc:0x%x\n", cc);
            }
            printf("Seg:%02x %02x:%02x:%02x "
                   "Reg %02x: 0x%0*x\n",
                   u8Seg, u8PciBus, u8PciDev, u8PciFunc, u16PciReg, u8Size * 2,
                   u32PciReadVal);
            if (0 != ret)
            {
                printf("ERROR: Endpoint Local PCI Read failed or is "
                       "not supported.\n");
                break;
            }
            break;

        case PECI_CMD_WR_END_PT_CFG_LOCAL_PCI:
            u8Index = argc;
            switch (argc - optind)
            {
                case 6:
                    u32PciWriteVal = strtoul(argv[--u8Index], NULL, 16);
                    u16PciReg = strtoul(argv[--u8Index], NULL, 16);
                    u8PciFunc = strtoul(argv[--u8Index], NULL, 16);
                    u8PciDev = strtoul(argv[--u8Index], NULL, 16);
                    u8PciBus = strtoul(argv[--u8Index], NULL, 16);
                    u8Seg = strtoul(argv[--u8Index], NULL, 16);
                    break;

                default:
                    printf("ERROR: Unsupported arguments for Endpoint Local "
                           "PCI Write\n");
                    goto ErrorExit;
            }

            ret = peci_WrEndPointPCIConfigLocal(address, u8Seg, u8PciBus,
                                                u8PciDev, u8PciFunc, u16PciReg,
                                                u8Size, u32PciWriteVal, &cc);
            if (showCc)
            {
                printf("Endpoint Local PCI Write cc:0x%x\n", cc);
            }
            printf("Seg:%02x %02x:%02x:%02x Reg %02x: 0x%0*x\n", u8Seg,
                   u8PciBus, u8PciDev, u8PciFunc, u16PciReg, u8Size * 2,
                   u32PciWriteVal);
            if (0 != ret)
            {
                printf("ERROR: Endpoint Local PCI Write failed "
                       "or is not supported.\n");
                break;
            }
            break;

        case PECI_CMD_RD_END_PT_CFG_PCI:
            u8Index = argc;
            switch (argc - optind)
            {
                case 5:
                    u16PciReg = strtoul(argv[--u8Index], NULL, 16);
                    u8PciFunc = strtoul(argv[--u8Index], NULL, 16);
                    u8PciDev = strtoul(argv[--u8Index], NULL, 16);
                    u8PciBus = strtoul(argv[--u8Index], NULL, 16);
                    u8Seg = strtoul(argv[--u8Index], NULL, 16);
                    break;

                default:
                    printf("ERROR: Unsupported arguments for Endpoint PCI Read"
                           "\n");
                    goto ErrorExit;
            }

            ret = peci_RdEndPointConfigPci(address, u8Seg, u8PciBus, u8PciDev,
                                           u8PciFunc, u16PciReg, u8Size,
                                           (uint8_t*)&u32PciReadVal, &cc);
            if (showCc)
            {
                printf("Endpoint PCI Read cc:0x%x\n", cc);
            }
            printf("Seg:%02x %02x:%02x:%02x Reg %02x: 0x%0*x\n", u8Seg,
                   u8PciBus, u8PciDev, u8PciFunc, u16PciReg, u8Size * 2,
                   u32PciReadVal);
            if (0 != ret)
            {
                printf("ERROR: Endpoint PCI Read failed or is not supported."
                       "\n");
                break;
            }
            break;

        case PECI_CMD_WR_END_PT_CFG_PCI:
            u8Index = argc;
            switch (argc - optind)
            {
                case 6:
                    u32PciWriteVal = strtoul(argv[--u8Index], NULL, 16);
                    u16PciReg = strtoul(argv[--u8Index], NULL, 16);
                    u8PciFunc = strtoul(argv[--u8Index], NULL, 16);
                    u8PciDev = strtoul(argv[--u8Index], NULL, 16);
                    u8PciBus = strtoul(argv[--u8Index], NULL, 16);
                    u8Seg = strtoul(argv[--u8Index], NULL, 16);
                    break;

                default:
                    printf("ERROR: Unsupported arguments for Endpoint PCI Write"
                           "\n");
                    goto ErrorExit;
            }

            ret = peci_WrEndPointPCIConfig(address, u8Seg, u8PciBus, u8PciDev,
                                           u8PciFunc, u16PciReg, u8Size,
                                           u32PciWriteVal, &cc);
            if (showCc)
            {
                printf("Endpoint PCI Write cc:0x%x\n", cc);
            }
            printf("Seg:%02x %02x:%02x:%02x Reg %02x: 0x%0*x\n", u8Seg,
                   u8PciBus, u8PciDev, u8PciFunc, u16PciReg, u8Size * 2,
                   u32PciWriteVal);
            if (0 != ret)
            {
                printf("ERROR: Endpoint PCI Write failed or is not supported."
                       "\n");
                break;
            }
            break;

        case PECI_CMD_RD_END_PT_CFG_MMIO:
            u8Index = argc;
            switch (argc - optind)
            {
                case 7:
                    u64Offset = strtoul(argv[--u8Index], NULL, 16);
                    u8PciFunc = strtoul(argv[--u8Index], NULL, 16);
                    u8PciDev = strtoul(argv[--u8Index], NULL, 16);
                    u8PciBus = strtoul(argv[--u8Index], NULL, 16);
                    u8Seg = strtoul(argv[--u8Index], NULL, 16);
                    u8Bar = strtoul(argv[--u8Index], NULL, 16);
                    u8AddrType = strtoul(argv[--u8Index], NULL, 16);
                    break;

                default:
                    printf("ERROR: Unsupported arguments for Endpoint MMIO Read"
                           "\n");
                    goto ErrorExit;
            }

            ret = peci_RdEndPointConfigMmio(
                address, u8Seg, u8PciBus, u8PciDev, u8PciFunc, u8Bar,
                u8AddrType, u64Offset, u8Size, (uint8_t*)&u32PciReadVal, &cc);
            if (showCc)
            {
                printf("Endpoint MMIO Read cc:0x%x\n", cc);
            }
            printf("Seg:%02x %02x:%02x:%02x AType:%02x Bar:%02x "
                   "Offset:0x%" PRIx64 " Data:0x%0*x\n",
                   u8Seg, u8PciBus, u8PciDev, u8PciFunc, u8AddrType, u8Bar,
                   u64Offset, u8Size * 2, u32PciReadVal);
            if (0 != ret)
            {
                printf("ERROR: Endpoint MMIO Read failed or is not supported."
                       "\n");
                break;
            }
            break;

        default:
            printf("ERROR: Unrecognized command\n");
            goto ErrorExit;
    }
    return 0;

ErrorExit:
    Usage(argv[0]);
    return 1;
}