* [U-Boot-Users] [PATCH] API: Dump contents of sector 0 in the demo application.
@ 2008-07-28 18:37 Rafal Jaworowski
2008-07-29 23:01 ` Wolfgang Denk
0 siblings, 1 reply; 2+ messages in thread
From: Rafal Jaworowski @ 2008-07-28 18:37 UTC (permalink / raw)
To: u-boot
Signed-off-by: Rafal Czubak <rcz@semihalf.com>
Acked-by: Rafal Jaworowski <raj@semihalf.com>
---
api_examples/demo.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/api_examples/demo.c b/api_examples/demo.c
index 7ccdb51..a842448 100644
--- a/api_examples/demo.c
+++ b/api_examples/demo.c
@@ -1,5 +1,5 @@
/*
- * (C) Copyright 2007 Semihalf
+ * (C) Copyright 2007-2008 Semihalf
*
* Written by: Rafal Jaworowski <raj@semihalf.com>
*
@@ -31,13 +31,15 @@
#define errf(fmt, args...) do { printf("ERROR @ %s(): ", __func__); printf(fmt, ##args); } while (0)
-void test_dump_si(struct sys_info *);
+#define BUF_SZ 2048
+#define WAIT_SECS 5
+
+void test_dump_buf(void *, int);
void test_dump_di(int);
+void test_dump_si(struct sys_info *);
void test_dump_sig(struct api_signature *);
-char buf[2048];
-
-#define WAIT_SECS 5
+static char buf[BUF_SZ];
int main(int argc, char *argv[])
{
@@ -126,11 +128,17 @@ int main(int argc, char *argv[])
if (i == devs_no)
printf("No storage devices available\n");
else {
+ memset(buf, 0, BUF_SZ);
+
if ((rv = ub_dev_open(i)) != 0)
errf("open device %d error %d\n", i, rv);
- else if ((rv = ub_dev_read(i, &buf, 200, 20)) != 0)
+
+ else if ((rv = ub_dev_read(i, buf, 1, 0)) != 0)
errf("could not read from device %d, error %d\n", i, rv);
+ printf("Sector 0 dump (512B):\n");
+ test_dump_buf(buf, 512);
+
ub_dev_close(i);
}
@@ -235,6 +243,36 @@ static char * test_stor_typ(int type)
return "Unknown";
}
+void test_dump_buf(void *buf, int len)
+{
+ int i;
+ int line_counter = 0;
+ int sep_flag = 0;
+ int addr = 0;
+
+ printf("%07x:\t", addr);
+
+ for (i = 0; i < len; i++) {
+ if (line_counter++ > 15) {
+ line_counter = 0;
+ sep_flag = 0;
+ addr += 16;
+ i--;
+ printf("\n%07x:\t", addr);
+ continue;
+ }
+
+ if (sep_flag++ > 1) {
+ sep_flag = 1;
+ printf(" ");
+ }
+
+ printf("%02x", *((char *)buf++));
+ }
+
+ printf("\n");
+}
+
void test_dump_di(int handle)
{
int i;
--
1.5.2.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot-Users] [PATCH] API: Dump contents of sector 0 in the demo application.
2008-07-28 18:37 [U-Boot-Users] [PATCH] API: Dump contents of sector 0 in the demo application Rafal Jaworowski
@ 2008-07-29 23:01 ` Wolfgang Denk
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2008-07-29 23:01 UTC (permalink / raw)
To: u-boot
In message <20080728183745.GC18963@semihalf.com> you wrote:
> Signed-off-by: Rafal Czubak <rcz@semihalf.com>
> Acked-by: Rafal Jaworowski <raj@semihalf.com>
> ---
> api_examples/demo.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------
> 1 files changed, 44 insertions(+), 6 deletions(-)
>
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Scotty: Captain, we din' can reference it!
Kirk: Analysis, Mr. Spock?
Spock: Captain, it doesn't appear in the symbol table.
Kirk: Then it's of external origin?
Spock: Affirmative.
Kirk: Mr. Sulu, go to pass two.
Sulu: Aye aye, sir, going to pass two.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-07-29 23:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-28 18:37 [U-Boot-Users] [PATCH] API: Dump contents of sector 0 in the demo application Rafal Jaworowski
2008-07-29 23:01 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox