summaryrefslogtreecommitdiffstats
path: root/kernel/firmware_analyzer.h
blob: 69a4ec3a4436ced07dc108a9206612f77e7aff6f (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
#ifndef _FW_ANALYZER_H_
#define _FW_ANALYZER_H_

#include <linux/types.h>
#include "gsp_rpc_client.h"

/* Firmware addresses discovered from analysis */
struct fw_addresses {
    u64 rpc_dispatch_primary;
    u64 rpc_jump_table;
    u64 alloc_main;
    u64 schedule_main;
    u64 bar_trap_handler;
    u64 wpr_handler1;
    u64 wpr_handler2;
    u64 migration_table1;
    u64 migration_table2;
    u64 entry_point;
};

/* Analysis result */
struct fw_analysis_result {
    char version[32];
    size_t fw_size;
    u32 crc32;
    u8 sha256[32];
    struct fw_addresses addresses;
    bool matched;
};

/* Public API */
int fw_analyzer_analyze(const u8 *fw_data, size_t fw_len, struct fw_analysis_result *result);
int fw_analyzer_load_and_analyze(const char *fw_path, struct fw_analysis_result *result);
void fw_analyzer_print_result(const struct fw_analysis_result *result);

#endif /* _FW_ANALYZER_H_ */