| /* Copyright Statement: |
| * |
| * This software/firmware and related documentation ("MediaTek Software") are |
| * protected under relevant copyright laws. The information contained herein is |
| * confidential and proprietary to MediaTek Inc. and/or its licensors. Without |
| * the prior written permission of MediaTek inc. and/or its licensors, any |
| * reproduction, modification, use or disclosure of MediaTek Software, and |
| * information contained herein, in whole or in part, shall be strictly |
| * prohibited. |
| * |
| * MediaTek Inc. (C) 2018. All rights reserved. |
| * |
| * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER |
| * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL |
| * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED |
| * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR |
| * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH |
| * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, |
| * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES |
| * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. |
| * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO |
| * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK |
| * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE |
| * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR |
| * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S |
| * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE |
| * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE |
| * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE |
| * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| * |
| * The following software/firmware and/or related documentation ("MediaTek |
| * Software") have been modified by MediaTek Inc. All revisions are subject to |
| * any receiver's applicable license agreements with MediaTek Inc. |
| */ |
| |
| #ifndef MIDDLEWARE_BOOTLOADER_PARTITION_GPT_H |
| #define MIDDLEWARE_BOOTLOADER_PARTITION_GPT_H |
| |
| //KH #include <libc_mini.h> |
| #include <stdint.h> |
| |
| #define PARTITION_TYPE_MBR 0U |
| #define PARTITION_TYPE_GPT 1U |
| #define PARTITION_TYPE_GPT_BACKUP 2U |
| |
| /* GPT Signature should be 0x5452415020494645 */ |
| #define GPT_SIGNATURE_1 0x54524150U |
| #define GPT_SIGNATURE_2 0x20494645U |
| |
| #define MMC_MBR_SIGNATURE_BYTE_0 0x55U |
| #define MMC_MBR_SIGNATURE_BYTE_1 0xAAU |
| |
| /* GPT Offsets */ |
| #define PROTECTIVE_MBR_SIZE BLOCK_SIZE |
| #define HEADER_SIZE_OFFSET 12U |
| #define HEADER_CRC_OFFSET 16U |
| #define PRIMARY_HEADER_OFFSET 24U |
| #define BACKUP_HEADER_OFFSET 32U |
| #define FIRST_USABLE_LBA_OFFSET 40U |
| #define LAST_USABLE_LBA_OFFSET 48U |
| #define PARTITION_ENTRIES_OFFSET 72U |
| #define PARTITION_COUNT_OFFSET 80U |
| #define PENTRY_SIZE_OFFSET 84U |
| #define PARTITION_CRC_OFFSET 88U |
| |
| #define MIN_PARTITION_ARRAY_SIZE 0x4000U |
| |
| #define PARTITION_ENTRY_FIRST_LBA 32U |
| #define PARTITION_ENTRY_LAST_LBA 40U |
| |
| #define ENTRY_SIZE 0x080U |
| |
| #define UNIQUE_GUID_OFFSET 16U |
| #define FIRST_LBA_OFFSET 32U |
| #define LAST_LBA_OFFSET 40U |
| #define ATTRIBUTE_FLAG_OFFSET 48U |
| #define PARTITION_NAME_OFFSET 56U |
| |
| #define MAX_GPT_NAME_SIZE 72U |
| #define PARTITION_TYPE_GUID_SIZE 16U |
| #define UNIQUE_PARTITION_GUID_SIZE 16U |
| #define NUM_PARTITIONS 128U |
| |
| #define OS_TYPE_INVALID 0x0U |
| #define OS_TYPE_PROTECTIVE_MBR 0xEEU |
| |
| /* MBR partition record */ |
| #define MBR_PR_DEFAULT 0x0U |
| #define MBR_PR_BOOTABLE_LEGACY 0x80U |
| |
| /* Some useful define used to access the MBR/EBR table */ |
| #define BLOCK_SIZE 0x200U |
| |
| static inline void GET_LWORD_FROM_BYTE(uint32_t *dst, uint8_t *src) |
| { |
| (void) MEMCPY(dst, src, 4); |
| } |
| |
| static inline void GET_LLWORD_FROM_BYTE(uint64_t *dst, uint8_t *src) |
| { |
| (void) MEMCPY(dst, src, 8); |
| } |
| |
| #endif /* MIDDLEWARE_BOOTLOADER_PARTITION_GPT_H */ |
| |