From: Anton Blanchard Date: Thu, 8 Jul 2010 19:03:38 +0000 (+0000) Subject: Add claim/release runtime debug output X-Git-Tag: yaboot-1.3.17-rc1~9 X-Git-Url: http://git.ozlabs.org/?p=yaboot.git;a=commitdiff_plain;h=ba5849c566fd9e1d0765d734d1871bc48c12350f;hp=89aafcfba49a5a302c591b05c7c73d26451dcfda Add claim/release runtime debug output Create prom_debug and use it in the claim and release routines. Clean up the debug and error messages in the area. Signed-off-by: Anton Blanchard Signed-off-by: Tony Breeds --- diff --git a/include/prom.h b/include/prom.h index 2743609..3dd4a51 100644 --- a/include/prom.h +++ b/include/prom.h @@ -77,10 +77,12 @@ int prom_nbgetchar(); void prom_vprintf (char *fmt, va_list ap) __attribute__ ((format (printf, 1, 0))); void prom_fprintf (prom_handle dev, char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void prom_printf (char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +void prom_debug (char *fmt, ...) __attribute__ ((format (printf, 1, 2))); #else void prom_vprintf (char *fmt, va_list ap); void prom_fprintf (prom_handle dev, char *fmt, ...); void prom_printf (char *fmt, ...); +void prom_debug (char *fmt, ...); #endif void prom_perror (int error, char *filename); diff --git a/second/prom.c b/second/prom.c index 3310ef3..119d0f3 100644 --- a/second/prom.c +++ b/second/prom.c @@ -472,6 +472,19 @@ prom_printf (char *fmt, ...) va_end (ap); } +void +prom_debug (char *fmt, ...) +{ + va_list ap; + + if (!yaboot_debug) + return; + + va_start (ap, fmt); + prom_vfprintf (prom_stdout, fmt, ap); + va_end (ap); +} + void prom_perror (int error, char *filename) { @@ -576,26 +589,37 @@ prom_claim_chunk(void *virt, unsigned int size, unsigned int align) void *found, *addr; for(addr=virt; addr <= (void*)PROM_CLAIM_MAX_ADDR; addr+=(0x100000/sizeof(addr))) { - found = prom_claim(addr, size, 0); + found = call_prom("claim", 3, 1, addr, size, 0); if (found != (void *)-1) { - DEBUG_F("claimed %i at 0x%x (0x%x)\n",size,(int)found,(int)virt); + prom_debug("claim of 0x%x at 0x%x returned 0x%x\n", size, (int)addr, (int)found); return(found); } } - prom_printf("Claim error, can't allocate %x at 0x%x\n",size,(int)virt); + prom_printf("ERROR: claim of 0x%x in range 0x%x-0x%x failed\n", size, (int)virt, PROM_CLAIM_MAX_ADDR); return((void*)-1); } void * prom_claim (void *virt, unsigned int size, unsigned int align) { - return call_prom ("claim", 3, 1, virt, size, align); + void *ret; + + ret = call_prom ("claim", 3, 1, virt, size, align); + if (ret == (void *)-1) + prom_printf("ERROR: claim of 0x%x at 0x%x failed\n", size, (int)virt); + else + prom_debug("claim of 0x%x at 0x%x returned 0x%x\n", size, (int)virt, (int)ret); + + return ret; } void prom_release(void *virt, unsigned int size) { - call_prom ("release", 2, 0, virt, size); + void *ret; + + ret = call_prom ("release", 2, 0, virt, size); + prom_debug("release of 0x%x at 0x%x returned 0x%x\n", size, (int)virt, (int)ret); } void