Home | History | Annotate | Download | only in futility
      1 /*
      2  * Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
      3  * Use of this source code is governed by a BSD-style license that can be
      4  * found in the LICENSE file.
      5  */
      6 #ifndef VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_
      7 #define VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_
      8 
      9 /* What type of things do I know how to handle? */
     10 enum futil_file_type {
     11 	FILE_TYPE_UNKNOWN,
     12 	FILE_TYPE_PUBKEY,			/* VbPublicKey */
     13 	FILE_TYPE_KEYBLOCK,			/* VbKeyBlockHeader */
     14 	FILE_TYPE_FW_PREAMBLE,			/* VbFirmwarePreambleHeader */
     15 	FILE_TYPE_GBB,				/* GoogleBinaryBlockHeader */
     16 	FILE_TYPE_BIOS_IMAGE,			/* Chrome OS BIOS image */
     17 	FILE_TYPE_OLD_BIOS_IMAGE,		/* Old Chrome OS BIOS image */
     18 	FILE_TYPE_KERN_PREAMBLE,		/* VbKernelPreambleHeader */
     19 
     20 	/* These are FILE_TYPE_UNKNOWN, but we've been told more about them */
     21 	FILE_TYPE_RAW_FIRMWARE,			/* FW_MAIN_A, etc. */
     22 	FILE_TYPE_RAW_KERNEL,			/* vmlinuz, *.uimg, etc. */
     23 
     24 	FILE_TYPE_CHROMIUMOS_DISK,		/* At least it has a GPT */
     25 	FILE_TYPE_PRIVKEY,			/* VbPrivateKey */
     26 
     27 	NUM_FILE_TYPES
     28 };
     29 
     30 /* Names for them */
     31 const char * const futil_file_type_str(enum futil_file_type type);
     32 
     33 /*
     34  * This tries to match the buffer content to one of the known file types.
     35  */
     36 enum futil_file_type futil_file_type_buf(uint8_t *buf, uint32_t len);
     37 
     38 /*
     39  * This opens a file and tries to match it to one of the known file types.
     40  * It's not an error if it returns FILE_TYPE_UKNOWN.
     41  */
     42 enum futil_file_err futil_file_type(const char *filename,
     43 				    enum futil_file_type *type);
     44 
     45 /* Routines to identify particular file types. */
     46 enum futil_file_type recognize_bios_image(uint8_t *buf, uint32_t len);
     47 enum futil_file_type recognize_gbb(uint8_t *buf, uint32_t len);
     48 enum futil_file_type recognize_vblock1(uint8_t *buf, uint32_t len);
     49 enum futil_file_type recognize_gpt(uint8_t *buf, uint32_t len);
     50 enum futil_file_type recognize_privkey(uint8_t *buf, uint32_t len);
     51 
     52 #endif	/* VBOOT_REFERENCE_FUTILITY_FILE_TYPE_H_ */
     53