blob: 48654731773c42ab2ea9e4dbeedd90ab6c93f948 [file] [log] [blame]
Louis Yung-Chieh Loe1a25ab2010-04-20 10:52:41 -07001/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6#include "cgpt.h"
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -07007#include <string.h>
8#include "gpt.h"
9#include "utility.h"
Louis Yung-Chieh Loe1a25ab2010-04-20 10:52:41 -070010
11/* stub code */
12static int start[] = { 34, 10034 };
13
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070014int GptInit(GptData_t *gpt) {
15 int valid_headers[2] = {1, 1};
16
17 /* check header signature */
18 if (Memcmp(gpt->primary_header, GPT_HEADER_SIGNATURE,
19 GPT_HEADER_SIGNATURE_SIZE))
20 valid_headers[0] = 0;
21 if (Memcmp(gpt->secondary_header, GPT_HEADER_SIGNATURE,
22 GPT_HEADER_SIGNATURE_SIZE))
23 valid_headers[1] = 0;
24
25 if (!valid_headers[0] && !valid_headers[1])
26 return GPT_ERROR_INVALID_HEADERS;
27
Louis Yung-Chieh Lo4bbf21e2010-04-21 17:29:05 -070028 gpt->current_kernel = 1;
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070029 return GPT_SUCCESS;
Louis Yung-Chieh Loe1a25ab2010-04-20 10:52:41 -070030}
31
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070032int GptNextKernelEntry(GptData_t *gpt, uint64_t *start_sector, uint64_t *size) {
33 /* FIXME: the following code is not really code, just returns anything */
Louis Yung-Chieh Lo4bbf21e2010-04-21 17:29:05 -070034 gpt->current_kernel ^= 1;
35 if (start_sector) *start_sector = start[gpt->current_kernel];
36 if (size) *size = 10000;
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070037 return GPT_SUCCESS;
Louis Yung-Chieh Loe1a25ab2010-04-20 10:52:41 -070038}
39
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070040int GptUpdateKernelEntry(GptData_t *gpt, uint32_t update_type) {
41 /* FIXME: the following code is not really code, just return anything */
Louis Yung-Chieh Lo4bbf21e2010-04-21 17:29:05 -070042 gpt->modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1) <<
43 gpt->current_kernel;
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070044 return GPT_SUCCESS;
Louis Yung-Chieh Loe1a25ab2010-04-20 10:52:41 -070045}