static struct sk_buff *rmnet_usb_tx_fixup(struct usbnet *dev,
		struct sk_buff *skb, gfp_t flags)
{
	struct QMI_QOS_HDR_S	*qmih;

	if (test_bit(RMNET_MODE_QOS, &dev->data[0])) {
		qmih = (struct QMI_QOS_HDR_S *)
		skb_push(skb, sizeof(struct QMI_QOS_HDR_S));
		qmih->version = 1;
		qmih->flags = 0;
		qmih->flow_id = skb->mark;
	 }

	DBG1("[%s] Tx packet #%lu len=%d mark=0x%x\n",
	    dev->net->name, dev->net->stats.tx_packets, skb->len, skb->mark);

	return skb;
}
Example #2
0
int RVB::init(double p[], int n_args)
{
    float  outskip, inskip, rvb_time;

    outskip = p[0];
    inskip = p[1];
    m_dur = p[2];
    if (m_dur < 0)                      /* "dur" represents timend */
        m_dur = -m_dur - inskip;

	if (rtsetinput(inskip, this) == -1) { // no input
	  return(DONT_SCHEDULE);
	}

    insamps = (int)(m_dur * SR);
    m_amp = p[3];

    if (inputChannels() != 2)
		return die(name(), "Input must be stereo.");

	if (outputChannels() != 2)
		return die(name(), "Output must be stereo.");

    double Matrix[12][12];
   
    /* Get results of Minc setup calls (space, mikes_on, mikes_off, matrix) */
    if (get_rvb_setup_params(Dimensions, Matrix, &rvb_time) == -1)
       return die(name(), "You must call setup routine `space' first.");
    /* (perform some initialization that used to be in space.c) */
    int meanLength = MFP_samps(SR, Dimensions); // mean delay length for reverb
    get_lengths(meanLength);              /* sets up delay lengths */
    set_gains(rvb_time);                		/* sets gains for filters */
	set_random();                       /* sets up random variation of delays */
    set_allpass();
   
	wire_matrix(Matrix);

	_skip = (int) (SR / (float) resetval);
	
	if (rtsetoutput(outskip, m_dur + rvb_time, this) == -1)
		return DONT_SCHEDULE;
	DBG1(printf("nsamps = %d\n", nSamps()));
	return nSamps();
}
Example #3
0
int usb_read(usb_handle *h, void *_data, int len)
{
    unsigned char *data = (unsigned char*) _data;
    unsigned count = 0;
    struct usbdevfs_bulktransfer bulk;
    int n, retry;

    if(h->ep_in == 0) {
        return -1;
    }

    while(len > 0) {
        int xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len;

        bulk.ep = h->ep_in;
        bulk.len = xfer;
        bulk.data = data;
        bulk.timeout = 0;
        retry = 0;

        do{
           DBG("[ usb read %d fd = %d], fname=%s\n", xfer, h->desc, h->fname);
           n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
           DBG("[ usb read %d ] = %d, fname=%s, Retry %d \n", xfer, n, h->fname, retry);

           if( n < 0 ) {
            DBG1("ERROR: n = %d, errno = %d (%s)\n",n, errno, strerror(errno));
            if ( ++retry > MAX_RETRIES ) return -1;
            sleep( 1 );
           }
        }
        while( n < 0 );

        count += n;
        len -= n;
        data += n;

        if(n < xfer) {
            break;
        }
    }

    return count;
}
Example #4
0
void ps2_main(void){

    m_state = STA_WAIT_RESET;
    kbd_init();

    keymap_init();
    clear();

    //set key repeat speed;
    uint8_t gSpeed = eeprom_read_byte((uint8_t *)EEPROM_PS2_REPEAT_SPEED);
    if(gSpeed == 0xFF) gSpeed = 1;
    if(ps2_repeat_speed == PS2_REPEAT_SPEED_NONE){
    	ps2_repeat_speed = gSpeed;
    }else if(ps2_repeat_speed != gSpeed){
    	eeprom_write_byte((uint8_t *)EEPROM_PS2_REPEAT_SPEED, ps2_repeat_speed);
    }


    // init
    setKeyScanDriver(&driverKeyScanPs2);
    setUpdateDriver(&updatePs2);
    clearMatrix();

//    DEBUG_PRINT(("STARTING PS/2 KEYBOARD\n"));

    sei();
//    DBG1(0x90, 0, 0);
    for(;;){

        // 카운트 이내에 신호가 잡히지 않으면 이동;
        // 특별한 경우에만 발생하는 현상이다.
        if(INTERFACE == INTERFACE_PS2 && interfaceReady == false && interfaceCount++ > 1000){
            // move to usb
            INTERFACE = INTERFACE_USB;
            DBG1(0x99, 0, 0);
            break;
        }

        processRxPs2();
        processTxPs2();

    }
//    DBG1(0x9F, 0, 0);
}
Example #5
0
/**
 * Server routine
 */
static int serve(host_t *host, identification_t *server,
                 int times, tls_cache_t *cache)
{
    tls_socket_t *tls;
    int fd, cfd;

    fd = socket(AF_INET, SOCK_STREAM, 0);
    if (fd == -1)
    {
        DBG1(DBG_TLS, "opening socket failed: %s", strerror(errno));
        return 1;
    }
    if (bind(fd, host->get_sockaddr(host),
             *host->get_sockaddr_len(host)) == -1)
    {
        DBG1(DBG_TLS, "binding to %#H failed: %s", host, strerror(errno));
        close(fd);
        return 1;
    }
    if (listen(fd, 1) == -1)
    {
        DBG1(DBG_TLS, "listen to %#H failed: %m", host, strerror(errno));
        close(fd);
        return 1;
    }

    while (times == -1 || times-- > 0)
    {
        cfd = accept(fd, host->get_sockaddr(host), host->get_sockaddr_len(host));
        if (cfd == -1)
        {
            DBG1(DBG_TLS, "accept failed: %s", strerror(errno));
            close(fd);
            return 1;
        }
        DBG1(DBG_TLS, "%#H connected", host);

        tls = tls_socket_create(TRUE, server, NULL, cfd, cache, TLS_1_2, TRUE);
        if (!tls)
        {
            close(fd);
            return 1;
        }
        tls->splice(tls, 0, 1);
        DBG1(DBG_TLS, "%#H disconnected", host);
        tls->destroy(tls);
    }
    close(fd);

    return 0;
}
Example #6
0
void chunk_to_sequence(const chunk_t * const chunk, void *sequence,
					   const uint32_t typelen)
{
	const uint32_t seqlenmax = typelen - sizeof(uint32_t);
	sequence_type *seq = sequence;

	memset(sequence, 0, typelen);
	if (chunk->len > seqlenmax)
	{
		DBG1(DBG_LIB, "chunk too large to fit into sequence %d > %d, limiting"
			 " to %d bytes", chunk->len, seqlenmax, seqlenmax);
		seq->size = seqlenmax;
	}
	else
	{
		seq->size = chunk->len;
	}
	memcpy(seq->data, chunk->ptr, seq->size);
}
// 改变Mute状态
VOID MuteStatusChange(VOID)
{	
	DBG((">>MuteStatusChange()\n"));
	if(gSys.MuteFg)
	{
		gSys.MuteFg = FALSE;		
		UnMute();	
		DBG1(("4433\n"));
	}
	else
	{	
		gSys.MuteFg = TRUE;
		MuteOn(TRUE, TRUE);       
	}
#ifdef FUNC_DISP_EN
   	DispMute();
#endif	
	DBG(("<<MuteStatusChange()\n"));
}
Example #8
0
/**
 * Read a PT-TLS message, return header data
 */
