Exemple #1
0
static int gbboot_cport_handler(uint32_t cportid,
                                void *data,
                                size_t len) {
    dbgprint("gbboot cport Rx:");
    int i;
    for(i = 0; i < len; i++) {
        if ((i & 0xF) == 0) dbgprint("\n    ");
        dbgprinthex8(((unsigned char *)data)[i]);
        dbgprint(" ");
    }
    dbgprint("\n");

    int rc = 0;
    if (len < sizeof(gb_operation_header)) {
        dbgprint("control_cport_handler: RX data length err\n");
        return -1;
    }

    gb_operation_header *op_header = (gb_operation_header *)data;

    switch (op_header->type) {
    case GB_BOOT_OP_FIRMWARE_SIZE:
        rc = gbboot_get_firmware_size(cportid, op_header);
        break;
    case GB_BOOT_OP_GET_FIRMWARE:
        rc = gbboot_get_firmware(cportid, op_header);
#if _SPECIAL_TEST == SPECIAL_GEAR_CHANGE_TEST
        switch_gear_change(GEAR_HS_G2,
                           TERMINATION_ON,
                           HS_MODE_A,
                           2,
                           POWERMODE_FAST);
#endif
        break;
    case GB_BOOT_OP_READY_TO_BOOT:
        rc = gbboot_ready_to_boot(cportid, op_header);
        break;
    default:
        break;
    }

    return rc;
}
static int gbboot_cport_handler(uint32_t cportid,
                                void *data,
                                size_t len) {
    dbgprint("gbboot cport Rx:");
    unsigned char *p = (unsigned char *)data;
    int i;
    for(i = 0; i < len; i++) {
        if ((i & 0xF) == 0) dbgprint("\n    ");
        dbgprinthex8(p[i]);
        dbgprint(" ");
    }
    dbgprint("\n");

    int rc = 0;
    if (len < sizeof(gb_operation_header)) {
        dbgprint("control_cport_handler: RX data length err\n");
        return -1;
    }

    gb_operation_header *op_header = (gb_operation_header *)data;

    switch (op_header->type) {
    case GB_BOOT_OP_FIRMWARE_SIZE:
        rc = gbboot_get_firmware_size(cportid, op_header);
        break;
    case GB_BOOT_OP_GET_FIRMWARE:
        rc = gbboot_get_firmware(cportid, op_header);
        break;
    case GB_BOOT_OP_READY_TO_BOOT:
        rc = gbboot_ready_to_boot(cportid, op_header);
        break;
    default:
        break;
    }

    return rc;
}