| /* Copyright Statement: |
| * |
| * This software/firmware and related documentation ("MediaTek Software") are |
| * protected under relevant copyright laws. The information contained herein is |
| * confidential and proprietary to MediaTek Inc. and/or its licensors. Without |
| * the prior written permission of MediaTek inc. and/or its licensors, any |
| * reproduction, modification, use or disclosure of MediaTek Software, and |
| * information contained herein, in whole or in part, shall be strictly |
| * prohibited. |
| * |
| * MediaTek Inc. (C) 2018. All rights reserved. |
| * |
| * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER |
| * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL |
| * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED |
| * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR |
| * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH |
| * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, |
| * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES |
| * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. |
| * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO |
| * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK |
| * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE |
| * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR |
| * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S |
| * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE |
| * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE |
| * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE |
| * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| * |
| * The following software/firmware and/or related documentation ("MediaTek |
| * Software") have been modified by MediaTek Inc. All revisions are subject to |
| * any receiver's applicable license agreements with MediaTek Inc. |
| */ |
| |
| #ifndef MIDDLEWARE_CLI_CLI_QUEUE_H |
| #define MIDDLEWARE_CLI_CLI_QUEUE_H |
| |
| #include <cli/cli.h> |
| #include <stdint.h> |
| |
| #define NO_WAIT 0 |
| #define WAIT_FOREVER 1 |
| |
| #define BQ_OK 0 |
| #define BQ_E_EMPTY -1 |
| |
| #define BQ_NO_WAIT 0 |
| #define BQ_WAIT_FOREVER -1 |
| |
| struct cli_queue { |
| struct list_node list; |
| uint32_t len; |
| int32_t task_id; |
| }; |
| |
| struct cli_byte_queue { |
| uint8_t *buff; |
| uint32_t head; |
| uint32_t tail; |
| |
| uint32_t capacity; /* buffer size */ |
| uint32_t len; /* available data qty */ |
| uint32_t drop; /* dropped data qty */ |
| uint32_t rx; /* accumulated data qty */ |
| uint32_t rx_ov; /* accumulated overflow times */ |
| |
| void *task_id; |
| }; |
| |
| #define INVALID_TID -1 |
| void q_init(struct cli_queue *q, |
| int32_t task_id); |
| |
| int32_t event_enq(struct cli_queue *q, |
| struct cli_event *ep); |
| int32_t str_enq(struct cli_queue *q, |
| struct cli_str *sp); |
| int32_t flow_enq(struct cli_queue *q, |
| struct cli_flow *fp); |
| int32_t rsp_enq(struct cli_queue *q, |
| struct cli_req *rp); |
| |
| struct cli_event *event_deq(struct cli_queue *q, |
| uint32_t wait_forever); |
| struct cli_str *str_deq(struct cli_queue *q, |
| uint32_t wait_forever, |
| int32_t task_id); |
| struct cli_flow *flow_deq(struct cli_queue *q, |
| uint32_t wait_forever); |
| struct cli_req *rsp_deq(struct cli_queue *q, |
| uint32_t wait_forever, |
| int32_t task_id); |
| |
| int32_t event_find_dup(struct cli_queue *q, |
| struct cli_event *ep); |
| |
| |
| int32_t bq_init(struct cli_byte_queue *bq, |
| uint8_t *buffer, |
| uint32_t size); |
| uint32_t bq_enq(struct cli_byte_queue *bq, |
| uint8_t *bytes, |
| uint32_t size); |
| int32_t bq_deq(struct cli_byte_queue *bq, |
| uint8_t *obyte, |
| int32_t timeout); |
| |
| |
| #endif /* MIDDLEWARE_CLI_CLI_QUEUE_H */ |