blob: 547b37a872ae7a3c6592c3c5b89b716f24ecdb8c [file] [log] [blame]
bigbiff7b4c7a62015-01-01 19:44:14 -05001#ifndef UTIL_LINUX_PT_SUN_H
2#define UTIL_LINUX_PT_SUN_H
3
4#include <stdint.h>
5
6#define SGI_LABEL_MAGIC 0x0be5a941
7
8#define SGI_MAXPARTITIONS 16
9#define SGI_MAXVOLUMES 15
10
11/* partition types */
12enum {
13 SGI_TYPE_VOLHDR = 0x00,
14 SGI_TYPE_TRKREPL = 0x01,
15 SGI_TYPE_SECREPL = 0x02,
16 SGI_TYPE_SWAP = 0x03,
17 SGI_TYPE_BSD = 0x04,
18 SGI_TYPE_SYSV = 0x05,
19 SGI_TYPE_ENTIRE_DISK = 0x06,
20 SGI_TYPE_EFS = 0x07,
21 SGI_TYPE_LVOL = 0x08,
22 SGI_TYPE_RLVOL = 0x09,
23 SGI_TYPE_XFS = 0x0a,
24 SGI_TYPE_XFSLOG = 0x0b,
25 SGI_TYPE_XLV = 0x0c,
26 SGI_TYPE_XVM = 0x0d
27};
28
29struct sgi_device_parameter {
30 unsigned char skew;
31 unsigned char gap1;
32 unsigned char gap2;
33 unsigned char sparecyl;
34
35 uint16_t pcylcount;
36 uint16_t head_vol0;
37 uint16_t ntrks; /* tracks in cyl 0 or vol 0 */
38
39 unsigned char cmd_tag_queue_depth;
40 unsigned char unused0;
41
42 uint16_t unused1;
43 uint16_t nsect; /* sectors/tracks in cyl 0 or vol 0 */
44 uint16_t bytes;
45 uint16_t ilfact;
46 uint32_t flags; /* SGI_DEVPARAM_* controller flags */
47 uint32_t datarate;
48 uint32_t retries_on_error;
49 uint32_t ms_per_word;
50 uint16_t xylogics_gap1;
51 uint16_t xylogics_syncdelay;
52 uint16_t xylogics_readdelay;
53 uint16_t xylogics_gap2;
54 uint16_t xylogics_readgate;
55 uint16_t xylogics_writecont;
56} __attribute__((packed));
57
58enum {
59 SGI_DEVPARAM_SECTOR_SLIP = 0x01,
60 SGI_DEVPARAM_SECTOR_FWD = 0x02,
61 SGI_DEVPARAM_TRACK_FWD = 0x04,
62 SGI_DEVPARAM_TRACK_MULTIVOL = 0x08,
63 SGI_DEVPARAM_IGNORE_ERRORS = 0x10,
64 SGI_DEVPARAM_RESEEK = 0x20,
65 SGI_DEVPARAM_CMDTAGQ_ENABLE = 0x40
66};
67
68
69struct sgi_disklabel {
70 uint32_t magic; /* magic number */
71 uint16_t root_part_num; /* # root partition */
72 uint16_t swap_part_num; /* # swap partition */
73 unsigned char boot_file[16]; /* name of boot file */
74
75 struct sgi_device_parameter devparam; /* not used now */
76
77 struct sgi_volume {
78 unsigned char name[8]; /* name of volume */
79 uint32_t block_num; /* logical block number */
80 uint32_t num_bytes; /* how big, in bytes */
81 } __attribute__((packed)) volume[SGI_MAXVOLUMES];
82
83 struct sgi_partition {
84 uint32_t num_blocks; /* size in logical blocks */
85 uint32_t first_block; /* first logical block */
86 uint32_t type; /* type of this partition */
87 } __attribute__((packed)) partitions[SGI_MAXPARTITIONS];
88
89 /* checksum is the 32bit 2's complement sum of the disklabel */
90 uint32_t csum; /* disk label checksum */
91 uint32_t padding; /* padding */
92} __attribute__((packed));
93
94static inline uint32_t sgi_pt_checksum(struct sgi_disklabel *label)
95{
96 int i;
97 uint32_t *ptr = (uint32_t *) label;
98 uint32_t sum = 0;
99
100 i = sizeof(*label) / sizeof(*ptr);
101
102 while (i) {
103 i--;
104 sum -= be32_to_cpu(ptr[i]);
105 }
106
107 return sum;
108}
109
110#endif /* UTIL_LINUX_PT_SUN_H */