OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.swp.api/] [openmcapi/] [1.0/] [libmcapi/] [mcapi/] [request.c] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/*
2
 * Copyright (c) 2010, Mentor Graphics Corporation
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
 * POSSIBILITY OF SUCH DAMAGE.
28
 */
29
 
30
 
31
 
32
#include <openmcapi.h>
33
 
34
extern mcapi_request_t      MCAPI_Free_Request_Structs[];
35
 
36
/*************************************************************************
37
*
38
*   FUNCTION
39
*
40
*       mcapi_init_request
41
*
42
*   DESCRIPTION
43
*
44
*       Initializes a request structure.
45
*
46
*   INPUTS
47
*
48
*       *request                A pointer to the request to initialize.
49
*       type                    The type of request.
50
*
51
*   OUTPUTS
52
*
53
*       None.
54
*
55
*************************************************************************/
56
void mcapi_init_request(mcapi_request_t *request, mcapi_uint8_t type)
57
{
58
    /* Zero out the request structure. */
59
    memset(request, 0, sizeof(mcapi_request_t));
60
 
61
    /* Initialize the common parameters. */
62
    request->mcapi_requesting_node_id = MCAPI_Node_ID;
63
    request->mcapi_type = type;
64
    request->mcapi_status = MCAPI_PENDING;
65
 
66
}
67
 
68
/*************************************************************************
69
*
70
*   FUNCTION
71
*
72
*       mcapi_get_free_request_struct
73
*
74
*   DESCRIPTION
75
*
76
*       Returns a free request structure to use for a pending request
77
*       from a foreign node.
78
*
79
*   INPUTS
80
*
81
*       None.
82
*
83
*   OUTPUTS
84
*
85
*       mcapi_request_t
86
*       MCAPI_NULL
87
*
88
*************************************************************************/
89
mcapi_request_t *mcapi_get_free_request_struct(void)
90
{
91
    mcapi_request_t     *request = MCAPI_NULL;
92
    int                 i;
93
 
94
    /* Traverse the list looking for a free entry. */
95
    for (i = 0; i < MCAPI_FREE_REQUEST_COUNT; i++)
96
    {
97
        /* If this entry is available. */
98
        if (MCAPI_Free_Request_Structs[i].mcapi_type == 0)
99
        {
100
            /* Clear any old data from the structure. */
101
            memset(&MCAPI_Free_Request_Structs[i], 0, sizeof(mcapi_request_t));
102
 
103
            /* Return a pointer to the request struct. */
104
            request = &MCAPI_Free_Request_Structs[i];
105
 
106
            break;
107
        }
108
    }
109
 
110
    return (request);
111
 
112
}
113
 
114
/*************************************************************************
115
*
116
*   FUNCTION
117
*
118
*       mcapi_release_request_struct
119
*
120
*   DESCRIPTION
121
*
122
*       Returns the request structure to the free list.
123
*
124
*   INPUTS
125
*
126
*       *req_ptr                A pointer to the structure to free.
127
*
128
*   OUTPUTS
129
*
130
*       None.
131
*
132
*************************************************************************/
133
void mcapi_release_request_struct(mcapi_request_t *req_ptr)
134
{
135
    /* Set the structure to available. */
136
    req_ptr->mcapi_type = 0;
137
 
138
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.