/** * e1000_acquire_swfw_sync_i210 - Acquire SW/FW semaphore * @hw: pointer to the HW structure * @mask: specifies which semaphore to acquire * * Acquire the SW/FW semaphore to access the PHY or NVM. The mask * will also specify which port we're acquiring the lock for. **/ s32 e1000_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask) { u32 swfw_sync; u32 swmask = mask; u32 fwmask = mask << 16; s32 ret_val = E1000_SUCCESS; s32 i = 0, timeout = 200; /* FIXME: find real value to use here */ DEBUGFUNC("e1000_acquire_swfw_sync_i210"); while (i < timeout) { if (e1000_get_hw_semaphore_i210(hw)) { ret_val = -E1000_ERR_SWFW_SYNC; goto out; } swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC); if (!(swfw_sync & fwmask)) break; /* * Firmware currently using resource (fwmask) */ e1000_put_hw_semaphore_i210(hw); msec_delay_irq(5); i++; } if (i == timeout) { DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n"); ret_val = -E1000_ERR_SWFW_SYNC; goto out; } swfw_sync |= swmask; E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync); e1000_put_hw_semaphore_i210(hw); out: return ret_val; }
static void gadget_border_highlight(Widget w) { DEBUGOUT(_LtDebug(__FILE__, w, "gadget_border_highlight\n")); /* with zero width, we don't need this... */ if (G_HighlightThickness(w) == 0) { return; } _XmDrawHighlight(XtDisplayOfObject(w), XtWindowOfObject(w), XmParentHighlightGC(w), XtX(w), XtY(w), XtWidth(w), XtHeight(w), G_HighlightThickness(w), LineSolid); G_Highlighted(w) = True; G_HighlightDrawn(w) = True; }
static void drop_timer(XtPointer cd, XtIntervalId *id) { Widget dt = (Widget)cd; Atom select; DEBUGOUT(_LtDebug(__FILE__, dt, "%s:drop_timer(%d)\n", __FILE__, __LINE__)); if (DT_NumDropTransferLists(dt)) { entry_transfer(dt, 0); } else { select = DC_ICCHandle(DT_DragContext(dt)); terminate_transfer(dt, &select); } }
int lua_debugpcall(lua_State *l, char *message, int a, int b, int c) { lua_list *l2 = lua_listfromstate(l); int ret; #ifdef LUA_DEBUGSOCKET DEBUGOUT("%s: %s\n", l2->name->content, message); #endif #ifdef LUA_PROFILE ACCOUNTING_START(l2); #endif ret = lua_pcall(l, a, b, c); #ifdef LUA_PROFILE ACCOUNTING_STOP(l2); #endif return ret; }
/* Slave receive in interrupt mode */ static void readI2CSlave(void) { ErrorCode_t error_code; /* Setup receive buffer, receive buffer size, and receive callback */ paramRX.num_bytes_rec = 2; /* Address and single byte */ paramRX.buffer_ptr_rec = &recvBuff[0]; paramRX.func_pt = cbRXI2CComplete; /* Clear error code */ RXintErrCode = -1; /* Function is non-blocking */ error_code = LPC_I2CD_API->i2c_slave_receive_intr(i2cHandleSlave, ¶mRX, &resultRX); /* Completed without erors? */ if (error_code != LPC_OK) { DEBUGOUT("i2c_slave_receive_intr error code : %x\r\b", error_code); errorI2C(); } }
static Widget start_drop_transfer(Widget refWidget, ArgList args, Cardinal argCount) { Widget disp = XmGetXmDisplay(XtDisplay(refWidget)), dt; DEBUGOUT(_LtDebug(__FILE__, refWidget, "%s:start_drop_transfer(%d)\n", __FILE__, __LINE__)); dt = XtCreateWidget("drop_transfer", Display_DropTransferClass(disp), disp, args, argCount); /* refWidget had BETTER be a DC */ DT_DragContext(dt) = refWidget; DT_Timestamp(dt) = DC_DragFinishTime(refWidget); XtAppAddTimeOut(XtWidgetToApplicationContext(dt), 0, drop_timer, (XtPointer)dt); return dt; }
/* * cache (program local) the value of the drag window */ static void set_drag_window(Display *display, Window win) { DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:set_drag_window(%d)\n", __FILE__, __LINE__)); if (displayToDW == None) { displayToDW = XUniqueContext(); } if (XFindContext(display, DefaultRootWindow(display), displayToDW, (XPointer *)&win) == XCSUCCESS) { XDeleteContext(display, DefaultRootWindow(display), displayToDW); } XSaveContext(display, DefaultRootWindow(display), displayToDW, (XPointer)win); }
VOID GetSpeedAndDuplex(PADAPTER_STRUCT Adapter, PUINT16 Speed, PUINT16 Duplex) { UINT32 DeviceStatusReg; UINT16 PhyData; DEBUGFUNC("GetSpeedAndDuplex") if (Adapter->AdapterStopped) { *Speed = 0; *Duplex = 0; return; } if (Adapter->MacType >= MAC_LIVENGOOD) { DEBUGOUT("Livengood MAC\n"); DeviceStatusReg = E1000_READ_REG(Status); if (DeviceStatusReg & E1000_STATUS_SPEED_1000) { *Speed = SPEED_1000; DEBUGOUT(" 1000 Mbs\n"); } else if (DeviceStatusReg & E1000_STATUS_SPEED_100) { *Speed = SPEED_100; DEBUGOUT(" 100 Mbs\n"); } else { *Speed = SPEED_10; DEBUGOUT(" 10 Mbs\n"); } if (DeviceStatusReg & E1000_STATUS_FD) { *Duplex = FULL_DUPLEX; DEBUGOUT(" Full Duplex\r\n"); } else { *Duplex = HALF_DUPLEX; DEBUGOUT(" Half Duplex\r\n"); } } else { DEBUGOUT("Wiseman MAC - 1000 Mbs, Full Duplex\r\n"); *Speed = SPEED_1000; *Duplex = FULL_DUPLEX; } return; }
static void class_part_initialize(WidgetClass widget_class) { WidgetClass sc; DEBUGOUT(_LtDebug(__FILE__, NULL, "DropTransfer class part initialize\n")); _XmFastSubclassInit(widget_class, XmDROP_TRANSFER_BIT); sc = widget_class->core_class.superclass; if (DTC_StartTransferProc(widget_class) == XmInheritStartTransferProc) { DTC_StartTransferProc(widget_class) = DTC_StartTransferProc(sc); } if (DTC_AddTransferProc(widget_class) == XmInheritAddTransferProc) { DTC_AddTransferProc(widget_class) = DTC_AddTransferProc(sc); } }
/* * fetch the cached atoms table */ static XmDndAtomsTable get_atoms_table(Display *display) { XmDndAtomsTable tbl = NULL; DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_atoms_table(%d)\n", __FILE__, __LINE__)); if (displayToAtoms == (XContext)0) { displayToAtoms = XUniqueContext(); } if (XFindContext(display, DefaultRootWindow(display), displayToAtoms, (XPointer *)&tbl) != XCSUCCESS) { return NULL; } return tbl; }
static XmDndAtomsTable create_default_atoms_table(Display *display) { XmDndAtomsTable tbl; DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:create_default_atoms_table(%d)\n", __FILE__, __LINE__)); tbl = (XmDndAtomsTable) XtMalloc(sizeof(XmDndAtomsTableRec)); tbl->num_entries = 1; tbl->entries = (XmDndAtomsTableEntry) XtMalloc(sizeof(XmDndAtomsTableEntryRec)); tbl->entries->atom = XmInternAtom(display, _XA_MOTIF_ATOM_0, False); tbl->entries->time = CurrentTime; set_atoms_table(display, tbl); return tbl; }
/** * @brief Main routine for I2C example * @return Function should not exit */ void i2C_slave_Task (void *pvParameters) { uint8_t i; /* Test I2c slave */ while (1) { // DEBUGOUT(" matched @: %u\r\n",Chip_I2C_GetPendingInt(LPC_I2C0)); i = Chip_I2CS_ReadByte(LPC_I2C0); xSemaphoreTake( xI2cSemaphore, portMAX_DELAY ); // DEBUGOUT(" read value: 0x%x\r\n",i); DEBUGOUT(" I2C transaction complete\r\n"); } }
extern char * _XmStringSourceGetString(XmTextWidget w, XmTextPosition from, XmTextPosition to, Boolean want_wchar) { #if 1 _XmWarning((Widget)w, "_XmStringSourceGetString is not implemented yet."); return NULL; #else if (want_wchar) { DEBUGOUT(_LtDebug(__FILE__, NULL, "_XmStringSourceGetString: wide characters not implemented yet.\n")); return NULL; } return NULL; /* FIX ME */ #endif }
/* * I understand what it does, by why would you want to do it? */ extern void _XmDestroyMotifWindow(Display *dpy) { Atom dw; Window win; DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:_XmDestroyMotifWindow(%d)\n", __FILE__, __LINE__)); win = read_drag_window(dpy); if (win == None) { return; } dw = XmInternAtom(dpy, _XA_MOTIF_DRAG_WINDOW, False); XDeleteProperty(dpy, DefaultRootWindow(dpy), dw); XDestroyWindow(dpy, win); }
extern void _LTCreateSearchPath(void) { const char *XBMLANGPATH = getenv("XBMLANGPATH"); const char *XAPPLRESDIR = getenv("XAPPLRESDIR"); const char *HOME = _XmOSGetHomeDirName(); if (HOME == NULL) { HOME = ""; } if (XBMLANGPATH) { _search_path = XtNewString(XBMLANGPATH); } else if (XAPPLRESDIR) { _search_path = (char *)XtMalloc(strlen(XAPPLRESDIR_set_pattern) + strlen(XAPPLRESDIR) * 6 + strlen(HOME) * 2 + 1); sprintf(_search_path, XAPPLRESDIR_set_pattern, XAPPLRESDIR, XAPPLRESDIR, XAPPLRESDIR, XAPPLRESDIR, XAPPLRESDIR, XAPPLRESDIR, HOME, HOME); } else { /* neither of them was set... */ _search_path = (char *)XtMalloc(strlen(nothing_set_pattern) + strlen(HOME) * 7 + 1); sprintf(_search_path, nothing_set_pattern, HOME, HOME, HOME, HOME, HOME, HOME, HOME); } DEBUGOUT(_LtDebug(__FILE__, NULL, "Using %s for search path\n", _search_path)); }
/* * called from DropSMgr's CreateInfo method. */ extern Cardinal _XmIndexToTargets(Widget shell, Cardinal t_index, Atom **targetsRtn) { Display *dpy = XtDisplay(shell); XmDndTargetsTable targets; DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:_XmIndexToTargets(%d)\n", __FILE__, __LINE__)); if ((targets = get_targets_table(dpy)) == NULL) { _XmInitTargetsTable(dpy); targets = get_targets_table(dpy); } if (t_index >= targets->num_entries) { if (!read_targets_table(dpy, targets)) { _XmInitTargetsTable(dpy); } targets = get_targets_table(dpy); } if (t_index >= targets->num_entries) { _XmWarning(shell, "Index out of range to _XmIndexToTargets. %i %i", t_index, targets->num_entries); *targetsRtn = NULL; return 0; } *targetsRtn = targets->entries[t_index].targets; return targets->entries[t_index].num_targets; }
JNIEXPORT jboolean JNICALL Java_com_st_microxplorer_plugins_projectmanager_model_ToolchainGenerator_generate( JNIEnv *env, jclass cls, jstring scratchFile ) { const char *ptr_str = (*env)->GetStringUTFChars(env, scratchFile, 0); int result = JNI_FALSE; char helper[PATH_MAX]; pid_t pid; int state; strcpy(helper, dataPath); strcat(helper, HELPER); DEBUGOUT("Called generate(%s)\n", ptr_str); DEBUGOUT(" forking...\n"); pid = vfork(); if (pid < 0) { perror(__FILE__ " fork failed: "); DEBUGOUT(" fork failed.\n"); } else if (pid == 0) { DEBUGOUT(" in child, calling helper (%s).\n", helper); execl(helper, helper, dataPath, ptr_str, NULL); perror(__FILE__ " helper exec failed: "); DEBUGOUT(" in child, exec failed.\n"); _exit(127); } else { DEBUGOUT(" in parent, waiting for child.\n"); wait(&state); DEBUGOUT(" in parent, child exited, return code=%d.\n", WEXITSTATUS(state)); if( WEXITSTATUS(state) == 0) { result = JNI_TRUE; } } /* cleanup */ (*env)->ReleaseStringUTFChars(env, scratchFile, ptr_str); return result; }
BYTE Mapper090::ReadLow( WORD addr ) { DEBUGOUT( "RD:%04X\n", addr ); switch( addr ) { case 0x5000: return sw_val?0x00:0xFF; case 0x5800: return (BYTE)(mul_val1*mul_val2); case 0x5801: return (BYTE)((mul_val1*mul_val2)>>8); case 0x5803: return key_val; } if( addr >= 0x6000 ) { return Mapper::ReadLow( addr ); } // return sw_val?0x00:0xFF; return (BYTE)(addr>>8); }
/*----------------------------------------------------------------------------- function: FE_ERR FEC_GetTuningParam( FE_device *handle, T_TuningParam *param) description: reads back frontend tuning params input: FE_device *handle output: T_TuningParam *param return: FE_ERR: error treatment -----------------------------------------------------------------------------*/ FE_ERR FEC_GetTuningParam(FE_Device *handle, T_TuningParam *param) { FEC_device *inthandle; U32 offset; if(handle==0 || param==0) return FE_WRONG_PARAM; inthandle=(FEC_device *)handle->internal_data; param->frequency= 1000*(inthandle->Demod.params.Frequency); param->qam.symbol_rate=1000*(inthandle->Demod.params.SymbolRate); switch(inthandle->Demod.params.Qam) { case QAM16: param->qam.modulation=QAM_16; break; case QAM32: param->qam.modulation=QAM_32; break; case QAM64: param->qam.modulation=QAM_64; break; case QAM128: param->qam.modulation=QAM_128; break; case QAM256: param->qam.modulation=QAM_256; break; default: return FE_WRONG_PARAM; } if(DEM_86668_GetCarrierOffset(inthandle, &offset)!=FeOk) return FE_I2C_ERR; DEBUGOUT(TOOL_Printf("Carrier Offset now at: %d Hz\n",offset)); return FE_OK; }
void Widget::MoveToBottom() { if (!mParent || !mSortable || !mParent->mCanSortChildren) return; ASSERT( !mParent->mChildren.empty() ); //if we're already at bottom, don't do the equations below if (mParent->mChildren.at(0) == this) return; sShort pos = mParent->Get(this); ASSERT(pos >= 0 && pos < mParent->mChildren.size()); mParent->mChildren.erase(mParent->mChildren.begin() + pos); mParent->mChildren.insert(mParent->mChildren.begin(), this); DEBUGOUT("Widget to bottom: " + mId); FlagRender(); }
/* * writes nent Atoms to the drag buffer */ static void write_atoms_to_drag_buffer(XmDndBufMgr bmgr, int n, Atom* atoms) { DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:write_atoms_to_drag_buffer(%d) - count %d\n", __FILE__, __LINE__, n)); if (sizeof(Atom) == sizeof(CARD32)) { _XmWriteDragBuffer(bmgr, False, (char*) atoms, sizeof(Atom) * n); } else { CARD32 out; int i; for (i = 0; i < n; i++) { out = atoms[i]; _XmWriteDragBuffer(bmgr, False, (char*) &out, sizeof(CARD32)); } } }
/* * catch window errors when fetching or setting the DRAG_WINDOW properties */ static int protect_handler(Display *display, XErrorEvent *event) { DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:protect_handler(%d)\n", __FILE__, __LINE__)); if (event->error_code == BadWindow && event->resourceid == errorWindow && event->serial >= firstProtectRequest) { bad_window = True; return 0; } if (oldErrorHandler == NULL) { return 0; } return (*oldErrorHandler) (display, event); }
static void destroy(Widget w) { Widget dc; Cardinal i; DEBUGOUT(_LtDebug(__FILE__, w, "DropTransfer destroy\n")); dc = XmGetDragContext(w, DT_Timestamp(w)); if (dc && DC_SourceIsExternal(dc)) { XtDestroyWidget(dc); } for (i = 0; i < DT_NumDropTransferLists(w); i++) { XtFree((char *)DT_DropTransferLists(w)[i].transfer_list); } XtFree((char *)DT_DropTransferLists(w)); }
ZrtpPacketHello::ZrtpPacketHello(uint8_t *data) { DEBUGOUT((fprintf(stdout, "Creating Hello packet from data\n"))); zrtpHeader = (zrtpPacketHeader_t *)&((HelloPacket_t *)data)->hdr; // the standard header helloHeader = (Hello_t *)&((HelloPacket_t *)data)->hello; uint32_t t = *((uint32_t*)&helloHeader->flags); uint32_t temp = ntohl(t); nHash = (temp & (0xf << 16)) >> 16; nCipher = (temp & (0xf << 12)) >> 12; nAuth = (temp & (0xf << 8)) >> 8; nPubkey = (temp & (0xf << 4)) >> 4; nSas = temp & 0xf; oHash = sizeof(Hello_t); oCipher = oHash + (nHash * ZRTP_WORD_SIZE); oAuth = oCipher + (nCipher * ZRTP_WORD_SIZE); oPubkey = oAuth + (nAuth * ZRTP_WORD_SIZE); oSas = oPubkey + (nPubkey * ZRTP_WORD_SIZE); oHmac = oSas + (nSas * ZRTP_WORD_SIZE); // offset to HMAC }
/***************************************************************************** * Private functions ****************************************************************************/ static SPIFI_HANDLE_T *initializeSpifi(void) { int idx; int devIdx; uint32_t memSize; SPIFI_HANDLE_T *pReturnVal; /* Initialize LPCSPIFILIB library, reset the interface */ spifiInit(LPC_SPIFI_BASE, true); /* register support for the family(s) we may want to work with (only 1 is required) */ spifiRegisterFamily(SPIFI_REG_FAMILY_SpansionS25FLP); spifiRegisterFamily(SPIFI_REG_FAMILY_SpansionS25FL1); spifiRegisterFamily(SPIFI_REG_FAMILY_MacronixMX25L); /* Return the number of families that are registered */ idx = spifiGetSuppFamilyCount(); /* Show all families that are registered */ for (devIdx = 0; devIdx < idx; ++devIdx) { DEBUGOUT("FAMILY: %s\r\n", spifiGetSuppFamilyName(devIdx)); } /* Get required memory for detected device, this may vary per device family */ memSize = spifiGetHandleMemSize(LPC_SPIFI_BASE); if (memSize == 0) { /* No device detected, error */ test_suiteError("spifiGetHandleMemSize", SPIFI_ERR_GEN); } /* Initialize and detect a device and get device context */ pReturnVal = spifiInitDevice(&lmem, sizeof(lmem), LPC_SPIFI_BASE, SPIFLASH_BASE_ADDRESS); if (pReturnVal == NULL) { test_suiteError("spifiInitDevice", SPIFI_ERR_GEN); } return pReturnVal; }
// .Say(entity, "msg", showbubble<true>, showinchat<true>) - Say the message. Last two parameters are optional, and default to 1. int entity_Say(lua_State* ls) { DEBUGOUT("entity_Say"); luaCountArgs(ls, 2); Entity* e = _getReferencedEntity(ls); int numArgs = lua_gettop(ls); string msg = lua_tostring(ls, 2); bool showbubble = (numArgs > 2) ? lua_toboolean(ls, 3) : true; bool showinchat = (numArgs > 3) ? lua_toboolean(ls, 4) : true; e->Say(msg, showbubble, showinchat); //Dispatch a say message MessageData md("ENTITY_SAY"); md.WriteUserdata("entity", e); md.WriteString("message", msg); messenger.Dispatch(md, NULL); return 0; }
void * serverThread(void * args) { Server * me = (Server *) args; //listen on the given port if(listen(me->socket, me->queueLen) == -1) { perror("listen"); servOff(me); return NULL; } //all clear, run the main loop function while(servStatus(me)) { DEBUGOUT("calling servLoop()"); servLoop(me); } delConnections(me); return NULL; }
/* Slave transmit in interrupt mode */ static void sendI2CSlave(void) { ErrorCode_t error_code; /* Send 1 byte based on master request */ paramRX.num_bytes_rec = 1; /* Address byte */ paramRX.buffer_ptr_rec = &recvBuff[0]; paramTX.num_bytes_send = 1; paramTX.buffer_ptr_send = &tranBuff[0]; paramTX.func_pt = cbTXI2CComplete; /* Clear error code */ TXintErrCode = -1; /* Function is non-blocking */ error_code = LPC_I2CD_API->i2c_slave_transmit_intr(i2cHandleSlave, ¶mTX, &resultTX); /* Completed without erors? */ if (error_code != LPC_OK) { DEBUGOUT("i2c_slave_transmit_intr error code : %x\r\b", error_code); errorI2C(); } }
/* * create the drag window */ static Window create_drag_window(Display *display) { Window win; XSetWindowAttributes attr; DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:create_drag_window(%d)\n", __FILE__, __LINE__)); attr.override_redirect = True; attr.event_mask = PropertyChangeMask; win = XCreateWindow(display, DefaultRootWindow(display), -100, -100, 10, 10, 0, 0, InputOnly, CopyFromParent, (CWOverrideRedirect | CWEventMask), &attr); XMapWindow(display, win); return win; }
static void secondary_object_create(Widget req, Widget new_w, ArgList args, Cardinal *num_args) { XmBaseClassExt *bce; Arg argl[1]; ArgList merged; DEBUGOUT(_LtDebug(__FILE__, new_w, "XmGadget secondary_object_create\n")); XtSetArg(argl[0], XmNlogicalParent, new_w); if (*num_args) { merged = XtMergeArgLists(args, *num_args, argl, XtNumber(argl)); bce = _XmGetBaseClassExtPtr(XtClass(new_w), XmQmotif); XtCreateWidget(XtName(new_w), (*bce)->secondaryObjectClass, XtParent(new_w) ? XtParent(new_w) : new_w, merged, *num_args + 1); XtFree((char *)merged); } else { bce = _XmGetBaseClassExtPtr(XtClass(new_w), XmQmotif); XtCreateWidget(XtName(new_w), (*bce)->secondaryObjectClass, XtParent(new_w) ? XtParent(new_w) : new_w, argl, 1); } }