summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/dev/net.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-09-04 18:18:59 +0200
committerUros Majstorovic <majstor@majstor.org>2022-09-04 18:18:59 +0200
commitc286437474becda19c255efa3ede6beb0f2292d9 (patch)
tree189a9c91255726c2445946e642e5b23c7363314c /fw/fe310/eos/dev/net.c
parent2b446dda5db1df77b9951d2c1908259076b1fbe1 (diff)
moved critical functions to itim
Diffstat (limited to 'fw/fe310/eos/dev/net.c')
-rw-r--r--fw/fe310/eos/dev/net.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/fw/fe310/eos/dev/net.c b/fw/fe310/eos/dev/net.c
index 6114485..3811368 100644
--- a/fw/fe310/eos/dev/net.c
+++ b/fw/fe310/eos/dev/net.c
@@ -34,7 +34,7 @@
static EOSBufQ net_buf_q;
static unsigned char *net_bufq_array[EOS_NET_SIZE_BUFQ];
-static unsigned char net_bufq_buffer[EOS_NET_SIZE_BUFQ][EOS_NET_SIZE_BUF];
+static unsigned char net_bufq_buffer[EOS_NET_SIZE_BUFQ][EOS_NET_SIZE_BUF] __attribute__((section (".itim2")));
static EOSMsgQ net_send_q;
static EOSMsgItem net_sndq_array[EOS_NET_SIZE_BUFQ];
@@ -91,6 +91,7 @@ static void net_xchg_wake(void) {
SPI1_REG(SPI_REG_CSMODE) = SPI_CSMODE_AUTO;
}
+__attribute__ ((section (".itim")))
static void net_xchg_reset(void) {
volatile uint32_t x = 0;
net_state_flags &= ~NET_STATE_FLAG_CTS;
@@ -103,6 +104,7 @@ static void net_xchg_reset(void) {
SPI1_REG(SPI_REG_CSMODE) = SPI_CSMODE_AUTO;
}
+__attribute__ ((section (".itim")))
static void net_xchg_start(unsigned char type, unsigned char *buffer, uint16_t len) {
net_state_flags &= ~NET_STATE_FLAG_CTS;
net_state_flags |= (NET_STATE_FLAG_INIT | NET_STATE_FLAG_XCHG);
@@ -123,6 +125,7 @@ static void net_xchg_start(unsigned char type, unsigned char *buffer, uint16_t l
SPI1_REG(SPI_REG_IE) = SPI_IP_RXWM;
}
+__attribute__ ((section (".itim")))
static int net_xchg_next(unsigned char *_buffer) {
unsigned char type;
unsigned char *buffer = NULL;
@@ -145,6 +148,7 @@ static int net_xchg_next(unsigned char *_buffer) {
return ret;
}
+__attribute__ ((section (".itim")))
static void net_handle_xchg(void) {
if (net_state_flags & NET_STATE_FLAG_INIT) {
volatile uint32_t r1, r2, r3;
@@ -203,6 +207,7 @@ static void net_handle_xchg(void) {
}
}
+// __attribute__ ((section (".itim")))
static void net_handle_cts(void) {
GPIO_REG(GPIO_RISE_IP) = (1 << NET_PIN_CTS);
net_state_flags |= NET_STATE_FLAG_CTS;
@@ -212,6 +217,7 @@ static void net_handle_cts(void) {
}
}
+__attribute__ ((section (".itim")))
static void net_handle_rts(void) {
uint32_t rts_offset = (1 << NET_PIN_RTS);
@@ -227,6 +233,7 @@ static void net_handle_rts(void) {
}
}
+__attribute__ ((section (".itim")))
static void net_handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
unsigned char idx = (type & ~EOS_EVT_MASK) - 1;
@@ -237,6 +244,7 @@ static void net_handle_evt(unsigned char type, unsigned char *buffer, uint16_t l
}
}
+__attribute__ ((section (".itim")))
static int net_acquire(unsigned char reserved) {
int ret = 0;
@@ -253,7 +261,9 @@ static int net_acquire(unsigned char reserved) {
}
} else {
clear_csr(mstatus, MSTATUS_MIE);
- if (net_state_next_buf == NULL) net_state_next_buf = eos_bufq_pop(&net_buf_q);
+ if (net_state_next_buf == NULL) {
+ net_state_next_buf = eos_bufq_pop(&net_buf_q);
+ }
ret = (net_state_next_buf != NULL);
if (!ret) net_state_next_cnt++;
set_csr(mstatus, MSTATUS_MIE);
@@ -261,6 +271,7 @@ static int net_acquire(unsigned char reserved) {
return ret;
}
+__attribute__ ((section (".itim")))
static void evt_handler_wrapper(unsigned char type, unsigned char *buffer, uint16_t len, unsigned char idx, uint16_t flag) {
int ok;
@@ -275,6 +286,7 @@ static void evt_handler_wrapper(unsigned char type, unsigned char *buffer, uint1
}
}
+__attribute__ ((section (".itim")))
static void evt_handler(unsigned char type, unsigned char *buffer, uint16_t len) {
unsigned char idx = (type & EOS_EVT_MASK) >> 4;
@@ -464,11 +476,13 @@ void eos_net_acquire_for_evt(unsigned char type, char acq) {
}
}
+__attribute__ ((section (".itim")))
void eos_net_acquire(void) {
unsigned char acq = net_acquire(0);
if (!acq) net_acquire(1);
}
+__attribute__ ((section (".itim")))
void eos_net_release(void) {
clear_csr(mstatus, MSTATUS_MIE);
if (!net_state_next_cnt && net_state_next_buf) {
@@ -478,6 +492,7 @@ void eos_net_release(void) {
set_csr(mstatus, MSTATUS_MIE);
}
+__attribute__ ((section (".itim")))
unsigned char *eos_net_alloc(void) {
unsigned char *ret = NULL;
@@ -495,6 +510,7 @@ unsigned char *eos_net_alloc(void) {
return ret;
}
+__attribute__ ((section (".itim")))
void eos_net_free(unsigned char *buffer, unsigned char more) {
uint8_t do_release = 1;
@@ -512,6 +528,7 @@ void eos_net_free(unsigned char *buffer, unsigned char more) {
set_csr(mstatus, MSTATUS_MIE);
}
+__attribute__ ((section (".itim")))
static int net_xchg(unsigned char *type, unsigned char *buffer, uint16_t *len, unsigned char flags) {
int rv = EOS_OK;
int _sync = 0;
@@ -577,8 +594,13 @@ int eos_net_send(unsigned char type, unsigned char *buffer, uint16_t len) {
return net_xchg(&type, buffer, &len, (EOS_NET_FLAG_ONEW | EOS_NET_FLAG_SYNC));
}
+__attribute__ ((section (".itim")))
int eos_net_send_async(unsigned char type, unsigned char *buffer, uint16_t len, unsigned char more) {
- return net_xchg(&type, buffer, &len, more ? EOS_NET_FLAG_ONEW : 0);
+ int rv;
+
+ rv = net_xchg(&type, buffer, &len, more ? EOS_NET_FLAG_ONEW : 0);
+ if (rv) eos_net_free(buffer, more);
+ return rv;
}
int _eos_net_send(unsigned char type, unsigned char *buffer, uint16_t len, unsigned char async, unsigned char more) {