LCOV - code coverage report
Current view: top level - test - dt_common.c (source / functions) Coverage Total Hit
Test: skiboot.info Lines: 46.2 % 26 12
Test Date: 2025-01-24 18:40:10 Functions: 66.7 % 3 2
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
       2                 :             : /* Copyright 2015-2017 IBM Corp. */
       3                 :             : 
       4                 :             : #include <skiboot.h>
       5                 :             : #include <stdlib.h>
       6                 :             : 
       7                 :             : #include "../include/device.h"
       8                 :             : 
       9                 :             : /* dump_dt() is used in hdata/test/hdata_to_dt.c and core/test/run-device.c
      10                 :             :  * this file is directly #included in both
      11                 :             :  */
      12                 :             : 
      13                 :         463 : static void indent_num(unsigned indent)
      14                 :             : {
      15                 :             :         unsigned int i;
      16                 :             : 
      17                 :        3115 :         for (i = 0; i < indent; i++)
      18                 :        2652 :                 putc(' ', stdout);
      19                 :         463 : }
      20                 :             : 
      21                 :           0 : static void dump_val(unsigned indent, const void *prop, size_t size)
      22                 :             : {
      23                 :             :         size_t i;
      24                 :           0 :         int width = 78 - indent;
      25                 :             : 
      26                 :           0 :         for (i = 0; i < size; i++) {
      27                 :           0 :                 printf("%02x", ((unsigned char *)prop)[i]);
      28                 :           0 :                 width -= 2;
      29                 :           0 :                 if(width < 2) {
      30                 :           0 :                         printf("\n");
      31                 :           0 :                         indent_num(indent);
      32                 :           0 :                         width = 80 - indent;
      33                 :             :                 }
      34                 :             :         }
      35                 :           0 : }
      36                 :             : 
      37                 :             : void dump_dt(const struct dt_node *root, unsigned indent, bool show_props);
      38                 :             : 
      39                 :         463 : void dump_dt(const struct dt_node *root, unsigned indent, bool show_props)
      40                 :             : {
      41                 :             :         const struct dt_node *i;
      42                 :             :         const struct dt_property *p;
      43                 :             : 
      44                 :         463 :         indent_num(indent);
      45                 :         463 :         printf("node: %s\n", root->name);
      46                 :             : 
      47                 :         463 :         if (show_props) {
      48                 :           1 :                 list_for_each(&root->properties, p, list) {
      49                 :           0 :                         indent_num(indent);
      50                 :           0 :                         printf("prop: %s size: %zu val: ", p->name, p->len);
      51                 :           0 :                         dump_val(indent, p->prop, p->len);
      52                 :           0 :                         printf("\n");
      53                 :             :                 }
      54                 :             :         }
      55                 :             : 
      56                 :         915 :         list_for_each(&root->children, i, list)
      57                 :         452 :                 dump_dt(i, indent + 2, show_props);
      58                 :         463 : }
      59                 :             : 
        

Generated by: LCOV version 2.0-1