Пример #1
0
CString CGenericProcessingMachine::ConfigurationName(void)
{
    if (PSC().VarDefined(GPM_VAR_NAME_CFG))
    {
        return PSC().VarNamed(GPM_VAR_NAME_CFG).GetString();
    }
    else
    {
        return DefaultConfigurationName();
    }
}
Пример #2
0
static void
mpc52xx_uart_break_ctl(struct uart_port *port, int ctl)
{
    unsigned long flags;
    spin_lock_irqsave(&port->lock, flags);

    if ( ctl == -1 )
        out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK);
    else
        out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK);

    spin_unlock_irqrestore(&port->lock, flags);
}
Пример #3
0
void CGenericProcessingMachine::Initialize(void)
{
    CreateConfiguration();
    PSC().ProcessParameters(m_ParameterString);
    Configure(ConfigurationName());
    m_FileNameLength = 12;
}
Пример #4
0
static void
mpc52xx_uart_stop_rx(struct uart_port *port)
{
    /* port->lock taken by caller */
    port->read_status_mask &= ~MPC52xx_PSC_IMR_RXRDY;
    out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
}
Пример #5
0
static int
mpc52xx_uart_startup(struct uart_port *port)
{
    struct mpc52xx_psc *psc = PSC(port);

    /* Reset/activate the port, clear and enable interrupts */
    out_8(&psc->command,MPC52xx_PSC_RST_RX);
    out_8(&psc->command,MPC52xx_PSC_RST_TX);

    out_be32(&psc->sicr,0);	/* UART mode DCD ignored */

    out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */

    out_8(&psc->rfcntl, 0x00);
    out_be16(&psc->rfalarm, 0x1ff);
    out_8(&psc->tfcntl, 0x07);
    out_be16(&psc->tfalarm, 0x80);

    port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY;
    out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);

    out_8(&psc->command,MPC52xx_PSC_TX_ENABLE);
    out_8(&psc->command,MPC52xx_PSC_RX_ENABLE);

    return 0;
}
Пример #6
0
static int
mpc52xx_uart_startup(struct uart_port *port)
{
	struct mpc52xx_psc __iomem *psc = PSC(port);
	int ret;

	/* Request IRQ */
	ret = request_irq(port->irq, mpc52xx_uart_int,
		SA_INTERRUPT | SA_SAMPLE_RANDOM, "mpc52xx_psc_uart", port);
	if (ret)
		return ret;

	/* Reset/activate the port, clear and enable interrupts */
	out_8(&psc->command,MPC52xx_PSC_RST_RX);
	out_8(&psc->command,MPC52xx_PSC_RST_TX);
	
	out_be32(&psc->sicr,0);	/* UART mode DCD ignored */

	out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */
	
	out_8(&psc->rfcntl, 0x00);
	out_be16(&psc->rfalarm, 0x1ff);
	out_8(&psc->tfcntl, 0x07);
	out_be16(&psc->tfalarm, 0x80);

	port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY;
	out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
	
	out_8(&psc->command,MPC52xx_PSC_TX_ENABLE);
	out_8(&psc->command,MPC52xx_PSC_RX_ENABLE);
		
	return 0;
}
Пример #7
0
static void
mpc52xx_uart_start_tx(struct uart_port *port, unsigned int tty_start)
{
    /* port->lock taken by caller */
    port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY;
    out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
}
Пример #8
0
static void
mpc52xx_uart_shutdown(struct uart_port *port)
{
    struct mpc52xx_psc *psc = PSC(port);

    /* Shut down the port, interrupt and all */
    out_8(&psc->command,MPC52xx_PSC_RST_RX);
    out_8(&psc->command,MPC52xx_PSC_RST_TX);

    port->read_status_mask = 0;
    out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
}
Пример #9
0
static void mpc52xx_psc_fifo_init(struct uart_port *port)
{
	struct mpc52xx_psc __iomem *psc = PSC(port);
	struct mpc52xx_psc_fifo __iomem *fifo = FIFO_52xx(port);

	out_8(&fifo->rfcntl, 0x00);
	out_be16(&fifo->rfalarm, 0x1ff);
	out_8(&fifo->tfcntl, 0x07);
	out_be16(&fifo->tfalarm, 0x80);

	port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY;
	out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask);
}
Пример #10
0
bool CGenericProcessingMachine::Configure(const CString& FileName)
{
    bool result = true;
//
    if (m_AliasesEnabled)
    {
        m_VerboseMode = PSC().VarDefined(GPM_VAR_NAME_VERBOSE_ALIAS);
        m_QuietMode = PSC().VarDefined(GPM_VAR_NAME_QUIET_ALIAS);
        m_HelpMode = PSC().VarDefined(GPM_VAR_NAME_HELP_ALIAS);
    }
    else
    {
        m_VerboseMode = PSC().VarDefined(GPM_VAR_NAME_VERBOSE);
        m_QuietMode = PSC().VarDefined(GPM_VAR_NAME_QUIET);
        m_HelpMode = PSC().VarDefined(GPM_VAR_NAME_HELP);
    }
//PSC().ProcessParameters(m_ParameterString);
    if ((FileName.GetLength()>0)&&(FileExists(FileName.GetString())))
    {
        CFG().LoadFromFile(FileName);
    }
    else
    {
        result = false;
    }
    if (PSC().VarDefined(GPM_VAR_NAME_LIST))
    {
        ILST().Clear();
        ILST().LoadFromFile(PSC().VarNamed(GPM_VAR_NAME_IN).GetString());
    }
    else if (PSC().VarDefined(GPM_VAR_NAME_IN))
    {
        ILST().Clear();
        ILST().Insert(PSC().VarNamed(GPM_VAR_NAME_IN).GetString());
    }
    return result;
}
Пример #11
0
static void
mpc52xx_uart_send_xchar(struct uart_port *port, char ch)
{
    unsigned long flags;
    spin_lock_irqsave(&port->lock, flags);

    port->x_char = ch;
    if (ch) {
        /* Make sure tx interrupts are on */
        /* Truly necessary ??? They should be anyway */
        port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY;
        out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
    }

    spin_unlock_irqrestore(&port->lock, flags);
}
Пример #12
0
static void
mpc52xx_uart_shutdown(struct uart_port *port)
{
	struct mpc52xx_psc __iomem *psc = PSC(port);

	/* Shut down the port.  Leave TX active if on a console port */
	out_8(&psc->command,MPC52xx_PSC_RST_RX);
	if (!uart_console(port))
		out_8(&psc->command,MPC52xx_PSC_RST_TX);

	port->read_status_mask = 0;
	out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);

	/* Release interrupt */
	free_irq(port->irq, port);
}
Пример #13
0
static void mpc512x_psc_fifo_init(struct uart_port *port)
{
	/* /32 prescaler */
	out_be16(&PSC(port)->mpc52xx_psc_clock_select, 0xdd00);

	out_be32(&FIFO_512x(port)->txcmd, MPC512x_PSC_FIFO_RESET_SLICE);
	out_be32(&FIFO_512x(port)->txcmd, MPC512x_PSC_FIFO_ENABLE_SLICE);
	out_be32(&FIFO_512x(port)->txalarm, 1);
	out_be32(&FIFO_512x(port)->tximr, 0);

	out_be32(&FIFO_512x(port)->rxcmd, MPC512x_PSC_FIFO_RESET_SLICE);
	out_be32(&FIFO_512x(port)->rxcmd, MPC512x_PSC_FIFO_ENABLE_SLICE);
	out_be32(&FIFO_512x(port)->rxalarm, 1);
	out_be32(&FIFO_512x(port)->rximr, 0);

	out_be32(&FIFO_512x(port)->tximr, MPC512x_PSC_FIFO_ALARM);
	out_be32(&FIFO_512x(port)->rximr, MPC512x_PSC_FIFO_ALARM);
}
Пример #14
0
static unsigned char mpc52xx_psc_read_char(struct uart_port *port)
{
	return in_8(&PSC(port)->mpc52xx_psc_buffer_8);
}
Пример #15
0
static void mpc52xx_psc_cw_disable_ints(struct uart_port *port)
{
	out_be16(&PSC(port)->mpc52xx_psc_imr, 0);
}
Пример #16
0
static void mpc52xx_psc_stop_rx(struct uart_port *port)
{
	port->read_status_mask &= ~MPC52xx_PSC_IMR_RXRDY;
	out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask);
}
Пример #17
0
static void mpc52xx_psc_write_char(struct uart_port *port, unsigned char c)
{
	out_8(&PSC(port)->mpc52xx_psc_buffer_8, c);
}
Пример #18
0
static int mpc52xx_psc_tx_rdy(struct uart_port *port)
{
	return in_be16(&PSC(port)->mpc52xx_psc_isr)
	    & port->read_status_mask
	    & MPC52xx_PSC_IMR_TXRDY;
}
Пример #19
0
static int mpc52xx_psc_tx_empty(struct uart_port *port)
{
	return in_be16(&PSC(port)->mpc52xx_psc_status)
	    & MPC52xx_PSC_SR_TXEMP;
}
Пример #20
0
	/* Shut down the port, interrupt and all */
	out_8(&psc->command,MPC52xx_PSC_RST_RX);
	out_8(&psc->command,MPC52xx_PSC_RST_TX);
	
	port->read_status_mask = 0; 
	out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);

	/* Release interrupt */
	free_irq(port->irq, port);
}

