1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include "volume_id_internal.h"
28
29struct hpt37x_meta {
30 uint8_t filler1[32];
31 uint32_t magic;
32} PACKED;
33
34struct hpt45x_meta {
35 uint32_t magic;
36} PACKED;
37
38#define HPT37X_CONFIG_OFF 0x1200
39#define HPT37X_MAGIC_OK 0x5a7816f0
40#define HPT37X_MAGIC_BAD 0x5a7816fd
41
42#define HPT45X_MAGIC_OK 0x5a7816f3
43#define HPT45X_MAGIC_BAD 0x5a7816fd
44
45
46int FAST_FUNC volume_id_probe_highpoint_37x_raid(struct volume_id *id, uint64_t off)
47{
48 struct hpt37x_meta *hpt;
49 uint32_t magic;
50
51 dbg("probing at offset 0x%llx", (unsigned long long) off);
52
53 hpt = volume_id_get_buffer(id, off + HPT37X_CONFIG_OFF, 0x200);
54 if (hpt == NULL)
55 return -1;
56
57 magic = hpt->magic;
58 if (magic != cpu_to_le32(HPT37X_MAGIC_OK) && magic != cpu_to_le32(HPT37X_MAGIC_BAD))
59 return -1;
60
61
62
63
64 return 0;
65}
66
67int FAST_FUNC volume_id_probe_highpoint_45x_raid(struct volume_id *id, uint64_t off, uint64_t size)
68{
69 struct hpt45x_meta *hpt;
70 uint64_t meta_off;
71 uint32_t magic;
72
73 dbg("probing at offset 0x%llx, size 0x%llx",
74 (unsigned long long) off, (unsigned long long) size);
75
76 if (size < 0x10000)
77 return -1;
78
79 meta_off = ((size / 0x200)-11) * 0x200;
80 hpt = volume_id_get_buffer(id, off + meta_off, 0x200);
81 if (hpt == NULL)
82 return -1;
83
84 magic = hpt->magic;
85 if (magic != cpu_to_le32(HPT45X_MAGIC_OK) && magic != cpu_to_le32(HPT45X_MAGIC_BAD))
86 return -1;
87
88
89
90
91 return 0;
92}
93