[gnome-color-manager] huey: add a program gcm-dump-to-values to discover new values in the register space
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] huey: add a program gcm-dump-to-values to discover new values in the register space
- Date: Sun, 1 Aug 2010 17:32:06 +0000 (UTC)
commit 6a53c534298b4cf3bf6d4e3c11adbb67d0d1ac0a
Author: Richard Hughes <richard hughsie com>
Date: Sun Aug 1 15:47:14 2010 +0100
huey: add a program gcm-dump-to-values to discover new values in the register space
docs/huey/.gitignore | 2 +
docs/huey/Makefile.am | 33 ++++++++++----
docs/huey/gcm-dump-to-values.c | 91 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 117 insertions(+), 9 deletions(-)
---
diff --git a/docs/huey/.gitignore b/docs/huey/.gitignore
index 938a2f7..afa4bb6 100644
--- a/docs/huey/.gitignore
+++ b/docs/huey/.gitignore
@@ -1,4 +1,6 @@
.deps
+.libs
+gcm-dump-to-values
gcm-parse-huey
*.o
*.parsed
diff --git a/docs/huey/Makefile.am b/docs/huey/Makefile.am
index bdb4ac1..6017590 100644
--- a/docs/huey/Makefile.am
+++ b/docs/huey/Makefile.am
@@ -1,17 +1,32 @@
-## We require new-style dependency handling.
-AUTOMAKE_OPTIONS = 1.7
-
-INCLUDES = \
+INCLUDES = \
+ -I$(top_srcdir)/libcolor-glib \
+ -DI_KNOW_THE_LIBCOLOR_GLIB_API_IS_SUBJECT_TO_CHANGE \
+ $(GUDEV_CFLAGS) \
+ $(GTK_CFLAGS) \
$(GLIB_CFLAGS)
-bin_PROGRAMS = \
- gcm-parse-huey
+bin_PROGRAMS = \
+ gcm-parse-huey \
+ gcm-dump-to-values
-gcm_parse_huey_SOURCES = \
+gcm_parse_huey_SOURCES = \
gcm-parse-huey.c
-gcm_parse_huey_LDADD = \
+gcm_parse_huey_LDADD = \
+ $(GLIB_LIBS)
+
+gcm_parse_huey_CFLAGS = \
+ $(WARNINGFLAGS_C)
+
+gcm_dump_to_values_SOURCES = \
+ gcm-dump-to-values.c
+
+COLOR_GLIB_LIBS = \
+ $(top_builddir)/libcolor-glib/libcolor-glib.la
+
+gcm_dump_to_values_LDADD = \
+ $(COLOR_GLIB_LIBS) \
$(GLIB_LIBS)
-gcm_parse_huey_CFLAGS = \
+gcm_dump_to_values_CFLAGS = \
$(WARNINGFLAGS_C)
diff --git a/docs/huey/gcm-dump-to-values.c b/docs/huey/gcm-dump-to-values.c
new file mode 100644
index 0000000..f5af1c3
--- /dev/null
+++ b/docs/huey/gcm-dump-to-values.c
@@ -0,0 +1,91 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU Lesser General Public License Version 2.1
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <glib.h>
+#include <libcolor-glib.h>
+
+gint
+main (gint argc, gchar *argv[])
+{
+ gboolean ret;
+ GError *error = NULL;
+ gchar *data = NULL;
+ gchar **lines = NULL;
+ guint i, j;
+ guint addr;
+ guint8 buffer[0xff+4];
+ guint value_uint32;
+ gfloat *value_float;
+
+ if (argc != 2)
+ goto out;
+
+ //g_error ("argv[1]=%s", argv[1]);
+ ret = g_file_get_contents (argv[1], &data, NULL, &error);
+ if (!ret) {
+ g_warning ("failed to open: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+ lines = g_strsplit (data, "\n", -1);
+ for (i=0; lines[i] != NULL; i++) {
+ if (g_str_has_prefix (lines[i], "register[0x")) {
+ addr = g_ascii_strtoull (lines[i] + 11, NULL, 16);
+ if (addr > 0xff) {
+ g_warning ("addr=%i", addr);
+ continue;
+ }
+ buffer[addr] = g_ascii_strtoull (lines[i] + 15, NULL, 16);
+ }
+ }
+ g_print ("*** find byte ***\n");
+ for (i=0; i<0xff; i++) {
+ g_print ("0x%02x\t0x%02x\t(%i)\n", i, (int) buffer[i], (int) buffer[i]);
+ }
+ g_print ("*** find uint32 ***\n");
+ for (j=0; j<4; j++) {
+ for (i=j; i<0xff-3; i+=4) {
+ value_uint32 = gcm_buffer_read_uint32_be (buffer+i);
+ if (value_uint32 == G_MAXUINT32)
+ continue;
+ g_print ("0x%02x\t%u\n", i, value_uint32);
+ }
+ }
+ g_print ("*** find float ***\n");
+ for (j=0; j<4; j++) {
+ for (i=j; i<0xff-3; i+=4) {
+ value_uint32 = gcm_buffer_read_uint32_be (buffer+i);
+ value_float = (gfloat*) &value_uint32;
+ if (isnan (*value_float))
+ continue;
+ g_print ("0x%02x\t%f\n", i, *value_float);
+ }
+ }
+out:
+ g_strfreev (lines);
+ g_free (data);
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]