summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2013-07-01 08:56:06 -0700
committerAaron Plattner <aplattner@nvidia.com>2013-07-01 08:56:06 -0700
commitf6d8aa6359ab7131e23e52c255aedce667b5a604 (patch)
tree85ea93b8c97b29c49614c25a1fb0429355ecbd10
parente20f6da31339d8cb151ff12609705eeab341751e (diff)
325.08325.08
-rw-r--r--common-utils/common-utils.c114
-rw-r--r--common-utils/common-utils.h45
-rw-r--r--multiple_screens.c6
-rw-r--r--nvidia-cfg.h12
-rw-r--r--nvidia-xconfig.1.m43
-rw-r--r--nvidia-xconfig.h3
-rw-r--r--query_gpu_info.c3
-rw-r--r--version.mk2
8 files changed, 179 insertions, 9 deletions
diff --git a/common-utils/common-utils.c b/common-utils/common-utils.c
index 9b734f3..b2958a7 100644
--- a/common-utils/common-utils.c
+++ b/common-utils/common-utils.c
@@ -492,8 +492,6 @@ void nv_text_rows_append(TextRows *t, const char *msg)
* result in t0
*/
-#define NV_MAX(x,y) ((x) > (y) ? (x) : (y))
-
void nv_concat_text_rows(TextRows *t0, TextRows *t1)
{
int n, i;
@@ -707,6 +705,107 @@ char *nvstrchrnul(char *s, int c)
return result;
}
+/****************************************************************************/
+/* file helper functions */
+/****************************************************************************/
+
+/*
+ * nv_open() - open(2) wrapper; prints an error message if open(2)
+ * fails and calls exit(). This function only returns on success.
+ */
+
+int nv_open(const char *pathname, int flags, mode_t mode)
+{
+ int fd;
+ fd = open(pathname, flags, mode);
+ if (fd == -1) {
+ fprintf(stderr, "Failure opening %s (%s).\n",
+ pathname, strerror(errno));
+ exit(1);
+ }
+ return fd;
+
+} /* nv_name() */
+
+
+
+/*
+ * nv_get_file_length() - stat(2) wrapper; prints an error message if
+ * the system call fails and calls exit(). This function only returns
+ * on success.
+ */
+
+int nv_get_file_length(const char *filename)
+{
+ struct stat stat_buf;
+ int ret;
+
+ ret = stat(filename, &stat_buf);
+ if (ret == -1) {
+ fprintf(stderr, "Unable to determine '%s' file length (%s).\n",
+ filename, strerror(errno));
+ exit(1);
+ }
+ return stat_buf.st_size;
+
+} /* nv_get_file_length() */
+
+
+
+/*
+ * nv_set_file_length() - wrapper for lseek() and write(); prints an
+ * error message if the system calls fail and calls exit(). This
+ * function only returns on success.
+ */
+
+void nv_set_file_length(const char *filename, int fd, int len)
+{
+ if ((lseek(fd, len - 1, SEEK_SET) == -1) ||
+ (write(fd, "", 1) == -1)) {
+ fprintf(stderr, "Unable to set file '%s' length %d (%s).\n",
+ filename, fd, strerror(errno));
+ exit(1);
+ }
+} /* nv_set_file_length() */
+
+
+
+/*
+ * nv_mmap() - mmap(2) wrapper; prints an error message if mmap(2)
+ * fails and calls exit(). This function only returns on success.
+ */
+
+void *nv_mmap(const char *filename, size_t len, int prot, int flags, int fd)
+{
+ void *ret;
+
+ ret = mmap(0, len, prot, flags, fd, 0);
+ if (ret == (void *) -1) {
+ fprintf(stderr, "Unable to mmap file %s (%s).\n",
+ filename, strerror(errno));
+ exit(1);
+ }
+ return ret;
+
+} /* nv_mmap() */
+
+
+/*
+ * nv_basename() - alternative to basename(3) which avoids differences in
+ * behavior from different implementations: this implementation never modifies
+ * the original string, and the return value can always be passed to free(3).
+ */
+
+char *nv_basename(const char *path)
+{
+ char *last_slash = strrchr(path, '/');
+ if (last_slash) {
+ return strdup(last_slash+1);
+ } else {
+ return strdup(path);
+ }
+}
+
/****************************************************************************/
/* string helper functions */
@@ -741,8 +840,12 @@ char *nv_trim_space(char *string) {
static char *trim_char(char *string, char trim, int *count) {
int len, replaced = 0;
- if (!string || trim == '\0') {
- return NULL;
+ if (count) {
+ *count = 0;
+ }
+
+ if (string == NULL || trim == '\0') {
+ return string;
}
if (string[0] == trim) {
@@ -781,7 +884,7 @@ char *nv_trim_char(char *string, char trim) {
*/
char *nv_trim_char_strict(char *string, char trim) {
- int count = 0;
+ int count;
char *trimmed;
trimmed = trim_char(string, trim, &count);
@@ -792,3 +895,4 @@ char *nv_trim_char_strict(char *string, char trim) {
return NULL;
}
+
diff --git a/common-utils/common-utils.h b/common-utils/common-utils.h
index 6dced25..92c57dd 100644
--- a/common-utils/common-utils.h
+++ b/common-utils/common-utils.h
@@ -19,6 +19,8 @@
#include <stdio.h>
#include <stdarg.h>
+#include <sys/types.h>
+#include <stdint.h>
#if !defined(TRUE)
#define TRUE 1
@@ -30,6 +32,9 @@
#define ARRAY_LEN(_arr) (sizeof(_arr) / sizeof(_arr[0]))
+#define NV_MIN(x,y) ((x) < (y) ? (x) : (y))
+#define NV_MAX(x,y) ((x) > (y) ? (x) : (y))
+
#define TAB " "
#define BIGTAB " "
@@ -90,6 +95,12 @@ void fmt(FILE *stream, const char *prefix, const char *fmt, ...) NV_ATTRIBUTE_PR
char *fget_next_line(FILE *fp, int *eof);
+int nv_open(const char *pathname, int flags, mode_t mode);
+int nv_get_file_length(const char *filename);
+void nv_set_file_length(const char *filename, int fd, int len);
+void *nv_mmap(const char *filename, size_t len, int prot, int flags, int fd);
+char *nv_basename(const char *path);
+
char *nv_trim_space(char *string);
char *nv_trim_char(char *string, char trim);
char *nv_trim_char_strict(char *string, char trim);
@@ -139,4 +150,38 @@ do { \
} \
} while (0)
+#if defined(__GNUC__)
+# define NV_INLINE __inline__
+#else
+# define NV_INLINE
+#endif
+
+/*
+ * Simple function which encodes a version number, given as major, minor, micro,
+ * and nano, as a 64-bit unsigned integer. This is defined in an inline function
+ * rather than as a macro for convenience so it can be examined by the debugger.
+ * Encoded version numbers can be compared directly in version checks.
+ */
+static NV_INLINE uint64_t nv_encode_version(unsigned int major,
+ unsigned int minor,
+ unsigned int micro,
+ unsigned int nano)
+{
+ return (((uint64_t)(nano & 0xFFFF)) |
+ (((uint64_t)(micro & 0xFFFF)) << 16) |
+ (((uint64_t)(minor & 0xFFFF)) << 32) |
+ (((uint64_t)(major & 0xFFFF)) << 48));
+}
+
+/*
+ * Wrapper macros for nv_encode_version(). For K in {2,3,4}, NV_VERSIONK() takes
+ * a K-part version number.
+ */
+#define NV_VERSION2(major, minor) \
+ nv_encode_version(major, minor, 0, 0)
+#define NV_VERSION3(major, minor, micro) \
+ nv_encode_version(major, minor, micro, 0)
+#define NV_VERSION4(major, minor, micro, nano) \
+ nv_encode_version(major, minor, micro, nano)
+
#endif /* __COMMON_UTILS_H__ */
diff --git a/multiple_screens.c b/multiple_screens.c
index 89aaffd..295318a 100644
--- a/multiple_screens.c
+++ b/multiple_screens.c
@@ -131,6 +131,7 @@ DevicesPtr find_devices(Options *op)
NvCfgBool (*__isPrimaryDevice)(NvCfgDeviceHandle handle,
NvCfgBool *is_primary_device);
NvCfgBool (*__closeDevice)(NvCfgDeviceHandle handle);
+ NvCfgBool (*__getDeviceUUID)(NvCfgDeviceHandle handle, char **uuid);
/* dlopen() the nvidia-cfg library */
@@ -170,6 +171,7 @@ DevicesPtr find_devices(Options *op)
__GET_FUNC(__getDisplayDevices, "nvCfgGetDisplayDevices");
__GET_FUNC(__getEDID, "nvCfgGetEDID");
__GET_FUNC(__closeDevice, "nvCfgCloseDevice");
+ __GET_FUNC(__getDeviceUUID, "nvCfgGetDeviceUUID");
/* optional functions */
__isPrimaryDevice = dlsym(lib_handle, "nvCfgIsPrimaryDevice");
@@ -205,6 +207,10 @@ DevicesPtr find_devices(Options *op)
goto fail;
}
+ if (__getDeviceUUID(pDevices->devices[i].handle,
+ &pDevices->devices[i].uuid) != NVCFG_TRUE) {
+ goto fail;
+ }
if (__getDisplayDevices(pDevices->devices[i].handle, &mask) !=
NVCFG_TRUE) {
goto fail;
diff --git a/nvidia-cfg.h b/nvidia-cfg.h
index 9dee627..03f2fed 100644
--- a/nvidia-cfg.h
+++ b/nvidia-cfg.h
@@ -297,6 +297,18 @@ NvCfgBool nvCfgGetProductName(NvCfgDeviceHandle handle, char **name);
/*
+ * nvCfgGetDeviceUUID() - return an allocated string containing the
+ * global unique identifier of the specified NVIDIA device. It is the caller's
+ * responsibility to free the returned string. On success, NVCFG_TRUE
+ * will be returned and uuid will be assigned. On failure,
+ * NVCFG_FALSE will be returned.
+ */
+
+NvCfgBool nvCfgGetDeviceUUID(NvCfgDeviceHandle handle, char **uuid);
+
+
+
+/*
* nvCfgGetDisplayDevices() - retrieve a bitmask describing the
* currently connected display devices: this "display device mask" is
* an unsigned 32 bit value that identifies one or more display
diff --git a/nvidia-xconfig.1.m4 b/nvidia-xconfig.1.m4
index 03893c9..1e8260a 100644
--- a/nvidia-xconfig.1.m4
+++ b/nvidia-xconfig.1.m4
@@ -66,7 +66,8 @@ will copy it to
before writing the new configuration.
The
.B \-\-post\-tree (\-T)
-option can be used to print the new configuration to standard out in tree form instead. This option is useful to see what
+option can be used to print the new configuration to standard out in tree form instead.
+This option is useful to see what
.B nvidia-xconfig
will do while leaving the original configuration intact.
.PP
diff --git a/nvidia-xconfig.h b/nvidia-xconfig.h
index fb47b18..c22d3a6 100644
--- a/nvidia-xconfig.h
+++ b/nvidia-xconfig.h
@@ -178,9 +178,10 @@ typedef struct _device_rec {
NvCfgDeviceHandle handle;
int crtcs;
char *name;
+ char *uuid;
unsigned int displayDeviceMask;
int nDisplayDevices;
- DisplayDevicePtr displayDevices;
+ DisplayDevicePtr displayDevices;
} DeviceRec, *DevicePtr;
typedef struct {
diff --git a/query_gpu_info.c b/query_gpu_info.c
index 3caf7a7..17152ff 100644
--- a/query_gpu_info.c
+++ b/query_gpu_info.c
@@ -59,7 +59,8 @@ int query_gpu_info(Options *op)
fmtout("");
fmtout("GPU #%d:", i);
fmtoutp(TAB, "Name : %s", pDevices->devices[i].name);
-
+ fmtoutp(TAB, "UUID : %s", pDevices->devices[i].uuid);
+
memset(busid, 0, BUS_ID_STRING_LENGTH);
xconfigFormatPciBusString(busid, BUS_ID_STRING_LENGTH,
pDevices->devices[i].dev.domain,
diff --git a/version.mk b/version.mk
index 47298b6..a8b6fa4 100644
--- a/version.mk
+++ b/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 319.32
+NVIDIA_VERSION = 325.08