From ecdca931ae0637d1a9498f64862939bd5bb99e0b Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Thu, 25 Jul 2019 18:26:18 +0800 Subject: vboot: move vb2_context inside vb2_shared_data (persistent context) Move vb2_context to live inside of vb2_shared_data, instead of in a separate memory space allocated by the caller. See design doc: http://go/vboot2-persistent-context BUG=b:124141368, chromium:994060 TEST=make clean && make runtests BRANCH=none Change-Id: If2421756572a43ba58b9da9f00e56a8f26ad3ad5 Signed-off-by: Joel Kitching Cq-Depend: chromium:1874753, chromium:1902339 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1716351 Tested-by: Joel Kitching Commit-Queue: Julius Werner Reviewed-by: Joel Kitching Reviewed-by: Julius Werner --- firmware/2lib/include/2misc.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'firmware/2lib/include/2misc.h') diff --git a/firmware/2lib/include/2misc.h b/firmware/2lib/include/2misc.h index 5ce10705..d9be9730 100644 --- a/firmware/2lib/include/2misc.h +++ b/firmware/2lib/include/2misc.h @@ -14,6 +14,10 @@ struct vb2_gbb_header; struct vb2_workbuf; +#define vb2_container_of(ptr, type, member) ({ \ + const typeof(((type *)0)->member) *__mptr = (ptr); \ + (type *)((uint8_t *)__mptr - offsetof(type, member) );}) \ + /** * Get the shared data pointer from the vboot context * @@ -22,7 +26,7 @@ struct vb2_workbuf; */ static inline struct vb2_shared_data *vb2_get_sd(struct vb2_context *ctx) { - return (struct vb2_shared_data *)ctx->workbuf; + return vb2_container_of(ctx, struct vb2_shared_data, ctx); } /** @@ -72,18 +76,6 @@ void vb2_set_workbuf_used(struct vb2_context *ctx, uint32_t used); vb2_error_t vb2_read_gbb_header(struct vb2_context *ctx, struct vb2_gbb_header *gbb); -/** - * Set up the verified boot context data, if not already set up. - * - * This uses ctx->workbuf_used=0 as a flag to indicate that the data has not - * yet been set up. Caller must set that before calling any vboot functions; - * see 2api.h. - * - * @param ctx Vboot context to initialize - * @return VB2_SUCCESS, or error code on error. - */ -vb2_error_t vb2_init_context(struct vb2_context *ctx); - /** * Check for recovery reasons we can determine early in the boot process. * -- cgit v1.2.1