summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/l1a_l23_interface.h1
-rw-r--r--src/target/firmware/include/layer1/l23_api.h2
-rw-r--r--src/target/firmware/layer1/init.c8
-rw-r--r--src/target/firmware/layer1/l23_api.c34
4 files changed, 38 insertions, 7 deletions
diff --git a/include/l1a_l23_interface.h b/include/l1a_l23_interface.h
index 5651d7b1..3782c58d 100644
--- a/include/l1a_l23_interface.h
+++ b/include/l1a_l23_interface.h
@@ -37,6 +37,7 @@
#define L1CTL_ECHO_RESP 12
#define L1CTL_RACH_RESP 13
#define L1CTL_RESET_REQ 14
+#define L1CTL_RESET_RESP 15
/*
* NOTE: struct size. We do add manual padding out of the believe
diff --git a/src/target/firmware/include/layer1/l23_api.h b/src/target/firmware/include/layer1/l23_api.h
index 66efce5d..1ba6d173 100644
--- a/src/target/firmware/include/layer1/l23_api.h
+++ b/src/target/firmware/include/layer1/l23_api.h
@@ -10,4 +10,6 @@ void l1_queue_for_l2(struct msgb *msg);
struct msgb *l1ctl_msgb_alloc(uint8_t msg_type);
struct msgb *l1_create_l2_msg(int msg_type, uint32_t fn, uint16_t snr, uint16_t arfcn);
+void l1ctl_tx_reset(uint8_t msg_type, uint8_t reset_type);
+
#endif /* _L1_L23_API_H */
diff --git a/src/target/firmware/layer1/init.c b/src/target/firmware/layer1/init.c
index c00d09fb..7af327eb 100644
--- a/src/target/firmware/layer1/init.c
+++ b/src/target/firmware/layer1/init.c
@@ -38,9 +38,6 @@
void layer1_init(void)
{
- struct msgb *msg;
- struct l1ctl_reset *res;
-
#ifndef CONFIG_TX_ENABLE
printf("\n\nTHIS FIRMWARE WAS COMPILED WITHOUT TX SUPPORT!!!\n\n");
#endif
@@ -73,8 +70,5 @@ void layer1_init(void)
irq_disable(IRQ_RTC_TIMER);
/* inform l2 and upwards that we are ready for orders */
- msg = l1_create_l2_msg(L1CTL_RESET_IND, 0, 0, 0);
- res = msgb_put(msg, sizeof(*res));
- res->type = L1CTL_RES_T_BOOT;
- l1_queue_for_l2(msg);
+ l1ctl_tx_reset(L1CTL_RESET_IND, L1CTL_RES_T_BOOT);
}
diff --git a/src/target/firmware/layer1/l23_api.c b/src/target/firmware/layer1/l23_api.c
index d37d18d5..ae10fe13 100644
--- a/src/target/firmware/layer1/l23_api.c
+++ b/src/target/firmware/layer1/l23_api.c
@@ -138,6 +138,38 @@ void l1ctl_rx_pm_req(struct msgb *msg)
l1s_pm_test(1, l1s.pm.range.arfcn_next);
}
+/* Transmit a L1CTL_RESET_IND or L1CTL_RESET_RESP */
+void l1ctl_tx_reset(uint8_t msg_type, uint8_t reset_type)
+{
+ struct msgb *msg = l1ctl_msgb_alloc(msg_type);
+ struct l1ctl_reset *reset_resp;
+ reset_resp = (struct l1ctl_reset *)
+ msgb_put(msg, sizeof(*reset_resp));
+ reset_resp->type = reset_type;
+
+ l1_queue_for_l2(msg);
+}
+
+/* receive a L1CTL_RESET_REQ from L23 */
+static void l1ctl_rx_reset_req(struct msgb *msg)
+{
+ struct l1ctl_hdr *l1h = (struct l1ctl_hdr *) msg->data;
+ struct l1ctl_reset *reset_req =
+ (struct l1ctl_reset *) l1h->data;
+
+ switch (reset_req->type) {
+ case L1CTL_RES_T_FULL:
+ printf("L1CTL_RESET_REQ: FULL!\n");
+ l1s_reset();
+ l1s_reset_hw();
+ l1ctl_tx_reset(L1CTL_RESET_RESP, reset_req->type);
+ break;
+ default:
+ printf("unknown L1CTL_RESET_REQ type\n");
+ break;
+ }
+}
+
/* callback from SERCOMM when L2 sends a message to L1 */
static void l1a_l23_rx_cb(uint8_t dlci, struct msgb *msg)
{
@@ -228,6 +260,8 @@ static void l1a_l23_rx_cb(uint8_t dlci, struct msgb *msg)
case L1CTL_PM_REQ:
l1ctl_rx_pm_req(msg);
break;
+ case L1CTL_RESET_REQ:
+ l1ctl_rx_reset_req(msg);
}
exit_msgbfree: