pc_slice.h revision 44bc9120699af80bb18366ca474cb2c618608ca9
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2003 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _PC_SLICE_H
#define _PC_SLICE_H
/*
* These define the basic PC MBR sector characteristics
*/
#define PC_MBR_SECTOR 0
#define PC_MBR_SIG_OFFSET 510
#define PC_MBR_SIGNATURE 0xaa55
#define PC_SLICE_OFFSET 446
#define PC_SLICE_MAX 4
/*
* Defines to guarantee structural alignment.
*/
#define PC_MBR_CHECK_SIG(mbr_ptr) \
( *( (unsigned short *) (((int) mbr_ptr) + PC_MBR_SIG_OFFSET) ) \
== PC_MBR_SIGNATURE )
#define PC_MBR_SIG(mbr_ptr) \
( *( (unsigned short *) (((int) mbr_ptr) + PC_MBR_SIG_OFFSET) ) )
( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET \
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
/*
* PC flag types are defined here.
*/
#define PC_SLICE_FLAG_NONE 0
#define PC_SLICE_FLAG_BOOTABLE 0x80
/*
* Known PC partition types are defined here.
*/
/* This is not a flag actually, but used as if it were a flag. */
#define PC_SLICE_TYPE_HIDDEN_FLAG 0x10
#define PC_SLICE_TYPE_NONE 0
#define PC_SLICE_TYPE_FAT12 1
#define PC_SLICE_TYPE_FAT16_LT32M 4
#define PC_SLICE_TYPE_EXTENDED 5
#define PC_SLICE_TYPE_FAT16_GT32M 6
#define PC_SLICE_TYPE_FAT32 0xb
#define PC_SLICE_TYPE_FAT32_LBA 0xc
#define PC_SLICE_TYPE_FAT16_LBA 0xe
#define PC_SLICE_TYPE_WIN95_EXTENDED 0xf
#define PC_SLICE_TYPE_EZD 0x55
#define PC_SLICE_TYPE_MINIX 0x80
#define PC_SLICE_TYPE_LINUX_MINIX 0x81
#define PC_SLICE_TYPE_EXT2FS 0x83
#define PC_SLICE_TYPE_LINUX_EXTENDED 0x85
#define PC_SLICE_TYPE_VSTAFS 0x9e
#define PC_SLICE_TYPE_DELL_UTIL 0xde
#define PC_SLICE_TYPE_GPT 0xee
#define PC_SLICE_TYPE_LINUX_RAID 0xfd
/* For convinience. */
/* Check if TYPE is a FAT partition type. Clear the hidden flag before
the check, to allow the user to mount a hidden partition in GRUB. */
#define IS_PC_SLICE_TYPE_FAT(type) \
_type == PC_SLICE_TYPE_FAT12 \
|| _type == PC_SLICE_TYPE_FAT16_LT32M \
|| _type == PC_SLICE_TYPE_FAT16_GT32M \
|| _type == PC_SLICE_TYPE_FAT16_LBA \
|| _type == PC_SLICE_TYPE_FAT32 \
|| _type == PC_SLICE_TYPE_FAT32_LBA \
|| type == PC_SLICE_TYPE_SOLARIS_BOOT \
|| type == PC_SLICE_TYPE_DELL_UTIL; })
#define IS_PC_SLICE_TYPE_EXTENDED(type) \
(((type) == PC_SLICE_TYPE_EXTENDED) \
|| ((type) == PC_SLICE_TYPE_WIN95_EXTENDED) \
|| ((type) == PC_SLICE_TYPE_LINUX_EXTENDED))
#define IS_PC_SLICE_TYPE_MINIX(type) \
(((type) == PC_SLICE_TYPE_MINIX) \
|| ((type) == PC_SLICE_TYPE_LINUX_MINIX))
/* these ones are special, as they use their own partitioning scheme
to subdivide the PC partitions from there. */
#define PC_SLICE_TYPE_FREEBSD 0xa5
#define PC_SLICE_TYPE_OPENBSD 0xa6
#define PC_SLICE_TYPE_NETBSD 0xa9
/* For convenience. */
#define IS_PC_SLICE_TYPE_SOLARIS(type) \
/*
* *BSD-style disklabel & partition definitions.
*
* This is a subdivided slice of type 'PC_SLICE_TYPE_BSD', so all of
* these, except where noted, are relative to the slice in question.
*/
#define BSD_LABEL_SECTOR 1
#define BSD_LABEL_MAGIC 0x82564557
#define BSD_LABEL_MAG_OFFSET 0
#define BSD_LABEL_MAG2_OFFSET 132
#define BSD_LABEL_NPARTS_OFFSET 138
#define BSD_LABEL_NPARTS_MAX 8
#define BSD_PART_OFFSET 148
/*
* Defines to guarantee structural alignment.
*/
#define BSD_LABEL_CHECK_MAG(l_ptr) \
( *( (unsigned long *) (((int) l_ptr) + BSD_LABEL_MAG_OFFSET) ) \
== ( (unsigned long) BSD_LABEL_MAGIC ) )
#define BSD_LABEL_MAG(l_ptr) \
( *( (unsigned long *) (((int) l_ptr) + BSD_LABEL_MAG_OFFSET) ) )
#define BSD_LABEL_DTYPE(l_ptr) \
#define BSD_LABEL_NPARTS(l_ptr) \
( *( (unsigned short *) (((int) l_ptr) + BSD_LABEL_NPARTS_OFFSET) ) )
( *( (unsigned long *) (((int) l_ptr) + BSD_PART_OFFSET \
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
+ (part << 4)) ) )
/* possible values for the "DISKTYPE"... all essentially irrelevant
except for DTYPE_SCSI */
/* possible values for the *BSD-style partition type */
#define FS_UNUSED 0 /* unused */
/*
* Solaris LABEL definitions. All definitions are relative to the
* current PC_SLICE.
*/
#define SOL_LABEL_LOC 1
#define SOL_LABEL_SIZE 512
#define SOL_LABEL_MAGIC 0xdabe
#define SOL_LABEL_MAGIC_OFFSET 0x1fc
#define SOL_LABEL_NPARTS 0x10
#define SOL_PART_OFFSET 0x48
#define SOL_LABEL_CHECK_MAG(l_ptr) \
(*((unsigned short *) (((int) l_ptr) + SOL_LABEL_MAGIC_OFFSET)) \
== ((unsigned short) SOL_LABEL_MAGIC ))
#define SOL_PART_START(l_ptr, p) \
#define SOL_PART_LENGTH(l_ptr, p) \
#endif /* _PC_SLICE_H */