WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_sortlink_pri.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
3 * Description: Sortlink Private HeadFile
4 * Author: Huawei LiteOS Team
5 * Create: 2013-01-01
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * --------------------------------------------------------------------------- */
28
29#ifndef _LOS_SORTLINK_PRI_H
30#define _LOS_SORTLINK_PRI_H
31
32#include "los_typedef.h"
33#include "los_list.h"
34#include "los_config.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif /* __cplusplus */
39
40/*
41 * Sortlink Rollnum Structure:
42 * ------------------------------------------
43 * | 31 | 30 | 29 |.......| 4 | 3 | 2 | 1 | 0 |
44 * ------------------------------------------
45 * |<-High Bits->|<---------Low Bits--------->|
46 *
47 * Low Bits : circles
48 * High Bits : sortlink index
49 */
50#ifndef LOSCFG_BASE_CORE_USE_SINGLE_LIST
51#ifndef LOSCFG_BASE_CORE_USE_MULTI_LIST
52#error "NO SORTLIST TYPE SELECTED"
53#endif
54#endif
55
56#ifdef LOSCFG_BASE_CORE_USE_SINGLE_LIST
57
58#define OS_TSK_SORTLINK_LOGLEN 0U
59#define OS_TSK_SORTLINK_LEN 1U
60#define OS_TSK_MAX_ROLLNUM 0xFFFFFFFEU
61#define OS_TSK_LOW_BITS_MASK 0xFFFFFFFFU
62
63#define SORTLINK_CURSOR_UPDATE(CURSOR)
64#define SORTLINK_LISTOBJ_GET(LISTOBJ, SORTLINK) (LISTOBJ = SORTLINK->sortLink)
65
66#define ROLLNUM_SUB(NUM1, NUM2) ((NUM1) = (ROLLNUM(NUM1) - ROLLNUM(NUM2)))
67#define ROLLNUM_ADD(NUM1, NUM2) ((NUM1) = (ROLLNUM(NUM1) + ROLLNUM(NUM2)))
68#define ROLLNUM_DEC(NUM) ((NUM) = ((NUM) - 1))
69#define ROLLNUM(NUM) (NUM)
70
71#define SET_SORTLIST_VALUE(sortList, value) (((SortLinkList *)(sortList))->idxRollNum = (value))
72
73#else
74
75#define OS_TSK_HIGH_BITS 3U
76#define OS_TSK_LOW_BITS (32U - OS_TSK_HIGH_BITS)
77#define OS_TSK_SORTLINK_LOGLEN OS_TSK_HIGH_BITS
78#define OS_TSK_SORTLINK_LEN (1U << OS_TSK_SORTLINK_LOGLEN)
79#define OS_TSK_SORTLINK_MASK (OS_TSK_SORTLINK_LEN - 1U)
80#define OS_TSK_MAX_ROLLNUM (0xFFFFFFFFU - OS_TSK_SORTLINK_LEN)
81#define OS_TSK_HIGH_BITS_MASK (OS_TSK_SORTLINK_MASK << OS_TSK_LOW_BITS)
82#define OS_TSK_LOW_BITS_MASK (~OS_TSK_HIGH_BITS_MASK)
83
84#define SORTLINK_CURSOR_UPDATE(CURSOR) ((CURSOR) = ((CURSOR) + 1) & OS_TSK_SORTLINK_MASK)
85#define SORTLINK_LISTOBJ_GET(LISTOBJ, SORTLINK) ((LISTOBJ) = (SORTLINK)->sortLink + (SORTLINK)->cursor)
86
87#define EVALUATE_L(NUM, VALUE) ((NUM) = (((NUM) & OS_TSK_HIGH_BITS_MASK) | (VALUE)))
88
89#define EVALUATE_H(NUM, VALUE) ((NUM) = (((NUM) & OS_TSK_LOW_BITS_MASK) | ((VALUE) << OS_TSK_LOW_BITS)))
90
91#define ROLLNUM_SUB(NUM1, NUM2) ((NUM1) = (((NUM1) & OS_TSK_HIGH_BITS_MASK) | \
92 (ROLLNUM(NUM1) - ROLLNUM(NUM2))))
93
94#define ROLLNUM_ADD(NUM1, NUM2) ((NUM1) = (((NUM1) & OS_TSK_HIGH_BITS_MASK) | \
95 (ROLLNUM(NUM1) + ROLLNUM(NUM2))))
96
97#define ROLLNUM_DEC(NUM) ((NUM) = ((NUM) - 1))
98
99#define ROLLNUM(NUM) ((NUM) & OS_TSK_LOW_BITS_MASK)
100
101#define SORT_INDEX(NUM) ((NUM) >> OS_TSK_LOW_BITS)
102
103#define SET_SORTLIST_VALUE(sortList, value) (((SortLinkList *)(sortList))->idxRollNum = (value))
104
105#endif
106
111
117
118extern VOID OsSortLinkInit(SortLinkAttribute *sortLinkHeader, LOS_DL_LIST *list);
119extern VOID OsAdd2SortLink(const SortLinkAttribute *sortLinkHeader, SortLinkList *sortList);
120extern VOID OsDeleteSortLink(const SortLinkAttribute *sortLinkHeader, SortLinkList *sortList);
123 const SortLinkList *targetSortList);
124extern VOID OsSortLinkUpdateExpireTime(UINT32 sleepTicks, SortLinkAttribute *sortLinkHeader);
127#ifdef __cplusplus
128}
129#endif /* __cplusplus */
130
131#endif /* _LOS_SORTLINK_PRI_H */
unsigned short UINT16
Definition los_typedef.h:51
#define VOID
Definition los_typedef.h:88
unsigned int UINTPTR
Definition los_typedef.h:74
unsigned int UINT32
Definition los_typedef.h:52
Definition los_list.h:47
Definition los_sortlink_pri.h:112
UINT16 reserved
Definition los_sortlink_pri.h:115
UINT16 cursor
Definition los_sortlink_pri.h:114
LOS_DL_LIST * sortLink
Definition los_sortlink_pri.h:113