mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Denis OSTERLAND <denis.osterland@diehl.com>
To: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Cc: Denis OSTERLAND <denis.osterland@diehl.com>
Subject: [PATCH v2] hab: Print events on info command.
Date: Fri, 5 Oct 2018 06:58:04 +0000	[thread overview]
Message-ID: <20181005065537.21844-1-Denis.Osterland@diehl.com> (raw)
In-Reply-To: <20181004070400.12338-1-Denis.Osterland@diehl.com>

From: Denis Osterland <Denis.Osterland@diehl.com>

This patch adds hab_get_status convenience function
and uses it in hab info command.
It returns -EIO if MMU is disabled and -ENXIO if no HAB device
is available.

Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
---
v1 -> v2: use runtime if, as suggested by Andrey Smirnov,
          add hab_get_status to have hab implementation
          selection at a central place

 commands/hab.c |  3 +++
 include/hab.h  | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/commands/hab.c b/commands/hab.c
index 0d7ee8e76..af51e73fc 100644
--- a/commands/hab.c
+++ b/commands/hab.c
@@ -72,6 +72,9 @@ static int do_hab(int argc, char *argv[])
 		else
 			printf("devel mode\n");
 
+		if (hab_get_status() == -EIO)
+			printf("Disable MMU to access HAB API!\n");
+
 		return 0;
 	}
 
diff --git a/include/hab.h b/include/hab.h
index 78c2b865b..7c2ffab5e 100644
--- a/include/hab.h
+++ b/include/hab.h
@@ -19,6 +19,7 @@
 #define __HABV4_H
 
 #include <errno.h>
+#include <mach/generic.h>
 
 #ifdef CONFIG_HABV4
 int imx28_hab_get_status(void);
@@ -43,6 +44,20 @@ static inline int imx25_hab_get_status(void)
 }
 #endif
 
+static inline int hab_get_status(void)
+{
+	if (IS_ENABLED(CONFIG_MMU))
+		return -EIO;
+	else if (cpu_is_mx6())
+		return imx6_hab_get_status();
+	else if (cpu_is_mx28())
+		return imx28_hab_get_status();
+	else if (cpu_is_mx25())
+		return imx25_hab_get_status();
+	else
+		return -ENXIO;
+}
+
 #define SRK_HASH_SIZE	32
 
 /* Force writing of key, even when a key is already written */
-- 
2.19.0



Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___________________________________________________________________________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited. 

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-10-05  6:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04  7:05 [PATCH] " Denis OSTERLAND
2018-10-04 21:14 ` Andrey Smirnov
2018-10-05  6:58 ` Denis OSTERLAND [this message]
2018-10-10  7:51   ` [PATCH v2] " Sascha Hauer
2018-10-10  9:29     ` Denis OSTERLAND
2018-10-12  6:23     ` Marc Kleine-Budde
2018-10-15  8:41       ` Denis OSTERLAND
2018-10-15  8:46         ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181005065537.21844-1-Denis.Osterland@diehl.com \
    --to=denis.osterland@diehl.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox