ramips: remove 2.6.3[24] support
[openwrt.git] / target / linux / generic / files / crypto / ocf / kirkwood / mvHal / common / mvStack.c
1 /*******************************************************************************
2 * Copyright 2003, Marvell Semiconductor Israel LTD. *
3 * THIS CODE CONTAINS CONFIDENTIAL INFORMATION OF MARVELL. *
4 * NO RIGHTS ARE GRANTED HEREIN UNDER ANY PATENT, MASK WORK RIGHT OR COPYRIGHT *
5 * OF MARVELL OR ANY THIRD PARTY. MARVELL RESERVES THE RIGHT AT ITS SOLE *
6 * DISCRETION TO REQUEST THAT THIS CODE BE IMMEDIATELY RETURNED TO MARVELL. *
7 * THIS CODE IS PROVIDED "AS IS". MARVELL MAKES NO WARRANTIES, EXPRESSED, *
8 * IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, COMPLETENESS OR PERFORMANCE. *
9 * *
10 * MARVELL COMPRISES MARVELL TECHNOLOGY GROUP LTD. (MTGL) AND ITS SUBSIDIARIES, *
11 * MARVELL INTERNATIONAL LTD. (MIL), MARVELL TECHNOLOGY, INC. (MTI), MARVELL *
12 * SEMICONDUCTOR, INC. (MSI), MARVELL ASIA PTE LTD. (MAPL), MARVELL JAPAN K.K. *
13 * (MJKK), MARVELL SEMICONDUCTOR ISRAEL LTD (MSIL). *
14 ********************************************************************************
15 * mvQueue.c
16 *
17 * FILENAME: $Workfile: mvStack.c $
18 * REVISION: $Revision: 1.1 $
19 * LAST UPDATE: $Modtime: $
20 *
21 * DESCRIPTION:
22 * This file implements simple Stack LIFO functionality.
23 *******************************************************************************/
24
25 /* includes */
26 #include "mvOs.h"
27 #include "mvTypes.h"
28 #include "mvDebug.h"
29 #include "mvStack.h"
30
31 /* defines */
32
33
34 /* Public functions */
35
36
37 /* Purpose: Create new stack
38 * Inputs:
39 * - MV_U32 noOfElements - maximum number of elements in the stack.
40 * Each element 4 bytes size
41 * Return: void* - pointer to created stack.
42 */
43 void* mvStackCreate(int numOfElements)
44 {
45 MV_STACK* pStack;
46 MV_U32* pStackElements;
47
48 pStack = (MV_STACK*)mvOsMalloc(sizeof(MV_STACK));
49 pStackElements = (MV_U32*)mvOsMalloc(numOfElements*sizeof(MV_U32));
50 if( (pStack == NULL) || (pStackElements == NULL) )
51 {
52 mvOsPrintf("mvStack: Can't create new stack\n");
53 return NULL;
54 }
55 memset(pStackElements, 0, numOfElements*sizeof(MV_U32));
56 pStack->numOfElements = numOfElements;
57 pStack->stackIdx = 0;
58 pStack->stackElements = pStackElements;
59
60 return pStack;
61 }
62
63 /* Purpose: Delete existing stack
64 * Inputs:
65 * - void* stackHndl - Stack handle as returned by "mvStackCreate()" function
66 *
67 * Return: MV_STATUS MV_NOT_FOUND - Failure. StackHandle is not valid.
68 * MV_OK - Success.
69 */
70 MV_STATUS mvStackDelete(void* stackHndl)
71 {
72 MV_STACK* pStack = (MV_STACK*)stackHndl;
73
74 if( (pStack == NULL) || (pStack->stackElements == NULL) )
75 return MV_NOT_FOUND;
76
77 mvOsFree(pStack->stackElements);
78 mvOsFree(pStack);
79
80 return MV_OK;
81 }
82
83
84 /* PrintOut status of the stack */
85 void mvStackStatus(void* stackHndl, MV_BOOL isPrintElements)
86 {
87 int i;
88 MV_STACK* pStack = (MV_STACK*)stackHndl;
89
90 mvOsPrintf("StackHandle=%p, pElements=%p, numElements=%d, stackIdx=%d\n",
91 stackHndl, pStack->stackElements, pStack->numOfElements,
92 pStack->stackIdx);
93 if(isPrintElements == MV_TRUE)
94 {
95 for(i=0; i<pStack->stackIdx; i++)
96 {
97 mvOsPrintf("%3d. Value=0x%x\n", i, pStack->stackElements[i]);
98 }
99 }
100 }
This page took 0.046703 seconds and 5 git commands to generate.