1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-02 06:23:18 +02:00

Convert various prints to use msg_p* and msg_g* respectively

Convert programmer print messages to msg_p* convert general print messages to msg_g* a few fixes as suggested by Carl-Daniel.

Corresponding to flashrom svn r997.

Signed-off-by: Sean Nelson <audiohacked@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
Sean Nelson
2010-05-07 20:09:04 +00:00
parent 270237687a
commit 316a29f33f
10 changed files with 308 additions and 317 deletions

View File

@ -38,17 +38,6 @@
#include "chipdrivers.h"
#include "spi.h"
/* Change this to #define if you want lowlevel debugging of commands
* sent to the ICH/VIA SPI controller.
*/
#undef COMM_DEBUG
#ifdef COMM_DEBUG
#define msg_comm_debug printf_debug
#else
#define msg_comm_debug(...) do {} while (0)
#endif
/* ICH9 controller register definition */
#define ICH9_REG_FADDR 0x08 /* 32 Bits */
#define ICH9_REG_FDATA0 0x10 /* 64 Bytes */
@ -237,7 +226,7 @@ static int generate_opcodes(OPCODES * op)
uint32_t opmenu[2];
if (op == NULL) {
printf_debug("\n%s: null OPCODES pointer!\n", __func__);
msg_perr("\n%s: null OPCODES pointer!\n", __func__);
return -1;
}
@ -256,7 +245,7 @@ static int generate_opcodes(OPCODES * op)
opmenu[1] = REGREAD32(ICH9_REG_OPMENU + 4);
break;
default:
printf_debug("%s: unsupported chipset\n", __func__);
msg_perr("%s: unsupported chipset\n", __func__);
return -1;
}
@ -315,7 +304,7 @@ int program_opcodes(OPCODES * op)
opmenu[1] |= ((uint32_t) op->opcode[a].opcode) << ((a - 4) * 8);
}
printf_debug("\n%s: preop=%04x optype=%04x opmenu=%08x%08x\n", __func__, preop, optype, opmenu[0], opmenu[1]);
msg_pdbg("\n%s: preop=%04x optype=%04x opmenu=%08x%08x\n", __func__, preop, optype, opmenu[0], opmenu[1]);
switch (spi_controller) {
case SPI_CONTROLLER_ICH7:
case SPI_CONTROLLER_VIA:
@ -331,7 +320,7 @@ int program_opcodes(OPCODES * op)
REGWRITE32(ICH9_REG_OPMENU + 4, opmenu[1]);
break;
default:
printf_debug("%s: unsupported chipset\n", __func__);
msg_perr("%s: unsupported chipset\n", __func__);
return -1;
}
@ -352,22 +341,22 @@ int ich_init_opcodes(void)
return 0;
if (ichspi_lock) {
printf_debug("Generating OPCODES... ");
msg_pdbg("Generating OPCODES... ");
curopcodes_done = &O_EXISTING;
rc = generate_opcodes(curopcodes_done);
} else {
printf_debug("Programming OPCODES... ");
msg_pdbg("Programming OPCODES... ");
curopcodes_done = &O_ST_M25P;
rc = program_opcodes(curopcodes_done);
}
if (rc) {
curopcodes = NULL;
printf_debug("failed\n");
msg_perr("failed\n");
return 1;
} else {
curopcodes = curopcodes_done;
printf_debug("done\n");
msg_pdbg("done\n");
return 0;
}
}
@ -439,7 +428,7 @@ static int ich7_run_opcode(OPCODE op, uint32_t offset,
opmenu >>= 8;
}
if (opcode_index == 8) {
printf_debug("Opcode %x not found.\n", op.opcode);
msg_pdbg("Opcode %x not found.\n", op.opcode);
return 1;
}
temp16 |= ((uint16_t) (opcode_index & 0x07)) << 4;
@ -468,11 +457,12 @@ static int ich7_run_opcode(OPCODE op, uint32_t offset,
programmer_delay(10);
}
if (!timeout) {
printf_debug("timeout\n");
msg_perr("timeout\n");
}
/* FIXME: make sure we do not needlessly cause transaction errors. */
if ((REGREAD16(ICH7_REG_SPIS) & SPIS_FCERR) != 0) {
printf_debug("Transaction error!\n");
msg_pdbg("Transaction error!\n");
return 1;
}
@ -557,7 +547,7 @@ static int ich9_run_opcode(OPCODE op, uint32_t offset,
opmenu >>= 8;
}
if (opcode_index == 8) {
printf_debug("Opcode %x not found.\n", op.opcode);
msg_pdbg("Opcode %x not found.\n", op.opcode);
return 1;
}
temp32 |= ((uint32_t) (opcode_index & 0x07)) << (8 + 4);
@ -586,11 +576,12 @@ static int ich9_run_opcode(OPCODE op, uint32_t offset,
programmer_delay(10);
}
if (!timeout) {
printf_debug("timeout\n");
msg_perr("timeout\n");
}
/* FIXME make sure we do not needlessly cause transaction errors. */
if ((REGREAD32(ICH9_REG_SSFS) & SSFS_FCERR) != 0) {
printf_debug("Transaction error!\n");
msg_pdbg("Transaction error!\n");
return 1;
}
@ -615,7 +606,7 @@ static int run_opcode(OPCODE op, uint32_t offset,
switch (spi_controller) {
case SPI_CONTROLLER_VIA:
if (datalength > 16) {
fprintf(stderr, "%s: Internal command size error for "
msg_perr("%s: Internal command size error for "
"opcode 0x%02x, got datalength=%i, want <=16\n",
__func__, op.opcode, datalength);
return SPI_INVALID_LENGTH;
@ -623,7 +614,7 @@ static int run_opcode(OPCODE op, uint32_t offset,
return ich7_run_opcode(op, offset, datalength, data, 16);
case SPI_CONTROLLER_ICH7:
if (datalength > 64) {
fprintf(stderr, "%s: Internal command size error for "
msg_perr("%s: Internal command size error for "
"opcode 0x%02x, got datalength=%i, want <=16\n",
__func__, op.opcode, datalength);
return SPI_INVALID_LENGTH;
@ -631,14 +622,14 @@ static int run_opcode(OPCODE op, uint32_t offset,
return ich7_run_opcode(op, offset, datalength, data, 64);
case SPI_CONTROLLER_ICH9:
if (datalength > 64) {
fprintf(stderr, "%s: Internal command size error for "
msg_perr("%s: Internal command size error for "
"opcode 0x%02x, got datalength=%i, want <=16\n",
__func__, op.opcode, datalength);
return SPI_INVALID_LENGTH;
}
return ich9_run_opcode(op, offset, datalength, data);
default:
printf_debug("%s: unsupported chipset\n", __func__);
msg_perr("%s: unsupported chipset\n", __func__);
}
/* If we ever get here, something really weird happened */
@ -652,14 +643,14 @@ static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes,
uint32_t remaining = page_size;
int towrite;
msg_comm_debug("ich_spi_write_page: offset=%d, number=%d, buf=%p\n",
msg_pspew("ich_spi_write_page: offset=%d, number=%d, buf=%p\n",
offset, page_size, bytes);
for (; remaining > 0; remaining -= towrite) {
towrite = min(remaining, maxdata);
if (spi_nbyte_program(offset + (page_size - remaining),
&bytes[page_size - remaining], towrite)) {
printf_debug("Error writing");
msg_perr("Error writing");
return 1;
}
}
@ -687,14 +678,14 @@ int ich_spi_write_256(struct flashchip *flash, uint8_t * buf)
spi_disable_blockprotect();
/* Erase first */
printf("Erasing flash before programming... ");
msg_pinfo("Erasing flash before programming... ");
if (erase_flash(flash)) {
fprintf(stderr, "ERASE FAILED!\n");
msg_perr("ERASE FAILED!\n");
return -1;
}
printf("done.\n");
msg_pinfo("done.\n");
printf("Programming page: \n");
msg_pinfo("Programming page: \n");
for (i = 0; i < total_size / erase_size; i++) {
if (spi_controller == SPI_CONTROLLER_VIA)
maxdata = 16;
@ -706,7 +697,7 @@ int ich_spi_write_256(struct flashchip *flash, uint8_t * buf)
}
}
printf("\n");
msg_pinfo("\n");
return rc;
}
@ -728,7 +719,7 @@ int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
/* FIXME: Reprogram opcodes if possible. Autodetect type of
* opcode by checking readcnt/writecnt.
*/
printf_debug("Invalid OPCODE 0x%02x\n", cmd);
msg_pdbg("Invalid OPCODE 0x%02x\n", cmd);
return SPI_INVALID_OPCODE;
}
@ -743,21 +734,21 @@ int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
*/
if ((opcode->spi_type == SPI_OPCODE_TYPE_READ_WITH_ADDRESS) &&
(writecnt != 4)) {
fprintf(stderr, "%s: Internal command size error for opcode "
msg_perr("%s: Internal command size error for opcode "
"0x%02x, got writecnt=%i, want =4\n", __func__, cmd,
writecnt);
return SPI_INVALID_LENGTH;
}
if ((opcode->spi_type == SPI_OPCODE_TYPE_READ_NO_ADDRESS) &&
(writecnt != 1)) {
fprintf(stderr, "%s: Internal command size error for opcode "
msg_perr("%s: Internal command size error for opcode "
"0x%02x, got writecnt=%i, want =1\n", __func__, cmd,
writecnt);
return SPI_INVALID_LENGTH;
}
if ((opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) &&
(writecnt < 4)) {
fprintf(stderr, "%s: Internal command size error for opcode "
msg_perr("%s: Internal command size error for opcode "
"0x%02x, got writecnt=%i, want >=4\n", __func__, cmd,
writecnt);
return SPI_INVALID_LENGTH;
@ -765,7 +756,7 @@ int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
if (((opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) ||
(opcode->spi_type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS)) &&
(readcnt)) {
fprintf(stderr, "%s: Internal command size error for opcode "
msg_perr("%s: Internal command size error for opcode "
"0x%02x, got readcnt=%i, want =0\n", __func__, cmd,
readcnt);
return SPI_INVALID_LENGTH;
@ -792,7 +783,7 @@ int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
result = run_opcode(*opcode, addr, count, data);
if (result) {
printf_debug("run OPCODE 0x%02x failed\n", opcode->opcode);
msg_pdbg("run OPCODE 0x%02x failed\n", opcode->opcode);
}
return result;
@ -817,7 +808,7 @@ int ich_spi_send_multicommand(struct spi_command *cmds)
*/
if (find_preop(curopcodes,
(cmds + 1)->writearr[0]) != -1) {
fprintf(stderr, "%s: Two subsequent "
msg_perr("%s: Two subsequent "
"preopcodes 0x%02x and 0x%02x, "
"ignoring the first.\n",
__func__, cmds->writearr[0],
@ -829,7 +820,7 @@ int ich_spi_send_multicommand(struct spi_command *cmds)
* No need to bother with fixups.
*/
if (!ichspi_lock) {
printf_debug("%s: FIXME: Add on-the-fly"
msg_pdbg("%s: FIXME: Add on-the-fly"
" reprogramming of the "
"chipset opcode list.\n",
__func__);