Beispiel #1
0
int _sdt_enable(void *arg, dtrace_id_t id, void *parg)
{
	sdt_probe_t	*sdp = parg;

	/*
	 * Ensure that we have a reference to the module.
	 */
	if (!try_module_get(sdp->sdp_module))
		return -EAGAIN;

	/*
	 * If at least one other enabled probe exists for this module, drop the
	 * reference we took above, because we only need one to prevent the
	 * module from being unloaded.
	 */
	PDATA(sdp->sdp_module)->sdt_enabled++;
	if (PDATA(sdp->sdp_module)->sdt_enabled > 1)
		module_put(sdp->sdp_module);

	while (sdp != NULL) {
		sdt_enable_arch(sdp, id, arg);
		sdp = sdp->sdp_next;
	}

	return 0;
}
Beispiel #2
0
static void usbasp_close(PROGRAMMER * pgm)
{
  if (verbose > 2)
    fprintf(stderr, "%s: usbasp_close()\n", progname);

  if (PDATA(pgm)->usbhandle!=NULL) {
    unsigned char temp[4];
    memset(temp, 0, sizeof(temp));

    if (PDATA(pgm)->use_tpi) {
        usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_DISCONNECT, temp, temp, sizeof(temp));
    } else {
        usbasp_transmit(pgm, 1, USBASP_FUNC_DISCONNECT, temp, temp, sizeof(temp));
    }

#ifdef USE_LIBUSB_1_0
    libusb_close(PDATA(pgm)->usbhandle);
#else
    usb_close(PDATA(pgm)->usbhandle);
#endif
  }
#ifdef USE_LIBUSB_1_0
  libusb_exit(ctx);
#else
  /* nothing for usb 0.1 ? */
#endif
}
Beispiel #3
0
static void usbasp_close(PROGRAMMER * pgm)
{
printf("done.");
  if (PDATA(pgm)->usbhandle!=NULL) {
    unsigned char temp[4];
    memset(temp, 0, sizeof(temp));

    if (PDATA(pgm)->use_tpi) {
        usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_DISCONNECT, temp, temp, sizeof(temp));
    } else {
        usbasp_transmit(pgm, 1, USBASP_FUNC_DISCONNECT, temp, temp, sizeof(temp));
    }

#ifdef USE_usb_1_0
    usb_close(PDATA(pgm)->usbhandle);
#else
    usb_close(PDATA(pgm)->usbhandle);
#endif
  }
#ifdef USE_usb_1_0
  usb_exit(ctx);
#else
  /* nothing for usb 0.1 ? */
#endif
}
static void
_dxf_DRAW_MARKER (tdmInteractor I)
{
  DEFDATA(I,CursorData) ;	
  long i, mx, my ;

  ENTRY(("_dxf_DRAW_MARKER(0x%x)", I));

  for (i = 0 ; i < PDATA(iMark) ; i++) 
    {
      PDATA(pXmark)[i] = PDATA(Xmark)[i] ;
      PDATA(pYmark)[i] = PDATA(Ymark)[i] ;
    }

  PDATA(piMark) = PDATA(iMark) ;
  
  cpack(0xffffffff) ;
  for (i = 0 ; i < PDATA(iMark) ; i++)
    {
      /* round marker to long for future lrectwrite() erasure */
      mx = (long)(PDATA(Xmark[i])+0.5) ;
      my = (long)(PDATA(Ymark[i])+0.5) ;
      
      /* draw it */
      if (!CLIPPED(mx,my))
	  recti (mx-1, my-1, mx+1, my+1) ;
    }

  EXIT((""));
}
Beispiel #5
0
static int buspirate_program_enable(struct programmer_t *pgm, AVRPART * p)
{
	unsigned char cmd[4];
	unsigned char res[4];

	if (pgm->flag & BP_FLAG_IN_BINMODE) {
		/* Clear configured reset pin(s): CS and/or AUX and/or AUX2 */
		PDATA(pgm)->current_peripherals_config &= ~PDATA(pgm)->reset;
		buspirate_expect_bin_byte(pgm, PDATA(pgm)->current_peripherals_config, 0x01);
	}
	else
		buspirate_expect(pgm, "{\n", "CS ENABLED", 1);

	if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
		fprintf(stderr,
			"program enable instruction not defined for part \"%s\"\n",
			p->desc);
		return -1;
	}

	memset(cmd, 0, sizeof(cmd));
	avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd);
	pgm->cmd(pgm, cmd, res);

	if (res[2] != cmd[1])
		return -2;

	return 0;
}
Beispiel #6
0
/*
 * wrapper for usb_control_msg call
 */
