2N/A/* raid.h - On disk structures for RAID. */
2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2006,2007,2008,2010 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#ifndef GRUB_RAID_H
2N/A#define GRUB_RAID_H 1
2N/A
2N/A#include <grub/types.h>
2N/A
2N/A#define GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC 0
2N/A#define GRUB_RAID_LAYOUT_RIGHT_ASYMMETRIC 1
2N/A#define GRUB_RAID_LAYOUT_LEFT_SYMMETRIC 2
2N/A#define GRUB_RAID_LAYOUT_RIGHT_SYMMETRIC 3
2N/A
2N/A#define GRUB_RAID_LAYOUT_RIGHT_MASK 1
2N/A#define GRUB_RAID_LAYOUT_SYMMETRIC_MASK 2
2N/A
2N/Astruct grub_raid_member
2N/A{
2N/A grub_disk_t device; /* Array of total_devs devices. */
2N/A grub_disk_addr_t start_sector;
2N/A /* Start of each device, in 512 byte sectors. */
2N/A};
2N/A
2N/Astruct grub_raid_array
2N/A{
2N/A int number; /* The device number, taken from md_minor so we
2N/A are consistent with the device name in
2N/A Linux. */
2N/A int became_readable_at;
2N/A int level; /* RAID levels, only 0, 1 or 5 at the moment. */
2N/A int layout; /* Layout for RAID 5/6. */
2N/A unsigned int total_devs; /* Total number of devices in the array. */
2N/A grub_size_t chunk_size; /* The size of a chunk, in 512 byte sectors. */
2N/A grub_uint64_t disk_size; /* Size of an individual disk, in 512 byte
2N/A sectors. */
2N/A unsigned int index; /* Index of current device. */
2N/A int uuid_len; /* The length of uuid. */
2N/A char *uuid; /* The UUID of the device. */
2N/A
2N/A /* The following field is setup by the caller. */
2N/A char *name; /* That will be "md<number>". */
2N/A unsigned int nr_devs; /* The number of devices we've found so far. */
2N/A unsigned int allocated_devs;
2N/A struct grub_raid_member *members;
2N/A struct grub_raid_array *next;
2N/A
2N/A#ifdef GRUB_UTIL
2N/A struct grub_raid *driver;
2N/A#endif
2N/A};
2N/A
2N/Astruct grub_raid
2N/A{
2N/A const char *name;
2N/A
2N/A grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array,
2N/A grub_disk_addr_t *start_sector);
2N/A
2N/A struct grub_raid *next;
2N/A};
2N/Atypedef struct grub_raid *grub_raid_t;
2N/A
2N/Avoid grub_raid_register (grub_raid_t raid);
2N/Avoid grub_raid_unregister (grub_raid_t raid);
2N/A
2N/Avoid grub_raid_block_xor (char *buf1, const char *buf2, int size);
2N/A
2N/Atypedef grub_err_t (*grub_raid5_recover_func_t) (struct grub_raid_array *array,
2N/A int disknr, char *buf,
2N/A grub_disk_addr_t sector,
2N/A int size);
2N/A
2N/Atypedef grub_err_t (*grub_raid6_recover_func_t) (struct grub_raid_array *array,
2N/A int disknr, int p, char *buf,
2N/A grub_disk_addr_t sector,
2N/A int size);
2N/A
2N/Aextern grub_raid5_recover_func_t grub_raid5_recover_func;
2N/Aextern grub_raid6_recover_func_t grub_raid6_recover_func;
2N/A
2N/A#endif /* ! GRUB_RAID_H */