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