blob: f620f80cf445e329212e89596d64c348df0d59af [file] [log] [blame]
mardyk01817d8602024-01-17 16:02:49 -06001# !/usr/bin/env python
2#
3# Copyright (c) 2024, Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8# Script to generate the header file compiled into fuzzer for creating
9# the various enum values used to identify the specific fuzzer function called.
10# This is intended to replace the orignal string output of the fuzzer.
11# There are two arguments... one to specify the device tree file input to the fuzzer
12# and the other to give the name and path of the header file.
13
14import re
15import argparse
16
17parser = argparse.ArgumentParser(
18 prog='gen_smc_fuzz_setup',
19 description='Creates a header file to assign enum values to fuzzing function names',
20 epilog='Two argument input')
21
22parser.add_argument('-dts', '--devtree',help="Device tree file to analyze .")
23parser.add_argument('-hdf', '--headfile',help="Header file to create .")
24
25args = parser.parse_args()
26
27addresses = {}
28numl = 1
29dt_file = open(args.devtree, "r")
30hdr_file = open(args.headfile, "w")
31dt_lines = dt_file.readlines()
32dt_file.close()
33for line in dt_lines:
34 if "functionname" in line:
35 grp = re.search(r'functionname\s*=\s*\"(\w+)\"',line)
36 fnme = grp.group(1)
37 if fnme not in addresses:
38 addresses[fnme] = 1;
39 print("#define", fnme, numl,file=hdr_file)
40 numl = numl + 1
41hdr_file.close()