source: rtems/cpukit/libblock/include/rtems/ide_part_table.h @ 3899a537

4.104.114.95
Last change on this file since 3899a537 was 3899a537, checked in by Chris Johns <chrisj@…>, on 07/29/08 at 02:21:15

2008-07-29 Chris Johns <chrisj@…>

  • libblock/Makefile.am: Removed src/show_bdbuf.c.
  • libblock/src/show_bdbuf.c: Removed.
  • libblock/include/rtems/bdbuf.h, cpukit/libblock/src/bdbuf.c: Rewritten the bdbuf code. Remove pre-emption disable, score access, fixed many bugs and increased performance.
  • libblock/include/rtems/blkdev.h: Added RTEMS_BLKDEV_CAPABILITIES block device request. Cleaned up comments. Added block and user fields to the sg buffer request. Move to rtems_* namespace.
  • libblock/include/rtems/diskdevs.h, cpukit/libblock/src/diskdevs.c: Move to rtems_* namespace. Add a capabilities field for drivers. Change rtems_disk_lookup to rtems_disk_obtain to match the release call. You do not lookup and release a disk, you obtain and release a disk.
  • libblock/include/rtems/ide_part_table.h, libblock/include/rtems/ramdisk.h, libblock/src/ide_part_table.c: Move to rtems_* namespace.
  • libblock/include/rtems/nvdisk.h: Formatting change.
  • libblock/src/blkdev.c: Move to rtems_* namespace. Change rtems_disk_lookup to rtems_disk_obtain
  • libblock/src/flashdisk.c: Move to rtems_* namespace. Use the new support for the block number in the scatter/grather request struct. This allows non-continuous buffer requests for those drivers that can support increasing performance.
  • libblock/src/nvdisk.c: Move to rtems_* namespace. Removed warnings. Added better error checking. Fixed some comments.
  • libblock/src/ramdisk.c: Move to rtems_* namespace. Added some trace functions to help debugging upper layers. Use the new support for the block number in the scatter/grather request struct. This allows non-continuous buffer requests for those drivers that can support increasing performance.
  • libfs/src/dosfs/fat.c, libfs/src/dosfs/fat.h: Use new chains API. Removed temporary hack and changed set_errno_and_return_minus_one to rtems_set_errno_and_return_minus_one. Move fat_buf_access from header and stopped it being inlined. Updated to libblock changes.
  • libfs/src/dosfs/fat_fat_operations.c, libfs/src/dosfs/fat_file.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_free.c, libfs/src/dosfs/msdos_initsupp.c, libfs/src/dosfs/msdos_misc.c, libfs/src/dosfs/msdos_mknod.c: Use new chains API. Removed temporary hack and changed set_errno_and_return_minus_one to rtems_set_errno_and_return_minus_one. Updated to libblock changes.
  • libmisc/Makefile.am: Add new ls and rm command files.
  • libmisc/shell/cmp-ls.c, libmisc/shell/extern-ls.h, libmisc/shell/filemode.c, libmisc/shell/print-ls.c, libmisc/shell/pwcache.c, libmisc/shell/utils-ls.c, libmisc/shell/vis.c, shell/vis.h: New.
  • libmisc/shell/extern-cp.h, libmisc/shell/main_cp.c, libmisc/shell/utils-cp.c: Fixed the usage call bug.
  • libmisc/shell/main_blksync.c: Updated to the new block IO ioctl command.
  • libmisc/shell/main_ls.c, libmisc/shell/main_rm.c: Updated to BSD commands with more features.
  • score/src/coremutex.c: Fix the strick order mutex code.
  • libmisc/shell/shell.c: Change shell tasks mode to be timeslice and no ASR.
  • sapi/include/confdefs.h: Change ata_driver_task_priority to rtems_ata_driver_task_priority. Add the new BD buf cache parameters with defaults.
  • score/src/interr.c: Do not return if the CPU halt call returns.
  • Property mode set to 100644
File size: 5.8 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_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 */
167void
168rtems_ide_part_table_free(rtems_disk_desc_t *disk_desc);
169
170
171/*
172 * rtems_ide_part_table_get --
173 *      reads partition table structure from the device
174 *      and creates disk description structure
175 *
176 * PARAMETERS:
177 *      dev_name  - path to physical device in /dev filesystem
178 *      disk_desc - returned disc description structure
179 *
180 * RETURNS:
181 *      RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else
182 */
183rtems_status_code
184rtems_ide_part_table_get(const char *dev_name, rtems_disk_desc_t *disk_desc);
185
186
187/*
188 * rtems_ide_part_table_initialize --
189 *      initializes logical devices on the physical IDE drive
190 *
191 * PARAMETERS:
192 *      dev_name - path to physical device in /dev filesystem
193 *
194 * RETURNS:
195 *      RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else
196 */
197rtems_status_code
198rtems_ide_part_table_initialize(char *dev_name);
199
200#ifdef __cplusplus
201}
202#endif
203
204#endif /* _RTEMS_IDE_PART_TABLE_H */
Note: See TracBrowser for help on using the repository browser.