예제 #1
0
파일: mca.c 프로젝트: edgar-pek/PerspicuOS
static size_t
show_section(struct mca_section_header *sh)
{
	static uuid_t uuid_cpu = MCA_UUID_CPU;
	static uuid_t uuid_memory = MCA_UUID_MEMORY;
	static uuid_t uuid_sel = MCA_UUID_SEL;
	static uuid_t uuid_pci_bus = MCA_UUID_PCI_BUS;
	static uuid_t uuid_smbios = MCA_UUID_SMBIOS;
	static uuid_t uuid_pci_dev = MCA_UUID_PCI_DEV;
	static uuid_t uuid_generic = MCA_UUID_GENERIC;

	printf("  <section>\n");
	show_value(4, "uuid", "%s", uuid(&sh->sh_uuid));
	show_value(4, "revision", "%d.%d", BCD(sh->sh_major),
	    BCD(sh->sh_minor));

	if (uuid_equal(&sh->sh_uuid, &uuid_cpu, NULL))
		show_cpu((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_memory, NULL))
		show_memory((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_sel, NULL))
		show_sel();
	else if (uuid_equal(&sh->sh_uuid, &uuid_pci_bus, NULL))
		show_pci_bus((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_smbios, NULL))
		show_smbios();
	else if (uuid_equal(&sh->sh_uuid, &uuid_pci_dev, NULL))
		show_pci_dev((void*)(sh + 1));
	else if (uuid_equal(&sh->sh_uuid, &uuid_generic, NULL))
		show_generic();

	printf("  </section>\n");
	return (sh->sh_length);
}
예제 #2
0
파일: reminder.c 프로젝트: ra1fh/s710
int
get_reminder ( S710_Driver *d, S710_Packet_Index which, reminder_t *reminder )
{
  packet_t *p;
  int       ok = 0;

  if ( which < S710_GET_REMINDER_1 || 
       which > S710_GET_REMINDER_7 )
    return 0;

  p = get_response ( which, d );
  if ( p != NULL) {
    reminder->which = p->data[0] + 1;
    extract_label ( &p->data[6], &reminder->label, 7 );
    memset(&reminder->date,0,sizeof(reminder->date));
    reminder->date.tm_sec  = 0;
    reminder->date.tm_min  = BCD(p->data[1]);
    reminder->date.tm_hour = BCD(p->data[2]);
    reminder->date.tm_mday = BCD(p->data[3]);
    reminder->date.tm_mon  = LNIB(p->data[5]) - 1;
    reminder->date.tm_year = BCD(p->data[4]) + 100;
    reminder->date.tm_wday = 0;
    reminder->on           = (UNIB(p->data[5]) & 0x01) ? S710_ON : S710_OFF;
    reminder->exercise     = LNIB(p->data[13]);
    reminder->repeat       = UNIB(p->data[13]);
    free ( p );
    ok = 1;
  }

  return ok;
}
void dec_mouse(void)
{
	if (data_trama_ready)
	{	
		sendCode(nIns, 0x80);
		sendCode(nData,'X');
		sendCode(nData,':');
		sig_x = (((trama_mouse[0] & 0x10)/0x10));
		sig_y = ((trama_mouse[0] & 0x20)/0x20);
		value_x =(trama_mouse[1]);
		value_y =(trama_mouse[2]);

		if(sig_x)
		{
			coord_x = ~trama_mouse[1];
			sendCode(nData,'-');
		}
		else
		{
			coord_x = trama_mouse[1];
			sendCode(nData,'+');
		}
		if(coord_x<0)
		{
			coord_x = coord_x*(0-1);
		}
		BCD(coord_x);
		sendCode(nData,cen+0x30);
		sendCode(nData,dec+0x30);
		sendCode(nData,uni+0x30);
		sendCode(nData,' ');
		sendCode(nData,'Y');
		sendCode(nData,':');
		if(sig_y)
		{
			coord_y = ~trama_mouse[2];
			sendCode(nData,'-');
		}
		else
		{
			sendCode(nData,'+');
			coord_y = trama_mouse[2];
		}
		
		if(coord_y<0)
		{
			coord_y = coord_y*(0-1);
		}
		BCD(coord_y);
		sendCode(nData,cen+0x30);
		sendCode(nData,dec+0x30);
		sendCode(nData,uni+0x30);
		trama_mouse[0] = 0;
		trama_mouse[1] = 0;
		trama_mouse[2] = 0;
		trama_mouse[3] = 0;
		data_trama_ready = 0;
	}
}
예제 #4
0
파일: rtc.c 프로젝트: GNsunghokim/rtos
// 0xff0000: hour, 0xff00: minute, 0xff: second
static uint32_t rtc_time() {
	uint32_t result = 0;
	uint32_t tmp;
	
	port_out8(RTC_ADDRESS, RTC_ADDR_HOUR);
	tmp = port_in8(RTC_DATA);
	result |= BCD(tmp) << 16;
	
	port_out8(RTC_ADDRESS, RTC_ADDR_MINUTE);
	tmp = port_in8(RTC_DATA);
	result |= BCD(tmp) << 8;
	
	port_out8(RTC_ADDRESS, RTC_ADDR_SECOND);
	tmp = port_in8(RTC_DATA);
	result |= BCD(tmp) << 0;
	
	return result;
}
예제 #5
0
파일: rtc.c 프로젝트: ErisBlastar/osfree
Bit8u rtc_read(Bit8u reg)
{
  Bit8u ret = GET_CMOS(reg);

  switch (reg) {
  case CMOS_SEC:
  case CMOS_SECALRM:
  case CMOS_MIN:
  case CMOS_MINALRM:
  case CMOS_DOW:
  case CMOS_DOM:
  case CMOS_MONTH:
  case CMOS_YEAR:
  case CMOS_CENTURY:
    /* Note - the inline function BCD() in cmos.h will check bit 2 of
     * status reg B for proper output format */
    ret = BCD(ret);
    break;

  case CMOS_HOUR:		/* RTC hour...bit 1 of 0xb set=24 hour mode, clear 12 hour */
  case CMOS_HOURALRM:
    if (!(GET_CMOS(CMOS_STATUSB) & 2)) {	/* 12-hour mode */
      if (ret == 0)
	ret = 12;
      else if (ret > 12)
	ret -= 12;
    }
    ret = BCD(ret);
    break;

  case CMOS_STATUSC:
    if (debug_level('h') > 8)
      h_printf("RTC: Read C=%hhx\n", ret);
    SET_CMOS(CMOS_STATUSC, 0);
    pic_untrigger(PIC_IRQ8);
    rtc_run();
    break;
  }

  return ret;
}
예제 #6
0
파일: rtc.c 프로젝트: GNsunghokim/rtos
// 0xff000000: year, 0xff0000: month, 0xff00: day of month, 0xff: day of week
static uint32_t rtc_date() {
	uint32_t result = 0;
	uint32_t tmp;
	
	port_out8(RTC_ADDRESS, RTC_ADDR_YEAR);
	tmp = port_in8(RTC_DATA);
	result |= BCD(tmp) << 24;
	
	port_out8(RTC_ADDRESS, RTC_ADDR_MONTH);
	tmp = port_in8(RTC_DATA);
	result |= BCD(tmp) << 16;
	
	port_out8(RTC_ADDRESS, RTC_ADDR_DATE);
	tmp = port_in8(RTC_DATA);
	result |= BCD(tmp) << 8;
	
	port_out8(RTC_ADDRESS, RTC_ADDR_WEEK);
	tmp = port_in8(RTC_DATA);
	result |= BCD(tmp) << 0;
	
	return result;
}
예제 #7
0
struct TK_MSID * tkmsid_make(u_char *frame, int frame_len, struct signalhdr *s, time_t *tm){
	struct TK_MSID *t;
	t = (struct TK_MSID *)malloc(sizeof(struct TK_MSID));
	t->sip = s->ip->src;
	t->dip = s->ip->dst;
	_Int32 *k = (_Int32 *)(frame+4);
	t->key = long_displace(*k);
	u_char c[4] = {0x00,0x00,0x00,0x00};
	_Int32 *offset = (_Int32 *)c;
	int i,j=0,u=0;

