Exemple #1
0
int dsp3780I_DisableDSP(DSP_3780I_CONFIG_SETTINGS * pSettings)
{
    unsigned long flags;
    unsigned short usDspBaseIO = pSettings->usDspBaseIO;
    DSP_ISA_SLAVE_CONTROL rSlaveControl;


    PRINTK_1(TRACE_3780I, "3780i::dsp3780i_DisableDSP entry\n");

    rSlaveControl.ClockControl = 0;
    rSlaveControl.SoftReset = TRUE;
    rSlaveControl.ConfigMode = FALSE;
    rSlaveControl.Reserved = 0;
    spin_lock_irqsave(&dsp_lock, flags);
    OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));

    udelay(5);

    rSlaveControl.ClockControl = 1;
    OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
    spin_unlock_irqrestore(&dsp_lock, flags);

    udelay(5);


    PRINTK_1(TRACE_3780I, "3780i::dsp3780i_DisableDSP exit\n");

    return 0;
}
Exemple #2
0
/**
 * @brief Parse packet
 *
 * This function checks validity of received packet.
 * And if it is valid, then sends it to high level.
 *
 * @param [in] _mbt RTU context
 */
static void parse_packet(struct emb_rtu_t* _mbt) {
    const unsigned char* buf = _mbt->rx_buffer;
    const int size = _mbt->rx_buf_counter-2;
    if(size >= 2) { // 4 bytes - minimal packet size
        const uint16_t crc1 = EMB_RTU_CRC_FUNCTION(buf, size);
        const uint16_t crc2 = MKWORD(buf[size], buf[size+1]);
#if EMODBUS_PACKETS_DUMPING
        if(_mbt->transport.flags & EMB_TRANSPORT_FLAG_DUMD_PAKETS)
            if(emb_dump_rx_data)
                emb_dump_rx_data(_mbt->rx_buffer, _mbt->rx_buf_counter);
#endif // EMODBUS_PACKETS_DUMPING
        if(crc1 != crc2) {
            emb_transport_error(&_mbt->transport, -modbus_bad_crc);
            return;
        }
        emb_pdu_t* const rx_pdu = _mbt->transport.rx_pdu;
        if(rx_pdu) {
            const unsigned int data_sz = size - 2;
            const unsigned int max_sz = rx_pdu->max_size;
            if(data_sz > max_sz) {
                emb_transport_error(&_mbt->transport, -modbus_resp_buffer_ovf);
                return;
            }
            rx_pdu->function = buf[1];
            rx_pdu->data_size = size - 2;
#if EMB_TRANSPORT_DO_DATA_COPY
            memcpy(rx_pdu->data, buf + 2, data_sz);
#endif  // EMB_TRANSPORT_DO_DATA_COPY
            emb_transport_recv_packet(&_mbt->transport, (int)buf[0], MB_CONST_PDU(rx_pdu));
        }
    }
}
Exemple #3
0
int dsp3780I_Reset(DSP_3780I_CONFIG_SETTINGS * pSettings)
{
    unsigned long flags;
    unsigned short usDspBaseIO = pSettings->usDspBaseIO;
    DSP_BOOT_DOMAIN rBootDomain;
    DSP_HBRIDGE_CONTROL rHBridgeControl;


    PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Reset entry\n");

    spin_lock_irqsave(&dsp_lock, flags);
    /* Mask DSP to PC interrupt */
    MKWORD(rHBridgeControl) = InWordDsp(DSP_HBridgeControl);

    PRINTK_2(TRACE_3780I, "3780i::dsp3780i_Reset rHBridgeControl %x\n",
             MKWORD(rHBridgeControl));

    rHBridgeControl.EnableDspInt = FALSE;
    OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
    spin_unlock_irqrestore(&dsp_lock, flags);

    /* Reset the core via the boot domain register */
    rBootDomain.ResetCore = TRUE;
    rBootDomain.Halt = TRUE;
    rBootDomain.NMI = TRUE;
    rBootDomain.Reserved = 0;

    PRINTK_2(TRACE_3780I, "3780i::dsp3780i_Reset rBootDomain %x\n",
             MKWORD(rBootDomain));

    WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));

    /* Reset all the chiplets and then reactivate them */
    WriteMsaCfg(DSP_ChipReset, 0xFFFF);
    udelay(5);
    WriteMsaCfg(DSP_ChipReset,
                (unsigned short) (~pSettings->usChipletEnable));


    PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Reset exit bRC=0\n");

    return 0;
}
Exemple #4
0
int dsp3780I_GetIPCSource(unsigned short usDspBaseIO,
                          unsigned short *pusIPCSource)
{
    unsigned long flags;
    DSP_HBRIDGE_CONTROL rHBridgeControl;
    unsigned short temp;


    PRINTK_3(TRACE_3780I,
             "3780i::dsp3780I_GetIPCSource entry usDspBaseIO %x pusIPCSource %p\n",
             usDspBaseIO, pusIPCSource);

    /*
    * Disable DSP to PC interrupts, read the interrupt register,
    * clear the pending IPC bits, and reenable DSP to PC interrupts
    */
    spin_lock_irqsave(&dsp_lock, flags);
    MKWORD(rHBridgeControl) = InWordDsp(DSP_HBridgeControl);
    rHBridgeControl.EnableDspInt = FALSE;
    OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));

    *pusIPCSource = InWordDsp(DSP_Interrupt);
    temp = (unsigned short) ~(*pusIPCSource);

    PRINTK_3(TRACE_3780I,
             "3780i::dsp3780I_GetIPCSource, usIPCSource %x ~ %x\n",
             *pusIPCSource, temp);

    OutWordDsp(DSP_Interrupt, (unsigned short) ~(*pusIPCSource));

    rHBridgeControl.EnableDspInt = TRUE;
    OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
    spin_unlock_irqrestore(&dsp_lock, flags);


    PRINTK_2(TRACE_3780I,
             "3780i::dsp3780I_GetIPCSource exit usIPCSource %x\n",
             *pusIPCSource);

    return 0;
}
static void EnableSRAM(THINKPAD_BD_DATA * pBDData)
{
	DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
	unsigned short usDspBaseIO = pSettings->usDspBaseIO;
	DSP_GPIO_OUTPUT_DATA_15_8 rGpioOutputData;
	DSP_GPIO_DRIVER_ENABLE_15_8 rGpioDriverEnable;
	DSP_GPIO_MODE_15_8 rGpioMode;

	PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM, entry\n");

	MKWORD(rGpioMode) = ReadMsaCfg(DSP_GpioModeControl_15_8);
	rGpioMode.GpioMode10 = 0;
	WriteMsaCfg(DSP_GpioModeControl_15_8, MKWORD(rGpioMode));

	MKWORD(rGpioDriverEnable) = 0;
	rGpioDriverEnable.Enable10 = TRUE;
	rGpioDriverEnable.Mask10 = TRUE;
	WriteMsaCfg(DSP_GpioDriverEnable_15_8, MKWORD(rGpioDriverEnable));

	MKWORD(rGpioOutputData) = 0;
	rGpioOutputData.Latch10 = 0;
	rGpioOutputData.Mask10 = TRUE;
	WriteMsaCfg(DSP_GpioOutputData_15_8, MKWORD(rGpioOutputData));

	PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM exit\n");
}
Exemple #6
0
int dsp3780I_Run(DSP_3780I_CONFIG_SETTINGS * pSettings)
{
    unsigned long flags;
    unsigned short usDspBaseIO = pSettings->usDspBaseIO;
    DSP_BOOT_DOMAIN rBootDomain;
    DSP_HBRIDGE_CONTROL rHBridgeControl;


    PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Run entry\n");


    /* Transition the core to a running state */
    rBootDomain.ResetCore = TRUE;
    rBootDomain.Halt = FALSE;
    rBootDomain.NMI = TRUE;
    rBootDomain.Reserved = 0;
    WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));

    udelay(5);

    rBootDomain.ResetCore = FALSE;
    WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
    udelay(5);

    rBootDomain.NMI = FALSE;
    WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
    udelay(5);

    /* Enable DSP to PC interrupt */
    spin_lock_irqsave(&dsp_lock, flags);
    MKWORD(rHBridgeControl) = InWordDsp(DSP_HBridgeControl);
    rHBridgeControl.EnableDspInt = TRUE;

    PRINTK_2(TRACE_3780I, "3780i::dsp3780i_Run rHBridgeControl %x\n",
             MKWORD(rHBridgeControl));

    OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
    spin_unlock_irqrestore(&dsp_lock, flags);


    PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Run exit bRC=TRUE\n");

    return 0;
}
Exemple #7
0
int dsp3780I_EnableDSP(DSP_3780I_CONFIG_SETTINGS * pSettings,
                       unsigned short *pIrqMap,
                       unsigned short *pDmaMap)
{
    unsigned long flags;
    unsigned short usDspBaseIO = pSettings->usDspBaseIO;
    int i;
    DSP_UART_CFG_1 rUartCfg1;
    DSP_UART_CFG_2 rUartCfg2;
    DSP_HBRIDGE_CFG_1 rHBridgeCfg1;
    DSP_HBRIDGE_CFG_2 rHBridgeCfg2;
    DSP_BUSMASTER_CFG_1 rBusmasterCfg1;
    DSP_BUSMASTER_CFG_2 rBusmasterCfg2;
    DSP_ISA_PROT_CFG rIsaProtCfg;
    DSP_POWER_MGMT_CFG rPowerMgmtCfg;
    DSP_HBUS_TIMER_CFG rHBusTimerCfg;
    DSP_LBUS_TIMEOUT_DISABLE rLBusTimeoutDisable;
    DSP_CHIP_RESET rChipReset;
    DSP_CLOCK_CONTROL_1 rClockControl1;
    DSP_CLOCK_CONTROL_2 rClockControl2;
    DSP_ISA_SLAVE_CONTROL rSlaveControl;
    DSP_HBRIDGE_CONTROL rHBridgeControl;
    unsigned short ChipID = 0;
    unsigned short tval;


    PRINTK_2(TRACE_3780I,
             "3780i::dsp3780I_EnableDSP entry pSettings->bDSPEnabled %x\n",
             pSettings->bDSPEnabled);


    if (!pSettings->bDSPEnabled) {
        PRINTK_ERROR( KERN_ERR "3780i::dsp3780I_EnableDSP: Error: DSP not enabled. Aborting.\n" );
        return -EIO;
    }


    PRINTK_2(TRACE_3780I,
             "3780i::dsp3780i_EnableDSP entry pSettings->bModemEnabled %x\n",
             pSettings->bModemEnabled);

    if (pSettings->bModemEnabled) {
        rUartCfg1.Reserved = rUartCfg2.Reserved = 0;
        rUartCfg1.IrqActiveLow = pSettings->bUartIrqActiveLow;
        rUartCfg1.IrqPulse = pSettings->bUartIrqPulse;
        rUartCfg1.Irq =
            (unsigned char) pIrqMap[pSettings->usUartIrq];
        switch (pSettings->usUartBaseIO) {
        case 0x03F8:
            rUartCfg1.BaseIO = 0;
            break;
        case 0x02F8:
            rUartCfg1.BaseIO = 1;
            break;
        case 0x03E8:
            rUartCfg1.BaseIO = 2;
            break;
        case 0x02E8:
            rUartCfg1.BaseIO = 3;
            break;
        }
        rUartCfg2.Enable = TRUE;
    }

    rHBridgeCfg1.Reserved = rHBridgeCfg2.Reserved = 0;
    rHBridgeCfg1.IrqActiveLow = pSettings->bDspIrqActiveLow;
    rHBridgeCfg1.IrqPulse = pSettings->bDspIrqPulse;
    rHBridgeCfg1.Irq = (unsigned char) pIrqMap[pSettings->usDspIrq];
    rHBridgeCfg1.AccessMode = 1;
    rHBridgeCfg2.Enable = TRUE;


    rBusmasterCfg2.Reserved = 0;
    rBusmasterCfg1.Dma = (unsigned char) pDmaMap[pSettings->usDspDma];
    rBusmasterCfg1.NumTransfers =
        (unsigned char) pSettings->usNumTransfers;
    rBusmasterCfg1.ReRequest = (unsigned char) pSettings->usReRequest;
    rBusmasterCfg1.MEMCS16 = pSettings->bEnableMEMCS16;
    rBusmasterCfg2.IsaMemCmdWidth =
        (unsigned char) pSettings->usIsaMemCmdWidth;


    rIsaProtCfg.Reserved = 0;
    rIsaProtCfg.GateIOCHRDY = pSettings->bGateIOCHRDY;

    rPowerMgmtCfg.Reserved = 0;
    rPowerMgmtCfg.Enable = pSettings->bEnablePwrMgmt;

    rHBusTimerCfg.LoadValue =
        (unsigned char) pSettings->usHBusTimerLoadValue;

    rLBusTimeoutDisable.Reserved = 0;
    rLBusTimeoutDisable.DisableTimeout =
        pSettings->bDisableLBusTimeout;

    MKWORD(rChipReset) = ~pSettings->usChipletEnable;

    rClockControl1.Reserved1 = rClockControl1.Reserved2 = 0;
    rClockControl1.N_Divisor = pSettings->usN_Divisor;
    rClockControl1.M_Multiplier = pSettings->usM_Multiplier;

    rClockControl2.Reserved = 0;
    rClockControl2.PllBypass = pSettings->bPllBypass;

    /* Issue a soft reset to the chip */
    /* Note: Since we may be coming in with 3780i clocks suspended, we must keep
    * soft-reset active for 10ms.
    */
    rSlaveControl.ClockControl = 0;
    rSlaveControl.SoftReset = TRUE;
    rSlaveControl.ConfigMode = FALSE;
    rSlaveControl.Reserved = 0;

    PRINTK_4(TRACE_3780I,
             "3780i::dsp3780i_EnableDSP usDspBaseIO %x index %x taddr %x\n",
             usDspBaseIO, DSP_IsaSlaveControl,
             usDspBaseIO + DSP_IsaSlaveControl);

    PRINTK_2(TRACE_3780I,
             "3780i::dsp3780i_EnableDSP rSlaveContrl %x\n",
             MKWORD(rSlaveControl));

    spin_lock_irqsave(&dsp_lock, flags);
    OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
    MKWORD(tval) = InWordDsp(DSP_IsaSlaveControl);

    PRINTK_2(TRACE_3780I,
             "3780i::dsp3780i_EnableDSP rSlaveControl 2 %x\n", tval);


    for (i = 0; i < 11; i++)
        udelay(2000);

    rSlaveControl.SoftReset = FALSE;
    OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));

    MKWORD(tval) = InWordDsp(DSP_IsaSlaveControl);

    PRINTK_2(TRACE_3780I,
             "3780i::dsp3780i_EnableDSP rSlaveControl 3 %x\n", tval);


    /* Program our general configuration registers */
    WriteGenCfg(DSP_HBridgeCfg1Index, MKBYTE(rHBridgeCfg1));
    WriteGenCfg(DSP_HBridgeCfg2Index, MKBYTE(rHBridgeCfg2));
    WriteGenCfg(DSP_BusMasterCfg1Index, MKBYTE(rBusmasterCfg1));
    WriteGenCfg(DSP_BusMasterCfg2Index, MKBYTE(rBusmasterCfg2));
    WriteGenCfg(DSP_IsaProtCfgIndex, MKBYTE(rIsaProtCfg));
    WriteGenCfg(DSP_PowerMgCfgIndex, MKBYTE(rPowerMgmtCfg));
    WriteGenCfg(DSP_HBusTimerCfgIndex, MKBYTE(rHBusTimerCfg));

    if (pSettings->bModemEnabled) {
        WriteGenCfg(DSP_UartCfg1Index, MKBYTE(rUartCfg1));
        WriteGenCfg(DSP_UartCfg2Index, MKBYTE(rUartCfg2));
    }


    rHBridgeControl.EnableDspInt = FALSE;
    rHBridgeControl.MemAutoInc = TRUE;
    rHBridgeControl.IoAutoInc = FALSE;
    rHBridgeControl.DiagnosticMode = FALSE;

    PRINTK_3(TRACE_3780I,
             "3780i::dsp3780i_EnableDSP DSP_HBridgeControl %x rHBridgeControl %x\n",
             DSP_HBridgeControl, MKWORD(rHBridgeControl));

    OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
    spin_unlock_irqrestore(&dsp_lock, flags);
    WriteMsaCfg(DSP_LBusTimeoutDisable, MKWORD(rLBusTimeoutDisable));
    WriteMsaCfg(DSP_ClockControl_1, MKWORD(rClockControl1));
    WriteMsaCfg(DSP_ClockControl_2, MKWORD(rClockControl2));
    WriteMsaCfg(DSP_ChipReset, MKWORD(rChipReset));

    ChipID = ReadMsaCfg(DSP_ChipID);

    PRINTK_2(TRACE_3780I,
             "3780i::dsp3780I_EnableDSP exiting bRC=TRUE, ChipID %x\n",
             ChipID);

    return 0;
}
Exemple #8
0
delimiters is passed unchanged to the output.
See: 17.6.2.2141 REPLACES, 17.6.2.2375 UNESCAPE, A.17.6.255.0 SUBSTITUTE.
17.6.2.2375 UNESCAPE
STRING EXT
x:substitute
( c-addr1u1c-addr2-- c-addr2u2)
Replace each ‘%’ character in the input string c-addr1u1by two ‘%’ characters. The
output is represented by c-addr2u2. The buffer at c-addr2must be big enough to hold
the unescaped string. An ambiguous condition occurs if the resulting string will not fit
into the destination buffer (c-addr2).
See: 17.6.2.2255 SUBSTITUTE.

