summaryrefslogtreecommitdiff
path: root/code/ecp/fe310
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2018-03-15 21:37:11 +0100
committerUros Majstorovic <majstor@majstor.org>2018-03-15 21:37:11 +0100
commit8755ad4c0b0652f16d3505ed72ed3d8310a35c6f (patch)
tree6d7c3b93563bf64b811bb198e13ebbe7d7907e67 /code/ecp/fe310
parentb00f381106c941ea03e5ea04dc08e6c4b9e582fa (diff)
removed *IFace from context
Diffstat (limited to 'code/ecp/fe310')
-rw-r--r--code/ecp/fe310/time.c14
-rw-r--r--code/ecp/fe310/transport.c35
2 files changed, 21 insertions, 28 deletions
diff --git a/code/ecp/fe310/time.c b/code/ecp/fe310/time.c
index 4b8b2a7..fedd23a 100644
--- a/code/ecp/fe310/time.c
+++ b/code/ecp/fe310/time.c
@@ -1,25 +1,21 @@
#include <core.h>
+#include <tr.h>
#include <eos/timer.h>
#include "encoding.h"
#include "platform.h"
-static ecp_cts_t t_abstime_ms(ecp_cts_t msec) {
+ecp_cts_t ecp_tm_abstime_ms(ecp_cts_t msec) {
volatile uint64_t *mtime = (uint64_t *) (CLINT_CTRL_ADDR + CLINT_MTIME);
uint64_t now_ms = *mtime * 1000 / RTC_FREQ;
return now_ms + msec;
}
-static void t_timer_set(ecp_cts_t next) {
+void ecp_tm_sleep_ms(ecp_cts_t msec) {}
+
+void ecp_tm_timer_set(ecp_cts_t next) {
uint32_t tick = next * (uint64_t)RTC_FREQ / 1000;
eos_timer_set(tick, 1);
}
-
-int ecp_time_init(ECPTimeIface *t) {
- t->init = 1;
- t->abstime_ms = t_abstime_ms;
- t->timer_set = t_timer_set;
- return 0;
-}
diff --git a/code/ecp/fe310/transport.c b/code/ecp/fe310/transport.c
index 5bffda9..3686e66 100644
--- a/code/ecp/fe310/transport.c
+++ b/code/ecp/fe310/transport.c
@@ -1,23 +1,28 @@
#include <core.h>
+#include <tr.h>
#include <eos/eos.h>
#include <eos/net.h>
-static int t_addr_eq(ECPNetAddr *addr1, ECPNetAddr *addr2) {
+int ecp_tr_addr_eq(ECPNetAddr *addr1, ECPNetAddr *addr2) {
if (addr1->port != addr2->port) return 0;
if (memcmp(addr1->host, addr2->host, sizeof(addr1->host)) != 0) return 0;
return 1;
}
-static int t_open(int *sock, void *addr_s) {
+int ecp_tr_addr_set(ECPNetAddr *addr, void *addr_s) {
+ return ECP_ERR;
+}
+
+int ecp_tr_open(int *sock, void *addr_s) {
*sock = 0;
return ECP_OK;
}
-static void t_close(int *sock) {
+void ecp_tr_close(int *sock) {
}
-static ssize_t t_send(int *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr *addr, unsigned char flags) {
+ssize_t ecp_tr_send(int *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr *addr, unsigned char flags) {
unsigned char *buf = NULL;
size_t addr_len = sizeof(addr->host) + sizeof(addr->port);
uint16_t buf_size = msg_size + addr_len;
@@ -41,32 +46,24 @@ static ssize_t t_send(int *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr
return msg_size;
}
-static void t_buf_free(ECP2Buffer *b, unsigned char flags) {
+ssize_t ecp_tr_recv(int *sock, ECPBuffer *packet, ECPNetAddr *addr, int timeout) {
+ return ECP_ERR;
+}
+
+void ecp_tr_buf_free(ECP2Buffer *b, unsigned char flags) {
size_t addr_len = ECP_IPv4_ADDR_SIZE + sizeof(uint16_t);
if (b && b->packet && b->packet->buffer) eos_net_free(b->packet->buffer-addr_len, flags & ECP_SEND_FLAG_MORE);
}
-static void t_buf_flag_set(ECP2Buffer *b, unsigned char flags) {
+void ecp_tr_buf_flag_set(ECP2Buffer *b, unsigned char flags) {
size_t addr_len = ECP_IPv4_ADDR_SIZE + sizeof(uint16_t);
if (flags & ECP_SEND_FLAG_MORE) {
if (b && b->packet && b->packet->buffer) eos_net_reserve(b->packet->buffer-addr_len);
}
}
-static void t_buf_flag_clear(ECP2Buffer *b, unsigned char flags) {
+void ecp_tr_buf_flag_clear(ECP2Buffer *b, unsigned char flags) {
if (flags & ECP_SEND_FLAG_MORE) {
eos_net_release(1);
}
}
-
-int ecp_transport_init(ECPTransportIface *t) {
- t->init = 1;
- t->open = t_open;
- t->close = t_close;
- t->send = t_send;
- t->addr_eq = t_addr_eq;
- t->buf_free = t_buf_free;
- t->buf_flag_set = t_buf_flag_set;
- t->buf_flag_clear = t_buf_flag_clear;
- return ECP_OK;
-}