source: rtems/cpukit/libblock/include/rtems/ide_part_table.h @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 6.2 KB
Line 
1/**
2 * @file rtems/ide_part_table.h
3 *
4 * Support for "MS-DOS-style" partition tables
5 */
6
7/*
8 * Copyright (C) 2002 OKTET Ltd., St.-Petersburg, Russia
9 *
10 * Author: Konstantin Abramenko <Konstantin.Abramenko@oktet.ru>
11 *         Alexander Kukuta <Alexander.Kukuta@oktet.ru>
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *****************************************************************************/
18
19#ifndef _RTEMS_IDE_PART_TABLE_H
20#define _RTEMS_IDE_PART_TABLE_H
21
22#include <rtems/chain.h>
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#include <errno.h>
27#include <sys/ioctl.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30#include <unistd.h>
31#include <fcntl.h>
32#include <rtems.h>
33#include <rtems/blkdev.h>
34#include <rtems/libio.h>
35#include <rtems/libio_.h>
36#include <rtems/bdbuf.h>
37#include <rtems/seterr.h>
38
39/* Minor base number for all logical devices */
40#define RTEMS_IDE_SECTOR_BITS                             9
41#define RTEMS_IDE_SECTOR_SIZE                             512
42#define RTEMS_IDE_PARTITION_DESCRIPTOR_SIZE               16
43#define RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER          63
44#define RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER      4
45#define RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX           16
46
47#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA1         0x55
48#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA2         0xaa
49#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_OFFSET        0x1fe
50#define RTEMS_IDE_PARTITION_TABLE_OFFSET                  0x1be
51#define RTEMS_IDE_PARTITION_TABLE_SIZE                    (4 * 16)
52#define RTEMS_IDE_PARTITION_BOOTABLE_OFFSET               0
53#define RTEMS_IDE_PARTITION_SYS_TYPE_OFFSET               4
54#define RTEMS_IDE_PARTITION_START_OFFSET                  8
55#define RTEMS_IDE_PARTITION_SIZE_OFFSET                   12
56
57/*
58 * Conversion from and to little-endian byte order. (no-op on i386/i486)
59 */
60
61#if (CPU_BIG_ENDIAN == TRUE)
62#   define LE_TO_CPU_U16(v) CPU_swap_u16(v)
63#   define LE_TO_CPU_U32(v) CPU_swap_u32(v)
64#   define CPU_TO_LE_U16(v) CPU_swap_u16(v)
65#   define CPU_TO_LE_U32(v) CPU_swap_u32(v)
66#else
67#   define LE_TO_CPU_U16(v) (v)
68#   define LE_TO_CPU_U32(v) (v)
69#   define CPU_TO_LE_U16(v) (v)
70#   define CPU_TO_LE_U32(v) (v)
71#endif
72
73
74/*
75 * sector_data_t --
76 *      corresponds to the sector on the device
77 */
78typedef struct rtems_sector_data_s
79{
80    uint32_t   sector_num; /* sector number on the device */
81    uint8_t    data[0]; /* raw sector data */
82} rtems_sector_data_t;
83
84
85/*
86 * Enum partition types
87 * see list at http://ata-atapi.com/hiwtab.htm
88 *
89 * @todo Should these have RTEMS before them.
90 */
91enum {
92    EMPTY_PARTITION     = 0x00,
93    DOS_FAT12_PARTITION = 0x01,
94    DOS_FAT16_PARTITION = 0x04,
95    EXTENDED_PARTITION  = 0x05,
96    DOS_P32MB_PARTITION = 0x06,
97    FAT32_PARTITION     = 0x0B,
98    FAT32_LBA_PARTITION = 0x0C,
99    FAT16_LBA_PARTITION = 0x0E,
100    DM6_PARTITION       = 0x54,
101    EZD_PARTITION       = 0x55,
102    DM6_AUX1PARTITION   = 0x51,
103    DM6_AUX3PARTITION   = 0x53,
104    LINUX_SWAP          = 0x82,
105    LINUX_NATIVE        = 0x83,
106    LINUX_EXTENDED      = 0x85
107};
108
109
110/* Forward declaration */
111struct rtems_disk_desc_s;
112
113/*
114 * part_desc_t --
115 *      contains all neccessary information about partition
116 */
117typedef struct rtems_part_desc_s {
118    uint8_t             bootable; /* is the partition active */
119    uint8_t             sys_type; /* type of partition */
120    uint8_t             log_id; /* logical number of partition */
121    uint32_t            start; /* first partition sector, in absolute
122                                * numeration */
123    uint32_t            size; /* size in sectors */
124    uint32_t            end; /* last partition sector, end = start + size - 1 */
125    struct rtems_disk_desc_s *disk_desc; /* descriptor of disk, partition
126                                          * contains in */
127    struct rtems_part_desc_s *ext_part; /* extended partition containing this
128                                         * one */
129
130    /* partitions, containing in this one */
131    struct rtems_part_desc_s *sub_part[RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER];
132} rtems_part_desc_t;
133
134
135
136typedef struct rtems_disk_desc_s {
137    dev_t        dev; /* device number */
138
139    /* device name in /dev filesystem */
140    char         dev_name[RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX];
141
142    uint32_t     sector_size; /* size of sector */
143    uint32_t     sector_bits; /* the base-2 logarithm of sector_size */
144    uint32_t     lba_size; /* total amount of sectors in lba address mode */
145    int          last_log_id; /* used for logical disks enumerating */
146
147    /* primary partition descriptors */
148    rtems_part_desc_t *partitions[RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER];
149} rtems_disk_desc_t;
150
151#ifdef __cplusplus
152extern "C" {
153#endif
154
155/*
156 * rtems_ide_part_table_free --
157 *      frees disk descriptor structure
158 *
159 * PARAMETERS:
160 *      disk_desc - disc descriptor structure to free
161 *
162 * RETURNS:
163 *      N/A
164 */
165/**
166 * @deprecated Use the @ref rtems_bdpart "block device partition module" instead.
167 */
168void rtems_ide_part_table_free(
169  rtems_disk_desc_t *disk_desc
170) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
171
172
173/*
174 * rtems_ide_part_table_get --
175 *      reads partition table structure from the device
176 *      and creates disk description structure
177 *
178 * PARAMETERS:
179 *      dev_name  - path to physical device in /dev filesystem
180 *      disk_desc - returned disc description structure
181 *
182 * RETURNS:
183 *      RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else
184 */
185/**
186 * @deprecated Use the @ref rtems_bdpart "block device partition module" instead.
187 */
188rtems_status_code rtems_ide_part_table_get(
189  const char *dev_name,
190  rtems_disk_desc_t *disk_desc
191) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
192
193
194/*
195 * rtems_ide_part_table_initialize --
196 *      initializes logical devices on the physical IDE drive
197 *
198 * PARAMETERS:
199 *      dev_name - path to physical device in /dev filesystem
200 *
201 * RETURNS:
202 *      RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else
203 */
204/**
205 * @deprecated Use the @ref rtems_bdpart "block device partition module" instead.
206 */
207rtems_status_code rtems_ide_part_table_initialize(
208  const char *dev_name
209) RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
210
211#ifdef __cplusplus
212}
213#endif
214
215#endif /* _RTEMS_IDE_PART_TABLE_H */
Note: See TracBrowser for help on using the repository browser.