bio_reader_t* pt_tls_read(tls_socket_t *tls, uint32_t *vendor,
						  uint32_t *type, uint32_t *identifier)
{
	bio_reader_t *reader;
	uint32_t len;
	uint8_t reserved;

	reader = read_tls(tls, PT_TLS_HEADER_LEN);
	if (!reader)
	{
		return NULL;
	}
	if (!reader->read_uint8(reader, &reserved) ||
		!reader->read_uint24(reader, vendor) ||
		!reader->read_uint32(reader, type) ||
		!reader->read_uint32(reader, &len) ||
		!reader->read_uint32(reader, identifier))
	{
		reader->destroy(reader);
		return NULL;
	}
	reader->destroy(reader);

	if (len < PT_TLS_HEADER_LEN)
	{
		DBG1(DBG_TNC, "received short PT-TLS header (%d bytes)", len);
		return NULL;
	}

	if (*vendor == PEN_IETF)
	{
		DBG2(DBG_TNC, "received PT-TLS message #%d of type '%N' (%d bytes)",
					  *identifier, pt_tls_message_type_names, *type, len);
	}
	else
	{
		DBG2(DBG_TNC, "received PT-TLS message #%d of unknown type "
					  "0x%06x/0x%08x (%d bytes)",
					  *identifier, *vendor, *type, len);
	}

	return read_tls(tls, len - PT_TLS_HEADER_LEN);
}
Example #9
0
static SECMODModule *find_module_by_library(char *pkcs11_module)
{
  SECMODModule *module = NULL;
  SECMODModuleList *modList = SECMOD_GetDefaultModuleList();

  /* threaded applications should also acquire the
   * DefaultModuleListLock */
  DBG("Looking up module in list");
  for ( ; modList; modList = modList->next) {
    char *dllName = modList->module->dllName;
    DBG2("modList = 0x%x next = 0x%x\n", modList, modList->next);
    DBG1("dllName= %s \n", dllName ? dllName : "<null>");
    if (dllName && strcmp(dllName,pkcs11_module) == 0) {
        module = SECMOD_ReferenceModule(modList->module);
        break;
    }
  }
  return module;
}
Example #10
0
/**
 * The write function is called when LEDs should be set. Normally, we get only
 * one byte that contains info about the LED states.
 * \param data pointer to received data
 * \param len number ob bytes received
 * \return 0x01
 */
uint8_t usbFunctionWrite(uchar *data, uchar len) {
//    DBG1(0xBB, (uchar *)&len, 1);
    if (expectReport == 1 && (len == 1)) {
        // change LEDs of indicator
        delegateLedUsb(data[0]);
        expectReport = 0;
    }else if (expectReport == 2){   // options
        DBG1(0xEE, data, len);
        // start bootloader
        if(data[1] == OPTION_INDEX_BOOTLOADER && len == 8){
        	if(data[2] == 0xFF){
        		eeprom_write_byte((uint8_t *)EEPROM_BOOTLOADER_START, 0x00);
        	}
        	delegateGotoBootloader();
/* TODO
 * 이전 버전과 호환을 위해 남겨둠
 */
#ifdef ENABLE_BOOTMAPPER
        }else if(data[1] == OPTION_INDEX_BOOTMAPPER){
        	if(data[2] == OPTION_VALUE_BOOTMAPPER_START){
        		setToBootMapper(true);
        	}else{
        		setToBootMapper(false);
        	}
#endif
       /* }else if(data[1] == OPTION_INDEX_READY){
            stopPwmForUsbReport(true);

        }else if(data[1] == OPTION_INDEX_ACTION){
            stopPwmForUsbReport(false);*/
        }else{
        	setOptions((uint8_t *)data);
        }
    }else if (expectReport == 4){
    	// rainbow color setting
    	setOptions((uint8_t *)data);
    }else if (expectReport == 5){
        // write quick macro;
        updateQuickMacro((uint8_t *)data, len);
    }

    return 0x01;
}
Example #11
0
/* Deallocate memory for one device */
static void nozomi_card_exit(struct pci_dev *pdev)
{
	int i;
	struct ctrl_ul ctrl;
	struct nozomi *dc = pci_get_drvdata(pdev);

	/* Disable all interrupts */
	dc->last_ier = 0;
	writew(dc->last_ier, dc->reg_ier);

	tty_exit(dc);

	/* Send 0x0001, command card to resend the reset token.  */
	/* This is to get the reset when the module is reloaded. */
	ctrl.port = 0x00;
	ctrl.reserved = 0;
	ctrl.RTS = 0;
	ctrl.DTR = 1;
	DBG1("sending flow control 0x%04X", *((u16 *)&ctrl));

	/* Setup dc->reg addresses to we can use defines here */
	write_mem32(dc->port[PORT_CTRL].ul_addr[0], (u32 *)&ctrl, 2);
	writew(CTRL_UL, dc->reg_fcr);	/* push the token to the card. */

	remove_sysfs_files(dc);

	free_irq(pdev->irq, dc);

	for (i = 0; i < MAX_PORT; i++)
		kfifo_free(&dc->port[i].fifo_ul);

	kfree(dc->send_buf);

	iounmap(dc->base_addr);

	pci_release_regions(pdev);

	pci_disable_device(pdev);

	ndevs[dc->index_start / MAX_PORT] = NULL;

	kfree(dc);
}
Example #12
0
static void leaveBootloader() {
    DBG1(0x01, 0, 0);
    bootLoaderExit();
    cli();
    boot_rww_enable();
    USB_INTR_ENABLE = 0;
    USB_INTR_CFG = 0;       /* also reset config bits */
#if F_CPU == 12800000
    TCCR0 = 0;              /* default value */
#endif
    GICR = (1 << IVCE);     /* enable change of interrupt vectors */
    GICR = (0 << IVSEL);    /* move interrupts to application flash section */
/* We must go through a global function pointer variable instead of writing
 *  ((void (*)(void))0)();
 * because the compiler optimizes a constant 0 to "rcall 0" which is not
 * handled correctly by the assembler.
 */
    nullVector();
}
static struct sk_buff *rmnet_usb_tx_fixup(struct usbnet *dev,
		struct sk_buff *skb, gfp_t flags)
{
	struct QMI_QOS_HDR_S	*qmih;
//++SSD_RIL:20120731: For tx/rx enable_hlt/disable_hlt
	if (rnmet_usb_hlt_enabled == 1 ) {
//++SSD_RIL:20120814: For CPU/Freq min default value
		int is_disable_flt = 0;
//--SSD_RIL
		unsigned long flags = 0;
		spin_lock_irqsave(&rmnet_usb_hlt_lock, flags);
		if ( rnmet_usb_hlt_timer_enabled == 0 ) {
			rnmet_usb_hlt_timer_enabled = 1;
			disable_hlt();
//++SSD_RIL:20120814: For CPU/Freq min default value
			is_disable_flt = 1;
//--SSD_RIL
			pr_info("%s: rmnet hlt disable\n", __func__);
		}
		del_timer(&rmnet_usb_lp2_in_idle_timer);
		mod_timer(&rmnet_usb_lp2_in_idle_timer, jiffies + msecs_to_jiffies(2000));
		spin_unlock_irqrestore(&rmnet_usb_hlt_lock, flags);
//++SSD_RIL:20120814: For CPU/Freq min default value
		if ( is_disable_flt == 1 && rnmet_usb_cpu_freq_enabled == 1 ) {
			rmnet_usb_freq_timer_enable();
		}
//--SSD_RIL
	}
//--SSD_RIL
	if (test_bit(RMNET_MODE_QOS, &dev->data[0])) {
		qmih = (struct QMI_QOS_HDR_S *)
		skb_push(skb, sizeof(struct QMI_QOS_HDR_S));
		qmih->version = 1;
		qmih->flags = 0;
		qmih->flow_id = skb->mark;
	 }

