1 // Copyright 2017 The Fuchsia 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 #pragma once 6 7 #include <stdbool.h> 8 #include <stdint.h> 9 #include <unistd.h> 10 11 #include <zircon/compiler.h> 12 13 __BEGIN_CDECLS 14 15 // GUID for a ChromeOS kernel partition 16 #define GUID_CROS_KERNEL_STRING "FE3A2A5D-4F32-41A7-B725-ACCC3285A309" 17 #define GUID_CROS_KERNEL_VALUE { \ 18 0x5d, 0x2a, 0x3a, 0xfe, \ 19 0x32, 0x4f, \ 20 0xa7, 0x41, \ 21 0xb7, 0x25, 0xac, 0xcc, 0x32, 0x85, 0xa3, 0x09 \ 22 } 23 24 #define GUID_CROS_ROOT_STRING "3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC" 25 #define GUID_CROS_ROOT_VALUE { \ 26 0x02, 0xe2, 0xb8, 0x3c, \ 27 0x7e, 0x3b, \ 28 0xdd, 0x47, \ 29 0x8a, 0x3c, 0x7f, 0xf2, 0xa1, 0x3c, 0xfc, 0xec \ 30 } 31 32 #define GUID_GEN_DATA_STRING "EBD0A0A2-B9E5-4433-87C0-68B8B72699C7" 33 #define GUID_GEN_DATA_VALUE { \ 34 0xa2, 0xa0, 0xd0, 0xeb, \ 35 0xe5, 0xb9, \ 36 0x33, 0x44, \ 37 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 \ 38 } 39 40 #define GUID_CROS_STATE_STRING GUID_GEN_DATA_STRING 41 #define GUID_CROS_STATE_VALUE GUID_GEN_DATA_VALUE 42 43 #define GUID_CROS_FIRMWARE_STRING "CAB6E88E-ABF3-4102-A07A-D4BB9BE3C1D3" 44 #define GUID_CROS_FIRMWARE_VALUE { \ 45 0x8e, 0xe8, 0xb6, 0xca, \ 46 0xf3, 0xab, \ 47 0x02, 0x41, \ 48 0xa0, 0x7a, 0xd4, 0xbb, 0x9b, 0xe3, 0xc1, 0xd3 \ 49 } 50 51 // Returns true if |guid| matches the ChromeOS kernel GUID. 52 bool gpt_cros_is_kernel_guid(const uint8_t* guid, size_t len); 53 54 // Gets/sets the successful flag for a CrOS KERNEL partition. 55 bool gpt_cros_attr_get_successful(uint64_t flags); 56 void gpt_cros_attr_set_successful(uint64_t* flags, bool successful); 57 58 // Gets/sets the tries remaining field for a CrOS KERNEL partition. 59 // tries must be in the range [0, 16). If it is out of range, -1 60 // is returned from set. Otherwise returns 0. 61 uint8_t gpt_cros_attr_get_tries(uint64_t flags); 62 int gpt_cros_attr_set_tries(uint64_t* flags, uint8_t tries); 63 64 // Gets/sets the priority field for a CrOS KERNEL partition. 65 // priority must be in the range [0, 16). If it is out of range, -1 66 // is returned from set. Otherwise returns 0. 67 uint8_t gpt_cros_attr_get_priority(uint64_t flags); 68 int gpt_cros_attr_set_priority(uint64_t* flags, uint8_t priority); 69 70 __END_CDECLS 71