Make TF UUID RFC 4122 compliant

RFC4122 defines that fields are stored in network order (big endian),
but TF-A stores them in machine order (little endian by default in TF-A).
We cannot change the future UUIDs that are already generated, but we can store
all the bytes using arrays and modify fiptool to generate the UUIDs with
the correct byte order.

Change-Id: I97be2d3168d91f4dee7ccfafc533ea55ff33e46f
Signed-off-by: Roberto Vargas <roberto.vargas@arm.com>
diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c
index 9f7e290..64b363c 100644
--- a/bl1/bl1_main.c
+++ b/bl1/bl1_main.c
@@ -21,8 +21,8 @@
 #include "bl1_private.h"
 
 /* BL1 Service UUID */
-DEFINE_SVC_UUID(bl1_svc_uid,
-	0xfd3967d4, 0x72cb, 0x4d9a, 0xb5, 0x75,
+DEFINE_SVC_UUID2(bl1_svc_uid,
+	0xd46739fd, 0xcb72, 0x9a4d, 0xb5, 0x75,
 	0x67, 0x15, 0xd6, 0xf4, 0xbb, 0x4a);
 
 static void bl1_load_bl2(void);
diff --git a/drivers/io/io_fip.c b/drivers/io/io_fip.c
index 487f586..1754339 100644
--- a/drivers/io/io_fip.c
+++ b/drivers/io/io_fip.c
@@ -32,7 +32,7 @@
 	fip_toc_entry_t entry;
 } file_state_t;
 
-static const uuid_t uuid_null = {0};
+static const uuid_t uuid_null = { {0} };
 static file_state_t current_file = {0};
 static uintptr_t backend_dev_handle;
 static uintptr_t backend_image_spec;
diff --git a/include/lib/smccc.h b/include/lib/smccc.h
index 660c1db..cb722b0 100644
--- a/include/lib/smccc.h
+++ b/include/lib/smccc.h
@@ -57,6 +57,7 @@
  * does not equal SMC_UNK. This is to ensure that the caller won't mistake the
  * returned UUID in x0 for an invalid SMC error return
  */
+#if !ERROR_DEPRECATED
 #define DEFINE_SVC_UUID(_name, _tl, _tm, _th, _cl, _ch, \
 		_n0, _n1, _n2, _n3, _n4, _n5) \
 	CASSERT((uint32_t)(_tl) != (uint32_t) SMC_UNK, invalid_svc_uuid);\
@@ -64,6 +65,24 @@
 		_tl, _tm, _th, _cl, _ch, \
 		{ _n0, _n1, _n2, _n3, _n4, _n5 } \
 	}
+#endif
+
+
+#define DEFINE_SVC_UUID2(_name, _tl, _tm, _th, _cl, _ch,		\
+		_n0, _n1, _n2, _n3, _n4, _n5)				\
+	CASSERT((uint32_t)(_tl) != (uint32_t) SMC_UNK, invalid_svc_uuid);\
+	static const uuid_t _name = {					\
+		{(_tl >> 24) & 0xFF,					\
+		 (_tl >> 16) & 0xFF,					\
+		 (_tl >> 8)  & 0xFF,					\
+		 (_tl & 0xFF)},						\
+		{(_tm >> 8) & 0xFF,					\
+		 (_tm  & 0xFF)},					\
+		{(_th >> 8) & 0xFF,					\
+		 (_th & 0xFF)},						\
+		_cl, _ch,						\
+		{ _n0, _n1, _n2, _n3, _n4, _n5 }			\
+	}
 
 #endif /*__ASSEMBLY__*/
 #endif /* __SMCCC_H__ */
diff --git a/include/tools_share/firmware_image_package.h b/include/tools_share/firmware_image_package.h
index f258555..b1ce56a 100644
--- a/include/tools_share/firmware_image_package.h
+++ b/include/tools_share/firmware_image_package.h
@@ -16,64 +16,64 @@
 
 /* ToC Entry UUIDs */
 #define UUID_TRUSTED_UPDATE_FIRMWARE_SCP_BL2U \
