]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/pt-sgi.h
include: add missing license lines
[thirdparty/util-linux.git] / include / pt-sgi.h
CommitLineData
faeb1b64
KZ
1/*
2 * No copyright is claimed. This code is in the public domain; do with
3 * it what you wish.
4 */
7618b3be
KZ
5#ifndef UTIL_LINUX_PT_SGI_H
6#define UTIL_LINUX_PT_SGI_H
1c314b31
KZ
7
8#include <stdint.h>
9
1a9889ad
KZ
10#define SGI_LABEL_MAGIC 0x0be5a941
11
1c314b31 12#define SGI_MAXPARTITIONS 16
5105f75f 13#define SGI_MAXVOLUMES 15
1c314b31
KZ
14
15/* partition types */
16enum {
17 SGI_TYPE_VOLHDR = 0x00,
a78651d7
KZ
18 SGI_TYPE_TRKREPL = 0x01,
19 SGI_TYPE_SECREPL = 0x02,
1c314b31 20 SGI_TYPE_SWAP = 0x03,
a78651d7
KZ
21 SGI_TYPE_BSD = 0x04,
22 SGI_TYPE_SYSV = 0x05,
1c314b31
KZ
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
33struct 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;
9fc1f5d8 50 uint32_t flags; /* SGI_DEVPARAM_* controller flags */
1c314b31
KZ
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
9fc1f5d8
KZ
62enum {
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
1c314b31
KZ
73struct 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 */
5105f75f 85 } __attribute__((packed)) volume[SGI_MAXVOLUMES];
1c314b31
KZ
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
98static inline uint32_t sgi_pt_checksum(struct sgi_disklabel *label)
99{
1a56f15b 100 int count;
1c314b31 101 uint32_t sum = 0;
1a56f15b 102 unsigned char *ptr = (unsigned char *) label;
1c314b31 103
1a56f15b
KZ
104 count = sizeof(*label) / sizeof(uint32_t);
105 ptr += sizeof(uint32_t) * (count - 1);
1c314b31 106
1a56f15b
KZ
107 while (count--) {
108 uint32_t val;
109
110 memcpy(&val, ptr, sizeof(uint32_t));
111 sum -= be32_to_cpu(val);
112
113 ptr -= sizeof(uint32_t);
737532ef 114 }
1c314b31
KZ
115
116 return sum;
117}
118
7618b3be 119#endif /* UTIL_LINUX_PT_SGI_H */