Merge branch 'makefile' into haiku
[grub2/phcoder.git] / include / grub / raid.h
blob595ced1d6ac9e854e1102cb8b185ec6d03d1514e
1 /* raid.h - On disk structures for RAID. */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef GRUB_RAID_H
21 #define GRUB_RAID_H 1
23 #include <grub/types.h>
25 #define GRUB_RAID_MAX_DEVICES 32
27 #define GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC 0
28 #define GRUB_RAID_LAYOUT_RIGHT_ASYMMETRIC 1
29 #define GRUB_RAID_LAYOUT_LEFT_SYMMETRIC 2
30 #define GRUB_RAID_LAYOUT_RIGHT_SYMMETRIC 3
32 #define GRUB_RAID_LAYOUT_RIGHT_MASK 1
33 #define GRUB_RAID_LAYOUT_SYMMETRIC_MASK 2
35 struct grub_raid_array
37 int number; /* The device number, taken from md_minor so we
38 are consistent with the device name in
39 Linux. */
40 int level; /* RAID levels, only 0, 1 or 5 at the moment. */
41 int layout; /* Layout for RAID 5/6. */
42 unsigned int total_devs; /* Total number of devices in the array. */
43 grub_size_t chunk_size; /* The size of a chunk, in 512 byte sectors. */
44 grub_uint64_t disk_size; /* Size of an individual disk, in 512 byte
45 sectors. */
46 int index; /* Index of current device. */
47 int uuid_len; /* The length of uuid. */
48 char *uuid; /* The UUID of the device. */
50 /* The following field is setup by the caller. */
51 char *name; /* That will be "md<number>". */
52 unsigned int nr_devs; /* The number of devices we've found so far. */
53 grub_disk_t device[GRUB_RAID_MAX_DEVICES]; /* Array of total_devs devices. */
54 struct grub_raid_array *next;
57 struct grub_raid
59 const char *name;
61 grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array);
63 struct grub_raid *next;
65 typedef struct grub_raid *grub_raid_t;
67 void grub_raid_register (grub_raid_t raid);
68 void grub_raid_unregister (grub_raid_t raid);
70 void grub_raid_rescan (void);
71 void grub_raid_block_xor (char *buf1, const char *buf2, int size);
73 typedef grub_err_t (*grub_raid5_recover_func_t) (struct grub_raid_array *array,
74 int disknr, char *buf,
75 grub_disk_addr_t sector,
76 int size);
78 typedef grub_err_t (*grub_raid6_recover_func_t) (struct grub_raid_array *array,
79 int disknr, int p, char *buf,
80 grub_disk_addr_t sector,
81 int size);
83 extern grub_raid5_recover_func_t grub_raid5_recover_func;
84 extern grub_raid6_recover_func_t grub_raid6_recover_func;
86 #endif /* ! GRUB_RAID_H */