-	{0x03279265, 0x742f, 0x44e6, 0x8d, 0xff, {0x57, 0x9a, 0xc1, 0xff, 0x06, 0x10} }
+	{{0x65, 0x92, 0x27, 0x03}, {0x2f, 0x74}, {0xe6, 0x44}, 0x8d, 0xff, {0x57, 0x9a, 0xc1, 0xff, 0x06, 0x10} }
 #define UUID_TRUSTED_UPDATE_FIRMWARE_BL2U \
-	{0x37ebb360, 0xe5c1, 0x41ea, 0x9d, 0xf3, {0x19, 0xed, 0xa1, 0x1f, 0x68, 0x01} }
+	{{0x60, 0xb3, 0xeb, 0x37}, {0xc1, 0xe5}, {0xea, 0x41}, 0x9d, 0xf3, {0x19, 0xed, 0xa1, 0x1f, 0x68, 0x01} }
 #define UUID_TRUSTED_UPDATE_FIRMWARE_NS_BL2U \
-	{0x111d514f, 0xe52b, 0x494e, 0xb4, 0xc5, {0x83, 0xc2, 0xf7, 0x15, 0x84, 0x0a} }
+	{{0x4f, 0x51, 0x1d, 0x11}, {0x2b, 0xe5}, {0x4e, 0x49}, 0xb4, 0xc5, {0x83, 0xc2, 0xf7, 0x15, 0x84, 0x0a} }
 #define UUID_TRUSTED_FWU_CERT \
-	{0xb28a4071, 0xd618, 0x4c87, 0x8b, 0x2e, {0xc6, 0xdc, 0xcd, 0x50, 0xf0, 0x96} }
+	{{0x71, 0x40, 0x8a, 0xb2}, {0x18, 0xd6}, {0x87, 0x4c}, 0x8b, 0x2e, {0xc6, 0xdc, 0xcd, 0x50, 0xf0, 0x96} }
 #define UUID_TRUSTED_BOOT_FIRMWARE_BL2 \
-	{0x0becf95f, 0x224d, 0x4d3e, 0xa5, 0x44, {0xc3, 0x9d, 0x81, 0xc7, 0x3f, 0x0a} }
+	{{0x5f, 0xf9, 0xec, 0x0b}, {0x4d, 0x22}, {0x3e, 0x4d}, 0xa5, 0x44, {0xc3, 0x9d, 0x81, 0xc7, 0x3f, 0x0a} }
 #define UUID_SCP_FIRMWARE_SCP_BL2 \
-	{0x3dfd6697, 0xbe89, 0x49e8, 0xae, 0x5d, {0x78, 0xa1, 0x40, 0x60, 0x82, 0x13} }
+	{{0x97,  0x66, 0xfd, 0x3d}, {0x89, 0xbe}, {0xe8, 0x49}, 0xae, 0x5d, {0x78, 0xa1, 0x40, 0x60, 0x82, 0x13} }
 #define UUID_EL3_RUNTIME_FIRMWARE_BL31 \
-	{0x6d08d447, 0xfe4c, 0x4698, 0x9b, 0x95, {0x29, 0x50, 0xcb, 0xbd, 0x5a, 0x00} }
+	{{0x47,  0xd4, 0x08, 0x6d}, {0x4c, 0xfe}, {0x98, 0x46}, 0x9b, 0x95, {0x29, 0x50, 0xcb, 0xbd, 0x5a, 0x00} }
 #define UUID_SECURE_PAYLOAD_BL32 \
-	{0x89e1d005, 0xdc53, 0x4713, 0x8d, 0x2b, {0x50, 0x0a, 0x4b, 0x7a, 0x3e, 0x38} }
+	{{0x05,  0xd0, 0xe1, 0x89}, {0x53, 0xdc}, {0x13, 0x47}, 0x8d, 0x2b, {0x50, 0x0a, 0x4b, 0x7a, 0x3e, 0x38} }
 #define UUID_SECURE_PAYLOAD_BL32_EXTRA1 \
