Commit 9d85b55f authored by Alessandro Rubini's avatar Alessandro Rubini

general: remove mprintf calls, use pp_printf

We have not been using mprintf for ages now, and it's better for the
code to explicitly call pp_printf, so people is aware of it.

We might "#define printf pp_printf", but currently we'd better not.
Maybe when we turn this into a real operating system, next millennium...
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 2cb2a054
......@@ -86,5 +86,3 @@ SECTIONS
PROVIDE(_fstack = ORIGIN(stack) + LENGTH(stack) - 4);
}
/* We need to provide mprintf to ptp-noposix object files, if missing */
PROVIDE(mprintf = pp_printf);
......@@ -65,6 +65,3 @@ SECTIONS
/* First location in stack is highest address in STACK */
PROVIDE(_fstack = ORIGIN(stack) + LENGTH(stack) - 4);
}
/* We need to provide mprintf to developers with old habits, if missing */
PROVIDE(mprintf = pp_printf);
......@@ -323,14 +323,14 @@ int storage_init_show(void)
if (used == 0 || used == 0xffff) {
used = 0; //this means the memory is blank
mprintf("Empty init script...\n");
pp_printf("Empty init script...\n");
}
//just read and print to the screen char after char
for (i = 0; i < used; ++i) {
if (eeprom_read(i2cif, i2c_addr, EE_BASE_INIT + sizeof(used)
+ i, &byte, sizeof(byte)) != sizeof(byte))
return EE_RET_I2CERR;
mprintf("%c", byte);
pp_printf("%c", byte);
}
return 0;
......
......@@ -102,7 +102,7 @@ int ep_enable(int enabled, int autoneg)
/* Disable the endpoint */
EP->ECR = 0;
mprintf("ID: %x\n", EP->IDCODE);
pp_printf("ID: %x\n", EP->IDCODE);
/* Load default packet classifier rules - see ep_pfilter.c for details */
pfilter_init_default();
......
......@@ -123,9 +123,9 @@ uint8_t mi2c_devprobe(uint8_t i2cif, uint8_t i2c_addr)
// for(i=0x50;i<0x51;i++)
// {
// mi2c_start(i2cif);
// if(!mi2c_put_byte(i2cif, i<<1)) mprintf("found : %x\n", i);
// if(!mi2c_put_byte(i2cif, i<<1)) pp_printf("found : %x\n", i);
// mi2c_stop(i2cif);
//
// }
// mprintf("Nothing more found...\n");
// pp_printf("Nothing more found...\n");
//}
......@@ -211,7 +211,7 @@ int minic_rx_frame(uint8_t * hdr, uint8_t * payload, uint32_t buf_size,
minic_new_rx_buffer();
} else {
//otherwise, weird !!
mprintf("invalid descriptor @%x = %x\n",
pp_printf("invalid descriptor @%x = %x\n",
(uint32_t) minic.rx_head, desc_hdr);
minic_new_rx_buffer();
}
......@@ -328,7 +328,7 @@ int minic_tx_frame(uint8_t * hdr, uint8_t * payload, uint32_t size,
}
if (i == 1000)
mprintf("Warning: tx not terminated infinite mcr=0x%x\n",mcr);
pp_printf("Warning: tx not terminated infinite mcr=0x%x\n",mcr);
if (hwts) {
uint32_t raw_ts;
......@@ -348,7 +348,7 @@ int minic_tx_frame(uint8_t * hdr, uint8_t * payload, uint32_t size,
if (i == 100)
{
mprintf("Warning: tx timestamp never became available\n");
pp_printf("Warning: tx timestamp never became available\n");
ts_valid = 0;
}
......
......@@ -10,7 +10,6 @@
#include <inttypes.h>
#include <syscon.h>
#include <pp-printf.h>
#define mprintf pp_printf
#define vprintf pp_vprintf
#define sprintf pp_sprintf
......
......@@ -134,7 +134,7 @@ int send_bootp(uint8_t * buf, int retry)
buf[IP_CHECKSUM + 0] = sum >> 8;
buf[IP_CHECKSUM + 1] = sum & 0xff;
// mprintf("Sending BOOTP request...\n");
// pp_printf("Sending BOOTP request...\n");
return BOOTP_END;
}
......@@ -160,9 +160,9 @@ int process_bootp(uint8_t * buf, int len)
return 0;
setIP(buf + BOOTP_YIADDR);
getIP(ip);
mprintf("Discovered IP address (%d.%d.%d.%d)!\n",
pp_printf("Discovered IP address (%d.%d.%d.%d)!\n",
ip[0], ip[1], ip[2], ip[3]);
return 1;
......
......@@ -50,7 +50,7 @@ int ptpd_netif_init()
return PTPD_NETIF_OK;
}
//#define TRACE_WRAP mprintf
//#define TRACE_WRAP pp_printf
int ptpd_netif_get_hw_addr(wr_socket_t * sock, mac_addr_t * mac)
{
get_mac_addr((uint8_t *) mac);
......
......@@ -81,25 +81,25 @@ char *format_time(uint64_t sec)
void cprintf(int color, const char *fmt, ...)
{
va_list ap;
mprintf("\e[0%d;3%dm", color & C_DIM ? 2 : 1, color & 0x7f);
pp_printf("\e[0%d;3%dm", color & C_DIM ? 2 : 1, color & 0x7f);
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
mprintf("\e[m");
pp_printf("\e[m");
}
void pcprintf(int row, int col, int color, const char *fmt, ...)
{
va_list ap;
mprintf("\e[%d;%df", row, col);
mprintf("\e[0%d;3%dm", color & C_DIM ? 2 : 1, color & 0x7f);
pp_printf("\e[%d;%df", row, col);
pp_printf("\e[0%d;3%dm", color & C_DIM ? 2 : 1, color & 0x7f);
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
mprintf("\e[m");
pp_printf("\e[m");
}
void term_clear(void)
{
mprintf("\e[2J\e[1;1H");
pp_printf("\e[2J\e[1;1H");
}
......@@ -177,7 +177,7 @@ void wrc_mon_gui(void)
if (aux_stat & SPLL_AUX_LOCKED)
cprintf(C_GREEN, ", locked");
mprintf("\n");
pp_printf("\n");
cprintf(C_BLUE, "\nTiming parameters:\n\n");
......
......@@ -30,12 +30,12 @@ static int cmd_calibration(const char *args[])
return storage_phtrans(&trans, 1);
} else if (!args[0]) {
if (storage_phtrans(&trans, 0) > 0) {
mprintf("Found phase transition in EEPROM: %dps\n",
pp_printf("Found phase transition in EEPROM: %dps\n",
trans);
cal_phase_transition = trans;
return 0;
} else {
mprintf("Measuring t2/t4 phase transition...\n");
pp_printf("Measuring t2/t4 phase transition...\n");
if (measure_t24p(&trans) < 0)
return -1;
cal_phase_transition = trans;
......
......@@ -17,18 +17,18 @@
static int cmd_init(const char *args[])
{
if (!mi2c_devprobe(WRPC_FMC_I2C, FMC_EEPROM_ADR)) {
mprintf("EEPROM not found..\n");
pp_printf("EEPROM not found..\n");
return -1;
}
if (args[0] && !strcasecmp(args[0], "erase")) {
if (storage_init_erase() < 0)
mprintf("Could not erase init script\n");
pp_printf("Could not erase init script\n");
} else if (args[1] && !strcasecmp(args[0], "add")) {
if (storage_init_add(args) < 0)
mprintf("Could not add the command\n");
pp_printf("Could not add the command\n");
else
mprintf("OK.\n");
pp_printf("OK.\n");
} else if (args[0] && !strcasecmp(args[0], "show")) {
storage_init_show();
} else if (args[0] && !strcasecmp(args[0], "boot")) {
......
......@@ -42,9 +42,9 @@ static int cmd_ip(const char *args[])
}
if (needIP) {
mprintf("IP-address: in training\n");
pp_printf("IP-address: in training\n");
} else {
mprintf("IP-address: %d.%d.%d.%d\n",
pp_printf("IP-address: %d.%d.%d.%d\n",
ip[0], ip[1], ip[2], ip[3]);
}
return 0;
......
......@@ -52,7 +52,7 @@ static int cmd_mac(const char *args[])
return -EINVAL;
}
mprintf("MAC-address: %02x:%02x:%02x:%02x:%02x:%02x\n",
pp_printf("MAC-address: %02x:%02x:%02x:%02x:%02x:%02x\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return 0;
}
......
......@@ -31,7 +31,7 @@ static int cmd_mode(const char *args[])
else if (!strcasecmp(args[0], "slave"))
mode = WRC_MODE_SLAVE;
else {
mprintf("%s\n", modes[wrc_ptp_get_mode()]);
pp_printf("%s\n", modes[wrc_ptp_get_mode()]);
return 0;
}
return wrc_ptp_set_mode(mode);
......
......@@ -25,7 +25,7 @@ static int cmd_pll(const char *args[])
} else if (!strcasecmp(args[0], "cl")) {
if (!args[1])
return -EINVAL;
mprintf("%d\n", spll_check_lock(atoi(args[1])));
pp_printf("%d\n", spll_check_lock(atoi(args[1])));
} else if (!strcasecmp(args[0], "stat")) {
spll_show_stats();
} else if (!strcasecmp(args[0], "sps")) {
......@@ -36,7 +36,7 @@ static int cmd_pll(const char *args[])
if (!args[1])
return -EINVAL;
spll_get_phase_shift(atoi(args[1]), &cur, &tgt);
mprintf("%d %d\n", cur, tgt);
pp_printf("%d %d\n", cur, tgt);
} else if (!strcasecmp(args[0], "start")) {
if (!args[1])
return -EINVAL;
......@@ -52,7 +52,7 @@ static int cmd_pll(const char *args[])
} else if (!strcasecmp(args[0], "gdac")) {
if (!args[1])
return -EINVAL;
mprintf("%d\n", spll_get_dac(atoi(args[1])));
pp_printf("%d\n", spll_get_dac(atoi(args[1])));
} else if(!strcasecmp(args[0], "checkvco"))
check_vco_frequencies();
else
......
......@@ -29,7 +29,7 @@ static int cmd_ptrack(const char *args[])
wr_servo_enable_tracking(0);
wrc_phase_tracking = 0;
}
mprintf("phase tracking %s\n", wrc_phase_tracking?"ON":"OFF");
pp_printf("phase tracking %s\n", wrc_phase_tracking?"ON":"OFF");
return 0;
}
......
......@@ -40,11 +40,11 @@ static int cmd_sfp(const char *args[])
if (args[0] && !strcasecmp(args[0], "detect")) {
if (!sfp_present())
mprintf("No SFP.\n");
pp_printf("No SFP.\n");
else
sfp_read_part_id(pn);
pn[16] = 0;
mprintf("%s\n", pn);
pp_printf("%s\n", pn);
return 0;
}
// else if (!strcasecmp(args[0], "i2cscan"))
......@@ -55,7 +55,7 @@ static int cmd_sfp(const char *args[])
else if (!strcasecmp(args[0], "erase")) {
if (storage_sfpdb_erase() ==
EE_RET_I2CERR)
mprintf("Could not erase DB\n");
pp_printf("Could not erase DB\n");
} else if (args[4] && !strcasecmp(args[0], "add")) {
if (strlen(args[1]) > 16)
temp = 16;
......@@ -70,44 +70,44 @@ static int cmd_sfp(const char *args[])
sfp.alpha = atoi(args[4]);
temp = storage_get_sfp(&sfp, 1, 0);
if (temp == EE_RET_DBFULL)
mprintf("SFP DB is full\n");
pp_printf("SFP DB is full\n");
else if (temp == EE_RET_I2CERR)
mprintf("I2C error\n");
pp_printf("I2C error\n");
else
mprintf("%d SFPs in DB\n", temp);
pp_printf("%d SFPs in DB\n", temp);
} else if (args[0] && !strcasecmp(args[0], "show")) {
for (i = 0; i < sfpcount; ++i) {
temp = storage_get_sfp(&sfp, 0, i);
if (!i) {
sfpcount = temp; //only in first round valid sfpcount is returned from storage_get_sfp
if (sfpcount == 0 || sfpcount == 0xFF) {
mprintf("SFP database empty...\n");
pp_printf("SFP database empty...\n");
return 0;
} else if (sfpcount == -1) {
mprintf("SFP database corrupted...\n");
pp_printf("SFP database corrupted...\n");
return 0;
}
}
mprintf("%d: PN:", i + 1);
pp_printf("%d: PN:", i + 1);
for (temp = 0; temp < 16; ++temp)
mprintf("%c", sfp.pn[temp]);
mprintf(" dTx: %d, dRx: %d, alpha: %d\n", sfp.dTx,
pp_printf("%c", sfp.pn[temp]);
pp_printf(" dTx: %d, dRx: %d, alpha: %d\n", sfp.dTx,
sfp.dRx, sfp.alpha);
}
} else if (args[0] && !strcasecmp(args[0], "match")) {
if (pn[0] == '\0') {
mprintf("Run sfp detect first\n");
pp_printf("Run sfp detect first\n");
return 0;
}
strncpy(sfp.pn, pn, SFP_PN_LEN);
if (storage_match_sfp(&sfp) > 0) {
mprintf("SFP matched, dTx=%d, dRx=%d, alpha=%d\n",
pp_printf("SFP matched, dTx=%d, dRx=%d, alpha=%d\n",
sfp.dTx, sfp.dRx, sfp.alpha);
sfp_deltaTx = sfp.dTx;
sfp_deltaRx = sfp.dRx;
sfp_alpha = sfp.alpha;
} else
mprintf("Could not match to DB\n");
pp_printf("Could not match to DB\n");
return 0;
} else if (args[0] && !strcasecmp(args[0], "ena")) {
if(!args[1])
......
......@@ -20,7 +20,7 @@ static int cmd_stat(const char *args[])
/* arguments: bts, on, off */
if (!strcasecmp(args[0], "bts")) {
mprintf("%d ps\n", ep_get_bitslide());
pp_printf("%d ps\n", ep_get_bitslide());
} else if (!strcasecmp(args[0], "on")) {
wrc_stat_running = 1;
wrc_stats_last--; /* force a line to be printed */
......
......@@ -49,11 +49,11 @@ static int cmd_time(const char *args[])
return 0;
}
} else if (args[0] && !strcasecmp(args[0], "raw")) {
mprintf("%d %d\n", (uint32_t) sec, nsec);
pp_printf("%d %d\n", (uint32_t) sec, nsec);
return 0;
}
mprintf("%s +%d nanoseconds.\n", format_time(sec), nsec); /* fixme: clock freq is not always 125 MHz */
pp_printf("%s +%d nanoseconds.\n", format_time(sec), nsec); /* fixme: clock freq is not always 125 MHz */
return 0;
}
......
......@@ -68,7 +68,7 @@ static void delete(int where)
static void esc(char code)
{
mprintf("\033[1%c", code);
pp_printf("\033[1%c", code);
}
static int _shell_exec(void)
......@@ -107,12 +107,12 @@ static int _shell_exec(void)
if (!strcasecmp(p->name, tokptr[0])) {
rv = p->exec((const char **)(tokptr + 1));
if (rv < 0)
mprintf("Command \"%s\": error %d\n",
pp_printf("Command \"%s\": error %d\n",
p->name, rv);
return rv;
}
mprintf("Unrecognized command \"%s\".\n", tokptr[0]);
pp_printf("Unrecognized command \"%s\".\n", tokptr[0]);
return -EINVAL;
}
......@@ -134,7 +134,7 @@ void shell_interactive()
int c;
switch (state) {
case SH_PROMPT:
mprintf("wrc# ");
pp_printf("wrc# ");
cmd_pos = 0;
cmd_len = 0;
state = SH_INPUT;
......@@ -168,7 +168,7 @@ void shell_interactive()
break;
case KEY_ENTER:
mprintf("\n");
pp_printf("\n");
state = SH_EXEC;
break;
......@@ -195,7 +195,7 @@ void shell_interactive()
if (!(current_key & ESCAPE_FLAG)
&& insert(current_key)) {
esc('@');
mprintf("%c", current_key);
pp_printf("%c", current_key);
}
break;
......@@ -260,12 +260,12 @@ int shell_boot_script(void)
SH_MAX_LINE_LEN, next);
if (cmd_len <= 0) {
if (next == 0)
mprintf("Empty init script...\n");
pp_printf("Empty init script...\n");
break;
}
cmd_buf[cmd_len - 1] = 0;
mprintf("executing: %s\n", cmd_buf);
pp_printf("executing: %s\n", cmd_buf);
_shell_exec();
next = 1;
}
......
......@@ -16,7 +16,7 @@ void check_stack(void)
{
/* print "Stack overflow!" forever if stack corrupted */
while (_endram != ENDRAM_MAGIC) {
mprintf("Stack overflow!\n");
pp_printf("Stack overflow!\n");
timer_delay_ms(1000);
}
}
......
......@@ -52,7 +52,7 @@ static void wrc_initialize(void)
uart_init_sw();
uart_init_hw();
mprintf("WR Core: starting up...\n");
pp_printf("WR Core: starting up...\n");
timer_init(1);
wrpc_w1_init();
......@@ -67,7 +67,7 @@ static void wrc_initialize(void)
storage_init(WRPC_FMC_I2C, FMC_EEPROM_ADR);
if (get_persistent_mac(ONEWIRE_PORT, mac_addr) == -1) {
mprintf("Unable to determine MAC address\n");
pp_printf("Unable to determine MAC address\n");
mac_addr[0] = 0x22; //
mac_addr[1] = 0x33; //
mac_addr[2] = 0x44; // fallback MAC if get_persistent_mac fails
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment