Commit 5c3ae852 authored by Alessandro Rubini's avatar Alessandro Rubini

Merge branch 'fix-warnings'

parents 14a84cc7 8f57a255
......@@ -63,7 +63,7 @@ include sockitowm/sockitowm.mk
include dev/dev.mk
CFLAGS = $(CFLAGS_PLATFORM) $(cflags-y) \
CFLAGS = $(CFLAGS_PLATFORM) $(cflags-y) -Wall \
-ffunction-sections -fdata-sections -Os \
-include include/trace.h
......
#include <string.h>
#include <wrc.h>
#include "types.h"
#include "i2c.h"
#include "eeprom.h"
......@@ -163,7 +166,7 @@ int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp,
chksum =
(uint8_t) ((uint16_t) chksum + *(ptr++)) & 0xff;
if (chksum != sfp->chksum)
EE_RET_CORRPT;
return EE_RET_CORRPT;
} else {
/*count checksum */
ptr = (uint8_t *) sfp;
......@@ -271,7 +274,7 @@ int8_t eeprom_init_purge(uint8_t i2cif, uint8_t i2c_addr)
int8_t eeprom_init_add(uint8_t i2cif, uint8_t i2c_addr, const char *args[])
{
uint8_t i = 1;
char separator = ' ';
uint8_t separator = ' ';
uint16_t used, readback;
if (eeprom_read(i2cif, i2c_addr, EE_BASE_INIT, (uint8_t *) & used,
......@@ -314,7 +317,7 @@ int8_t eeprom_init_add(uint8_t i2cif, uint8_t i2c_addr, const char *args[])
int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr)
{
uint16_t used, i;
char byte;
uint8_t byte;
if (eeprom_read(i2cif, i2c_addr, EE_BASE_INIT, (uint8_t *) & used,
sizeof(used)) != sizeof(used))
......@@ -335,7 +338,7 @@ int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr)
return 0;
}
int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, char *buf,
int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, uint8_t *buf,
uint8_t bufsize, uint8_t next)
{
static uint16_t ptr;
......
......@@ -9,6 +9,7 @@ LGPL 2.1
*/
#include <stdio.h>
#include <wrc.h>
#include "board.h"
#include "syscon.h"
......
......@@ -76,7 +76,7 @@
#define PFILTER_MAX_CODE_SIZE 32
#define pfilter_dbg
#define pfilter_dbg(x, ...) /* nothing */
extern volatile struct EP_WB *EP;
......@@ -87,7 +87,7 @@ static int code_pos;
static uint64_t code_buf[32];
/* begins assembling a new packet filter program */
void pfilter_new()
static void pfilter_new()
{
code_pos = 0;
}
......@@ -108,7 +108,8 @@ static void check_reg_range(int val, int minval, int maxval, char *name)
}
}
void pfilter_cmp(int offset, int value, int mask, pfilter_op_t op, int rd)
static void pfilter_cmp(int offset, int value, int mask, pfilter_op_t op,
int rd)
{
uint64_t ir;
......@@ -132,28 +133,7 @@ void pfilter_cmp(int offset, int value, int mask, pfilter_op_t op, int rd)
code_buf[code_pos++] = ir;
}
// rd = (packet[offset] & (1<<bit_index)) op rd
void pfilter_btst(int offset, int bit_index, pfilter_op_t op, int rd)
{
uint64_t ir;
check_size();
if (offset > code_pos)
pfilter_dbg
("microcode: comparison offset is bigger than current PC. Insert some nops before comparing");
check_reg_range(rd, 1, 15, "ra/rd");
check_reg_range(bit_index, 0, 15, "bit index");
ir = ((1ULL << 33) | PF_MODE_CMP | ((uint64_t) offset << 7) |
((uint64_t) bit_index << 29) | (uint64_t) op | ((uint64_t) rd <<
3));
code_buf[code_pos++] = ir;
}
void pfilter_nop()
static void pfilter_nop()
{
uint64_t ir;
check_size();
......@@ -162,7 +142,7 @@ void pfilter_nop()
}
// rd = ra op rb
void pfilter_logic2(int rd, int ra, pfilter_op_t op, int rb)
static void pfilter_logic2(int rd, int ra, pfilter_op_t op, int rb)
{
uint64_t ir;
check_size();
......@@ -194,7 +174,7 @@ static void pfilter_logic3(int rd, int ra, pfilter_op_t op, int rb,
}
/* Terminates the microcode, loads it to the endpoint and enables the pfilter */
void pfilter_load()
static void pfilter_load()
{
int i;
code_buf[code_pos++] = (1ULL << 35); // insert FIN instruction
......
#include <stdio.h>
#include <string.h>
#include <wrc.h>
#include "types.h"
#include "board.h"
......@@ -186,7 +187,7 @@ int minic_rx_frame(uint8_t * hdr, uint8_t * payload, uint32_t buf_size,
uint32_t payload_size, num_words;
uint32_t desc_hdr;
uint32_t raw_ts;
uint32_t rx_addr_cur, cur_avail;
uint32_t cur_avail;
int n_recvd;
if (!(minic_readl(MINIC_REG_EIC_ISR) & MINIC_EIC_ISR_RX))
......
#include <string.h>
#include <wrc.h>
#include "onewire.h"
#include "../sockitowm/ownet.h"
#include "../sockitowm/findtype.h"
#include "../sockitowm/eep43.h"
#include "../sockitowm/temp28.h"
#define DEBUG_PMAC 0
......@@ -72,7 +76,7 @@ int8_t get_persistent_mac(uint8_t portnum, uint8_t * mac)
if (FamilySN[i][0] == 0x43) {
owLevel(portnum, MODE_NORMAL);
if (ReadMem43(portnum, FamilySN[i], EEPROM_MAC_PAGE,
&read_buffer) == TRUE) {
read_buffer) == TRUE) {
if (read_buffer[0] == 0 && read_buffer[1] == 0
&& read_buffer[2] == 0) {
/* Skip the EEPROM since it has not been programmed! */
......@@ -116,7 +120,7 @@ int8_t set_persistent_mac(uint8_t portnum, uint8_t * mac)
/* Write the last EEPROM with the MAC */
owLevel(portnum, MODE_NORMAL);
if (Write43(portnum, FamilySN[0], EEPROM_MAC_PAGE, &write_buffer) ==
if (Write43(portnum, FamilySN[0], EEPROM_MAC_PAGE, write_buffer) ==
TRUE)
return 0;
......
#include <wrc.h>
#include "board.h"
#include "pps_gen.h"
......@@ -18,7 +19,7 @@
#define ppsg_read(reg) \
*(volatile uint32_t *) (BASE_PPS_GEN + (offsetof(struct PPSG_WB, reg)))
int pps_gen_init()
void pps_gen_init()
{
uint32_t cr;
......@@ -38,8 +39,6 @@ int pps_gen_init()
/* Adjusts the nanosecond (refclk cycle) counter by atomically adding (how_much) cycles. */
int pps_gen_adjust(int counter, int64_t how_much)
{
uint32_t cr;
TRACE_DEV("Adjust: counter = %s [%c%d]\n",
counter == PPSG_ADJUST_SEC ? "seconds" : "nanoseconds",
how_much < 0 ? '-' : '+', (int32_t) abs(how_much));
......@@ -61,10 +60,8 @@ int pps_gen_adjust(int counter, int64_t how_much)
}
/* Sets the current time */
int pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds)
void pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds)
{
uint32_t cr;
ppsg_write(ADJ_UTCLO, (uint32_t) (seconds & 0xffffffffLL));
ppsg_write(ADJ_UTCHI, (uint32_t) (seconds >> 32) & 0xff);
ppsg_write(ADJ_NSEC,
......@@ -72,7 +69,6 @@ int pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds)
(int64_t) REF_CLOCK_PERIOD_PS));
ppsg_write(CR, (ppsg_read(CR) & 0xfffffffb) | PPSG_CR_CNT_SET);
return 0;
}
uint64_t pps_get_utc(void)
......
#include <string.h>
#include <wrc.h>
#include "hw/memlayout.h"
#define SDB_INTERCONNET 0x00
......@@ -117,7 +119,7 @@ static void print_devices_deep(unsigned int base, unsigned int sdb)
static unsigned char *find_device(unsigned int devid)
{
find_device_deep(0, SDB_ADDRESS, devid);
return find_device_deep(0, SDB_ADDRESS, devid);
}
void sdb_print_devices(void)
......
......@@ -44,7 +44,11 @@ int8_t eeprom_phtrans(uint8_t i2cif, uint8_t i2c_addr, uint32_t * val,
int8_t eeprom_init_erase(uint8_t i2cif, uint8_t i2c_addr);
int8_t eeprom_init_add(uint8_t i2cif, uint8_t i2c_addr, const char *args[]);
int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr);
int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, char *buf,
int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, uint8_t *buf,
uint8_t bufsize, uint8_t next);
int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp,
uint8_t add, uint8_t pos);
int8_t eeprom_init_purge(uint8_t i2cif, uint8_t i2c_addr);
#endif
......@@ -27,14 +27,6 @@ int ep_get_psval(int32_t * psval);
int ep_cal_pattern_enable();
int ep_cal_pattern_disable();
void pfilter_new();
void pfilter_cmp(int offset, int value, int mask, pfilter_op_t op, int rd);
void pfilter_btst(int offset, int bit_index, pfilter_op_t op, int rd);
void pfilter_nop();
void pfilter_logic2(int rd, int ra, pfilter_op_t op, int rb);
static void pfilter_logic3(int rd, int ra, pfilter_op_t op, int rb,
pfilter_op_t op2, int rc);
void pfilter_load();
void pfilter_init_default();
uint16_t pcs_read(int location);
......
......@@ -7,21 +7,21 @@
#define PPSG_ADJUST_NSEC 0x2
/* Initializes the PPS Generator. 0 on success, negative on failure. */
int shw_pps_gen_init();
void pps_gen_init(void);
/* Adjusts the <counter> (PPSG_ADJUST_SEC/NSEC) by (how_much) seconds/nanoseconds */
int shw_pps_gen_adjust(int counter, int64_t how_much);
int pps_gen_adjust(int counter, int64_t how_much);
/* Returns 1 when the PPS is busy adjusting its time counters, 0 if PPS gen idle */
int shw_pps_gen_busy();
int pps_gen_busy(void);
/* Enables/disables PPS Generator PPS output */
int shw_pps_gen_enable_output(int enable);
int pps_gen_enable_output(int enable);
/* Reads the current time and stores at <seconds,nanoseconds>. */
void shw_pps_gen_get_time(uint64_t * seconds, uint32_t * nanoseconds);
void pps_gen_get_time(uint64_t * seconds, uint32_t * nanoseconds);
/* Sets the time to <seconds,nanoseconds>. */
void shw_pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds);
void pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds);
#endif
#ifndef __SOCKITOWM_H__
#define __SOCKITOWM_H__
#include "sockitowm/ownet.h"
#endif /* __SOCKITOWM_H__ */
#ifndef __UART_H
#define __UART_H
int mprintf(char const *format, ...);
void uart_init();
void uart_init(void);
void uart_write_byte(int b);
void uart_write_string(char *s);
int uart_read_byte(void);
#endif
#ifndef __WRC_H__
#define __WRC_H__
/*
* This header includes all generic prototypes that were missing
* in earlier implementations. For example, the monitor is only
* one function and doesn't deserve an header of its own.
* Also, this brings in very common and needed headers
*/
int mprintf(char const *format, ...)
__attribute__((format(printf,1,2)));
void wrc_mon_gui(void);
void shell_init(void);
int wrc_log_stats(uint8_t onetime);
/* This is in the library, somewhere */
extern int abs(int val);
/* The following from ptp-noposix */
extern void wr_servo_reset(void);
void update_rx_queues(void);
void spll_enable_ptracker(int ref_channel, int enable);
#endif /* __WRC_H__ */
#include <string.h>
#include "endpoint.h"
#include "ipv4.h"
#include "ptpd_netif.h"
......
#include <string.h>
#include <wrc.h>
#include "endpoint.h"
#include "ipv4.h"
......
......@@ -2,6 +2,7 @@
#include <stdint.h>
#include <stdarg.h>
#include <time.h>
#include <wrc.h>
#include "util.h"
......
#include <stdio.h>
#include <time.h>
#include <wrc.h>
#include "board.h"
#include "ptpd_exports.h"
#include "hal_exports.h"
#include "softpll_ng.h"
#include "minic.h"
#include "pps_gen.h"
#include "util.h"
#include "timer.h"
......@@ -15,12 +17,8 @@
extern ptpdexp_sync_state_t cur_servo_state;
extern int wrc_man_phase;
int wrc_mon_gui(void)
void wrc_mon_gui(void)
{
static char *slave_states[] = {
"Uninitialized", "SYNC_SEC", "SYNC_NSEC", "SYNC_PHASE",
"TRACK_PHASE"
};
static uint32_t last = 0;
hexp_port_state_t ps;
int tx, rx;
......@@ -29,7 +27,7 @@ int wrc_mon_gui(void)
uint32_t nsec;
if (timer_get_tics() - last < UI_REFRESH_PERIOD)
return 0;
return;
last = timer_get_tics();
......@@ -150,15 +148,11 @@ int wrc_mon_gui(void)
cprintf(C_GREY, "--");
return 0;
return;
}
int wrc_log_stats(uint8_t onetime)
{
static char *slave_states[] = {
"Uninitialized", "SYNC_SEC", "SYNC_NSEC", "SYNC_PHASE",
"TRACK_PHASE"
};
static uint32_t last = 0;
hexp_port_state_t ps;
int tx, rx;
......
......@@ -3,11 +3,13 @@
Description: launches the WR Core monitor GUI */
#include <string.h>
#include <wrc.h>
#include "shell.h"
#include "eeprom.h"
#include "syscon.h"
extern int measure_t24p(int *value);
extern int measure_t24p(uint32_t *value);
int cmd_calib(const char *args[])
{
......
#include <string.h>
#include <wrc.h>
#include "shell.h"
#include "eeprom.h"
#include "syscon.h"
#include "i2c.h"
int cmd_init(const char *args[])
{
......
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <wrc.h>
#include "softpll_ng.h"
#include "shell.h"
#include "../lib/ipv4.h"
static decode_ip(const char *str, unsigned char *ip)
static void decode_ip(const char *str, unsigned char *ip)
{
int i, x;
......@@ -38,4 +39,5 @@ int cmd_ip(const char *args[])
mprintf("IP-address: %d.%d.%d.%d\n",
ip[0], ip[1], ip[2], ip[3]);
}
return 0;
}
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <wrc.h>
#include "softpll_ng.h"
#include "shell.h"
#include "onewire.h"
#include "endpoint.h"
#include "../lib/ipv4.h"
static decode_mac(const char *str, unsigned char *mac)
static void decode_mac(const char *str, unsigned char *mac)
{
int i, x;
......@@ -44,4 +46,5 @@ int cmd_mac(const char *args[])
mprintf("MAC-address: %x:%x:%x:%x:%x:%x\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return 0;
}
......@@ -5,6 +5,7 @@
#include <errno.h>
#include <string.h>
#include <wrc.h>
#include "shell.h"
#include "wrc_ptp.h"
......
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <wrc.h>
#include "softpll_ng.h"
#include "shell.h"
......
......@@ -5,7 +5,7 @@
#include <errno.h>
#include <string.h>
#include "wrc_ptp.h"
#include "shell.h"
int cmd_ptp(const char *args[])
......
......@@ -11,6 +11,10 @@
detect - detects the transceiver type
*/
#include <string.h>
#include <stdlib.h>
#include <wrc.h>
#include "shell.h"
#include "eeprom.h"
#include "syscon.h"
......
#include "shell.h"
#include <string.h>
#include <wrc.h>
int cmd_stat(const char *args[])
{
......
......@@ -8,6 +8,8 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <wrc.h>
#include "shell.h"
#include "util.h"
......
#include <wrc.h>
#include "shell.h"
#include "syscon.h"
extern const char *build_revision, *build_date;
int cmd_version(const char *args[])
......
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wrc.h>
#include "shell.h"
......@@ -8,7 +9,7 @@
/* Environment-related functions */
static unsigned char env_buf[SH_ENVIRON_SIZE];
static char env_buf[SH_ENVIRON_SIZE];
void env_init()
{
......@@ -45,11 +46,12 @@ static int _env_end()
for (i = 0; i < SH_ENVIRON_SIZE; i++)
if (env_buf[i] == 0xff)
return i;
return 0;
}
int env_set(const char *var, const char *value)
{
unsigned char *vstart = _env_get(var), *p;
char *vstart = _env_get(var), *p;
int end;
if (vstart) { /* entry already present? remove current and append at the end of environment */
......@@ -81,7 +83,7 @@ int env_set(const char *var, const char *value)
int cmd_env(const char *args[])
{
unsigned char *p = env_buf;
char *p = env_buf;
while (*p != 0xff) {
if (*p == 0xaa)
......
......@@ -2,6 +2,7 @@
#include <string.h>
#include <errno.h>
#include <wrc.h>
#include "util.h"
#include "uart.h"
#include "syscon.h"
......@@ -275,7 +276,8 @@ int shell_boot_script(void)
while (1) {
cmd_len = eeprom_init_readcmd(WRPC_FMC_I2C, FMC_EEPROM_ADR,
cmd_buf, SH_MAX_LINE_LEN, next);
(uint8_t *)cmd_buf,
SH_MAX_LINE_LEN, next);
if (cmd_len <= 0) {
if (next == 0)
mprintf("Empty init script...\n");
......
#include <wrc.h>
#include "ownet.h"
#define READ_SCRATCH_CMD 0xaa
......@@ -8,6 +9,8 @@
//#define DEBUG_EEP43 1
static int Copy2Mem43(int portnum, uchar * SerialNum);
int Write43(int portnum, uchar * SerialNum, int page, uchar * page_buffer)
{
uchar rt = FALSE;
......@@ -62,11 +65,9 @@ int Write43(int portnum, uchar * SerialNum, int page, uchar * page_buffer)
return rt;
}
int Copy2Mem43(int portnum, uchar * SerialNum)
static int Copy2Mem43(int portnum, uchar * SerialNum)
{
uchar rt = FALSE;
ushort lastcrc16;
int i;
uchar read_data;
owSerialNum(portnum, SerialNum, FALSE);
......@@ -164,7 +165,6 @@ int ReadMem43(int portnum, uchar * SerialNum, int page, uchar * page_buffer)
uchar rt = FALSE;
ushort lastcrc16;
int i;
ushort target_addr = 0;
uchar read_data;
owSerialNum(portnum, SerialNum, FALSE);
......
......@@ -30,6 +30,7 @@
//
#include <string.h>
#include <wrc.h>
//#include <stdio.h>
#include "ownet.h"
#include "uart.h"
......@@ -314,9 +315,6 @@ void owPrintErrorMsg(FILE * filenum)
char *f = owErrorStack[owErrorPointer].filename;
int err = owGetErrorNum();
//fprintf(filenum,"Error %d: %s line %d: %s\r\n",err,f,l,owErrorMsg[err]);
#else
int err = owGetErrorNum();
//fprintf(filenum,"Error %d: %s\r\n",err,owErrorMsg[err]);
#endif
}
......
......@@ -306,6 +306,8 @@ extern char *owGetErrorMsg(int);
#define OWERROR_LIBUSB_SET_ALTINTERFACE_ERROR 123
#define OWERROR_LIBUSB_NO_ADAPTER_FOUND 124
SMALLINT owInit(void);
// One Wire functions defined in ownetu.c
SMALLINT owFirst(int portnum, SMALLINT do_reset, SMALLINT alarm_only);
SMALLINT owNext(int portnum, SMALLINT do_reset, SMALLINT alarm_only);
......
#include <stdio.h>
#include <inttypes.h>
#include <stdarg.h>
#include <wrc.h>
#define INET_ADDRSTRLEN 16
#include "syscon.h"
......@@ -17,10 +18,12 @@
#include "ptpd.h"
#if 0 /* not used, currently */
static int get_bitslide(int ep)
{
return (pcs_read(16) >> 4) & 0x1f;
}
#endif
struct meas_entry {
int delta_ns;
......@@ -42,7 +45,7 @@ static int meas_phase_range(wr_socket_t * sock, int phase_min, int phase_max,
int phase_step, struct meas_entry *results)
{
char buf[128];
wr_timestamp_t ts_tx, ts_rx, ts_sync;
wr_timestamp_t ts_rx, ts_sync = {0,};
wr_sockaddr_t from;
MsgHeader mhdr;
int setpoint = phase_min, i = 0, phase;
......@@ -63,7 +66,7 @@ static int meas_phase_range(wr_socket_t * sock, int phase_min, int phase_max,
msgUnpackHeader(buf, &mhdr);
if (mhdr.messageType == 0)
ts_sync = ts_rx;
else if (mhdr.messageType == 8) {
else if (mhdr.messageType == 8 && ts_sync.correct) {
MsgFollowUp fup;
msgUnpackFollowUp(buf, &fup);
......@@ -84,6 +87,7 @@ static int meas_phase_range(wr_socket_t * sock, int phase_min, int phase_max,
while (spll_shifter_busy(0)) ;
purge_socket(sock);
ts_sync.correct = 0;
i++;
}
}
......@@ -100,6 +104,7 @@ static int find_transition(struct meas_entry *results, int n, int positive)
&& (results[(i + 1) % n].ahead == positive))
return i;
}
return -1;
}
extern void ptpd_netif_set_phase_transition(wr_socket_t * sock, int phase);
......
......@@ -3,6 +3,7 @@
#include <stdarg.h>
#include <wrc.h>
#include "syscon.h"
#include "uart.h"
#include "endpoint.h"
......@@ -14,6 +15,8 @@
//#include "eeprom.h"
#include "softpll_ng.h"
#include "onewire.h"
#include "pps_gen.h"
#include "sockitowm.h"
#include "shell.h"
#include "lib/ipv4.h"
......@@ -30,9 +33,7 @@ uint32_t cal_phase_transition = 2389;
void wrc_initialize()
{
int ret, i;
uint8_t mac_addr[6], ds18_id[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
char sfp_pn[17];
uint8_t mac_addr[6];
sdb_find_devices();
uart_init();
......@@ -117,8 +118,6 @@ void wrc_debug_printf(int subsys, const char *fmt, ...)