1/* $NetBSD: nouveau_nvkm_nvfw_ls.c,v 1.2 2021/12/18 23:45:38 riastradh Exp $ */ 2 3/* 4 * Copyright 2019 Red Hat Inc. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 */ 24#include <sys/cdefs.h> 25__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_nvfw_ls.c,v 1.2 2021/12/18 23:45:38 riastradh Exp $"); 26 27#include <core/subdev.h> 28#include <nvfw/ls.h> 29 30static void 31nvfw_ls_desc_head(struct nvkm_subdev *subdev, 32 const struct nvfw_ls_desc_head *hdr) 33{ 34 char *date; 35 36 nvkm_debug(subdev, "lsUcodeImgDesc:\n"); 37 nvkm_debug(subdev, "\tdescriptorSize : %d\n", 38 hdr->descriptor_size); 39 nvkm_debug(subdev, "\timageSize : %d\n", hdr->image_size); 40 nvkm_debug(subdev, "\ttoolsVersion : 0x%x\n", 41 hdr->tools_version); 42 nvkm_debug(subdev, "\tappVersion : 0x%x\n", hdr->app_version); 43 44 date = kstrndup(hdr->date, sizeof(hdr->date), GFP_KERNEL); 45 nvkm_debug(subdev, "\tdate : %s\n", date); 46 kfree(date); 47 48 nvkm_debug(subdev, "\tbootloaderStartOffset: 0x%x\n", 49 hdr->bootloader_start_offset); 50 nvkm_debug(subdev, "\tbootloaderSize : 0x%x\n", 51 hdr->bootloader_size); 52 nvkm_debug(subdev, "\tbootloaderImemOffset : 0x%x\n", 53 hdr->bootloader_imem_offset); 54 nvkm_debug(subdev, "\tbootloaderEntryPoint : 0x%x\n", 55 hdr->bootloader_entry_point); 56 57 nvkm_debug(subdev, "\tappStartOffset : 0x%x\n", 58 hdr->app_start_offset); 59 nvkm_debug(subdev, "\tappSize : 0x%x\n", hdr->app_size); 60 nvkm_debug(subdev, "\tappImemOffset : 0x%x\n", 61 hdr->app_imem_offset); 62 nvkm_debug(subdev, "\tappImemEntry : 0x%x\n", 63 hdr->app_imem_entry); 64 nvkm_debug(subdev, "\tappDmemOffset : 0x%x\n", 65 hdr->app_dmem_offset); 66 nvkm_debug(subdev, "\tappResidentCodeOffset: 0x%x\n", 67 hdr->app_resident_code_offset); 68 nvkm_debug(subdev, "\tappResidentCodeSize : 0x%x\n", 69 hdr->app_resident_code_size); 70 nvkm_debug(subdev, "\tappResidentDataOffset: 0x%x\n", 71 hdr->app_resident_data_offset); 72 nvkm_debug(subdev, "\tappResidentDataSize : 0x%x\n", 73 hdr->app_resident_data_size); 74} 75 76const struct nvfw_ls_desc * 77nvfw_ls_desc(struct nvkm_subdev *subdev, const void *data) 78{ 79 const struct nvfw_ls_desc *hdr = data; 80 int i; 81 82 nvfw_ls_desc_head(subdev, &hdr->head); 83 84 nvkm_debug(subdev, "\tnbOverlays : %d\n", hdr->nb_overlays); 85 for (i = 0; i < ARRAY_SIZE(hdr->load_ovl); i++) { 86 nvkm_debug(subdev, "\tloadOvl[%d] : 0x%x %d\n", i, 87 hdr->load_ovl[i].start, hdr->load_ovl[i].size); 88 } 89 nvkm_debug(subdev, "\tcompressed : %d\n", hdr->compressed); 90 91 return hdr; 92} 93 94const struct nvfw_ls_desc_v1 * 95nvfw_ls_desc_v1(struct nvkm_subdev *subdev, const void *data) 96{ 97 const struct nvfw_ls_desc_v1 *hdr = data; 98 int i; 99 100 nvfw_ls_desc_head(subdev, &hdr->head); 101 102 nvkm_debug(subdev, "\tnbImemOverlays : %d\n", 103 hdr->nb_imem_overlays); 104 nvkm_debug(subdev, "\tnbDmemOverlays : %d\n", 105 hdr->nb_imem_overlays); 106 for (i = 0; i < ARRAY_SIZE(hdr->load_ovl); i++) { 107 nvkm_debug(subdev, "\tloadOvl[%2d] : 0x%x %d\n", i, 108 hdr->load_ovl[i].start, hdr->load_ovl[i].size); 109 } 110 nvkm_debug(subdev, "\tcompressed : %d\n", hdr->compressed); 111 112 return hdr; 113} 114