static int usbasp_transmit(PROGRAMMER * pgm,
			   unsigned char receive, unsigned char functionid,
			   unsigned char send[4], unsigned char * buffer, int buffersize)
{
  int nbytes;
#ifdef USE_LIBUSB_1_0
  nbytes = libusb_control_transfer(PDATA(pgm)->usbhandle,
				   (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | (receive << 7)) & 0xff,
				   functionid & 0xff, 
				   ((send[1] << 8) | send[0]) & 0xffff, 
				   ((send[3] << 8) | send[2]) & 0xffff, 
				   (char *)buffer, 
				   buffersize & 0xffff,
				   5000);
  if(nbytes < 0){
    fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes)));
    return -1;
  }
#else
  nbytes = usb_control_msg(PDATA(pgm)->usbhandle,
			   USB_TYPE_VENDOR | USB_RECIP_DEVICE | (receive << 7),
			   functionid,
			   (send[1] << 8) | send[0],
			   (send[3] << 8) | send[2],
			   (char *)buffer, buffersize,
			   5000);
  if(nbytes < 0){
    fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
    return -1;
  }
#endif
  return nbytes;
}
Beispiel #7
0
static int
buspirate_verifyconfig(struct programmer_t *pgm)
{
	/* Default reset pin is CS */
	if (PDATA(pgm)->reset == 0x00)
		PDATA(pgm)->reset |= BP_RESET_CS;

	if ((PDATA(pgm)->reset != BP_RESET_CS) && buspirate_uses_ascii(pgm)) {
		fprintf(stderr, "BusPirate: RESET pin other than CS is not supported in ASCII mode\n");
		return -1;
	}

	if (( (pgm->flag & BP_FLAG_XPARM_SPIFREQ) ||
	(pgm->flag & BP_FLAG_XPARM_RAWFREQ) ) && buspirate_uses_ascii(pgm)) {
		fprintf(stderr, "BusPirate: SPI speed selection is not supported in ASCII mode\n");
		return -1;
	}

	if ((pgm->flag & BP_FLAG_XPARM_CPUFREQ) && !buspirate_uses_ascii(pgm)) {
		fprintf(stderr, "BusPirate: Setting cpufreq is only supported in ASCII mode\n");
		return -1;
	}

	return 0;
}
Beispiel #8
0
static int buspirate_start_spi_mode_bin(struct programmer_t *pgm)
{
	char buf[20] = { '\0' };

	/* == Switch to binmode - send 20x '\0' == */
	buspirate_send_bin(pgm, buf, sizeof(buf));

	/* Expecting 'BBIOx' reply */
	memset(buf, 0, sizeof(buf));
	buspirate_recv_bin(pgm, buf, 5);
	if (sscanf(buf, "BBIO%d", &PDATA(pgm)->binmode_version) != 1) {
		fprintf(stderr, "Binary mode not confirmed: '%s'\n", buf);
		buspirate_reset_from_binmode(pgm);
		return -1;
	}
	if (verbose)
		fprintf(stderr, "BusPirate binmode version: %d\n",
			PDATA(pgm)->binmode_version);

	pgm->flag |= BP_FLAG_IN_BINMODE;

	/* == Enter SPI mode == */
	buf[0] = 0x01;	/* Enter raw SPI mode */
	buspirate_send_bin(pgm, buf, 1);
	memset(buf, 0, sizeof(buf));
	buspirate_recv_bin(pgm, buf, 4);
	if (sscanf(buf, "SPI%d", &PDATA(pgm)->bin_spi_version) != 1) {
		fprintf(stderr, "SPI mode not confirmed: '%s'\n", buf);
		buspirate_reset_from_binmode(pgm);
		return -1;
	}
	if (verbose)
		fprintf(stderr, "BusPirate SPI version: %d\n",
			PDATA(pgm)->bin_spi_version);

	/* 0b0100wxyz - Configure peripherals w=power, x=pull-ups/aux2, y=AUX, z=CS
	 * we want power (0x48) and all reset pins high. */
	PDATA(pgm)->current_peripherals_config  = 0x48;
	PDATA(pgm)->current_peripherals_config |= BP_RESET_CS;
	PDATA(pgm)->current_peripherals_config |= BP_RESET_AUX;
	if (buspirate_has_aux2(pgm))
		PDATA(pgm)->current_peripherals_config |= BP_RESET_AUX2;
	buspirate_expect_bin_byte(pgm, PDATA(pgm)->current_peripherals_config, 0x01);
	usleep(50000);	// sleep for 50ms after power up

	/* 01100xxx -  SPI speed
	 * xxx = 000=30kHz, 001=125kHz, 010=250kHz, 011=1MHz,
	 *       100=2MHz, 101=2.6MHz, 110=4MHz, 111=8MHz
	 * use 30kHz = 0x60 */
	buspirate_expect_bin_byte(pgm, 0x60 | PDATA(pgm)->spifreq, 0x01);

	/* 1000wxyz - SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample
	 * we want: 3.3V(1), idle low(0), data change on trailing edge (1),
	 *          sample in the middle of the pulse (0)
	 *       => 0b10001010 = 0x8a */
	buspirate_expect_bin_byte(pgm, 0x8A, 0x01);

	return 0;
}
Beispiel #9
0
/*
 * wrapper for usb_control_msg call
 */
