mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 18:25:10 +00:00
cgptlib: Add functions to cgptlib API
Following changes are done to the cgptlib API in order to allow backend component of fastboot to perform erase and write operations on partitions and manipulate GPT entries: GptFindNthEntry - Returns the nth entry in GPT that matches provided GUID. GptGetEntrySizeLba - Returns size of a partition in lba. GptGetEntrySizeBytes - Returns size of a partition in bytes. GptUpdateKernelWithEntry - Given kernel entry is updated using the provided update_type. GptUpdateKernelEntry calls this function with entry for current_kernel. Add flags GPT_UPDATE_ENTRY_RESET and GPT_UPDATE_ENTRY_INVALID for calls to GptUpdateKernelEntry. These operations are used by write image and erase partition respectively. BUG=chrome-os-partner:35861 BRANCH=None TEST=Compiles successfully and all the newly added functions work as expected. Change-Id: I82c87e4c97de2d207e80209dbd4922b4bcd5880a Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/240268 Trybot-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
f1f53b3732
commit
f620c0d656
@@ -50,6 +50,16 @@ enum {
|
||||
* entry as invalid.
|
||||
*/
|
||||
GPT_UPDATE_ENTRY_BAD = 2,
|
||||
/*
|
||||
* Used for fastboot mode. When an image is written to kernel partition,
|
||||
* its GPT entry is marked with S1,P1,T15.
|
||||
*/
|
||||
GPT_UPDATE_ENTRY_RESET = 3,
|
||||
/*
|
||||
* Used for fastboot mode. When an image is written to kernel partition,
|
||||
* its GPT entry is marked with S0,P0,T0.
|
||||
*/
|
||||
GPT_UPDATE_ENTRY_INVALID = 4,
|
||||
};
|
||||
|
||||
/* If this bit is 1, the GPT is stored in another from the streaming data */
|
||||
@@ -129,6 +139,13 @@ typedef struct {
|
||||
* small) */
|
||||
int GptInit(GptData *gpt);
|
||||
|
||||
/**
|
||||
* Return the nth instance of parition entry matching the partition type guid
|
||||
* from the gpt table. Instance value starts from 0. If the entry is not found,
|
||||
* it returns NULL.
|
||||
*/
|
||||
GptEntry *GptFindNthEntry(GptData *gpt, const Guid *guid, unsigned int n);
|
||||
|
||||
/**
|
||||
* Allocate and read GPT data from the drive. The sector_bytes and
|
||||
* drive_sectors fields should be filled on input. The primary and secondary
|
||||
@@ -148,4 +165,35 @@ int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData *gptdata);
|
||||
*/
|
||||
int IsUnusedEntry(const GptEntry *e);
|
||||
|
||||
/**
|
||||
* Return size(in lba) of a partition represented by given GPT entry.
|
||||
*/
|
||||
size_t GptGetEntrySizeLba(const GptEntry *e);
|
||||
|
||||
/**
|
||||
* Return size(in bytes) of a partition represented by given GPT entry.
|
||||
*/
|
||||
size_t GptGetEntrySizeBytes(const GptData *gpt, const GptEntry *e);
|
||||
|
||||
/**
|
||||
* Updates the kernel entry with the specified index, using the specified type
|
||||
* of update (GPT_UPDATE_ENTRY_*).
|
||||
*
|
||||
* On return the modified field may be set, if the GPT data has been modified
|
||||
* and should be written to disk.
|
||||
*
|
||||
* Returns GPT_SUCCESS if successful, else
|
||||
* GPT_ERROR_INVALID_UPDATE_TYPE, invalid 'update_type' is given.
|
||||
*/
|
||||
int GptUpdateKernelWithEntry(GptData *gpt, GptEntry *e, uint32_t update_type);
|
||||
|
||||
/**
|
||||
* Updates the kernel entry identified by current_kernel field. If
|
||||
* current_kernel is not set it returns an error.
|
||||
*
|
||||
* Returns GPT_SUCCESS if successful, else
|
||||
* GPT_ERROR_INVALID_UPDATE_TYPE, invalid 'update_type' is given.
|
||||
*/
|
||||
int GptUpdateKernelEntry(GptData *gpt, uint32_t update_type);
|
||||
|
||||
#endif /* VBOOT_REFERENCE_CGPT_MISC_H_ */
|
||||
|
||||
Reference in New Issue
Block a user