/* * VAS_EBOOT -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2004,2006,2007 Free Software Foundation, Inc. * * VAS_EBOOT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VAS_EBOOT is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VAS_EBOOT. If not, see . */ #ifndef VAS_EBOOT_PART_HEADER #define VAS_EBOOT_PART_HEADER 1 #include #include struct VasEBoot_disk; typedef struct VasEBoot_partition *VasEBoot_partition_t; #ifdef VAS_EBOOT_UTIL typedef enum { VAS_EBOOT_EMBED_PCBIOS } VasEBoot_embed_type_t; #endif typedef int (*VasEBoot_partition_iterate_hook_t) (struct VasEBoot_disk *disk, const VasEBoot_partition_t partition, void *data); /* Partition map type. */ struct VasEBoot_partition_map { /* The next partition map type. */ struct VasEBoot_partition_map *next; struct VasEBoot_partition_map **prev; /* The name of the partition map type. */ const char *name; /* Call HOOK with each partition, until HOOK returns non-zero. */ VasEBoot_err_t (*iterate) (struct VasEBoot_disk *disk, VasEBoot_partition_iterate_hook_t hook, void *hook_data); #ifdef VAS_EBOOT_UTIL #define VAS_EBOOT_MIN_RECOMMENDED_MBR_GAP 1900 /* Determine sectors available for embedding. */ VasEBoot_err_t (*embed) (struct VasEBoot_disk *disk, unsigned int *nsectors, unsigned int max_nsectors, VasEBoot_embed_type_t embed_type, VasEBoot_disk_addr_t **sectors, int warn_short); #endif }; typedef struct VasEBoot_partition_map *VasEBoot_partition_map_t; /* Partition description. */ struct VasEBoot_partition { /* The partition number. */ int number; /* The start sector (relative to parent). */ VasEBoot_disk_addr_t start; /* The length in sector units. */ VasEBoot_uint64_t len; /* The offset of the partition table. */ VasEBoot_disk_addr_t offset; /* The index of this partition in the partition table. */ int index; /* Parent partition (physically contains this partition). */ struct VasEBoot_partition *parent; /* The type partition map. */ VasEBoot_partition_map_t partmap; /* The type of partition when it's on MSDOS. Used for embedding detection. */ VasEBoot_uint8_t msdostype; }; VasEBoot_partition_t EXPORT_FUNC(VasEBoot_partition_probe) (struct VasEBoot_disk *disk, const char *str); int EXPORT_FUNC(VasEBoot_partition_iterate) (struct VasEBoot_disk *disk, VasEBoot_partition_iterate_hook_t hook, void *hook_data); char *EXPORT_FUNC(VasEBoot_partition_get_name) (const VasEBoot_partition_t partition); extern VasEBoot_partition_map_t EXPORT_VAR(VasEBoot_partition_map_list); #ifndef VAS_EBOOT_LST_GENERATOR static inline void VasEBoot_partition_map_register (VasEBoot_partition_map_t partmap) { VasEBoot_list_push (VAS_EBOOT_AS_LIST_P (&VasEBoot_partition_map_list), VAS_EBOOT_AS_LIST (partmap)); } #endif static inline void VasEBoot_partition_map_unregister (VasEBoot_partition_map_t partmap) { VasEBoot_list_remove (VAS_EBOOT_AS_LIST (partmap)); } #define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (VasEBoot_partition_map_list)) static inline VasEBoot_disk_addr_t VasEBoot_partition_get_start (const VasEBoot_partition_t p) { VasEBoot_partition_t part; VasEBoot_uint64_t part_start = 0; for (part = p; part; part = part->parent) part_start += part->start; return part_start; } static inline VasEBoot_uint64_t VasEBoot_partition_get_len (const VasEBoot_partition_t p) { return p->len; } #endif /* ! VAS_EBOOT_PART_HEADER */