Louis Yung-Chieh Lo | e1a25ab | 2010-04-20 10:52:41 -0700 | [diff] [blame] | 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 |
| 3 | * found in the LICENSE file. |
| 4 | */ |
| 5 | |
| 6 | #include "cgpt.h" |
Louis Yung-Chieh Lo | 37f6b55 | 2010-04-22 21:22:22 -0700 | [diff] [blame^] | 7 | #include <string.h> |
| 8 | #include "gpt.h" |
| 9 | #include "utility.h" |
Louis Yung-Chieh Lo | e1a25ab | 2010-04-20 10:52:41 -0700 | [diff] [blame] | 10 | |
| 11 | /* stub code */ |
| 12 | static int start[] = { 34, 10034 }; |
| 13 | |
Louis Yung-Chieh Lo | 37f6b55 | 2010-04-22 21:22:22 -0700 | [diff] [blame^] | 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 | |
Louis Yung-Chieh Lo | 4bbf21e | 2010-04-21 17:29:05 -0700 | [diff] [blame] | 28 | gpt->current_kernel = 1; |
Louis Yung-Chieh Lo | 37f6b55 | 2010-04-22 21:22:22 -0700 | [diff] [blame^] | 29 | return GPT_SUCCESS; |
Louis Yung-Chieh Lo | e1a25ab | 2010-04-20 10:52:41 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Louis Yung-Chieh Lo | 37f6b55 | 2010-04-22 21:22:22 -0700 | [diff] [blame^] | 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 */ |
Louis Yung-Chieh Lo | 4bbf21e | 2010-04-21 17:29:05 -0700 | [diff] [blame] | 34 | gpt->current_kernel ^= 1; |
| 35 | if (start_sector) *start_sector = start[gpt->current_kernel]; |
| 36 | if (size) *size = 10000; |
Louis Yung-Chieh Lo | 37f6b55 | 2010-04-22 21:22:22 -0700 | [diff] [blame^] | 37 | return GPT_SUCCESS; |
Louis Yung-Chieh Lo | e1a25ab | 2010-04-20 10:52:41 -0700 | [diff] [blame] | 38 | } |
| 39 | |
Louis Yung-Chieh Lo | 37f6b55 | 2010-04-22 21:22:22 -0700 | [diff] [blame^] | 40 | int GptUpdateKernelEntry(GptData_t *gpt, uint32_t update_type) { |
| 41 | /* FIXME: the following code is not really code, just return anything */ |
Louis Yung-Chieh Lo | 4bbf21e | 2010-04-21 17:29:05 -0700 | [diff] [blame] | 42 | gpt->modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1) << |
| 43 | gpt->current_kernel; |
Louis Yung-Chieh Lo | 37f6b55 | 2010-04-22 21:22:22 -0700 | [diff] [blame^] | 44 | return GPT_SUCCESS; |
Louis Yung-Chieh Lo | e1a25ab | 2010-04-20 10:52:41 -0700 | [diff] [blame] | 45 | } |