-	{0x9bc2700b, 0x5a2a, 0x4078, 0x9f, 0x65, {0x0a, 0x56, 0x82, 0x73, 0x82, 0x88} }
+	{{0x0b,  0x70, 0xc2, 0x9b}, {0x2a, 0x5a}, {0x78, 0x40}, 0x9f, 0x65, {0x0a, 0x56, 0x82, 0x73, 0x82, 0x88} }
 #define UUID_SECURE_PAYLOAD_BL32_EXTRA2 \
-	{0xb17ba88e, 0xa2cf, 0x4d3f, 0x85, 0xfd, {0xe7, 0xbb, 0xa5, 0x02, 0x20, 0xd9} }
+	{{0x8e,  0xa8, 0x7b, 0xb1}, {0xcf, 0xa2}, {0x3f, 0x4d}, 0x85, 0xfd, {0xe7, 0xbb, 0xa5, 0x02, 0x20, 0xd9} }
 #define UUID_NON_TRUSTED_FIRMWARE_BL33 \
-	{0xa7eed0d6, 0xeafc, 0x4bd5, 0x97, 0x82, {0x99, 0x34, 0xf2, 0x34, 0xb6, 0xe4} }
+	{{0xd6,  0xd0, 0xee, 0xa7}, {0xfc, 0xea}, {0xd5, 0x4b}, 0x97, 0x82, {0x99, 0x34, 0xf2, 0x34, 0xb6, 0xe4} }
 /* Key certificates */
 #define UUID_ROT_KEY_CERT \
-	{0x721d2d86, 0x60f8, 0x11e4, 0x92, 0x0b, {0x8b, 0xe7, 0x62, 0x16, 0x0f, 0x24} }
+	{{0x86,  0x2d, 0x1d, 0x72}, {0xf8, 0x60}, {0xe4, 0x11}, 0x92, 0x0b, {0x8b, 0xe7, 0x62, 0x16, 0x0f, 0x24} }
 #define UUID_TRUSTED_KEY_CERT \
-	{0x90e87e82, 0x60f8, 0x11e4, 0xa1, 0xb4, {0x77, 0x7a, 0x21, 0xb4, 0xf9, 0x4c} }
+	{{0x82,  0x7e, 0xe8, 0x90}, {0xf8, 0x60}, {0xe4, 0x11}, 0xa1, 0xb4, {0x77, 0x7a, 0x21, 0xb4, 0xf9, 0x4c} }
 #define UUID_NON_TRUSTED_WORLD_KEY_CERT \
-	{0x3d87671c, 0x635f, 0x11e4, 0x97, 0x8d, {0x27, 0xc0, 0xc7, 0x14, 0x8a, 0xbd} }
+	{{0x1c,  0x67, 0x87, 0x3d}, {0x5f, 0x63}, {0xe4, 0x11}, 0x97, 0x8d, {0x27, 0xc0, 0xc7, 0x14, 0x8a, 0xbd} }
 #define UUID_SCP_FW_KEY_CERT \
-	{0xa1214202, 0x60f8, 0x11e4, 0x8d, 0x9b, {0xf3, 0x3c, 0x0e, 0x15, 0xa0, 0x14} }
+	{{0x02,  0x42, 0x21, 0xa1}, {0xf8, 0x60}, {0xe4, 0x11}, 0x8d, 0x9b, {0xf3, 0x3c, 0x0e, 0x15, 0xa0, 0x14} }
 #define UUID_SOC_FW_KEY_CERT \
-	{0xccbeb88a, 0x60f9, 0x11e4, 0x9a, 0xd0, {0xeb, 0x48, 0x22, 0xd8, 0xdc, 0xf8} }
+	{{0x8a,  0xb8, 0xbe, 0xcc}, {0xf9, 0x60}, {0xe4, 0x11}, 0x9a, 0xd0, {0xeb, 0x48, 0x22, 0xd8, 0xdc, 0xf8} }
 #define UUID_TRUSTED_OS_FW_KEY_CERT \
