matlab_23550/Inu/Src2/main/not_use/log_to_mem.c

250 lines
5.4 KiB
C

/****************************************************************/
/* TMS320C32 */
/* ====== BIOS, ÊËÀÈÍ, ÊËÂÑÏ ====== */
/* ÖÍÈÈ ÑÝÒ (ñ) 1998-2001ã. */
/****************************************************************/
/* log_to_mem.c
****************************************************************
* Çàïèñü ëîãîâ â ïàìyòü *
****************************************************************/
#include <log_to_mem.h>
#include "MemoryFunctions.h"
// ïåðåìåííûå èñïîëüçóåìûå òîëüêî â ýòîì ìîäóëå
// Ïåðåìåííûå èç ï/ï logs_data(), write_to_mem è clear_mem
// Íà÷àëüíûé àäðåñ ïàìyòè äëy çàïèñè ëîãîâ (ñì. ï/ï write_to_mem)
//#pragma DATA_SECTION(count_mem,".fast_vars");
//static long count_mem = START_ADDRESS_LOG;
#pragma DATA_SECTION(count_mem_slow,".fast_vars");
static long count_mem_slow = START_ADDRESS_LOG_SLOW;
// Îáyçàòåëüíîå íà÷àëüíîå çíà÷åíèå èíà÷å ïîðyäîê çàïèñè
// íàðóøàåòñy ïðè ïåðâîì çààïîëíåíèè áóôåðà
int hb_logs_data = 0;
#pragma DATA_SECTION(stop_log,".fast_vars");
int stop_log = 0;
int stop_log_slow = 0;
#pragma DATA_SECTION(logpar,".fast_vars");
LOGSPARAMS logpar = LOGSPARAMS_DEFAULTS;
#pragma DATA_SECTION(no_write,".fast_vars");
int no_write = 0; // Ôëàã, ÷òîáû íå ïèñàòü (åñëè ÷òî)
#pragma DATA_SECTION(no_write_slow,".fast_vars");
int no_write_slow = 0; // Ôëàã, ÷òîáû íå ïèñàòü (åñëè ÷òî)
#pragma CODE_SECTION(clear_logpar,".fast_run");
void clear_logpar()
{
int i;
for(i=0;i<SIZE_LOGS_ARRAY;i++)
logpar.logs[i] = 0;
}
// Çàïèñü äâóõ ìëàäøèõ áàéòîâ àðãóìåíòà â ïàìyòü, ãäå ëîãè ëåæàò
#pragma CODE_SECTION(write_to_mem,".fast_run");
void write_to_mem(int tlog,int DataM)
{
// int DataT;
if (tlog==FAST_LOG)
{
if (no_write) return;
if (logpar.stop_log_level_1) return;
if (logpar.addres_mem >= END_ADDRESS_LOG) logpar.addres_mem = END_ADDRESS_LOG;
i_WriteMemory(logpar.addres_mem,DataM);
// *(int *)logpar.count_mem = ((DataM & 0xFFFF) );
logpar.addres_mem++;
}
if (tlog==SLOW_LOG)
{
if (no_write_slow) return;
if (logpar.stop_log_slow_level_1) return;
if (count_mem_slow >= END_ADDRESS_LOG_SLOW) count_mem_slow = END_ADDRESS_LOG_SLOW;
i_WriteMemory(count_mem_slow,DataM);
// *(int *)logpar.count_mem = ((DataM & 0xFFFF) );
count_mem_slow++;
}
}
#pragma CODE_SECTION(test_mem_limit,".fast_run");
void test_mem_limit(int tlog,int ciclelog)
{
if (tlog==FAST_LOG)
{
if( logpar.addres_mem >= (END_ADDRESS_LOG - LENGTH_HAZARD))
{
logpar.real_finish_addres_mem = logpar.addres_mem;
if (ciclelog==1)
{
stop_log = 0;
logpar.stop_log_level_1=0;
logpar.addres_mem = START_ADDRESS_LOG;
}
else
{
stop_log = 1;
logpar.stop_log_level_1=1;
}
}
if( logpar.addres_mem >= (END_ADDRESS_LOG_LEVEL_2))
{
logpar.stop_log_level_2=1;
}
else
{
logpar.stop_log_level_2=0;
}
if( logpar.addres_mem >= (END_ADDRESS_LOG_LEVEL_3))
{
logpar.stop_log_level_3=1;
}
else
{
logpar.stop_log_level_3=0;
}
}
else
{
if (tlog==SLOW_LOG)
{
if (ciclelog==1)
{
logpar.stop_log_slow_level_1=0;
}
if( count_mem_slow >= (END_ADDRESS_LOG_SLOW - LENGTH_HAZARD))
{
if (ciclelog==1)
{
stop_log_slow = 0;
logpar.stop_log_slow_level_1=0;
count_mem_slow = START_ADDRESS_LOG_SLOW;
}
else
{
stop_log_slow = 1;
logpar.stop_log_slow_level_1=1;
}
}
if( count_mem_slow >= (END_ADDRESS_LOG_SLOW_LEVEL_2))
{
logpar.stop_log_slow_level_2=1;
}
else
{
logpar.stop_log_slow_level_2=0;
}
if( count_mem_slow >= (END_ADDRESS_LOG_SLOW_LEVEL_3))
{
logpar.stop_log_slow_level_3=1;
}
else
{
logpar.stop_log_slow_level_3=0;
}
}
}
}
// Î÷èùåíèå ïàìyòè, ãäå ëîãè ëåæàò
void clear_mem(int tlog)
{
if (tlog==FAST_LOG)
{
logpar.real_finish_addres_mem = 0;
for (logpar.addres_mem=START_ADDRESS_LOG; logpar.addres_mem<END_ADDRESS_LOG; logpar.addres_mem++)//END_ADDRESS_LOG; logpar.count_mem++)
i_WriteMemory(logpar.addres_mem,0x0);
logpar.addres_mem = START_ADDRESS_LOG;
hb_logs_data = 0;
stop_log = 0;
logpar.stop_log_level_1=0;
logpar.stop_log_level_2=0;
logpar.stop_log_level_3=0;
logpar.start_write_fast_log = 1;
}
if (tlog==SLOW_LOG)
{
for (count_mem_slow=START_ADDRESS_LOG_SLOW; count_mem_slow<END_ADDRESS_LOG_SLOW; count_mem_slow++)
i_WriteMemory(count_mem_slow,0x0);
count_mem_slow = START_ADDRESS_LOG_SLOW;
hb_logs_data = 0;
stop_log_slow = 0;
logpar.stop_log_slow_level_1=0;
logpar.stop_log_slow_level_2=0;
logpar.stop_log_slow_level_3=0;
}
}
// Âûñòàâëåíèå ïîçèöèè ëîãîâ â íà÷àëî
void set_start_mem(int tlog)
{
if (tlog==FAST_LOG)
{
logpar.real_finish_addres_mem = 0;
logpar.addres_mem = START_ADDRESS_LOG;
hb_logs_data = 0;
stop_log = 0;
logpar.stop_log_level_1=0;
logpar.stop_log_level_2=0;
logpar.stop_log_level_3=0;
}
if (tlog==SLOW_LOG)
{
count_mem_slow = START_ADDRESS_LOG_SLOW;
hb_logs_data = 0;
stop_log_slow = 0;
logpar.stop_log_slow_level_1=0;
logpar.stop_log_slow_level_2=0;
logpar.stop_log_slow_level_3=0;
}
}
void get_log_params_count(void) {
logpar.count_log_params_fast_log = logpar.addres_mem - START_ADDRESS_LOG;
}