*/

#include "sf-word-wizard.h"
static struct word dict_base_dummy_word[1] = { MKWORD(0, 0, "", 0), };
static const struct word custom_dict[] = {
	/* override the sforth supplied engine reset */
	MKWORD(dict_base_dummy_word,	0,		"-trailing",	do_dash_trailing),
	MKWORD(custom_dict,		__COUNTER__,	"/string",	do_slash_string),
	MKWORD(custom_dict,		__COUNTER__,	"blank",	do_blank),
	MKWORD(custom_dict,		__COUNTER__,	"cmove",	do_cmove),
	MKWORD(custom_dict,		__COUNTER__,	"cmove>",	do_cmove_up),
	MKWORD(custom_dict,		__COUNTER__,	"compare",	do_compare),
	MKWORD(custom_dict,		__COUNTER__,	"search",	do_search),
	MKIMMWORD(custom_dict,		__COUNTER__,	"sliteral",	do_sliteral),

}, * custom_dict_start = custom_dict + __COUNTER__;

static void sf_opt_string_init(void) __attribute__((constructor));
static void sf_opt_string_init(void)
Execution: ( -- )
Does nothing. [THEN] is an immediate word.
See: A.15.6.2.2533 [THEN].

*/
static void do_bracket_then(void) { /*: [then] ; immediate */ }
static void do_bracket_defined(void)
{
	/*: [defined] bl word find swap drop 0<> ; immediate */
	do_bl(); do_word(); do_find(); do_swap(); do_drop(); do_zero_not_equals();
}
static void do_bracket_undefined(void) { /* : [undefined] [defined] invert ; immediate */ do_bracket_defined(); do_invert(); }


