?? boot.c
字號(hào):
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdSfr(char *Parameter, uint8 PLen)
{
uint32 sfr, data;
char Ch;
if (PLen < 1)
{
return FALSE;
}
PLen--;
Parameter++;
sscanf(Parameter, "0X%X", &sfr);
do
{
Ch = *Parameter++;
if (Ch == ' ')
{
break;
}
}while (--PLen != 0);
if (PLen == 0)
{
return FALSE;
}
sscanf(Parameter, "0X%X", &data);
((volatile uint32 *)sfr)[0] = data;
return TRUE;
}
/*********************************************************************************************************
** Function name: CmdSfrh
** Descriptions: Set 16bit register cmd
** Input:Parameter: Parameter string
** PLen: Parameter string length
** Output: TRUE: OK
** FALSE: NOT OK
** Created by: chenmingji
** Created Date: 2005-02-24
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdSfrh(char *Parameter, uint8 PLen)
{
uint32 sfr, data;
char Ch;
if (PLen < 1)
{
return FALSE;
}
PLen--;
Parameter++;
sscanf(Parameter, "0X%X", &sfr);
do
{
Ch = *Parameter++;
if (Ch == ' ')
{
break;
}
}while (--PLen != 0);
if (PLen == 0)
{
return FALSE;
}
sscanf(Parameter, "0X%X", &data);
((volatile uint16 *)sfr)[0] = data;
return TRUE;
}
/*********************************************************************************************************
** Function name: CmdSfrb
** Descriptions: Set 8bit register cmd
** Input:Parameter: Parameter string
** PLen: Parameter string length
** Output: TRUE: OK
** FALSE: NOT OK
** Created by: chenmingji
** Created Date: 2005-02-24
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdSfrb(char *Parameter, uint8 PLen)
{
uint32 sfr, data;
char Ch;
if (PLen < 1)
{
return FALSE;
}
PLen--;
Parameter++;
sscanf(Parameter, "0X%X", &sfr);
do
{
Ch = *Parameter++;
if (Ch == ' ')
{
break;
}
}while (--PLen != 0);
if (PLen == 0)
{
return FALSE;
}
sscanf(Parameter, "0X%X", &data);
((volatile uint8 *)sfr)[0] = data;
return TRUE;
}
/*********************************************************************************************************
** Function name: CmdRun
** Descriptions: run load code
** Input:Parameter: Parameter string
** PLen: Parameter string length
** Output: TRUE: OK
** FALSE: NOT OK
** Created by: chenmingji
** Created Date: 2005-02-24
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdRun(char *Parameter, uint8 PLen)
{
extern uint8 Start_Boot(char *Parameter, uint8 PLen);
ChangeToSYSMode();
Start_Boot(Parameter, PLen);
return 0;
}
/*********************************************************************************************************
** Function name: Readline
** Descriptions: Read line from file
** Input:Buf: store read data
** Handle: file Handle
** Output: string length
**
** Created by: chenmingji
** Created Date: 2005-02-24
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
unsigned int Readline(char *Buf, HANDLE Handle)
{
unsigned int length;
uint8 c, c1;
length = 0;
c1 = '\r' + 1;
while(FileEof(Handle) == 0)
{
if (FileGetCh(&c, Handle) != RETURN_OK)
{
*Buf = 0;
break;
}
if (c >= 'a' && c <= 'z' )
{
c = c + 'A' - 'a';
}
*Buf++ = c;
if (c1 == '\r')
if (c == '\n')
{
length--;
Buf -= 2;
*Buf = 0;
break;
}
length++;
c1 = c;
}
*Buf = 0;
return length;
}
/*********************************************************************************************************
** Function name: Boot
** Descriptions: read a:\zlg_boot.ini and execute it
** Input:none
**
** Output: none
**
** Created by: chenmingji
** Created Date: 2005-02-24
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Boot(char *file)
{
unsigned int length, i;
const _CMD *cmd;
HANDLE Handle;
char Buf[512];
char *cp1, *cp2;
char temp;
if (file == NULL || *file == 0)
{
file = "a:\\zlg_boot.ini";
}
for (i = 0; i < 32; i++)
{
Regs[i] = 0;
}
Regs[0] = 0xd3;
OS_ENTER_CRITICAL();
Handle = FileOpen(file, "r");
if (Handle == Not_Open_FILE)
{
Reset();
}
while (1)
{
Next:
length = Readline(Buf, Handle);
if (length != 0)
{
cmd = CmdData;
while (cmd->CmdName != NULL)
{
i = length + 1;
cp1 = cmd->CmdName;
cp2 = Buf;
do
{
temp = *cp2;
if (temp == ' ' || temp == 0)
{
if (cmd->Cmd != NULL)
{
cmd->Cmd(cp2, length);
}
goto Next;
}
if (*cp1 == temp)
{
cp1++;
cp2++;
continue;
}
break;
} while (--i != 0);
cmd++;
}
}
else
{
Reset();
}
}
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -