diff options
Diffstat (limited to 'futility/traversal.h')
-rw-r--r-- | futility/traversal.h | 111 |
1 files changed, 23 insertions, 88 deletions
diff --git a/futility/traversal.h b/futility/traversal.h index e975469a..cb2052d0 100644 --- a/futility/traversal.h +++ b/futility/traversal.h @@ -6,98 +6,33 @@ #ifndef VBOOT_REFERENCE_FUTILITY_TRAVERSAL_H_ #define VBOOT_REFERENCE_FUTILITY_TRAVERSAL_H_ #include <stdint.h> - - -/* What are we trying to accomplish? */ -enum futil_op_type { - FUTIL_OP_SHOW, - FUTIL_OP_SIGN, - - NUM_FUTIL_OPS -}; - -/* What component are we currently handling in the callback routine? */ -enum futil_cb_component { - /* entire input buffer */ - CB_BEGIN_TRAVERSAL, - CB_END_TRAVERSAL, - /* fmap areas within a bios image */ - CB_FMAP_GBB, - CB_FMAP_VBLOCK_A, - CB_FMAP_VBLOCK_B, - CB_FMAP_FW_MAIN_A, - CB_FMAP_FW_MAIN_B, - /* individual files (extracted from a bios, for example) */ - CB_PUBKEY, - CB_KEYBLOCK, - CB_GBB, - CB_FW_PREAMBLE, - CB_KERN_PREAMBLE, - CB_RAW_FIRMWARE, - CB_RAW_KERNEL, - CB_PRIVKEY, - CB_VB2_PUBKEY, - CB_VB2_PRIVKEY, - CB_PEM, - - NUM_CB_COMPONENTS -}; - -/* Where is the component we're poking at? */ -struct cb_area_s { - uint32_t offset; /* to avoid pointer math */ - uint8_t *buf; - uint32_t len; - uint32_t _flags; /* for callback use */ -}; - -/* What do we know at this point in time? */ -struct futil_traverse_state_s { - /* These two should be initialized by the caller as needed */ - const char *in_filename; - enum futil_op_type op; - /* Current activity during traversal */ - enum futil_cb_component component; - struct cb_area_s *my_area; - const char *name; - /* Other activites, possibly before or after the current one */ - struct cb_area_s cb_area[NUM_CB_COMPONENTS]; - struct cb_area_s recovery_key; - struct cb_area_s rootkey; - enum futil_file_type in_type; - int errors; -}; - +#include "fmap.h" /* - * Traverse the buffer using the provided state, which should be initialized - * before calling. Returns nonzero (but no details) if there were any errors. + * The Chrome OS BIOS must contain specific FMAP areas, and we generally want + * to look at each one in a certain order. */ -int futil_traverse(uint8_t *buf, uint32_t len, - struct futil_traverse_state_s *state, - enum futil_file_type type_hint); +enum bios_component { + BIOS_FMAP_GBB, + BIOS_FMAP_FW_MAIN_A, + BIOS_FMAP_FW_MAIN_B, + BIOS_FMAP_VBLOCK_A, + BIOS_FMAP_VBLOCK_B, + + NUM_BIOS_COMPONENTS +}; + +/* These are the expected areas, in order of traversal */ +extern struct bios_fmap_s { + enum bios_component component; + const char * const name; + /* The Cr-48 BIOS images have different FMAP names but work the same, + * so we allow those too. */ + const char * const oldname; +} bios_area[]; -/* These are invoked by the traversal. They also return nonzero on error. */ -int futil_cb_show_begin(struct futil_traverse_state_s *state); -int futil_cb_show_pubkey(struct futil_traverse_state_s *state); -int futil_cb_show_gbb(struct futil_traverse_state_s *state); -int futil_cb_show_keyblock(struct futil_traverse_state_s *state); -int futil_cb_show_fw_main(struct futil_traverse_state_s *state); -int futil_cb_show_fw_preamble(struct futil_traverse_state_s *state); -int futil_cb_show_kernel_preamble(struct futil_traverse_state_s *state); -int futil_cb_show_privkey(struct futil_traverse_state_s *state); -int futil_cb_show_vb2_pubkey(struct futil_traverse_state_s *state); -int futil_cb_show_vb2_privkey(struct futil_traverse_state_s *state); -int futil_cb_show_pem(struct futil_traverse_state_s *state); -int futil_cb_sign_pubkey(struct futil_traverse_state_s *state); -int futil_cb_sign_fw_main(struct futil_traverse_state_s *state); -int futil_cb_sign_fw_vblock(struct futil_traverse_state_s *state); -int futil_cb_sign_raw_firmware(struct futil_traverse_state_s *state); -int futil_cb_resign_kernel_part(struct futil_traverse_state_s *state); -int futil_cb_create_kernel_part(struct futil_traverse_state_s *state); -int futil_cb_sign_begin(struct futil_traverse_state_s *state); -int futil_cb_sign_end(struct futil_traverse_state_s *state); +void fmap_limit_area(FmapAreaHeader *ah, uint32_t len); -#endif /* VBOOT_REFERENCE_FUTILITY_TRAVERSAL_H_ */ +#endif /* VBOOT_REFERENCE_FUTILITY_TRAVERSAL_H_ */ |