#include "sf-word-wizard.h"
static struct word dict_base_dummy_word[1] = { MKWORD(0, 0, "", 0), };
static const struct word custom_dict[] = {
	/* override the sforth supplied engine reset */
	MKWORD(dict_base_dummy_word,	0,		"[else]",	do_bracket_else),
	MKWORD(custom_dict,		__COUNTER__,	"[if]",		do_bracket_if),
	MKWORD(custom_dict,		__COUNTER__,	"[then]",	do_bracket_then),
	MKWORD(custom_dict,		__COUNTER__,	"[defined]",	do_bracket_defined),
	MKWORD(custom_dict,		__COUNTER__,	"[undefined]",	do_bracket_undefined),

}, * custom_dict_start = custom_dict + __COUNTER__;

static void sf_opt_prog_tools_init(void) __attribute__((constructor));
static void sf_opt_prog_tools_init(void)
{
	sf_merge_custom_dictionary(dict_base_dummy_word, custom_dict_start);
}
Exemple #10
0
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "engine.h"
#include "sf-word-wizard.h"

static void do_squared(void) { cell x = sf_pop(); sf_push(x * x); }
static void do_gcd(void)
/* implements the FORTH word:
: gcd ( n1 n2 | n) begin over mod swap over 0= until nip ;
*/
{ do { do_over(); do_mod(); do_swap(); do_over(); do_zero_not_equals(); } while (sf_pop()); do_nip(); }

static struct word dict_base_dummy_word[1] = { MKWORD(0, 0, "", 0), };
static const struct word custom_dict[] = {
	MKWORD(dict_base_dummy_word,	0,		"squared",	do_squared),
	MKWORD(custom_dict,		__COUNTER__,	"gcd",	do_gcd),

}, * custom_dict_start = custom_dict + __COUNTER__;

static void sf_opt_sample_init(void) __attribute__((constructor));
static void sf_opt_sample_init(void)
{
	sf_merge_custom_dictionary(dict_base_dummy_word, custom_dict_start);
}