hdt: Dumping vesa modes & configuration
authorErwan Velu <erwanaliasr1@gmail.com>
Wed, 23 Mar 2011 21:53:17 +0000 (22:53 +0100)
committerErwan Velu <erwanaliasr1@gmail.com>
Wed, 23 Mar 2011 21:53:17 +0000 (22:53 +0100)
com32/hdt/hdt-dump-vesa.c [new file with mode: 0644]
com32/hdt/hdt-dump.c
com32/hdt/hdt-dump.h

diff --git a/com32/hdt/hdt-dump-vesa.c b/com32/hdt/hdt-dump-vesa.c
new file mode 100644 (file)
index 0000000..3818435
--- /dev/null
@@ -0,0 +1,65 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2011 Erwan Velu - All Rights Reserved
+ *
+ *   Permission is hereby granted, free of charge, to any person
+ *   obtaining a copy of this software and associated documentation
+ *   files (the "Software"), to deal in the Software without
+ *   restriction, including without limitation the rights to use,
+ *   copy, modify, merge, publish, distribute, sublicense, and/or
+ *   sell copies of the Software, and to permit persons to whom
+ *   the Software is furnished to do so, subject to the following
+ *   conditions:
+ *
+ *   The above copyright notice and this permission notice shall
+ *   be included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#include "hdt-common.h"
+#include "hdt-dump.h"
+#include <syslinux/config.h>
+
+void dump_vesa(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
+
+        *item = zzjson_create_object(config, NULL); /* empty object */
+       add_hb(is_vesa_valid);
+       if (hardware->is_vesa_valid) {
+               char buffer[64]={0};
+               snprintf(buffer,sizeof(buffer),"%d.%d", hardware->vesa.major_version, hardware->vesa.minor_version);
+               add_s("vesa.version",buffer);
+               add_hs(vesa.vendor);
+               add_hs(vesa.product);
+               add_hs(vesa.product_revision);
+               add_hi(vesa.software_rev);
+               memset(buffer,0,sizeof(buffer));
+               snprintf(buffer,sizeof(buffer),"%d KB",hardware->vesa.total_memory*64);
+               add_s("vesa.memory",buffer);
+               add_i("vesa.modes",hardware->vesa.vmi_count);
+               for (int i = 0; i < hardware->vesa.vmi_count; i++) {
+                       struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
+                       if ((mi->h_res == 0) || (mi->v_res == 0))
+                               continue;
+                       zzjson_print(config, *item);
+                       zzjson_free(config, *item);
+                       *item = zzjson_create_object(config, NULL); /* empty object */
+                       memset(buffer,0,sizeof(buffer));
+                       snprintf(buffer,sizeof(buffer),"0x%04x",hardware->vesa.vmi[i].mode + 0x200);
+                       add_s("vesa.kernel_mode",buffer);
+                       add_i("vesa.hres",mi->h_res);
+                       add_i("vesa.vres",mi->v_res);
+                       add_i("vesa.bpp",mi->bpp);
+               }
+       }
+       flush("vesa",config,item);
+}
index 55ef907..805289f 100644 (file)
@@ -118,6 +118,7 @@ void dump(struct s_hardware *hardware)
     dump_pxe(hardware, &config, &json);
     dump_syslinux(hardware, &config, &json);
     dump_vpd(hardware, &config, &json);
+    dump_vesa(hardware, &config, &json);
 
     /* We close & flush the file to send */
     cpio_close(upload);
index 8a2e410..4f4d6ca 100644 (file)
@@ -53,3 +53,4 @@ void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item)
 void dump_pxe(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
 void dump_syslinux(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
 void dump_vpd(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
+void dump_vesa(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);