From patchwork Fri Jul 9 05:03:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 58331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id BB3C3B7092 for ; Fri, 9 Jul 2010 15:11:12 +1000 (EST) Received: by ozlabs.org (Postfix, from userid 1010) id ED510B6F19; Fri, 9 Jul 2010 15:11:10 +1000 (EST) Message-Id: <20100709050342.088080677@samba.org> User-Agent: quilt/0.48-1 Date: Fri, 09 Jul 2010 15:03:38 +1000 From: Anton Blanchard To: yaboot-devel@lists.ozlabs.org Subject: [patch 08/14] Add claim/release runtime debug output References: <20100709050330.507659708@samba.org> Content-Disposition: inline; filename=prom_debug_claim X-BeenThere: yaboot-devel@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Technical and development discussion regarding yaboot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org 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 Index: yaboot/second/prom.c =================================================================== --- yaboot.orig/second/prom.c 2010-07-08 17:08:03.000000000 +1000 +++ yaboot/second/prom.c 2010-07-08 17:08:07.000000000 +1000 @@ -473,6 +473,19 @@ prom_printf (char *fmt, ...) } 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) { if (error == FILE_ERR_EOF) @@ -576,26 +589,37 @@ prom_claim_chunk(void *virt, unsigned in 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 Index: yaboot/include/prom.h =================================================================== --- yaboot.orig/include/prom.h 2010-07-08 17:08:03.000000000 +1000 +++ yaboot/include/prom.h 2010-07-08 17:08:07.000000000 +1000 @@ -76,10 +76,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);