sincerly I found the ar_loadslv code but it make no really help because it make calls to function with no code. if you want it i can post it…
/*===========================================================================*
* ENTRY POINT: A R _ L O A D S L V
*===========================================================================*
*
* FUNCTION: Load and initialize the CEI-x20 dual-port RAM and i960 processor.
*
* RETURN VAL: short -- ARS_NORMAL Success.
* -- ARS_INVBOARD The board segment was out of range.
* -- ARS_BADLOAD The memory test failed and the board was
* not loaded.
* -- ARS_BAD_FPGA Bad number of transmitters or receivers,
* no FPGA support for this config.
*
* DESCRIPTION: This routine loads the Slave Control Program into dual-port
* RAM. (The i960 runs it's firmware out of dual-port RAM).
* This must be the first utility subroutine executed.
*
* The routine resets the slave then performs a memory check on the dual-
* port memory. If the memory test passes, the slave program is loaded
* and started.
*
* Upon successful completion of this routine, the following ARINC defaults
* are in effect: Transmit and receive bit rates are 100K; Parity ODD;
* SDI and label filters disabled; Timer rate 5 milliseconds.
*
*===========================================================================*/
#ifdef __TURBOC__
#pragma argsused
#endif
EXPORT32 short DLL_EXPORTED ar_loadslv(
short cardnum, // (i) Board number associated with this and all
// future references to the board. Since up to
// MAX_BOARDS are supported simultaneously in one
// host, each board has a unique number.
// Under WIN32 this is the WinRT device number
// and the base_seg is ignored.
unsigned long base_seg, // (i) Ignored in WIN32, else is the Base Address of
// the board memory space.
int base_port, // (i) Ignored in WIN32, or if non-zero used to
// enter a special FACTORY TEST mode.
unsigned short ram_size) // (i) unused, should be set to zero. If non-zero
// used to enter a special FACTORY TEST mode.
{
struct CONTROL_DPRAM volatile *ar_base; // Current board pointer.
int channel;
int status; // Device driver and loader function status
#if defined(__WIN32__)
char szINIFileName[260]; // Name and path to our .ini file.
char *lp; // Pointer to .ini file extension.
char szSectionInfo[16]; // Lookup board type.
#else
short dpmi_err_flag = 0; // Status from ar_map_dualportram()
#endif
//------------------------------------------------------------------------
// Check validity of board number.
//------------------------------------------------------------------------
if ( (unsigned)cardnum >= MAX_BOARDS )
return ARS_INVBOARD;
#if defined(__WIN32__) || defined(_UNIX_)
//---------------------------------------------------------------------
// Open CEI-x20 low-level driver to map board into our address space.
// Since this is a WIN32 application, we will call the kernel driver
// open function here. Check to see if driver is already opened,
// then map the memory region and save the memory region pointer.V3.22
//---------------------------------------------------------------------
if ( ar_board[cardnum].board_mapped == 0 )
{
// If this is a CEI-520 board, it has two mapping regions
ar_board[cardnum].pMap.flagMapToHost[0] = 1; // Map the first
ar_board[cardnum].pMap.flagMapToHost[1] = 1; // two memory regions.
status = (short)vbtMapBoardAddresses(cardnum, &ar_board[cardnum].pMap);
// CEI-520/620 is not supported by the standard API, see the Enhanced
// API ("API520.C") for support.
if ( ar_board[cardnum].pMap.flagMapToHost[1] )
{
return ARS_NO_HW_SUPRT; // Only the CEI-520/620 maps two regions
}
else
{
ar_static_base[cardnum] = (void *)ar_board[cardnum].pMap.memHostBase[0];
}
if ( status != BTD_OK )
{
sprintf(last_error, "Failed to map the CEI-x20 board, "
"error %d", status);
return (short)status; // Return LOWLEVEL.C error code.
}
#ifndef _UNIX_
// Initialize a Critical Section to protect the frame register.
InitializeCriticalSection(&hFrameCritSect[cardnum]);
#endif
}
#else
//------------------------------------------------------------------------
// 16-bit Windows and DOS applications map board RAM into memory.
//------------------------------------------------------------------------
base_seg = ar_map_dualportram (cardnum, base_seg, &dpmi_err_flag, ram_size);
if ( dpmi_err_flag != 0 )
return ARS_MEMADERR;
// Create and save the 16-bit land-style pointer.
ar_static_base[cardnum] = MK_FP(base_seg,0);
#endif // endif __WIN32__
/*******************************************************************
* Determine the name of our .INI file, by getting from WINDOWS
* the name of this .dll file, and replacing the ".DLL" with ".INI"
* The purpose of this code is to set the factory debug flag during
* factory test. This entire section can be safely discarded when
* building the API for non-Condor-factory applications!
*******************************************************************/
#if defined(__WIN32__)
GetModuleFileName(GetModuleHandle("CEx22032.DLL"),
(LPSTR)szINIFileName, sizeof(szINIFileName));
//MessageBox(NULL, szINIFileName, "vbtSetup()", MB_OK | MB_SYSTEMMODAL);
lp = strrchr(szINIFileName, '.'); // Find the last '.' in the string.
if ( lp )
strcpy(lp, ".INI");
//MessageBox(NULL, szINIFileName, "vbtSetup()", MB_OK | MB_SYSTEMMODAL);
/*******************************************************************
* Setup a factory test only test flag. If the .ini file does not
* exist, or this entry does not exist, pass through the callers flag.
*******************************************************************/
strcpy(szSectionInfo, "Setup Info0"); // Lookup card/carrier type info
szSectionInfo[10] += (char)cardnum; // for the specified card number.
base_port = GetPrivateProfileInt(szSectionInfo, "EnableTestMode",
base_port, szINIFileName);
/*******************************************************************
* This is the end of the section that can be safely discarded when
* building the API for non-Condor-factory applications!
*******************************************************************/
#endif
// Board has been commanded to not "GO"
ar_board[cardnum].board_ar_go = 0;
// Get the board type (either a CEI-220, CEI-420 or a CEI-420A).
ar_board[cardnum].board_type = 0; // Clear the board type
ar_board[cardnum].ar_inited = 1; // So we can read board type
ar_board[cardnum].board_type = ar_get_boardtype(cardnum);
if ( ar_board[cardnum].board_type == 0 )
return ARS_HW_DETECT;
//----------------------------------------------------------------------
// W A R N I N G !! Ugly Code Follows: +
//---------------------------------------------------------------------+
// Modify the i960 load image...at offset ff90 into dual port. +
// Dual port on the CEI-220/420/420A is 16-bits wide. +
//----------------------------------------------------------------------
#define IBR_BASE (0xF000/2)
// Modify the i960 image for CEI-220/420/420A processors.
i960_data[IBR_BASE+0x0F30/2+4] = 0x0040;
i960_data[IBR_BASE+0x0F80/2+5] = 0x0040; // 16-bit wide
i960_data[IBR_BASE+0x0FB0/2+5] = 0x0040;
//ar_board[cardnum].ar_inited = 0; // We are not done yet...
//------------------------------------------------------------------------
// Initialize some global info for this board and then load and start it.
// i960 comes up in "ar_reset" mode, it does NOT process ARINC data until
// "ar_go" is called, but it DOES process the discretes...
//------------------------------------------------------------------------
ar_board[cardnum].board_mapped = 1;
status = loader(cardnum, base_port, ram_size);
if ( status )
return (short)status; // last_error has already been setup...
//------------------------------------------------------------------------
// Initialize i960 receiver and transmitter buffer data structures. +
// The i960 is running at this point, but it is not ar_go()... +
//------------------------------------------------------------------------
ar_board[cardnum].board_mapped = 2;
ar_board[cardnum].ar_inited = 1;
ar_base = ar_set_cpage(cardnum); // Go to control page zero.
// Clear the timer tick counter. Firmware will load it on the next ar_go().
ar_base->TickTimer = 0;
for ( channel = 0; channel < MAX_CHAN; channel++ )
{
ar_base->rcvr[channel].head_ptr = 0;
ar_base->rcvr[channel].tail_ptr = 0;
ar_base->rcvr[channel].mask_ptr = ARINC_RX_BUFFER_MASK;
ar_base->rcvr[channel].num_scheduled = 0;
ar_base->xmtr[channel].head_ptr = 0;
ar_base->xmtr[channel].tail_ptr = 0;
ar_base->xmtr[channel].mask_ptr = ARINC_TX_BUFFER_MASK;
ar_base->xmtr[channel].num_scheduled = 0;
}
return ARS_NORMAL;
}