From patchwork Mon Nov 20 22:33:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 839797 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="RlmW4Elq"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ygk8d0zYZz9sRW for ; Tue, 21 Nov 2017 09:36:17 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CE7CCC22113; Mon, 20 Nov 2017 22:34:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DF1D1C21FEA; Mon, 20 Nov 2017 22:33:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C3C64C22007; Mon, 20 Nov 2017 22:33:53 +0000 (UTC) Received: from mail-it0-f68.google.com (mail-it0-f68.google.com [209.85.214.68]) by lists.denx.de (Postfix) with ESMTPS id B2D23C22014 for ; Mon, 20 Nov 2017 22:33:47 +0000 (UTC) Received: by mail-it0-f68.google.com with SMTP id 187so11482055iti.1 for ; Mon, 20 Nov 2017 14:33:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=pKRyZ3hXunfq4RX4LlMUdMpq31V8BChuRFd8LDmUeHY=; b=RlmW4ElqPG0/glZM8+2d54iTLmwN96wJXEmFoOjkB2XRDnqRnCjZZ5Ht5REPkPDnIs 43c690D9P0DvUPAqqiEEEBIlBTBuINFfsobFLXacjrZt/Hauff0nZAJuqoNtvXC6KsHg WKmY7O1VuYcVR9aLR28v66Nqr8HueVdAFGBl7+fjhTC4DvBDWSGW62+My+zfJCFHo37R g73HwFrL0i9ahHBh2qntXQMRALlqAQmtskVSbH3ajWqfIY1S5VnrLAMtLcIS0b2dWrZh SN5XNK2s0aOCQXfbuIAfketWkQuS7/81m2PZ8UwPwgfMQlx5nAg1IEyp0eskxXkmyJRL RzIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=pKRyZ3hXunfq4RX4LlMUdMpq31V8BChuRFd8LDmUeHY=; b=swoPmMfnSZY1Xb5Z7euPyeyMTmrplroqOQ6jImelSDZWsN40OhIFFb1MvNEnorzBlJ V0O2xssRWTowzLu4tkxpjA2RVt0Easr3VMayejb7ShlH0/rwxRHG+YDlguDiwZ7cJOA0 a8AtFSNAQ4acyQGIw10P3Q/sgppATxAbYLbQWSvjpf7IXE/eHwRszuzRuuCZGJRrUyLZ TQCeZ7xnMrFHflM4nOVDMW9GIsQhUf0AD0IsA/Vt1O0jqmGnhuZubSxrohCR1BHCHY/h lGBoLOjDRrSfTLcYR5ZbLRsAPCxR0qzIelxP22jy6SV5Pvl93N+1tMAclVNhrJw7AG2/ /ygQ== X-Gm-Message-State: AJaThX6Q8KPYwOS4tVgJuU2ILFCVylM6n4dYiNYuBQBGC+jdQuazdnOo 7aYumagLpE538bDOgjyU/dqjgw== X-Google-Smtp-Source: AGs4zMYiUAz+nWBbGBcbpG+aRXe4NYEC75YFIEK+0V+93qCQJ02sK+QjEb12JLg/KHRygykAg1WeYw== X-Received: by 10.36.66.18 with SMTP id i18mr21446724itb.148.1511217226144; Mon, 20 Nov 2017 14:33:46 -0800 (PST) Received: from kiwi.bld.corp.google.com ([100.101.164.89]) by smtp.gmail.com with ESMTPSA id 191sm5446442itb.21.2017.11.20.14.33.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 14:33:45 -0800 (PST) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 1FE7213FF3B; Mon, 20 Nov 2017 15:33:44 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Mon, 20 Nov 2017 15:33:25 -0700 Message-Id: <20171120223335.45852-5-sjg@chromium.org> X-Mailer: git-send-email 2.15.0.448.gf294e3d99a-goog In-Reply-To: <20171120223335.45852-1-sjg@chromium.org> References: <20171120223335.45852-1-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH v3 04/14] Move debug and logging support to a separate header X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Before adding new features, move these definitions to a separate header to avoid further cluttering common.h. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Reviewed-by: Lukasz Majewski --- Changes in v3: None Changes in v2: None include/common.h | 46 +------------------------------------------ include/log.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 45 deletions(-) create mode 100644 include/log.h diff --git a/include/common.h b/include/common.h index e14e1daa88b..90334a8c086 100644 --- a/include/common.h +++ b/include/common.h @@ -45,51 +45,7 @@ typedef volatile unsigned char vu_char; #define CONFIG_SYS_SUPPORT_64BIT_DATA #endif -#ifdef DEBUG -#define _DEBUG 1 -#else -#define _DEBUG 0 -#endif - -#ifdef CONFIG_SPL_BUILD -#define _SPL_BUILD 1 -#else -#define _SPL_BUILD 0 -#endif - -/* - * Output a debug text when condition "cond" is met. The "cond" should be - * computed by a preprocessor in the best case, allowing for the best - * optimization. - */ -#define debug_cond(cond, fmt, args...) \ - do { \ - if (cond) \ - printf(pr_fmt(fmt), ##args); \ - } while (0) - -/* Show a message if DEBUG is defined in a file */ -#define debug(fmt, args...) \ - debug_cond(_DEBUG, fmt, ##args) - -/* Show a message if not in SPL */ -#define warn_non_spl(fmt, args...) \ - debug_cond(!_SPL_BUILD, fmt, ##args) - -/* - * An assertion is run-time check done in debug mode only. If DEBUG is not - * defined then it is skipped. If DEBUG is defined and the assertion fails, - * then it calls panic*( which may or may not reset/halt U-Boot (see - * CONFIG_PANIC_HANG), It is hoped that all failing assertions are found - * before release, and after release it is hoped that they don't matter. But - * in any case these failing assertions cannot be fixed with a reset (which - * may just do the same assertion again). - */ -void __assert_fail(const char *assertion, const char *file, unsigned line, - const char *function); -#define assert(x) \ - ({ if (!(x) && _DEBUG) \ - __assert_fail(#x, __FILE__, __LINE__, __func__); }) +#include typedef void (interrupt_handler_t)(void *); diff --git a/include/log.h b/include/log.h new file mode 100644 index 00000000000..08ad44cf497 --- /dev/null +++ b/include/log.h @@ -0,0 +1,59 @@ +/* + * Logging support + * + * Copyright (c) 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __LOG_H +#define __LOG_H + +#ifdef DEBUG +#define _DEBUG 1 +#else +#define _DEBUG 0 +#endif + +#ifdef CONFIG_SPL_BUILD +#define _SPL_BUILD 1 +#else +#define _SPL_BUILD 0 +#endif + +/* + * Output a debug text when condition "cond" is met. The "cond" should be + * computed by a preprocessor in the best case, allowing for the best + * optimization. + */ +#define debug_cond(cond, fmt, args...) \ + do { \ + if (cond) \ + printf(pr_fmt(fmt), ##args); \ + } while (0) + +/* Show a message if DEBUG is defined in a file */ +#define debug(fmt, args...) \ + debug_cond(_DEBUG, fmt, ##args) + +/* Show a message if not in SPL */ +#define warn_non_spl(fmt, args...) \ + debug_cond(!_SPL_BUILD, fmt, ##args) + +/* + * An assertion is run-time check done in debug mode only. If DEBUG is not + * defined then it is skipped. If DEBUG is defined and the assertion fails, + * then it calls panic*( which may or may not reset/halt U-Boot (see + * CONFIG_PANIC_HANG), It is hoped that all failing assertions are found + * before release, and after release it is hoped that they don't matter. But + * in any case these failing assertions cannot be fixed with a reset (which + * may just do the same assertion again). + */ +void __assert_fail(const char *assertion, const char *file, unsigned int line, + const char *function); +#define assert(x) \ + ({ if (!(x) && _DEBUG) \ + __assert_fail(#x, __FILE__, __LINE__, __func__); }) + +#endif