1 /*
2 * Copyright 2019 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 #include <core/subdev.h>
23 #include <nvfw/hs.h>
24
25 const struct nvfw_hs_header *
nvfw_hs_header(struct nvkm_subdev * subdev,const void * data)26 nvfw_hs_header(struct nvkm_subdev *subdev, const void *data)
27 {
28 const struct nvfw_hs_header *hdr = data;
29 nvkm_debug(subdev, "hsHeader:\n");
30 nvkm_debug(subdev, "\tsigDbgOffset : 0x%x\n", hdr->sig_dbg_offset);
31 nvkm_debug(subdev, "\tsigDbgSize : 0x%x\n", hdr->sig_dbg_size);
32 nvkm_debug(subdev, "\tsigProdOffset : 0x%x\n", hdr->sig_prod_offset);
33 nvkm_debug(subdev, "\tsigProdSize : 0x%x\n", hdr->sig_prod_size);
34 nvkm_debug(subdev, "\tpatchLoc : 0x%x\n", hdr->patch_loc);
35 nvkm_debug(subdev, "\tpatchSig : 0x%x\n", hdr->patch_sig);
36 nvkm_debug(subdev, "\thdrOffset : 0x%x\n", hdr->hdr_offset);
37 nvkm_debug(subdev, "\thdrSize : 0x%x\n", hdr->hdr_size);
38 return hdr;
39 }
40
41 const struct nvfw_hs_header_v2 *
nvfw_hs_header_v2(struct nvkm_subdev * subdev,const void * data)42 nvfw_hs_header_v2(struct nvkm_subdev *subdev, const void *data)
43 {
44 const struct nvfw_hs_header_v2 *hdr = data;
45
46 nvkm_debug(subdev, "hsHeader:\n");
47 nvkm_debug(subdev, "\tsigProdOffset : 0x%x\n", hdr->sig_prod_offset);
48 nvkm_debug(subdev, "\tsigProdSize : 0x%x\n", hdr->sig_prod_size);
49 nvkm_debug(subdev, "\tpatchLoc : 0x%x\n", hdr->patch_loc);
50 nvkm_debug(subdev, "\tpatchSig : 0x%x\n", hdr->patch_sig);
51 nvkm_debug(subdev, "\tmetadataOffset : 0x%x\n", hdr->meta_data_offset);
52 nvkm_debug(subdev, "\tmetadataSize : 0x%x\n", hdr->meta_data_size);
53 nvkm_debug(subdev, "\tnumSig : 0x%x\n", hdr->num_sig);
54 nvkm_debug(subdev, "\theaderOffset : 0x%x\n", hdr->header_offset);
55 nvkm_debug(subdev, "\theaderSize : 0x%x\n", hdr->header_size);
56 return hdr;
57 }
58
59 const struct nvfw_hs_load_header *
nvfw_hs_load_header(struct nvkm_subdev * subdev,const void * data)60 nvfw_hs_load_header(struct nvkm_subdev *subdev, const void *data)
61 {
62 const struct nvfw_hs_load_header *hdr = data;
63 int i;
64
65 nvkm_debug(subdev, "hsLoadHeader:\n");
66 nvkm_debug(subdev, "\tnonSecCodeOff : 0x%x\n",
67 hdr->non_sec_code_off);
68 nvkm_debug(subdev, "\tnonSecCodeSize : 0x%x\n",
69 hdr->non_sec_code_size);
70 nvkm_debug(subdev, "\tdataDmaBase : 0x%x\n", hdr->data_dma_base);
71 nvkm_debug(subdev, "\tdataSize : 0x%x\n", hdr->data_size);
72 nvkm_debug(subdev, "\tnumApps : 0x%x\n", hdr->num_apps);
73 for (i = 0; i < hdr->num_apps; i++) {
74 nvkm_debug(subdev,
75 "\tApp[%d] : offset 0x%x size 0x%x\n", i,
76 hdr->apps[(i * 2) + 0], hdr->apps[(i * 2) + 1]);
77 }
78
79 return hdr;
80 }
81
82 const struct nvfw_hs_load_header_v2 *
nvfw_hs_load_header_v2(struct nvkm_subdev * subdev,const void * data)83 nvfw_hs_load_header_v2(struct nvkm_subdev *subdev, const void *data)
84 {
85 const struct nvfw_hs_load_header_v2 *hdr = data;
86 int i;
87
88 nvkm_debug(subdev, "hsLoadHeader:\n");
89 nvkm_debug(subdev, "\tosCodeOffset : 0x%x\n", hdr->os_code_offset);
90 nvkm_debug(subdev, "\tosCodeSize : 0x%x\n", hdr->os_code_size);
91 nvkm_debug(subdev, "\tosDataOffset : 0x%x\n", hdr->os_data_offset);
92 nvkm_debug(subdev, "\tosDataSize : 0x%x\n", hdr->os_data_size);
93 nvkm_debug(subdev, "\tnumApps : 0x%x\n", hdr->num_apps);
94 for (i = 0; i < hdr->num_apps; i++) {
95 nvkm_debug(subdev,
96 "\tApp[%d] : offset 0x%x size 0x%x\n", i,
97 hdr->app[i].offset, hdr->app[i].size);
98 }
99
100 return hdr;
101 }
102