PD Buddy Sink Firmware
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

policy_engine.c 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. /*
  2. * PD Buddy - USB Power Delivery for everyone
  3. * Copyright (C) 2017 Clayton G. Hobbs <clay@lakeserv.net>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "policy_engine.h"
  19. #include "messages.h"
  20. #include "priorities.h"
  21. #include "device_policy_manager.h"
  22. #include "protocol_tx.h"
  23. #include "hard_reset.h"
  24. #include "pd.h"
  25. thread_t *pdb_pe_thread;
  26. enum policy_engine_state {
  27. PESinkStartup,
  28. PESinkDiscovery,
  29. PESinkWaitCap,
  30. PESinkEvalCap,
  31. PESinkSelectCap,
  32. PESinkTransitionSink,
  33. PESinkReady,
  34. PESinkGetSourceCap,
  35. PESinkGiveSinkCap,
  36. PESinkHardReset,
  37. PESinkTransitionDefault,
  38. PESinkSoftReset,
  39. PESinkSendSoftReset,
  40. PESinkSendReject
  41. };
  42. /* The received message we're currently working with */
  43. static union pd_msg *policy_engine_message = NULL;
  44. /* Whether or not the source capabilities match our required power */
  45. static bool capability_match = false;
  46. /* Policy Engine thread mailbox */
  47. static msg_t pdb_pe_mailbox_queue[PDB_MSG_POOL_SIZE];
  48. mailbox_t pdb_pe_mailbox;
  49. static enum policy_engine_state pe_sink_startup(void)
  50. {
  51. /* No need to reset the protocol layer here. There are two ways into this
  52. * state: startup and exiting hard reset. On startup, the protocol layer
  53. * is reset by the startup procedure. When exiting hard reset, the
  54. * protocol layer is reset by the hard reset state machine. Since it's
  55. * already done somewhere else, there's no need to do it again here. */
  56. return PESinkDiscovery;
  57. }
  58. static enum policy_engine_state pe_sink_discovery(void)
  59. {
  60. /* Wait for VBUS. Since it's our only power source, we already know that
  61. * we have it, so just move on. */
  62. return PESinkWaitCap;
  63. }
  64. static enum policy_engine_state pe_sink_wait_cap(void)
  65. {
  66. /* Fetch a message from the protocol layer */
  67. eventmask_t evt = chEvtWaitAnyTimeout(PDB_EVT_PE_MSG_RX, PD_T_TYPEC_SINK_WAIT_CAP);
  68. /* If we timed out waiting for Source_Capabilities, send a hard reset */
  69. if (evt == 0) {
  70. return PESinkHardReset;
  71. }
  72. /* Get the message */
  73. if (chMBFetch(&pdb_pe_mailbox, (msg_t *) &policy_engine_message, TIME_IMMEDIATE) == MSG_OK) {
  74. /* If we got a Source_Capabilities message, read it. */
  75. if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SOURCE_CAPABILITIES
  76. && PD_NUMOBJ_GET(policy_engine_message) > 0) {
  77. return PESinkEvalCap;
  78. /* If the message was a Soft_Reset, do the soft reset procedure */
  79. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SOFT_RESET
  80. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  81. chPoolFree(&pdb_msg_pool, policy_engine_message);
  82. policy_engine_message = NULL;
  83. return PESinkSoftReset;
  84. /* If we got an unexpected message, reset */
  85. } else {
  86. /* Free the received message */
  87. chPoolFree(&pdb_msg_pool, policy_engine_message);
  88. return PESinkHardReset;
  89. }
  90. }
  91. /* If we failed to get a message, send a hard reset */
  92. return PESinkHardReset;
  93. }
  94. static enum policy_engine_state pe_sink_eval_cap(void)
  95. {
  96. /* Get a message object */
  97. union pd_msg *request = chPoolAlloc(&pdb_msg_pool);
  98. /* Ask the DPM what to request */
  99. capability_match = pdb_dpm_evaluate_capability(policy_engine_message, request);
  100. /* Free the Source_Capabilities message */
  101. chPoolFree(&pdb_msg_pool, policy_engine_message);
  102. /* Put the request into policy_engine_message */
  103. policy_engine_message = request;
  104. return PESinkSelectCap;
  105. }
  106. static enum policy_engine_state pe_sink_select_cap(void)
  107. {
  108. /* Transmit the request */
  109. chMBPost(&pdb_prltx_mailbox, (msg_t) policy_engine_message, TIME_IMMEDIATE);
  110. chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
  111. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR);
  112. /* Free the sent message */
  113. chPoolFree(&pdb_msg_pool, policy_engine_message);
  114. policy_engine_message = NULL;
  115. /* If the message transmission failed, send a hard reset */
  116. if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
  117. return PESinkHardReset;
  118. }
  119. /* Wait for a response */
  120. evt = chEvtWaitAnyTimeout(PDB_EVT_PE_MSG_RX, PD_T_SENDER_RESPONSE);
  121. /* If we didn't get a response before the timeout, send a hard reset */
  122. if (evt == 0) {
  123. return PESinkHardReset;
  124. }
  125. /* Get the response message */
  126. if (chMBFetch(&pdb_pe_mailbox, (msg_t *) &policy_engine_message, TIME_IMMEDIATE) == MSG_OK) {
  127. /* If the source accepted our request, wait for the new power */
  128. if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_ACCEPT
  129. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  130. chPoolFree(&pdb_msg_pool, policy_engine_message);
  131. policy_engine_message = NULL;
  132. return PESinkTransitionSink;
  133. /* If the message was a Soft_Reset, do the soft reset procedure */
  134. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SOFT_RESET
  135. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  136. chPoolFree(&pdb_msg_pool, policy_engine_message);
  137. policy_engine_message = NULL;
  138. return PESinkSoftReset;
  139. /* TODO: Wait and Reject messages should be recognized here */
  140. } else {
  141. return PESinkSendSoftReset;
  142. }
  143. }
  144. return PESinkHardReset;
  145. }
  146. static enum policy_engine_state pe_sink_transition_sink(void)
  147. {
  148. /* Wait for the PS_RDY message */
  149. eventmask_t evt = chEvtWaitAnyTimeout(PDB_EVT_PE_MSG_RX, PD_T_PS_TRANSITION);
  150. /* If no message was received, send a hard reset */
  151. if (evt == 0) {
  152. return PESinkHardReset;
  153. }
  154. /* If we received a message, read it */
  155. if (chMBFetch(&pdb_pe_mailbox, (msg_t *) &policy_engine_message, TIME_IMMEDIATE) == MSG_OK) {
  156. /* If we got a PS_RDY, handle it */
  157. if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_PS_RDY
  158. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  159. /* Set the output appropriately */
  160. if (capability_match) {
  161. pdb_dpm_output_on();
  162. } else {
  163. pdb_dpm_output_off();
  164. }
  165. chPoolFree(&pdb_msg_pool, policy_engine_message);
  166. policy_engine_message = NULL;
  167. return PESinkReady;
  168. /* If there was a protocol error, send a hard reset */
  169. } else {
  170. /* Turn off the power output before this hard reset to make sure we
  171. * don't supply an incorrect voltage to the device we're powering.
  172. */
  173. pdb_dpm_output_off();
  174. chPoolFree(&pdb_msg_pool, policy_engine_message);
  175. policy_engine_message = NULL;
  176. return PESinkHardReset;
  177. }
  178. }
  179. return PESinkHardReset;
  180. }
  181. static enum policy_engine_state pe_sink_ready(void)
  182. {
  183. /* Wait for an event */
  184. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_MSG_RX | PDB_EVT_PE_RESET);
  185. /* If we got reset signaling, transition to default */
  186. if (evt & PDB_EVT_PE_RESET) {
  187. return PESinkTransitionDefault;
  188. }
  189. /* If we received a message */
  190. if (evt & PDB_EVT_PE_MSG_RX) {
  191. if (chMBFetch(&pdb_pe_mailbox, (msg_t *) &policy_engine_message, TIME_IMMEDIATE) == MSG_OK) {
  192. /* Ignore vendor-defined messages */
  193. if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_VENDOR_DEFINED
  194. && PD_NUMOBJ_GET(policy_engine_message) > 0) {
  195. chPoolFree(&pdb_msg_pool, policy_engine_message);
  196. policy_engine_message = NULL;
  197. return PESinkReady;
  198. /* Ignore Ping messages */
  199. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_PING
  200. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  201. chPoolFree(&pdb_msg_pool, policy_engine_message);
  202. policy_engine_message = NULL;
  203. return PESinkReady;
  204. /* Reject DR_Swap messages */
  205. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_DR_SWAP
  206. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  207. chPoolFree(&pdb_msg_pool, policy_engine_message);
  208. policy_engine_message = NULL;
  209. return PESinkSendReject;
  210. /* Reject Get_Source_Cap messages */
  211. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_GET_SOURCE_CAP
  212. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  213. chPoolFree(&pdb_msg_pool, policy_engine_message);
  214. policy_engine_message = NULL;
  215. return PESinkSendReject;
  216. /* Reject PR_Swap messages */
  217. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_PR_SWAP
  218. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  219. chPoolFree(&pdb_msg_pool, policy_engine_message);
  220. policy_engine_message = NULL;
  221. return PESinkSendReject;
  222. /* Reject VCONN_Swap messages */
  223. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_VCONN_SWAP
  224. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  225. chPoolFree(&pdb_msg_pool, policy_engine_message);
  226. policy_engine_message = NULL;
  227. return PESinkSendReject;
  228. /* Reject Request messages */
  229. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_REQUEST
  230. && PD_NUMOBJ_GET(policy_engine_message) > 0) {
  231. chPoolFree(&pdb_msg_pool, policy_engine_message);
  232. policy_engine_message = NULL;
  233. return PESinkSendReject;
  234. /* Reject Sink_Capabilities messages */
  235. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SINK_CAPABILITIES
  236. && PD_NUMOBJ_GET(policy_engine_message) > 0) {
  237. chPoolFree(&pdb_msg_pool, policy_engine_message);
  238. policy_engine_message = NULL;
  239. return PESinkSendReject;
  240. /* Evaluate new Source_Capabilities */
  241. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SOURCE_CAPABILITIES
  242. && PD_NUMOBJ_GET(policy_engine_message) > 0) {
  243. return PESinkEvalCap;
  244. /* Give sink capabilities when asked */
  245. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_GET_SINK_CAP
  246. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  247. chPoolFree(&pdb_msg_pool, policy_engine_message);
  248. policy_engine_message = NULL;
  249. return PESinkGiveSinkCap;
  250. /* If the message was a Soft_Reset, do the soft reset procedure */
  251. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SOFT_RESET
  252. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  253. chPoolFree(&pdb_msg_pool, policy_engine_message);
  254. policy_engine_message = NULL;
  255. return PESinkSoftReset;
  256. /* If we got an unknown message, send a soft reset */
  257. } else {
  258. chPoolFree(&pdb_msg_pool, policy_engine_message);
  259. policy_engine_message = NULL;
  260. return PESinkSendSoftReset;
  261. }
  262. }
  263. }
  264. return PESinkReady;
  265. }
  266. static enum policy_engine_state pe_sink_get_source_cap(void)
  267. {
  268. /* Stubbed until we actually have a need for this */
  269. return PESinkReady;
  270. }
  271. static enum policy_engine_state pe_sink_give_sink_cap(void)
  272. {
  273. /* Get a message object */
  274. union pd_msg *snk_cap = chPoolAlloc(&pdb_msg_pool);
  275. /* Get our capabilities from the DPM */
  276. pdb_dpm_get_sink_capability(snk_cap);
  277. /* Transmit our capabilities */
  278. chMBPost(&pdb_prltx_mailbox, (msg_t) snk_cap, TIME_IMMEDIATE);
  279. chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
  280. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR);
  281. /* Free the Sink_Capabilities message */
  282. chPoolFree(&pdb_msg_pool, snk_cap);
  283. snk_cap = NULL;
  284. /* If the message transmission failed, send a hard reset */
  285. if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
  286. return PESinkHardReset;
  287. }
  288. return PESinkReady;
  289. }
  290. static enum policy_engine_state pe_sink_hard_reset(void)
  291. {
  292. /* Generate a hard reset signal */
  293. chEvtSignal(pdb_hardrst_thread, PDB_EVT_HARDRST_RESET);
  294. chEvtWaitAny(PDB_EVT_PE_HARD_SENT);
  295. /* TODO: maintain HardResetCounter */
  296. return PESinkTransitionDefault;
  297. }
  298. static enum policy_engine_state pe_sink_transition_default(void)
  299. {
  300. /* Tell the DPM to turn off the output */
  301. pdb_dpm_output_off();
  302. /* There is no local hardware to reset. */
  303. /* Since we never change our data role from UFP, there is no reason to set
  304. * it here. */
  305. /* Tell the protocol layer we're done with the reset */
  306. chEvtSignal(pdb_hardrst_thread, PDB_EVT_HARDRST_DONE);
  307. return PESinkStartup;
  308. }
  309. static enum policy_engine_state pe_sink_soft_reset(void)
  310. {
  311. /* No need to explicitly reset the protocol layer here. It resets itself
  312. * when a Soft_Reset message is received. */
  313. /* Get a message object */
  314. union pd_msg *accept = chPoolAlloc(&pdb_msg_pool);
  315. /* Make an Accept message */
  316. accept->hdr = PD_MSGTYPE_ACCEPT | PD_DATAROLE_UFP | PD_SPECREV_2_0
  317. | PD_POWERROLE_SINK | PD_NUMOBJ(0);
  318. /* Transmit the Accept */
  319. chMBPost(&pdb_prltx_mailbox, (msg_t) accept, TIME_IMMEDIATE);
  320. chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
  321. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR);
  322. /* Free the sent message */
  323. chPoolFree(&pdb_msg_pool, accept);
  324. accept = NULL;
  325. /* If the message transmission failed, send a hard reset */
  326. if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
  327. return PESinkHardReset;
  328. }
  329. return PESinkWaitCap;
  330. }
  331. static enum policy_engine_state pe_sink_send_soft_reset(void)
  332. {
  333. /* No need to explicitly reset the protocol layer here. It resets itself
  334. * just before a Soft_Reset message is transmitted. */
  335. /* Get a message object */
  336. union pd_msg *softrst = chPoolAlloc(&pdb_msg_pool);
  337. /* Make a Soft_Reset message */
  338. softrst->hdr = PD_MSGTYPE_SOFT_RESET | PD_DATAROLE_UFP | PD_SPECREV_2_0
  339. | PD_POWERROLE_SINK | PD_NUMOBJ(0);
  340. /* Transmit the soft reset */
  341. chMBPost(&pdb_prltx_mailbox, (msg_t) softrst, TIME_IMMEDIATE);
  342. chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
  343. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR);
  344. /* Free the sent message */
  345. chPoolFree(&pdb_msg_pool, softrst);
  346. softrst = NULL;
  347. /* If the message transmission failed, send a hard reset */
  348. if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
  349. return PESinkHardReset;
  350. }
  351. /* Wait for a response */
  352. evt = chEvtWaitAnyTimeout(PDB_EVT_PE_MSG_RX, PD_T_SENDER_RESPONSE);
  353. /* If we didn't get a response before the timeout, send a hard reset */
  354. if (evt == 0) {
  355. return PESinkHardReset;
  356. }
  357. /* Get the response message */
  358. if (chMBFetch(&pdb_pe_mailbox, (msg_t *) &policy_engine_message, TIME_IMMEDIATE) == MSG_OK) {
  359. /* If the source accepted our soft reset, wait for capabilities. */
  360. if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_ACCEPT
  361. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  362. chPoolFree(&pdb_msg_pool, policy_engine_message);
  363. policy_engine_message = NULL;
  364. return PESinkWaitCap;
  365. /* If the message was a Soft_Reset, do the soft reset procedure */
  366. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SOFT_RESET
  367. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  368. chPoolFree(&pdb_msg_pool, policy_engine_message);
  369. policy_engine_message = NULL;
  370. return PESinkSoftReset;
  371. /* Otherwise, send a hard reset */
  372. } else {
  373. chPoolFree(&pdb_msg_pool, policy_engine_message);
  374. policy_engine_message = NULL;
  375. return PESinkHardReset;
  376. }
  377. }
  378. return PESinkHardReset;
  379. }
  380. static enum policy_engine_state pe_sink_send_reject(void)
  381. {
  382. /* Get a message object */
  383. union pd_msg *reject = chPoolAlloc(&pdb_msg_pool);
  384. /* Make a Reject message */
  385. reject->hdr = PD_MSGTYPE_REJECT | PD_DATAROLE_UFP | PD_SPECREV_2_0
  386. | PD_POWERROLE_SINK | PD_NUMOBJ(0);
  387. /* Transmit the message */
  388. chMBPost(&pdb_prltx_mailbox, (msg_t) reject, TIME_IMMEDIATE);
  389. chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
  390. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR);
  391. /* Free the Reject message */
  392. chPoolFree(&pdb_msg_pool, reject);
  393. reject = NULL;
  394. /* If the message transmission failed, send a soft reset */
  395. if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
  396. return PESinkSendSoftReset;
  397. }
  398. return PESinkReady;
  399. }
  400. /*
  401. * Policy Engine state machine thread
  402. */
  403. static THD_WORKING_AREA(waPolicyEngine, 128);
  404. static THD_FUNCTION(PolicyEngine, arg) {
  405. (void) arg;
  406. enum policy_engine_state state = PESinkStartup;
  407. /* Initialize the mailbox */
  408. chMBObjectInit(&pdb_pe_mailbox, pdb_pe_mailbox_queue, PDB_MSG_POOL_SIZE);
  409. while (true) {
  410. switch (state) {
  411. case PESinkStartup:
  412. state = pe_sink_startup();
  413. break;
  414. case PESinkDiscovery:
  415. state = pe_sink_discovery();
  416. break;
  417. case PESinkWaitCap:
  418. state = pe_sink_wait_cap();
  419. break;
  420. case PESinkEvalCap:
  421. state = pe_sink_eval_cap();
  422. break;
  423. case PESinkSelectCap:
  424. state = pe_sink_select_cap();
  425. break;
  426. case PESinkTransitionSink:
  427. state = pe_sink_transition_sink();
  428. break;
  429. case PESinkReady:
  430. state = pe_sink_ready();
  431. break;
  432. case PESinkGetSourceCap:
  433. state = pe_sink_get_source_cap();
  434. break;
  435. case PESinkGiveSinkCap:
  436. state = pe_sink_give_sink_cap();
  437. break;
  438. case PESinkHardReset:
  439. state = pe_sink_hard_reset();
  440. break;
  441. case PESinkTransitionDefault:
  442. state = pe_sink_transition_default();
  443. break;
  444. case PESinkSoftReset:
  445. state = pe_sink_soft_reset();
  446. break;
  447. case PESinkSendSoftReset:
  448. state = pe_sink_send_soft_reset();
  449. break;
  450. case PESinkSendReject:
  451. state = pe_sink_send_reject();
  452. break;
  453. default:
  454. /* This is an error. It really shouldn't happen. We might
  455. * want to handle it anyway, though. */
  456. state = PESinkStartup;
  457. break;
  458. }
  459. }
  460. }
  461. void pdb_pe_run(void)
  462. {
  463. pdb_pe_thread = chThdCreateStatic(waPolicyEngine, sizeof(waPolicyEngine),
  464. PDB_PRIO_PE, PolicyEngine, NULL);
  465. }