blob: 34bf36200a0e8255da512a89a8e2c7d422097c92 [file] [log] [blame] [raw]
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
*
* This program 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 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) ) )
#define PC_SLICE_FLAG(mbr_ptr, part) \
( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET \
+ (part << 4)) ) )
#define PC_SLICE_HEAD(mbr_ptr, part) \
( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 1 \
+ (part << 4)) ) )
#define PC_SLICE_SEC(mbr_ptr, part) \
( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 2 \
+ (part << 4)) ) )
#define PC_SLICE_CYL(mbr_ptr, part) \
( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 3 \
+ (part << 4)) ) )
#define PC_SLICE_TYPE(mbr_ptr, part) \
( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 4 \
+ (part << 4)) ) )
#define PC_SLICE_EHEAD(mbr_ptr, part) \
( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 5 \
+ (part << 4)) ) )
#define PC_SLICE_ESEC(mbr_ptr, part) \
( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 6 \
+ (part << 4)) ) )
#define PC_SLICE_ECYL(mbr_ptr, part) \
( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 7 \
+ (part << 4)) ) )
#define PC_SLICE_START(mbr_ptr, part) \
( *( (unsigned long *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 8 \
+ (part << 4)) ) )
#define PC_SLICE_LENGTH(mbr_ptr, part) \
( *( (unsigned long *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 12 \
+ (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.
*/
#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_WIN95_EXTENDED 0xf
#define PC_SLICE_TYPE_EXT2FS 0x83
/* this next one is special, as it uses it's own partitioning scheme
to subdivide the PC partition from there */
#define PC_SLICE_TYPE_BSD 0xa5
/*
* *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) \
( *( (unsigned short *) (((int) l_ptr) + BSD_LABEL_MAG_OFFSET + 4) ) )
#define BSD_LABEL_NPARTS(l_ptr) \
( *( (unsigned short *) (((int) l_ptr) + BSD_LABEL_NPARTS_OFFSET) ) )
#define BSD_PART_LENGTH(l_ptr, part) \
( *( (unsigned long *) (((int) l_ptr) + BSD_PART_OFFSET \
+ (part << 4)) ) )
#define BSD_PART_START(l_ptr, part) \
( *( (unsigned long *) (((int) l_ptr) + BSD_PART_OFFSET + 4 \
+ (part << 4)) ) )
#define BSD_PART_FRAG_SIZE(l_ptr, part) \
( *( (unsigned long *) (((int) l_ptr) + BSD_PART_OFFSET + 8 \
+ (part << 4)) ) )
#define BSD_PART_TYPE(l_ptr, part) \
( *( (unsigned char *) (((int) l_ptr) + BSD_PART_OFFSET + 12 \
+ (part << 4)) ) )
#define BSD_PART_FRAGS_PER_BLOCK(l_ptr, part) \
( *( (unsigned char *) (((int) l_ptr) + BSD_PART_OFFSET + 13 \
+ (part << 4)) ) )
#define BSD_PART_EXTRA(l_ptr, part) \
( *( (unsigned short *) (((int) l_ptr) + BSD_PART_OFFSET + 14 \
+ (part << 4)) ) )
/* possible values for the "DISKTYPE"... all essentially irrelevant
except for DTYPE_SCSI */
#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
#define DTYPE_MSCP 2 /* MSCP */
#define DTYPE_DEC 3 /* other DEC (rk, rl) */
#define DTYPE_SCSI 4 /* SCSI */
#define DTYPE_ESDI 5 /* ESDI interface */
#define DTYPE_ST506 6 /* ST506 etc. */
#define DTYPE_HPIB 7 /* CS/80 on HP-IB */
#define DTYPE_HPFL 8 /* HP Fiber-link */
#define DTYPE_FLOPPY 10 /* floppy */
/* possible values for the *BSD-style partition type */
#define FS_UNUSED 0 /* unused */
#define FS_SWAP 1 /* swap */
#define FS_V6 2 /* Sixth Edition */
#define FS_V7 3 /* Seventh Edition */
#define FS_SYSV 4 /* System V */
#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
#define FS_V8 6 /* Eighth Edition, 4K blocks */
#define FS_BSDFFS 7 /* 4.2BSD fast file system */
#define FS_MSDOS 8 /* MSDOS file system */
#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */
#define FS_OTHER 10 /* in use, but unknown/unsupported */
#define FS_HPFS 11 /* OS/2 high-performance file system */
#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
#define FS_BOOT 13 /* partition contains bootstrap */
#endif /* _PC_SLICE_H */