1 /* 2 * virpcivpd.h: helper APIs for working with the PCI/PCIe VPD capability 3 * 4 * Copyright (C) 2021 Canonical Ltd. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library. If not, see 18 * <http://www.gnu.org/licenses/>. 19 */ 20 21 #pragma once 22 23 #include "internal.h" 24 25 typedef struct virPCIVPDResourceCustom virPCIVPDResourceCustom; 26 struct virPCIVPDResourceCustom { 27 char idx; 28 char *value; 29 }; 30 31 typedef struct virPCIVPDResourceRO virPCIVPDResourceRO; 32 struct virPCIVPDResourceRO { 33 char *part_number; 34 char *change_level; 35 char *manufacture_id; 36 char *serial_number; 37 GPtrArray *vendor_specific; 38 }; 39 40 typedef struct virPCIVPDResourceRW virPCIVPDResourceRW; 41 struct virPCIVPDResourceRW { 42 char *asset_tag; 43 GPtrArray *vendor_specific; 44 GPtrArray *system_specific; 45 }; 46 47 typedef struct virPCIVPDResource virPCIVPDResource; 48 struct virPCIVPDResource { 49 char *name; 50 virPCIVPDResourceRO *ro; 51 virPCIVPDResourceRW *rw; 52 }; 53 54 55 virPCIVPDResource *virPCIVPDParse(int vpdFileFd); 56 void virPCIVPDResourceFree(virPCIVPDResource *res); 57 58 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virPCIVPDResource, virPCIVPDResourceFree); 59 60 virPCIVPDResourceRO *virPCIVPDResourceRONew(void); 61 void virPCIVPDResourceROFree(virPCIVPDResourceRO *ro); 62 63 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virPCIVPDResourceRO, virPCIVPDResourceROFree); 64 65 virPCIVPDResourceRW *virPCIVPDResourceRWNew(void); 66 void virPCIVPDResourceRWFree(virPCIVPDResourceRW *rw); 67 68 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virPCIVPDResourceRW, virPCIVPDResourceRWFree); 69 70 bool 71 virPCIVPDResourceUpdateKeyword(virPCIVPDResource *res, const bool readOnly, 72 const char *const keyword, const char *const value); 73 74 void virPCIVPDResourceCustomFree(virPCIVPDResourceCustom *custom); 75 76 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virPCIVPDResourceCustom, virPCIVPDResourceCustomFree); 77