	t->msid[j] = BCD(frame[15]>>4);
	for(i=16;j<14;i++){
		t->msid[++j] = BCD(frame[i]);
		t->msid[++j] = BCD(frame[i]>>4);
	}
	t->msid[++j] = '\0';
	c[0] = frame[u+1];
	u = u+(*offset)+2;

	c[0] = frame[u+3]; c[1] = frame[u+2];
	int y = u+(*offset)+4;
	u+=10;
	do{
		switch(frame[u+6]){
			case 0x74:
				for(i=0;i<14;i++)
					t->meid[i] = frame[u+i+8];
				t->meid[i] = '\0';
				break;
			case 0x0a:
				for(i=0;i<12;i++)
					t->bsid[i] = frame[u+i+8];
				t->bsid[i] = '\0';
				break;
			default:
				break;
		}
		c[0] = frame[u+1]; c[1] = 0x00;
		u+=(*offset);
	}while(u < y);

	if(tm){
		t->time = (time_t)long_displace(*tm);
//		printf("%s", ctime(&t->time));
//		fflush(stdout);
	}
	t->next = NULL;
	return t;
}
예제 #8
0
파일: emv_pk.c 프로젝트: Zengwn/emv-tools
static ssize_t emv_pk_read_ymv(char *buf, unsigned *ymv)
{
	int i;
	unsigned char temp[3];
	char *p = buf;

	*ymv = 0;

	while (*p && *p == ' ')
		p++;

	for (i = 0; i < 3; i++) {
		int c1, c2;
		c1 = BCD(*p);
		if (c1 == -1)
			return -(p - buf);
		p++;
		c2 = BCD(*p);
		if (c2 == -1)
			return -(p - buf);
		p++;
		temp[i] = (c1 * 16 + c2);
	}

	while (*p && *p == ' ')
		p++;

	p--;

	if (temp[1] > 0x12 || temp[2] > 0x31)
		return -(p - buf);

	*ymv = (temp[0] * 0x10000 + temp[1] * 0x100 + temp[2]);

	return (p - buf);
}
예제 #9
0
파일: overview.c 프로젝트: ra1fh/s710
int
get_overview ( S710_Driver *d, overview_t *overview )
{
  packet_t *p;
  int       ok = 0;

  p = get_response ( S710_GET_OVERVIEW, d );
  if ( p != NULL) {
    overview->files = BCD(p->data[2]);
    overview->bytes = (p->data[4] << 8) + p->data[5];
    ok = 1;
    free ( p );
  }

  return ok;
}
예제 #10
0
파일: mca.c 프로젝트: edgar-pek/PerspicuOS
static size_t
show_header(struct mca_record_header *rh)
{

	printf("  <header>\n");
	show_value(4, "seqnr", "%lld", (long long)rh->rh_seqnr);
	show_value(4, "revision", "%d.%d", BCD(rh->rh_major),
	    BCD(rh->rh_minor));
	show_value(4, "severity", "%s", severity(rh->rh_error));
	show_value(4, "length", "%lld", (long long)rh->rh_length);
	show_value(4, "date", "%d%02d/%02d/%02d",
	    BCD(rh->rh_time[MCA_RH_TIME_CENT]),
	    BCD(rh->rh_time[MCA_RH_TIME_YEAR]),
	    BCD(rh->rh_time[MCA_RH_TIME_MON]),
	    BCD(rh->rh_time[MCA_RH_TIME_MDAY]));
	show_value(4, "time", "%02d:%02d:%02d",
	    BCD(rh->rh_time[MCA_RH_TIME_HOUR]),
	    BCD(rh->rh_time[MCA_RH_TIME_MIN]),
	    BCD(rh->rh_time[MCA_RH_TIME_SEC]));
	if (rh->rh_flags & MCA_RH_FLAGS_PLATFORM_ID)
		show_value(4, "platform", "%s", uuid(&rh->rh_platform));
	printf("  </header>\n");
	return (rh->rh_length);
}
예제 #11
0
	HID_REPORT_COUNT    (8, 0x05),
	HID_OUTPUT          (8, HID_DATA | HID_VARIABLE | HID_ABSOLUTE),

	HID_REPORT_SIZE     (8, 0x03),
	HID_REPORT_COUNT    (8, 0x01),
	HID_OUTPUT          (8, HID_CONSTANT),

	HID_END_COLLECTION  (0)
};

