22 | | #define |
| 25 | static function_ptr_t new_reservation_callback; |
| 26 | static function_ptr_t adjust_reservation_ts_callback; |
| 27 | |
| 28 | volatile static u8 allow_new_mpdu_tx; |
| 29 | volatile static s8 pkt_buf_pending_tx; |
| 30 | }}} |
| 31 | |
| 32 | We should give these values sane defaults in the {{{wlan_mac_low_init()}}} function: |
| 33 | |
| 34 | {{{ |
| 35 | #!c |
| 36 | |
| 37 | new_reservation_callback = (function_ptr_t)nullCallback; |
| 38 | adjust_reservation_ts_callback = (function_ptr_t)nullCallback; |
| 39 | allow_new_mpdu_tx = 0; |
| 40 | pkt_buf_pending_tx = -1; |
| 41 | }}} |
| 42 | |
| 43 | Finally, we should create some setters to allow the CPU_LOW application (e.g. NoMAC) to attach its function to these callbacks. Add the following functions to the MAC Low Framework: |
| 44 | |
| 45 | {{{ |
| 46 | #!c |
| 47 | |
| 48 | inline void wlan_mac_low_set_new_reservation_callback(function_ptr_t callback){ |
| 49 | new_reservation_callback = callback; |
| 50 | } |
| 51 | |
| 52 | inline void wlan_mac_low_set_adjust_reservation_ts_callback(function_ptr_t callback){ |
| 53 | adjust_reservation_ts_callback = callback; |
| 54 | } |
| 55 | }}} |
| 56 | |
| 57 | The above updates are primarily bookkeeping. We'll explain the purpose of these additions in the coming sections. |
| 58 | |
| 59 | ---- |
| 60 | |
| 61 | When CPU_HIGH (or, more accurately, the AP project) passes CPU_LOW a {{{TOKEN_NEW_RESERVATION}}} message, we should pass the details of that message to the CPU_LOW application via the {{{new_reservation_callback()}}} we just created. The {{{process_ipc_msg_from_high()}}} function contains a large switch statement that covers each type of IPC message as an individual case. We should add a case for the {{{TOKEN_NEW_RESERVATION}}} message. First, we should declare a new local variable at the top of the function: |
| 62 | {{{ |
| 63 | ipc_token_new_reservation* new_reservation; |
| 64 | }}} |
| 65 | |
| 66 | Next, we'll assign that pointer to the IPC payload. This will let us access the payload of the IPC message with easy-to-read named structure elements rather than accessing arbitrary low-level bytes. |
| 67 | |
| 68 | {{{ |
| 69 | case IPC_MBOX_TOKEN_NEW_RESERVATION: |
| 70 | new_reservation = (ipc_token_new_reservation*)msg->payload_ptr; |
| 71 | new_reservation_callback(new_reservation); |
| 72 | break; |