* Create new path for CBMEM entry of a requested type. free() path_out after use. * * @param id CBMEM_ID_* value. * @param t path type. * @param path_out output pointer to created path. */
| 54 | * @param path_out output pointer to created path. |
| 55 | */ |
| 56 | static void new_sysfs_path(uint32_t id, enum cbmem_sysfs_path_type t, char *path_out, size_t path_out_max_size) |
| 57 | { |
| 58 | const char *const type2str[] = { |
| 59 | [CBMEM_SYSFS_PATH_BASE] = "", |
| 60 | [CBMEM_SYSFS_PATH_ADDRESS] = "/address", |
| 61 | [CBMEM_SYSFS_PATH_MEM] = "/mem", |
| 62 | [CBMEM_SYSFS_PATH_SIZE] = "/size" |
| 63 | }; |
| 64 | |
| 65 | if (t >= ARRAY_SIZE(type2str)) |
| 66 | die("Incorrect path type requested: %d\n", t); |
| 67 | |
| 68 | if (snprintf(path_out, path_out_max_size, CBMEM_SYSFS_ENTRY_DIR_PATH_PRI_FMT "%s", id, |
| 69 | type2str[t]) <= 0) |
| 70 | die("Unable to create sysfs path string for coreboot table: %#" PRIx32 |
| 71 | ". Path type: %d. Error: %s\n", |
| 72 | id, t, strerror(errno)); |
| 73 | } |
| 74 | |
| 75 | bool cbmem_sysfs_init(void) |
| 76 | { |
no test coverage detected