[syslinux:firmware] Archicture-dependent get_cpuid in sysdump/ cpuid is fixed.

syslinux-bot for chandramouli narayanan mouli at linux.intel.com
Fri Nov 9 09:06:22 PST 2012


Commit-ID:  a5759fa44611e372eccc01d85f2db1bc7050c77d
Gitweb:     http://www.syslinux.org/commit/a5759fa44611e372eccc01d85f2db1bc7050c77d
Author:     chandramouli narayanan <mouli at linux.intel.com>
AuthorDate: Mon, 25 Jun 2012 12:50:11 -0700
Committer:  chandramouli narayanan <mouli at linux.intel.com>
CommitDate: Mon, 25 Jun 2012 12:50:11 -0700

Archicture-dependent get_cpuid in sysdump/cpuid is fixed.

In the following sample programs zzjson.c, advdump.c, entrydump.c, hello.c, resolv.c,
serialinfo.c in com32/samples, the following code call hangs the program:
openconsole(&dev_null_r, &dev_stdcon_w);

The following fix works:
openconsole(&dev_rawcon_r, &dev_ansiserial_w);

Remanants of the unused old i386-only files, if any, need to be pruned.

---
 com32/modules/ls.c         |    2 +-
 com32/modules/zzjson.c     |    6 ++++++
 com32/samples/advdump.c    |    6 ++++++
 com32/samples/entrydump.c  |    6 ++++++
 com32/samples/hello.c      |    6 ++++++
 com32/samples/resolv.c     |    6 ++++++
 com32/samples/serialinfo.c |    6 ++++++
 com32/sysdump/cpuid.c      |   11 +++++++++++
 8 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/com32/modules/ls.c b/com32/modules/ls.c
index 11c18ae..47eacdb 100644
--- a/com32/modules/ls.c
+++ b/com32/modules/ls.c
@@ -172,4 +172,4 @@ int main(int argc, char *argv[])
 
     return rv ? 1 : 0;
 }
-  
+ 
diff --git a/com32/modules/zzjson.c b/com32/modules/zzjson.c
index e2516fa..a126b8f 100644
--- a/com32/modules/zzjson.c
+++ b/com32/modules/zzjson.c
@@ -21,7 +21,13 @@ static void myerror(void *ehandle, const char *format, ...) {
 
 int main(int argc, char *argv[])
 {
+#if 0
+	/* this hangs! */
     openconsole(&dev_rawcon_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
     (void) argc;
     (void) argv;
     ZZJSON  *tmp;
diff --git a/com32/samples/advdump.c b/com32/samples/advdump.c
index 2c78641..83fe838 100644
--- a/com32/samples/advdump.c
+++ b/com32/samples/advdump.c
@@ -27,7 +27,13 @@ int main(void)
     size_t s = syslinux_adv_size();
     char buf[256];
 
+#if 0
+	/* this hangs! */
     openconsole(&dev_stdcon_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
 
     p = syslinux_adv_ptr();
 
diff --git a/com32/samples/entrydump.c b/com32/samples/entrydump.c
index d50859f..56a683e 100644
--- a/com32/samples/entrydump.c
+++ b/com32/samples/entrydump.c
@@ -36,7 +36,13 @@ int main(void)
     const union syslinux_derivative_info *di;
     const struct stack_frame *sf;
 
+#if 0
+	/* this hangs! */
     openconsole(&dev_null_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
 
     di = syslinux_derivative_info();
 
diff --git a/com32/samples/hello.c b/com32/samples/hello.c
index 77e93ac..eef8528 100644
--- a/com32/samples/hello.c
+++ b/com32/samples/hello.c
@@ -24,7 +24,13 @@ int main(int argc, char *argv[])
 {
     int i;
 
+#if 0
+	/* this hangs! */
     openconsole(&dev_stdcon_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
 
     printf("Hello, World!\n");
 
diff --git a/com32/samples/resolv.c b/com32/samples/resolv.c
index bd49d9f..fae6649 100644
--- a/com32/samples/resolv.c
+++ b/com32/samples/resolv.c
@@ -45,7 +45,13 @@ int main(int argc, char *argv[])
 {
     uint32_t ip;
 
+#if 0
+	/* this hangs! */
     openconsole(&dev_null_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
 
     if (argc < 2) {
 	fputs("Usage: resolv hostname\n", stderr);
diff --git a/com32/samples/serialinfo.c b/com32/samples/serialinfo.c
index 10d0252..2936b4e 100644
--- a/com32/samples/serialinfo.c
+++ b/com32/samples/serialinfo.c
@@ -25,7 +25,13 @@ int main(void)
 {
     const struct syslinux_serial_console_info *si;
 
+#if 0
+	/* this hangs! */
     openconsole(&dev_null_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
 
     si = syslinux_serial_console_info();
 
diff --git a/com32/sysdump/cpuid.c b/com32/sysdump/cpuid.c
index e7fc576..846b540 100644
--- a/com32/sysdump/cpuid.c
+++ b/com32/sysdump/cpuid.c
@@ -20,10 +20,21 @@ struct cpuid_info {
 
 static void get_cpuid(uint32_t eax, uint32_t ecx, struct cpuid_data *data)
 {
+#if __SIZEOF_POINTER__ == 4
     asm("pushl %%ebx ; cpuid ; movl %%ebx,%1 ; popl %%ebx"
 	: "=a" (data->eax), "=r" (data->ebx),
 	  "=c" (data->ecx), "=d" (data->edx)
 	: "a" (eax), "c" (ecx));
+#elif __SIZEOF_POINTER__ == 8
+        asm volatile("push %%rbx; cpuid; movl %%ebx, %1; pop %%rbx"
+            : "=a" (data->eax),
+              "=b" (data->ebx),
+              "=c" (data->ecx),
+              "=d" (data->edx)
+            : "a" (eax), "c" (ecx));
+#else
+#error "unsupported architecture"
+#endif
 }
 
 #define CPUID_CHUNK 128


More information about the Syslinux-commits mailing list