static int usbasp_transmit(PROGRAMMER * pgm,
			   unsigned char receive, unsigned char functionid,
			   const unsigned char *send,
			   unsigned char *buffer, int buffersize)
{
  int nbytes;

  if (verbose > 3) {
    fprintf(stderr,
	    "%s: usbasp_transmit(\"%s\", 0x%02x, 0x%02x, 0x%02x, 0x%02x)\n",
	    progname,
	    usbasp_get_funcname(functionid), send[0], send[1], send[2], send[3]);
    if (!receive && buffersize > 0) {
      int i;
      fprintf(stderr, "%s => ", progbuf);
      for (i = 0; i < buffersize; i++)
	fprintf(stderr, "[%02x] ", buffer[i]);
      fprintf(stderr, "\n");
    }
  }

#ifdef USE_LIBUSB_1_0
  nbytes = libusb_control_transfer(PDATA(pgm)->usbhandle,
				   (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | (receive << 7)) & 0xff,
				   functionid & 0xff, 
				   ((send[1] << 8) | send[0]) & 0xffff, 
				   ((send[3] << 8) | send[2]) & 0xffff, 
				   (char *)buffer, 
				   buffersize & 0xffff,
				   5000);
  if(nbytes < 0){
    fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes)));
    return -1;
  }
#else
  nbytes = usb_control_msg(PDATA(pgm)->usbhandle,
			   USB_TYPE_VENDOR | USB_RECIP_DEVICE | (receive << 7),
			   functionid,
			   (send[1] << 8) | send[0],
			   (send[3] << 8) | send[2],
			   (char *)buffer, buffersize,
			   5000);
  if(nbytes < 0){
    fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
    return -1;
  }
