xref: /openbmc/linux/drivers/gpu/drm/nouveau/nvkm/nvfw/ls.c (revision dc6a81c3)
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/ls.h>
24 
25 static void
26 nvfw_ls_desc_head(struct nvkm_subdev *subdev,
27 		  const struct nvfw_ls_desc_head *hdr)
28 {
29 	char *date;
30 
31 	nvkm_debug(subdev, "lsUcodeImgDesc:\n");
32 	nvkm_debug(subdev, "\tdescriptorSize       : %d\n",
33 			   hdr->descriptor_size);
34 	nvkm_debug(subdev, "\timageSize            : %d\n", hdr->image_size);
35 	nvkm_debug(subdev, "\ttoolsVersion         : 0x%x\n",
36 			   hdr->tools_version);
37 	nvkm_debug(subdev, "\tappVersion           : 0x%x\n", hdr->app_version);
38 
39 	date = kstrndup(hdr->date, sizeof(hdr->date), GFP_KERNEL);
40 	nvkm_debug(subdev, "\tdate                 : %s\n", date);
41 	kfree(date);
42 
43 	nvkm_debug(subdev, "\tbootloaderStartOffset: 0x%x\n",
44 			   hdr->bootloader_start_offset);
45 	nvkm_debug(subdev, "\tbootloaderSize       : 0x%x\n",
46 			   hdr->bootloader_size);
47 	nvkm_debug(subdev, "\tbootloaderImemOffset : 0x%x\n",
48 			   hdr->bootloader_imem_offset);
49 	nvkm_debug(subdev, "\tbootloaderEntryPoint : 0x%x\n",
50 			   hdr->bootloader_entry_point);
51 
52 	nvkm_debug(subdev, "\tappStartOffset       : 0x%x\n",
53 			   hdr->app_start_offset);
54 	nvkm_debug(subdev, "\tappSize              : 0x%x\n", hdr->app_size);
55 	nvkm_debug(subdev, "\tappImemOffset        : 0x%x\n",
56 			   hdr->app_imem_offset);
57 	nvkm_debug(subdev, "\tappImemEntry         : 0x%x\n",
58 			   hdr->app_imem_entry);
59 	nvkm_debug(subdev, "\tappDmemOffset        : 0x%x\n",
60 			   hdr->app_dmem_offset);
61 	nvkm_debug(subdev, "\tappResidentCodeOffset: 0x%x\n",
62 			   hdr->app_resident_code_offset);
63 	nvkm_debug(subdev, "\tappResidentCodeSize  : 0x%x\n",
64 			   hdr->app_resident_code_size);
65 	nvkm_debug(subdev, "\tappResidentDataOffset: 0x%x\n",
66 			   hdr->app_resident_data_offset);
67 	nvkm_debug(subdev, "\tappResidentDataSize  : 0x%x\n",
68 			   hdr->app_resident_data_size);
69 }
70 
71 const struct nvfw_ls_desc *
72 nvfw_ls_desc(struct nvkm_subdev *subdev, const void *data)
73 {
74 	const struct nvfw_ls_desc *hdr = data;
75 	int i;
76 
77 	nvfw_ls_desc_head(subdev, &hdr->head);
78 
79 	nvkm_debug(subdev, "\tnbOverlays           : %d\n", hdr->nb_overlays);
80 	for (i = 0; i < ARRAY_SIZE(hdr->load_ovl); i++) {
81 		nvkm_debug(subdev, "\tloadOvl[%d]          : 0x%x %d\n", i,
82 			   hdr->load_ovl[i].start, hdr->load_ovl[i].size);
83 	}
84 	nvkm_debug(subdev, "\tcompressed           : %d\n", hdr->compressed);
85 
86 	return hdr;
87 }
88 
89 const struct nvfw_ls_desc_v1 *
90 nvfw_ls_desc_v1(struct nvkm_subdev *subdev, const void *data)
91 {
92 	const struct nvfw_ls_desc_v1 *hdr = data;
93 	int i;
94 
95 	nvfw_ls_desc_head(subdev, &hdr->head);
96 
97 	nvkm_debug(subdev, "\tnbImemOverlays       : %d\n",
98 			   hdr->nb_imem_overlays);
99 	nvkm_debug(subdev, "\tnbDmemOverlays       : %d\n",
100 			   hdr->nb_imem_overlays);
101 	for (i = 0; i < ARRAY_SIZE(hdr->load_ovl); i++) {
102 		nvkm_debug(subdev, "\tloadOvl[%2d]          : 0x%x %d\n", i,
103 			   hdr->load_ovl[i].start, hdr->load_ovl[i].size);
104 	}
105 	nvkm_debug(subdev, "\tcompressed           : %d\n", hdr->compressed);
106 
107 	return hdr;
108 }
109