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 11 * 12 ********************************************************************* 13 * 14 * Copyright 2000,2001,2002,2003 15 * Broadcom Corporation. All rights reserved. 16 * 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. 23 * 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. 27 * 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. 33 * 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 ********************************************************************* */ 48 49#include "cfe.h" 50#include "cfe_vendor_iocb.h" 51#include "cfe_mem.h" 52#include "cfe_fileops.h" 53#include "cfe_boot.h" 54#include "env_subr.h" 55 56/* ********************************************************************* 57 * Constants 58 ********************************************************************* */ 59 60#define HV 1 /* handle valid */ 61 62/* ********************************************************************* 63 * Globals 64 ********************************************************************* */ 65 66extern cfe_devctx_t *cfe_handle_table[CFE_MAX_HANDLE]; 67 68/* ********************************************************************* 69 * Prototypes 70 ********************************************************************* */ 71 72int cfe_vendor_iocb_dispatch(cfe_iocb_t *iocb); 73 74/* ********************************************************************* 75 * Dispatch table 76 ********************************************************************* */ 77 78struct cfe_vendor_cmd_dispatch_s { 79 int plistsize; 80 int flags; 81 int (*func)(cfe_devctx_t *ctx,cfe_iocb_t *iocb); 82}; 83 84 85static int cfe_cmd_vendor_sample(cfe_devctx_t *ctx,cfe_iocb_t *iocb); 86 87const static struct cfe_vendor_cmd_dispatch_s 88 cfe_vendor_cmd_dispatch_table[CFE_CMD_VENDOR_MAX - CFE_CMD_VENDOR_USE] = { 89 {sizeof(iocb_buffer_t), 0, cfe_cmd_vendor_sample}, /* 0 : CFE_CMD_VENDOR_SAMPLE */ 90}; 91 92/* ********************************************************************* 93 * IOCB dispatch routines 94 ********************************************************************* */ 95 96 97int cfe_vendor_iocb_dispatch(cfe_iocb_t *iocb) 98{ 99 const struct cfe_vendor_cmd_dispatch_s *disp; 100 int res; 101 cfe_devctx_t *ctx; 102 103 /* 104 * Check for commands codes out of range 105 */ 106 107 if ((iocb->iocb_fcode < CFE_CMD_VENDOR_USE) || 108 (iocb->iocb_fcode >= CFE_CMD_VENDOR_MAX)) { 109 iocb->iocb_status = CFE_ERR_INV_COMMAND; 110 return iocb->iocb_status; 111 } 112 113 /* 114 * Check for command codes in range but invalid 115 */ 116 117 disp = &cfe_vendor_cmd_dispatch_table[iocb->iocb_fcode - CFE_CMD_VENDOR_USE]; 118 119 if (disp->plistsize < 0) { 120 iocb->iocb_status = CFE_ERR_INV_COMMAND; 121 return iocb->iocb_status; 122 } 123 124 /* 125 * Check for invalid parameter list size 126 */ 127 128 if (disp->plistsize != iocb->iocb_psize) { 129 iocb->iocb_status = CFE_ERR_INV_PARAM; 130 return iocb->iocb_status; 131 } 132 133 /* 134 * Determine handle 135 */ 136 137 ctx = NULL; 138 if (disp->flags & HV) { 139 if ((iocb->iocb_handle >= CFE_MAX_HANDLE) || 140 (iocb->iocb_handle < 0) || 141 (cfe_handle_table[iocb->iocb_handle] == NULL)){ 142 iocb->iocb_status = CFE_ERR_INV_PARAM; 143 return iocb->iocb_status; 144 } 145 ctx = cfe_handle_table[iocb->iocb_handle]; 146 } 147 148 /* 149 * Dispatch to handler routine 150 */ 151 152 res = (*disp->func)(ctx,iocb); 153 154 iocb->iocb_status = res; 155 return res; 156} 157 158 159 160/* ********************************************************************* 161 * Implementation routines for each IOCB function 162 ********************************************************************* */ 163 164static int cfe_cmd_vendor_sample(cfe_devctx_t *ctx,cfe_iocb_t *iocb) 165{ 166 return CFE_OK; 167} 168