From cb38815c0b91fe25a1876e83c239b2908fa2a80c Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 20 Jun 2010 18:42:42 +0200 Subject: [PATCH] [L1CTL] Introduce L1CTL_RESET_RESP 1) On boot, L23 is notified by L1CTL_RESET_IND: 2) At any time, L23 can call L1CTL_RESET_REQ and get a L1CTL_RESET_RESP once the reset has been performed. Also, there is no 'l1ctl_info_dl' in the RESET_IND anymore, as it is useless. --- include/l1a_l23_interface.h | 1 + src/target/firmware/include/layer1/l23_api.h | 2 ++ src/target/firmware/layer1/init.c | 8 +---- src/target/firmware/layer1/l23_api.c | 34 ++++++++++++++++++++ 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/include/l1a_l23_interface.h b/include/l1a_l23_interface.h index 5651d7b..3782c58 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 66efce5..1ba6d17 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 c00d09f..7af327e 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 d37d18d..ae10fe1 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: -- 2.20.1