Skip to content

Commit 4c1b28d

Browse files
committed
refactor(pal): unify PAL print helper macros
Introduce a shared PAL print helper and route the existing PAL print front ends through it. This removes repeated print gating and level definitions from baremetal common, exerciser, and UEFI PAL headers while keeping current call sites and backend behavior intact. - add pal/include/pal_print.h for shared PAL print levels and gating - centralize backend selection between pal_uart_print and UEFI Print - keep separate literal and format helpers for ASCII literals and pre-wide UEFI format strings - convert pal_common_support.h, target pal_exerciser.h, and UEFI pal_uefi.h to thin wrapper macros over the shared helper - make supported targets explicit in pal_print.h for baremetal and UEFI builds Change-Id: I0fc28009df537a76791986bb899d1513a37601cf
1 parent 2320408 commit 4c1b28d

18 files changed

Lines changed: 87 additions & 106 deletions

File tree

pal/baremetal/base/include/pal_common_support.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
#define __PAL_COMMON_SUPPORT_H_
2020

2121
#include <stdio.h>
22-
#include <stdint.h>
22+
#include "acs_stdint.h"
2323
#include <string.h>
2424
#include <stdlib.h>
2525
#include "pal_status.h"
2626
#include "pal_execution_policy.h"
27+
#include "pal_print.h"
2728
#include "platform_override_fvp.h"
2829

2930
typedef uintptr_t addr_t;
@@ -32,12 +33,6 @@ typedef char char8_t;
3233
extern uint32_t g_curr_module;
3334
extern uint32_t g_enable_module;
3435

35-
#define ACS_PRINT_ERR 5 /* Only Errors. use this to de-clutter the terminal and focus only on specifics */
36-
#define ACS_PRINT_WARN 4 /* Only warnings & errors. use this to de-clutter the terminal and focus only on specifics */
37-
#define ACS_PRINT_TEST 3 /* Test description and result descriptions. THIS is DEFAULT */
38-
#define ACS_PRINT_DEBUG 2 /* For Debug statements. contains register dumps etc */
39-
#define ACS_PRINT_INFO 1 /* Print all statements. Do not use unless really needed */
40-
4136
#define MEM_ALIGN_4K 0x1000
4237
#define MEM_ALIGN_8K 0x2000
4338
#define MEM_ALIGN_16K 0x4000
@@ -65,14 +60,10 @@ void *pal_aligned_alloc( uint32_t alignment, uint32_t size );
6560
#define PCIE_MAX_DEV 32
6661
#define PCIE_MAX_FUNC 8
6762

68-
void pal_uart_print(int log, const char *fmt, ...);
6963
void *mem_alloc(size_t alignment, size_t size);
7064
void pal_warn_not_implemented(const char *api_name);
7165
#define print(verbose, string, ...) \
72-
do { \
73-
if ((verbose) >= acs_policy_get_print_level()) \
74-
pal_uart_print((verbose), (string), ##__VA_ARGS__); \
75-
} while (0)
66+
PAL_PRINT_LITERAL((verbose), string, ##__VA_ARGS__)
7667

7768
#define PCIE_CREATE_BDF(Seg, Bus, Dev, Func) ((Seg << 24) | (Bus << 16) | (Dev << 8) | Func)
7869

pal/baremetal/base/include/pal_pcie_enum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @file
2-
* Copyright (c) 2023-2025, Arm Limited or its affiliates. All rights reserved.
2+
* Copyright (c) 2023-2026, Arm Limited or its affiliates. All rights reserved.
33
* SPDX-License-Identifier : Apache-2.0
44
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,7 @@
1919
#define __PAL_PCIE_ENUM_H__
2020

2121
#include <stdio.h>
22-
#include <stdint.h>
22+
#include "acs_stdint.h"
2323

2424

2525
/* Header Offset and Type*/

pal/baremetal/base/include/pal_pl011_uart.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
**/
1717

18-
#include <stdint.h>
18+
#include "acs_stdint.h"
1919
#include "platform_override_fvp.h"
2020

2121
#ifndef _PAL_UART_PL011_H_

pal/baremetal/base/include/pal_run_request.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#ifndef __PAL_RUN_REQUEST_H__
1919
#define __PAL_RUN_REQUEST_H__
2020

21-
#include <stdint.h>
21+
#include "acs_stdint.h"
2222

2323
#include "rule_based_execution_enum.h"
2424

pal/baremetal/base/src/pal_misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
**/
1717

18-
#include <stdint.h>
18+
#include "acs_stdint.h"
1919
#include <stdarg.h>
2020
#include "pal_pcie_enum.h"
2121
#include "pal_common_support.h"

pal/baremetal/target/RDN2/include/pal_exerciser.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,22 @@
1717
**/
1818

1919
#include <stdio.h>
20-
#include <stdint.h>
20+
#include "acs_stdint.h"
2121
#include "acs_execution_policy.h"
22+
#include "pal_print.h"
2223
#include "platform_override_fvp.h"
2324

24-
#define ACS_PRINT_ERR 5 /* Only Errors. use this to de-clutter the terminal and focus only on specifics */
25-
#define ACS_PRINT_WARN 4 /* Only warnings & errors. use this to de-clutter the terminal and focus only on specifics */
26-
#define ACS_PRINT_TEST 3 /* Test description and result descriptions. THIS is DEFAULT */
27-
#define ACS_PRINT_DEBUG 2 /* For Debug statements. contains register dumps etc */
28-
#define ACS_PRINT_INFO 1 /* Print all statements. Do not use unless really needed */
29-
3025
#define PCIE_SUCCESS 0x00000000 /* Operation completed successfully */
3126
#define PCIE_NO_MAPPING 0x10000001 /* A mapping to a Function does not exist */
3227
#define PCIE_CAP_NOT_FOUND 0x10000010 /* The specified capability was not found */
3328
#define PCIE_UNKNOWN_RESPONSE 0xFFFFFFFF /* Function not found or UR response from completer */
3429

3530
#ifdef TARGET_BAREMETAL
36-
void pal_uart_print(int log, const char *fmt, ...);
3731
void *mem_alloc(size_t alignment, size_t size);
38-
#define print(verbose, string, ...) \
39-
do { \
40-
if ((verbose) >= acs_policy_get_print_level()) \
41-
pal_uart_print((verbose), (string), ##__VA_ARGS__); \
42-
} while (0)
43-
#else
44-
#include <Library/UefiLib.h>
32+
#endif
4533

4634
#define print(verbose, string, ...) \
47-
do { \
48-
if ((verbose) >= acs_policy_get_print_level()) \
49-
Print(L##string, ##__VA_ARGS__); \
50-
} while (0)
51-
#endif
35+
PAL_PRINT_LITERAL((verbose), string, ##__VA_ARGS__)
5236

5337
#define PCIE_CREATE_BDF(Seg, Bus, Dev, Func) ((Seg << 24) | (Bus << 16) | (Dev << 8) | Func)
5438
#define PCIE_EXTRACT_BDF_SEG(bdf) ((bdf >> 24) & 0xFF)

pal/baremetal/target/RDN2/include/platform_override_struct.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
**/
1717

1818
#include <stdio.h>
19-
#include <stdint.h>
19+
#include "acs_stdint.h"
2020
#include "platform_override_fvp.h"
2121

2222
#define MAX_CS_COMP_LENGTH 256

pal/baremetal/target/RDV3/include/pal_exerciser.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,22 @@
1717
**/
1818

1919
#include <stdio.h>
20-
#include <stdint.h>
20+
#include "acs_stdint.h"
2121
#include "acs_execution_policy.h"
22+
#include "pal_print.h"
2223
#include "platform_override_fvp.h"
2324

24-
#define ACS_PRINT_ERR 5 /* Only Errors. Use this to trim output to key info */
25-
#define ACS_PRINT_WARN 4 /* Only warnings & errors. Use this to trim output to key info */
26-
#define ACS_PRINT_TEST 3 /* Test description and result descriptions. THIS is DEFAULT */
27-
#define ACS_PRINT_DEBUG 2 /* For Debug statements. contains register dumps etc */
28-
#define ACS_PRINT_INFO 1 /* Print all statements. Do not use unless really needed */
29-
3025
#define PCIE_SUCCESS 0x00000000 /* Operation completed successfully */
3126
#define PCIE_NO_MAPPING 0x10000001 /* A mapping to a Function does not exist */
3227
#define PCIE_CAP_NOT_FOUND 0x10000010 /* The specified capability was not found */
3328
#define PCIE_UNKNOWN_RESPONSE 0xFFFFFFFF /* Function not found or UR response from completer */
3429

3530
#ifdef TARGET_BAREMETAL
36-
void pal_uart_print(int log, const char *fmt, ...);
3731
void *mem_alloc(size_t alignment, size_t size);
38-
#define print(verbose, string, ...) \
39-
do { \
40-
if ((verbose) >= acs_policy_get_print_level()) \
41-
pal_uart_print((verbose), (string), ##__VA_ARGS__); \
42-
} while (0)
43-
#else
44-
#include <Library/UefiLib.h>
32+
#endif
4533

4634
#define print(verbose, string, ...) \
47-
do { \
48-
if ((verbose) >= acs_policy_get_print_level()) \
49-
Print(L##string, ##__VA_ARGS__); \
50-
} while (0)
51-
#endif
35+
PAL_PRINT_LITERAL((verbose), string, ##__VA_ARGS__)
5236

5337
/* Exerciser PAL API declarations */
5438
uint64_t pal_exerciser_get_ecam(uint32_t Bdf);

pal/baremetal/target/RDV3/include/platform_override_struct.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
**/
1717

1818
#include <stdio.h>
19-
#include <stdint.h>
19+
#include "acs_stdint.h"
2020
#include "platform_override_fvp.h"
2121

2222
#define MAX_CS_COMP_LENGTH 256

pal/baremetal/target/RDV3CFG1/include/pal_exerciser.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,22 @@
1717
**/
1818

1919
#include <stdio.h>
20-
#include <stdint.h>
20+
#include "acs_stdint.h"
2121
#include "acs_execution_policy.h"
22+
#include "pal_print.h"
2223
#include "platform_override_fvp.h"
2324

24-
#define ACS_PRINT_ERR 5 /* Only Errors. Use this to trim output to key info */
25-
#define ACS_PRINT_WARN 4 /* Only warnings & errors. Use this to trim output to key info */
26-
#define ACS_PRINT_TEST 3 /* Test description and result descriptions. THIS is DEFAULT */
27-
#define ACS_PRINT_DEBUG 2 /* For Debug statements. contains register dumps etc */
28-
#define ACS_PRINT_INFO 1 /* Print all statements. Do not use unless really needed */
29-
3025
#define PCIE_SUCCESS 0x00000000 /* Operation completed successfully */
3126
#define PCIE_NO_MAPPING 0x10000001 /* A mapping to a Function does not exist */
3227
#define PCIE_CAP_NOT_FOUND 0x10000010 /* The specified capability was not found */
3328
#define PCIE_UNKNOWN_RESPONSE 0xFFFFFFFF /* Function not found or UR response from completer */
3429

3530
#ifdef TARGET_BAREMETAL
36-
void pal_uart_print(int log, const char *fmt, ...);
3731
void *mem_alloc(size_t alignment, size_t size);
38-
#define print(verbose, string, ...) \
39-
do { \
40-
if ((verbose) >= acs_policy_get_print_level()) \
41-
pal_uart_print((verbose), (string), ##__VA_ARGS__); \
42-
} while (0)
43-
#else
44-
#include <Library/UefiLib.h>
32+
#endif
4533

4634
#define print(verbose, string, ...) \
47-
do { \
48-
if ((verbose) >= acs_policy_get_print_level()) \
49-
Print(L##string, ##__VA_ARGS__); \
50-
} while (0)
51-
#endif
35+
PAL_PRINT_LITERAL((verbose), string, ##__VA_ARGS__)
5236

5337
/* Exerciser PAL API declarations */
5438
uint64_t pal_exerciser_get_ecam(uint32_t Bdf);

0 commit comments

Comments
 (0)