1 /*- 2 * BSD LICENSE 3 * 4 * Copyright (c) Intel Corporation. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * * Neither the name of Intel Corporation nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 /** \file 35 * GPT internal Interface 36 */ 37 38 #ifndef SPDK_INTERNAL_GPT_H 39 #define SPDK_INTERNAL_GPT_H 40 41 #include "spdk/stdinc.h" 42 43 #include "spdk/gpt_spec.h" 44 45 #define SPDK_GPT_PART_TYPE_GUID SPDK_GPT_GUID(0x7c5222bd, 0x8f5d, 0x4087, 0x9c00, 0xbf9843c7b58c) 46 #define SPDK_GPT_BUFFER_SIZE 32768 /* 32KB */ 47 #define SPDK_GPT_GUID_EQUAL(x,y) (memcmp(x, y, sizeof(struct spdk_gpt_guid)) == 0) 48 49 enum spdk_gpt_parse_phase { 50 SPDK_GPT_PARSE_PHASE_INVALID = 0, 51 SPDK_GPT_PARSE_PHASE_PRIMARY, 52 SPDK_GPT_PARSE_PHASE_SECONDARY, 53 }; 54 55 struct spdk_gpt { 56 uint8_t parse_phase; 57 unsigned char *buf; 58 uint64_t buf_size; 59 uint64_t lba_start; 60 uint64_t lba_end; 61 uint64_t total_sectors; 62 uint32_t sector_size; 63 struct spdk_gpt_header *header; 64 struct spdk_gpt_partition_entry *partitions; 65 }; 66 67 int spdk_gpt_parse_mbr(struct spdk_gpt *gpt); 68 int spdk_gpt_parse_partition_table(struct spdk_gpt *gpt); 69 70 #endif /* SPDK_INTERNAL_GPT_H */ 71