162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright 2019 Red Hat Inc. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation 762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 1262306a36Sopenharmony_ci * all copies or substantial portions of the Software. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1762306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1862306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1962306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2062306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 2162306a36Sopenharmony_ci */ 2262306a36Sopenharmony_ci#include <core/subdev.h> 2362306a36Sopenharmony_ci#include <nvfw/ls.h> 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_cistatic void 2662306a36Sopenharmony_cinvfw_ls_desc_head(struct nvkm_subdev *subdev, 2762306a36Sopenharmony_ci const struct nvfw_ls_desc_head *hdr) 2862306a36Sopenharmony_ci{ 2962306a36Sopenharmony_ci char *date; 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci nvkm_debug(subdev, "lsUcodeImgDesc:\n"); 3262306a36Sopenharmony_ci nvkm_debug(subdev, "\tdescriptorSize : %d\n", 3362306a36Sopenharmony_ci hdr->descriptor_size); 3462306a36Sopenharmony_ci nvkm_debug(subdev, "\timageSize : %d\n", hdr->image_size); 3562306a36Sopenharmony_ci nvkm_debug(subdev, "\ttoolsVersion : 0x%x\n", 3662306a36Sopenharmony_ci hdr->tools_version); 3762306a36Sopenharmony_ci nvkm_debug(subdev, "\tappVersion : 0x%x\n", hdr->app_version); 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci date = kstrndup(hdr->date, sizeof(hdr->date), GFP_KERNEL); 4062306a36Sopenharmony_ci nvkm_debug(subdev, "\tdate : %s\n", date); 4162306a36Sopenharmony_ci kfree(date); 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderStartOffset: 0x%x\n", 4462306a36Sopenharmony_ci hdr->bootloader_start_offset); 4562306a36Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderSize : 0x%x\n", 4662306a36Sopenharmony_ci hdr->bootloader_size); 4762306a36Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderImemOffset : 0x%x\n", 4862306a36Sopenharmony_ci hdr->bootloader_imem_offset); 4962306a36Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderEntryPoint : 0x%x\n", 5062306a36Sopenharmony_ci hdr->bootloader_entry_point); 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci nvkm_debug(subdev, "\tappStartOffset : 0x%x\n", 5362306a36Sopenharmony_ci hdr->app_start_offset); 5462306a36Sopenharmony_ci nvkm_debug(subdev, "\tappSize : 0x%x\n", hdr->app_size); 5562306a36Sopenharmony_ci nvkm_debug(subdev, "\tappImemOffset : 0x%x\n", 5662306a36Sopenharmony_ci hdr->app_imem_offset); 5762306a36Sopenharmony_ci nvkm_debug(subdev, "\tappImemEntry : 0x%x\n", 5862306a36Sopenharmony_ci hdr->app_imem_entry); 5962306a36Sopenharmony_ci nvkm_debug(subdev, "\tappDmemOffset : 0x%x\n", 6062306a36Sopenharmony_ci hdr->app_dmem_offset); 6162306a36Sopenharmony_ci nvkm_debug(subdev, "\tappResidentCodeOffset: 0x%x\n", 6262306a36Sopenharmony_ci hdr->app_resident_code_offset); 6362306a36Sopenharmony_ci nvkm_debug(subdev, "\tappResidentCodeSize : 0x%x\n", 6462306a36Sopenharmony_ci hdr->app_resident_code_size); 6562306a36Sopenharmony_ci nvkm_debug(subdev, "\tappResidentDataOffset: 0x%x\n", 6662306a36Sopenharmony_ci hdr->app_resident_data_offset); 6762306a36Sopenharmony_ci nvkm_debug(subdev, "\tappResidentDataSize : 0x%x\n", 6862306a36Sopenharmony_ci hdr->app_resident_data_size); 6962306a36Sopenharmony_ci} 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ciconst struct nvfw_ls_desc * 7262306a36Sopenharmony_cinvfw_ls_desc(struct nvkm_subdev *subdev, const void *data) 7362306a36Sopenharmony_ci{ 7462306a36Sopenharmony_ci const struct nvfw_ls_desc *hdr = data; 7562306a36Sopenharmony_ci int i; 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci nvfw_ls_desc_head(subdev, &hdr->head); 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci nvkm_debug(subdev, "\tnbOverlays : %d\n", hdr->nb_overlays); 8062306a36Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(hdr->load_ovl); i++) { 8162306a36Sopenharmony_ci nvkm_debug(subdev, "\tloadOvl[%d] : 0x%x %d\n", i, 8262306a36Sopenharmony_ci hdr->load_ovl[i].start, hdr->load_ovl[i].size); 8362306a36Sopenharmony_ci } 8462306a36Sopenharmony_ci nvkm_debug(subdev, "\tcompressed : %d\n", hdr->compressed); 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci return hdr; 8762306a36Sopenharmony_ci} 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ciconst struct nvfw_ls_desc_v1 * 9062306a36Sopenharmony_cinvfw_ls_desc_v1(struct nvkm_subdev *subdev, const void *data) 9162306a36Sopenharmony_ci{ 9262306a36Sopenharmony_ci const struct nvfw_ls_desc_v1 *hdr = data; 9362306a36Sopenharmony_ci int i; 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci nvfw_ls_desc_head(subdev, &hdr->head); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci nvkm_debug(subdev, "\tnbImemOverlays : %d\n", 9862306a36Sopenharmony_ci hdr->nb_imem_overlays); 9962306a36Sopenharmony_ci nvkm_debug(subdev, "\tnbDmemOverlays : %d\n", 10062306a36Sopenharmony_ci hdr->nb_imem_overlays); 10162306a36Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(hdr->load_ovl); i++) { 10262306a36Sopenharmony_ci nvkm_debug(subdev, "\tloadOvl[%2d] : 0x%x %d\n", i, 10362306a36Sopenharmony_ci hdr->load_ovl[i].start, hdr->load_ovl[i].size); 10462306a36Sopenharmony_ci } 10562306a36Sopenharmony_ci nvkm_debug(subdev, "\tcompressed : %d\n", hdr->compressed); 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci return hdr; 10862306a36Sopenharmony_ci} 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ciconst struct nvfw_ls_desc_v2 * 11162306a36Sopenharmony_cinvfw_ls_desc_v2(struct nvkm_subdev *subdev, const void *data) 11262306a36Sopenharmony_ci{ 11362306a36Sopenharmony_ci const struct nvfw_ls_desc_v2 *hdr = data; 11462306a36Sopenharmony_ci char *date; 11562306a36Sopenharmony_ci int i; 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci nvkm_debug(subdev, "lsUcodeImgDesc:\n"); 11862306a36Sopenharmony_ci nvkm_debug(subdev, "\tdescriptorSize : %d\n", hdr->descriptor_size); 11962306a36Sopenharmony_ci nvkm_debug(subdev, "\timageSize : %d\n", hdr->image_size); 12062306a36Sopenharmony_ci nvkm_debug(subdev, "\ttoolsVersion : 0x%x\n", hdr->tools_version); 12162306a36Sopenharmony_ci nvkm_debug(subdev, "\tappVersion : 0x%x\n", hdr->app_version); 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci date = kstrndup(hdr->date, sizeof(hdr->date), GFP_KERNEL); 12462306a36Sopenharmony_ci nvkm_debug(subdev, "\tdate : %s\n", date); 12562306a36Sopenharmony_ci kfree(date); 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci nvkm_debug(subdev, "\tsecureBootloader : 0x%x\n", hdr->secure_bootloader); 12862306a36Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderStartOffset: 0x%x\n", hdr->bootloader_start_offset); 12962306a36Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderSize : 0x%x\n", hdr->bootloader_size); 13062306a36Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderImemOffset : 0x%x\n", hdr->bootloader_imem_offset); 13162306a36Sopenharmony_ci nvkm_debug(subdev, "\tbootloaderEntryPoint : 0x%x\n", hdr->bootloader_entry_point); 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci nvkm_debug(subdev, "\tappStartOffset : 0x%x\n", hdr->app_start_offset); 13462306a36Sopenharmony_ci nvkm_debug(subdev, "\tappSize : 0x%x\n", hdr->app_size); 13562306a36Sopenharmony_ci nvkm_debug(subdev, "\tappImemOffset : 0x%x\n", hdr->app_imem_offset); 13662306a36Sopenharmony_ci nvkm_debug(subdev, "\tappImemEntry : 0x%x\n", hdr->app_imem_entry); 13762306a36Sopenharmony_ci nvkm_debug(subdev, "\tappDmemOffset : 0x%x\n", hdr->app_dmem_offset); 13862306a36Sopenharmony_ci nvkm_debug(subdev, "\tappResidentCodeOffset: 0x%x\n", hdr->app_resident_code_offset); 13962306a36Sopenharmony_ci nvkm_debug(subdev, "\tappResidentCodeSize : 0x%x\n", hdr->app_resident_code_size); 14062306a36Sopenharmony_ci nvkm_debug(subdev, "\tappResidentDataOffset: 0x%x\n", hdr->app_resident_data_offset); 14162306a36Sopenharmony_ci nvkm_debug(subdev, "\tappResidentDataSize : 0x%x\n", hdr->app_resident_data_size); 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci nvkm_debug(subdev, "\tnbImemOverlays : %d\n", hdr->nb_imem_overlays); 14462306a36Sopenharmony_ci nvkm_debug(subdev, "\tnbDmemOverlays : %d\n", hdr->nb_dmem_overlays); 14562306a36Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(hdr->load_ovl); i++) { 14662306a36Sopenharmony_ci nvkm_debug(subdev, "\tloadOvl[%d] : 0x%x %d\n", i, 14762306a36Sopenharmony_ci hdr->load_ovl[i].start, hdr->load_ovl[i].size); 14862306a36Sopenharmony_ci } 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci return hdr; 15162306a36Sopenharmony_ci} 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ciconst struct nvfw_ls_hsbl_bin_hdr * 15462306a36Sopenharmony_cinvfw_ls_hsbl_bin_hdr(struct nvkm_subdev *subdev, const void *data) 15562306a36Sopenharmony_ci{ 15662306a36Sopenharmony_ci const struct nvfw_ls_hsbl_bin_hdr *hdr = data; 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci nvkm_debug(subdev, "lsHsblBinHdr:\n"); 15962306a36Sopenharmony_ci nvkm_debug(subdev, "\tbinMagic : 0x%08x\n", hdr->bin_magic); 16062306a36Sopenharmony_ci nvkm_debug(subdev, "\tbinVer : %d\n", hdr->bin_ver); 16162306a36Sopenharmony_ci nvkm_debug(subdev, "\tbinSize : %d\n", hdr->bin_size); 16262306a36Sopenharmony_ci nvkm_debug(subdev, "\theaderOffset : 0x%x\n", hdr->header_offset); 16362306a36Sopenharmony_ci return hdr; 16462306a36Sopenharmony_ci} 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ciconst struct nvfw_ls_hsbl_hdr * 16762306a36Sopenharmony_cinvfw_ls_hsbl_hdr(struct nvkm_subdev *subdev, const void *data) 16862306a36Sopenharmony_ci{ 16962306a36Sopenharmony_ci const struct nvfw_ls_hsbl_hdr *hdr = data; 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci nvkm_debug(subdev, "lsHsblHdr:\n"); 17262306a36Sopenharmony_ci nvkm_debug(subdev, "\tsigProdOffset : 0x%x\n", hdr->sig_prod_offset); 17362306a36Sopenharmony_ci nvkm_debug(subdev, "\tsigProdSize : 0x%x\n", hdr->sig_prod_size); 17462306a36Sopenharmony_ci nvkm_debug(subdev, "\tpatchLoc : 0x%x\n", hdr->patch_loc); 17562306a36Sopenharmony_ci nvkm_debug(subdev, "\tpatchSig : 0x%x\n", hdr->patch_sig); 17662306a36Sopenharmony_ci nvkm_debug(subdev, "\tmetadataOffset : 0x%x\n", hdr->meta_data_offset); 17762306a36Sopenharmony_ci nvkm_debug(subdev, "\tmetadataSize : 0x%x\n", hdr->meta_data_size); 17862306a36Sopenharmony_ci nvkm_debug(subdev, "\tnumSig : 0x%x\n", hdr->num_sig); 17962306a36Sopenharmony_ci return hdr; 18062306a36Sopenharmony_ci} 181