struct ssfdcr_record { struct mtd_blktrans_dev mbd; unsignedchar heads; unsignedchar sectors; unsignedshort cylinders; int cis_block; /* block n. containing CIS/IDI */ int erase_size; /* phys_block_size */ unsignedshort *logic_block_map; /* all zones (max 8192 phys blocks on
the 128MiB) */ int map_len; /* n. phys_blocks on the card */
};
staticint get_chs(unsignedlong size, unsignedshort *cyl, unsignedchar *head, unsignedchar *sec)
{ int k; int found = 0;
k = 0; while (chs_table[k].size > 0 && size > chs_table[k].size)
k++;
if (chs_table[k].size > 0) { if (cyl)
*cyl = chs_table[k].cyl; if (head)
*head = chs_table[k].head; if (sec)
*sec = chs_table[k].sec;
found = 1;
}
return found;
}
/* These bytes are the signature for the CIS/IDI sector */ staticconst uint8_t cis_numbers[] = {
0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02, 0xDF, 0x01, 0x20
};
/* Read and check for a valid CIS sector */ staticint get_valid_cis_sector(struct mtd_info *mtd)
{ int ret, k, cis_sector;
size_t retlen;
loff_t offset;
uint8_t *sect_buf;
cis_sector = -1;
sect_buf = kmalloc(SECTOR_SIZE, GFP_KERNEL); if (!sect_buf) goto out;
/* * Look for CIS/IDI sector on the first GOOD block (give up after 4 bad * blocks). If the first good block doesn't contain CIS number the flash * is not SSFDC formatted
*/ for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) { if (mtd_block_isbad(mtd, offset)) {
ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen,
sect_buf);
/* CIS pattern match on the sector buffer */ if (ret < 0 || retlen != SECTOR_SIZE) {
printk(KERN_WARNING "SSFDC_RO:can't read CIS/IDI sector\n");
} elseif (!memcmp(sect_buf, cis_numbers, sizeof(cis_numbers))) { /* Found */
cis_sector = (int)(offset >> SECTOR_SHIFT);
} else {
pr_debug("SSFDC_RO: CIS/IDI sector not found" " on %s (mtd%d)\n", mtd->name,
mtd->index);
} break;
}
}
kfree(sect_buf);
out: return cis_sector;
}
/* Read physical sector (wrapper to MTD_READ) */ staticint read_physical_sector(struct mtd_info *mtd, uint8_t *sect_buf, int sect_no)
{ int ret;
size_t retlen;
loff_t offset = (loff_t)sect_no << SECTOR_SHIFT;
ret = mtd_read(mtd, offset, SECTOR_SIZE, &retlen, sect_buf); if (ret < 0 || retlen != SECTOR_SIZE) return -1;
return 0;
}
/* Read redundancy area (wrapper to MTD_READ_OOB */ staticint read_raw_oob(struct mtd_info *mtd, loff_t offs, uint8_t *buf)
{ struct mtd_oob_ops ops = { }; int ret;
/* Read and validate the logical block address field stored in the OOB */ staticint get_logical_address(uint8_t *oob_buf)
{ int block_address, parity; int offset[2] = {6, 11}; /* offset of the 2 address fields within OOB */ int j; int ok = 0;
/* * Look for the first valid logical address * Valid address has fixed pattern on most significant bits and * parity check
*/ for (j = 0; j < ARRAY_SIZE(offset); j++) {
block_address = ((int)oob_buf[offset[j]] << 8) |
oob_buf[offset[j]+1];
/* Check for the signature bits in the address field (MSBits) */ if ((block_address & ~0x7FF) == 0x1000) {
parity = block_address & 0x01;
block_address &= 0x7FF;
block_address >>= 1;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.