Example #1
0
/*============================================================================*/
static bool uart_listen(struct bldr_comport *comport, uint8 *data, uint32 size, int retry, uint32 tmo_ms)
{
    u8 c = 0;
    int rx_cnt = 0;
    int tmo_en = (tmo_ms) ? 1 : 0;
    ulong start_time;

    for (; retry > 0; retry--) {
        start_time = get_timer(0);
        while(1) {
            if (tmo_en && (get_timer(start_time) > tmo_ms))
                break;

            /* kick watchdog to avoid cpu reset */
            if (!tmo_en)
                platform_wdt_kick();

            GetUARTBytes(&c, 1, 10);
            if (c != 0) {
                *data++ = (uint8)c;
                rx_cnt++;
            }

            if (rx_cnt == size){
                print("%s <UART> listen  success!\n",MOD);
                return TRUE;
            }
        }
    }

      print("%s <UART> listen  ended, receive size:%d!\n",MOD,rx_cnt);

    return FALSE;
}
Example #2
0
/*============================================================================*/
void bldr_jump(u32 addr, u32 arg1, u32 arg2)
{
    platform_wdt_kick();

    /* disable preloader safe mode */
    platform_safe_mode(0, 0);

    print("\n%s jump to 0x%x\n", MOD, addr);
    print("%s <0x%x>=0x%x\n", MOD, addr, *(u32*)addr);
    print("%s <0x%x>=0x%x\n", MOD, addr + 4, *(u32*)(addr + 4));

    jump(addr, arg1, arg2);
}
Example #3
0
/*============================================================================*/
void bldr_jump(u32 addr, u32 arg1, u32 arg2)
{
    platform_wdt_kick();

    /* disable preloader safe mode */
    platform_safe_mode(0, 0);

    print("\n%s jump to 0x%x\n", MOD, addr);
    print("%s <0x%x>=0x%x\n", MOD, addr, *(u32*)addr);
    print("%s <0x%x>=0x%x\n", MOD, addr + 4, *(u32*)(addr + 4));
    /* 2012/11/27
     * Sten
     * Remove MT6589 MCI downsizer workaround start*/
    *(volatile unsigned int*)(0x10001200) &= (~0x1);
     /* Remove MT6589 MCI downsizer workaround end*/
    jump(addr, arg1, arg2);
}
Example #4
0
/*============================================================================*/
void bldr_jump(u32 addr, u32 arg1, u32 arg2)
{
    platform_wdt_kick();

    /* disable preloader safe mode */
    platform_safe_mode(0, 0);

    apmcu_disable_dcache();
    apmcu_dcache_clean_invalidate();
    apmcu_dsb();
    apmcu_icache_invalidate();
    apmcu_disable_icache();
    apmcu_isb();
    apmcu_disable_smp();

    print("\n%s jump to 0x%x\n", MOD, addr);
    print("%s <0x%x>=0x%x\n", MOD, addr, *(u32*)addr);
    print("%s <0x%x>=0x%x\n", MOD, addr + 4, *(u32*)(addr + 4));

    jump(addr, arg1, arg2);
}
static int usb_recv(u8 *buf, u32 size, u32 tmo_ms)
{
    ulong start_time = get_timer(0);
    u32 dsz;
    u32 tmo_en = (tmo_ms) ? 1 : 0;
    u8 *ptr = buf;

    if (!size)
        return 0;

    while (1) {
        if (tmo_en && (get_timer(start_time) > tmo_ms))
            return -1;

        if (!tmo_en) {
            /* kick watchdog to avoid cpu reset but don't kick pmic wdt since
             * it could use i2c operations during a communication command protocl
             * that could break the atomic operation of 2 pmic i2c communication 
             * commands. i2c operations should be not used during usb send or recv. 
             * for example:
             *
             * i2c_write(pmic_addr) -> usb_recv() -> i2c_read(&pmic_data).
             */
            platform_wdt_kick();
        }

        dsz = mt_usbtty_query_data_size();
        if (dsz) {
            dsz = dsz < size ? dsz : size;
            mt_usbtty_getcn(dsz, (char*)ptr);
            ptr  += dsz;
            size -= dsz;
        }
        if (size == 0)
            break;
    }

    return 0;
}
Example #6
0
int GetUARTBytes(u8 *buf, u32 size, u32 tmo_ms)
{
    u32 LSR;
    int tmo_en = (tmo_ms) ? 1 : 0;
    ulong start_time = get_timer(0);

    while (size) {
        if (tmo_en && (get_timer(start_time) > tmo_ms))
            break;

        /* kick watchdog to avoid cpu reset */
        if (!tmo_en)
            platform_wdt_kick();

        LSR = UART_READ32(UART_LSR(g_uart));
        if (LSR & UART_LSR_DR) {
            *buf++ = (u8)UART_READ32(UART_RBR(g_uart));
            size--;
        }
    }

    return (0 == size) ? 0 : -1;
}
Example #7
0
void bldr_jump64(u32 addr, u32 arg1, u32 arg2)
{
    platform_wdt_kick();

    /* disable preloader safe mode */
    platform_safe_mode(0, 0);

    print("\n%s jump to 0x%x\n", MOD, addr);
    print("%s <0x%x>=0x%x\n", MOD, addr, *(u32*)addr);
    print("%s <0x%x>=0x%x\n", MOD, addr + 4, *(u32*)(addr + 4));

#if CFG_ATF_SUPPORT
    trustzone_jump(addr, arg1, arg2);
#else
    print("%s trustzone is not supported!\n", MOD);

    #if CFG_LOAD_SLT_AARCH64_KERNEL
	print("%s jump to 64 bit SLT kernel!\n", MOD);
	jumparch64_slt();
    #endif

#endif
}