hardware_caps: add boxarch field

This commit is contained in:
Stefan Seyfried
2016-01-22 19:02:33 +01:00
parent 42267080f9
commit db3ec7352e
6 changed files with 29 additions and 13 deletions

View File

@@ -2,7 +2,7 @@
* determine the capabilities of the hardware. * determine the capabilities of the hardware.
* part of libstb-hal * part of libstb-hal
* *
* (C) 2010-2012 Stefan Seyfried * (C) 2010-2012,2016 Stefan Seyfried
* *
* License: GPL v2 or later * License: GPL v2 or later
*/ */
@@ -45,6 +45,7 @@ hw_caps_t *get_hwcaps(void)
} }
else else
strcpy(caps.boxname, "(unknown model)"); strcpy(caps.boxname, "(unknown model)");
strcpy(caps.boxarch, "mipsel");
return ∩︀ return ∩︀
} }

View File

@@ -2,24 +2,22 @@
* determine the capabilities of the hardware. * determine the capabilities of the hardware.
* part of libstb-hal * part of libstb-hal
* *
* (C) 2010-2012 Stefan Seyfried * (C) 2010-2012,2016 Stefan Seyfried
* *
* License: GPL v2 or later * License: GPL v2 or later
*/ */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <hardware_caps.h> #include <hardware_caps.h>
#include <sys/utsname.h>
static int initialized = 0; static int initialized = 0;
static hw_caps_t caps; static hw_caps_t caps;
hw_caps_t *get_hwcaps(void) hw_caps_t *get_hwcaps(void)
{ {
struct utsname u;
if (initialized) if (initialized)
return &caps; return &caps;
@@ -32,6 +30,10 @@ hw_caps_t *get_hwcaps(void)
caps.display_xres = 8; caps.display_xres = 8;
strcpy(caps.boxvendor, "Generic"); strcpy(caps.boxvendor, "Generic");
strcpy(caps.boxname, "PC"); strcpy(caps.boxname, "PC");
if (! uname(&u))
strncpy(caps.boxarch, u.machine, sizeof(caps.boxarch));
else
fprintf(stderr, "%s: uname() failed: %m\n", __func__);
return &caps; return &caps;
} }

View File

@@ -35,6 +35,7 @@ typedef struct hw_caps
int display_yres; int display_yres;
char boxvendor[64]; char boxvendor[64];
char boxname[64]; char boxname[64];
char boxarch[64];
} hw_caps_t; } hw_caps_t;
hw_caps_t *get_hwcaps(void); hw_caps_t *get_hwcaps(void);

View File

@@ -15,6 +15,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <aotom_main.h> #include <aotom_main.h>
#include <sys/utsname.h>
#include <hardware_caps.h> #include <hardware_caps.h>
@@ -24,6 +25,7 @@ static hw_caps_t caps;
hw_caps_t *get_hwcaps(void) hw_caps_t *get_hwcaps(void)
{ {
struct utsname u;
if (initialized) if (initialized)
return &caps; return &caps;
@@ -55,12 +57,18 @@ hw_caps_t *get_hwcaps(void)
len = read(fd, buf, sizeof(buf) - 1); len = read(fd, buf, sizeof(buf) - 1);
close(fd); close(fd);
} }
ret = uname(&u);
if (ret == 0)
snprintf(caps.boxarch, sizeof(caps.boxarch), "%s", u.machine); /* even if cmdline failed */
if (len > 0) { if (len > 0) {
buf[len] = 0; buf[len] = 0;
char *p = strstr(buf, "STB_ID="); char *p = strstr(buf, "STB_ID=");
int h0, h1, h2; int h0, h1, h2;
if (p && sscanf(p, "STB_ID=%x:%x:%x:", &h0, &h1, &h2) == 3) { if (p && sscanf(p, "STB_ID=%x:%x:%x:", &h0, &h1, &h2) == 3) {
int sys_id = (h0 << 16) | (h1 << 8) | h2; int sys_id = (h0 << 16) | (h1 << 8) | h2;
/* include processor architecture and boxid bytes in boxarch */
p[15] = '\0';
snprintf(caps.boxarch, sizeof(caps.boxarch), "%s %s", u.machine, p);
switch (sys_id) { switch (sys_id) {
case 0x090003: case 0x090003:
tmp = "Truman Premier 1+"; tmp = "Truman Premier 1+";

View File

@@ -2,7 +2,7 @@
* determine the capabilities of the hardware. * determine the capabilities of the hardware.
* part of libstb-hal * part of libstb-hal
* *
* (C) 2010-2012 Stefan Seyfried * (C) 2010-2012,2016 Stefan Seyfried
* *
* License: GPL v2 or later * License: GPL v2 or later
*/ */
@@ -21,7 +21,8 @@ static hw_caps_t caps = {
.display_xres = 128, .display_xres = 128,
.display_yres = 64, .display_yres = 64,
.boxvendor = "Armas", .boxvendor = "Armas",
.boxname = "TripleDragon" .boxname = "TripleDragon",
.boxarch = "ppc405"
}; };
hw_caps_t *get_hwcaps(void) hw_caps_t *get_hwcaps(void)

View File

@@ -2,24 +2,23 @@
* determine the capabilities of the hardware. * determine the capabilities of the hardware.
* part of libstb-hal * part of libstb-hal
* *
* (C) 2010-2013 Stefan Seyfried * (C) 2010-2013,2016 Stefan Seyfried
* *
* License: GPL v2 or later * License: GPL v2 or later
*/ */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <hardware_caps.h> #include <hardware_caps.h>
#include <sys/utsname.h>
#include <stdio.h>
static int initialized = 0; static int initialized = 0;
static hw_caps_t caps; static hw_caps_t caps;
hw_caps_t *get_hwcaps(void) hw_caps_t *get_hwcaps(void)
{ {
struct utsname u;
if (initialized) if (initialized)
return &caps; return &caps;
@@ -32,6 +31,10 @@ hw_caps_t *get_hwcaps(void)
caps.display_xres = 8; caps.display_xres = 8;
strcpy(caps.boxvendor, "Raspberry"); strcpy(caps.boxvendor, "Raspberry");
strcpy(caps.boxname, "Pi"); strcpy(caps.boxname, "Pi");
if (! uname(&u))
strncpy(caps.boxarch, u.machine, sizeof(caps.boxarch));
else
fprintf(stderr, "%s: uname() failed: %m\n", __func__);
return &caps; return &caps;
} }