File indexing completed on 2025-05-11 08:24:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #ifndef _RTEMS_IDE_PART_TABLE_H
0039 #define _RTEMS_IDE_PART_TABLE_H
0040
0041 #include <rtems/chain.h>
0042 #include <stdio.h>
0043 #include <stdlib.h>
0044 #include <string.h>
0045 #include <errno.h>
0046 #include <sys/ioctl.h>
0047 #include <sys/types.h>
0048 #include <sys/endian.h>
0049 #include <sys/stat.h>
0050 #include <unistd.h>
0051 #include <fcntl.h>
0052 #include <rtems.h>
0053 #include <rtems/blkdev.h>
0054 #include <rtems/libio.h>
0055 #include <rtems/libio_.h>
0056 #include <rtems/bdbuf.h>
0057 #include <rtems/seterr.h>
0058
0059
0060 #define RTEMS_IDE_SECTOR_BITS 9
0061 #define RTEMS_IDE_SECTOR_SIZE 512
0062 #define RTEMS_IDE_PARTITION_DESCRIPTOR_SIZE 16
0063 #define RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER 63
0064 #define RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER 4
0065 #define RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX 16
0066
0067 #define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA1 0x55
0068 #define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA2 0xaa
0069 #define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_OFFSET 0x1fe
0070 #define RTEMS_IDE_PARTITION_TABLE_OFFSET 0x1be
0071 #define RTEMS_IDE_PARTITION_TABLE_SIZE (4 * 16)
0072 #define RTEMS_IDE_PARTITION_BOOTABLE_OFFSET 0
0073 #define RTEMS_IDE_PARTITION_SYS_TYPE_OFFSET 4
0074 #define RTEMS_IDE_PARTITION_START_OFFSET 8
0075 #define RTEMS_IDE_PARTITION_SIZE_OFFSET 12
0076
0077
0078
0079
0080 #define LE_TO_CPU_U16(v) le16toh(v)
0081 #define LE_TO_CPU_U32(v) le32toh(v)
0082 #define CPU_TO_LE_U16(v) htole16(v)
0083 #define CPU_TO_LE_U32(v) htole32(v)
0084
0085
0086
0087
0088
0089 typedef struct rtems_sector_data_s
0090 {
0091 uint32_t sector_num;
0092 uint8_t data[RTEMS_ZERO_LENGTH_ARRAY];
0093 } rtems_sector_data_t;
0094
0095
0096
0097
0098
0099
0100
0101
0102 enum {
0103 EMPTY_PARTITION = 0x00,
0104 DOS_FAT12_PARTITION = 0x01,
0105 DOS_FAT16_PARTITION = 0x04,
0106 EXTENDED_PARTITION = 0x05,
0107 DOS_P32MB_PARTITION = 0x06,
0108 FAT32_PARTITION = 0x0B,
0109 FAT32_LBA_PARTITION = 0x0C,
0110 FAT16_LBA_PARTITION = 0x0E,
0111 DM6_PARTITION = 0x54,
0112 EZD_PARTITION = 0x55,
0113 DM6_AUX1PARTITION = 0x51,
0114 DM6_AUX3PARTITION = 0x53,
0115 LINUX_SWAP = 0x82,
0116 LINUX_NATIVE = 0x83,
0117 LINUX_EXTENDED = 0x85
0118 };
0119
0120
0121
0122 struct rtems_disk_desc_s;
0123
0124
0125
0126
0127
0128 typedef struct rtems_part_desc_s {
0129 uint8_t bootable;
0130 uint8_t sys_type;
0131 uint8_t log_id;
0132 uint32_t start;
0133
0134 uint32_t size;
0135 uint32_t end;
0136 struct rtems_disk_desc_s *disk_desc;
0137
0138 struct rtems_part_desc_s *ext_part;
0139
0140
0141
0142 struct rtems_part_desc_s *sub_part[RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER];
0143 } rtems_part_desc_t;
0144
0145
0146
0147 typedef struct rtems_disk_desc_s {
0148
0149 char dev_name[RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX];
0150
0151 uint32_t sector_size;
0152 uint32_t sector_bits;
0153 uint32_t lba_size;
0154 int last_log_id;
0155
0156
0157 rtems_part_desc_t *partitions[RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER];
0158 } rtems_disk_desc_t;
0159
0160 #ifdef __cplusplus
0161 extern "C" {
0162 #endif
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 void rtems_ide_part_table_free(
0178 rtems_disk_desc_t *disk_desc
0179 ) RTEMS_DEPRECATED;
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197 rtems_status_code rtems_ide_part_table_get(
0198 const char *dev_name,
0199 rtems_disk_desc_t *disk_desc
0200 ) RTEMS_DEPRECATED;
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216 rtems_status_code rtems_ide_part_table_initialize(
0217 const char *dev_name
0218 ) RTEMS_DEPRECATED;
0219
0220 #ifdef __cplusplus
0221 }
0222 #endif
0223
0224 #endif