Attention is currently required from: Patrick Georgi, Jakub Czapiga. Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/59492 )
Change subject: libpayload: Add libpayload_boot_device_read function ......................................................................
Patch Set 2:
(2 comments)
File payloads/libpayload/include/boot_device.h:
https://review.coreboot.org/c/coreboot/+/59492/comment/85f1facc_1672803d PS2, Line 20: libpayload_boot_device_read
I'm not that happy with the name, especially since it has to be implemented by payloads. […]
I'm okay just calling it boot_device_read() if you prefer that (generally namespacing is nice, but it's not like we're doing that anywhere else in libpayload so I guess there's no point trying to do it here... we also have usb_generic_create() and usb_generic_destroy() as names for functions that need to be implemented by the payload, FWIW).
File payloads/libpayload/libc/boot_device.c:
https://review.coreboot.org/c/coreboot/+/59492/comment/00069e9b_ab3774a0 PS1, Line 8: __attribute__((weak)) ssize_t libpayload_boot_device_read(void *buf, size_t offset, size_t size)
Ok, I removed this implementation. […]
I'm saying this should be implemented similarly to arch/x86/rom_media.c but not quite with the same code. You can put it in the same file if you want (and then we'll just remove the other stuff when we remove the media API). Basically, I think all this would need to be is:
__attribute__((weak)) ssize_t libpayload_boot_device_read(void *buf, size_t offset, size_t size) { /* Memory-mapping usually only works for the top 16MB. */ if (!lib_sysinfo.boot_media_size || lib_sysinfo.boot_media_size - offset > 16*MiB) return -CB_ERR_ARG; void *ptr = (void *)(uintptr_t)(uint32_t)(0 - lib_sysinfo.boot_media_size + offset); memcpy(buf, ptr, size); return size; }