static int emi_msg_read_retdata(struct sk_dpr *sd, struct emi_msg *msg){ void *total_data = GET_ADDR(msg, msg->retdata_offset); if(emi_read(sd, total_data, msg->retsize)) { return -1; } //update offset struct emi_retdata *data = (struct emi_retdata *)total_data; es64 left_size = msg->retsize; while(1){ data->next_offset = msg->retdata_offset + data->size + sizeof(struct emi_retdata); left_size -= data->size + sizeof(struct emi_retdata); if(left_size > 0){ data = (struct emi_retdata *)GET_ADDR(msg, data->next_offset); }else{ break; } }; data->next_offset = 0; return 0; }
/*********************************************************************//** * @brief Program one 16-bit data into external NOR FLASH memory * This "uint16_t" for the external flash is 16 bits!!! * @param[in] Addr Address value * @param[in] Data data value * @return Program result, could be: - TRUE: succesful - FALSE: fail **********************************************************************/ uint32_t NORFLASHWriteWord( uint32_t Addr, uint16_t Data ) { volatile uint16_t *ip; ip = GET_ADDR(0x5555); *ip = 0x00AA; ip = GET_ADDR(0x2aaa); *ip = 0x0055; ip = GET_ADDR(0x5555); *ip = 0x00A0; ip = GET_ADDR(Addr); /* Program 16-bit word */ *ip = Data; return ( ToggleBitCheck( Addr, Data ) ); }
static int emi_msg_write_data(struct sk_dpr *sd, struct emi_msg const *msg){ void *data = GET_ADDR(msg, msg->data_offset); if (emi_write(sd, data, msg->size)) { return -1; } return 0; }
void sos_fill_input_state(sos_input_id_t id, sos_input_state_t *state) { uint32_t val = GET_ADDR((SOS_INPUT_BASE_ADDR + id)); state->left = ((val & 0x01) != 0); state->right = ((val & 0x02) != 0); state->up = ((val & 0x04) != 0); state->down = ((val & 0x08) != 0); state->aux_a = ((val & 0x10) != 0); state->aux_b = ((val & 0x20) != 0); state->aux_c = ((val & 0x40) != 0); state->aux_d = ((val & 0x80) != 0); state->active = ((val & 0x100) != 0); }
/*********************************************************************//** * @brief Toggle Bit check if the data is written or erased * @param[in] Addr address value * @param[in] Data expected data * @return Checking result, could be: * - TRUE: Done * - FALSE: Timeout **********************************************************************/ uint32_t ToggleBitCheck( uint32_t Addr, uint16_t Data ) { volatile uint16_t *ip; uint16_t temp1, temp2; uint32_t TimeOut = PROGRAM_TIMEOUT; while( TimeOut > 0 ) { ip = GET_ADDR(Addr); temp1 = *ip; ip = GET_ADDR(Addr); temp2 = *ip; if ( (temp1 == temp2) && (temp1 == Data) ) { return( TRUE ); } TimeOut--; } return ( FALSE ); }
int build_frame(frame_t dest, const out_cmd_t cmd, const plchar_t *payload, const size_t input_len) { int pos = 0; /* add start-of-frame, address and command: */ dest[pos++] = START_CHAR; dest[pos++] = addr_encode(GET_ADDR(cmd)); dest[pos++] = GET_CMD_CHAR(cmd); /* add and encode payload: */ pos += mb64_encode(&dest[pos], payload, input_len); /* add CRC and end-of-frame character: */ pos += calc_crc_chars(&dest[pos], calc_crc(dest, pos)); dest[pos++] = END_CHAR; dest[pos] = '\0'; return pos; }
static inline void disposeFrameIfNeeded(argb *bm, GifInfo *info) { GifFileType *fGif = info->gifFilePtr; SavedImage *cur = &fGif->SavedImages[info->currentIndex - 1]; SavedImage *next = &fGif->SavedImages[info->currentIndex]; // We can skip disposal process if next frame is not transparent // and completely covers current area uint_fast8_t curDisposal = info->controlBlock[info->currentIndex - 1].DisposalMode; bool nextTrans = info->controlBlock[info->currentIndex].TransparentColor != NO_TRANSPARENT_COLOR; unsigned char nextDisposal = info->controlBlock[info->currentIndex].DisposalMode; if ((curDisposal == DISPOSE_PREVIOUS || nextDisposal == DISPOSE_PREVIOUS) && info->backupPtr == NULL) { info->backupPtr = calloc(info->stride * fGif->SHeight, sizeof(argb)); if (!info->backupPtr) { info->gifFilePtr->Error = D_GIF_ERR_NOT_ENOUGH_MEM; //TODO throw OOME return; } } argb *backup = info->backupPtr; if (nextTrans || !checkIfCover(next, cur)) { if (curDisposal == DISPOSE_BACKGROUND) {// restore to background (under this image) color uint32_t *dst = (uint32_t *) GET_ADDR(bm, info->stride, cur->ImageDesc.Left, cur->ImageDesc.Top); uint_fast16_t copyWidth = cur->ImageDesc.Width; if (cur->ImageDesc.Left + copyWidth > fGif->SWidth) { copyWidth = fGif->SWidth - cur->ImageDesc.Left; } uint_fast16_t copyHeight = cur->ImageDesc.Height; if (cur->ImageDesc.Top + copyHeight > fGif->SHeight) { copyHeight = fGif->SHeight - cur->ImageDesc.Top; } for (; copyHeight > 0; copyHeight--) { MEMSET_ARGB(dst, 0, copyWidth); dst += info->stride; } } else if (curDisposal == DISPOSE_PREVIOUS && nextDisposal == DISPOSE_PREVIOUS) {// restore to previous argb *tmp = bm; bm = backup; backup = tmp; } } // Save current image if next frame's disposal method == DISPOSE_PREVIOUS if (nextDisposal == DISPOSE_PREVIOUS) memcpy(backup, bm, info->stride * fGif->SHeight * sizeof(argb)); }
static inline void blitNormal(argb *bm, GifInfo *info, SavedImage *frame, ColorMapObject *cmap) { unsigned char *src = info->rasterBits; argb *dst = GET_ADDR(bm, info->stride, frame->ImageDesc.Left, frame->ImageDesc.Top); uint_fast16_t x, y = frame->ImageDesc.Height; const int_fast16_t transpIndex = info->controlBlock[info->currentIndex].TransparentColor; if (info->isOpaque == JNI_TRUE) { if (transpIndex == NO_TRANSPARENT_COLOR) { for (; y > 0; y--) { for (x = frame->ImageDesc.Width; x > 0; x--, src++, dst++) dst->rgb = cmap->Colors[*src]; dst += info->stride - frame->ImageDesc.Width; } } else { for (; y > 0; y--) { for (x = frame->ImageDesc.Width; x > 0; x--, src++, dst++) { if (*src != transpIndex) dst->rgb = cmap->Colors[*src]; } dst += info->stride - frame->ImageDesc.Width; } } } else { if (transpIndex == NO_TRANSPARENT_COLOR) { for (; y > 0; y--) { MEMSET_ARGB((uint32_t *) dst, UINT32_MAX, frame->ImageDesc.Width); for (x = frame->ImageDesc.Width; x > 0; x--, src++, dst++) dst->rgb = cmap->Colors[*src]; dst += info->stride - frame->ImageDesc.Width; } } else { for (; y > 0; y--) { for (x = frame->ImageDesc.Width; x > 0; x--, src++, dst++) { if (*src != transpIndex) { dst->rgb = cmap->Colors[*src]; dst->alpha = 0xFF; } } dst += info->stride - frame->ImageDesc.Width; } } } }
/*********************************************************************//** * @brief Check ID from external NOR FLASH memory * @param[in] None * @return Checking result, could be: * - TRUE: Correct * - FALSE: Incorrect **********************************************************************/ uint32_t NORFLASHCheckID( void ) { volatile uint16_t *ip; uint16_t SST_id1, SST_id2; /* Issue the Software Product ID code to 39VF160 */ ip = GET_ADDR(0x5555); *ip = 0x00AA; ip = GET_ADDR(0x2AAA); *ip = 0x0055; ip = GET_ADDR(0x5555); *ip = 0x0090; delay(10); /* Read the product ID from 39VF160 */ ip = GET_ADDR(0x0000); SST_id1 = *ip & 0x00FF; ip = GET_ADDR(0x0001); SST_id2 = *ip; /* Issue the Soffware Product ID Exit code thus returning the 39VF160 */ /* to the read operating mode */ ip = GET_ADDR(0x5555); *ip = 0x00AA; ip = GET_ADDR(0x2AAA); *ip = 0x0055; ip = GET_ADDR(0x5555); *ip = 0x00F0; delay(10); /* Check ID */ if ((SST_id1 == SST_ID) && (SST_id2 ==SST_39VF160)) return( TRUE ); else return( FALSE ); }
/*********************************************************************//** * @brief Erase external NOR FLASH memory * @param[in] None * @return None **********************************************************************/ void NORFLASHErase( void ) { volatile uint16_t *ip; ip = GET_ADDR(0x5555); *ip = 0x00AA; ip = GET_ADDR(0x2AAA); *ip = 0x0055; ip = GET_ADDR(0x5555); *ip = 0x0080; ip = GET_ADDR(0x5555); *ip = 0x00AA; ip = GET_ADDR(0x2AAA); *ip = 0x0055; ip = GET_ADDR(0x5555); *ip = 0x0010; delay(10000000); /* Use timer 1 */ return; }
int test_controller() { vbe_controller_info_t info; void* base=NULL; if(vbe_get_controller_info(&info, &base)){ printf("test_controller(): vbe_get_controller_info() failed\n"); return 1; } printf("VBE Signature : %s\n", info.VbeSignature); printf("VBE Version : ");print_vbe_version(info.VbeVersion); printf("\n"); printf("OEM String : %s\n", GET_ADDR(info.OemStringPtr, base)); printf("Total VRAM memory : %u (blocks of 64 kb)\n", info.TotalMemory); printf("OEM Software Revision: "); print_vbe_version(info.OemSoftwareRev); printf("\n"); printf("OEM Vendor Name : %s\n", GET_ADDR(info.OemVendorNamePtr, base),GET_ADDR(info.OemVendorNamePtr, base)); printf("OEM Product Name : %s\n", GET_ADDR(info.OemProductNamePtr, base)); printf("OEM Product Revision : %s\n", GET_ADDR(info.OemProductRevPtr, base)); unsigned long capabilities = (unsigned long) (*(info.Capabilities)); printf("Capabilities: 0x%x\n",capabilities); if((capabilities & BIT(0)) == 0) printf("\tDAC is fixed width, with 6 bits per primary color\n"); else printf("\tDAC width is switchable to 8 bits per primary color\n"); if((capabilities & BIT(1)) == 0) printf("\tController is VGA compatible\n"); else printf("\tController is not VGA compatible\n"); if((capabilities & BIT(2)) == 0) printf("\tNormal RAMDAC operation\n"); else printf("\tRAMDAC operation: Blank bit in Function 09h\n"); short* modes = GET_ADDR(info.VideoModePtr, base); size_t nummodes=0; printf("Supported modes:\n"); while(*modes != -1) { nummodes++; printf("Mode number %3d : 0x%X\n", nummodes,*modes); modes++; } if(nummodes == 0) printf("No modes supported\n"); return 0; }
/*********************************************************************//** * @brief c_entry: Main ADC program body * @param[in] None * @return None **********************************************************************/ void c_entry(void) { uint32_t i; volatile uint16_t *ip; uint32_t NorFlashAdr; /* Initialize debug via UART0 * – 115200bps * – 8 data bit * – No parity * – 1 stop bit * – No flow control */ debug_frmwrk_init(); // print welcome screen print_menu(); _DBG_("Init NOR Flash..."); NORFLASHInit(); _DBG_("Read NOR Flash ID..."); if ( NORFLASHCheckID() == FALSE ) { _DBG_("Error in reading NOR Flash ID, testing terminated!"); while ( 1 ); /* Fatal error */ } _DBG_("Erase entire NOR Flash..."); NORFLASHErase(); /* Chip erase */ /* Write to flash with pattern 0xAA55 and 0xA55A */ NorFlashAdr = NOR_FLASH_BASE; _DBG_("Write a block of 2K data to NOR Flash..."); for ( i = 0; i < NORFLASH_RW_PAGE_SIZE/2; i++ ) { NORFLASHWriteWord( NorFlashAdr, 0xAA55 ); NorFlashAdr++; NORFLASHWriteWord( NorFlashAdr, 0xA55A ); NorFlashAdr++; } /* Verify */ _DBG_("Verify data..."); NorFlashAdr = NOR_FLASH_BASE; for ( i = 0; i < NORFLASH_RW_PAGE_SIZE/2; i+=2 ) { ip = GET_ADDR(i); if ( (*ip & 0xFFFF) != 0xAA55 ) { _DBG_("Verifying fail, testing terminated!"); while ( 1 ); /* Fatal error */ } ip = GET_ADDR(i+1); if ( (*ip & 0xFFFF) != 0xA55A ) { _DBG_("Verifying fail, testing terminated!"); while ( 1 ); /* Fatal error */ } } // terminated _DBG_("Verifying complete! Testing terminated!"); while (1); }
static PyObject * p_findalldevs (PyObject *self, PyObject *args) { char errbuf[PCAP_ERRBUF_SIZE]; pcap_if_t * devs; int r = pcap_findalldevs(&devs, errbuf); if (r) { // Hopefully this copies errbuf... it must, right? PyErr_SetString(PyExc_RuntimeError, errbuf); return NULL; } PyObject * pdevs = PyList_New(0); for (pcap_if_t * d = devs; d != NULL; d = d->next) { PyObject * addrs = PyList_New(0); for (pcap_addr_t * a = d->addresses; a != NULL; a = a->next) { if (a->addr == NULL) { // No idea what to do with this entry! continue; } if (a->addr->sa_family == AF_INET) { // Assume all members for this entry are AF_INET... PyObject * e1 = a->addr ? Py_BuildValue("i", ((sockaddr_in*)a->addr)->sin_addr.s_addr) : none_ref(); PyObject * e2 = a->netmask ? Py_BuildValue("i", ((sockaddr_in*)a->netmask)->sin_addr.s_addr) : none_ref(); PyObject * e3 = a->broadaddr ? Py_BuildValue("i", ((sockaddr_in*)a->broadaddr)->sin_addr.s_addr) : none_ref(); PyObject * e4 = a->dstaddr ? Py_BuildValue("i", ((sockaddr_in*)a->dstaddr)->sin_addr.s_addr) : none_ref(); PyObject * addr_entry = Py_BuildValue("sNNNN", "AF_INET", e1, e2, e3, e4); PyList_Append(addrs, addr_entry); Py_DECREF(addr_entry); } #ifdef IPPROTO_IPV6 else if (a->addr->sa_family == AF_INET6) { #define GET_INET6(__f) (__f ? Py_BuildValue("s#", ((sockaddr_in6*)a->addr)->sin6_addr.s6_addr, 16) : none_ref()) PyObject * addr_entry = Py_BuildValue("sNNNN", "AF_INET6", GET_INET6(a->addr), GET_INET6(a->netmask), GET_INET6(a->broadaddr), GET_INET6(a->dstaddr)); PyList_Append(addrs, addr_entry); Py_DECREF(addr_entry); } #endif #ifdef AF_LINK_SOCKETS else if (a->addr->sa_family == AF_LINK) { #define GET_ADDR(__f) a->__f ? (((sockaddr_dl*)a->__f)->sdl_data + ((sockaddr_dl*)a->__f)->sdl_nlen) : "", a->__f ? ((sockaddr_dl*)a->__f)->sdl_alen : 0 PyObject * epo = Py_BuildValue("ss#", "ethernet", GET_ADDR(addr)); PyList_Append(addrs, epo); Py_DECREF(epo); PyObject * addr_entry = Py_BuildValue("ss#s#s#s#", "AF_LINK", GET_ADDR(addr), GET_ADDR(netmask), GET_ADDR(broadaddr), GET_ADDR(dstaddr)); #undef GET_ADDR PyList_Append(addrs, addr_entry); Py_DECREF(addr_entry); } #endif #ifdef AF_PACKET_SOCKETS else if (a->addr->sa_family == AF_PACKET) { struct sockaddr_ll * dll = (struct sockaddr_ll *)a->addr; if (dll->sll_hatype == ARPHRD_ETHER && dll->sll_halen == 6) { PyObject * epo = Py_BuildValue("ss#", "ethernet", dll->sll_addr, 6); PyList_Append(addrs, epo); Py_DECREF(epo); } } #endif else { //printf("address family: %i %i\n", a->addr->sa_family); } } #ifdef WIN32 { char mac[6]; if (macForName(d->name, mac)) { PyObject * epo = Py_BuildValue("ss#", "ethernet", mac, 6); PyList_Append(addrs, epo); Py_DECREF(epo); } } #endif PyObject * entry = Py_BuildValue("ssO", d->name, d->description, addrs); PyList_Append(pdevs, entry); Py_DECREF(entry); } pcap_freealldevs(devs); return pdevs; }
/* Parse user command */ int parse_cmd(uint8_t *buf, size_t *len) { char cmd_buf[MAX_SIZE] = ""; /* For storing command */ char split[8] = " "; /* Split characters for parsing command */ char *para; /* Point to parameters in command */ /* Initialize variables */ print_prefix(); fgets(cmd_buf, MAX_SIZE, stdin); /* Repeat? */ if ('\n' == cmd_buf[0]) /* Repeat last command */ strcpy(cmd_buf, last_cmd); else /* Just store the command */ strcpy(last_cmd, cmd_buf); /* Move the point to the command */ para = strtok(cmd_buf, split); if (!para) return CMD_ERR; /* Help */ if (!compare_cmd(para, "help")) return CMD_HELP; /* Continue */ else if (!compare_cmd(para, "c") || !compare_cmd(para, "continue")) return CMD_CONTINUE; /* Single step */ else if (!compare_cmd(para, "s") || !compare_cmd(para, "step")) return CMD_SINGLE_STEP; /* Quit */ else if (!compare_cmd(para, "q") || !compare_cmd(para, "quit")) return CMD_QUIT; /* Detach */ else if (!compare_cmd(para, "detach")) return CMD_DETACH; /* Set breakpoint */ else if (!compare_cmd(para, "b") || !compare_cmd(para, "bp") || !compare_cmd(para, "breakpoint")) { GET_ADDR(); return CMD_BREAKPOINT; /* Disassembly */ } else if (!compare_cmd(para, "disas") || !compare_cmd(para, "disass") || !compare_cmd(para, "disassembly")) { GET_ADDR(); return CMD_DISAS; /* Disassembly single instruction */ } else if (!compare_cmd(para, "ds") || !compare_cmd(para, "disas_s") || !compare_cmd(para, "disas_single") || !compare_cmd(para, "disassembly_single")) { GET_ADDR(); return CMD_DISAS_SINGLE; /* Peek memory or register */ } else if (!compare_cmd(para, "x") || !compare_cmd(para, "peek")) { char *tmp; peek_t *peek; if (*len < sizeof(peek_t)) { printf("Memory is not enough\n"); return CMD_ERR; } /* Initialize viables */ peek = (peek_t *)buf; memset(peek, 0, sizeof(peek_t)); /* Make tmp point to the first character after command */ if ('x' == *para) tmp = para + 1; else tmp = para + strlen("peek"); /* para -> "peekABCD..." * ^ * tmp ---------| */ /* para -> parameters */ para = strtok(NULL, split); if (NULL == para) { printf("Lack parameters.\n"); return CMD_ERR; } if ('/' == *tmp) { tmp++; if (isdigit(*tmp)) peek->len = strtoul(tmp, NULL, 0); tmp = para - 1; while ((*tmp != '/') && !isalpha(*tmp)) tmp--; if (*tmp != '/') peek->format = *tmp; else { printf("Incorrect format. See help.\n"); return CMD_ERR; } } else peek->format = 'x'; if ('$' == *para) { /* Rigster */ strncpy(peek->reg, para, min(sizeof(peek->reg) - 1, strlen(para))); return CMD_PEEK_REG; } else { /* Memory */ if (0 == (peek->addr = strtoul(para, NULL, 16))) { printf("Invalid address.\n"); return CMD_ERR; } return CMD_PEEK_MEM; } return CMD_ERR; /* Poke, Change the value of memory or rigester */ } else if (!compare_cmd(para, "poke") || !compare_cmd(para, "set")) { int user_cmd; poke_t *poke; if (*len < sizeof(peek_t)) { printf("Memory is not enough.\n"); return CMD_ERR; } poke = (poke_t *)buf; memset(poke, 0, sizeof(poke_t)); strcpy(split, " ="); para = strtok(NULL, split); if (!para) return CMD_ERR; if (isdigit(*para)) { /* Memory */ if (0 == (poke->addr = strtoul(para, NULL, 0))) { printf("Invalid address.\n"); return CMD_ERR; } user_cmd = CMD_POKE_MEM; } else if ('$' == *para) { /* Rigester */ strncpy(poke->reg, para, sizeof(poke->reg)-1); user_cmd = CMD_POKE_REG; } else { printf("Invalid parameters. See help.\n"); return CMD_ERR; } /* Get value */ para = strtok(NULL, split); if (!para) { printf("Lack value.\n"); return CMD_ERR; } if (0 == (poke->value = strtoul(para, NULL, 0))) { printf("Invalid value.\n"); return CMD_ERR; } return user_cmd; /* Set Shellcode */ } else if (0 == compare_cmd(para, "shellcode")) { return CMD_SET_SHELLCODE; /* Inject shellcode */ } else if (0 == compare_cmd(para, "inject")) { GET_ADDR(); return CMD_INJECT_SHELLCODE; } return CMD_UNSUPPORTED; }
MSG_ERR_T msgi_copy_to_sbp(int buf_idx, void *data,int sizeb) { volatile msgi_sbp_meta_t *local_meta_ptr = NULL; volatile long local_buffer; unsigned char *p; int bcount; int index; int i; int level = 3; MSG_DBG(level, MESSAGE, "In msgmi_copy_to_sbp()"); local_meta_ptr = (msgi_sbp_meta_t *) (uintptr_t)msgi_sbp_meta[local_rank][buf_idx]; local_buffer = msgi_sbp[local_rank][buf_idx]; MSG_DBG(level, MESSAGE, "(before)producer = %d", local_meta_ptr->producer); if(sizeb > block_size) // now block size = 16KB { p = (unsigned char *)data; //block count bcount = msgi_count_blocks(sizeb); MSG_DBG(level, MESSAGE, "bcount = %d", bcount); //example: data_size = 120K, block_size = 16K, buffer_size = 64K // bcount = 8, for entry[0-6] is 16K and entry[7] is 120-(8-1)*16K = 8K //The for loop is handling the entry[0-6] for(i=0;i<(bcount-1);i++) { index = (local_meta_ptr->producer + 1) % MSGI_MAX_SBP_BLOCKS_PER_BUFFER; //when the producer is faster than consumer while(index == local_meta_ptr->consumer){} MSG_DBG(level, MESSAGE, "addr = %ld", (long)GET_ADDR(local_buffer, local_meta_ptr->producer, block_size)); memcpy(GET_ADDR(local_buffer,local_meta_ptr->producer,block_size), p, block_size); local_meta_ptr->producer = index; p += block_size; } //handle the remain data, e.g. entry[7] index = (local_meta_ptr->producer + 1) % MSGI_MAX_SBP_BLOCKS_PER_BUFFER; while(index == local_meta_ptr->consumer){} MSG_DBG(level, MESSAGE, "addr = %ld", (long)GET_ADDR(local_buffer, local_meta_ptr->producer, block_size)); memcpy(GET_ADDR(local_buffer,local_meta_ptr->producer,block_size), p,sizeb - (bcount - 1)* block_size); local_meta_ptr->producer = index; //mark the entry to BUSY local_meta_ptr->control_flag = BUSY; } else { index = (local_meta_ptr->producer + 1) % MSGI_MAX_SBP_BLOCKS_PER_BUFFER; //block is full while(index == local_meta_ptr->consumer){} MSG_DBG(level, MESSAGE, "addr = %ld", (long)GET_ADDR(local_buffer, local_meta_ptr->producer, block_size)); memcpy(GET_ADDR(local_buffer,local_meta_ptr->producer,block_size),data,sizeb); local_meta_ptr->producer = index; //mark the entry to BUSY local_meta_ptr->control_flag = BUSY; } MSG_DBG(level, MESSAGE, "(after)producer = %d", local_meta_ptr->producer); MSG_DBG(level, MESSAGE, "Leaving msgmi_copy_to_shm() ..."); return MSG_SUCCESS; }
MSG_ERR_T msgi_copy_from_sbp(int src_rank,int buf_idx, void *data,int sizeb) { volatile msgi_sbp_meta_t *remote_meta_ptr = NULL; volatile long remote_buffer; volatile unsigned char *p; volatile int index; int bcount; int i; int level = 3; MSG_DBG(level, MESSAGE, "In msgmi_copy_from_sbp()"); remote_meta_ptr = (msgi_sbp_meta_t *)(uintptr_t)msgi_sbp_meta[src_rank][buf_idx]; remote_buffer = msgi_sbp[src_rank][buf_idx]; MSG_DBG(level, MESSAGE, "(before)consumer = %d", remote_meta_ptr->consumer); if(sizeb > block_size) // now block size = 16KB { p = (unsigned char *)data; bcount = msgi_count_blocks(sizeb); MSG_DBG(level, MESSAGE, "bcount = %d", bcount); for(i=0;i<(bcount-1);i++) { // Check if the shared memory queue is not empty while(remote_meta_ptr->consumer == remote_meta_ptr->producer){} memcpy((void *)p, GET_ADDR(remote_buffer,remote_meta_ptr->consumer,block_size), block_size); index = (remote_meta_ptr->consumer + 1) % MSGI_MAX_SBP_BLOCKS_PER_BUFFER; remote_meta_ptr->consumer = index; p += block_size; } // Check if the shared memory queue is not empty while(remote_meta_ptr->consumer == remote_meta_ptr->producer){} memcpy((void *)p, GET_ADDR(remote_buffer,remote_meta_ptr->consumer,block_size), sizeb - (bcount - 1) * block_size); index = (remote_meta_ptr->consumer + 1) % MSGI_MAX_SBP_BLOCKS_PER_BUFFER; remote_meta_ptr->consumer = index; //mark the entry to FREE remote_meta_ptr->control_flag = FREE; } else { //Check if the shared memory queue is not empty while(remote_meta_ptr->consumer == remote_meta_ptr->producer){} memcpy(data,GET_ADDR(remote_buffer,remote_meta_ptr->consumer,block_size),sizeb); index = (remote_meta_ptr->consumer + 1) % MSGI_MAX_SBP_BLOCKS_PER_BUFFER; remote_meta_ptr->consumer = index; //mark the entry to FREE remote_meta_ptr->control_flag = FREE; } MSG_DBG(level, MESSAGE, "(after)consumer = %d", remote_meta_ptr->consumer); MSG_DBG(level, MESSAGE, "Leaving msgmi_copy_from_sbp() ..."); return MSG_SUCCESS; }