#endif

  if (verbose > 3 && receive && nbytes > 0) {
    int i;
    fprintf(stderr, "%s<= ", progbuf);
    for (i = 0; i < nbytes; i++)
      fprintf(stderr, "[%02x] ", buffer[i]);
    fprintf(stderr, "\n");
  }

  return nbytes;
}
Beispiel #10
0
static int  pickit2_parseextparams(struct programmer_t * pgm, LISTID extparms)
{
    LNODEID ln;
    const char *extended_param;
    int rv = 0;

    for (ln = lfirst(extparms); ln; ln = lnext(ln))
    {
        extended_param = ldata(ln);

        if (strncmp(extended_param, "clockrate=", strlen("clockrate=")) == 0)
        {
            int clock_rate;
            if (sscanf(extended_param, "clockrate=%i", &clock_rate) != 1 || clock_rate <= 0)
            {
                avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid clockrate '%s'\n",
                                progname, extended_param);
                rv = -1;
                continue;
            }

            int clock_period = MIN(1000000 / clock_rate, 255);    // max period is 255
            clock_rate = (int)(1000000 / (clock_period + 5e-7));    // assume highest speed is 2MHz - should probably check this

            avrdude_message(MSG_NOTICE2, "%s: pickit2_parseextparms(): clockrate set to 0x%02x\n",
                                progname, clock_rate);
            PDATA(pgm)->clock_period = clock_period;

            continue;
        }

        if (strncmp(extended_param, "timeout=", strlen("timeout=")) == 0)
        {
            int timeout;
            if (sscanf(extended_param, "timeout=%i", &timeout) != 1 || timeout <= 0)
            {
                avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid timeout '%s'\n",
                                progname, extended_param);
                rv = -1;
                continue;
            }

            avrdude_message(MSG_NOTICE2, "%s: pickit2_parseextparms(): usb timeout set to 0x%02x\n",
                                progname, timeout);
            PDATA(pgm)->transaction_timeout = timeout;

            continue;
        }

        avrdude_message(MSG_INFO, "%s: pickit2_parseextparms(): invalid extended parameter '%s'\n",
                        progname, extended_param);
        rv = -1;
    }

    return rv;
}
Beispiel #11
0
static void pickit2_close(PROGRAMMER * pgm)
{
#if (defined(WIN32NATIVE) && defined(HAVE_LIBHID))
    CloseHandle(PDATA(pgm)->usb_handle);
    CloseHandle(PDATA(pgm)->read_event);
    CloseHandle(PDATA(pgm)->write_event);
#else
    usb_close(PDATA(pgm)->usb_handle);
#endif  // WIN32NATIVE
}
Beispiel #12
0
/* Interface - prog. */
static int usbasp_open(PROGRAMMER * pgm, char * port)
{

  /* usb_init will be done in usbOpenDevice */
  if (usbOpenDevice(&PDATA(pgm)->usbhandle, pgm->usbvid, pgm->usbvendor,
		  pgm->usbpid, pgm->usbproduct) != 0) {
    /* try alternatives */
    if(strcasecmp(ldata(lfirst(pgm->id)), "usbasp") == 0) {
    /* for id usbasp autodetect some variants */
      if(strcasecmp(port, "nibobee") == 0) {
        fprintf(stderr,
	        "%s: warning: Using \"-C usbasp -P nibobee\" is deprecated,"
	        "use \"-C nibobee\" instead.\n",
	        progname);
        if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_NIBOBEE_VID, "www.nicai-systems.com",
		        USBASP_NIBOBEE_PID, "NIBObee") != 0) {
          fprintf(stderr,
	          "%s: error: could not find USB device "
	          "\"NIBObee\" with vid=0x%x pid=0x%x\n",
	          progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID);
          return -1;
        }
        return 0;
      }
      /* check if device with old VID/PID is available */
      if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_OLD_VID, "www.fischl.de",
		             USBASP_OLD_PID, "USBasp") == 0) {
        /* found USBasp with old IDs */
        fprintf(stderr,
		"%s: Warning: Found USB device \"USBasp\" with "
	        "old VID/PID! Please update firmware of USBasp!\n",
	        progname);
	return 0;
      }
    /* original USBasp is specified in config file, so no need to check it again here */
    /* no alternative found => fall through to generic error message */
    }

    fprintf(stderr,
            "%s: error: could not find USB device with vid=0x%x pid=0x%x",
            progname, pgm->usbvid, pgm->usbpid);
    if (pgm->usbvendor[0] != 0) {
       fprintf(stderr, " vendor='%s'", pgm->usbvendor);
    }
    if (pgm->usbproduct[0] != 0) {
       fprintf(stderr, " product='%s'", pgm->usbproduct);
    }
    fprintf(stderr,"\n");
    return -1;
  }

  return 0;
}
Beispiel #13
0
static void pickit2_setup(PROGRAMMER * pgm)
{
    if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0)
    {
        avrdude_message(MSG_INFO, "%s: pickit2_setup(): Out of memory allocating private data\n",
                        progname);
        exit(1);
    }
    memset(pgm->cookie, 0, sizeof(struct pdata));

    PDATA(pgm)->transaction_timeout = 1500;    // default value, may be overridden with -x timeout=ms
    PDATA(pgm)->clock_period = 10;    // default value, may be overridden with -x clockrate=us or -B or -i
}
Beispiel #14
0
/* ====== Config / parameters handling functions ====== */
static int
buspirate_parseextparms(struct programmer_t *pgm, LISTID extparms)
{
	LNODEID ln;
	const char *extended_param;
	char reset[10];
	char *preset = reset;	/* for strtok() */
	int spifreq;

	for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
    	extended_param = ldata(ln);
		if (strcmp(extended_param, "ascii") == 0) {
			pgm->flag |= BP_FLAG_XPARM_FORCE_ASCII;
			continue;
		}
		if (sscanf(extended_param, "spifreq=%d", &spifreq) == 1) {
			if (spifreq & (~0x07)) {
				fprintf(stderr, "BusPirate: spifreq must be between 0 and 7.\n");
				fprintf(stderr, "BusPirate: see BusPirate manual for details.\n");
				return -1;
			}
			PDATA(pgm)->spifreq = spifreq;
			pgm->flag |= BP_FLAG_XPARM_SPIFREQ;
			continue;
		}

		if (sscanf(extended_param, "reset=%s", reset) == 1) {
			char *resetpin;
			while ((resetpin = strtok(preset, ","))) {
				preset = NULL;	/* for subsequent strtok() calls */
				if (strcasecmp(resetpin, "cs") == 0)
					PDATA(pgm)->reset |= BP_RESET_CS;
				else if (strcasecmp(resetpin, "aux") == 0 || strcasecmp(reset, "aux1") == 0)
					PDATA(pgm)->reset |= BP_RESET_AUX;
				else if (strcasecmp(resetpin, "aux2") == 0)
					PDATA(pgm)->reset |= BP_RESET_AUX2;
				else {
					fprintf(stderr, "BusPirate: reset must be either CS or AUX.\n");
					return -1;
				}
			}
			pgm->flag |= BP_FLAG_XPARM_RESET;
			continue;
		}
	}

	return 0;
}
JNIEXPORT jstring JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_getText (JNIEnv *env, 
                                                    jobject thisObj)
{
    CHECK_PEER_RETURN(thisObj);
    int len;
    AwtTextComponent* c = PDATA(AwtTextComponent, thisObj);

    len = c->GetTextLength();
    jstring js;
    if (len == 0) {
        // Make java null string
        jchar *jc = new jchar[0];
	js = env->NewString(jc, 0);
	delete [] jc;
        ASSERT(!env->ExceptionCheck());
    } else {
#ifndef UNICODE
       char* buffer = new char[len+1];
       c->GetText(buffer, len+1);
       AwtTextComponent::RemoveCR(buffer);
       js = env->NewString(buffer, wcslen(buf)); // convert to unicode. right???
       delete[] buffer;
#else
       TCHAR *buffer = new TCHAR[len+1];
       c->GetText(buffer, len+1);
       AwtTextComponent::RemoveCR(buffer);
       js = TO_JSTRING((LPWSTR)buffer);
       //js = env->NewString(buffer, wcslen(buffer));
       delete[] buffer;
#endif
    }
    return js;
}
static MRESULT APIENTRY Destroy ( HWND Window, MESG, MPARAM1, MPARAM2 ) {

  /**************************************************************************
   * Find the instance data.                                                *
   **************************************************************************/

   PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

  /**************************************************************************
   * Discard the pointers.                                                  *
   **************************************************************************/

   WinDestroyPointer ( Data->MarginPtr ) ;
   WinDestroyPointer ( Data->TabstopPtr ) ;

  /**************************************************************************
   * Destroy the device context object for the window.                      *
   **************************************************************************/

   delete Data->pDevice ;

  /**************************************************************************
   * Release the instance data.                                             *
   **************************************************************************/

   free ( Data ) ;

  /**************************************************************************
   * We're done.                                                            *
   **************************************************************************/

   return ( MRFROMSHORT ( 0 ) ) ;
}
Beispiel #17
0
static void buspirate_powerup(struct programmer_t *pgm)
{
	if (pgm->flag & BP_FLAG_IN_BINMODE) {
		/* Powerup in BinMode is handled in SPI init */
		return;
	} else {
		if (buspirate_expect(pgm, "W\n", "Power supplies ON", 1)) {
			if (pgm->flag & BP_FLAG_XPARM_CPUFREQ) {
				char buf[25];
				int ok = 0;
				snprintf(buf, sizeof(buf), "%d\n", PDATA(pgm)->cpufreq);
				if (buspirate_expect(pgm, "g\n", "Frequency in KHz", 1)) {
					if (buspirate_expect(pgm, buf, "Duty cycle in %", 1)) {
						if (buspirate_expect(pgm, "50\n", "PWM active", 1)) {
							ok = 1;
						}
					}
				}
				if(!ok) {
					fprintf(stderr, "%s: warning: did not get a response to start PWM command.\n", progname);
				}
			}
			return;
		}
	}

	fprintf(stderr, "%s: warning: did not get a response to PowerUp command.\n", progname);
	fprintf(stderr, "%s: warning: Trying to continue anyway...\n", progname);
}
JNIEXPORT void JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_setText (JNIEnv *env, 
                                                    jobject thisObj,
                                                    jstring text)
{
    CHECK_PEER(thisObj);
    AwtTextComponent* c = PDATA(AwtTextComponent, thisObj);

    int length = env->GetStringLength(text);
#ifndef UNICODE
    TCHAR* buffer = new TCHAR[length * 2 + 1];
    buffer = TO_WSTRING(text);
#else
    WCHAR* buffer = new WCHAR[length  + 1];
    env->GetStringRegion(text, 0, length, (jchar*)buffer);
    buffer[length] = 0; //or it should be TEXT('\0') or L'\0'???
#endif

    buffer = AwtTextComponent::AddCR(buffer, length);
    c->SetText(buffer);
    /* Fix for TCK bug: setText() does not generate valueChangedEvent */
    if (env->IsInstanceOf(c->GetTarget(), WCachedIDs.java_awt_TextAreaClass)) {
        c->WmNotify(EN_CHANGE);
    }
    delete[] buffer;
}
Beispiel #19
0
void sdt_destroy(void *arg, dtrace_id_t id, void *parg)
{
	sdt_probe_t	*sdp = parg;

	PDATA(sdp->sdp_module)->sdt_probe_cnt--;

	while (sdp != NULL) {
		sdt_probe_t	*old = sdp, *last, *hash;
		int		ndx;

		ndx = SDT_ADDR2NDX(sdp->sdp_patchpoint);
		last = NULL;
		hash = sdt_probetab[ndx];

		while (hash != sdp) {
			ASSERT(hash != NULL);
			last = hash;
			hash = hash->sdp_hashnext;
		}

		if (last != NULL)
			last->sdp_hashnext = sdp->sdp_hashnext;
		else
			sdt_probetab[ndx] = sdp->sdp_hashnext;

		kfree(sdp->sdp_name);
		sdp = sdp->sdp_next;
		kfree(old);
	}
}
JNIEXPORT void JNICALL
Java_sun_awt_pocketpc_PPCTextFieldPeer_setEchoCharacter (JNIEnv *env, 
                                                         jobject self, jchar ch)
{
    CHECK_PEER(self);
    AwtComponent* c = PDATA(AwtComponent, self);
    c->SendMessage(EM_SETPASSWORDCHAR, ch);
}
Beispiel #21
0
static int
buspirate_verifyconfig(struct programmer_t *pgm)
{
	/* Default reset pin is CS */
	if (PDATA(pgm)->reset == 0x00)
		PDATA(pgm)->reset |= BP_RESET_CS;

	/* reset=AUX2 is only available on HW=v1a and FW>=3.0 */
	if ((PDATA(pgm)->reset & BP_RESET_AUX2) && !buspirate_has_aux2(pgm)) {
		fprintf(stderr, "BusPirate: Pin AUX2 is only available in binary mode\n");
		fprintf(stderr, "BusPirate: with hardware==v1a && firmware>=3.0\n");
		fprintf(stderr, "BusPirate: Your hardware==%s and firmware==%d.%d\n",
				PDATA(pgm)->hw_version, PDATA(pgm)->fw_version/100, PDATA(pgm)->fw_version%100);
		return -1;
	}

	if ((PDATA(pgm)->reset != BP_RESET_CS) && buspirate_uses_ascii(pgm)) {
		fprintf(stderr, "BusPirate: RESET pin other than CS is not supported in ASCII mode\n");
		return -1;
	}

	if ((pgm->flag & BP_FLAG_XPARM_SPIFREQ) && buspirate_uses_ascii(pgm)) {
		fprintf(stderr, "BusPirate: SPI speed selection is not supported in ASCII mode\n");
		return -1;
	}

	return 0;
}
JNIEXPORT void JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_enableEditing (JNIEnv *env, 
                                                          jobject thisObj,
                                                          jboolean editable)
{
    CHECK_PEER(thisObj);
    AwtTextComponent* c = PDATA(AwtTextComponent, thisObj);
    c->SendMessage(EM_SETREADONLY, !editable);
}
JNIEXPORT void JNICALL
Java_sun_awt_pocketpc_PPCChoicePeer_select( JNIEnv *env,
        jobject self,
        jint index )
{
    CHECK_PEER( self );
    AwtChoice *c = PDATA( AwtChoice, self );
    c->SendMessage( CB_SETCURSEL, index );
    return;
}
Beispiel #24
0
static void usbasp_close(PROGRAMMER * pgm)
{
  if (PDATA(pgm)->usbhandle!=NULL) {
    unsigned char temp[4];
    memset(temp, 0, sizeof(temp));

    if (PDATA(pgm)->use_tpi) {
        usbasp_transmit(pgm, 1, USBASP_FUNC_TPI_DISCONNECT, temp, temp, sizeof(temp));
    } else {
        usbasp_transmit(pgm, 1, USBASP_FUNC_DISCONNECT, temp, temp, sizeof(temp));
    }

#ifdef USE_LIBUSB_1_0
    libusb_close(PDATA(pgm)->usbhandle);
#else
    usb_close(PDATA(pgm)->usbhandle);
#endif
  }
}
JNIEXPORT jint JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_getSelectionEnd (JNIEnv *env, 
                                                            jobject self)
{
     CHECK_PEER_RETURN(self);
     AwtComponent* c = PDATA(AwtComponent, self);
     long end;
     c->SendMessage(EM_GETSEL, 0, (LPARAM)&end);
     return getJavaSelPos((AwtTextComponent*)c, end);    
}
Beispiel #26
0
/* Interface - prog. */
static int usbasp_open(PROGRAMMER * pgm, char * port)
{
#ifdef USE_LIBUSB_1_0
  libusb_init(&ctx);
#else
  usb_init();
#endif
  if(strcasecmp(port, "nibobee") == 0) {
    if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_NIBOBEE_VID, "www.nicai-systems.com",
		    USBASP_NIBOBEE_PID, "NIBObee") != 0) {
      fprintf(stderr,
	      "%s: error: could not find USB device "
	      "\"NIBObee\" with vid=0x%x pid=0x%x\n",
  	      progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID);
      return -1;
      
    }
  } else if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_SHARED_VID, "www.fischl.de",
		    USBASP_SHARED_PID, "USBasp") != 0) {

    /* check if device with old VID/PID is available */
    if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_OLD_VID, "www.fischl.de",
		      USBASP_OLD_PID, "USBasp") != 0) {

      /* no USBasp found */
      fprintf(stderr,
	      "%s: error: could not find USB device "
	      "\"USBasp\" with vid=0x%x pid=0x%x\n",
  	      progname, USBASP_SHARED_VID, USBASP_SHARED_PID);
      return -1;

    } else {

      /* found USBasp with old IDs */
      fprintf(stderr,
	      "%s: Warning: Found USB device \"USBasp\" with "
	      "old VID/PID! Please update firmware of USBasp!\n",
  	      progname);
    }
  }

  return 0;
}
Beispiel #27
0
unsigned logic_pinger_http_get_data(unsigned pkt, unsigned more_data)
{
  char buf[1024];
  char *dest = buf;
  if(more_data == 0)
  {
    dest+=sprintf((char*)dest,"var pinger_packfmt={");
    PLINK(dest, logic_pinger_setup[0], ip);
    PLINK(dest, logic_pinger_setup[0], period);
    PLINK(dest, logic_pinger_setup[0], timeout);
#ifdef DNS_MODULE
    PLINK(dest, logic_pinger_setup[0], hostname);
#endif
    PSIZE(dest, sizeof logic_pinger_setup[0]); // must be the last // size must be word-aligned!
    dest += sprintf(dest, "}; var pinger_data=[");
  }
  struct logic_pinger_setup_s *setup;
  for(;more_data<LOGIC_MAX_PINGER;)
  {
    setup = &logic_pinger_setup[more_data];
    *dest++ = '{';
    PDATA_IP(dest, (*setup), ip);
    PDATA(dest, (*setup), period);
    PDATA(dest, (*setup), timeout);
#ifdef DNS_MODULE
    PDATA_PASC_STR(dest, (*setup), hostname);
#endif
    --dest; // clear last PDATA-created comma
    *dest++ = '}';
    *dest++ = ',';
    ++more_data;
    if(dest - buf > sizeof buf - 128) break; // data buffer capacity used up to 80%
  }
  if(more_data == LOGIC_MAX_PINGER)
  {
    more_data = 0; // reset pumping
    --dest; // remove last comma
    *dest++ = ']';
    *dest++ = ';';
  }
  tcp_put_tx_body(pkt, (unsigned char*)buf, dest - buf);
  return more_data;
}
Beispiel #28
0
/* Interface - management */
static void buspirate_setup(struct programmer_t *pgm)
{
	/* Allocate private data */
	if ((pgm->cookie = calloc(1, sizeof(struct pdata))) == 0) {
		fprintf(stderr, "%s: buspirate_initpgm(): Out of memory allocating private data\n",
			progname);
		exit(1);
	}
	PDATA(pgm)->serial_recv_timeout = 100;
}
Beispiel #29
0
void _sdt_disable(void *arg, dtrace_id_t id, void *parg)
{
	sdt_probe_t	*sdp = parg;

	/*
	 * If we are disabling a probe, we know it was enabled, and therefore
	 * we know that we have a reference on the module to prevent it from
	 * being unloaded.  If we disable the last probe on the module, we can
	 * drop the reference.
	 */
	PDATA(sdp->sdp_module)->sdt_enabled--;
	if (PDATA(sdp->sdp_module)->sdt_enabled == 0)
		module_put(sdp->sdp_module);

	while (sdp != NULL) {
		sdt_disable_arch(sdp, id, arg);
		sdp = sdp->sdp_next;
	}
}
JNIEXPORT jint JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_getSelectionStart (JNIEnv *env,
                                                              jobject thisObj)
{
    CHECK_PEER_RETURN(thisObj);
    AwtComponent* c = PDATA(AwtComponent, thisObj);
    long start;
    c->SendMessage(EM_GETSEL, (WPARAM)&start);
    return getJavaSelPos((AwtTextComponent*)c, start);

}