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 10 #include <gpt/gpt.h> 11 #include <zircon/device/block.h> 12 #include <zircon/types.h> 13 14 // Recommended default size of the Zircon kernel partition 15 #define SZ_ZX_PART (64 * ((uint64_t)1) << 20) 16 // Recommended default size of the root partition 17 #define SZ_ROOT_PART (4 * ((uint64_t)1) << 30) 18 // Recommended minimum size of the ChromeOS state partition 19 #define MIN_SZ_STATE (5 * ((uint64_t)1) << 30) 20 21 __BEGIN_CDECLS 22 23 // determine if this looks like a ChromeOS partition layout 24 bool is_cros(const gpt_device_t* gpt); 25 26 // We define that we're ready to pave if 27 // - ZIRCON-A, ZIRCON-B, and ZIRCON-R are present and at least sz_kern bytes 28 // - An FVM a partition is present 29 bool is_ready_to_pave(const gpt_device_t* gpt, const block_info_t* block_info, 30 const uint64_t sz_kern); 31 32 // Configure the GPT for a dual-boot of Fuchsia and ChromeOS. 33 // 34 // Partitions ZIRCON-A, ZIRCON-B, ZIRCON-R, and FVM will be created. 35 // 36 // If space is required to create the above partitions, KERN-C and ROOT-C may be 37 // deleted, and STATE may be resized. 38 // 39 // Returns ZX_OK if reconfiguration succeeds and then the GPT should be 40 // persisted. Returns ZX_ERR_BAD_STATE if the partition table can't be 41 // reconfigured. In the case of error, the GPT should NOT be written back to 42 // disk and should be discarded. 43 zx_status_t config_cros_for_fuchsia(gpt_device_t* gpt, 44 const block_info_t* blk_info, 45 const uint64_t sz_kern); 46 47 __END_CDECLS 48