source: rtems/cpukit/libblock/include/rtems/ide_part_table.h @ 71c012af

4.115
Last change on this file since 71c012af was 71c012af, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 4, 2010 at 2:53:47 PM

2010-07-04 Joel Sherrill <joel.sherrill@…>

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