a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef COMPILER_H
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define COMPILER_H
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Doxygen can't cope with some of the more esoteric areas of C, so we
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * make its life simpler.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifdef DOXYGEN
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __attribute__(x)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** @file
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Global compiler definitions.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This file is implicitly included by every @c .c file in Etherboot.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * It defines global macros such as DBG().
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * We arrange for each object to export the symbol @c obj_OBJECT
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * (where @c OBJECT is the object name, e.g. @c rtl8139) as a global
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * symbol, so that the linker can drag in selected object files from
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * the library using <tt> -u obj_OBJECT </tt>.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Force visibility of all symbols to "hidden", i.e. inform gcc that
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * all symbol references resolve strictly within our final binary.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This avoids unnecessary PLT/GOT entries on x86_64.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This is a stronger claim than specifying "-fvisibility=hidden",
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * since it also affects symbols marked with "extern".
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef ASSEMBLY
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#if __GNUC__ >= 4
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#pragma GCC visibility push(hidden)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#undef _S1
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#undef _S2
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#undef _C1
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#undef _C2
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Concatenate non-expanded arguments */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define _C1( x, y ) x ## y
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Concatenate expanded arguments */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define _C2( x, y ) _C1 ( x, y )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Stringify non-expanded argument */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define _S1( x ) #x
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Stringify expanded argument */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define _S2( x ) _S1 ( x )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @defgroup symmacros Macros to provide or require explicit symbols
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Provide a symbol within this object file */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifdef ASSEMBLY
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define PROVIDE_SYMBOL( _sym ) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync .globl _sym ; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync .comm _sym, 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#else /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define PROVIDE_SYMBOL( _sym ) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync char _sym[0]
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Require a symbol within this object file
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * The symbol is referenced by a relocation in a discarded section, so
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * if it is not available at link time the link will fail.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifdef ASSEMBLY
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define REQUIRE_SYMBOL( _sym ) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync .section ".discard", "a", @progbits ; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync .extern _sym ; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync .long _sym ; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync .previous
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#else /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define REQUIRE_SYMBOL( _sym ) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync extern char _sym; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync static char * _C2 ( _C2 ( __require_, _sym ), _C2 ( _, __LINE__ ) ) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync __attribute__ (( section ( ".discard" ), used )) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync = &_sym
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Request that a symbol be available at runtime
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * The requested symbol is entered as undefined into the symbol table
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * for this object, so the linker will pull in other object files as
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * necessary to satisfy the reference. However, the undefined symbol
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * is not referenced in any relocations, so the link can still succeed
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * if no file contains it.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * A symbol passed to this macro may not be referenced anywhere
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * else in the file. If you want to do that, see IMPORT_SYMBOL().
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifdef ASSEMBLY
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define REQUEST_SYMBOL( _sym ) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync .equ __need_ ## _sym, _sym
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#else /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define REQUEST_SYMBOL( _sym ) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync __asm__ ( ".equ\t__need_" #_sym ", " #_sym )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Set up a symbol to be usable in another file by IMPORT_SYMBOL()
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * The symbol must already be marked as global.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define EXPORT_SYMBOL( _sym ) PROVIDE_SYMBOL ( __export_ ## _sym )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Make a symbol usable to this file if available at link time
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * If no file passed to the linker contains the symbol, it will have
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @c NULL value to future uses. Keep in mind that the symbol value is
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * really the @e address of a variable or function; see the code
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * snippet below.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * In C using IMPORT_SYMBOL, you must specify the declaration as the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * second argument, for instance
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @code
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * IMPORT_SYMBOL ( my_func, int my_func ( int arg ) );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * IMPORT_SYMBOL ( my_var, int my_var );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * void use_imports ( void ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * if ( my_func && &my_var )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * my_var = my_func ( my_var );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @endcode
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * GCC considers a weak declaration to override a strong one no matter
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * which comes first, so it is safe to include a header file declaring
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * the imported symbol normally, but providing the declaration to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * IMPORT_SYMBOL is still required.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * If no EXPORT_SYMBOL declaration exists for the imported symbol in
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * another file, the behavior will be most likely be identical to that
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * for an unavailable symbol.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifdef ASSEMBLY
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define IMPORT_SYMBOL( _sym ) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync REQUEST_SYMBOL ( __export_ ## _sym ) ; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync .weak _sym
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#else /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define IMPORT_SYMBOL( _sym, _decl ) \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync REQUEST_SYMBOL ( __export_ ## _sym ) ; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync extern _decl __attribute__ (( weak ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** @} */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @defgroup objmacros Macros to provide or require explicit objects
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define PREFIX_OBJECT( _prefix ) _C2 ( _prefix, OBJECT )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define OBJECT_SYMBOL PREFIX_OBJECT ( obj_ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define REQUEST_EXPANDED( _sym ) REQUEST_SYMBOL ( _sym )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define CONFIG_SYMBOL PREFIX_OBJECT ( obj_config_ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Always provide the symbol for the current object (defined by -DOBJECT) */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncPROVIDE_SYMBOL ( OBJECT_SYMBOL );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Pull in an object-specific configuration file if available */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncREQUEST_EXPANDED ( CONFIG_SYMBOL );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Explicitly require another object */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define REQUIRE_OBJECT( _obj ) REQUIRE_SYMBOL ( obj_ ## _obj )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Pull in another object if it exists */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define REQUEST_OBJECT( _obj ) REQUEST_SYMBOL ( obj_ ## _obj )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** @} */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Select file identifier for errno.h (if used) */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define ERRFILE PREFIX_OBJECT ( ERRFILE_ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef ASSEMBLY
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a function as weak (use *before* the definition)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Due to a bug in at least GCC 4.4.4 and earlier, weak symbols may be
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * inlined if they have hidden visibility (see above for why hidden
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * visibility is used). This results in the non-weak symbol never
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * being used, so explicitly mark the function as noinline to prevent
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * inlining.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __weak __attribute__ (( weak, noinline ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Prevent a function from being optimized away without inlining
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Calls to functions with void return type that contain no code in their body
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * may be removed by gcc's optimizer even when inlining is inhibited. Placing
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * this macro in the body of the function prevents that from occurring.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __keepme asm("");
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** @defgroup dbg Debugging infrastructure
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** @def DBG
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Print a debugging message.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * The debug level is set at build time by specifying the @c DEBUG=
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * parameter on the @c make command line. For example, to enable
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * debugging for the PCI bus functions (in pci.c) in a @c .dsk image
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * for the @c rtl8139 card, you could use the command line
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @code
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * make bin/rtl8139.dsk DEBUG=pci
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @endcode
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This will enable the debugging statements (DBG()) in pci.c. If
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * debugging is not enabled, DBG() statements will be ignored.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * You can enable debugging in several objects simultaneously by
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * separating them with commas, as in
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @code
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * make bin/rtl8139.dsk DEBUG=pci,buffer,heap
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @endcode
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * You can increase the debugging level for an object by specifying it
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * with @c :N, where @c N is the level, as in
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @code
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * make bin/rtl8139.dsk DEBUG=pci,buffer:2,heap
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @endcode
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * which would enable debugging for the PCI, buffer-handling and
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * heap-allocation code, with the buffer-handling code at level 2.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * If debug_OBJECT is set to a true value, the macro DBG(...) will
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * expand to printf(...) when compiling OBJECT, and the symbol
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * DEBUG_LEVEL will be inserted into the object file.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DEBUG_SYMBOL PREFIX_OBJECT ( debug_ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#if DEBUG_SYMBOL == 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define NDEBUG
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef ASSEMBLY
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** printf() for debugging */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern void __attribute__ (( format ( printf, 1, 2 ) ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncdbg_printf ( const char *fmt, ... );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern void dbg_autocolourise ( unsigned long id );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern void dbg_decolourise ( void );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern void dbg_hex_dump_da ( unsigned long dispaddr,
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync const void *data, unsigned long len );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern void dbg_md5_da ( unsigned long dispaddr,
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync const void *data, unsigned long len );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern void dbg_pause ( void );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern void dbg_more ( void );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#if DEBUG_SYMBOL
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGLVL_MAX DEBUG_SYMBOL
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#else
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGLVL_MAX 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Allow for selective disabling of enabled debug levels */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#if DBGLVL_MAX
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncint __debug_disable;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGLVL ( DBGLVL_MAX & ~__debug_disable )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_DISABLE( level ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync __debug_disable |= (level); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_ENABLE( level ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync __debug_disable &= ~(level); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#else
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGLVL 0
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_DISABLE( level ) do { } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_ENABLE( level ) do { } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGLVL_LOG 1
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_LOG ( DBGLVL & DBGLVL_LOG )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGLVL_EXTRA 2
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_EXTRA ( DBGLVL & DBGLVL_EXTRA )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGLVL_PROFILE 4
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_PROFILE ( DBGLVL & DBGLVL_PROFILE )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGLVL_IO 8
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_IO ( DBGLVL & DBGLVL_IO )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Print debugging message if we are at a certain debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v level Debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v ... printf() argument list
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_IF( level, ... ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( DBG_ ## level ) { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync dbg_printf ( __VA_ARGS__ ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Print a hex dump if we are at a certain debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v level Debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v dispaddr Display address
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v data Data to print
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v len Length of data
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_HDA_IF( level, dispaddr, data, len ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( DBG_ ## level ) { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync union { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync unsigned long ul; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync typeof ( dispaddr ) raw; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } da; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync da.ul = 0; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync da.raw = dispaddr; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync dbg_hex_dump_da ( da.ul, data, len ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Print a hex dump if we are at a certain debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v level Debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v data Data to print
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v len Length of data
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_HD_IF( level, data, len ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync const void *_data = data; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_HDA_IF ( level, _data, _data, len ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Print an MD5 checksum if we are at a certain debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v level Debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v dispaddr Display address
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v data Data to print
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v len Length of data
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_MD5A_IF( level, dispaddr, data, len ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( DBG_ ## level ) { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync union { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync unsigned long ul; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync typeof ( dispaddr ) raw; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } da; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync da.ul = 0; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync da.raw = dispaddr; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync dbg_md5_da ( da.ul, data, len ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Print an MD5 checksum if we are at a certain debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v level Debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v data Data to print
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v len Length of data
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_MD5_IF( level, data, len ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync const void *_data = data; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_MD5A_IF ( level, _data, _data, len ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Prompt for key press if we are at a certain debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v level Debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_PAUSE_IF( level ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( DBG_ ## level ) { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync dbg_pause(); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Prompt for more output data if we are at a certain debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v level Debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_MORE_IF( level ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( DBG_ ## level ) { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync dbg_more(); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Select colour for debug messages if we are at a certain debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v level Debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v id Message stream ID
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_AC_IF( level, id ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( DBG_ ## level ) { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync union { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync unsigned long ul; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync typeof ( id ) raw; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } dbg_stream; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync dbg_stream.ul = 0; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync dbg_stream.raw = id; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync dbg_autocolourise ( dbg_stream.ul ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Revert colour for debug messages if we are at a certain debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v level Debug level
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_DC_IF( level ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( DBG_ ## level ) { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync dbg_decolourise(); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Autocolourising versions of the DBGxxx_IF() macros */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_IF( level, id, ... ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_AC_IF ( level, id ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_IF ( level, __VA_ARGS__ ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_DC_IF ( level ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_HDA_IF( level, id, ... ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_AC_IF ( level, id ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_HDA_IF ( level, __VA_ARGS__ ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_DC_IF ( level ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_HD_IF( level, id, ... ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_AC_IF ( level, id ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_HD_IF ( level, __VA_ARGS__ ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_DC_IF ( level ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_MD5A_IF( level, id, ... ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_AC_IF ( level, id ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_MD5A_IF ( level, __VA_ARGS__ ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_DC_IF ( level ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_MD5_IF( level, id, ... ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_AC_IF ( level, id ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_MD5_IF ( level, __VA_ARGS__ ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_DC_IF ( level ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_PAUSE_IF( level, id ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_AC_IF ( level, id ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_PAUSE_IF ( level ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_DC_IF ( level ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_MORE_IF( level, id ) do { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_AC_IF ( level, id ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_MORE_IF ( level ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync DBG_DC_IF ( level ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } while ( 0 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( LOG, ... )*/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG( ... ) DBG_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_HDA( ... ) DBG_HDA_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_HD( ... ) DBG_HD_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_MD5A( ... ) DBG_MD5A_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_MD5( ... ) DBG_MD5_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_PAUSE( ... ) DBG_PAUSE_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG_MORE( ... ) DBG_MORE_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC( ... ) DBGC_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_HDA( ... ) DBGC_HDA_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_HD( ... ) DBGC_HD_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_MD5A( ... ) DBGC_MD5A_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_MD5( ... ) DBGC_MD5_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_PAUSE( ... ) DBGC_PAUSE_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC_MORE( ... ) DBGC_MORE_IF ( LOG, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( EXTRA, ... )*/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG2( ... ) DBG_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG2_HDA( ... ) DBG_HDA_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG2_HD( ... ) DBG_HD_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG2_MD5A( ... ) DBG_MD5A_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG2_MD5( ... ) DBG_MD5_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG2_PAUSE( ... ) DBG_PAUSE_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBG2_MORE( ... ) DBG_MORE_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC2( ... ) DBGC_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC2_HDA( ... ) DBGC_HDA_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC2_HD( ... ) DBGC_HD_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC2_MD5A( ... ) DBGC_MD5A_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC2_MD5( ... ) DBGC_MD5_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC2_PAUSE( ... ) DBGC_PAUSE_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGC2_MORE( ... ) DBGC_MORE_IF ( EXTRA, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( PROFILE, ... )*/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGP( ... ) DBG_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGP_HDA( ... ) DBG_HDA_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGP_HD( ... ) DBG_HD_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGP_MD5A( ... ) DBG_MD5A_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGP_MD5( ... ) DBG_MD5_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGP_PAUSE( ... ) DBG_PAUSE_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGP_MORE( ... ) DBG_MORE_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCP( ... ) DBGC_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCP_HDA( ... ) DBGC_HDA_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCP_HD( ... ) DBGC_HD_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCP_MD5A( ... ) DBGC_MD5A_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCP_MD5( ... ) DBGC_MD5_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCP_PAUSE( ... ) DBGC_PAUSE_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCP_MORE( ... ) DBGC_MORE_IF ( PROFILE, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Versions of the DBGxxx_IF() macros that imply DBGxxx_IF( IO, ... )*/
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGIO( ... ) DBG_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGIO_HDA( ... ) DBG_HDA_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGIO_HD( ... ) DBG_HD_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGIO_MD5A( ... ) DBG_MD5A_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGIO_MD5( ... ) DBG_MD5_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGIO_PAUSE( ... ) DBG_PAUSE_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGIO_MORE( ... ) DBG_MORE_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCIO( ... ) DBGC_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCIO_HDA( ... ) DBGC_HDA_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCIO_HD( ... ) DBGC_HD_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCIO_MD5A( ... ) DBGC_MD5A_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCIO_MD5( ... ) DBGC_MD5_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCIO_PAUSE( ... ) DBGC_PAUSE_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define DBGCIO_MORE( ... ) DBGC_MORE_IF ( IO, ##__VA_ARGS__ )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** @} */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** @defgroup attrs Miscellaneous attributes
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef ASSEMBLY
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a variable or data structure as unused. */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __unused __attribute__ (( unused ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Declare a function as pure - i.e. without side effects
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __pure __attribute__ (( pure ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Declare a function as const - i.e. it does not access global memory
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * (including dereferencing pointers passed to it) at all.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Must also not call any non-const functions.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __const __attribute__ (( const ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Declare a function's pointer parameters as non-null - i.e. force
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * compiler to check pointers at compile time and enable possible
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * optimizations based on that fact
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __nonnull __attribute__ (( nonnull ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Declare a pointer returned by a function as a unique memory address
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * as returned by malloc-type functions.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __malloc __attribute__ (( malloc ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Declare a function as used.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Necessary only if the function is called only from assembler code.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __used __attribute__ (( used ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a data structure to be aligned with 16-byte alignment */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __aligned __attribute__ (( aligned ( 16 ) ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a function to be always inline */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __always_inline __attribute__ (( always_inline ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Force all inline functions to not be instrumented
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This is required to cope with what seems to be a long-standing gcc
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * bug, in which -finstrument-functions will cause instances of
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * inlined functions to be reported as further calls to the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * *containing* function. This makes instrumentation very difficult
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * to use.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Work around this problem by adding the no_instrument_function
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * attribute to all inlined functions.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define inline inline __attribute__ (( no_instrument_function ))
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Shared data.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * To save space in the binary when multiple-driver images are
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * compiled, uninitialised data areas can be shared between drivers.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This will typically be used to share statically-allocated receive
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * and transmit buffers between drivers.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Use as e.g.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @code
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * struct {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * char rx_buf[NUM_RX_BUF][RX_BUF_SIZE];
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * char tx_buf[TX_BUF_SIZE];
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * } my_static_data __shared;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @endcode
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define __shared __asm__ ( "_shared_bss" ) __aligned
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** @} */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Optimisation barrier
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef ASSEMBLY
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define barrier() __asm__ __volatile__ ( "" : : : "memory" )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif /* ASSEMBLY */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @defgroup licences Licence declarations
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * For reasons that are partly historical, various different files
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * within the iPXE codebase have differing licences.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a file as being in the public domain
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This licence declaration is applicable when a file states itself to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * be in the public domain.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define FILE_LICENCE_PUBLIC_DOMAIN \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync PROVIDE_SYMBOL ( __licence_public_domain )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a file as being under version 2 (or later) of the GNU GPL
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This licence declaration is applicable when a file states itself to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * be licensed under the GNU GPL; "either version 2 of the License, or
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * (at your option) any later version".
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define FILE_LICENCE_GPL2_OR_LATER \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync PROVIDE_SYMBOL ( __licence_gpl2_or_later )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a file as being under version 2 of the GNU GPL
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This licence declaration is applicable when a file states itself to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * be licensed under version 2 of the GPL, and does not include the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * "or, at your option, any later version" clause.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define FILE_LICENCE_GPL2_ONLY \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync PROVIDE_SYMBOL ( __licence_gpl2_only )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a file as being under any version of the GNU GPL
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This licence declaration is applicable when a file states itself to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * be licensed under the GPL, but does not specify a version.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * According to section 9 of the GPLv2, "If the Program does not
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * specify a version number of this License, you may choose any
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * version ever published by the Free Software Foundation".
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define FILE_LICENCE_GPL_ANY \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync PROVIDE_SYMBOL ( __licence_gpl_any )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a file as being under the three-clause BSD licence
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This licence declaration is applicable when a file states itself to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * be licensed under terms allowing redistribution in source and
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * binary forms (with or without modification) provided that:
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * redistributions of source code retain the copyright notice,
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * list of conditions and any attached disclaimers
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * redistributions in binary form reproduce the copyright notice,
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * list of conditions and any attached disclaimers in the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * documentation and/or other materials provided with the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * distribution
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * the name of the author is not used to endorse or promote
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * products derived from the software without specific prior
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * written permission
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * It is not necessary for the file to explicitly state that it is
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * under a "BSD" licence; only that the licensing terms be
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * functionally equivalent to the standard three-clause BSD licence.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define FILE_LICENCE_BSD3 \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync PROVIDE_SYMBOL ( __licence_bsd3 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a file as being under the two-clause BSD licence
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This licence declaration is applicable when a file states itself to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * be licensed under terms allowing redistribution in source and
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * binary forms (with or without modification) provided that:
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * redistributions of source code retain the copyright notice,
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * list of conditions and any attached disclaimers
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * redistributions in binary form reproduce the copyright notice,
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * list of conditions and any attached disclaimers in the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * documentation and/or other materials provided with the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * distribution
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * It is not necessary for the file to explicitly state that it is
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * under a "BSD" licence; only that the licensing terms be
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * functionally equivalent to the standard two-clause BSD licence.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define FILE_LICENCE_BSD2 \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync PROVIDE_SYMBOL ( __licence_bsd2 )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a file as being under the one-clause MIT-style licence
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This licence declaration is applicable when a file states itself to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * be licensed under terms allowing redistribution for any purpose
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * with or without fee, provided that the copyright notice and
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * permission notice appear in all copies.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define FILE_LICENCE_MIT \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync PROVIDE_SYMBOL ( __licence_mit )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** Declare a particular licence as applying to a file */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define FILE_LICENCE( _licence ) FILE_LICENCE_ ## _licence
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/** @} */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* This file itself is under GPLv2-or-later */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncFILE_LICENCE ( GPL2_OR_LATER );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#include <bits/compiler.h>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif /* COMPILER_H */