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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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. /* TODO: we're supposed to send NAKs in response to all
  194. * unsupported structured VDMs except Attention. */
  195. if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_VENDOR_DEFINED
  196. && PD_NUMOBJ_GET(policy_engine_message) > 0) {
  197. chPoolFree(&pdb_msg_pool, policy_engine_message);
  198. policy_engine_message = NULL;
  199. return PESinkReady;
  200. /* Ignore Ping messages */
  201. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_PING
  202. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  203. chPoolFree(&pdb_msg_pool, policy_engine_message);
  204. policy_engine_message = NULL;
  205. return PESinkReady;
  206. /* Reject DR_Swap messages */
  207. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_DR_SWAP
  208. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  209. chPoolFree(&pdb_msg_pool, policy_engine_message);
  210. policy_engine_message = NULL;
  211. return PESinkSendReject;
  212. /* Reject Get_Source_Cap messages */
  213. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_GET_SOURCE_CAP
  214. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  215. chPoolFree(&pdb_msg_pool, policy_engine_message);
  216. policy_engine_message = NULL;
  217. return PESinkSendReject;
  218. /* Reject PR_Swap messages */
  219. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_PR_SWAP
  220. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  221. chPoolFree(&pdb_msg_pool, policy_engine_message);
  222. policy_engine_message = NULL;
  223. return PESinkSendReject;
  224. /* Reject VCONN_Swap messages */
  225. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_VCONN_SWAP
  226. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  227. chPoolFree(&pdb_msg_pool, policy_engine_message);
  228. policy_engine_message = NULL;
  229. return PESinkSendReject;
  230. /* Reject Request messages */
  231. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_REQUEST
  232. && PD_NUMOBJ_GET(policy_engine_message) > 0) {
  233. chPoolFree(&pdb_msg_pool, policy_engine_message);
  234. policy_engine_message = NULL;
  235. return PESinkSendReject;
  236. /* Reject Sink_Capabilities messages */
  237. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SINK_CAPABILITIES
  238. && PD_NUMOBJ_GET(policy_engine_message) > 0) {
  239. chPoolFree(&pdb_msg_pool, policy_engine_message);
  240. policy_engine_message = NULL;
  241. return PESinkSendReject;
  242. /* Evaluate new Source_Capabilities */
  243. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SOURCE_CAPABILITIES
  244. && PD_NUMOBJ_GET(policy_engine_message) > 0) {
  245. return PESinkEvalCap;
  246. /* Give sink capabilities when asked */
  247. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_GET_SINK_CAP
  248. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  249. chPoolFree(&pdb_msg_pool, policy_engine_message);
  250. policy_engine_message = NULL;
  251. return PESinkGiveSinkCap;
  252. /* If the message was a Soft_Reset, do the soft reset procedure */
  253. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SOFT_RESET
  254. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  255. chPoolFree(&pdb_msg_pool, policy_engine_message);
  256. policy_engine_message = NULL;
  257. return PESinkSoftReset;
  258. /* If we got an unknown message, send a soft reset */
  259. } else {
  260. chPoolFree(&pdb_msg_pool, policy_engine_message);
  261. policy_engine_message = NULL;
  262. return PESinkSendSoftReset;
  263. }
  264. }
  265. }
  266. return PESinkReady;
  267. }
  268. static enum policy_engine_state pe_sink_get_source_cap(void)
  269. {
  270. /* Stubbed until we actually have a need for this */
  271. return PESinkReady;
  272. }
  273. static enum policy_engine_state pe_sink_give_sink_cap(void)
  274. {
  275. /* Get a message object */
  276. union pd_msg *snk_cap = chPoolAlloc(&pdb_msg_pool);
  277. /* Get our capabilities from the DPM */
  278. pdb_dpm_get_sink_capability(snk_cap);
  279. /* Transmit our capabilities */
  280. chMBPost(&pdb_prltx_mailbox, (msg_t) snk_cap, TIME_IMMEDIATE);
  281. chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
  282. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR);
  283. /* Free the Sink_Capabilities message */
  284. chPoolFree(&pdb_msg_pool, snk_cap);
  285. snk_cap = NULL;
  286. /* If the message transmission failed, send a hard reset */
  287. if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
  288. return PESinkHardReset;
  289. }
  290. return PESinkReady;
  291. }
  292. static enum policy_engine_state pe_sink_hard_reset(void)
  293. {
  294. /* Generate a hard reset signal */
  295. chEvtSignal(pdb_hardrst_thread, PDB_EVT_HARDRST_RESET);
  296. chEvtWaitAny(PDB_EVT_PE_HARD_SENT);
  297. /* TODO: maintain HardResetCounter */
  298. return PESinkTransitionDefault;
  299. }
  300. static enum policy_engine_state pe_sink_transition_default(void)
  301. {
  302. /* Tell the DPM to turn off the output */
  303. pdb_dpm_output_off();
  304. /* There is no local hardware to reset. */
  305. /* Since we never change our data role from UFP, there is no reason to set
  306. * it here. */
  307. /* Tell the protocol layer we're done with the reset */
  308. chEvtSignal(pdb_hardrst_thread, PDB_EVT_HARDRST_DONE);
  309. return PESinkStartup;
  310. }
  311. static enum policy_engine_state pe_sink_soft_reset(void)
  312. {
  313. /* No need to explicitly reset the protocol layer here. It resets itself
  314. * when a Soft_Reset message is received. */
  315. /* Get a message object */
  316. union pd_msg *accept = chPoolAlloc(&pdb_msg_pool);
  317. /* Make an Accept message */
  318. accept->hdr = PD_MSGTYPE_ACCEPT | PD_DATAROLE_UFP | PD_SPECREV_2_0
  319. | PD_POWERROLE_SINK | PD_NUMOBJ(0);
  320. /* Transmit the Accept */
  321. chMBPost(&pdb_prltx_mailbox, (msg_t) accept, TIME_IMMEDIATE);
  322. chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
  323. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR);
  324. /* Free the sent message */
  325. chPoolFree(&pdb_msg_pool, accept);
  326. accept = NULL;
  327. /* If the message transmission failed, send a hard reset */
  328. if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
  329. return PESinkHardReset;
  330. }
  331. return PESinkWaitCap;
  332. }
  333. static enum policy_engine_state pe_sink_send_soft_reset(void)
  334. {
  335. /* No need to explicitly reset the protocol layer here. It resets itself
  336. * just before a Soft_Reset message is transmitted. */
  337. /* Get a message object */
  338. union pd_msg *softrst = chPoolAlloc(&pdb_msg_pool);
  339. /* Make a Soft_Reset message */
  340. softrst->hdr = PD_MSGTYPE_SOFT_RESET | PD_DATAROLE_UFP | PD_SPECREV_2_0
  341. | PD_POWERROLE_SINK | PD_NUMOBJ(0);
  342. /* Transmit the soft reset */
  343. chMBPost(&pdb_prltx_mailbox, (msg_t) softrst, TIME_IMMEDIATE);
  344. chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
  345. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR);
  346. /* Free the sent message */
  347. chPoolFree(&pdb_msg_pool, softrst);
  348. softrst = NULL;
  349. /* If the message transmission failed, send a hard reset */
  350. if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
  351. return PESinkHardReset;
  352. }
  353. /* Wait for a response */
  354. evt = chEvtWaitAnyTimeout(PDB_EVT_PE_MSG_RX, PD_T_SENDER_RESPONSE);
  355. /* If we didn't get a response before the timeout, send a hard reset */
  356. if (evt == 0) {
  357. return PESinkHardReset;
  358. }
  359. /* Get the response message */
  360. if (chMBFetch(&pdb_pe_mailbox, (msg_t *) &policy_engine_message, TIME_IMMEDIATE) == MSG_OK) {
  361. /* If the source accepted our soft reset, wait for capabilities. */
  362. if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_ACCEPT
  363. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  364. chPoolFree(&pdb_msg_pool, policy_engine_message);
  365. policy_engine_message = NULL;
  366. return PESinkWaitCap;
  367. /* If the message was a Soft_Reset, do the soft reset procedure */
  368. } else if (PD_MSGTYPE_GET(policy_engine_message) == PD_MSGTYPE_SOFT_RESET
  369. && PD_NUMOBJ_GET(policy_engine_message) == 0) {
  370. chPoolFree(&pdb_msg_pool, policy_engine_message);
  371. policy_engine_message = NULL;
  372. return PESinkSoftReset;
  373. /* Otherwise, send a hard reset */
  374. } else {
  375. chPoolFree(&pdb_msg_pool, policy_engine_message);
  376. policy_engine_message = NULL;
  377. return PESinkHardReset;
  378. }
  379. }
  380. return PESinkHardReset;
  381. }
  382. static enum policy_engine_state pe_sink_send_reject(void)
  383. {
  384. /* Get a message object */
  385. union pd_msg *reject = chPoolAlloc(&pdb_msg_pool);
  386. /* Make a Reject message */
  387. reject->hdr = PD_MSGTYPE_REJECT | PD_DATAROLE_UFP | PD_SPECREV_2_0
  388. | PD_POWERROLE_SINK | PD_NUMOBJ(0);
  389. /* Transmit the message */
  390. chMBPost(&pdb_prltx_mailbox, (msg_t) reject, TIME_IMMEDIATE);
  391. chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
  392. eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR);
  393. /* Free the Reject message */
  394. chPoolFree(&pdb_msg_pool, reject);
  395. reject = NULL;
  396. /* If the message transmission failed, send a soft reset */
  397. if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
  398. return PESinkSendSoftReset;
  399. }
  400. return PESinkReady;
  401. }
  402. /*
  403. * Policy Engine state machine thread
  404. */
  405. static THD_WORKING_AREA(waPolicyEngine, 128);
  406. static THD_FUNCTION(PolicyEngine, arg) {
  407. (void) arg;
  408. enum policy_engine_state state = PESinkStartup;
  409. /* Initialize the mailbox */
  410. chMBObjectInit(&pdb_pe_mailbox, pdb_pe_mailbox_queue, PDB_MSG_POOL_SIZE);
  411. while (true) {
  412. switch (state) {
  413. case PESinkStartup:
  414. state = pe_sink_startup();
  415. break;
  416. case PESinkDiscovery:
  417. state = pe_sink_discovery();
  418. break;
  419. case PESinkWaitCap:
  420. state = pe_sink_wait_cap();
  421. break;
  422. case PESinkEvalCap:
  423. state = pe_sink_eval_cap();
  424. break;
  425. case PESinkSelectCap:
  426. state = pe_sink_select_cap();
  427. break;
  428. case PESinkTransitionSink:
  429. state = pe_sink_transition_sink();
  430. break;
  431. case PESinkReady:
  432. state = pe_sink_ready();
  433. break;
  434. case PESinkGetSourceCap:
  435. state = pe_sink_get_source_cap();
  436. break;
  437. case PESinkGiveSinkCap:
  438. state = pe_sink_give_sink_cap();
  439. break;
  440. case PESinkHardReset:
  441. state = pe_sink_hard_reset();
  442. break;
  443. case PESinkTransitionDefault:
  444. state = pe_sink_transition_default();
  445. break;
  446. case PESinkSoftReset:
  447. state = pe_sink_soft_reset();
  448. break;
  449. case PESinkSendSoftReset:
  450. state = pe_sink_send_soft_reset();
  451. break;
  452. case PESinkSendReject:
  453. state = pe_sink_send_reject();
  454. break;
  455. default:
  456. /* This is an error. It really shouldn't happen. We might
  457. * want to handle it anyway, though. */
  458. state = PESinkStartup;
  459. break;
  460. }
  461. }
  462. }
  463. void pdb_pe_run(void)
  464. {
  465. pdb_pe_thread = chThdCreateStatic(waPolicyEngine, sizeof(waPolicyEngine),
  466. PDB_PRIO_PE, PolicyEngine, NULL);
  467. }