arm-trusted-firmware/plat/hisilicon/hikey
Masahiro Yamada 0a2d5b43c8 types: use int-ll64 for both aarch32 and aarch64
Since commit 031dbb1224 ("AArch32: Add essential Arch helpers"),
it is difficult to use consistent format strings for printf() family
between aarch32 and aarch64.

For example, uint64_t is defined as 'unsigned long long' for aarch32
and as 'unsigned long' for aarch64.  Likewise, uintptr_t is defined
as 'unsigned int' for aarch32, and as 'unsigned long' for aarch64.

A problem typically arises when you use printf() in common code.

One solution could be, to cast the arguments to a type long enough
for both architectures.  For example, if 'val' is uint64_t type,
like this:

  printf("val = %llx\n", (unsigned long long)val);

Or, somebody may suggest to use a macro provided by <inttypes.h>,
like this:

  printf("val = %" PRIx64 "\n", val);

But, both would make the code ugly.

The solution adopted in Linux kernel is to use the same typedefs for
all architectures.  The fixed integer types in the kernel-space have
been unified into int-ll64, like follows:

    typedef signed char           int8_t;
    typedef unsigned char         uint8_t;

    typedef signed short          int16_t;
    typedef unsigned short        uint16_t;

    typedef signed int            int32_t;
    typedef unsigned int          uint32_t;

    typedef signed long long      int64_t;
    typedef unsigned long long    uint64_t;

[ Linux commit: 0c79a8e29b5fcbcbfd611daf9d500cfad8370fcf ]

This gets along with the codebase shared between 32 bit and 64 bit,
with the data model called ILP32, LP64, respectively.

The width for primitive types is defined as follows:

                   ILP32           LP64
    int            32              32
    long           32              64
    long long      64              64
    pointer        32              64

'long long' is 64 bit for both, so it is used for defining uint64_t.
'long' has the same width as pointer, so for uintptr_t.

We still need an ifdef conditional for (s)size_t.

All 64 bit architectures use "unsigned long" size_t, and most 32 bit
architectures use "unsigned int" size_t.  H8/300, S/390 are known as
exceptions; they use "unsigned long" size_t despite their architecture
is 32 bit.

One idea for simplification might be to define size_t as 'unsigned long'
across architectures, then forbid the use of "%z" string format.
However, this would cause a distortion between size_t and sizeof()
operator.  We have unknowledge about the native type of sizeof(), so
we need a guess of it anyway.  I want the following formula to always
return 1:

  __builtin_types_compatible_p(size_t, typeof(sizeof(int)))

Fortunately, ARM is probably a majority case.  As far as I know, all
32 bit ARM compilers use "unsigned int" size_t.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-04-27 18:35:02 +09:00
..
aarch64 plat/hikey: boot memory layout to dedicated file 2018-03-12 13:19:00 +01:00
include plat/hikey: boot memory layout to dedicated file 2018-03-12 13:19:00 +01:00
hikey_bl1_setup.c types: use int-ll64 for both aarch32 and aarch64 2018-04-27 18:35:02 +09:00
hikey_bl2_mem_params_desc.c plat/hikey: boot memory layout to dedicated file 2018-03-12 13:19:00 +01:00
hikey_bl2_setup.c hikey: clean sram before mcu used 2018-04-11 19:06:14 +08:00
hikey_bl31_setup.c plat/hikey: boot memory layout to dedicated file 2018-03-12 13:19:00 +01:00
hikey_bl_common.c hikey: move out duplicated code 2018-03-05 13:03:53 +08:00
hikey_ddr.c hikey: save ddr parameters into SRAM 2018-04-11 19:05:59 +08:00
hikey_image_load.c hikey*: Add LOAD_IMAGE_V2 support 2017-09-01 22:47:50 +09:00
hikey_io_storage.c hikey: migrate to bl2_el3 2018-03-05 09:51:43 +08:00
hikey_pm.c plat/hikey: boot memory layout to dedicated file 2018-03-12 13:19:00 +01:00
hikey_private.h hikey: update ddr initialization 2018-04-11 19:05:32 +08:00
hikey_security.c hikey: fix assert in sec_protect() 2018-01-28 00:07:07 +09:00
hikey_topology.c hikey: fix for CPU topology 2017-05-31 13:19:05 +08:00
hisi_dvfs.c hikey: support BL2 2017-05-24 17:34:41 +01:00
hisi_ipc.c hikey: support BL31 2017-05-24 17:34:41 +01:00
hisi_mcu.c hikey: support BL2 2017-05-24 17:34:41 +01:00
hisi_pwrc.c Hikey: enable CPU debug module 2017-09-07 16:57:31 +08:00
hisi_pwrc_sram.S HiKey: Rename CPUACTRL reg constants 2017-08-29 13:52:48 +01:00
hisi_sip_svc.c Fix order of remaining platform #includes 2017-07-14 10:50:41 +01:00
platform.mk Merge pull request #1277 from hzhuang1/testing/bl2_el3_v0.6 2018-03-08 10:39:52 +00:00