A simple test infrastructure -- idea stolen from Gaurav.

Review URL: http://codereview.chromium.org/1761004
This commit is contained in:
Louis Yung-Chieh Lo
2010-04-21 17:29:05 -07:00
parent e1a25ab108
commit 4bbf21e476
4 changed files with 196 additions and 34 deletions

View File

@@ -9,10 +9,11 @@
#include <stdint.h>
enum {
GPT_ERROR_INVALID_HEADERS = 1,
GPT_ERROR_INVALID_ENTRIES,
GPT_ERROR_INVALID_SECTOR_SIZE,
GPT_ERROR_INVALID_SECTOR_NUMBER,
GPT_ERROR_NO_VALID_KERNEL = 1,
GPT_ERROR_INVALID_HEADERS,
GPT_ERROR_INVALID_ENTRIES,
GPT_ERROR_INVALID_SECTOR_SIZE,
GPT_ERROR_INVALID_SECTOR_NUMBER,
};
#define GPT_MODIFIED_HEADER1 0x01
@@ -28,27 +29,27 @@ enum {
* invalid. */
struct GPTData {
/* Fill in the following fields before calling GPTInit() */
uint8_t *header1; /* GPT primary header, from sector 1 of disk
* (size: 512 bytes) */
uint8_t *header2; /* GPT secondary header, from last sector of
* disk (size: 512 bytes) */
uint8_t *entries1; /* primary GPT table, follows primary header
* (size: 16 KB) */
uint8_t *entries2; /* secondary GPT table, precedes secondary
* header (size: 16 KB) */
uint32_t sector_bytes; /* Size of a LBA sector, in bytes */
uint64_t drive_sectors; /* Size of drive in LBA sectors, in sectors */
/* Fill in the following fields before calling GPTInit() */
uint8_t *header1; /* GPT primary header, from sector 1 of disk
* (size: 512 bytes) */
uint8_t *header2; /* GPT secondary header, from last sector of
* disk (size: 512 bytes) */
uint8_t *entries1; /* primary GPT table, follows primary header
* (size: 16 KB) */
uint8_t *entries2; /* secondary GPT table, precedes secondary
* header (size: 16 KB) */
uint32_t sector_bytes; /* Size of a LBA sector, in bytes */
uint64_t drive_sectors; /* Size of drive in LBA sectors, in sectors */
/* Outputs */
uint8_t modified; /* Which inputs have been modified?
* 0x01 = header1
* 0x02 = header2
* 0x04 = table1
* 0x08 = table2 */
/* Outputs */
uint8_t modified; /* Which inputs have been modified?
* 0x01 = header1
* 0x02 = header2
* 0x04 = table1
* 0x08 = table2 */
/* Internal state */
uint8_t current_kernel; // the current kernel index
/* Internal state */
uint8_t current_kernel; // the current kernel index
};
typedef struct GPTData GPTData_t;
@@ -74,7 +75,8 @@ int GPTNextKernelEntry(GPTData_t *gpt, uint64_t *start_sector, uint64_t *size);
* for the start of the kernel partition, and the size parameter contains the
* size of the kernel partition in LBA sectors.
*
* Returns 0 if successful, 1 if error or no more sectors. */
* Returns 0 if successful, else
* GPT_ERROR_NO_VALID_KERNEL, no avaliable kernel, enters recovery mode */
int GPTUpdateKernelEntry(GPTData_t *gpt, uint32_t update_type);
/* Updates the kernel entry with the specified index, using the specified type
@@ -85,4 +87,4 @@ int GPTUpdateKernelEntry(GPTData_t *gpt, uint32_t update_type);
*
* Returns 0 if successful, 1 if error. */
#endif // VBOOT_REFERENCE_CGPT_H_
#endif /* VBOOT_REFERENCE_CGPT_H_ */