summaryrefslogtreecommitdiff
path: root/common/printf.c
Commit message (Collapse)AuthorAgeFilesLines
* console: Add non-verbose print config optionShawn Nematbakhsh2017-02-111-0/+5
| | | | | | | | | | | | | | | | | Shorten certain long prints and reduce the precision of timestamp prints when CONFIG_CONSOLE_VERBOSE is undef'd. BUG=chromium:688743 BRANCH=gru TEST=On kevin, cold reset the EC, boot to OS, and verify cros_ec.log contains all data since sysjump and is < 2K bytes (~1500 bytes). Change-Id: Ia9390867788d0ab3087f827b0296107b4e9d4bca Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/438932 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* printf: Add sign ('+') flagDaisuke Nojiri2016-07-291-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | '+' flag can be used with signed integer type (%d) and causes positive integers to be prefixed with '+' (e.g. +1745). This emphasizes output values as a signed value. It can be mixed with left-justification flag '-': %-+8d. It's ignored when used with unsigned integer or non-integer types: %u, %x, %p, %s, %c, etc. BUG=none BRANCH=none TEST=make buildall && int32_t d = 1745; CPRINTS("'%-+8d'", -d); /* '-1745 ' */ CPRINTS("'%-+8d'", d); /* '+1745 ' */ CPRINTS("'%d'", d); /* '1745' */ CPRINTS("'%+08d'", -d); /* '000-1745' */ CPRINTS("'%+08d'", d); /* '000+1745' */ CPRINTS("'%+d'", -d); /* '-1745' */ CPRINTS("'%+d'", d); /* '+1745' */ CPRINTS("'%+s'", "foo"); /* 'foo' */ CPRINTS("'%-+8s'", "foo"); /* 'foo ' */ CPRINTS("'%+08x'", d); /* '000006d1' */ CPRINTS("'%+u'", d); /* '1745' */ Change-Id: I8dcd34b0cf03dbefc500b9c98fea235d85bde8d3 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/363924
* stm32: add synchronous debug printfAlec Berg2015-10-191-2/+2
| | | | | | | | | | | | | | | | | | Allow use of a synchronous debug printf instead of using the full console task to save space. This can be turned on with CONFIG_DEBUG_PRINTF, and will provide essentially a one-way console for debugging. This is essentially expanding upon the debug_printf work done for zinger. BUG=chrome-os-partner:41959 BRANCH=none TEST=tested with following CLs on glados_pd by verifying we get a one-way console. Change-Id: If028b5d873261890de5b270bbc00e06bdcaa7431 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/306782 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* optimize printf size without the common runtimeVincent Palatin2015-04-101-3/+25
| | | | | | | | | | | | | | | | | | | | | | | When a platform is built without the common runtime to optimize for flash size, remove the 64-bit support in printf to save more space (mainly by getting rid of the uint64divmod helper). This saves 376 bytes of flash on Zinger/MiniMuffin. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make buildall and compare flash size with and without the change. the common runtime binaries are identical excepted the version information. Change-Id: I1e7237e693df9ea23291c8c0fe414c3b5c716848 Reviewed-on: https://chromium-review.googlesource.com/265052 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* cleanup: Remove checkpatch warningsRandall Spangler2013-12-191-1/+1
| | | | | | | | | | | | | | | | This make minor syntactic changes and renames some camel-cased symbols to keep checkpatch from complaining. The goal is to reduce the temptation to use 'repo upload --no-verify'. This is a big furball of find/replace, but no functional changes. BUG=chromium:322144 BRANCH=none TEST=build all boards; pass unit tests Change-Id: I0269b7dd95836ef9a6e33f88c003ab0f24f842a0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/180495
* Reduce stack space used by vfnprintf()Randall Spangler2013-11-201-36/+51
| | | | | | | | | | | | | | | | | | | | Converting some of the boolean variables in vfnprintf() to a single flags word reduces stack usage by 8 bytes and function size by 12 bytes. So it's slightly more efficient in both respects. Confirmed size and stack usage improvements via 'make BOARD=rambi all dis' and looking at the disassembly for vfnprintf() BUG=chrome-os-partner:24148 BRANCH=none TEST=Run taskinfo command twice and compare stack used by CONSOLE task. Run timerinfo and charger commands and verify output looks reasonable; those exercise binary and 64-bit number printing. Change-Id: Ie4396bb0bc01dc155956fa2d8ca84c6630006729 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/177400 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Clean up printf moduleRandall Spangler2012-10-251-10/+22
| | | | | | | | | | | | | No functional changes. BUG=chrome-os-partner:15579 BRANCH=none TEST=boot system; debug output still shows up on EC console Change-Id: I63f4f9481f5393aaff065b37a274236bd78622d9 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36581 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Enhance printf()Randall Spangler2012-07-301-22/+88
| | | | | | | | | | | | | | | | | | | 1. Add precision to limit string length. ccprintf("%.4s", "foobar") prints "foob" 2. Handle '*' for length, precision fields. ccprintf("%.*s", 3, "foobar") prints "foo" 3. Add hex-dump code "%h" ccprintf("%.*s", 4, "foobar") prints 666f6f62 BUG=none TEST=at ec console, 'hash' prints the current hash Change-Id: I568310f2727495b021081bf58df2a0bbb3c74e73 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28704 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Fix printing hex numbersRandall Spangler2012-06-071-2/+2
| | | | | | | | | | | | | | | | Off-by-one is not my friend. BUG=chrome-os-partner:10206 TEST=manual 1. rw 0x20000000 2. ww back the same number printed 3. rw 0x20000000. should match Signed-off-by: Randall Spangler <rspangler@chromium.org> Change-Id: I61e0d26cf4cb274a88326d4e7d24ff1c82d6e515 Reviewed-on: https://gerrit.chromium.org/gerrit/24756 Reviewed-by: Simon Glass <sjg@chromium.org>
* Move printf() formatting to its own file to enable re-useRandall Spangler2012-06-071-0/+236
Also add snprintf(), and %X format code. BUG=chrome-os-partner:10206 TEST=timerinfo; should print correctly. 'ectool battery' on host side should print same serial as 'battery' on EC console. Change-Id: I5c9f69d1a20ee5d0a59440c122655adbf62c9aea Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/24635 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>