source: rtems/cpukit/libblock/include/rtems/ide_part_table.h @ 164adec

4.104.11
Last change on this file since 164adec was 164adec, checked in by Chris Johns <chrisj@…>, on Apr 29, 2009 at 8:33:35 AM

2009-04-29 Chris Johns <chrisj@…>

  • libcsupport/include/rtems/libio.h: Add rtems_off64_t for internal use. Update the internal off_t to the 64bit offset.
  • libnetworking/lib/ftpfs.c, libnetworking/lib/tftpDriver.c, libfs/src/nfsclient/src/nfs.c, libfs/src/imfs/imfs_fifo.c, libfs/src/imfs/memfile.c, libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs.h, libfs/src/imfs/deviceio.c: Change off_t to rtems_off64_t.
  • libmisc/shell/main_msdosfmt.c: Add an info level so the format code can tell the user what is happening. Add more options to control the format configuration.
  • libfs/src/dosfs/msdos_format.c: Add a print function to display the format progress and print statements. Select a better default cluster size depending on the size of the disk. This lowers the size of the FAT on large disks. Read and maintain the MRB partition information.
  • libfs/src/dosfs/dosfs.h, libfs/src/dosfs/fat.h, libfs/src/dosfs/fat_file.c, libfs/src/dosfs/fat_file.h, libfs/src/dosfs/msdos.h, libfs/src/dosfs/msdos_conv.c, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_file.c, libfs/src/dosfs/msdos_handlers_dir.c, libfs/src/dosfs/msdos_handlers_file.c, libfs/src/dosfs/msdos_init.c, libfs/src/dosfs/msdos_initsupp.c, libfs/src/dosfs/msdos_misc.c, libfs/src/dosfs/msdos_mknod.c: Add long file name support. Change off_t to rtems_off64_t.
  • libblock/include/rtems/ide_part_table.h: Add MRB partition table size.
  • Property mode set to 100644
