Home | History | Annotate | Download | only in libbridge
      1 /*
      2  * dspbridge/src/api/linux/DSPProcessor_OEM.c
      3  *
      4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
      5  *
      6  * Copyright (C) 2007 Texas Instruments, Inc.
      7  *
      8  * This program is free software; you can redistribute it and/or modify it
      9  * under the terms of the GNU Lesser General Public License as published
     10  * by the Free Software Foundation version 2.1 of the License.
     11  *
     12  * This program is distributed .as is. WITHOUT ANY WARRANTY of any kind,
     13  * whether express or implied; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Lesser General Public License for more details.
     16  */
     17 
     18 /*
     19  *  ======== DSPProcessor_OEM.c ========
     20  *  Description:
     21  *      This is the source for the DSP/BIOS Bridge API processor module.
     22  *
     23  *  Public Functions:
     24  *      DSPProcessor_Ctrl       - OEM
     25  *      DSPProcessor_GetTrace   - OEM
     26  *      DSPProcessor_Load       - OEM
     27  *      DSPProcessor_Start      - OEM
     28  *
     29  *! Revision History
     30  *! ================
     31  *! 29-Nov-2000 rr: Seperated from DSPProcessor.c
     32  *
     33  */
     34 
     35 /*  ----------------------------------- Host OS */
     36 #include <host_os.h>
     37 
     38 /*  ----------------------------------- DSP/BIOS Bridge */
     39 #include <dbdefs.h>
     40 #include <errbase.h>
     41 
     42 /*  ----------------------------------- Others */
     43 #include <dsptrap.h>
     44 
     45 /*  ----------------------------------- This */
     46 #include "_dbdebug.h"
     47 #include "_dbpriv.h"
     48 #include <DSPProcessor_OEM.h>
     49 #ifdef DEBUG_BRIDGE_PERF
     50 #include <perfutils.h>
     51 #endif
     52 
     53 
     54 
     55 /*
     56  *  ======== DSPProcessor_Ctrl ========
     57  *  Purpose:
     58  *      Pass control information to the GPP device driver managing the
     59  *      DSP processor.
     60  *      This will be an OEM-only function, and not part of the 'Bridge
     61  *      application developer's API.
     62  */
     63 DBAPI DSPProcessor_Ctrl(DSP_HPROCESSOR hProcessor, ULONG dwCmd,
     64 		  IN OPTIONAL struct DSP_CBDATA *pArgs)
     65 {
     66 	DSP_STATUS status = DSP_SOK;
     67 	Trapped_Args tempStruct;
     68 
     69 	DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("PROC: DSPProcessor_Ctrl\r\n")));
     70 
     71 	/* Check the handle */
     72 	if (hProcessor) {
     73 		tempStruct.ARGS_PROC_CTRL.hProcessor = hProcessor;
     74 		tempStruct.ARGS_PROC_CTRL.dwCmd = dwCmd;
     75 		tempStruct.ARGS_PROC_CTRL.pArgs = pArgs;
     76 		status = DSPTRAP_Trap(&tempStruct, CMD_PROC_CTRL_OFFSET);
     77 	} else {
     78 		/* Invalid handle */
     79 		status = DSP_EHANDLE;
     80 		DEBUGMSG(DSPAPI_ZONE_ERROR,
     81 				(TEXT("PROC: Invalid Handle \r\n")));
     82 	}
     83 
     84 	return status;
     85 }
     86 
     87 /*
     88  *  ======== DSPProcessor_Load ========
     89  *  Purpose:
     90  *      Reset a processor and load a new base program image.
     91  *      This will be an OEM-only function, and not part of the 'Bridge
     92  *      application developer's API.
     93  */
     94 DBAPI DSPProcessor_Load(DSP_HPROCESSOR hProcessor, IN CONST INT iArgc,
     95 		  IN CONST CHAR **aArgv, IN CONST CHAR **aEnvp)
     96 {
     97 	DSP_STATUS status = DSP_SOK;
     98 	Trapped_Args tempStruct;
     99 #ifdef DEBUG_BRIDGE_PERF
    100 	struct timeval tv_beg;
    101 	struct timeval tv_end;
    102 	struct timezone tz;
    103 	int timeRetVal = 0;
    104 
    105 	timeRetVal = getTimeStamp(&tv_beg);
    106 #endif
    107 
    108 
    109 	DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("PROC: DSPProcessor_Load\r\n")));
    110 
    111 	/* Check the handle */
    112 	if (hProcessor) {
    113 		if (iArgc > 0) {
    114 			if (!DSP_ValidReadPtr(aArgv, iArgc)) {
    115 				tempStruct.ARGS_PROC_LOAD.hProcessor =
    116 						hProcessor;
    117 				tempStruct.ARGS_PROC_LOAD.iArgc = iArgc;
    118 				tempStruct.ARGS_PROC_LOAD.aArgv =
    119 						(CHAR **)aArgv;
    120 				tempStruct.ARGS_PROC_LOAD.aEnvp =
    121 						(CHAR **)aEnvp;
    122 				status = DSPTRAP_Trap(&tempStruct,
    123 						CMD_PROC_LOAD_OFFSET);
    124 			} else {
    125 				status = DSP_EPOINTER;
    126 				DEBUGMSG(DSPAPI_ZONE_ERROR,
    127 				(TEXT("PROC: Null pointer in input \r\n")));
    128 			}
    129 		} else {
    130 			status = DSP_EINVALIDARG;
    131 			DEBUGMSG(DSPAPI_ZONE_ERROR,
    132 					(TEXT("PROC: iArgc is invalid. \r\n")));
    133 		}
    134 	} else {
    135 		/* Invalid handle */
    136 		status = DSP_EHANDLE;
    137 		DEBUGMSG(DSPAPI_ZONE_ERROR,
    138 				(TEXT("PROC: Invalid Handle \r\n")));
    139 	}
    140 
    141 #ifdef DEBUG_BRIDGE_PERF
    142 	timeRetVal = getTimeStamp(&tv_end);
    143 	PrintStatistics(&tv_beg, &tv_end, "DSPProcessor_Load", 0);
    144 
    145 #endif
    146 
    147 	return status;
    148 }
    149 
    150 /*
    151  *  ======== DSPProcessor_Start ========
    152  *  Purpose:
    153  *      Start a processor running.
    154  */
    155 DBAPI DSPProcessor_Start(DSP_HPROCESSOR hProcessor)
    156 {
    157 	DSP_STATUS status = DSP_SOK;
    158 	Trapped_Args tempStruct;
    159 
    160 	DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("PROC: DSPProcessor_Start\r\n")));
    161 
    162 	/* Check the handle */
    163 	if (hProcessor) {
    164 		tempStruct.ARGS_PROC_START.hProcessor = hProcessor;
    165 		status = DSPTRAP_Trap(&tempStruct, CMD_PROC_START_OFFSET);
    166 	} else {
    167 		/* Invalid handle */
    168 		status = DSP_EHANDLE;
    169 		DEBUGMSG(DSPAPI_ZONE_ERROR,
    170 				(TEXT("PROC: Invalid Handle \r\n")));
    171 	}
    172 
    173 	return status;
    174 }
    175 
    176 /*
    177  *  ======== DSPProcessor_Stop ========
    178  *  Purpose:
    179  *      Stop a running processor .
    180  */
    181 DBAPI DSPProcessor_Stop(DSP_HPROCESSOR hProcessor)
    182 {
    183 	DSP_STATUS status = DSP_SOK;
    184 	Trapped_Args tempStruct;
    185 
    186 	DEBUGMSG(DSPAPI_ZONE_FUNCTION, (TEXT("PROC: DSPProcessor_Stop\r\n")));
    187 
    188 	/* Check the handle */
    189 	if (hProcessor) {
    190 		tempStruct.ARGS_PROC_START.hProcessor = hProcessor;
    191 		status = DSPTRAP_Trap(&tempStruct, CMD_PROC_STOP_OFFSET);
    192 	} else {
    193 		/* Invalid handle */
    194 		status = DSP_EHANDLE;
    195 		DEBUGMSG(DSPAPI_ZONE_ERROR,
    196 				(TEXT("PROC: Invalid Handle \r\n")));
    197 	}
    198 
    199 	return status;
    200 }
    201