Merge pull request #8 from stsp/chain

Implement CHAIN directive
This commit is contained in:
PerditionC 2017-02-11 13:00:40 -05:00 committed by GitHub
commit 2835dfe920
1 changed files with 108 additions and 67 deletions

View File

@ -155,6 +155,14 @@ COUNT UmbState BSS_INIT(0);
STATIC BYTE szLine[256] BSS_INIT({0});
STATIC BYTE szBuf[256] BSS_INIT({0});
#define MAX_CHAINS 5
struct CfgFile {
COUNT nFileDesc;
COUNT nCfgLine;
} cfgFile[MAX_CHAINS];
COUNT nCurChain = 0;
COUNT nFileDesc;
BYTE singleStep BSS_INIT(FALSE); /* F8 processing */
BYTE SkipAllConfig BSS_INIT(FALSE); /* F5 processing */
BYTE askThisSingleCommand BSS_INIT(FALSE); /* ?device= device?= */
@ -188,6 +196,7 @@ STATIC VOID InitPgm(BYTE * pLine);
STATIC VOID InitPgmHigh(BYTE * pLine);
STATIC VOID CmdInstall(BYTE * pLine);
STATIC VOID CmdInstallHigh(BYTE * pLine);
STATIC VOID CmdChain(BYTE * pLine);
STATIC VOID CmdSet(BYTE * pLine);
@ -294,6 +303,7 @@ STATIC struct table commands[] = {
{"DEVICEHIGH", 2, DeviceHigh},
{"INSTALL", 2, CmdInstall},
{"INSTALLHIGH", 2, CmdInstallHigh},
{"CHAIN", 2, CmdChain},
{"SET", 2, CmdSet},
/* default action */
@ -791,7 +801,6 @@ copy_char:
VOID DoConfig(int nPass)
{
COUNT nFileDesc;
BYTE *pLine;
BOOL bEof = FALSE;
@ -913,6 +922,15 @@ VOID DoConfig(int nPass)
}
#endif
if (bEof && nCurChain) {
struct CfgFile *cfg = &cfgFile[--nCurChain];
close(nFileDesc);
bEof = FALSE;
nFileDesc = cfg->nFileDesc;
nCfgLine = cfg->nCfgLine;
continue;
}
DebugPrintf(("CONFIG=[%s]\n", szLine));
/* Skip leading white space and get verb. */
@ -1025,6 +1043,7 @@ UWORD GetBiosKey(int timeout)
STATIC BOOL SkipLine(char *pLine)
{
short key;
COUNT i;
if (InitKernelConfig.SkipConfigSeconds >= 0)
{
@ -1067,6 +1086,8 @@ STATIC BOOL SkipLine(char *pLine)
if (!askThisSingleCommand && !singleStep)
return FALSE;
for (i = 0; i < nCurChain; i++)
printf(" ");
printf("%s[Y,N]?", pLine);
for (;;)
@ -2584,6 +2605,26 @@ STATIC VOID CmdInstallHigh(BYTE * pLine)
{
_CmdInstall(pLine,0x80); /* load high, if possible */
}
STATIC VOID CmdChain(BYTE * pLine)
{
struct CfgFile *cfg;
int fd;
InstallPrintf(("CHAIN: %s\n", pLine));
if (nCurChain >= MAX_CHAINS) {
CfgFailure(pLine);
return;
}
if ((fd = open(pLine, 0)) < 0) {
CfgFailure(pLine);
return;
}
cfg = &cfgFile[nCurChain++];
cfg->nFileDesc = nFileDesc;
cfg->nCfgLine = nCfgLine;
nFileDesc = fd;
nCfgLine = 0;
}
STATIC VOID InstallExec(struct instCmds *icmd)
{