ide_part_table.h
来自「AMLOGIC DPF source code」· C头文件 代码 · 共 281 行
H
281 行
/*******************************************************************
*
* Copyright C 2005 by Amlogic, Inc. All Rights Reserved.
*
* Description:
*
* Author: Amlogic Software
* Created: Fri Nov 11 01:07:14 2005
*
*******************************************************************/
/*****************************************************************************
*
* ide_part_table.h
*
* The header file for library supporting "MS-DOS-style" partition table
*
*
* Copyright (C) 2002 OKTET Ltd., St.-Petersburg, Russia
*
* Author: Konstantin Abramenko <Konstantin.Abramenko@oktet.ru>
* Alexander Kukuta <Alexander.Kukuta@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.avfs.com/license/LICENSE.
*
* ide_part_table.h,v 1.1.2.2 2003/09/04 18:46:53 joel Exp
*
*****************************************************************************/
#ifndef __AVFS_IDE_PART_TABLE_H__
#define __AVFS_IDE_PART_TABLE_H__
#if 0
//porting
#include <assert.h>
#include <chain.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <avfs.h>
#include <avfs/blkdev.h>
#include <avfs/libio.h>
#include <avfs/libio_.h>
#include <avfs/bdbuf.h>
#include <avfs/seterr.h>
#endif
/* Minor base number for all logical devices */
#define AVFS_IDE_SECTOR_BITS 9
#define AVFS_IDE_SECTOR_SIZE 512
#define AVFS_IDE_PARTITION_DESCRIPTOR_SIZE 16
#define AVFS_IDE_PARTITION_MAX_PARTITION_NUMBER 63
#define AVFS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER 4
#define AVFS_IDE_PARTITION_DEV_NAME_LENGTH_MAX 32
#define AVFS_IDE_PARTITION_MSDOS_SIGNATURE_DATA1 0x55
#define AVFS_IDE_PARTITION_MSDOS_SIGNATURE_DATA2 0xaa
#define AVFS_IDE_PARTITION_MSDOS_SIGNATURE_OFFSET 0x1fe
#define AVFS_IDE_PARTITION_TABLE_OFFSET 0x1be
#define AVFS_IDE_PARTITION_BOOTABLE_OFFSET 0
#define AVFS_IDE_PARTITION_SYS_TYPE_OFFSET 4
#define AVFS_IDE_PARTITION_START_OFFSET 8
#define AVFS_IDE_PARTITION_SIZE_OFFSET 12
/*
* Conversion from and to little-endian byte order. (no-op on i386/i486)
*/
#if (CPU_BIG_ENDIAN == TRUE)
# define LE_TO_CPU_U16(v) CPU_swap_u16(v)
# define LE_TO_CPU_U32(v) CPU_swap_u32(v)
# define CPU_TO_LE_U16(v) CPU_swap_u16(v)
# define CPU_TO_LE_U32(v) CPU_swap_u32(v)
#else
# define LE_TO_CPU_U16(v) (v)
# define LE_TO_CPU_U32(v) (v)
# define CPU_TO_LE_U16(v) (v)
# define CPU_TO_LE_U32(v) (v)
#endif
/*
* sector_data_t --
* corresponds to the sector on the device
*/
typedef struct sector_data_s
{
unsigned32 sector_num; /* sector number on the device */
unsigned8 data[0]; /* raw sector data */
} sector_data_t;
/*
* Enum partition types
* see list at http://ata-atapi.com/hiwtab.htm
*/
enum {
EMPTY_PARTITION = 0x00,
DOS_FAT12_PARTITION = 0x01,
DOS_FAT16_PARTITION = 0x04,
EXTENDED_PARTITION = 0x05,
DOS_P32MB_PARTITION = 0x06,
NTFS_OR_HPFS_PART = 0x07,
FAT32_PARTITION = 0x0B,
FAT32_LBA_PARTITION = 0x0C,
FAT16_LBA_PARTITION = 0x0E,
DM6_PARTITION = 0x54,
EZD_PARTITION = 0x55,
DM6_AUX1PARTITION = 0x51,
DM6_AUX3PARTITION = 0x53,
LINUX_SWAP = 0x82,
LINUX_NATIVE = 0x83,
LINUX_EXTENDED = 0x85
#if 1
//added by rain
,
WIN95_EXTENDED = 0x0f
#endif
};
#if 0 //Added by Andrew more partition table
Values for operating system indicator:
00h empty
01h DOS 12-bit FAT
02h XENIX root file system
03h XENIX /usr file system (obsolete)
04h DOS 16-bit FAT (up to 32M)
05h DOS 3.3+ extended partition
06h DOS 3.31+ Large File System (16-bit FAT, over 32M)
07h QNX
07h OS/2 HPFS
07h Windows NT NTFS
07h Advanced Unix
08h AIX bootable partition, SplitDrive
09h AIX data partition
09h Coherent filesystem
0Ah OS/2 Boot Manager
0Ah OPUS
0Ah Coherent swap partition
10h OPUS
11h OS/2 Boot Manager hidden 12-bit FAT partition
12h Compaq Diagnostics partition
14h (resulted from using Novell DOS 7.0 FDISK to delete Linux Native part)
14h OS/2 Boot Manager hidden sub-32M 16-bit FAT partition
16h OS/2 Boot Manager hidden over-32M 16-bit FAT partition
17h OS/2 Boot Manager hidden HPFS partition
18h AST special Windows swap file
24h NEC MS-DOS 3.x
3Ch PowerQuest PartitionMagic recovery partition
40h VENIX 80286
42h SFS (Secure File System) by Peter Gutmann
50h Disk Manager, read-only partition
51h Disk Manager, read/write partition
51h Novell???
52h CP/M
52h Microport System V/386
56h GoldenBow VFeature
61h SpeedStor
63h Unix SysV/386, 386/ix
63h Mach, MtXinu BSD 4.3 on Mach
63h GNU HURD
64h Novell NetWare
65h Novell NetWare (3.11)
70h DiskSecure Multi-Boot
75h PC/IX
80h Minix v1.1 - 1.4a
81h Minix v1.4b+
81h Linux
81h Mitac Advanced Disk Manager
82h Linux Swap partition
83h Linux native file system (ext2fs/xiafs)
84h OS/2-renumbered type 04h partition (related to hiding DOS C: drive)
93h Amoeba file system
94h Amoeba bad block table
A5h FreeBSD
B7h BSDI file system (secondarily swap)
B8h BSDI swap partition (secondarily file system)
C1h DR-DOS 6.0 LOGIN.EXE-secured 12-bit FAT partition
C4h DR-DOS 6.0 LOGIN.EXE-secured 16-bit FAT partition
C6h DR-DOS 6.0 LOGIN.EXE-secured Huge partition
C7h Cyrnix Boot
DBh CP/M, Concurrent CP/M, Concurrent DOS
DBh CTOS (Convergent Technologies OS)
E1h SpeedStor 12-bit FAT extended partition
E4h SpeedStor 16-bit FAT extended partition
F2h DOS 3.3+ secondary
F4h SpeedStor
FEh LANstep
FFh Xenix bad block table
#endif
/* Forward declaration */
struct disk_desc_s;
/*
* part_desc_t --
* contains all neccessary information about partition
*/
typedef struct part_desc_s {
unsigned8 bootable; /* is the partition active */
unsigned8 sys_type; /* type of partition */
unsigned8 log_id; /* logical number of partition */
unsigned32 start; /* first partition sector, in absolute numeration */
unsigned32 size; /* size in sectors */
unsigned32 end; /* last partition sector, end = start + size - 1 */
struct disk_desc_s *disk_desc; /* descriptor of disk, partition contains in */
struct part_desc_s *ext_part; /* extended partition containing this one */
/* partitions, containing in this one */
struct part_desc_s *sub_part[AVFS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER];
} part_desc_t;
typedef struct disk_desc_s {
dev_t dev; /* device number */
/* device name in /dev filesystem */
unsigned8 dev_name[AVFS_IDE_PARTITION_DEV_NAME_LENGTH_MAX];
unsigned32 sector_size; /* size of sector */
unsigned32 sector_bits; /* the base-2 logarithm of sector_size */
unsigned32 lba_size; /* total amount of sectors in lba address mode */
int last_log_id; /* used for logical disks enumerating */
/* primary partition descriptors */
part_desc_t *partitions[AVFS_IDE_PARTITION_MAX_PARTITION_NUMBER];
} disk_desc_t;
/*
* avfs_ide_part_table_free --
* frees disk descriptor structure
*
* PARAMETERS:
* disk_desc - disc descriptor structure to free
*
* RETURNS:
* N/A
*/
void
avfs_ide_part_table_free(disk_desc_t *disk_desc);
/*
* avfs_ide_part_table_get --
* reads partition table structure from the device
* and creates disk description structure
*
* PARAMETERS:
* dev_name - path to physical device in /dev filesystem
* disk_desc - returned disc description structure
*
* RETURNS:
* AVFS_SUCCESSFUL if success, or -1 and corresponding errno else
*/
avfs_status_code
avfs_ide_part_table_get(const char *dev_name, disk_desc_t *disk_desc);
/*
* avfs_ide_part_table_initialize --
* initializes logical devices on the physical IDE drive
*
* PARAMETERS:
* dev_name - path to physical device in /dev filesystem
*
* RETURNS:
* AVFS_SUCCESSFUL if success, or -1 and corresponding errno else
*/
avfs_status_code
avfs_ide_part_table_initialize(char *dev_name);
#endif /* __AVFS_IDE_PART_TABLE_H__ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?