-	{0x03d67794, 0x60fb, 0x11e4, 0x85, 0xdd, {0xb7, 0x10, 0x5b, 0x8c, 0xee, 0x04} }
+	{{0x94,  0x77, 0xd6, 0x03}, {0xfb, 0x60}, {0xe4, 0x11}, 0x85, 0xdd, {0xb7, 0x10, 0x5b, 0x8c, 0xee, 0x04} }
 #define UUID_NON_TRUSTED_FW_KEY_CERT \
-	{0x2a83d58a, 0x60fb, 0x11e4, 0x8a, 0xaf, {0xdf, 0x30, 0xbb, 0xc4, 0x98, 0x59} }
+	{{0x8a,  0xd5, 0x83, 0x2a}, {0xfb, 0x60}, {0xe4, 0x11}, 0x8a, 0xaf, {0xdf, 0x30, 0xbb, 0xc4, 0x98, 0x59} }
 /* Content certificates */
 #define UUID_TRUSTED_BOOT_FW_CERT \
-	{0xea69e2d6, 0x635d, 0x11e4, 0x8d, 0x8c, {0x9f, 0xba, 0xbe, 0x99, 0x56, 0xa5} }
+	{{0xd6,  0xe2, 0x69, 0xea}, {0x5d, 0x63}, {0xe4, 0x11}, 0x8d, 0x8c, {0x9f, 0xba, 0xbe, 0x99, 0x56, 0xa5} }
 #define UUID_SCP_FW_CONTENT_CERT \
-	{0x046fbe44, 0x635e, 0x11e4, 0xb2, 0x8b, {0x73, 0xd8, 0xea, 0xae, 0x96, 0x56} }
+	{{0x44,  0xbe, 0x6f, 0x04}, {0x5e, 0x63}, {0xe4, 0x11}, 0xb2, 0x8b, {0x73, 0xd8, 0xea, 0xae, 0x96, 0x56} }
 #define UUID_SOC_FW_CONTENT_CERT \
-	{0x200cb2e2, 0x635e, 0x11e4, 0x9c, 0xe8, {0xab, 0xcc, 0xf9, 0x2b, 0xb6, 0x66} }
+	{{0xe2,  0xb2, 0x0c, 0x20}, {0x5e, 0x63}, {0xe4, 0x11}, 0x9c, 0xe8, {0xab, 0xcc, 0xf9, 0x2b, 0xb6, 0x66} }
 #define UUID_TRUSTED_OS_FW_CONTENT_CERT \
-	{0x11449fa4, 0x635e, 0x11e4, 0x87, 0x28, {0x3f, 0x05, 0x72, 0x2a, 0xf3, 0x3d} }
+	{{0xa4,  0x9f, 0x44, 0x11}, {0x5e, 0x63}, {0xe4, 0x11}, 0x87, 0x28, {0x3f, 0x05, 0x72, 0x2a, 0xf3, 0x3d} }
 #define UUID_NON_TRUSTED_FW_CONTENT_CERT \
-	{0xf3c1c48e, 0x635d, 0x11e4, 0xa7, 0xa9, {0x87, 0xee, 0x40, 0xb2, 0x3f, 0xa7} }
+	{{0x8e,  0xc4, 0xc1, 0xf3}, {0x5d, 0x63}, {0xe4, 0x11}, 0xa7, 0xa9, {0x87, 0xee, 0x40, 0xb2, 0x3f, 0xa7} }
 /* Dynamic configs */
 #define UUID_HW_CONFIG \
-	{0xd9f1b808, 0xcfc9, 0x4993, 0xa9, 0x62, {0x6f, 0xbc, 0x6b, 0x72, 0x65, 0xcc} }
+	{{0x08,  0xb8, 0xf1, 0xd9}, {0xc9, 0xcf}, {0x93, 0x49}, 0xa9, 0x62, {0x6f, 0xbc, 0x6b, 0x72, 0x65, 0xcc} }
 #define UUID_TB_FW_CONFIG \
