commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10429 - gnuradio/branches/developers/jcorgan/fw-optim


From: jcorgan
Subject: [Commit-gnuradio] r10429 - gnuradio/branches/developers/jcorgan/fw-optimize/usrp2/firmware/apps
Date: Tue, 10 Feb 2009 13:36:14 -0700 (MST)

Author: jcorgan
Date: 2009-02-10 13:36:13 -0700 (Tue, 10 Feb 2009)
New Revision: 10429

Modified:
   
gnuradio/branches/developers/jcorgan/fw-optimize/usrp2/firmware/apps/app_common_v2.c
Log:
Clean up, saves 260 bytes, woot

Modified: 
gnuradio/branches/developers/jcorgan/fw-optimize/usrp2/firmware/apps/app_common_v2.c
===================================================================
--- 
gnuradio/branches/developers/jcorgan/fw-optimize/usrp2/firmware/apps/app_common_v2.c
        2009-02-10 19:52:54 UTC (rev 10428)
+++ 
gnuradio/branches/developers/jcorgan/fw-optimize/usrp2/firmware/apps/app_common_v2.c
        2009-02-10 20:36:13 UTC (rev 10429)
@@ -40,17 +40,11 @@
 
 static unsigned char exp_seqno __attribute__((unused)) = 0;
 
-static bool
-burn_mac_addr(const op_burn_mac_addr_t *p)
-{
-  return ethernet_set_mac_addr(&p->addr);
-}
-
-static bool
+static inline bool
 sync_to_pps(const op_generic_t *p)
 {
   timesync_regs->sync_on_next_pps = 1;
-  putstr("SYNC to PPS\n");
+  //putstr("SYNC to PPS\n");
   return true;
 }
 
@@ -66,7 +60,7 @@
   return true;
 }
 
-static bool
+static inline bool
 config_mimo_cmd(const op_config_mimo_t *p)
 {
   clocks_mimo_config(p->flags);
@@ -349,8 +343,8 @@
 {
   op_generic_t *r = (op_generic_t *) reply_payload;
 
-  putstr("peek: addr="); puthex32(p->addr);
-  printf(" bytes=%u\n", p->bytes);
+  //putstr("peek: addr="); puthex32(p->addr);
+  //printf(" bytes=%u\n", p->bytes);
 
   if ((reply_payload_space < (sizeof(*r) + p->bytes)) ||
       p->bytes > MAX_SUBPKT_LEN - sizeof(op_generic_t)) {
@@ -372,8 +366,8 @@
 poke_cmd(const op_poke_t *p)
 {
   int bytes = p->len - sizeof(*p);
-  putstr("poke: addr="); puthex32(p->addr);
-  printf(" bytes=%u\n", bytes);
+  //putstr("poke: addr="); puthex32(p->addr);
+  //printf(" bytes=%u\n", bytes);
 
   uint8_t *src = (uint8_t *)p + sizeof(*p);
   memcpy_wa((void *)p->addr, src, bytes);
@@ -439,6 +433,7 @@
   int payload_len = len - sizeof(u2_eth_packet_t);
   
   size_t subpktlen = 0;
+  bool ok = false;
 
   while (payload_len >= sizeof(op_generic_t)){
     const op_generic_t *gp = (const op_generic_t *) payload;
@@ -455,34 +450,30 @@
       break;
     
     case OP_CONFIG_TX_V2:
-      subpktlen = config_tx_v2_cmd((op_config_tx_v2_t *) payload,
-                                  reply_payload, reply_payload_space);
+      subpktlen = config_tx_v2_cmd((op_config_tx_v2_t *) payload, 
reply_payload, reply_payload_space);
       break;
 
     case OP_CONFIG_RX_V2:
-      subpktlen = config_rx_v2_cmd((op_config_rx_v2_t *) payload,
-                                  reply_payload, reply_payload_space);
+      subpktlen = config_rx_v2_cmd((op_config_rx_v2_t *) payload, 
reply_payload, reply_payload_space);
       break;
 
     case OP_START_RX_STREAMING:
       start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) 
payload);
-      subpktlen = generic_reply(gp, reply_payload, reply_payload_space, true);
-      break;
+      ok = true;
+      goto generic_reply;
     
     case OP_STOP_RX:
       stop_rx_cmd();
-      subpktlen = generic_reply(gp, reply_payload, reply_payload_space, true);
-      break;
+      ok = true;
+      goto generic_reply;
     
     case OP_BURN_MAC_ADDR:
-      subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
-                               burn_mac_addr((op_burn_mac_addr_t *) payload));
-      break;
+      ok = ethernet_set_mac_addr(&((op_burn_mac_addr_t *)payload)->addr);
+      goto generic_reply;
 
     case OP_CONFIG_MIMO:
-      subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
-                               config_mimo_cmd((op_config_mimo_t *) payload));
-      break;
+      ok = config_mimo_cmd((op_config_mimo_t *) payload);
+      goto generic_reply;
 
     case OP_READ_TIME:
       subpktlen = read_time_cmd(gp, reply_payload, reply_payload_space);
@@ -493,33 +484,36 @@
       break;
 
     case OP_SYNC_TO_PPS:
-      subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
-                               sync_to_pps((op_generic_t *) payload));
-      break;
+      sync_to_pps((op_generic_t *) payload);
+      ok = true;
+      goto generic_reply;
 
     case OP_PEEK:
       subpktlen = peek_cmd((op_peek_t *)payload, reply_payload, 
reply_payload_space);
       break;
 
     case OP_POKE:
-      subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
-                               poke_cmd((op_poke_t *)payload));
-      break;
+      ok = poke_cmd((op_poke_t *)payload);
+      goto generic_reply;
 
     case OP_SET_TX_LO_OFFSET:
     case OP_SET_RX_LO_OFFSET:
-      subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
-                               set_lo_offset_cmd((op_freq_t *)payload));
-      break;
+      ok = set_lo_offset_cmd((op_freq_t *)payload);
+      goto generic_reply;
 
     case OP_RESET_DB:
       db_init();
-      subpktlen = generic_reply(gp, reply_payload, reply_payload_space, true);
-      break;
+      ok = true;
+      goto generic_reply;
 
     case OP_SYNC_EVERY_PPS:
-      subpktlen = generic_reply(gp, reply_payload, reply_payload_space,
-                               sync_every_pps((op_generic_t *) payload));
+      ok = sync_every_pps((op_generic_t *) payload);
+      goto generic_reply;
+
+    // Add new opcode handlers here
+
+    generic_reply:
+      subpktlen = generic_reply(gp, reply_payload, reply_payload_space, ok);
       break;
 
     default:





reply via email to

[Prev in Thread] Current Thread [Next in Thread]