📄 mld_anwi.c
字号:
A_UINT32 persistent,
A_UINT32 param1,
A_UINT32 param2,
A_UINT32 param3,
EVT_HANDLE eventHandle
)
{
MDK_WLAN_DEV_INFO *pdevInfo;
A_BOOL status;
A_UINT32 bR = 0;
anwiReturnContext returnContext;
anwiEventOpStruct event;
HANDLE hnd;
pdevInfo = globDrvInfo.pDevInfoArray[devIndex];
#ifdef LEGACY
event.cliId = pdevInfo->cliId;
#endif
event.opType = ANWI_CREATE_EVENT;
event.valid = 1;
event.param[0] = type;
event.param[1] = persistent;
event.param[2] = param1;
event.param[3] = param2;
event.param[4] = param3;
event.param[5] = (eventHandle.f2Handle << 16) | eventHandle.eventID;
#ifdef LEGACY
hnd = hDriver;
#else
hnd = pdevInfo->hDevice;
#endif
status = DeviceIoControl (hnd,
IOCTL_ANWI_EVENT_OP,
&event,
sizeof(event),
&returnContext,
sizeof(anwiReturnContext),
&bR,
NULL);
if ((!status) || (returnContext.returnCode != ANWI_OK)) {
printf("Error returned by event op DeviceIoControl call \n");
return -1;
}
return(0);
}
A_UINT16 getNextEvent
(
A_UINT16 devIndex,
EVENT_STRUCT *pEvent
)
{
MDK_WLAN_DEV_INFO *pdevInfo;
A_BOOL status;
A_UINT32 bR = 0;
anwiReturnContext returnContext;
anwiEventOpStruct inEvent;
pAnwiEventOpStruct outEvent;
A_UINT32 i;
HANDLE hnd;
pdevInfo = globDrvInfo.pDevInfoArray[devIndex];
#ifdef LEGACY
inEvent.cliId = pdevInfo->cliId;
#endif
inEvent.opType = ANWI_GET_NEXT_EVENT;
inEvent.valid = 0;
#ifdef LEGACY
hnd = hDriver;
#else
hnd = pdevInfo->hDevice;
#endif
status = DeviceIoControl (hnd,
IOCTL_ANWI_EVENT_OP,
&inEvent,
sizeof(anwiEventOpStruct),
&returnContext,
sizeof(anwiReturnContext),
&bR,
NULL);
if ((!status) || (returnContext.returnCode != ANWI_OK)) {
printf("Error returned by event op DeviceIoControl call \n");
return 0;
}
if (returnContext.contextLen != sizeof(anwiEventOpStruct)) {
printf("Return size (%d) from event op DeviceIoControl call doesnt match the expected size (%d) \n",returnContext.contextLen,sizeof(anwiEventOpStruct));
return 0;
}
outEvent = (pAnwiEventOpStruct) returnContext.context;
if (!outEvent->valid) {
return 0;
}
pEvent->type = outEvent->param[0];
pEvent->persistent = outEvent->param[1];
pEvent->param1 = outEvent->param[2];
pEvent->param2 = outEvent->param[3];
pEvent->param3 = outEvent->param[4];
pEvent->eventHandle.eventID = outEvent->param[5] & 0xffff;
pEvent->eventHandle.f2Handle = (outEvent->param[5] >> 16 ) & 0xffff;
for (i=0;i<6;i++) {
pEvent->result[i] = outEvent->param[6+i];
}
return(1);
}
/**************************************************************************
* hwMemWriteBlock - Write a block of memory within the simulation environment
*
* Write a block of memory within the simulation environment
*
*
* RETURNS: 0 on success, -1 on error
*/
A_INT16 hwMemWriteBlock
(
A_UINT16 devIndex,
A_UCHAR *pBuffer,
A_UINT32 length,
A_UINT32 *pPhysAddr
)
{
A_UCHAR *pMem; /* virtual pointer to area to be written */
MDK_WLAN_DEV_INFO *pdevInfo;
A_UINT32 startPhysAddr; /* physical address of start of device memory block,
for easier readability */
pdevInfo = globDrvInfo.pDevInfoArray[devIndex];
if(*pPhysAddr == 0)
{
return(-1);
}
/* first need to check that the phys address is within the allocated memory block.
Need to make sure that the begin size and endsize match. Will check all the
devices. Only checking the memory block, will not allow registers to be accessed
this way
*/
//check start and end addresswithin memory allocation
startPhysAddr = pdevInfo->pdkInfo->memPhyAddr;
if((*pPhysAddr >= startPhysAddr) &&
(*pPhysAddr <= (startPhysAddr + pdevInfo->pdkInfo->memSize)) &&
((*pPhysAddr + length) >= startPhysAddr) &&
((*pPhysAddr + length) <= (startPhysAddr + pdevInfo->pdkInfo->memSize))
) {
/* address is within range, so can do the write */
/* get the virtual pointer to start and read */
pMem = (A_UINT8 *) (pdevInfo->pdkInfo->memVirAddr + (*pPhysAddr - pdevInfo->pdkInfo->memPhyAddr));
memcpy(pMem, pBuffer, length);
return(0);
}
// check within the register regions
startPhysAddr = pdevInfo->pdkInfo->f2MapAddress;
if ((*pPhysAddr >= startPhysAddr) &&
(*pPhysAddr < startPhysAddr + pdevInfo->pdkInfo->regMapRange) &&
((*pPhysAddr + length) >= startPhysAddr) &&
((*pPhysAddr + length) <= (startPhysAddr + pdevInfo->pdkInfo->regMapRange))) {
pMem = (A_UINT8 *) (pdevInfo->pdkInfo->regVirAddr + (*pPhysAddr - pdevInfo->pdkInfo->f2MapAddress));
memcpy(pMem, pBuffer, length);
return(0);
}
/* if got to here, then address is bad */
uiPrintf("Warning: Address is not within legal memory range, nothing written\n");
return(-1);
}
/**************************************************************************
* hwMemReadBlock - Read a block of memory within the simulation environment
*
* Read a block of memory within the simulation environment
*
*
* RETURNS: 0 on success, -1 on error
*/
A_INT16 hwMemReadBlock
(
A_UINT16 devIndex,
A_UCHAR *pBuffer,
A_UINT32 physAddr,
A_UINT32 length
)
{
A_UCHAR *pMem; /* virtual pointer to area to be written */
MDK_WLAN_DEV_INFO *pdevInfo;
A_UINT32 startPhysAddr; /* physical address of start of device memory block,
for easier readability */
pdevInfo = globDrvInfo.pDevInfoArray[devIndex];
/* first need to check that the phys address is within the allocated memory block.
Need to make sure that the begin size and endsize match. Will check all the
devices. Only checking the memory block, will not allow registers to be accessed
this way
*/
//check start and end addresswithin memory allocation
startPhysAddr = pdevInfo->pdkInfo->memPhyAddr;
if((physAddr >= startPhysAddr) &&
(physAddr <= (startPhysAddr + pdevInfo->pdkInfo->memSize)) &&
((physAddr + length) >= startPhysAddr) &&
((physAddr + length) <= (startPhysAddr + pdevInfo->pdkInfo->memSize))
) {
/* address is within range, so can do the read */
/* get the virtual pointer to start and read */
pMem = (A_UINT8 *) (pdevInfo->pdkInfo->memVirAddr + (physAddr - pdevInfo->pdkInfo->memPhyAddr));
memcpy(pBuffer, pMem, length);
return(0);
}
startPhysAddr = pdevInfo->pdkInfo->f2MapAddress;
if ((physAddr >= startPhysAddr) &&
(physAddr < startPhysAddr + pdevInfo->pdkInfo->regMapRange) &&
((physAddr + length) >= startPhysAddr) &&
((physAddr + length) <= (startPhysAddr + pdevInfo->pdkInfo->regMapRange))) {
pMem = (A_UINT8 *) (pdevInfo->pdkInfo->regVirAddr + (physAddr - pdevInfo->pdkInfo->f2MapAddress));
// check within the register regions
memcpy(pBuffer, pMem, length);
return(0);
}
/* if got to here, then address is bad */
uiPrintf("Warning: Address is not within legal memory range, nothing read\n");
return(-1);
}
/**************************************************************************
* uiPrintf - print to the perl console
*
* This routine is the equivalent of printf. It is used such that logging
* capabilities can be added.
*
* RETURNS: same as printf. Number of characters printed
*/
A_INT32 uiPrintf
(
const char * format,
...
)
{
va_list argList;
A_INT32 retval = 0;
A_UCHAR buffer[256];
/*if have logging turned on then can also write to a file if needed */
/* get the arguement list */
va_start(argList, format);
/* using vprintf to perform the printing it is the same is printf, only
* it takes a va_list or arguments
*/
retval = vprintf(format, argList);
fflush(stdout);
if (logging) {
vsprintf(buffer, format, argList);
fputs(buffer, logFile);
fflush(logFile);
}
va_end(argList); /* cleanup arg list */
return(retval);
}
A_INT32 q_uiPrintf
(
const char * format,
...
)
{
va_list argList;
A_INT32 retval = 0;
A_UCHAR buffer[256];
if ( !quietMode ) {
va_start(argList, format);
retval = vprintf(format, argList);
fflush(stdout);
if ( logging ) {
vsprintf(buffer, format, argList);
fputs(buffer, logFile);
}
va_end(argList); // clean up arg list
}
return(retval);
}
/**************************************************************************
* uilog - turn on logging
*
* A user interface command which turns on logging to a fill, all of the
* information printed on screen
*
* RETURNS: 1 if file opened, 0 if not
*/
A_UINT16 uilog
(
char *filename, /* name of file to log to */
A_BOOL append
)
{
/* open file for writing */
if (append) {
logFile = fopen(filename, "a+");
}
else {
logFile = fopen(filename, "w");
}
if (logFile == NULL) {
uiPrintf("Unable to open file %s\n", filename);
return(0);
}
/* set flag to say logging enabled */
logging = 1;
//turn on logging in the library
enableLogging(filename);
return(1);
}
/**************************************************************************
* uiWriteToLog - write a string to the log file
*
* A user interface command which writes a string to the log file
*
* RETURNS: 1 if sucessful, 0 if not
*/
A_UINT16 uiWriteToLog
(
char *string
)
{
if(logFile == NULL) {
uiPrintf("Error, logfile not valid, unable to write to file\n");
return 0;
}
/* write string to file */
fprintf(logFile, string);
return 1;
}
void configPrint
(
A_BOOL flag
)
{
enablePrint = flag;
}
/**************************************************************************
* uilogClose - close the logging file
*
* A user interface command which closes an already open log file
*
* RETURNS: 1 if file opened, 0 if not
*/
void uilogClose(void)
{
if ( logging ) {
fclose(logFile);
logging = 0;
}
return;
}
/**************************************************************************
* quiet - set quiet mode on or off
*
* A user interface command which turns quiet mode on or off
*
* RETURNS: N/A
*/
void dk_quiet
(
A_UINT16 Mode // 0 for off, 1 for on
)
{
quietMode = Mode;
return;
}
/**************************************************************************
* milliSleep - sleep for the specified number of milliseconds
*
* This routine calls a OS specific routine for sleeping
*
* RETURNS: N/A
*/
void milliSleep
(
A_UINT32 millitime
)
{
Sleep((DWORD) millitime);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -