Skip to content

Commit f701455

Browse files
shrutig-armjk-arm
authored andcommitted
feat(logger): Route VAL formatted output via PAL
- store VAL formatted output in buffer and pass via pal_print - Add baremetal and UEFI support for final string path Signed-off-by: Shruti Ghadge <shruti.ghadge@arm.com> Change-Id: I1d7340806b6b4c0808b31a5ce919b3bb9abfc713
1 parent 000423a commit f701455

7 files changed

Lines changed: 117 additions & 62 deletions

File tree

pal/baremetal/target/RDN2/src/pal_bsa.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "platform_image_def.h"
2222
#include "platform_override_struct.h"
2323
#include "platform_override_fvp.h"
24+
#include "pal_pl011_uart.h"
2425

2526
/**
2627
Conduits for service calls (SMC vs HVC).
@@ -868,10 +869,15 @@ static uint64_t heap_init_done = 0;
868869
869870
@return None
870871
**/
872+
871873
void
872-
pal_print(char *string, uint64_t data)
874+
pal_print(uint64_t data)
873875
{
874-
print(ACS_PRINT_ERR, string, data);
876+
char *buf = (char *)(uintptr_t)data;
877+
878+
while (*buf != '\0') {
879+
pal_uart_putc(*buf++);
880+
}
875881
}
876882

877883
/**
@@ -1263,4 +1269,4 @@ uint32_t pal_exit_acs(void)
12631269
{
12641270
while (1);
12651271
return 0;
1266-
}
1272+
}

pal/baremetal/target/RDV3/src/pal_bsa.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "platform_image_def.h"
2222
#include "platform_override_struct.h"
2323
#include "platform_override_fvp.h"
24+
#include "pal_pl011_uart.h"
2425

2526
/**
2627
Conduits for service calls (SMC vs HVC).
@@ -898,11 +899,13 @@ static uint8_t heap_init_done;
898899
@return None
899900
**/
900901
void
901-
pal_print(char *string, uint64_t data)
902+
pal_print(uint64_t data)
902903
{
904+
char *buf = (char *)(uintptr_t)data;
903905

904-
print(ACS_PRINT_ERR, string, data);
905-
return;
906+
while (*buf != '\0') {
907+
pal_uart_putc(*buf++);
908+
}
906909
}
907910

908911
/**
@@ -1296,4 +1299,4 @@ uint32_t pal_exit_acs(void)
12961299
{
12971300
while (1);
12981301
return 0;
1299-
}
1302+
}

pal/baremetal/target/RDV3CFG1/src/pal_bsa.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "platform_image_def.h"
2222
#include "platform_override_struct.h"
2323
#include "platform_override_fvp.h"
24+
#include "pal_pl011_uart.h"
2425

2526
/**
2627
Conduits for service calls (SMC vs HVC).
@@ -898,11 +899,13 @@ static uint8_t heap_init_done;
898899
@return None
899900
**/
900901
void
901-
pal_print(char *string, uint64_t data)
902+
pal_print(uint64_t data)
902903
{
904+
char *buf = (char *)(uintptr_t)data;
903905

904-
print(ACS_PRINT_ERR, string, data);
905-
return;
906+
while (*buf != '\0') {
907+
pal_uart_putc(*buf++);
908+
}
906909
}
907910

908911
/**

pal/uefi_acpi/src/pal_misc.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,26 @@ pal_mmio_write(UINT64 addr, UINT32 data)
190190
191191
@return None
192192
**/
193+
193194
VOID
194-
pal_print(CHAR8 *string, UINT64 data)
195+
pal_print(UINT64 data)
195196
{
196-
if(g_acs_log_file_handle)
197+
CHAR8 *buf = (CHAR8 *)(UINTN)data;
198+
199+
if (g_acs_log_file_handle)
197200
{
198-
CHAR8 Buffer[1024];
199-
UINTN BufferSize = 1;
200-
EFI_STATUS Status = 0;
201-
BufferSize = AsciiSPrint(Buffer, 1024, string, data);
202-
AsciiPrint(Buffer);
203-
Status = ShellWriteFile(g_acs_log_file_handle, &BufferSize, (VOID*)Buffer);
204-
if(EFI_ERROR(Status))
201+
UINTN BufferSize = AsciiStrLen(buf);
202+
EFI_STATUS Status;
203+
204+
AsciiPrint("%a", buf);
205+
Status = ShellWriteFile(g_acs_log_file_handle, &BufferSize, (VOID *)buf);
206+
if (EFI_ERROR(Status))
205207
acs_print(ACS_PRINT_ERR, L" Error in writing to log file\n");
206-
} else
207-
AsciiPrint(string, data);
208+
}
209+
else
210+
{
211+
AsciiPrint("%a", buf);
212+
}
208213
}
209214

