summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@amacapital.net>2014-07-29 20:54:33 -0700
committerAndy Lutomirski <luto@amacapital.net>2014-07-29 20:54:33 -0700
commitd1c4e4fcfbac0469db5b36815536cde70806e570 (patch)
tree61e93568107479e3abd969c8163255e515b36a9c
parentbc9adfa2e38fe4d86fe38f60b2a6bfa39ba4b385 (diff)
downloadmisc-tests-d1c4e4fcfbac0469db5b36815536cde70806e570.tar.gz
user_visible_state: Decode MSw
-rw-r--r--user_visible_state.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/user_visible_state.c b/user_visible_state.c
index 4616ca4..f171ab5 100644
--- a/user_visible_state.c
+++ b/user_visible_state.c
@@ -43,9 +43,33 @@ static void show_tr(void)
static void show_msw(void)
{
- unsigned short msw;
+ static const struct msw_bit {
+ int pos;
+ const char *str;
+ } bits[] = {
+ {0, "PE"},
+ {1, "MP"},
+ {2, "EM"},
+ {3, "TS"}, /* this is actually interesting */
+ {4, "ET"},
+ {5, "NE"},
+ };
+
+ unsigned short msw, remaining;
asm ("smsww %0" : "=rm" (msw));
- printf("MSW: 0x%04X\n", msw);
+ printf("MSW: 0x%04X", msw);
+
+ remaining = msw;
+ for (int i = 0; i < sizeof(bits) / sizeof(bits[0]); i++) {
+ if (msw & (1 << bits[i].pos)) {
+ printf(" %s", bits[i].str);
+ remaining &= ~(1 << bits[i].pos);
+ }
+ }
+ if (remaining)
+ printf(" unknown:0x%x", remaining);
+
+ printf("\n");
}
static void show_flags(void)