Bläddra i källkod

Reference the PRLTX thread by the new struct

Clara Hobbs 7 år sedan
förälder
incheckning
fc5c6780a8
6 ändrade filer med 21 tillägg och 25 borttagningar
  1. 1
    1
      lib/src/hard_reset.c
  2. 1
    1
      lib/src/int_n.c
  3. 6
    6
      lib/src/policy_engine.c
  4. 12
    11
      lib/src/protocol_rx.c
  5. 1
    3
      lib/src/protocol_tx.c
  6. 0
    3
      lib/src/protocol_tx.h

+ 1
- 1
lib/src/hard_reset.c Visa fil

@@ -57,7 +57,7 @@ static enum hardrst_state hardrst_reset_layer(struct pdb_config *cfg)
57 57
     chThdYield();
58 58
 
59 59
     /* Reset the Protocol TX machine */
60
-    chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_RESET);
60
+    chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_RESET);
61 61
     chThdYield();
62 62
 
63 63
     /* Continue the process based on what event started the reset. */

+ 1
- 1
lib/src/int_n.c Visa fil

@@ -59,7 +59,7 @@ static THD_FUNCTION(IntNPoll, vcfg) {
59 59
             if (status.interrupta & FUSB_INTERRUPTA_I_TXSENT) {
60 60
                 events |= PDB_EVT_PRLTX_I_TXSENT;
61 61
             }
62
-            chEvtSignal(pdb_prltx_thread, events);
62
+            chEvtSignal(cfg->prl.tx_thread, events);
63 63
 
64 64
             /* If the I_HARDRST or I_HARDSENT flag is set, tell the Hard Reset
65 65
              * thread */

+ 6
- 6
lib/src/policy_engine.c Visa fil

@@ -154,7 +154,7 @@ static enum policy_engine_state pe_sink_select_cap(struct pdb_config *cfg)
154 154
 {
155 155
     /* Transmit the request */
156 156
     chMBPost(&pdb_prltx_mailbox, (msg_t) last_dpm_request, TIME_IMMEDIATE);
157
-    chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
157
+    chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
158 158
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
159 159
             | PDB_EVT_PE_RESET);
160 160
     /* Don't free the request; we might need it again */
@@ -428,7 +428,7 @@ static enum policy_engine_state pe_sink_get_source_cap(struct pdb_config *cfg)
428 428
         | PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(0);
429 429
     /* Transmit the Get_Source_Cap */
430 430
     chMBPost(&pdb_prltx_mailbox, (msg_t) get_source_cap, TIME_IMMEDIATE);
431
-    chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
431
+    chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
432 432
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
433 433
             | PDB_EVT_PE_RESET);
434 434
     /* Free the sent message */
@@ -455,7 +455,7 @@ static enum policy_engine_state pe_sink_give_sink_cap(struct pdb_config *cfg)
455 455
 
456 456
     /* Transmit our capabilities */
457 457
     chMBPost(&pdb_prltx_mailbox, (msg_t) snk_cap, TIME_IMMEDIATE);
458
-    chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
458
+    chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
459 459
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
460 460
             | PDB_EVT_PE_RESET);
461 461
 
@@ -522,7 +522,7 @@ static enum policy_engine_state pe_sink_soft_reset(struct pdb_config *cfg)
522 522
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
523 523
     /* Transmit the Accept */
524 524
     chMBPost(&pdb_prltx_mailbox, (msg_t) accept, TIME_IMMEDIATE);
525
-    chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
525
+    chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
526 526
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
527 527
             | PDB_EVT_PE_RESET);
528 528
     /* Free the sent message */
@@ -552,7 +552,7 @@ static enum policy_engine_state pe_sink_send_soft_reset(struct pdb_config *cfg)
552 552
         | PD_POWERROLE_SINK | PD_NUMOBJ(0);
553 553
     /* Transmit the soft reset */
554 554
     chMBPost(&pdb_prltx_mailbox, (msg_t) softrst, TIME_IMMEDIATE);
555
-    chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
555
+    chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
556 556
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
557 557
             | PDB_EVT_PE_RESET);
558 558
     /* Free the sent message */
@@ -613,7 +613,7 @@ static enum policy_engine_state pe_sink_send_reject(struct pdb_config *cfg)
613 613
 
614 614
     /* Transmit the message */
615 615
     chMBPost(&pdb_prltx_mailbox, (msg_t) reject, TIME_IMMEDIATE);
616
-    chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
616
+    chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
617 617
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
618 618
             | PDB_EVT_PE_RESET);
619 619
 

+ 12
- 11
lib/src/protocol_rx.c Visa fil

@@ -49,8 +49,9 @@ int8_t pdb_prlrx_messageid = -1;
49 49
 /*
50 50
  * PRL_Rx_Wait_for_PHY_Message state
51 51
  */
