summaryrefslogtreecommitdiff
path: root/code/ecp
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2019-10-13 02:05:03 +0200
committerUros Majstorovic <majstor@majstor.org>2019-10-13 02:05:03 +0200
commit8c6c68e92d6b4c8aa5e2fcc784ed52da40845acc (patch)
tree0251bea9be01701c488f9d8719b52eeb2a64855d /code/ecp
parent2a39fdf6d943f5738ba174368053a86304b0d8fa (diff)
net refactor; rename cmd -> type
Diffstat (limited to 'code/ecp')
-rw-r--r--code/ecp/fe310/time.c7
-rw-r--r--code/ecp/fe310/transport.c6
2 files changed, 9 insertions, 4 deletions
diff --git a/code/ecp/fe310/time.c b/code/ecp/fe310/time.c
index fedd23a..995b4f2 100644
--- a/code/ecp/fe310/time.c
+++ b/code/ecp/fe310/time.c
@@ -13,7 +13,12 @@ ecp_cts_t ecp_tm_abstime_ms(ecp_cts_t msec) {
return now_ms + msec;
}
-void ecp_tm_sleep_ms(ecp_cts_t msec) {}
+void ecp_tm_sleep_ms(ecp_cts_t msec) {
+ volatile uint64_t *mtime = (uint64_t *) (CLINT_CTRL_ADDR + CLINT_MTIME);
+
+ uint64_t now_ms = *mtime * 1000 / RTC_FREQ;
+ while (*mtime * 1000 / RTC_FREQ < now_ms + msec);
+}
void ecp_tm_timer_set(ecp_cts_t next) {
uint32_t tick = next * (uint64_t)RTC_FREQ / 1000;
diff --git a/code/ecp/fe310/transport.c b/code/ecp/fe310/transport.c
index f728792..61d3355 100644
--- a/code/ecp/fe310/transport.c
+++ b/code/ecp/fe310/transport.c
@@ -28,12 +28,12 @@ ssize_t ecp_tr_send(int *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr *a
unsigned char *buf = NULL;
size_t addr_len = sizeof(addr->host) + sizeof(addr->port);
uint16_t buf_size = msg_size + addr_len;
- unsigned char cmd = EOS_NET_CMD_PKT;
+ unsigned char type = EOS_NET_MTYPE_SOCK;
int rv;
flags |= _flags;
if (flags & ECP_SEND_FLAG_MORE) {
- cmd |= EOS_NET_CMD_FLAG_ONEW;
+ type |= EOS_NET_MTYPE_FLAG_ONEW;
}
if (flags & ECP_SEND_FLAG_REPLY) {
if (packet && packet->buffer) {
@@ -47,7 +47,7 @@ ssize_t ecp_tr_send(int *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr *a
if (buf == NULL) return ECP_ERR;
memcpy(buf, addr->host, sizeof(addr->host));
memcpy(buf+sizeof(addr->host), &addr->port, sizeof(addr->port));
- rv = eos_net_send(cmd, buf, buf_size);
+ rv = eos_net_send(type, buf, buf_size);
if (rv) return ECP_ERR_SEND;
return msg_size;
}