This source file includes following definitions.
- hs_ucode_patch_signature
- hs_ucode_load_blob
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include "hs_ucode.h"
24 #include "ls_ucode.h"
25 #include "acr.h"
26
27 #include <engine/falcon.h>
28
29
30
31
32
33 static void
34 hs_ucode_patch_signature(const struct nvkm_falcon *falcon, void *acr_image,
35 bool new_format)
36 {
37 struct fw_bin_header *hsbin_hdr = acr_image;
38 struct hsf_fw_header *fw_hdr = acr_image + hsbin_hdr->header_offset;
39 void *hs_data = acr_image + hsbin_hdr->data_offset;
40 void *sig;
41 u32 sig_size;
42 u32 patch_loc, patch_sig;
43
44
45
46
47
48
49 if (new_format) {
50 patch_loc = fw_hdr->patch_loc;
51 patch_sig = fw_hdr->patch_sig;
52 } else {
53 patch_loc = *(u32 *)(acr_image + fw_hdr->patch_loc);
54 patch_sig = *(u32 *)(acr_image + fw_hdr->patch_sig);
55 }
56
57
58 if (falcon->debug) {
59 sig = acr_image + fw_hdr->sig_dbg_offset;
60 sig_size = fw_hdr->sig_dbg_size;
61 } else {
62 sig = acr_image + fw_hdr->sig_prod_offset;
63 sig_size = fw_hdr->sig_prod_size;
64 }
65
66
67 memcpy(hs_data + patch_loc, sig + patch_sig, sig_size);
68 }
69
70 void *
71 hs_ucode_load_blob(struct nvkm_subdev *subdev, const struct nvkm_falcon *falcon,
72 const char *fw)
73 {
74 void *acr_image;
75 bool new_format;
76
77 acr_image = nvkm_acr_load_firmware(subdev, fw, 0);
78 if (IS_ERR(acr_image))
79 return acr_image;
80
81
82 switch (((u32 *)acr_image)[0]) {
83 case 0x3b1d14f0:
84 new_format = true;
85 break;
86 case 0x000010de:
87 new_format = false;
88 break;
89 default:
90 nvkm_error(subdev, "unknown header for HS blob %s\n", fw);
91 return ERR_PTR(-EINVAL);
92 }
93
94 hs_ucode_patch_signature(falcon, acr_image, new_format);
95
96 return acr_image;
97 }