	DBG1("[%s] Tx packet #%lu len=%d mark=0x%x\n",
	    dev->net->name, dev->net->stats.tx_packets, skb->len, skb->mark);

	return skb;
}
Example #14
0
/*
 * This routine is symmetric for master and slave, so it handles both without
 * splitting up the codepath.
 *
 * If there are messages on this queue that can be sent to the other, send
 * them via putnext(). Else, if queued messages cannot be sent, leave them
 * on this queue.
 */
static void
zc_wsrv(queue_t *qp)
{
	mblk_t *mp;

	DBG1("zc_wsrv master (%s) side", zc_side(qp));

	/*
	 * Partner has no read queue, so take the data, and throw it away.
	 */
	if (zc_switch(RD(qp)) == NULL) {
		DBG("zc_wsrv: other side isn't listening");
		while ((mp = getq(qp)) != NULL) {
			if (mp->b_datap->db_type == M_IOCTL)
				miocnak(qp, mp, 0, 0);
			else
				freemsg(mp);
		}
		flushq(qp, FLUSHALL);
		return;
	}

	/*
	 * while there are messages on this write queue...
	 */
	while ((mp = getq(qp)) != NULL) {
		/*
		 * Due to the way zc_wput is implemented, we should never
		 * see a control message here.
		 */
		ASSERT(mp->b_datap->db_type < QPCTL);

		if (bcanputnext(RD(zc_switch(qp)), mp->b_band)) {
			DBG("wsrv: send message to other side\n");
			putnext(RD(zc_switch(qp)), mp);
		} else {
			DBG("wsrv: putting msg back on queue\n");
			(void) putbq(qp, mp);
			break;
		}
	}
}
/* Rx Callback, Called in Work Queue context */
static void sdio_recv_notify(void *dev, struct sk_buff *skb)
{
	struct rmnet_private *p = netdev_priv(dev);
	unsigned long flags;
	u32 opmode;

	if (skb) {
		skb->dev = dev;
		/* Handle Rx frame format */
		spin_lock_irqsave(&p->lock, flags);
		opmode = p->operation_mode;
		spin_unlock_irqrestore(&p->lock, flags);

		if (RMNET_IS_MODE_IP(opmode)) {
			/* Driver in IP mode */
			skb->protocol = rmnet_ip_type_trans(skb, dev);
		} else {
			/* Driver in Ethernet mode */
			skb->protocol = eth_type_trans(skb, dev);
		}
		if (RMNET_IS_MODE_IP(opmode) ||
		    count_this_packet(skb->data, skb->len)) {
#ifdef CONFIG_MSM_RMNET_DEBUG
			p->wakeups_rcv += rmnet_cause_wakeup(p);
#endif
			p->stats.rx_packets++;
			p->stats.rx_bytes += skb->len;
		}
		DBG1("[%s] Rx packet #%lu len=%d\n",
			((struct net_device *)dev)->name,
			p->stats.rx_packets, skb->len);

		/* Deliver to network stack */
		netif_rx(skb);
	} else {
		spin_lock_irqsave(&p->lock, flags);
		if (!sdio_update_reset_state((struct net_device *)dev))
			pr_err("[%s] %s: No skb received",
				((struct net_device *)dev)->name, __func__);
		spin_unlock_irqrestore(&p->lock, flags);
	}
}
void charon_esa_expire(result_type *res, const sp_id_type sp_id,
					   const esp_spi_type spi_rem, const protocol_type protocol,
					   const expiry_flag_type hard)
{
	host_t *dst;

	dst = tkm->sad->get_dst_host(tkm->sad, sp_id, spi_rem, protocol);
	*res = TKM_OK;
	if (dst == NULL)
	{
		DBG3(DBG_KNL, "ees: destination host not found for reqid %u, spi %x, "
			 "proto %u", sp_id, ntohl(spi_rem), protocol);
		return;
	}

	DBG1(DBG_KNL, "ees: expire received for reqid %u, spi %x, dst %H", sp_id,
		 ntohl(spi_rem), dst);
	hydra->kernel_interface->expire(hydra->kernel_interface, protocol,
									spi_rem, dst, hard != 0);
}
Example #17
0
static char *IMPI_adjustbuffer(char *buf, size_t actualsize, size_t newsize)
{
    if (buf == NULL) {
	DBG1("adjustbuffer: buffer pointer NULL, allocating %d bytes", newsize);
	buf = (char *) malloc (newsize);
    } else {
      if (actualsize < newsize)
      {
	DBG2("Realloc buffer: %d vs %d", actualsize, newsize);
	buf = (char *) realloc(buf, newsize);
      }
    }
    
    if (buf == NULL) {
	DBG("adjustbuffer: realloc failed");
	ROUTER_ABORT;
    }
    
    return buf;
}
Example #18
0
File: main.c Project: elcerdo/avr
usbMsgLen_t usbFunctionSetup(uchar data[8])
{
    usbRequest_t    *rq = (void *)data;

    if (rq->bRequest == CUSTOM_RQ_LED_SET_STATUS) {
        status_set(rq->wValue.word & 1);
    } else if (rq->bRequest == CUSTOM_RQ_KEY_GET_STATUS) {
        keypad_update();
        DBG1(0x02, keypad_get(), 8);
        usbMsgPtr = keypad_get();
        return 8;
    } else if (rq->bRequest == CUSTOM_RQ_LEDS_SET_STATUS) {
        return USB_NO_MSG;
    } else if (rq->bRequest == CUSTOM_RQ_LEDS_SET_LAYER) {
        if (rq->wValue.word >= 0 && rq->wValue.word < MAXLAYER) current_layer = rq->wValue.word;
	} else if (rq->bRequest == CUSTOM_RQ_LEDS_SET_INTENSITY) {
        led_send_command(LED_INTENSITY,rq->wValue.bytes[0]);
    }
    return 0;
}
Example #19
0
static int
acebus_get_ranges_prop(ebus_devstate_t *ebus_p)
{
	struct ebus_pci_rangespec *rangep;
	int nrange, range_len;

	if (ddi_getlongprop(DDI_DEV_T_ANY, ebus_p->dip, DDI_PROP_DONTPASS,
	    "ranges", (caddr_t)&rangep, &range_len) != DDI_SUCCESS) {

		cmn_err(CE_WARN, "%s%d: can't get ranges property",
		    ddi_get_name(ebus_p->dip), ddi_get_instance(ebus_p->dip));
		return (DDI_ME_REGSPEC_RANGE);
	}

	nrange = range_len / sizeof (struct ebus_pci_rangespec);

	if (nrange == 0)  {
		kmem_free(rangep, range_len);
		return (DDI_FAILURE);
	}

#ifdef	DEBUG
	{
		int i;

		for (i = 0; i < nrange; i++) {
			DBG5(D_MAP, ebus_p,
			    "ebus range addr 0x%x.0x%x PCI range "
			    "addr 0x%x.0x%x.0x%x ", rangep[i].ebus_phys_hi,
			    rangep[i].ebus_phys_low, rangep[i].pci_phys_hi,
			    rangep[i].pci_phys_mid, rangep[i].pci_phys_low);
			DBG1(D_MAP, ebus_p, "Size 0x%x\n", rangep[i].rng_size);
		}
	}
#endif /* DEBUG */

	ebus_p->rangep = rangep;
	ebus_p->range_cnt = nrange;

	return (DDI_SUCCESS);
}
Example #20
0
static void putChangedKey(uint8_t xKeyidx, bool xIsDown, uint8_t xCol, uint8_t xRow){

    applyKeyDownForFullLED(xKeyidx, xCol, xRow, xIsDown);

    // 빈 키코드는 LED 반응 이외의 기능 없음;
    if(xKeyidx == KEY_NONE ) return;

    // fn 키가 눌렸을 경우 해당 위치의 키는 무시한다.
    uint8_t gLayer, gKeyIndex, gFnIndex;

    gLayer = getCurrentFnLayer();
    DBG1(0xC2, (uchar *)&gLayer, 1);

    if(isFnPosition(xCol, xRow) /* -> */ && (xIsDown || (!xIsDown && isFnPressed())) /* <- */)
        // 키 입력 동안 레이어 토글이 변경될 경우 FN 키와 같은 위치의 키들은 up 신호가 무시 되어 계속 눌려진 상태가 된다. 이를 패치.
        // 이 경우 fnPressed가 false 상태로 진행되므로 이를 확인
    {
        // 현재 레이어에서 눌린 FN키가 듀얼 액션 키이면, 변경된 레이어의 키를 듀얼 액션 키로 강제 치환시켜서 진행
        gKeyIndex = getCurrentKeyindex(gLayer, xRow, xCol);

        // fn key는 하나만 눌릴 수 있도록 처리;
        if(xIsDown)
        {
            // dual action key라면 FN을 추출;
            gFnIndex = getDualActionDownKeyIndexWhenIsCompounded(gKeyIndex, true);
//            DBG1(0x32, (uchar *)&gFnIndex, 1);
            setFnPressed(gFnIndex);
        }
        else
        {
            setFnPressed(KEY_NONE);
            clearFnPosition();
        }

        IF_IS_DUAL_ACTION_KEY(gKeyIndex)
        {
            xKeyidx = gKeyIndex;
        }
        else
        {
            return;
Example #21
0
static void load_also_cas(starter_ca_t *ca, also_t *also, starter_config_t *cfg)
{
	while (also != NULL)
	{
		kw_list_t *kw = find_also_ca(also->name, ca, cfg);

		if (kw == NULL)
		{
			DBG1(DBG_APP, "  ca '%s' cannot include '%s'", ca->name,
				 also->name);
		}
		else
		{
			DBG2(DBG_APP, "ca '%s' includes '%s'", ca->name, also->name);
			/* only load if no error occurred in the first round */
			if (cfg->err == 0)
			load_ca(ca, kw, cfg);
		}
		also = also->next;
	}
}
Example #22
0
usbMsgLen_t usbFunctionSetup(uchar data[8])
{
    usbRequest_t *rq = (void *)data;

    if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS){ /* class request type */
        DBG1(0x50, &rq->bRequest, 1);  /* debug output: print our request */
        if(rq->bRequest == USBRQ_HID_GET_REPORT){ /* wValue: ReportType (highbyte), ReportID (lowbyte) */
            /* we only have one report type, so don't look at wValue */
            usbMsgPtr = (void *)&reportBuffer;
            return sizeof(reportBuffer);
            }else if(rq->bRequest == USBRQ_HID_GET_IDLE){
            usbMsgPtr = &idleRate;
            return 1;
            }else if(rq->bRequest == USBRQ_HID_SET_IDLE){
            idleRate = rq->wValue.bytes[1];
        }
        }else{
        /* no vendor specific requests implemented */
    }
    return 0;  /* default for not implemented requests: return no data back to host */
}
Example #23
0
/*
* parses the certificate and try to macht any UID in the certificate
* with provided user
*/
static int uid_mapper_match_user(X509 *x509, const char *login, void *context) {
	char *str;
	int match_found = 0;
	char **entries  = cert_info(x509,CERT_UID,ALGORITHM_NULL);
        if (!entries) {
            DBG("get_unique_id() failed");
            return -1;
        }
	/* parse list of uids until match */
	for (str=*entries; str && (match_found==0); str=*++entries) {
	    int res=0;
            DBG1("trying to map & match uid entry '%s'",str);
            res = mapfile_match(mapfile,str,login,ignorecase);
	    if (!res) {
	        DBG("Error in map&match process");
	        return -1; /* or perhaps should be "continue" ??*/
	    }
	    if (res>0) match_found=1;
	}
	return match_found;
}
Example #24
0
DJ850::DJ850(SystemServices* pSS,
                       int numfonts, BOOL proto)
    : Printer(pSS, numfonts, proto)
{
    if ((!proto) && (IOMode.bDevID))
    {
        constructor_error = VerifyPenInfo();
        CERRCHECK;
    }
    else ePen=BOTH_PENS;    // matches default mode

    pMode[GRAYMODE_INDEX]      = new DJ850Mode5 ();   // Normal Gray K
    pMode[DEFAULTMODE_INDEX]   = new DJ850Mode1 ();   // Normal Color
    pMode[SPECIALMODE_INDEX] = new DJ850Mode3 ();   // Draft Color
    pMode[SPECIALMODE_INDEX+1] = new DJ850Mode4 ();   // Draft Gray K
    ModeCount = 4;

    CMYMap = ulMapDJ850_Normal_KCMY;

    DBG1("DJ850 created\n");
}
Example #25
0
/*
 * vdds_send_dds_rel_msg -- Send a DDS_REL_SHARE message.
 */
static int
vdds_send_dds_rel_msg(vnet_t *vnetp)
{
	vnet_dds_info_t *vdds = &vnetp->vdds_info;
	vio_dds_msg_t	vmsg;
	dds_share_msg_t	*smsg = &vmsg.msg.share_msg;
	int rv;

	DBG1(vdds, "Sending DDS_VNET_REL_SHARE message");
	vmsg.tag.vio_msgtype = VIO_TYPE_CTRL;
	vmsg.tag.vio_subtype = VIO_SUBTYPE_INFO;
	vmsg.tag.vio_subtype_env = VIO_DDS_INFO;
	/* vio_sid filled by the LDC module */
	vmsg.dds_class = DDS_VNET_NIU;
	vmsg.dds_subclass = DDS_VNET_REL_SHARE;
	vmsg.dds_req_id = (++vdds->dds_req_id);
	smsg->macaddr = vnet_macaddr_strtoul(vnetp->curr_macaddr);
	smsg->cookie = vdds->hio_cookie;
	rv = vnet_send_dds_msg(vnetp, &vmsg);
	return (rv);
}
Example #26
0
/*
* parses the certificate and try to macht any CN in the certificate
* with provided user
*/
static int krb_mapper_match_user(X509 *x509, const char *login, void *context) {
	char *str;
        int match_found = 0;
        char **entries  = cert_info(x509,CERT_KPN,ALGORITHM_NULL);
        if (!entries) {
            DBG("get_krb_principalname() failed");
            return -1;
        }
        /* parse list of entries until match */
        for (str=*entries; str && (match_found==0); str=*++entries) {
            int res=0;
            DBG1("trying to map & match KPN entry '%s'",str);
            res = mapfile_match("none",str,login,0);
            if (!res) {
                DBG("Error in map&match process");
                return -1; /* or perhaps should be "continue" ??*/
            }
            if (res>0) match_found=1;
        }
        return match_found;
}
Example #27
0
/**
 * Check/create PID file, return TRUE if already running
 */
static bool check_pidfile()
{
	struct stat stb;

	if (stat(pidfile_name, &stb) == 0)
	{
		pidfile = fopen(pidfile_name, "r");
		if (pidfile)
		{
			char buf[64];
			pid_t pid = 0;

			memset(buf, 0, sizeof(buf));
			if (fread(buf, 1, sizeof(buf), pidfile))
			{
				buf[sizeof(buf) - 1] = '\0';
				pid = atoi(buf);
			}
			fclose(pidfile);
			if (pid && kill(pid, 0) == 0)
			{	/* such a process is running */
				return TRUE;
			}
		}
		DBG1(DBG_DMN, "removing pidfile '%s', process not running", pidfile_name);
		unlink(pidfile_name);
	}

	/* create new pidfile */
	pidfile = fopen(pidfile_name, "w");
	if (pidfile)
	{
		ignore_result(fchown(fileno(pidfile),
							 lib->caps->get_uid(lib->caps),
							 lib->caps->get_gid(lib->caps)));
		fprintf(pidfile, "%d\n", getpid());
		fflush(pidfile);
	}
	return FALSE;
}
Example #28
0
File: main.c Project: elcerdo/avr
int main(void) {
    uint8_t i;

    keypad_init();
    led_init();
    status_init();
    layers_init();

    for (i=0; i<8; i++) led_send_command(i+1,0x00);

    wdt_enable(WDTO_1S);
    /* Even if you don't use the watchdog, turn it off here. On newer devices,
     * the status of the watchdog (on/off, period) is PRESERVED OVER RESET!
     */
    /* RESET status: all port bits are inputs without pull-up.
     * That's the way we need D+ and D-. Therefore we don't need any
     * additional hardware initialization.
     */
    odDebugInit();
    usbInit();
    usbDeviceDisconnect();  /* enforce re-enumeration, do this while interrupts are disabled! */
    i = 0;
    while(--i){             /* fake USB disconnect for > 250 ms */
        wdt_reset();
        _delay_ms(1);
    }
    usbDeviceConnect();

    sei();
    DBG1(0x01, 0, 0);       /* debug output: main loop starts */
    for(;;){                /* main event loop */
        wdt_reset();
        usbPoll();
    }

    keypad_free();
    layers_free();

    return 0;
}
Example #29
0
void BuzzMDKHelper::Init(CMachineDataInput * const pi) {
	DBG1("(pi=%p)\n",pi);
/*
    ThisMachine = pmi->pCB->GetThisMachine();

	numChannels = 1;

    Inputs.clear();
	InputIterator = Inputs.begin();
	HaveInput = 0;
	MachineWantsChannels = 1;

    // Buzz seems to store a dummy initial byte here - maybe
	// some kind of version tag?
	byte byDummy;
	pi->Read(byDummy);

	pmi->MDKInit(pi);

	pInnerEx = pmi->GetEx();
*/
}
Example #30
0
void set_dictionary_value(const FieldType* ftype,
                          const FieldData* fdata, address src, address dest)
{
  GHashTable* dictionary = 0;
  TypedValue* prev_value = 0;
  TypedValue* new_value = 0;
  
  dictionary = get_dictionary(ftype, src, dest);
  
  if(!ftype->key) {
    return;
  }

  prev_value = g_hash_table_lookup(dictionary, ftype->key);
  /* Recycle the previous value */
  if (prev_value) {
    if (!prev_value->empty) {
      cleanup_field_value(ftype->type, &prev_value->value);
    }
    new_value = prev_value;
  }
  else {
    new_value = g_malloc(sizeof(TypedValue));
  }
  /* Copy in the values */
  new_value->type = ftype->type;
  new_value->empty = fdata->status == FieldEmpty;
  if (!new_value->empty) {
    copy_field_value(ftype->type, &fdata->value, &new_value->value);
  }
  if (new_value) {
    /* Only have to insert if we created a new value. */
    if (!prev_value) {
      g_hash_table_insert(dictionary, g_strdup(ftype->key), new_value);
    }
  } else {
    DBG1("Failed to set value for field type: %s", ftype->name);
  }
}