18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2019 Red Hat Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci#include <core/subdev.h> 238c2ecf20Sopenharmony_ci#include <nvfw/ls.h> 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistatic void 268c2ecf20Sopenharmony_cinvfw_ls_desc_head(struct nvkm_subdev *subdev, 278c2ecf20Sopenharmony_ci const struct nvfw_ls_desc_head *hdr) 288c2ecf20Sopenharmony_ci{ 298c2ecf20Sopenharmony_ci char *date; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci nvkm_debug(subdev, "lsUcodeImgDesc:\n"); 328c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tdescriptorSize : %d\n", 338c2ecf20Sopenharmony_ci hdr->descriptor_size); 348c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\timageSize : %d\n", hdr->image_size); 358c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\ttoolsVersion : 0x%x\n", 368c2ecf20Sopenharmony_ci hdr->tools_version); 378c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappVersion : 0x%x\n", hdr->app_version); 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci date = kstrndup(hdr->date, sizeof(hdr->date), GFP_KERNEL); 408c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tdate : %s\n", date); 418c2ecf20Sopenharmony_ci kfree(date); 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderStartOffset: 0x%x\n", 448c2ecf20Sopenharmony_ci hdr->bootloader_start_offset); 458c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderSize : 0x%x\n", 468c2ecf20Sopenharmony_ci hdr->bootloader_size); 478c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderImemOffset : 0x%x\n", 488c2ecf20Sopenharmony_ci hdr->bootloader_imem_offset); 498c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderEntryPoint : 0x%x\n", 508c2ecf20Sopenharmony_ci hdr->bootloader_entry_point); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappStartOffset : 0x%x\n", 538c2ecf20Sopenharmony_ci hdr->app_start_offset); 548c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappSize : 0x%x\n", hdr->app_size); 558c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappImemOffset : 0x%x\n", 568c2ecf20Sopenharmony_ci hdr->app_imem_offset); 578c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappImemEntry : 0x%x\n", 588c2ecf20Sopenharmony_ci hdr->app_imem_entry); 598c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappDmemOffset : 0x%x\n", 608c2ecf20Sopenharmony_ci hdr->app_dmem_offset); 618c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappResidentCodeOffset: 0x%x\n", 628c2ecf20Sopenharmony_ci hdr->app_resident_code_offset); 638c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappResidentCodeSize : 0x%x\n", 648c2ecf20Sopenharmony_ci hdr->app_resident_code_size); 658c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappResidentDataOffset: 0x%x\n", 668c2ecf20Sopenharmony_ci hdr->app_resident_data_offset); 678c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tappResidentDataSize : 0x%x\n", 688c2ecf20Sopenharmony_ci hdr->app_resident_data_size); 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciconst struct nvfw_ls_desc * 728c2ecf20Sopenharmony_cinvfw_ls_desc(struct nvkm_subdev *subdev, const void *data) 738c2ecf20Sopenharmony_ci{ 748c2ecf20Sopenharmony_ci const struct nvfw_ls_desc *hdr = data; 758c2ecf20Sopenharmony_ci int i; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci nvfw_ls_desc_head(subdev, &hdr->head); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tnbOverlays : %d\n", hdr->nb_overlays); 808c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(hdr->load_ovl); i++) { 818c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tloadOvl[%d] : 0x%x %d\n", i, 828c2ecf20Sopenharmony_ci hdr->load_ovl[i].start, hdr->load_ovl[i].size); 838c2ecf20Sopenharmony_ci } 848c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tcompressed : %d\n", hdr->compressed); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci return hdr; 878c2ecf20Sopenharmony_ci} 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciconst struct nvfw_ls_desc_v1 * 908c2ecf20Sopenharmony_cinvfw_ls_desc_v1(struct nvkm_subdev *subdev, const void *data) 918c2ecf20Sopenharmony_ci{ 928c2ecf20Sopenharmony_ci const struct nvfw_ls_desc_v1 *hdr = data; 938c2ecf20Sopenharmony_ci int i; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci nvfw_ls_desc_head(subdev, &hdr->head); 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tnbImemOverlays : %d\n", 988c2ecf20Sopenharmony_ci hdr->nb_imem_overlays); 998c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tnbDmemOverlays : %d\n", 1008c2ecf20Sopenharmony_ci hdr->nb_imem_overlays); 1018c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(hdr->load_ovl); i++) { 1028c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tloadOvl[%2d] : 0x%x %d\n", i, 1038c2ecf20Sopenharmony_ci hdr->load_ovl[i].start, hdr->load_ovl[i].size); 1048c2ecf20Sopenharmony_ci } 1058c2ecf20Sopenharmony_ci nvkm_debug(subdev, "\tcompressed : %d\n", hdr->compressed); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci return hdr; 1088c2ecf20Sopenharmony_ci} 109