1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-28 15:33:42 +02:00

Improve SST25 status register routines

- Using a 4-bit index into an array with 8 elements leads to
out-of-bounds accesses. Use proper bit masking to fix this.
- Factor out common SST25 status register printing.
- Use the common SST25 status register printing for SST25VF080B.

Corresponding to flashrom svn r468.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Peter Stuge <peter@stuge.se>
This commit is contained in:
Carl-Daniel Hailfinger 2009-05-06 13:59:44 +00:00
parent 9bb88acc5e
commit 1bfd6c9524

26
spi.c
View File

@ -275,6 +275,15 @@ void spi_prettyprint_status_register_st_m25p(uint8_t status)
spi_prettyprint_status_register_common(status); spi_prettyprint_status_register_common(status);
} }
void spi_prettyprint_status_register_sst25(uint8_t status)
{
printf_debug("Chip status register: Block Protect Write Disable "
"(BPL) is %sset\n", (status & (1 << 7)) ? "" : "not ");
printf_debug("Chip status register: Auto Address Increment Programming "
"(AAI) is %sset\n", (status & (1 << 6)) ? "" : "not ");
spi_prettyprint_status_register_common(status);
}
/* Prettyprint the status register. Works for /* Prettyprint the status register. Works for
* SST 25VF016 * SST 25VF016
*/ */
@ -289,11 +298,7 @@ void spi_prettyprint_status_register_sst25vf016(uint8_t status)
"100000H-1FFFFFH", "100000H-1FFFFFH",
"all", "all" "all", "all"
}; };
printf_debug("Chip status register: Block Protect Write Disable " spi_prettyprint_status_register_sst25(status);
"(BPL) is %sset\n", (status & (1 << 7)) ? "" : "not ");
printf_debug("Chip status register: Auto Address Increment Programming "
"(AAI) is %sset\n", (status & (1 << 6)) ? "" : "not ");
spi_prettyprint_status_register_common(status);
printf_debug("Resulting block protection : %s\n", printf_debug("Resulting block protection : %s\n",
bpt[(status & 0x1c) >> 2]); bpt[(status & 0x1c) >> 2]);
} }
@ -307,13 +312,9 @@ void spi_prettyprint_status_register_sst25vf040b(uint8_t status)
"0x40000-0x7ffff", "0x40000-0x7ffff",
"all blocks", "all blocks", "all blocks", "all blocks" "all blocks", "all blocks", "all blocks", "all blocks"
}; };
printf_debug("Chip status register: Block Protect Write Disable " spi_prettyprint_status_register_sst25(status);
"(BPL) is %sset\n", (status & (1 << 7)) ? "" : "not ");
printf_debug("Chip status register: Auto Address Increment Programming "
"(AAI) is %sset\n", (status & (1 << 6)) ? "" : "not ");
spi_prettyprint_status_register_common(status);
printf_debug("Resulting block protection : %s\n", printf_debug("Resulting block protection : %s\n",
bpt[(status & 0x3c) >> 2]); bpt[(status & 0x1c) >> 2]);
} }
void spi_prettyprint_status_register(struct flashchip *flash) void spi_prettyprint_status_register(struct flashchip *flash)
@ -341,6 +342,9 @@ void spi_prettyprint_status_register(struct flashchip *flash)
case 0x258d: case 0x258d:
spi_prettyprint_status_register_sst25vf040b(status); spi_prettyprint_status_register_sst25vf040b(status);
break; break;
case 0x258e:
spi_prettyprint_status_register_sst25(status);
break;
} }
break; break;
} }