Commit ac91a7f3 authored by Alessandro Rubini's avatar Alessandro Rubini

build and doc: use pp_printf and better conventions

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 5a8b8d50
...@@ -25,7 +25,13 @@ CFLAGS += -Wall -O2 -ggdb -Iinclude ...@@ -25,7 +25,13 @@ CFLAGS += -Wall -O2 -ggdb -Iinclude
# to avoid ifdef as much as possible, I use the kernel trick for OBJ variables # to avoid ifdef as much as possible, I use the kernel trick for OBJ variables
OBJ-y := fsm.o OBJ-y := fsm.o
# include diagnostic objects # include pp_printf code, by default the "full" version. Please
# set CONFIG_PRINTF_NONE or CONFIG_PRINTF_XINT if needed.
OBJ-y += pp_printf/pp-printf.o
pp_printf/pp-printf.o: $(wildcard pp_printf/*.[ch])
$(MAKE) -C pp_printf pp-printf.o
include diag/Makefile include diag/Makefile
# Update 2012-07-10 # Update 2012-07-10
......
# Alessandro Rubini for CERN, 2011 -- public domain # Alessandro Rubini for CERN, 2011 -- public domain
# Diagnostics: we have tree levels: none, full and limited # This changed in 2013-02, and it's incompatible with what we had
# full: use a complete printf and the diag code ifdef PPSI_NO_DIAG
OBJ-$(HAS_FULL_DIAG) += diag/diag-yes.o OBJ-y += diag/diag-no.o
ifdef INTERNAL_PRINTF else
OBJ-$(HAS_FULL_DIAG) += diag/diag-printf.o diag/printf-full.o OBJ-y += diag/diag-yes.o
endif endif
# limited: use a minimal printf (can't coexist with FULL_DIAG) ifdef HAS_DIAG
ifndef HAS_FULL_DIAG SAY := $(shell echo "WARNING: ppsi doesn't use \$$HAS_DIAG any more" >&2)
OBJ-$(HAS_DIAG) += diag/diag-yes.o diag/diag-printf.o diag/printf-mini.o
endif endif
ifdef HAS_FULL_DIAG
# no diagnostics: the diag-no.c file includes weak aliases to an empty func SAY := $(shell echo "WARNING: ppsi doesn't use \$$HAS_FULL_DIAG any more" >&2)
OBJ-y += diag/diag-no.o endif
\ No newline at end of file
...@@ -66,22 +66,13 @@ environment: ...@@ -66,22 +66,13 @@ environment:
CROSS_COMPILE prefix, like "arm-linux-", or empty CROSS_COMPILE prefix, like "arm-linux-", or empty
PROTO_EXT "whiterabbit" or empty PROTO_EXT "whiterabbit" or empty
ARCH name of you arch (default: gnu-linux) ARCH name of you arch (default: gnu-linux)
HAS_DIAG set to "y" or leave unset PPSI_NO_DIAG if set, prevents diagnostics from being there
HAS_FULL_DIAG set to "y" or leave unset
WRMODE (spec only) set to "master" for m/s autodetect; set to WRMODE (spec only) set to "master" for m/s autodetect; set to
"slave" for slave only configuration "slave" for slave only configuration
NOTE: The default has no diagnostics, so you most likely will want to run
make HAS_FULL_DIAG=y
or just "make" after running
export HAS_FULL_DIAG=y
If none of the variables are specified, the default Makefile compiles If none of the variables are specified, the default Makefile compiles
with standard gcc, over gnu-linux architecture, with no protocol with standard gcc, over gnu-linux architecture, with no protocol
extension and no diagnostic. extension and full diagnostic conde (relying on pp_printf).
Implementation Details Implementation Details
...@@ -100,8 +91,9 @@ is LGPL-2.1 or later. ...@@ -100,8 +91,9 @@ is LGPL-2.1 or later.
All the rest of the package is built as libraries. The link order All the rest of the package is built as libraries. The link order
of libraries selects which object files are picked up and which are not. of libraries selects which object files are picked up and which are not.
Additionally, "HAS_DIAG" and "HAS_FULL_DIAG" select by Makefile rules Additionally, "CONFIG_PRINTF_XINT" or one of the other pp_printf
which diagnostic implementation (if any) is part of the diag library. configurations can be set to override the default (which selects the
most complete printf implementation from the package).
This state-machine source has three undefined symbols: two for This state-machine source has three undefined symbols: two for
diagnostics and the "pp_state_table". The table is picked by a diagnostics and the "pp_state_table". The table is picked by a
...@@ -158,24 +150,17 @@ similar to what you already see for `arch-'. ...@@ -158,24 +150,17 @@ similar to what you already see for `arch-'.
Diagnostics Diagnostics
=========== ===========
Diagnostic functions may call printf(). If you select HAS_DIAG, the Diagnostic functions may call pp_printf(). They should not call
daemon is built with a minimal printf implementation. printf() because it is not available when building from freestanding
environments. You can use the Kconfig-like environment variables
HAS_FULL_DIAG Selects a complete printf implementation to choose which pp_printf implementation to build. The default is
HAS_DIAG Selects a smaller printf the full function and should be good for everyone. If you have
-- By default a no-op printf is selected size problems, please check pp_printf/README about the options.
The complete implementation comes from an older Linux implementation ppsi up to 2013-01 had no diagnostics by default and used the
(we pulled it from U-boot) as the kernel has currently extra stuff like environment variables HAS_DIAG and HAS_FULL_DIAG. They are not
%-rules for printing IPV4/IPV6 addresses, symbol tables and so on. used any more and the Makefile warns about them, to ease previous
users.
The small implementation receives and parses the complete % formats
but only obeys %c and %s; everything else is printed as 32-bit hex
numbers. So you can use "%-10s %3i" and the output will still make some
sense, saving some kilobytes in code. The code is derived from the full
printf by stripping out code, so the same parsing applies for sure.
With no diagnostics, the printf does nothing and only puts() is available.
Command Line Command Line
============ ============
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment