]>
Commit | Line | Data |
---|---|---|
1c314b31 KZ |
1 | #ifndef UTIL_LINUX_PT_SUN_H |
2 | #define UTIL_LINUX_PT_SUN_H | |
3 | ||
4 | #include <stdint.h> | |
5 | ||
1a9889ad KZ |
6 | #define SGI_LABEL_MAGIC 0x0be5a941 |
7 | ||
1c314b31 | 8 | #define SGI_MAXPARTITIONS 16 |
5105f75f | 9 | #define SGI_MAXVOLUMES 15 |
1c314b31 KZ |
10 | |
11 | /* partition types */ | |
12 | enum { | |
13 | SGI_TYPE_VOLHDR = 0x00, | |
a78651d7 KZ |
14 | SGI_TYPE_TRKREPL = 0x01, |
15 | SGI_TYPE_SECREPL = 0x02, | |
1c314b31 | 16 | SGI_TYPE_SWAP = 0x03, |
a78651d7 KZ |
17 | SGI_TYPE_BSD = 0x04, |
18 | SGI_TYPE_SYSV = 0x05, | |
1c314b31 KZ |
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 | ||
29 | struct 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; | |
9fc1f5d8 | 46 | uint32_t flags; /* SGI_DEVPARAM_* controller flags */ |
1c314b31 KZ |
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 | ||
9fc1f5d8 KZ |
58 | enum { |
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 | ||
1c314b31 KZ |
69 | struct 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 */ | |
5105f75f | 81 | } __attribute__((packed)) volume[SGI_MAXVOLUMES]; |
1c314b31 KZ |
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 | ||
94 | static inline uint32_t sgi_pt_checksum(struct sgi_disklabel *label) | |
95 | { | |
1a56f15b | 96 | int count; |
1c314b31 | 97 | uint32_t sum = 0; |
1a56f15b | 98 | unsigned char *ptr = (unsigned char *) label; |
1c314b31 | 99 | |
1a56f15b KZ |
100 | count = sizeof(*label) / sizeof(uint32_t); |
101 | ptr += sizeof(uint32_t) * (count - 1); | |
1c314b31 | 102 | |
1a56f15b KZ |
103 | while (count--) { |
104 | uint32_t val; | |
105 | ||
106 | memcpy(&val, ptr, sizeof(uint32_t)); | |
107 | sum -= be32_to_cpu(val); | |
108 | ||
109 | ptr -= sizeof(uint32_t); | |
737532ef | 110 | } |
1c314b31 KZ |
111 | |
112 | return sum; | |
113 | } | |
114 | ||
115 | #endif /* UTIL_LINUX_PT_SUN_H */ |