source: rtems/cpukit/libblock/include/rtems/ide_part_table.h @ ef142d7

4.104.114.84.95
Last change on this file since ef142d7 was ef142d7, checked in by Joel Sherrill <joel.sherrill@…>, on 10/28/02 at 14:00:43

2002-10-28 Eugeny S. Mints <Eugeny.Mints@…>

  • Added ATA support.
  • include/rtems/blkdev.h: Added last IO status.
  • include/rtems/ata.h, include/rtems/ata_internal.h, include/rtems/ide_part_table.h, src/ata.c, src/ide_part_table.c: New files.
  • Property mode set to 100644
File size: 5.4 KB
Line 
1/*****************************************************************************
2 *
3 * ide_part_table.h
4 *
5 * The header file for library supporting "MS-DOS-style" partition table
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.OARcorp.com/rtems/license.html.
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 <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_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 sector_data_s
81{
82    unsigned32 sector_num; /* sector number on the device */
83    unsigned8  data[0]; /* raw sector data */
84} sector_data_t;
85
86
87/*
88 * Enum partition types
89 */
90enum {
91    EMPTY_PARTITION     = 0,
92    EXTENDED_PARTITION  = 5,
93    DM6_PARTITION       = 0x54,
94    EZD_PARTITION       = 0x55,
95    DM6_AUX1PARTITION   = 0x51,
96    DM6_AUX3PARTITION   = 0x53,
97    LINUX_SWAP          = 0x82,
98    LINUX_NATIVE        = 0x83,
99    LINUX_EXTENDED      = 0x85
100};
101
102
103/* Forward declaration */
104struct disk_desc_s;
105
106/*
107 * part_desc_t --
108 *      contains all neccessary information about partition
109 */
110typedef struct part_desc_s {
111    unsigned8           bootable; /* is the partition active */
112    unsigned8           sys_type; /* type of partition */
113    unsigned8           log_id; /* logical number of partition */
114    unsigned32          start; /* first partition sector, in absolute numeration */
115    unsigned32          size; /* size in sectors */
116    unsigned32          end; /* last partition sector, end = start + size - 1 */
117    struct disk_desc_s *disk_desc; /* descriptor of disk, partition contains in */
118    struct part_desc_s *ext_part; /* extended partition containing this one */
119
120    /* partitions, containing in this one */
121    struct part_desc_s *sub_part[RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER];
122} part_desc_t;
123
124
125
126typedef struct disk_desc_s {
127    dev_t        dev; /* device number */
128
129    /* device name in /dev filesystem */
130    unsigned8    dev_name[RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX];
131
132    unsigned32   sector_size; /* size of sector */
133    unsigned32   sector_bits; /* the base-2 logarithm of sector_size */
134    unsigned32   lba_size; /* total amount of sectors in lba address mode */
135    int          last_log_id; /* used for logical disks enumerating */
136
137    /* primary partition descriptors */
138    part_desc_t *partitions[RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER];
139} disk_desc_t;
140
141
142/*
143 * rtems_ide_part_table_free --
144 *      frees disk descriptor structure
145 *
146 * PARAMETERS:
147 *      disk_desc - disc descriptor structure to free
148 *
149 * RETURNS:
150 *      N/A
151 */
152void
153rtems_ide_part_table_free(disk_desc_t *disk_desc);
154
155
156/*
157 * rtems_ide_part_table_get --
158 *      reads partition table structure from the device
159 *      and creates disk description structure
160 *
161 * PARAMETERS:
162 *      dev_name  - path to physical device in /dev filesystem
163 *      disk_desc - returned disc description structure
164 *
165 * RETURNS:
166 *      RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else
167 */
168rtems_status_code
169rtems_ide_part_table_get(const char *dev_name, disk_desc_t *disk_desc);
170
171
172/*
173 * rtems_ide_part_table_initialize --
174 *      initializes logical devices on the physical IDE drive
175 *
176 * PARAMETERS:
177 *      dev_name - path to physical device in /dev filesystem
178 *
179 * RETURNS:
180 *      RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else
181 */
182rtems_status_code
183rtems_ide_part_table_initialize(char *dev_name);
184
185
186#endif /* __RTEMS_IDE_PART_TABLE_H__ */
Note: See TracBrowser for help on using the repository browser.