52
-static enum protocol_rx_state protocol_rx_wait_phy(void)
52
+static enum protocol_rx_state protocol_rx_wait_phy(struct pdb_config *cfg)
53 53
 {
54
+    (void) cfg;
54 55
     /* Wait for an event */
55 56
     eventmask_t evt = chEvtWaitAny(ALL_EVENTS);
56 57
 
@@ -82,7 +83,7 @@ static enum protocol_rx_state protocol_rx_wait_phy(void)
82 83
 /*
83 84
  * PRL_Rx_Layer_Reset_for_Receive state
84 85
  */
85
-static enum protocol_rx_state protocol_rx_reset(void)
86
+static enum protocol_rx_state protocol_rx_reset(struct pdb_config *cfg)
86 87
 {
87 88
     /* Reset MessageIDCounter */
88 89
     pdb_prltx_messageidcounter = 0;
@@ -91,7 +92,7 @@ static enum protocol_rx_state protocol_rx_reset(void)
91 92
     pdb_prlrx_messageid = -1;
92 93
 
93 94
     /* TX transitions to its reset state */
94
-    chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_RESET);
95
+    chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_RESET);
95 96
     chThdYield();
96 97
 
97 98
     /* If we got a RESET signal, reset the machine */
@@ -108,8 +109,9 @@ static enum protocol_rx_state protocol_rx_reset(void)
108 109
 /*
109 110
  * PRL_Rx_Check_MessageID state
110 111
  */
111
-static enum protocol_rx_state protocol_rx_check_messageid(void)
112
+static enum protocol_rx_state protocol_rx_check_messageid(struct pdb_config *cfg)
112 113
 {
114
+    (void) cfg;
113 115
     /* If we got a RESET signal, reset the machine */
114 116
     if (chEvtGetAndClearEvents(PDB_EVT_PRLRX_RESET) != 0) {
115 117
         chPoolFree(&pdb_msg_pool, protocol_rx_message);
@@ -133,10 +135,10 @@ static enum protocol_rx_state protocol_rx_check_messageid(void)
133 135
 /*
134 136
  * PRL_Rx_Store_MessageID state
135 137
  */
136
-static enum protocol_rx_state protocol_rx_store_messageid(void)
138
+static enum protocol_rx_state protocol_rx_store_messageid(struct pdb_config *cfg)
137 139
 {
138 140
     /* Tell ProtocolTX to discard the message being transmitted */
139
-    chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_DISCARD);
141
+    chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_DISCARD);
140 142
     chThdYield();
141 143
 
142 144
     /* Update the stored MessageID */
@@ -155,22 +157,21 @@ static enum protocol_rx_state protocol_rx_store_messageid(void)
155 157
  * Protocol layer RX state machine thread
156 158
  */
157 159
 static THD_FUNCTION(ProtocolRX, cfg) {
158
-    (void) cfg;
159 160
     enum protocol_rx_state state = PRLRxWaitPHY;
160 161
 
161 162
     while (true) {
162 163
         switch (state) {
163 164
             case PRLRxWaitPHY:
164
-                state = protocol_rx_wait_phy();
165
+                state = protocol_rx_wait_phy(cfg);
165 166
                 break;
166 167
             case PRLRxReset:
167
-                state = protocol_rx_reset();
168
+                state = protocol_rx_reset(cfg);
168 169
                 break;
169 170
             case PRLRxCheckMessageID:
170
-                state = protocol_rx_check_messageid();
171
+                state = protocol_rx_check_messageid(cfg);
171 172
                 break;
172 173
             case PRLRxStoreMessageID:
173
-                state = protocol_rx_store_messageid();
174
+                state = protocol_rx_store_messageid(cfg);
174 175
                 break;
175 176
             default:
176 177
                 /* This is an error.  It really shouldn't happen.  We might

+ 1
- 3
lib/src/protocol_tx.c Visa fil

@@ -26,8 +26,6 @@
26 26
 #include "pd.h"
27 27
 
28 28
 
29
-thread_t *pdb_prltx_thread;
30
-
31 29
 /* Protocol layer TX thread mailbox */
32 30
 static msg_t pdb_prltx_mailbox_queue[PDB_MSG_POOL_SIZE];
33 31
 mailbox_t pdb_prltx_mailbox;
@@ -290,6 +288,6 @@ static THD_FUNCTION(ProtocolTX, cfg) {
290 288
 
291 289
 void pdb_prltx_run(struct pdb_config *cfg)
292 290
 {
293
-    pdb_prltx_thread = chThdCreateStatic(cfg->prl._tx_wa,
291
+    cfg->prl.tx_thread = chThdCreateStatic(cfg->prl._tx_wa,
294 292
             sizeof(cfg->prl._tx_wa), PDB_PRIO_PRL, ProtocolTX, cfg);
295 293
 }

+ 0
- 3
lib/src/protocol_tx.h Visa fil

@@ -33,9 +33,6 @@
33 33
 #define PDB_EVT_PRLTX_DISCARD EVENT_MASK(3)
34 34
 #define PDB_EVT_PRLTX_MSG_TX EVENT_MASK(4)
35 35
 
36
-/* The Protocol TX thread object */
37
-extern thread_t *pdb_prltx_thread;
38
-
39 36
 /* Protocol layer TX thread mailbox */
40 37
 extern mailbox_t pdb_prltx_mailbox;
41 38
 

Laddar…
Avbryt
Spara