210215
/**
@@ -214,13 +219,18 @@ pal_print(CHAR8 *string, UINT64 data)
214219
VOID
215220
pal_warn_not_implemented(const CHAR8 *api_name)
216221
{
222+
CHAR8 Buffer[512];
223+
217224
if (api_name == NULL)
218225
return;
219226

220-
pal_print("\n %a is not implemented."
221-
"\n Please implement the PAL function in test suite or"
222-
"\n conduct an offline review for this rule.\n",
223-
(UINT64)(UINTN)api_name);
227+
AsciiSPrint(Buffer, sizeof(Buffer),
228+
"\n %a is not implemented."
229+
"\n Please implement the PAL function in test suite or"
230+
"\n conduct an offline review for this rule.\n",
231+
api_name);
232+
233+
pal_print((UINT64)(UINTN)Buffer);
224234
}
225235

226236
/**

pal/uefi_dt/src/pal_misc.c

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,24 @@ pal_mmio_write(UINT64 addr, UINT32 data)
192192
@return None
193193
**/
194194
VOID
195-
pal_print(CHAR8 *string, UINT64 data)
195+
pal_print(UINT64 data)
196196
{
197-
if(g_acs_log_file_handle)
197+
CHAR8 *buf = (CHAR8 *)(UINTN)data;
198+
199+
if (g_acs_log_file_handle)
198200
{
199-
CHAR8 Buffer[1024];
200-
UINTN BufferSize = 1;
201-
EFI_STATUS Status = 0;
202-
BufferSize = AsciiSPrint(Buffer, 1024, string, data);
203-
AsciiPrint(Buffer);
204-
Status = ShellWriteFile(g_acs_log_file_handle, &BufferSize, (VOID*)Buffer);
205-
if(EFI_ERROR(Status))
201+
UINTN BufferSize = AsciiStrLen(buf);
202+
EFI_STATUS Status;
203+
204+
AsciiPrint("%a", buf);
205+
Status = ShellWriteFile(g_acs_log_file_handle, &BufferSize, (VOID *)buf);
206+
if (EFI_ERROR(Status))
206207
acs_print(ACS_PRINT_ERR, L" Error in writing to log file\n");
207-
} else
208-
AsciiPrint(string, data);
208+
}
209+
else
210+
{
211+
AsciiPrint("%a", buf);
212+
}
209213
}
210214

211215
/**
@@ -215,13 +219,18 @@ pal_print(CHAR8 *string, UINT64 data)
215219
VOID
216220
pal_warn_not_implemented(const CHAR8 *api_name)
217221
{
222+
CHAR8 Buffer[512];
223+
218224
if (api_name == NULL)
219225
return;
220226

221-
pal_print("\n %a is not implemented."
222-
"\n Please implement the PAL function in test suite or"
223-
"\n conduct an offline review for this rule.\n",
224-
(UINT64)(UINTN)api_name);
227+
AsciiSPrint(Buffer, sizeof(Buffer),
228+
"\n %a is not implemented."
229+
"\n Please implement the PAL function in test suite or"
230+
"\n conduct an offline review for this rule.\n",
231+
api_name);
232+
233+
pal_print((UINT64)(UINTN)Buffer);
225234
}
226235

227236
/**

val/include/pal_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ uint64_t pal_memory_get_unpopulated_addr(uint64_t *addr, uint32_t instance);
797797
uint32_t pal_mem_set_wb_executable(void *addr, uint32_t size);
798798

799799
/* Common Definitions */
800-
void pal_print(char8_t *string, uint64_t data);
800+
void pal_print(uint64_t data);
801801
void pal_uart_print(int log, const char *fmt, ...);
802802
void pal_print_raw(uint64_t addr, char8_t *string, uint64_t data);
803803
uint32_t pal_strncmp(char8_t *str1, char8_t *str2, uint32_t len);

0 commit comments

Comments
 (0)