Commit f1edab08 authored by Adam Wujek's avatar Adam Wujek 💬

Merge branch "adam-wrpc-dump"

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parents 2b3cc5e4 5f514c38
...@@ -101,6 +101,8 @@ CFLAGS = $(cflags-y) -Wall -Wstrict-prototypes \ ...@@ -101,6 +101,8 @@ CFLAGS = $(cflags-y) -Wall -Wstrict-prototypes \
-ffunction-sections -fdata-sections -Os -Wmissing-prototypes \ -ffunction-sections -fdata-sections -Os -Wmissing-prototypes \
-include include/wrc.h -ggdb -include include/wrc.h -ggdb
ASFLAGS = -I.
LDFLAGS = $(ldflags-y) \ LDFLAGS = $(ldflags-y) \
-Wl,--gc-sections -Os -lgcc -lc -Wl,--gc-sections -Os -lgcc -lc
...@@ -114,6 +116,8 @@ OUTPUT := $(OUTPUT-y) ...@@ -114,6 +116,8 @@ OUTPUT := $(OUTPUT-y)
GIT_VER = $(shell git describe --always --dirty | sed 's;^wr-switch-sw-;;') GIT_VER = $(shell git describe --always --dirty | sed 's;^wr-switch-sw-;;')
GIT_USR = $(shell git config --get-all user.name) GIT_USR = $(shell git config --get-all user.name)
export GIT_VER
export GIT_USR
# if user.name is not available from git use user@hostname # if user.name is not available from git use user@hostname
ifeq ($(GIT_USR),) ifeq ($(GIT_USR),)
......
...@@ -74,7 +74,10 @@ ...@@ -74,7 +74,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#define __ASSEMBLY__
#include "include/revision.h"
#include "ppsi/proto-ext-whiterabbit/wr-api.h"
#include "arch/lm32/crt0.h"
/* From include/sys/signal.h */ /* From include/sys/signal.h */
#define SIGINT 2 /* interrupt */ #define SIGINT 2 /* interrupt */
#define SIGTRAP 5 /* trace trap */ #define SIGTRAP 5 /* trace trap */
...@@ -83,7 +86,6 @@ ...@@ -83,7 +86,6 @@
//#define MICO32_FULL_CONTEXT_SAVE_RESTORE //#define MICO32_FULL_CONTEXT_SAVE_RESTORE
/* Exception handlers - Must be 32 bytes long. */ /* Exception handlers - Must be 32 bytes long. */
.section .boot, "ax", @progbits .section .boot, "ax", @progbits
...@@ -103,19 +105,36 @@ _reset_handler: ...@@ -103,19 +105,36 @@ _reset_handler:
nop nop
.size _reset_handler, .-_reset_handler .size _reset_handler, .-_reset_handler
.org 0x80 .org WRPC_MARK
/* Used by the dumping tool to identify byte ordering */ /* Used by the dumping tool to identify byte ordering */
.ascii "WRPC----" .ascii "WRPC----"
.int 0x01234567 .int 0x01234567
.short 0x89ab, 0xcdef .short 0x89ab, 0xcdef
/* Pointer to structures, for the dumping tool */ /* Pointer to structures, for the dumping tool */
.word softpll, fifo_log, ppi_static, 0 .org SOFTPLL_PADDR
.word softpll
.org FIFO_LOG_PADDR
.word fifo_log
.org PPI_STATIC_PADDR
.word ppi_static
.org STATS_PADDR
.word stats
.org 0xa0 .org UPTIME_SEC_ADDR
.global uptime_sec .global uptime_sec
uptime_sec: uptime_sec:
.word 0 .word 0
.org VERSION_WRPC_ADDR
.global version_wrpc
version_wrpc:
.byte WRPC_SHMEM_VERSION
.org VERSION_PPSI_ADDR
.global version_ppsi
version_ppsi:
.byte WRS_PPSI_SHMEM_VERSION
.extern _irq_entry .extern _irq_entry
.org 0xc0 .org 0xc0
.global _interrupt_handler .global _interrupt_handler
......
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2017 CERN (www.cern.ch)
* Author: Adam Wujek <adam.wujek@cern.ch>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#ifndef __CRT0_H__
#define __CRT0_H__
/* offsets for crt0.s */
#define WRPC_MARK 0x80
#define SOFTPLL_PADDR 0x90
#define FIFO_LOG_PADDR 0x94
#define PPI_STATIC_PADDR 0x98
#define STATS_PADDR 0x9c
#define UPTIME_SEC_ADDR 0xa0
#define VERSION_WRPC_ADDR 0xa4
#define VERSION_PPSI_ADDR 0xa5
#endif /* __CRT0_H__ */
...@@ -247,6 +247,28 @@ struct dump_info dump_info[] = { ...@@ -247,6 +247,28 @@ struct dump_info dump_info[] = {
DUMP_FIELD(uint16_t, tag_count), DUMP_FIELD(uint16_t, tag_count),
/* FIXME: aux_state and ptracker_state -- variable-len arrays */ /* FIXME: aux_state and ptracker_state -- variable-len arrays */
#undef DUMP_STRUCT
#define DUMP_STRUCT struct spll_stats
DUMP_HEADER("stats"),
DUMP_FIELD(uint32_t, magic),
DUMP_FIELD(int, ver),
DUMP_FIELD(int, sequence),
DUMP_FIELD(int, mode),
DUMP_FIELD(int, irq_cnt),
DUMP_FIELD(int, seq_state),
DUMP_FIELD(int, align_state),
DUMP_FIELD(int, H_lock),
DUMP_FIELD(int, M_lock),
DUMP_FIELD(int, H_y),
DUMP_FIELD(int, M_y),
DUMP_FIELD(int, del_cnt),
DUMP_FIELD(int, start_cnt),
DUMP_FIELD_SIZE(char, commit_id, 32),
DUMP_FIELD_SIZE(char, build_date, 16),
DUMP_FIELD_SIZE(char, build_time, 16),
DUMP_FIELD_SIZE(char, build_by, 32),
DUMP_HEADER("end"), DUMP_HEADER("end"),
}; };
...@@ -15,6 +15,7 @@ enum dump_type { ...@@ -15,6 +15,7 @@ enum dump_type {
dump_type_char, /* for zero-terminated strings */ dump_type_char, /* for zero-terminated strings */
dump_type_bina, /* for binary stull in MAC format */ dump_type_bina, /* for binary stull in MAC format */
/* normal types follow */ /* normal types follow */
dump_type_uint8_t,
dump_type_uint32_t, dump_type_uint32_t,
dump_type_uint16_t, dump_type_uint16_t,
dump_type_int, dump_type_int,
......
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2017 CERN (www.cern.ch)
* Author: Adam Wujek <adam.wujek@cern.ch>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#ifndef __REVISION_H__ #ifndef __REVISION_H__
#define __REVISION_H__ #define __REVISION_H__
/* Please increment WRPC_SHMEM_VERSION if you change any exported data
* structure */
#define WRPC_SHMEM_VERSION 1 /* first version */
#ifndef __ASSEMBLY__
extern const char *build_revision; extern const char *build_revision;
extern const char *build_date; extern const char *build_date;
extern const char *build_time; extern const char *build_time;
extern const char *build_by; extern const char *build_by;
#endif
#endif /* __REVISION_H__ */ #endif /* __REVISION_H__ */
ppsi @ 0e0abb05
Subproject commit 8ff1442e9e8caaa016f0b8fb9903f3c28a57077a Subproject commit 0e0abb05d413c8c1368c393c34d2da8ac7281463
...@@ -116,6 +116,7 @@ void check_vco_frequencies(void); ...@@ -116,6 +116,7 @@ void check_vco_frequencies(void);
* Aux and main state: * Aux and main state:
* used to be in .c file, but we need it here for memory dumping * used to be in .c file, but we need it here for memory dumping
*/ */
/* NOTE: Please increment WRPC_SHMEM_VERSION if you change this structure */
struct spll_aux_state { struct spll_aux_state {
int seq_state; int seq_state;
int32_t phase_target; int32_t phase_target;
...@@ -125,7 +126,7 @@ struct spll_aux_state { ...@@ -125,7 +126,7 @@ struct spll_aux_state {
} pll; } pll;
}; };
/* NOTE: Please increment WRPC_SHMEM_VERSION if you change this structure */
struct softpll_state { struct softpll_state {
int mode; int mode;
int seq_state; int seq_state;
...@@ -142,6 +143,7 @@ struct softpll_state { ...@@ -142,6 +143,7 @@ struct softpll_state {
struct spll_ptracker_state ptrackers[MAX_PTRACKERS]; struct spll_ptracker_state ptrackers[MAX_PTRACKERS];
}; };
/* NOTE: Please increment WRPC_SHMEM_VERSION if you change this structure */
struct spll_fifo_log { struct spll_fifo_log {
uint32_t trr; uint32_t trr;
uint32_t tstamp; uint32_t tstamp;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "softpll_ng.h" #include "softpll_ng.h"
/* NOTE: Please increment WRPC_SHMEM_VERSION if you change this structure */
struct spll_external_state { struct spll_external_state {
struct spll_helper_state *helper; struct spll_helper_state *helper;
struct spll_main_state *main; struct spll_main_state *main;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* clamped to this value. */ * clamped to this value. */
#define HELPER_ERROR_CLAMP 150000 #define HELPER_ERROR_CLAMP 150000
/* NOTE: Please increment WRPC_SHMEM_VERSION if you change this structure */
struct spll_helper_state { struct spll_helper_state {
int p_adder; /* anti wrap-around adder */ int p_adder; /* anti wrap-around adder */
int p_setpoint, tag_d0; int p_setpoint, tag_d0;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define __SPLL_MAIN_H #define __SPLL_MAIN_H
/* State of the Main PLL */ /* State of the Main PLL */
/* NOTE: Please increment WRPC_SHMEM_VERSION if you change this structure */
struct spll_main_state { struct spll_main_state {
int state; int state;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#ifndef __SPLL_PTRACKER_H #ifndef __SPLL_PTRACKER_H
#define __SPLL_PTRACKER_H #define __SPLL_PTRACKER_H
/* NOTE: Please increment WRPC_SHMEM_VERSION if you change this structure */
struct spll_ptracker_state { struct spll_ptracker_state {
int enabled, id; int enabled, id;
int n_avg, acc, avg_count, preserve_sign; int n_avg, acc, avg_count, preserve_sign;
......
...@@ -43,9 +43,10 @@ sdb-wrpc.bin: sdbfs ...@@ -43,9 +43,10 @@ sdb-wrpc.bin: sdbfs
$(SDBFS)/gensdbfs $< $@ $(SDBFS)/gensdbfs $< $@
wrpc-dump: wrpc-dump.c dump-info-host.o wrpc-dump: wrpc-dump.c dump-info-host.o
$(CC) $(CFLAGS) -I../ppsi/include -I../ppsi/arch-wrpc/include \ $(CC) $(CFLAGS) -I../ppsi/include -I../ppsi/arch-wrpc/include -I.. \
-I ../softpll \ -I ../softpll \
$^ -o $@ $^ -o $@ \
-D__GIT_VER__="\"$(GIT_VER)\"" -D__GIT_USR__="\"$(GIT_USR)\""
pfilter-builder: pfilter-builder.c pfilter-builder: pfilter-builder.c
$(CC) $(CFLAGS) -include ../include/generated/autoconf.h \ $(CC) $(CFLAGS) -include ../include/generated/autoconf.h \
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include <softpll_ng.h> #include <softpll_ng.h>
#include <revision.h>
#include <arch/lm32/crt0.h>
#include <dump-info.h> #include <dump-info.h>
/* We have a problem: ppsi is built for wrpc, so it has ntoh[sl] wrong */ /* We have a problem: ppsi is built for wrpc, so it has ntoh[sl] wrong */
...@@ -51,10 +53,12 @@ static long wrpc_get_l32(void *p) ...@@ -51,10 +53,12 @@ static long wrpc_get_l32(void *p)
return *p32; return *p32;
return __bswap_32(*p32); return __bswap_32(*p32);
} }
static int wrpc_get_i32(void *p) static int wrpc_get_i32(void *p)
{ {
return wrpc_get_l32(p); return wrpc_get_l32(p);
} }
static int wrpc_get_16(void *p) static int wrpc_get_16(void *p)
{ {
uint16_t *p16 = p; uint16_t *p16 = p;
...@@ -64,6 +68,12 @@ static int wrpc_get_16(void *p) ...@@ -64,6 +68,12 @@ static int wrpc_get_16(void *p)
return __bswap_16(*p16); return __bswap_16(*p16);
} }
static uint8_t wrpc_get_8(void *p)
{
uint8_t *p8 = p;
return *p8;
}
void dump_one_field(void *addr, struct dump_info *info) void dump_one_field(void *addr, struct dump_info *info)
{ {
...@@ -112,6 +122,7 @@ void dump_one_field(void *addr, struct dump_info *info) ...@@ -112,6 +122,7 @@ void dump_one_field(void *addr, struct dump_info *info)
case dump_type_Integer8: case dump_type_Integer8:
case dump_type_Enumeration8: case dump_type_Enumeration8:
case dump_type_Boolean: case dump_type_Boolean:
case dump_type_uint8_t:
printf("%i\n", *(unsigned char *)p); printf("%i\n", *(unsigned char *)p);
break; break;
case dump_type_UInteger16: case dump_type_UInteger16:
...@@ -217,9 +228,18 @@ unsigned long wrpc_get_pointer(void *base, char *s_name, char *f_name) ...@@ -217,9 +228,18 @@ unsigned long wrpc_get_pointer(void *base, char *s_name, char *f_name)
return 0; return 0;
} }
void print_version(void)
{
fprintf(stderr, "Built in wrpc-sw repo ver:%s, by %s on %s %s\n",
__GIT_VER__, __GIT_USR__, __TIME__, __DATE__);
fprintf(stderr, "Supported WRPC structures version %d\n",
WRPC_SHMEM_VERSION);
fprintf(stderr, "Supported PPSI structures version %d\n",
WRS_PPSI_SHMEM_VERSION);
}
/* all of these are 0 by default */ /* all of these are 0 by default */
unsigned long spll_off, fifo_off, ppi_off, ppg_off, servo_off, ds_off; unsigned long spll_off, fifo_off, ppi_off, ppg_off, servo_off, ds_off,
stats_off;
/* Use: wrs_dump_memory <file> <hex-offset> <name> */ /* Use: wrs_dump_memory <file> <hex-offset> <name> */
int main(int argc, char **argv) int main(int argc, char **argv)
...@@ -230,6 +250,7 @@ int main(int argc, char **argv) ...@@ -230,6 +250,7 @@ int main(int argc, char **argv)
struct stat st; struct stat st;
char *dumpname = ""; char *dumpname = "";
char c; char c;
uint8_t version_wrpc, version_ppsi;
if (argc != 4 && argc != 2) { if (argc != 4 && argc != 2) {
fprintf(stderr, "%s: use \"%s <file> <offset> <name>\n", fprintf(stderr, "%s: use \"%s <file> <offset> <name>\n",
...@@ -237,7 +258,8 @@ int main(int argc, char **argv) ...@@ -237,7 +258,8 @@ int main(int argc, char **argv)
fprintf(stderr, fprintf(stderr,
"\"name\" is one of pll, fifo, ppg, ppi, servo_state" "\"name\" is one of pll, fifo, ppg, ppi, servo_state"
" or ds for data-sets. \"ds\" gets a ppg offset\n"); " or ds for data-sets. \"ds\" gets a ppg offset\n");
fprintf(stderr, "But with a new binary, just pass <file>\n"); fprintf(stderr, "But with a new binary, just pass <file>\n\n");
print_version();
exit(1); exit(1);
} }
...@@ -274,7 +296,7 @@ int main(int argc, char **argv) ...@@ -274,7 +296,7 @@ int main(int argc, char **argv)
} }
/* In case we have a "new" binary file, use such information */ /* In case we have a "new" binary file, use such information */
if (!strncmp(mapaddr + 0x80, "CPRW", 4)) if (!strncmp(mapaddr + WRPC_MARK, "CPRW", 4))
setenv("WRPC_SPEC", "yes", 1); setenv("WRPC_SPEC", "yes", 1);
/* If the dump file needs "spec" byte order, fix it all */ /* If the dump file needs "spec" byte order, fix it all */
...@@ -289,12 +311,14 @@ int main(int argc, char **argv) ...@@ -289,12 +311,14 @@ int main(int argc, char **argv)
if (argc == 4) if (argc == 4)
dumpname = argv[3]; dumpname = argv[3];
/* If we have a new binary file, pick the pointers */ /* If we have a new binary file, pick the pointers
if (!strncmp(mapaddr + 0x80, "WRPC----", 8)) { * Magic numbers are taken from crt0.S or disassembly of wrc.bin */
if (!strncmp(mapaddr + WRPC_MARK, "WRPC----", 8)) {
spll_off = wrpc_get_l32(mapaddr + 0x90); spll_off = wrpc_get_l32(mapaddr + SOFTPLL_PADDR);
fifo_off = wrpc_get_l32(mapaddr + 0x94); fifo_off = wrpc_get_l32(mapaddr + FIFO_LOG_PADDR);
ppi_off = wrpc_get_l32(mapaddr + 0x98); ppi_off = wrpc_get_l32(mapaddr + PPI_STATIC_PADDR);
stats_off = wrpc_get_l32(mapaddr + STATS_PADDR);
if (ppi_off) { /* This is 0 for wrs */ if (ppi_off) { /* This is 0 for wrs */
ppg_off = wrpc_get_pointer(mapaddr + ppi_off, ppg_off = wrpc_get_pointer(mapaddr + ppi_off,
"pp_instance", "glbs"); "pp_instance", "glbs");
...@@ -304,6 +328,20 @@ int main(int argc, char **argv) ...@@ -304,6 +328,20 @@ int main(int argc, char **argv)
} }
} }
/* Check the version of wrpc and ppsi structures */
version_wrpc = wrpc_get_8(mapaddr + VERSION_WRPC_ADDR);
version_ppsi = wrpc_get_8(mapaddr + VERSION_PPSI_ADDR);
if (version_wrpc != WRPC_SHMEM_VERSION) {
printf("Unsupported version of WRPC structures! Expected %d, "
"but read %d\n", WRPC_SHMEM_VERSION, version_wrpc);
exit(1);
}
if (version_ppsi != WRS_PPSI_SHMEM_VERSION) {
printf("Unsupported version of PPSI structures! Expected %d, "
"but read %d\n", WRS_PPSI_SHMEM_VERSION, version_ppsi);
exit(1);
}
#define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x) #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
/* Now check the "name" to be dumped */ /* Now check the "name" to be dumped */
...@@ -370,6 +408,12 @@ int main(int argc, char **argv) ...@@ -370,6 +408,12 @@ int main(int argc, char **argv)
dump_many_fields(mapaddr + newoffset, "DSTimeProperties"); dump_many_fields(mapaddr + newoffset, "DSTimeProperties");
} }
if (!strcmp(dumpname, "stats"))
stats_off = offset;
if (stats_off) {
printf("stats at 0x%lx\n", stats_off);
dump_many_fields(mapaddr + stats_off, "stats");
}
exit(0); exit(0);
} }
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