xref: /aosp_15_r20/external/coreboot/src/soc/amd/common/block/include/amdblocks/agesawrapper_call.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef AMD_BLOCK_AGESAWRAPPER_CALL_H
4 #define AMD_BLOCK_AGESAWRAPPER_CALL_H
5 
6 #include <amdblocks/agesawrapper.h>
7 #include <stdint.h>
8 #include <console/console.h>
9 
10 /*
11  * Possible AGESA_STATUS values:
12  *
13  * 0x0 = AGESA_SUCCESS
14  * 0x1 = AGESA_UNSUPPORTED
15  * 0x2 = AGESA_BOUNDS_CHK
16  * 0x3 = AGESA_ALERT
17  * 0x4 = AGESA_WARNING
18  * 0x5 = AGESA_ERROR
19  * 0x6 = AGESA_CRITICAL
20  * 0x7 = AGESA_FATAL
21  */
decodeAGESA_STATUS(AGESA_STATUS sret)22 static const char *decodeAGESA_STATUS(AGESA_STATUS sret)
23 {
24 	const char *statusStrings[] = { "AGESA_SUCCESS", "AGESA_UNSUPPORTED",
25 					"AGESA_BOUNDS_CHK", "AGESA_ALERT",
26 					"AGESA_WARNING", "AGESA_ERROR",
27 					"AGESA_CRITICAL", "AGESA_FATAL"
28 					};
29 	if (sret >= ARRAY_SIZE(statusStrings))
30 		return "unknown"; /* Non-AGESA error code */
31 	return statusStrings[sret];
32 }
33 
do_agesawrapper(AGESA_STRUCT_NAME func,const char * name)34 static inline u32 do_agesawrapper(AGESA_STRUCT_NAME func, const char *name)
35 {
36 	AGESA_STATUS ret;
37 	printk(BIOS_DEBUG, "agesawrapper_%s() entry\n", name);
38 	ret = agesa_execute_state(func);
39 	printk(BIOS_DEBUG, "agesawrapper_%s() returned %s\n",
40 			name, decodeAGESA_STATUS(ret));
41 	return (u32)ret;
42 }
43 
44 #endif /* AMD_BLOCK_AGESAWRAPPER_CALL_H */
45