static void 
mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
                         struct termios *old)
{
	struct mpc52xx_psc __iomem *psc = PSC(port);
	unsigned long flags;
	unsigned char mr1, mr2;
	unsigned short ctr;
	unsigned int j, baud, quot;
	
	/* Prepare what we're gonna write */
	mr1 = 0;
	
	switch (new->c_cflag & CSIZE) {
		case CS5:	mr1 |= MPC52xx_PSC_MODE_5_BITS;
				break;
		case CS6:	mr1 |= MPC52xx_PSC_MODE_6_BITS;
				break;
		case CS7:	mr1 |= MPC52xx_PSC_MODE_7_BITS;
				break;
Пример #21
0
static int mpc52xx_psc_raw_tx_rdy(struct uart_port *port)
{
	return in_be16(&PSC(port)->mpc52xx_psc_status)
	    & MPC52xx_PSC_SR_TXRDY;
}
Пример #22
0
static unsigned int mpc5200_psc_set_baudrate(struct uart_port *port,
					     struct ktermios *new,
					     struct ktermios *old)
{
	unsigned int baud;
	unsigned int divisor;

	/* The 5200 has a fixed /32 prescaler, uartclk contains the ipb freq */
	baud = uart_get_baud_rate(port, new, old,
				  port->uartclk / (32 * 0xffff) + 1,
				  port->uartclk / 32);
	divisor = (port->uartclk + 16 * baud) / (32 * baud);

	/* enable the /32 prescaler and set the divisor */
	mpc52xx_set_divisor(PSC(port), 0xdd00, divisor);
	return baud;
}

static unsigned int mpc5200b_psc_set_baudrate(struct uart_port *port,
					      struct ktermios *new,
					      struct ktermios *old)
{
	unsigned int baud;
	unsigned int divisor;
	u16 prescaler;

	/* The 5200B has a selectable /4 or /32 prescaler, uartclk contains the
	 * ipb freq */
	baud = uart_get_baud_rate(port, new, old,
				  port->uartclk / (32 * 0xffff) + 1,
Пример #23
0
static void mpc52xx_psc_cw_restore_ints(struct uart_port *port)
{
	out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask);
}
Пример #24
0
void CProcessingMachine::CreateConfiguration(void)
{
 CGenericProcessingMachine::CreateConfiguration();
 CPlatform pl; pl.Reset(CPlatform::OS_Unix);
 CToolChain tc("gcc");
 //
 PSC().InsertBooleanVariable("--version");
 PSC().InsertStringVariable("--config");
 PSC().InsertBooleanVariable("--local");
 PSC().InsertBooleanVariable("--global");
 PSC().InsertBooleanVariable("--add");
 PSC().InsertBooleanVariable("--remove");
 PSC().InsertStringVariable("-set","default");
 PSC().InsertStringVariable("-name","");
 PSC().InsertStringVariable("-desc","");
 PSC().InsertStringVariable("-field","base");
 PSC().InsertStringVariable("-value","");
 //
 PSC().InsertStringVariable("-alias","gcc");
 PSC().InsertStringVariable("-chain","gcc");
 PSC().InsertStringVariable("-make","make");
 PSC().InsertStringVariable("-tool","gnu_c_compiler");
 PSC().InsertStringVariable("-type","cc");
 PSC().InsertStringVariable("-desc","GNU C Compiler");
 PSC().InsertStringVariable("-program","gcc");
 PSC().InsertStringVariable("-command","$compiler $options $includes -c $file -o $object");
 PSC().InsertStringVariable("-mkv","CC");
 PSC().InsertStringVariable("-srcext","c");
 PSC().InsertStringVariable("-outext","o");
 PSC().InsertStringVariable("-quotepath","yes");
 PSC().InsertStringVariable("-fullpath","no");
 PSC().InsertStringVariable("-unixpath","no");
 PSC().InsertStringVariable("-incsw","-I");
 PSC().InsertStringVariable("-defsw","-D");
 PSC().InsertStringVariable("-deps","yes");
 PSC().InsertStringVariable("-ldsw","-L");
 PSC().InsertStringVariable("-llsw","-l");
 PSC().InsertStringVariable("-lext","a");
 PSC().InsertStringVariable("-objext","o");
 PSC().InsertStringVariable("-lflat","no");

 PSC().InsertBooleanVariable("-unix");
 PSC().InsertBooleanVariable("-windows");
 PSC().InsertBooleanVariable("-mac");
 PSC().InsertBooleanVariable("--all-os");
 PSC().InsertBooleanVariable("--flat-objects");
 PSC().InsertBooleanVariable("--flat-objpath");
 PSC().InsertBooleanVariable("--wrap-objects");
 PSC().InsertBooleanVariable("--wrap-options");
 PSC().InsertBooleanVariable("--with-deps");
 PSC().InsertBooleanVariable("--keep-objdir");
 PSC().InsertBooleanVariable("--keep-outdir");
 PSC().InsertStringVariable("--target-case","lower");
 PSC().InsertStringVariable("--macros-case","upper");
 PSC().InsertStringVariable("--quote-path","auto");
 PSC().InsertStringVariable("--default-options");
 PSC().InsertStringVariable("-targets","");

 PSC().InsertStringVariable("-pwd",pl.Cmd_PrintWorkDir());
 PSC().InsertStringVariable("-wd",pl.Cmd_EvalWorkDir());
 PSC().InsertStringVariable("-cd",pl.Cmd_ChangeDir());
 PSC().InsertStringVariable("-rm",pl.Cmd_RemoveFile());
 PSC().InsertStringVariable("-rmf",pl.Cmd_ForceRemoveFile());
 PSC().InsertStringVariable("-rmd",pl.Cmd_RemoveDir());
 //PSC().InsertStringVariable("-tf",pl.Cmd_TestFile());
 //PSC().InsertStringVariable("-td",pl.Cmd_TestDir());
 PSC().InsertStringVariable("-cp",pl.Cmd_Copy());
 PSC().InsertStringVariable("-mv",pl.Cmd_Move());
 PSC().InsertStringVariable("-md",pl.Cmd_MakeDir());
 PSC().InsertStringVariable("-mdf",pl.Cmd_ForceMakeDir());
 //PSC().InsertBooleanVariable("--no-header");
 //
 //PSC().InsertIntegerVariable("-");
 //PSC().InsertFloatVariable("-");
 //PSC().InsertBooleanVariable("-");
 //PSC().InsertStringVariable("-");
 //PSC().InsertCharVariable("-");
}
Пример #25
0
void CProcessingMachine::ConfigurePlatform(CPlatform *Platform)
{
 CPlatform *p = Platform;
 if (PSC().VarDefined("-make"))
 {
  p->Cmd_Make() = PSC().VarNamed("-make").GetString();
 }
 if (PSC().VarDefined("-pwd"))
 {
  p->Cmd_PrintWorkDir() = PSC().VarNamed("-pwd").GetString();
 }
 if (PSC().VarDefined("-wd"))
 {
  p->Cmd_EvalWorkDir() = PSC().VarNamed("-wd").GetString();
 }
 if (PSC().VarDefined("-cd"))
 {
  p->Cmd_ChangeDir() = PSC().VarNamed("-cd").GetString();
 }
 if (PSC().VarDefined("-rm"))
 {
  p->Cmd_RemoveFile() = PSC().VarNamed("-rm").GetString();
 }
 if (PSC().VarDefined("-rmf"))
 {
  p->Cmd_ForceRemoveFile() = PSC().VarNamed("-rmf").GetString();
 }
 if (PSC().VarDefined("-rmd"))
 {
  p->Cmd_RemoveDir() = PSC().VarNamed("-rmd").GetString();
 }
 /*
 if (PSC().VarDefined("-tf"))
 {
  p->Cmd_TestFile() = PSC().VarNamed("-tf").GetString();
 }
 if (PSC().VarDefined("-td"))
 {
  p->Cmd_TestDir() = PSC().VarNamed("-td").GetString();
 }
 */
 if (PSC().VarDefined("-cp"))
 {
  p->Cmd_Copy() = PSC().VarNamed("-cp").GetString();
 }
 if (PSC().VarDefined("-mv"))
 {
  p->Cmd_Move() = PSC().VarNamed("-mv").GetString();
 }
 if (PSC().VarDefined("-md"))
 {
  p->Cmd_MakeDir() = PSC().VarNamed("-md").GetString();
 }
 if (PSC().VarDefined("-mdf"))
 {
  p->Cmd_ForceMakeDir() = PSC().VarNamed("-mdf").GetString();
 }
}
Пример #26
0
void CProcessingMachine::ConfigureBuildTool(CBuildTool *BuildTool)
{
 CBuildTool *bt = BuildTool;
 if (PSC().VarDefined("-desc"))
 {
  bt->Description() = PSC().VarNamed("-desc").GetString();
 }
 if (PSC().VarDefined("-program"))
 {
  bt->Program() = PSC().VarNamed("-program").GetString();
 }
 if (PSC().VarDefined("-command"))
 {
  bt->CommandTemplate() = PSC().VarNamed("-command").GetString();
 }
 if (PSC().VarDefined("-mkv"))
 {
  bt->MakeVariable() = PSC().VarNamed("-mkv").GetString();
 }
 if (PSC().VarDefined("-srcext"))
 {
  ParseStr(PSC().VarNamed("-srcext").GetString(),' ',bt->SourceExtensions());
  bt->SourceExtensions().RemoveDuplicates();
  bt->SourceExtensions().RemoveEmpty();
 }
 if (PSC().VarDefined("-outext"))
 {
  bt->TargetExtension() = PSC().VarNamed("-outext").GetString();
 }
 if (PSC().VarDefined("-quotepath"))
 {
  bt->NeedQuotedPath() = PSC().VarNamed("-quotepath").GetBoolean();
 }
 if (PSC().VarDefined("-fullpath"))
 {
  bt->NeedFullPath() = PSC().VarNamed("-fullpath").GetBoolean();
 }
 if (PSC().VarDefined("-unixpath"))
 {
  bt->NeedUnixPath() = PSC().VarNamed("-unixpath").GetBoolean();
 }
 CCompiler *cc = dynamic_cast<CCompiler *>(BuildTool);
 if (0!=cc)
 {
  if (PSC().VarDefined("-incsw"))
  {
   cc->IncludeDirSwitch() = PSC().VarNamed("-incsw").GetString();
  }
  if (PSC().VarDefined("-defsw"))
  {
   cc->DefineSwitch() = PSC().VarNamed("-defsw").GetString();
  }
  if (PSC().VarDefined("-deps"))
  {
   cc->NeedDependencies() = PSC().VarNamed("-deps").GetBoolean();
  }
 }
 CLinker *ln = dynamic_cast<CLinker *>(BuildTool);
 if (0!=ln)
 {
  if (PSC().VarDefined("-ldsw"))
  {
   ln->LibraryDirSwitch() = PSC().VarNamed("-ldsw").GetString();
  }
  if (PSC().VarDefined("-llsw"))
  {
   ln->LinkLibrarySwitch() = PSC().VarNamed("-llsw").GetString();
  }
  if (PSC().VarDefined("-lpfx"))
  {
   ln->LibraryPrefix() = PSC().VarNamed("-lpfx").GetString();
   ln->NeedLibraryPrefix() = !(ln->LibraryPrefix().IsEmpty());
  }
  if (PSC().VarDefined("-lext"))
  {
   ln->LibraryExtension() = PSC().VarNamed("-lext").GetString();
  }
  if (PSC().VarDefined("-objext"))
  {
   ln->ObjectExtension() = PSC().VarNamed("-objext").GetString();
  }
  if (PSC().VarDefined("-lflat"))
  {
   ln->NeedFlatObjects() = PSC().VarNamed("-lflat").GetBoolean();
  }
 }
}
Пример #27
0
static unsigned int
mpc52xx_uart_tx_empty(struct uart_port *port)
{
    int status = in_be16(&PSC(port)->mpc52xx_psc_status);
    return (status & MPC52xx_PSC_SR_TXEMP) ? TIOCSER_TEMT : 0;
}
Пример #28
0
{
    struct mpc52xx_psc *psc = PSC(port);

    /* Shut down the port, interrupt and all */
    out_8(&psc->command,MPC52xx_PSC_RST_RX);
    out_8(&psc->command,MPC52xx_PSC_RST_TX);

    port->read_status_mask = 0;
    out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
}

static void
mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
                         struct termios *old)
{
    struct mpc52xx_psc *psc = PSC(port);
    unsigned long flags;
    unsigned char mr1, mr2;
    unsigned short ctr;
    unsigned int j, baud, quot;

    /* Prepare what we're gonna write */
    mr1 = 0;

    switch (new->c_cflag & CSIZE) {
    case CS5:
        mr1 |= MPC52xx_PSC_MODE_5_BITS;
        break;
    case CS6:
        mr1 |= MPC52xx_PSC_MODE_6_BITS;
        break;
Пример #29
0
void CGenericProcessingMachine::CreateConfiguration(void)
{
    PSC().InsertStringVariable(GPM_VAR_NAME_IN);
    PSC().InsertStringVariable(GPM_VAR_NAME_OUT);
    PSC().InsertBooleanVariable(GPM_VAR_NAME_LIST);
    PSC().InsertStringVariable(GPM_VAR_NAME_CFG);
    PSC().InsertStringVariable(GPM_VAR_NAME_INDIR);
    PSC().InsertStringVariable(GPM_VAR_NAME_OUTDIR);
    PSC().InsertBooleanVariable(GPM_VAR_NAME_HELP);
    PSC().InsertBooleanVariable(GPM_VAR_NAME_VERBOSE);
    PSC().InsertBooleanVariable(GPM_VAR_NAME_QUIET);
    if (m_AliasesEnabled)
    {
        PSC().InsertBooleanVariable(GPM_VAR_NAME_HELP_ALIAS);
        PSC().InsertBooleanVariable(GPM_VAR_NAME_VERBOSE_ALIAS);
        PSC().InsertBooleanVariable(GPM_VAR_NAME_QUIET_ALIAS);
    }
}
Пример #30
0
bool CProcessingMachine::Configure(const CString& FileName)
{
 CGenericProcessingMachine::Configure(""/*FileName*/);
 if (DoShowHelp())
 {
  DisplayHelpMessage();
  return false;
 }
 if (BeVerbose())
 {
  std::cout<<"Command line parameters:"<<std::endl;
  PSC().Print(std::cout);
 }
 if (PSC().VarDefined("--version"))
 {
  std::cout<<"cbp2make rev."<<REVISION_NUMBER<<std::endl;
  return false;
 }
#ifdef REVISION_NUMBER
 if (!BeQuiet()) std::cout<<"Starting cbp2make rev."<<REVISION_NUMBER<<"..."<<std::endl;
#endif
 m_BuildManager.Config().BeQuiet() = BeQuiet();
 m_BuildManager.Config().BeVerbose() = BeVerbose();
 CString cfg_name = ConfigurationName();
 // Lookup configuration file
 // 1) if "-cfg" option is specified, use it as-is
 // 2) if "-cfg" option is not specified do following:
 // 2A) use default configuration in current directory
 //     if it exists or "--local" option is specified.
 // 2B) find and/or create configuration in user's home directory,
 //     if it is not possible, fallback to current directory.
 if (!PSC().VarDefined(GPM_VAR_NAME_CFG) &&
     ((!FileExists(cfg_name) && !PSC().VarDefined("--local")) ||
      PSC().VarDefined("--global")))
 {
  CString cfg_path = JoinPaths(HomeDirPath(),".cbp2make");
  if (!DirExists(cfg_path))
  {
   MakeDir(cfg_path);
  }
  if (DirExists(cfg_path))
  {
   cfg_name = JoinPaths(cfg_path,DefaultConfigurationName());
  }
 }
 if (FileExists(cfg_name))
 {
  if (!BeQuiet()) std::cout<<"Using configuration: "<<cfg_name.GetCString()<<std::endl;
  m_BuildManager.Config().Load(cfg_name);
  m_BuildManager.Config().BeQuiet() = BeQuiet();
  m_BuildManager.Config().BeVerbose() = BeVerbose();
 }
 else
 {
  if (!BeQuiet()) std::cout<<"Using default configuration."<<std::endl;
  m_BuildManager.Config().Platforms().AddDefault();
  m_BuildManager.Config().ToolChains().AddDefault();
  //do not create configuration file unless explicitly instructed to do so
  //m_BuildManager.Config().Save(cfg_name);
 }
 if (PSC().VarDefined("--default-options"))
 {
  m_BuildManager.Config().DefaultOptions() = PSC().VarNamed("--default-options").GetString();
 }
 if (!m_BuildManager.Config().DefaultOptions().IsEmpty())
 {
  PS().AddParameters(m_BuildManager.Config().DefaultOptions());
  PSC().ProcessParameters(PS());
  CGenericProcessingMachine::Configure("");
  m_BuildManager.Config().BeQuiet() = BeQuiet();
  m_BuildManager.Config().BeVerbose() = BeVerbose();
 }
 // cache frequently used variables
 bool os_unix = PSC().VarDefined("-unix");
 bool os_windows = PSC().VarDefined("-windows");
 bool os_mac = PSC().VarDefined("-mac");
 CPlatform::OS_Type os_type = CPlatform::OS_Unix;
 if (os_unix) os_type = CPlatform::OS_Unix;
 else if (os_windows) os_type = CPlatform::OS_Windows;
 else if (os_mac) os_type = CPlatform::OS_Mac;
 bool os_any = os_unix || os_windows || os_mac;
 // configure
 m_BuildManager.Config().Platforms().AddDefault();
 if (PSC().VarDefined("--config"))
 {
  CString config_item_str = PSC().VarNamed("--config").GetString();
  int config_item = GuessStr(config_item_str,"toolchain tool platform variable options",
                             config_item_str,true);
  if (0==config_item)
  {
   CString chain_name = PSC().VarNamed("-chain").GetString();
   if (PSC().VarDefined("--add"))
   {
    if (PSC().VarDefined("-chain"))
    {
     CToolChain *tc = m_BuildManager.ToolChains().Find(os_type,chain_name);
     if (0==tc)
     {
      tc = m_BuildManager.ToolChains().Add(os_type,chain_name);
     }
     if (0==tc) return false;
     ConfigureToolchain(tc);
    }
   } // add-toolchain
   else if (PSC().VarDefined("--remove")&&PSC().VarDefined("-chain")&&os_any)
   {
    m_BuildManager.ToolChains().Remove(os_type,chain_name);
   }
  }
  if (1==config_item)
  {
   CString chain_name = PSC().VarNamed("-chain").GetString();
   if (PSC().VarDefined("--add"))
   {
    if (PSC().VarDefined("-chain"))
    {
     CToolChain *tc = m_BuildManager.ToolChains().Find(os_type,chain_name);
     if (0==tc)
     {
      tc = m_BuildManager.ToolChains().Add(os_type,chain_name);
     }
     if (0==tc) return false;
     if (PSC().VarDefined("-tool")&&PSC().VarDefined("-type"))
     {
      CString tool_type_str = PSC().VarNamed("-type").GetString();
      int tool_type_int = GuessStr(tool_type_str,"other pp as cc rc sl dl el nl count",
                                   tool_type_str,false);
      CBuildTool::ToolType tool_type = (CBuildTool::ToolType)tool_type_int;
      CString tool_name = PSC().VarNamed("-tool").GetString();
      CBuildTool *bt = tc->FindBuildToolByName(tool_name);
      if (0==bt)
      {
       bt = tc->CreateBuildTool(tool_type);
       bt->Alias() = tool_name;
      }
      if (0==bt) return false;
      ConfigureBuildTool(bt);
     }
    }
   } // add-tool
   else if (PSC().VarDefined("--remove")&&PSC().VarDefined("-chain")&&PSC().VarDefined("-tool")&&os_any)
   {
    CToolChain *tc = m_BuildManager.ToolChains().Find(os_type,chain_name);
    if (0!=tc)
    {
     return tc->RemoveToolByName(PSC().VarNamed("-tool").GetString());
    }
   }
  }
  if (2==config_item)
  {
   if (os_any)
   {
    CPlatform *p = m_BuildManager.Platforms().Find(os_type);
    if (0==p) return false;
    ConfigurePlatform(p);
   }
  }
  if (3==config_item)
  {
   if (PSC().VarDefined("--add"))
   {
    CString set_name = PSC().VarNamed("-set").GetString();
    if (PSC().VarDefined("-name") && PSC().VarDefined("-value"))
    {
     CString var_name = PSC().VarNamed("-name").GetString();
     CGlobalVariableSet *vset = m_BuildManager.Config().GlobalVariables().Add(set_name);
     CGlobalVariable *var = vset->Add(var_name);
     if (PSC().VarDefined("-desc"))
     {
      var->Description() = PSC().VarNamed("-desc").GetString();
     }
     if (PSC().VarDefined("-value"))
     {
      var->Add(PSC().VarNamed("-field").GetString(),
               PSC().VarNamed("-value").GetString());
     }
    }
   } // add variable
   else if (PSC().VarDefined("--remove"))
   {
    CString set_name = PSC().VarNamed("-set").GetString();
    if (PSC().VarDefined("-name"))
    {
     CString var_name = PSC().VarNamed("-name").GetString();
     CGlobalVariableSet *vset = m_BuildManager.Config().GlobalVariables().Add(set_name);
     CGlobalVariable *var = vset->Add(var_name);
     if (PSC().VarDefined("-field"))
     {
      // if both variable and field names are defined, remove the field
      var->Remove(PSC().VarNamed("-field").GetString());
     }
     else
     {
      // if variable name is defined, but field name is not, remove the variable
      vset->Remove(var_name);
     }
    }
    else
    {
     // if both variable and field names are not defined,
     // but set name is defined, remove the entire set
     if (PSC().VarDefined("-set"))
     {
      m_BuildManager.Config().GlobalVariables().Remove(set_name);
     }
    }
   } // remove variable
  } // config variable
  if (config_item < 0) m_BuildManager.Config().Show();
  std::cout<<"Saving configuration: "<<cfg_name.GetCString()<<std::endl;
  m_BuildManager.Config().Save(cfg_name);
  return false;
 } // config
 //
 bool os_all = PSC().VarDefined("--all-os");
      os_all = os_all || (os_unix && os_windows && os_mac);
      os_unix = os_unix || os_all;
      os_windows = os_windows || os_all;
      os_mac = os_mac || os_all;
 bool os_none = !os_all && !os_unix && !os_windows && !os_mac;
 if (os_none)
 {
#ifdef OS_UNIX
  os_unix = true;
#endif
#ifdef OS_WIN
  os_windows = true;
#endif
#ifdef OS_MAC
  os_mac = true;
#endif
 }
 if (os_unix)
 {
  CPlatform *p = m_BuildManager.Config().Platforms().Find(CPlatform::OS_Unix);
  if (p) p->Active() = true;
 }
 if (os_windows)
 {
  CPlatform *p = m_BuildManager.Config().Platforms().Find(CPlatform::OS_Windows);
  if (p) p->Active() = true;
 }
 if (os_mac)
 {
  CPlatform *p = m_BuildManager.Config().Platforms().Find(CPlatform::OS_Mac);
  if (p) p->Active() = true;
 }
 //
 {
  CString vset_name = PSC().VarNamed("-set").GetString();
  CGlobalVariableSet *vset = m_BuildManager.Config().GlobalVariables().Find(vset_name);
  if (0!=vset)
  {
   vset->Active() = true;
  }
 }
 m_BuildManager.Config().FlatObjectNames() = PSC().VarDefined("--flat-objects");
 m_BuildManager.Config().FlatObjectPaths() = PSC().VarDefined("--flat-objpath");
 m_BuildManager.Config().MultilineObjects() = PSC().VarDefined("--wrap-objects");
 m_BuildManager.Config().MultilineOptions() = PSC().VarDefined("--wrap-options");
 m_BuildManager.Config().IncludeDependencies() = PSC().VarDefined("--with-deps");
 {
  CString target_case_name = PSC().VarNamed("--target-case").GetString();
  m_BuildManager.Config().TargetNameCase() =
   GuessStr(target_case_name,"keep lower upper",target_case_name,false);
 }
 {
  CString macros_case_name = PSC().VarNamed("--macros-case").GetString();
  m_BuildManager.Config().MacroVariableCase() =
   GuessStr(macros_case_name,"keep lower upper",macros_case_name,false);
 }
 {
  CString quote_path_name = PSC().VarNamed("--quote-path").GetString();
  m_BuildManager.Config().QuotePathMode() =
   GuessStr(quote_path_name,"auto never always",quote_path_name,false);
 }
 m_BuildManager.Config().KeepObjectDirectories() = PSC().VarDefined("--keep-objdir");
 m_BuildManager.Config().KeepOutputDirectories() = PSC().VarDefined("--keep-outdir");
 {
  CStringList targets;
  ParseStr(PSC().VarNamed("-targets").GetString(),',',targets);
  targets.RemoveEmpty();
  targets.RemoveDuplicates();
  m_BuildManager.Config().Targets() = targets;
 }
 //if (BeVerbose()) PSC().Print(std::cout);
 return true;
}