It's been several years already since we announced the deprecation of the legacy CBFS API for payloads. It's time to remove it completely. Change-Id: I0ed157ac2d1376b8dff4537af9a63731064b45f6 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80650 Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Jakub Czapiga <czapiga@google.com> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
		
			
				
	
	
		
			143 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			143 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /* SPDX-License-Identifier: BSD-3-Clause */
 | |
| 
 | |
| #ifndef _CBFS_H_
 | |
| #define _CBFS_H_
 | |
| 
 | |
| #include <commonlib/bsd/cb_err.h>
 | |
| #include <commonlib/bsd/cbfs_mdata.h>
 | |
| #include <endian.h>
 | |
| #include <stdbool.h>
 | |
| 
 | |
| 
 | |
| /**********************************************************************************************
 | |
|  *                                  CBFS FILE ACCESS APIs                                     *
 | |
|  **********************************************************************************************/
 | |
| 
 | |
| /* For documentation look in src/include/cbfs.h file in the main coreboot source tree. */
 | |
| 
 | |
| static inline size_t cbfs_load(const char *name, void *buf, size_t size);
 | |
| static inline size_t cbfs_ro_load(const char *name, void *buf, size_t size);
 | |
| static inline size_t cbfs_unverified_area_load(const char *area, const char *name, void *buf,
 | |
| 					       size_t size);
 | |
| 
 | |
| static inline void *cbfs_map(const char *name, size_t *size_out);
 | |
| static inline void *cbfs_ro_map(const char *name, size_t *size_out);
 | |
| static inline void *cbfs_unverified_area_map(const char *area, const char *name,
 | |
| 					     size_t *size_out);
 | |
| 
 | |
| void cbfs_unmap(void *mapping);
 | |
| 
 | |
| static inline size_t cbfs_get_size(const char *name);
 | |
| static inline size_t cbfs_ro_get_size(const char *name);
 | |
| 
 | |
| static inline enum cbfs_type cbfs_get_type(const char *name);
 | |
| static inline enum cbfs_type cbfs_ro_get_type(const char *name);
 | |
| 
 | |
| static inline bool cbfs_file_exists(const char *name);
 | |
| static inline bool cbfs_ro_file_exists(const char *name);
 | |
| 
 | |
| /**********************************************************************************************
 | |
|  *                         INTERNAL HELPERS FOR INLINES, DO NOT USE.                          *
 | |
|  **********************************************************************************************/
 | |
| ssize_t _cbfs_boot_lookup(const char *name, bool force_ro, union cbfs_mdata *mdata);
 | |
| 
 | |
| void *_cbfs_load(const char *name, void *buf, size_t *size_inout, bool force_ro);
 | |
| 
 | |
| void *_cbfs_unverified_area_load(const char *area, const char *name, void *buf,
 | |
| 				 size_t *size_inout);
 | |
| 
 | |
| /**********************************************************************************************
 | |
|  *                                  INLINE IMPLEMENTATIONS                                    *
 | |
|  **********************************************************************************************/
 | |
| 
 | |
| static inline void *cbfs_map(const char *name, size_t *size_out)
 | |
| {
 | |
| 	return _cbfs_load(name, NULL, size_out, false);
 | |
| }
 | |
| 
 | |
| static inline void *cbfs_ro_map(const char *name, size_t *size_out)
 | |
| {
 | |
| 	return _cbfs_load(name, NULL, size_out, true);
 | |
| }
 | |
| 
 | |
| static inline void *cbfs_unverified_area_map(const char *area, const char *name,
 | |
| 					     size_t *size_out)
 | |
| {
 | |
| 	return _cbfs_unverified_area_load(area, name, NULL, size_out);
 | |
| }
 | |
| 
 | |
| static inline size_t cbfs_load(const char *name, void *buf, size_t size)
 | |
| {
 | |
| 	if (_cbfs_load(name, buf, &size, false))
 | |
| 		return size;
 | |
| 	else
 | |
| 		return 0;
 | |
| }
 | |
| 
 | |
| static inline size_t cbfs_ro_load(const char *name, void *buf, size_t size)
 | |
| {
 | |
| 	if (_cbfs_load(name, buf, &size, true))
 | |
| 		return size;
 | |
| 	else
 | |
| 		return 0;
 | |
| }
 | |
| 
 | |
| static inline size_t cbfs_unverified_area_load(const char *area, const char *name, void *buf,
 | |
| 					       size_t size)
 | |
| {
 | |
| 	if (_cbfs_unverified_area_load(area, name, buf, &size))
 | |
| 		return size;
 | |
| 	else
 | |
| 		return 0;
 | |
| }
 | |
| 
 | |
| static inline size_t cbfs_get_size(const char *name)
 | |
| {
 | |
| 	union cbfs_mdata mdata;
 | |
| 	if (_cbfs_boot_lookup(name, false, &mdata) < 0)
 | |
| 		return 0;
 | |
| 	else
 | |
| 		return be32toh(mdata.h.len);
 | |
| }
 | |
| 
 | |
| static inline size_t cbfs_ro_get_size(const char *name)
 | |
| {
 | |
| 	union cbfs_mdata mdata;
 | |
| 	if (_cbfs_boot_lookup(name, true, &mdata) < 0)
 | |
| 		return 0;
 | |
| 	else
 | |
| 		return be32toh(mdata.h.len);
 | |
| }
 | |
| 
 | |
| static inline enum cbfs_type cbfs_get_type(const char *name)
 | |
| {
 | |
| 	union cbfs_mdata mdata;
 | |
| 	if (_cbfs_boot_lookup(name, false, &mdata) < 0)
 | |
| 		return CBFS_TYPE_NULL;
 | |
| 	else
 | |
| 		return be32toh(mdata.h.type);
 | |
| }
 | |
| 
 | |
| static inline enum cbfs_type cbfs_ro_get_type(const char *name)
 | |
| {
 | |
| 	union cbfs_mdata mdata;
 | |
| 	if (_cbfs_boot_lookup(name, true, &mdata) < 0)
 | |
| 		return CBFS_TYPE_NULL;
 | |
| 	else
 | |
| 		return be32toh(mdata.h.type);
 | |
| }
 | |
| 
 | |
| static inline bool cbfs_file_exists(const char *name)
 | |
| {
 | |
| 	union cbfs_mdata mdata;
 | |
| 	return _cbfs_boot_lookup(name, false, &mdata) >= 0;
 | |
| }
 | |
| 
 | |
| static inline bool cbfs_ro_file_exists(const char *name)
 | |
| {
 | |
| 	union cbfs_mdata mdata;
 | |
| 	return _cbfs_boot_lookup(name, true, &mdata) >= 0;
 | |
| }
 | |
| 
 | |
| #endif
 |