OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 | 5 |
6 #include "cgpt.h" | 6 #include "cgpt.h" |
| 7 #include <string.h> |
| 8 #include "gpt.h" |
| 9 #include "utility.h" |
7 | 10 |
8 /* stub code */ | 11 /* stub code */ |
9 static int start[] = { 34, 10034 }; | 12 static int start[] = { 34, 10034 }; |
10 | 13 |
11 int GPTInit(GPTData_t *gpt) { | 14 int 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 |
12 gpt->current_kernel = 1; | 28 gpt->current_kernel = 1; |
13 return 0; | 29 return GPT_SUCCESS; |
14 } | 30 } |
15 | 31 |
16 int GPTNextKernelEntry(GPTData_t *gpt, uint64_t *start_sector, uint64_t *size) { | 32 int GptNextKernelEntry(GptData_t *gpt, uint64_t *start_sector, uint64_t *size) { |
| 33 /* FIXME: the following code is not really code, just returns anything */ |
17 gpt->current_kernel ^= 1; | 34 gpt->current_kernel ^= 1; |
18 if (start_sector) *start_sector = start[gpt->current_kernel]; | 35 if (start_sector) *start_sector = start[gpt->current_kernel]; |
19 if (size) *size = 10000; | 36 if (size) *size = 10000; |
20 return 0; | 37 return GPT_SUCCESS; |
21 } | 38 } |
22 | 39 |
23 int GPTUpdateKernelEntry(GPTData_t *gpt, uint32_t update_type) { | 40 int GptUpdateKernelEntry(GptData_t *gpt, uint32_t update_type) { |
| 41 /* FIXME: the following code is not really code, just return anything */ |
24 gpt->modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1) << | 42 gpt->modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1) << |
25 gpt->current_kernel; | 43 gpt->current_kernel; |
26 return 0; | 44 return GPT_SUCCESS; |
27 } | 45 } |
OLD | NEW |