local const USB_DeviceDescriptor_t PROGMEM DeviceDescriptor = {
	.header = {
		.length         = sizeof(USB_DeviceDescriptor_t),
		.descriptorType = USB_DescriptorType_Device,
	},
	.usbVersion         = BCD(1,1,0),
	.deviceClass        = USB_Class_FromInterface,
	.deviceSubClass     = USB_Subclass_FromInterface,
	.deviceProtocol     = USB_Protocol_FromInterface,
	.maxPacketSize      = USB_ENDPOINT_CONTROL_SIZE,
	.vendorId           = USB_VENDOR_ID,
	.productId          = USB_PRODUCT_ID,
	.deviceVersion      = USB_RELEASE_NUMBER,
	.manufacturerString = StringDescriptorId_Manufacturer,
	.productString      = StringDescriptorId_Product,
	.serialNumberString = USB_NO_STRING_DESCRIPTOR,
	.numConfigurations  = USB_CONFIGURATION_COUNT
};

local const USB_CombinedConfigurationDescriptor_t PROGMEM ConfigurationDescriptor = {
	.configuration = {
예제 #12
0
/*******************************************************************************
**	InitializeVGProfiler
**
**	Initialize the profiler for the context provided.
**
**	Arguments:
**
**		VGContext Context
**			Pointer to a new VGContext object.
*/
void
InitializeVGProfiler(
    _VGContext * Context
	)
{
	gceSTATUS status;
	gctUINT rev;
        char *env;

	status = gcoPROFILER_Initialize(Context->hal);

	if (gcmIS_ERROR(status))
	{
		Context->profiler.enable = gcvFALSE;
		return;
	}

    /* Clear the profiler. */
	gcmVERIFY_OK(
		gcoOS_ZeroMemory(&Context->profiler, gcmSIZEOF(Context->profiler)));

    gcoOS_GetEnv(Context->os, "VP_COUNTER_FILTER", &env);
    if ((env == gcvNULL) || (env[0] ==0))
    {
        Context->profiler.drvEnable =
            Context->profiler.timeEnable =
            Context->profiler.memEnable = gcvTRUE;
    }
    else
    {
        gctSIZE_T bitsLen;
        gcoOS_StrLen(env, &bitsLen);
        if (bitsLen > 0)
        {
            Context->profiler.timeEnable = (env[0] == '1');
        }
        else
        {
            Context->profiler.timeEnable = gcvTRUE;
        }
        if (bitsLen > 1)
        {
            Context->profiler.memEnable = (env[1] == '1');
        }
        else
        {
            Context->profiler.memEnable = gcvTRUE;
        }
        if (bitsLen > 4)
        {
            Context->profiler.drvEnable = (env[4] == '1');
        }
        else
        {
            Context->profiler.drvEnable = gcvTRUE;
        }
    }

    Context->profiler.enable = gcvTRUE;

#if gcdNEW_PROFILER_FILE
    {
        /* Write Generic Info. */
        char* infoCompany = "Vivante Corporation";
        char* infoVersion = "1.0";
        char  infoRevision[255] = {'\0'};   /* read from hw */
        char* infoRenderer = Context->chipName;
        char* infoDriver = "OpenVG 1.1";
        gctUINT offset = 0;
        rev = Context->revision;
#define BCD(digit)      ((rev >> (digit * 4)) & 0xF)
        gcoOS_MemFill(infoRevision, 0, gcmSIZEOF(infoRevision));
        gcoOS_MemFill(infoRevision, 0, gcmSIZEOF(infoRevision));
        if (BCD(3) == 0)
        {
            /* Old format. */
            gcoOS_PrintStrSafe(infoRevision, gcmSIZEOF(infoRevision),
                &offset, "revision=\"%d.%d\" ", BCD(1), BCD(0));
        }
        else
        {
            /* New format. */
            gcoOS_PrintStrSafe(infoRevision, gcmSIZEOF(infoRevision),
                &offset, "revision=\"%d.%d.%d_rc%d\" ",
                BCD(3), BCD(2), BCD(1), BCD(0));
        }


        gcmWRITE_CONST(VPG_INFO);

        gcmWRITE_CONST(VPC_INFOCOMPANY);
        gcmWRITE_STRING(infoCompany);
        gcmWRITE_CONST(VPC_INFOVERSION);
        gcmWRITE_STRING(infoVersion);
        gcmWRITE_CONST(VPC_INFORENDERER);
        gcmWRITE_STRING(infoRenderer);
        gcmWRITE_CONST(VPC_INFOREVISION);
        gcmWRITE_STRING(infoRevision);
        gcmWRITE_CONST(VPC_INFODRIVER);
        gcmWRITE_STRING(infoDriver);

        gcmWRITE_CONST(VPG_END);
    }
#else
    /* Print generic info */
    _Print(Context, "<GenericInfo company=\"Vivante Corporation\" "
		"version=\"%d.%d\" renderer=\"%s\" ",
		1, 0, Context->chipName);

   	rev = Context->revision;
#define BCD(digit)		((rev >> (digit * 4)) & 0xF)
   	if (BCD(3) == 0)
   	{
   		/* Old format. */
   		_Print(Context, "revision=\"%d.%d\" ", BCD(1), BCD(0));
   	}
   	else
   	{
   		/* New format. */
   		_Print(Context, "revision=\"%d.%d.%d_rc%d\" ",
   			   BCD(3), BCD(2), BCD(1), BCD(0));
   	}
    _Print(Context, "driver=\"%s\" />\n", "OpenVG 1.1");
#endif

	gcoOS_GetTime(&Context->profiler.frameStart);
    Context->profiler.frameStartTimeusec     = Context->profiler.frameStart;
    Context->profiler.primitiveStartTimeusec = Context->profiler.frameStart;
	gcoOS_GetCPUTime(&Context->profiler.frameStartCPUTimeusec);
}
예제 #13
0
 **********************************************************************/

#if defined(__USBCDC__)

const USB_DEVICE_DESCRIPTOR usb_device = {
    //sizeof(usb_device)
    sizeof(USB_DEVICE_DESCRIPTOR),              // Size of this descriptor in bytes
    USB_DESCRIPTOR_DEVICE,                      // DEVICE descriptor type
    0x0200,                                     // USB Spec Release Number in BCD format
    CDC_DEVICE,                                 // Class Code CDC_DEVICE
    0x00,                                       // Subclass code, unused at this time
    0x00,                                       // Protocol code, unused at this time
    USB_EP0_BUFF_SIZE,                          // Max packet size for EP0
    0x04D8,                                     // Vendor ID
    0xFEAB,                                     // Product ID: PINGUINO USB CDC
    (BCD(CDC_MAJOR_VER)<<8)|BCD(CDC_MINOR_VER), // Version Number
    1,                                          // Manufacturer string index
    2,                                          // Product string index
    3,                                          // Device serial number string index
    CDC_CONFIG_NUM                              // Number of possible configurations
};

/*
 * Configuration #1 descriptor
 */

// Total length in chars of data returned
#define CONFIGURATION_TOTAL_LENGTH (sizeof(USB_CONFIGURATION_DESCRIPTOR) + \
                                    sizeof(USB_INTERFACE_DESCRIPTOR) + \
                                    sizeof(USB_CDC_HEADER_FN_DSC) + \
                                    sizeof(USB_CDC_ACM_FN_DSC) + \