2
* SNIA DDF1 v1.0 metadata format handler.
4
* Copyright (C) 2005-2006 IBM, All rights reserved.
5
* Written by Darrick Wong <djwong@us.ibm.com>
7
* Copyright (C) 2006 Heinz Mauelshagen, Red Hat GmbH
10
* See file LICENSE at the top of this source tree for license information.
15
#define FORMAT_HANDLER
19
#define DM_BYTEORDER_SWAB
20
#include <datastruct/byteorder.h>
22
/* Figure out what endian conversions we need */
24
ddf1_endianness(struct lib_context *lc, struct ddf1 *ddf1)
26
uint8_t *ptr = (uint8_t *) & ddf1->anchor.signature;
28
if (ptr[0] == 0xDE && ptr[1] == 0x11)
30
else if (ptr[0] == 0x11 && ptr[1] == 0xDE)
33
LOG_ERR(lc, -EINVAL, "Can't figure out endianness!");
36
/* Find the beginning of all DDF metadata */
38
ddf1_beginning(struct ddf1 *ddf1)
41
struct ddf1_header *h = &ddf1->anchor;
43
start = ddf1->anchor_offset;
44
if (h->primary_table_lba < start)
45
start = h->primary_table_lba;
46
if (h->secondary_table_lba < start)
47
start = h->secondary_table_lba;
48
#ifdef WORKSPACE_IS_PART_OF_DDF
49
if (ddf1->primary->workspace_lba < start)
50
start = ddf1->primary->workspace_lba;
56
/* Helper for CR_OFF */
58
ddf1_cr_off_maxpds_helper(struct ddf1 * ddf1)
60
struct ddf1_header *h = ddf1->primary;
62
/* The 0xFFFF nonsense is a weird Adaptec quirk */
64
// return (h->max_primary_elements == 0xFFFF && ddf1->adaptec_mode) ?
65
return (h->max_primary_elements == 0xFFFF) ?
66
h->max_phys_drives : h->max_primary_elements;
69
/* Process DDF1 records depending on type */
71
ddf1_process_records(struct lib_context *lc, struct dev_info *di,
72
struct ddf1_record_handler *handler,
73
struct ddf1 *ddf1, int in_cpu_format)
75
unsigned int i, cfgs = NUM_CONFIG_ENTRIES(ddf1);
78
for (i = 0; i < cfgs; i++) {
79
x = *((uint32_t *) CR(ddf1, i));
80
if (!in_cpu_format && BYTE_ORDER != ddf1->disk_format)
84
case DDF1_VD_CONFIG_REC:
85
if (!handler->vd(lc, di, ddf1, i))
91
if (!handler->spare(lc, di, ddf1, i))
96
case 0: /* Adaptec puts zero in this field??? */
101
log_warn(lc, "%s: Unknown config record %d.",