Commit 616aec67 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Some more trace changes. Mostly adding 'channel' to trace interfaces.

Also module enable code for am335x.
parent 74756dbf
......@@ -89,7 +89,7 @@ int trace_interval_set(struct trace *trace, struct timespec *interval, enum trac
return 0;
}
int trace_name_set(struct trace *trace, char *name)
int trace_name_set(struct trace *trace, int channel, char *name)
{
struct trace_pkt *pkt;
......@@ -98,7 +98,7 @@ int trace_name_set(struct trace *trace, char *name)
trace->name = strdup(name);
pkt = trace_packet_new();
trace_packet_name_set(pkt, name);
trace_packet_name_set(pkt, channel, name);
trace_packet_write(trace, pkt);
trace_packet_put(pkt);
......@@ -318,7 +318,7 @@ int trace_packet_timestamp_set(struct trace_pkt *pkt,
return 0;
}
int trace_packet_name_set(struct trace_pkt *pkt, char *name)
int trace_packet_name_set(struct trace_pkt *pkt, int channel, char *name)
{
size_t len = sizeof(struct trace_header) +
sizeof(struct trace_ptype_name_header) +
......@@ -383,8 +383,9 @@ bool trace_check(struct trace *trace)
struct trace_pkt *pkt;
if (trace->name) {
int channel = 0;
pkt = trace_packet_new();
trace_packet_name_set(pkt, trace->name);
trace_packet_name_set(pkt, channel, trace->name);
trace_packet_write(trace, pkt);
trace_packet_put(pkt);
}
......@@ -498,6 +499,7 @@ int trace_handle_recv(struct trace *trace)
}
case TRACE_PTYPE_NAME: {
char *name;
int channel;
name = (void*)pkt->data +
sizeof(struct trace_ptype_name_header) +
......@@ -505,9 +507,10 @@ int trace_handle_recv(struct trace *trace)
trace->name_set = true;
trace->name = strdup(name);
channel = pkt->data[sizeof(struct trace_header)];
if (trace->handler_name) {
trace->handler_name(trace, name);
trace->handler_name(trace, channel, name);
}
break;
}
......
/*
trace support
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2011
Copyright Jeroen Vreeken (jeroen@vreeken.net), 2008, 2011, 2015
Copyright Stichting C.A. Muller Radioastronomiestation, 2008, 2011
This program is free software: you can redistribute it and/or modify
......@@ -127,7 +127,7 @@ struct trace {
enum trace_value_type type);
void (*handler_value)(struct trace *, int channel,
struct trace_value *value);
void (*handler_name)(struct trace *, char *name);
void (*handler_name)(struct trace *, int channel, char *name);
void (*handler_close)(struct trace *);
size_t (*handler_read)(struct trace *, void *buf, size_t len);
void (*handler_capabilities)(struct trace *, unsigned long cap);
......@@ -150,7 +150,7 @@ void trace_initialize_fd(struct trace *trace, int fd);
int trace_connect(struct trace *trace);
int trace_interval_set(struct trace *trace,
struct timespec *interval, enum trace_interval_type type);
int trace_name_set(struct trace *trace, char *name);
int trace_name_set(struct trace *trace, int channel, char *name);
void trace_autorecover(struct trace *trace, bool value);
void trace_close(struct trace *trace);
void trace_free(struct trace *trace);
......@@ -175,7 +175,7 @@ int trace_packet_interval_set(struct trace_pkt *pkt,
struct timespec *interval, enum trace_interval_type type);
int trace_packet_timestamp_set(struct trace_pkt *pkt,
struct timespec *timestamp);
int trace_packet_name_set(struct trace_pkt *pkt, char *name);
int trace_packet_name_set(struct trace_pkt *pkt, int channel, char *name);
int trace_packet_type_set(struct trace_pkt *pkt, enum trace_value_type type);
int trace_packet_value_add(struct trace_pkt *pkt, int channel,
struct trace_value *value, enum trace_value_type type);
......
......@@ -67,7 +67,7 @@ static void open_output(void)
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
pkt = trace_packet_new();
trace_packet_name_set(pkt, tracename);
trace_packet_name_set(pkt, 0, tracename);
trace_packet_write(trace, pkt);
trace_packet_write_fd(fd_file, pkt);
trace_packet_put(pkt);
......
/*
trace definitions
Copyright Jeroen Vreeken (jeroen@vreeken.net), 2013
Copyright Jeroen Vreeken (jeroen@vreeken.net), 2013, 2015
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
......@@ -165,7 +165,7 @@ int main(int argc, char **argv)
}
pkt = trace_packet_new();
trace_packet_name_set(pkt, tracename);
trace_packet_name_set(pkt, 0, tracename);
trace_packet_write(trace, pkt);
trace_packet_put(pkt);
}
......
......@@ -118,7 +118,7 @@ int main(int argc, char **argv)
trace_packet_put(pkt);
pkt = trace_packet_new();
trace_packet_name_set(pkt, tracename);
trace_packet_name_set(pkt, 0, tracename);
trace_packet_write(trace, pkt);
trace_packet_put(pkt);
......
......@@ -263,7 +263,7 @@ int main(int argc, char **argv)
return 1;
}
t->trace->private = &traces[trace_nr];
trace_name_set(t->trace, tracename);
trace_name_set(t->trace, 0, tracename);
t->tmpfilename = malloc(100);
sprintf(t->tmpfilename,
......
......@@ -465,7 +465,7 @@ static void start_trace(struct libwebsocket *wsi, int freq, char *variable)
if (!trace)
return;
trace_name_set(trace, variable);
trace_name_set(trace, 0, variable);
free(variable);
trace_autorecover(trace, true);
......
......@@ -390,8 +390,8 @@ int main(int argc, char **argv)
traceval_az = trace_open(trace_host, trace_port);
traceval_el = trace_open(trace_host, trace_port);
trace_name_set(traceval_az, az_trace_name);
trace_name_set(traceval_el, el_trace_name);
trace_name_set(traceval_az, 0, az_trace_name);
trace_name_set(traceval_el, 0, el_trace_name);
trace_autorecover(traceval_az, true);
trace_autorecover(traceval_el, true);
traceval_az->handler_interval = handler_interval;
......
/*
Copyright Jeroen Vreeken (jeroen@vreeken.net), 2013, 2014
Copyright Jeroen Vreeken (jeroen@vreeken.net), 2013, 2014, 2015
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -200,7 +200,7 @@ static void start_trace(struct plugin_private *priv, int freq, char *variable)
trace = trace_open("localhost", 10000);
trace_name_set(trace, variable);
trace_name_set(trace, 0, variable);
free(variable);
trace_autorecover(trace, true);
......
......@@ -436,7 +436,7 @@ static struct trace *server_find(char *name)
struct trace_pkt *pkt;
trace = trace_open(tr_host, tr_port);
trace_name_set(trace, name);
trace_name_set(trace, 0, name);
trace->interval_type = TRACE_INTERVAL_TYPE_INTERVAL;
......
......@@ -88,3 +88,40 @@ err_open:
err_calloc:
return NULL;
}
static void *cm_base;
static int am335x_cm_init(void)
{
cm_base = am335x_mem(AM335X_CM_BASE, AM335X_CM_SIZE);
return cm_base == NULL;
}
int am335x_cm_enable(size_t cm_off)
{
uint32_t reg;
if (!cm_base) {
if (am335x_cm_init()) {
log_send(LOG_T_ERROR, "am335x: CM init failed");
return -1;
}
}
reg = am335x_read32(cm_base, cm_off);
log_send(LOG_T_DEBUG, "am335x: CM %x: 0x%08x", cm_off, reg);
reg &= AM335X_CM_IDLEST_MASK;
if (reg == AM335X_CM_IDLEST_FUNCTIONAL)
log_send(LOG_T_DEBUG, "am335x: CM %x: functional", cm_off);
if (reg == AM335X_CM_IDLEST_TRANSITION)
log_send(LOG_T_DEBUG, "am335x: CM %x: transition", cm_off);
if (reg == AM335X_CM_IDLEST_IDLE)
log_send(LOG_T_DEBUG, "am335x: CM %x: idle", cm_off);
if (reg == AM335X_CM_IDLEST_DISABLED)
log_send(LOG_T_DEBUG, "am335x: CM %x: disabled", cm_off);
log_send(LOG_T_DEBUG, "am335x: CM %x: enabling", cm_off);
am335x_write32(cm_base, cm_off, AM335X_CM_MODULEMODE_ENABLE);
}
......@@ -23,6 +23,23 @@
#define AM335X_SYSCLK 100000000
#define AM335X_CM_BASE 0x44e00000
#define AM335X_CM_SIZE 0x00000b00
#define AM335X_CM_PER_BASE 0x44e00000
#define AM335X_CM_PER_SIZE 0x00000400
#define AM335X_CM_WKUP_BASE 0x44e00400
#define AM335X_CM_WKUP_SIZE 0x00000100
#define AM335X_CM_IDLEST_MASK 0x00030000
#define AM335X_CM_IDLEST_FUNCTIONAL 0x0
#define AM335X_CM_IDLEST_TRANSITION 0x1
#define AM335X_CM_IDLEST_IDLE 0x2
#define AM335X_CM_IDLEST_DISABLED 0x3
#define AM335X_CM_MODULEMODE_DISABLE 0x00000000
#define AM335X_CM_MODULEMODE_ENABLE 0x00000002
#define AM335X_CM_WKUP_ADC_TSC_CLKCTRL 0x000004bc
#define AM335X_ADC_BASE 0x44e0d000
#define AM335X_ADC_SIZE 0x00002000
......@@ -295,6 +312,7 @@ static inline void am335x_write16(void *base, size_t reg_offset, uint16_t value)
void *am335x_mem(size_t base, size_t size);
int am335x_cm_enable(size_t cm_off);
#endif /* _INCLUDE_AM335X_ */
......@@ -112,7 +112,12 @@ static struct controller_block * block_am335x_adc_create(char *name, int argc, v
struct controller_block *adc;
void *base;
uint32_t reg;
if (am335x_cm_enable(AM335X_CM_WKUP_ADC_TSC_CLKCTRL)) {
log_send(LOG_T_ERROR, "%s: Enabling module failed", name);
return NULL;
}
base = am335x_mem(AM335X_ADC_BASE, AM335X_ADC_SIZE);
if (!base) {
log_send(LOG_T_ERROR, "%s: Mapping ADC failed", name);
......
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2007, 2013
Copyright Jeroen Vreeken (jeroen@vreeken.net), 2007, 2013, 2015
Copyright Stichting C.A. Muller Radioastronomiestation, 2007, 2013
This program is free software: you can redistribute it and/or modify
......@@ -297,7 +297,7 @@ static void handler_close(struct trace *trace)
hdl->free = 1;
}
static void handler_name(struct trace *trace, char *name)
static void handler_name(struct trace *trace, int channel, char *name)
{
struct trace_hdl *hdl = trace->private;
int j;
......
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