/* Processes and validates incoming frames. Calls frame * dependant handler functions. * Returns < 0 for serious error */ int handle_frame(Conn_t *conn, char *buff, int size) { struct ctrl_frame *frame; if (validate_frame(buff, size) < 0) return 0; frame = (struct ctrl_frame *)buff; switch (ntohs(frame->header.opcode)) { case LE_FLUSH_REQ: handle_flush_req(frame); break; case LE_FLUSH_RSP: handle_flush_rsp(frame); break; case READY_QUERY: handle_ready_query(conn, (struct ready_frame *)frame); break; case READY_IND: /* We can ignore these */ break; case LE_ARP_REQ: if (handle_le_arp_req(frame, size) < 0) return -1; break; case LE_ARP_RSP: if (handle_arp_rsp(frame, size) < 0) return -1; break; case LE_TOPO_REQ: if (handle_topo_req(frame) < 0) return -1; break; case LE_REG_RSP: /* FIXME: Should we do something? */ break; case LE_NARP_REQ: if (handle_narp_req(frame, size) < 0) return -1; break; default: diag(COMPONENT, DIAG_ERROR, "Unknown frame, opcode 0x%x %s\n", ntohs(frame->header.opcode), opcode2text(frame->header.opcode)); break; } return 0; }
bool FrameMap::finalize_frame(int nof_slots) { assert(nof_slots >= 0, "must be positive"); assert(_num_spills == -1, "can only be set once"); _num_spills = nof_slots; assert(_framesize == -1, "should only be calculated once"); _framesize = round_to(in_bytes(sp_offset_for_monitor_base(0)) + _num_monitors * sizeof(BasicObjectLock) + sizeof(intptr_t) + // offset of deopt orig pc frame_pad_in_bytes, StackAlignmentInBytes) / 4; int java_index = 0; for (int i = 0; i < _incoming_arguments->length(); i++) { LIR_Opr opr = _incoming_arguments->at(i); if (opr->is_stack()) { _argument_locations->at_put(java_index, in_bytes(framesize_in_bytes()) + _argument_locations->at(java_index)); } java_index += type2size[opr->type()]; } // make sure it's expressible on the platform return validate_frame(); }
void print_led_info(char* filepath) { if (access(filepath, F_OK) == -1) { printf("file %s does not exist.", filepath); exit(1); } FILE* fp = fopen(filepath, "rb"); // get the size fseek(fp, 0, SEEK_END); long fsize = ftell(fp); fseek(fp, 0, SEEK_SET); // validate size if (fsize % BYTE_SIZE_SLICE != 0) { printf("Problem:\tData length is not a multiple of the slice size (%d bytes).\n", BYTE_SIZE_SLICE); exit(1); } else { printf("Info:\tContains %d slices.\n", (int)fsize / BYTE_SIZE_SLICE); } if (get_ddr_size() < fsize) { printf("Warning: The current size of shared memory is too small! Need %d bytes for this frame but only have %d.\n", (int)fsize, get_ddr_size()); exit(1); } // read file into shared memory uint32_t* frame = (uint32_t*)malloc(fsize); fread(frame, fsize, 1, fp); fclose(fp); validate_frame(frame, fsize / 4); }