Codebase list nvidia-persistenced / 9bf753f
510.39.01 Aaron Plattner 2 years ago
8 changed file(s) with 121 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
7676 include $(COMMON_UTILS_DIR)/src.mk
7777 SRC += $(addprefix $(COMMON_UTILS_DIR)/,$(COMMON_UTILS_SRC))
7878
79 # rpcgen generates code that emits unused variable warnings
79 # rpcgen generates code that emits unused variable warnings and suspicious
80 # function type casts
8081 $(call BUILD_OBJECT_LIST,$(RPC_SRC)): CFLAGS += -Wno-unused-variable
82 suppress_cast_func_type_warning := $(call TEST_CC_ARG,-Wno-cast-function-type)
83 $(call BUILD_OBJECT_LIST,$(RPC_SRC)): CFLAGS += $(suppress_cast_func_type_warning)
8184
8285 OBJS = $(call BUILD_OBJECT_LIST,$(SRC))
8386
112112 NV_VSNPRINTF(buf, fmt); \
113113 format(stream, prefix, buf, whitespace); \
114114 free (buf); \
115 } while(0)
115 } while (0)
116116
117117
118118 /*
188188 if (a[0] == '-') a++;
189189 if (a[0] == '+') a++;
190190
191 while(a[0]) { a[0] = a[1]; a++; }
191 while (a[0]) { a[0] = a[1]; a++; }
192192
193193 /*
194194 * decrement argv_index so that we process this
0 /*
1 * Copyright (C) 2021 NVIDIA Corporation
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
20 */
21
22 #include "nvpci-utils.h"
23
24 /*
25 * libpciaccess stores the device class in bits 16-23, subclass in 8-15, and
26 * interface in bits 0-7 of dev->device_class. We care only about the class
27 * and subclass.
28 */
29 const uint32_t PCI_CLASS_DISPLAY_VGA = 0x30000;
30 const uint32_t PCI_CLASS_SUBCLASS_MASK = 0xffff00;
31
32 /*
33 * nvpci_find_gpu_by_vendor() - use libpciaccess to find all VGA and 3D PCI
34 * devices matching the passed-in vendor_id (which may be set to PCI_MATCH_ANY).
35 * The caller is responsible for calling pci_system_init() before using this
36 * function, and pci_system_cleanup() when libpciaccess is no longer needed.
37 */
38 struct pci_device_iterator *nvpci_find_gpu_by_vendor(uint32_t vendor_id)
39 {
40 const struct pci_id_match match = {
41 .vendor_id = vendor_id,
42 .device_id = PCI_MATCH_ANY,
43 .subvendor_id = PCI_MATCH_ANY,
44 .subdevice_id = PCI_MATCH_ANY,
45 .device_class = PCI_CLASS_DISPLAY_VGA,
46 /*
47 * Ignore bit 1 of the subclass, to allow both 0x30000 (VGA controller)
48 * and 0x30200 (3D controller).
49 */
50 .device_class_mask = PCI_CLASS_SUBCLASS_MASK & ~0x200,
51 };
52
53 return pci_id_match_iterator_create(&match);
54 }
55
56 /*
57 * nvpci_dev_is_vga() - test whether the passed-in struct pci_device* has the
58 * VGA device class 0x0300 (and not 3D class 0x0302).
59 */
60 int nvpci_dev_is_vga(struct pci_device *dev)
61 {
62 return (dev->device_class & PCI_CLASS_SUBCLASS_MASK) ==
63 PCI_CLASS_DISPLAY_VGA;
64 }
0 /*
1 * Copyright (C) 2021 NVIDIA Corporation
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
20 */
21
22 #ifndef __NVPCI_UTILS_H__
23 #define __NVPCI_UTILS_H__
24
25 #include <pciaccess.h>
26
27 #define NV_PCI_VENDOR_ID 0x10de
28
29 struct pci_device_iterator *nvpci_find_gpu_by_vendor(uint32_t vendor_id);
30 int nvpci_dev_is_vga(struct pci_device *dev);
31
32 #endif /* __NVPCI_UTILS_H__ */
00 # makefile fragment included by nvidia-xconfig, nvidia-settings, and nvidia-installer
1
2 # the including makefile should set this if the relevant program uses pciaccess
3 COMMON_UTILS_PCIACCESS ?=
14
25 COMMON_UTILS_SRC += nvgetopt.c
36 COMMON_UTILS_SRC += common-utils.c
811 COMMON_UTILS_EXTRA_DIST += msg.h
912 COMMON_UTILS_EXTRA_DIST += src.mk
1013
14 # only build nvpci-utils.c for programs that actually use libpciaccess, to
15 # prevent other programs from needing to set the right CFLAGS/LDFLAGS for code
16 # they won't use. Otherwise, just package it in the source tarball.
17 ifneq ($(COMMON_UTILS_PCIACCESS),)
18 COMMON_UTILS_SRC += nvpci-utils.c
19 else
20 COMMON_UTILS_EXTRA_DIST += nvpci-utils.c
21 endif
22 COMMON_UTILS_EXTRA_DIST += nvpci-utils.h
23
1124 # gen-manpage-opts-helper.c is listed in EXTRA_DIST, rather than SRC,
1225 # because it is not compiled into the utilities themselves, but used
1326 # when building the utility's gen-manpage-opts
185185
186186 NV_GENERATED_HEADERS ?=
187187
188 PCIACCESS_CFLAGS ?=
189 PCIACCESS_LDFLAGS ?=
188190
189191 ##############################################################################
190192 # This makefile uses the $(eval) builtin function, which was added in
379381 BUILD_OBJECT_LIST = \
380382 $(call BUILD_OBJECT_LIST_WITH_DIR,$(1),$(OUTPUTDIR))
381383
384 $(call BUILD_OBJECT_LIST,nvpci-utils.c): CFLAGS += $(PCIACCESS_CFLAGS)
382385
383386 ##############################################################################
384387 # function to generate a list of dependency files from their
0 NVIDIA_VERSION = 495.46
0 NVIDIA_VERSION = 510.39.01
11
22 # This file.
33 VERSION_MK_FILE := $(lastword $(MAKEFILE_LIST))