Ejemplo n.º 1
0
// Reset the board.
void 
__reset (void)
{
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
    __call_if_reset_t *__rom_reset = CYGACC_CALL_IF_RESET_GET();
    if (__rom_reset)
        (*__rom_reset)();
#else
    HAL_PLATFORM_RESET();
#endif
}
Ejemplo n.º 2
0
static void
reset(void)
{
    CYGARC_HAL_SAVE_GP();
    // With luck, the platform defines some magic that will cause a hardware
    // reset.
    HAL_PLATFORM_RESET();

#ifdef HAL_PLATFORM_RESET_ENTRY
    // If that's not the case (above is an empty statement) there may
    // be defined an address we can jump to - and effectively
    // reinitialize the system. Not quite as good as a reset, but it
    // is often enough.
//    goto *HAL_PLATFORM_RESET_ENTRY;

#else
#error " no RESET_ENTRY"
#endif

    CYGARC_HAL_RESTORE_GP();
}
Ejemplo n.º 3
0
void 
create_cleanup_thread(void)
{
    unsigned int err;

    cyg_mbox_create(&cleanup.mbox_handle, &cleanup_mbox);
    cyg_semaphore_init(&cleanup.cleanup_sem, 0);
    
    if((err = shell_create_thread(NULL,
				 5,
				 cleanup_thread,
				 0,
				 "Cleanup Thread",
				 NULL,
				 0,
				 NULL) != SHELL_OK)) {
	SHELL_ERROR("Failed to create Cleanup thread\n");
	HAL_PLATFORM_RESET();
    }
    
    SHELL_DEBUG_PRINT("Created Cleanup thread\n");
}
Ejemplo n.º 4
0
void l2ftp_frame_proc(cs_ether_frame_t *frame, cs_uint16 framesz, cs_port_id_t port)
{
    cs_l2ftp_header_t *header;
    cs_l2ftp_pdu_data_t *l2ftp_pdu_p;
    cs_uint16 l2ftp_pdu_len, block, opcode;
    cs_uint16 minsz;
    cs_uint8 *ptr;
    cs_callback_context_t context;
    cs_uint8 mac[CS_MACADDR_LEN];
    bool last_data_frame = false;

    minsz = CS_FRAME_HEADER_LEN + sizeof(cs_l2ftp_header_t);

    if (framesz < minsz) {
        IROS_LOG_INF(IROS_MID_L2FTP,
        "l2ftp: too short for headers\n");
        return;
    }

#ifdef HAVE_OOB_MGMT
    if(port != active_update_port)
    {
        diag_printf("l2ftp error: active_update_port 0x%x, port 0x%x\n",
        active_update_port, port);
        /*l2ftp_send_error_to_port(EPON_L2FTP_ERROR_WRONG_PORT, port);*/
        return;
    }
#endif

    ptr = (cs_uint8 *)frame;

    epon_request_onu_pon_mac_addr_get(context, ONU_DEVICEID_FOR_API, ONU_LLIDPORT_FOR_API, (cs_mac_t *)mac);
    if (memcmp(frame->ether_header.dst.addr,mac,CS_MACADDR_LEN)||
        memcmp(frame->layer3_header.dst.addr,mac,CS_MACADDR_LEN)||
        (frame->ether_header.ethertype != htons(CS_ETHERTYPE_IROS)) ||
        (frame->layer3_header.layer3type != htons(CS_LAYER3_TYPE_FTP))) {
            IROS_LOG_INF(IROS_MID_L2FTP,"l2ftp: not a l2ftp frame\n");
            return;
    }

    header = (cs_l2ftp_header_t *)frame->payload;
    opcode = ntohs(header->opcode);

    switch (opcode) {
        case CS_L2FTP_PDU_OPCODE_DATA:
            IROS_LOG_DBG0(IROS_MID_L2FTP,
                            "l2ftp: rx an data pdu\n");
            diag_printf(".");
            dot_count++;
            if (dot_count >= 40) {
                dot_count = 0;
                diag_printf("\n");
            }
            minsz += sizeof(cs_uint16) + sizeof(cs_uint16);
            if (framesz < minsz) {
                IROS_LOG_INF(IROS_MID_L2FTP,
                "l2ftp: too short for data headers\n");
                return;
            }
            l2ftp_pdu_p = (cs_l2ftp_pdu_data_t *)frame->payload;
            block = ntohs(l2ftp_pdu_p->block);
            l2ftp_pdu_len = ntohs(l2ftp_pdu_p->length);
            minsz += l2ftp_pdu_len;
            if (framesz < minsz) {
                IROS_LOG_INF(IROS_MID_L2FTP,
                "l2ftp: too short for data payload\n");
                return;
            }
            if (block == block_expected) {
                block_expected++;
                if (start) {
                    start = 0;
                }
                retry = 0;

                
                if (l2ftp_pdu_len < CS_L2FTP_BLOCK_SIZE)
                    last_data_frame = true;

#if 0
                cs_int32 return_status = 0;
                mif_upgrade_state_t mif_engine_status;
                memset(&mif_engine_status, 0, sizeof(mif_engine_status));

                extern cs_int32 mif_upgrade (cs_uint8 module, cs_uint8 * input_buff, cs_int32 length, mif_upgrade_state_t * cur_state, bool end_of_file);
                return_status = mif_upgrade (1, l2ftp_pdu_p->data, l2ftp_pdu_len, &mif_engine_status, last_data_frame);

                if (return_status ==0) {  //write successfully
                    if (last_data_frame == true) {   //for the last frame
                        cs_timer_del(l2ftp_record.timer);
                        l2ftp_send_ack();
                        l2ftp_send_ack();
                        //IROS_LOG_CRI(IROS_MID_L2FTP,
                        //        "\nl2ftp done: len %d\n", image_len);
                        //app_update_file_transfer_done(image_len);
                        updateInProgress = EPON_FALSE;
                        active_update_port = 0;

                        //if blob partition is updated, reset the CPU
                        if (mif_engine_status.tlv_update_successed & 0x1) {
                            diag_printf("reboot\n");
                            HAL_PLATFORM_RESET();
                        }
                    }

                }
                else {
                    diag_printf("error encounted durng update, error code: %d\n", return_status);
                    l2ftp_send_error(CS_L2FTP_ERROR_IMAGE_SIZE);
                    // image_len = 0;
                    cs_timer_del(l2ftp_record.timer);
                    updateInProgress = EPON_FALSE;
                    active_update_port = 0;
                    return;
                }
#endif                
            }
            else {
                IROS_LOG_INF(IROS_MID_L2FTP,
                "l2ftp: duplicated data pdu\n");
            }
            
            l2ftp_send_ack();
            break;

        case CS_L2FTP_PDU_OPCODE_ERROR:
            IROS_LOG_INF(IROS_MID_L2FTP,
                        "l2ftp: rx an error pdu\n");
            minsz += sizeof(cs_uint32);
            if (framesz < minsz) {
                IROS_LOG_INF(IROS_MID_L2FTP,
                "l2ftp: too short for error reason\n");
                return;
            }
            retry = 0;
            //image_len = 0;
            cs_timer_del(l2ftp_record.timer);
            //app_update_file_transfer_done(image_len);
            updateInProgress = EPON_FALSE;
            active_update_port = 0;
            break;

        default:
            IROS_LOG_INF(IROS_MID_L2FTP,
            "l2ftp: unexpected opcode 0x%x\n", opcode);
            break;
        }
}