File size: 5.9 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 <assert.h>
25#include <rtems/chain.h>
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29#include <errno.h>
30#include <sys/ioctl.h>
31#include <sys/types.h>
32#include <sys/stat.h>
33#include <unistd.h>
34#include <fcntl.h>
35#include <rtems.h>
36#include <rtems/blkdev.h>
37#include <rtems/libio.h>
38#include <rtems/libio_.h>
39#include <rtems/bdbuf.h>
40#include <rtems/seterr.h>
41
42/* Minor base number for all logical devices */
43#define RTEMS_IDE_SECTOR_BITS                             9
44#define RTEMS_IDE_SECTOR_SIZE                             512
45#define RTEMS_IDE_PARTITION_DESCRIPTOR_SIZE               16
46#define RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER          63
47#define RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER      4
48#define RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX           16
49
50#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA1         0x55
51#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA2         0xaa
52#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_OFFSET        0x1fe
53#define RTEMS_IDE_PARTITION_TABLE_OFFSET                  0x1be
54#define RTEMS_IDE_PARTITION_TABLE_SIZE                    (4 * 16)
55#define RTEMS_IDE_PARTITION_BOOTABLE_OFFSET               0
56#define RTEMS_IDE_PARTITION_SYS_TYPE_OFFSET               4
57#define RTEMS_IDE_PARTITION_START_OFFSET                  8
58#define RTEMS_IDE_PARTITION_SIZE_OFFSET                   12
59
60/*
61 * Conversion from and to little-endian byte order. (no-op on i386/i486)
62 */
63
64#if (CPU_BIG_ENDIAN == TRUE)
65#   define LE_TO_CPU_U16(v) CPU_swap_u16(v)
66#   define LE_TO_CPU_U32(v) CPU_swap_u32(v)
67#   define CPU_TO_LE_U16(v) CPU_swap_u16(v)
68#   define CPU_TO_LE_U32(v) CPU_swap_u32(v)
69#else
70#   define LE_TO_CPU_U16(v) (v)
71#   define LE_TO_CPU_U32(v) (v)
72#   define CPU_TO_LE_U16(v) (v)
73#   define CPU_TO_LE_U32(v) (v)
74#endif
75
76
77/*
78 * sector_data_t --
79 *      corresponds to the sector on the device
80 */
81typedef struct rtems_sector_data_s
82{
83    uint32_t   sector_num; /* sector number on the device */
84    uint8_t    data[0]; /* raw sector data */
85} rtems_sector_data_t;
86
87
88/*
89 * Enum partition types
90 * see list at http://ata-atapi.com/hiwtab.htm
91 *
92 * @todo Should these have RTEMS before them.
93 */
94enum {
95    EMPTY_PARTITION     = 0x00,
96    DOS_FAT12_PARTITION = 0x01,
97    DOS_FAT16_PARTITION = 0x04,
98    EXTENDED_PARTITION  = 0x05,
99    DOS_P32MB_PARTITION = 0x06,
100    FAT32_PARTITION     = 0x0B,
101    FAT32_LBA_PARTITION = 0x0C,
102    FAT16_LBA_PARTITION = 0x0E,
103    DM6_PARTITION       = 0x54,
104    EZD_PARTITION       = 0x55,
105    DM6_AUX1PARTITION   = 0x51,
106    DM6_AUX3PARTITION   = 0x53,
107    LINUX_SWAP          = 0x82,
108    LINUX_NATIVE        = 0x83,
109    LINUX_EXTENDED      = 0x85
110};
111
112
113/* Forward declaration */
114struct rtems_disk_desc_s;
115
116/*
117 * part_desc_t --
118 *      contains all neccessary information about partition
119 */
120typedef struct rtems_part_desc_s {
121    uint8_t             bootable; /* is the partition active */
122    uint8_t             sys_type; /* type of partition */
123    uint8_t             log_id; /* logical number of partition */
124    uint32_t            start; /* first partition sector, in absolute
125                                * numeration */
126    uint32_t            size; /* size in sectors */
127    uint32_t            end; /* last partition sector, end = start + size - 1 */
128    struct rtems_disk_desc_s *disk_desc; /* descriptor of disk, partition
129                                          * contains in */
130    struct rtems_part_desc_s *ext_part; /* extended partition containing this
131                                         * one */
132
133    /* partitions, containing in this one */
134    struct rtems_part_desc_s *sub_part[RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER];
135} rtems_part_desc_t;
136
137
138
139typedef struct rtems_disk_desc_s {
140    dev_t        dev; /* device number */
141
142    /* device name in /dev filesystem */
143    char         dev_name[RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX];
144
145    uint32_t     sector_size; /* size of sector */
146    uint32_t     sector_bits; /* the base-2 logarithm of sector_size */
147    uint32_t     lba_size; /* total amount of sectors in lba address mode */
148    int          last_log_id; /* used for logical disks enumerating */
149
150    /* primary partition descriptors */
151    rtems_part_desc_t *partitions[RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER];
152} rtems_disk_desc_t;
153
154#ifdef __cplusplus
155extern "C" {
156#endif
157
158/*
159 * rtems_ide_part_table_free --
160 *      frees disk descriptor structure
161 *
162 * PARAMETERS:
163 *      disk_desc - disc descriptor structure to free
164 *
165 * RETURNS:
166 *      N/A
167 */
168void
169rtems_ide_part_table_free(rtems_disk_desc_t *disk_desc);
170
171
172/*
173 * rtems_ide_part_table_get --
174 *      reads partition table structure from the device
175 *      and creates disk description structure
176 *
177 * PARAMETERS:
178 *      dev_name  - path to physical device in /dev filesystem
179 *      disk_desc - returned disc description structure
180 *
181 * RETURNS:
182 *      RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else
183 */
184rtems_status_code
185rtems_ide_part_table_get(const char *dev_name, rtems_disk_desc_t *disk_desc);
186
187
188/*
189 * rtems_ide_part_table_initialize --
190 *      initializes logical devices on the physical IDE drive
191 *
192 * PARAMETERS:
193 *      dev_name - path to physical device in /dev filesystem
194 *
195 * RETURNS:
196 *      RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else
197 */
198rtems_status_code
199rtems_ide_part_table_initialize(char *dev_name);
200
201#ifdef __cplusplus
202}
203#endif
204
205#endif /* _RTEMS_IDE_PART_TABLE_H */
Note: See TracBrowser for help on using the repository browser.