GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / vendor / cfe_vendor_iocb_dispatch.c
blobfb00c03f3b3d963abbfc1dff56eb61d82c940134
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * IOCB dispatcher File: cfe_vendor_iocb_dispatch.c
5 *
6 * This routine is the main API dispatch for CFE. User API
7 * calls, via the ROM entry point, get dispatched to routines
8 * in this module.
9 *
10 * Author: Mitch Lichtenberg (mpl@broadcom.com)
12 *********************************************************************
14 * Copyright 2000,2001,2002,2003
15 * Broadcom Corporation. All rights reserved.
17 * This software is furnished under license and may be used and
18 * copied only in accordance with the following terms and
19 * conditions. Subject to these conditions, you may download,
20 * copy, install, use, modify and distribute modified or unmodified
21 * copies of this software in source and/or binary form. No title
22 * or ownership is transferred hereby.
24 * 1) Any source code used, modified or distributed must reproduce
25 * and retain this copyright notice and list of conditions
26 * as they appear in the source file.
28 * 2) No right is granted to use any trade name, trademark, or
29 * logo of Broadcom Corporation. The "Broadcom Corporation"
30 * name may not be used to endorse or promote products derived
31 * from this software without the prior written permission of
32 * Broadcom Corporation.
34 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
35 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
36 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
38 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
39 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
40 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
42 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
44 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
45 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
46 * THE POSSIBILITY OF SUCH DAMAGE.
47 ********************************************************************* */
50 #include "lib_types.h"
51 #include "lib_malloc.h"
52 #include "lib_queue.h"
53 #include "lib_printf.h"
54 #include "lib_string.h"
55 #include "cfe_iocb.h"
56 #include "cfe_vendor_iocb.h"
57 #include "cfe_error.h"
58 #include "cfe_device.h"
59 #include "cfe_timer.h"
60 #include "cfe_mem.h"
61 #include "cfe_fileops.h"
62 #include "cfe_boot.h"
63 #include "env_subr.h"
64 #include "cfe.h"
65 #include "cfe_console.h"
66 #include "bsp_config.h"
68 /* *********************************************************************
69 * Constants
70 ********************************************************************* */
72 #define HV 1 /* handle valid */
74 /* *********************************************************************
75 * Globals
76 ********************************************************************* */
78 extern cfe_devctx_t *cfe_handle_table[CFE_MAX_HANDLE];
80 /* *********************************************************************
81 * Prototypes
82 ********************************************************************* */
84 int cfe_vendor_iocb_dispatch(cfe_iocb_t *iocb);
86 /* *********************************************************************
87 * Dispatch table
88 ********************************************************************* */
90 struct cfe_vendor_cmd_dispatch_s {
91 int plistsize;
92 int flags;
93 int (*func)(cfe_devctx_t *ctx,cfe_iocb_t *iocb);
97 static int cfe_cmd_vendor_sample(cfe_devctx_t *ctx,cfe_iocb_t *iocb);
99 const static struct cfe_vendor_cmd_dispatch_s
100 cfe_vendor_cmd_dispatch_table[CFE_CMD_VENDOR_MAX - CFE_CMD_VENDOR_USE] = {
101 {sizeof(iocb_buffer_t), 0, cfe_cmd_vendor_sample}, /* 0 : CFE_CMD_VENDOR_SAMPLE */
104 /* *********************************************************************
105 * IOCB dispatch routines
106 ********************************************************************* */
109 int cfe_vendor_iocb_dispatch(cfe_iocb_t *iocb)
111 const struct cfe_vendor_cmd_dispatch_s *disp;
112 int res;
113 cfe_devctx_t *ctx;
116 * Check for commands codes out of range
119 if ((iocb->iocb_fcode < CFE_CMD_VENDOR_USE) ||
120 (iocb->iocb_fcode >= CFE_CMD_VENDOR_MAX)) {
121 iocb->iocb_status = CFE_ERR_INV_COMMAND;
122 return iocb->iocb_status;
126 * Check for command codes in range but invalid
129 disp = &cfe_vendor_cmd_dispatch_table[iocb->iocb_fcode - CFE_CMD_VENDOR_USE];
131 if (disp->plistsize < 0) {
132 iocb->iocb_status = CFE_ERR_INV_COMMAND;
133 return iocb->iocb_status;
137 * Check for invalid parameter list size
140 if (disp->plistsize != iocb->iocb_psize) {
141 iocb->iocb_status = CFE_ERR_INV_PARAM;
142 return iocb->iocb_status;
146 * Determine handle
149 ctx = NULL;
150 if (disp->flags & HV) {
151 if ((iocb->iocb_handle >= CFE_MAX_HANDLE) ||
152 (iocb->iocb_handle < 0) ||
153 (cfe_handle_table[iocb->iocb_handle] == NULL)){
154 iocb->iocb_status = CFE_ERR_INV_PARAM;
155 return iocb->iocb_status;
157 ctx = cfe_handle_table[iocb->iocb_handle];
161 * Dispatch to handler routine
164 res = (*disp->func)(ctx,iocb);
166 iocb->iocb_status = res;
167 return res;
172 /* *********************************************************************
173 * Implementation routines for each IOCB function
174 ********************************************************************* */
176 static int cfe_cmd_vendor_sample(cfe_devctx_t *ctx,cfe_iocb_t *iocb)
178 return CFE_OK;