-	{0xff58046c, 0x6baf, 0x4f7d, 0x82, 0xed, {0xaa, 0x27, 0xbc, 0x69, 0xbf, 0xd2} }
+	{{0x6c,  0x04, 0x58, 0xff}, {0xaf, 0x6b}, {0x7d, 0x4f}, 0x82, 0xed, {0xaa, 0x27, 0xbc, 0x69, 0xbf, 0xd2} }
 #define UUID_SOC_FW_CONFIG \
-	{0x4b817999, 0x7603, 0x46fb, 0x8c, 0x8e, {0x8d, 0x26, 0x7f, 0x78, 0x59, 0xe0} }
+	{{0x99,  0x79, 0x81, 0x4b}, {0x03, 0x76}, {0xfb, 0x46}, 0x8c, 0x8e, {0x8d, 0x26, 0x7f, 0x78, 0x59, 0xe0} }
 #define UUID_TOS_FW_CONFIG \
-	{0x1a7c2526, 0xc6bd, 0x477f, 0x8d, 0x96, {0xc4, 0xc4, 0xb0, 0x24, 0x80, 0x21} }
+	{{0x26,  0x25, 0x7c, 0x1a}, {0xdb, 0xc6}, {0x7f, 0x47}, 0x8d, 0x96, {0xc4, 0xc4, 0xb0, 0x24, 0x80, 0x21} }
 #define UUID_NT_FW_CONFIG \
-	{0x1598da28, 0xe893, 0x447e, 0xac, 0x66, {0x1a, 0xaf, 0x80, 0x15, 0x50, 0xf9} }
+	{{0x28,  0xda, 0x98, 0x15}, {0x93, 0xe8}, {0x7e, 0x44}, 0xac, 0x66, {0x1a, 0xaf, 0x80, 0x15, 0x50, 0xf9} }
 
 typedef struct fip_toc_header {
 	uint32_t	name;
diff --git a/include/tools_share/uuid.h b/include/tools_share/uuid.h
index 6d935bd..f3ac4af 100644
--- a/include/tools_share/uuid.h
+++ b/include/tools_share/uuid.h
@@ -48,9 +48,9 @@
  * A DCE 1.1 compatible source representation of UUIDs.
  */
 struct uuid {
-	uint32_t	time_low;
-	uint16_t	time_mid;
-	uint16_t	time_hi_and_version;
+	uint8_t		time_low[4];
+	uint8_t		time_mid[2];
+	uint8_t		time_hi_and_version[2];
 	uint8_t		clock_seq_hi_and_reserved;
 	uint8_t		clock_seq_low;
 	uint8_t		node[_UUID_NODE_LEN];
diff --git a/plat/arm/common/arm_sip_svc.c b/plat/arm/common/arm_sip_svc.c
index 7fe6101..bb5b5c6 100644
--- a/plat/arm/common/arm_sip_svc.c
+++ b/plat/arm/common/arm_sip_svc.c
@@ -14,9 +14,9 @@
 
 
 /* ARM SiP Service UUID */
-DEFINE_SVC_UUID(arm_sip_svc_uid,
-		0xe2756d55, 0x3360, 0x4bb5, 0xbf, 0xf3,
-		0x62, 0x79, 0xfd, 0x11, 0x37, 0xff);
+DEFINE_SVC_UUID2(arm_sip_svc_uid,
+	0x556d75e2, 0x6033, 0xb54b, 0xb5, 0x75,
+	0x62, 0x79, 0xfd, 0x11, 0x37, 0xff);
 
 static int arm_sip_setup(void)
 {
diff --git a/plat/hisilicon/hikey/hisi_sip_svc.c b/plat/hisilicon/hikey/hisi_sip_svc.c
index b3109d6..ffa4903 100644
--- a/plat/hisilicon/hikey/hisi_sip_svc.c
+++ b/plat/hisilicon/hikey/hisi_sip_svc.c
@@ -13,9 +13,9 @@
 
 
 /* Hisi SiP Service UUID */
-DEFINE_SVC_UUID(hisi_sip_svc_uid,
-		0xe599df74, 0x7682, 0x40aa, 0x9f, 0xf8,
-		0xc0, 0x85, 0x52, 0xbc, 0x39, 0x3f);
+DEFINE_SVC_UUID2(hisi_sip_svc_uid,
+	0x74df99e5, 0x8276, 0xaa40, 0x9f, 0xf8,
+	0xc0, 0x85, 0x52, 0xbc, 0x39, 0x3f);
 
 static int hisi_sip_setup(void)
 {
diff --git a/plat/mediatek/common/custom/oem_svc.c b/plat/mediatek/common/custom/oem_svc.c
index c396e2d..18bda51 100644
--- a/plat/mediatek/common/custom/oem_svc.c
+++ b/plat/mediatek/common/custom/oem_svc.c
@@ -14,10 +14,9 @@
 #include <uuid.h>
 
 /* OEM Service UUID */
-DEFINE_SVC_UUID(oem_svc_uid,
-		0xb943add0, 0x069d, 0x11e4, 0x91, 0x91,
-		0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66);
-
+DEFINE_SVC_UUID2(oem_svc_uid,
+	0xd0ad43b9, 0x9b06, 0xe411, 0x91, 0x91,
+	0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66);
 
 /* Setup OEM Services */
 static int32_t oem_svc_setup(void)
diff --git a/plat/mediatek/common/mtk_sip_svc.c b/plat/mediatek/common/mtk_sip_svc.c
index ea8cea0..71eddca 100644
--- a/plat/mediatek/common/mtk_sip_svc.c
+++ b/plat/mediatek/common/mtk_sip_svc.c
@@ -14,9 +14,9 @@
 #include <uuid.h>
 
 /* Mediatek SiP Service UUID */
-DEFINE_SVC_UUID(mtk_sip_svc_uid,
-		0xf7582ba4, 0x4262, 0x4d7d, 0x80, 0xe5,
-		0x8f, 0x95, 0x05, 0x00, 0x0f, 0x3d);
+DEFINE_SVC_UUID2(mtk_sip_svc_uid,
+	0xa42b58f7, 0x6242, 0x7d4d, 0x80, 0xe5,
+	0x8f, 0x95, 0x05, 0x00, 0x0f, 0x3d);
 
 #pragma weak mediatek_plat_sip_handler
 uintptr_t mediatek_plat_sip_handler(uint32_t smc_fid,
diff --git a/plat/rockchip/common/rockchip_sip_svc.c b/plat/rockchip/common/rockchip_sip_svc.c
index 2480599..d690e92 100644
--- a/plat/rockchip/common/rockchip_sip_svc.c
+++ b/plat/rockchip/common/rockchip_sip_svc.c
@@ -13,9 +13,9 @@
 #include <uuid.h>
 
 /* Rockchip SiP Service UUID */
-DEFINE_SVC_UUID(rk_sip_svc_uid,
-		0xe86fc7e2, 0x313e, 0x11e6, 0xb7, 0x0d,
-		0x8f, 0x88, 0xee, 0x74, 0x7b, 0x72);
+DEFINE_SVC_UUID2(rk_sip_svc_uid,
+	0xe2c76fe8, 0x3e31, 0xe611, 0xb7, 0x0d,
+	0x8f, 0x88, 0xee, 0x74, 0x7b, 0x72);
 
 #pragma weak rockchip_plat_sip_handler
 uintptr_t rockchip_plat_sip_handler(uint32_t smc_fid,
diff --git a/plat/xilinx/zynqmp/sip_svc_setup.c b/plat/xilinx/zynqmp/sip_svc_setup.c
index c7996ce..9fe709d 100644
--- a/plat/xilinx/zynqmp/sip_svc_setup.c
+++ b/plat/xilinx/zynqmp/sip_svc_setup.c
@@ -29,9 +29,9 @@
 #define is_ipi_fid(_fid) (((_fid) & PM_FID_MASK) == IPI_FID_VALUE)
 
 /* SiP Service UUID */
-DEFINE_SVC_UUID(zynqmp_sip_uuid,
-		0x2a1d9b5c, 0x8605, 0x4023, 0xa6, 0x1b,
-		0xb9, 0x25, 0x82, 0x2d, 0xe3, 0xa5);
+DEFINE_SVC_UUID2(zynqmp_sip_uuid,
+	0x5c9b1b2a, 0x0586, 0x2340, 0xa6, 0x1b,
+	0xb9, 0x25, 0x82, 0x2d, 0xe3, 0xa5);
 
 /**
  * sip_svc_setup() - Setup SiP Service
diff --git a/services/spd/tlkd/tlkd_main.c b/services/spd/tlkd/tlkd_main.c
index 5090f06..cee7ef8 100644
--- a/services/spd/tlkd/tlkd_main.c
+++ b/services/spd/tlkd/tlkd_main.c
@@ -40,9 +40,9 @@
 static uint32_t boot_cpu;
 
 /* TLK UID: RFC-4122 compliant UUID (version-5, sha-1) */
-DEFINE_SVC_UUID(tlk_uuid,
-		0xbd11e9c9, 0x2bba, 0x52ee, 0xb1, 0x72,
-		0x46, 0x1f, 0xba, 0x97, 0x7f, 0x63);
+DEFINE_SVC_UUID2(tlk_uuid,
+	0xc9e911bd, 0xba2b, 0xee52, 0xb1, 0x72,
+	0x46, 0x1f, 0xba, 0x97, 0x7f, 0x63);
 
 static int32_t tlkd_init(void);
 
diff --git a/services/spd/tspd/tspd_main.c b/services/spd/tspd/tspd_main.c
index 8cb23b9..3ec98d6 100644
--- a/services/spd/tspd/tspd_main.c
+++ b/services/spd/tspd/tspd_main.c
@@ -43,9 +43,9 @@
 
 
 /* TSP UID */
-DEFINE_SVC_UUID(tsp_uuid,
-		0x5b3056a0, 0x3291, 0x427b, 0x98, 0x11,
-		0x71, 0x68, 0xca, 0x50, 0xf3, 0xfa);
+DEFINE_SVC_UUID2(tsp_uuid,
+	0xa056305b, 0x9132, 0x7b42, 0x98, 0x11,
+	0x71, 0x68, 0xca, 0x50, 0xf3, 0xfa);
 
 int32_t tspd_init(void);
 
diff --git a/services/std_svc/std_svc_setup.c b/services/std_svc/std_svc_setup.c
index 41befe5..1a81a0a 100644
--- a/services/std_svc/std_svc_setup.c
+++ b/services/std_svc/std_svc_setup.c
@@ -19,9 +19,13 @@
 #include <uuid.h>
 
 /* Standard Service UUID */
-DEFINE_SVC_UUID(arm_svc_uid,
-		0x108d905b, 0xf863, 0x47e8, 0xae, 0x2d,
-		0xc0, 0xfb, 0x56, 0x41, 0xf6, 0xe2);
+static uuid_t arm_svc_uid = {
+	{0x5b, 0x90, 0x8d, 0x10},
+	{0x63, 0xf8},
+	{0xe8, 0x47},
+	0xae, 0x2d,
+	{0xc0, 0xfb, 0x56, 0x41, 0xf6, 0xe2}
+};
 
 /* Setup Standard Services */
 static int32_t std_svc_setup(void)
diff --git a/tools/fiptool/fiptool.c b/tools/fiptool/fiptool.c
index e4348ee..0d4f929 100644
--- a/tools/fiptool/fiptool.c
+++ b/tools/fiptool/fiptool.c
@@ -51,7 +51,7 @@
 
 static image_desc_t *image_desc_head;
 static size_t nr_image_descs;
-static uuid_t uuid_null = { 0 };
+static const uuid_t uuid_null;
 static int verbose;
 
 static void vlog(int prio, const char *msg, va_list ap)
@@ -241,14 +241,15 @@
 {
 	assert(len >= (_UUID_STR_LEN + 1));
 
-	snprintf(s, len, "%08X-%04X-%04X-%04X-%04X%04X%04X",
-	    u->time_low,
-	    u->time_mid,
-	    u->time_hi_and_version,
-	    ((uint16_t)u->clock_seq_hi_and_reserved << 8) | u->clock_seq_low,
-	    ((uint16_t)u->node[0] << 8) | u->node[1],
-	    ((uint16_t)u->node[2] << 8) | u->node[3],
-	    ((uint16_t)u->node[4] << 8) | u->node[5]);
+	snprintf(s, len,
+	    "%02X%02X%02X%02X-%02X%02X-%02X%02X-%04X-%04X%04X%04X",
+	    u->time_low[0], u->time_low[1], u->time_low[2], u->time_low[3],
+	    u->time_mid[0], u->time_mid[1],
+	    u->time_hi_and_version[0], u->time_hi_and_version[1],
+	    (u->clock_seq_hi_and_reserved << 8) | u->clock_seq_low,
+	    (u->node[0] << 8) | u->node[1],
+	    (u->node[2] << 8) | u->node[3],
+	    (u->node[4] << 8) | u->node[5]);
 }
 
 static void uuid_from_str(uuid_t *u, const char *s)
@@ -261,10 +262,14 @@
 		log_errx("Invalid UUID: %s", s);
 
 	n = sscanf(s,
-	    "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
-	    &u->time_low, &u->time_mid, &u->time_hi_and_version,
-	    &u->clock_seq_hi_and_reserved, &u->clock_seq_low, &u->node[0],
-	    &u->node[1], &u->node[2], &u->node[3], &u->node[4], &u->node[5]);
+	    "%2hhx%2hhx%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
+	    &u->time_low[0], &u->time_low[1], &u->time_low[2], &u->time_low[3],
+	    &u->time_mid[0], &u->time_mid[1],
+	    &u->time_hi_and_version[0], &u->time_hi_and_version[1],
+	    &u->clock_seq_hi_and_reserved, &u->clock_seq_low,
+	    &u->node[0], &u->node[1],
+	    &u->node[2], &u->node[3],
+	    &u->node[4], &u->node[5]);
 	/*
 	 * Given the format specifier above, we expect 11 items to be scanned
 	 * for a properly formatted UUID.
@@ -697,7 +702,7 @@
 		case 'b': {
 			char name[_UUID_STR_LEN + 1];
 			char filename[PATH_MAX] = { 0 };
-			uuid_t uuid = { 0 };
+			uuid_t uuid = uuid_null;
 			image_desc_t *desc;
 
 			parse_blob_opt(optarg, &uuid,
@@ -794,7 +799,7 @@
 		case 'b': {
 			char name[_UUID_STR_LEN + 1];
 			char filename[PATH_MAX] = { 0 };
-			uuid_t uuid = { 0 };
+			uuid_t uuid = uuid_null;
 			image_desc_t *desc;
 
 			parse_blob_opt(optarg, &uuid,
@@ -902,7 +907,7 @@
 		case 'b': {
 			char name[_UUID_STR_LEN + 1];
 			char filename[PATH_MAX] = { 0 };
-			uuid_t uuid = { 0 };
+			uuid_t uuid = uuid_null;
 			image_desc_t *desc;
 
 			parse_blob_opt(optarg, &uuid,
@@ -1041,7 +1046,7 @@
 			break;
 		case 'b': {
 			char name[_UUID_STR_LEN + 1], filename[PATH_MAX];
-			uuid_t uuid = { 0 };
+			uuid_t uuid = uuid_null;
 			image_desc_t *desc;
 
 			parse_blob_opt(optarg, &uuid,
diff --git a/tools/fiptool/tbbr_config.c b/tools/fiptool/tbbr_config.c
index c7df243..86b8581 100644
--- a/tools/fiptool/tbbr_config.c
+++ b/tools/fiptool/tbbr_config.c
@@ -153,7 +153,7 @@
 	},
 	{
 		.name = NULL,
-		.uuid = { 0 },
+		.uuid = { {0} },
 		.cmdline_name = NULL,
 	}
 };