Esempio n. 1
0
	bool DebugLayer::create_test_triangle(void)
	{
		HRESULT res;
		D3D11_BUFFER_DESC buf_desc;
		D3D11_SUBRESOURCE_DATA initial_data;
		Vector3 verts[3];

		buf_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
		buf_desc.ByteWidth = sizeof(Vector3) * 3;
		buf_desc.CPUAccessFlags = 0;
		buf_desc.MiscFlags = 0;
		buf_desc.StructureByteStride = 0;
		buf_desc.Usage = D3D11_USAGE_DEFAULT;

		memset(&initial_data, 0, sizeof(D3D11_SUBRESOURCE_DATA));
		initial_data.pSysMem = &verts;
		
		if (FAILED(res = this->renderer->GetDevice()->CreateBuffer(
			&buf_desc,
			&initial_data,
			&this->test_tri_vbuffer)))
		{
			log_str("CreateBuffer error: %s\n", get_err_str(res));
			return false;
		}
	
	}
Esempio n. 2
0
static int
query_dev_property(HANDLE hdevice,
                   union STORAGE_DEVICE_DESCRIPTOR_DATA * data)
{
    DWORD num_out, err;
    char b[256];
    STORAGE_PROPERTY_QUERY query = {StorageDeviceProperty,
                                    PropertyStandardQuery, {0} };

    memset(data, 0, sizeof(*data));
    if (! DeviceIoControl(hdevice, IOCTL_STORAGE_QUERY_PROPERTY,
                          &query, sizeof(query), data, sizeof(*data),
                          &num_out, NULL)) {
        if (verbose > 2) {
            err = GetLastError();
            fprintf(stderr, "  IOCTL_STORAGE_QUERY_PROPERTY(Devprop) failed, "
                    "Error=%u %s\n", (unsigned int)err,
                    get_err_str(err, sizeof(b), b));
        }
        return -ENOSYS;
    }

    if (verbose > 3)
        fprintf(stderr, "  IOCTL_STORAGE_QUERY_PROPERTY(DevProp) "
                "num_out=%u\n", (unsigned int)num_out);
    return 0;
}
Esempio n. 3
0
static int
query_dev_uid(HANDLE hdevice, union STORAGE_DEVICE_UID_DATA * data)
{
    DWORD num_out, err;
    char b[256];
    STORAGE_PROPERTY_QUERY query = {StorageDeviceUniqueIdProperty,
                                    PropertyStandardQuery, {0} };

    memset(data, 0, sizeof(*data));
    num_out = 0;
    query.QueryType = PropertyExistsQuery;
    if (! DeviceIoControl(hdevice, IOCTL_STORAGE_QUERY_PROPERTY,
                          &query, sizeof(query), NULL, 0, &num_out, NULL)) {
        if (verbose > 2) {
            err = GetLastError();
            fprintf(stderr, "  IOCTL_STORAGE_QUERY_PROPERTY(DevUid(exists)) "
                    "failed, Error=%u %s\n", (unsigned int)err,
                    get_err_str(err, sizeof(b), b));
        }
        if (verbose > 3)
            fprintf(stderr, "      num_out=%u\n", (unsigned int)num_out);
        /* interpret any error to mean this property doesn't exist */
        return 0;
    }

    query.QueryType = PropertyStandardQuery;
    if (! DeviceIoControl(hdevice, IOCTL_STORAGE_QUERY_PROPERTY,
                          &query, sizeof(query), data, sizeof(*data),
                          &num_out, NULL)) {
        if (verbose > 2) {
            err = GetLastError();
            fprintf(stderr, "  IOCTL_STORAGE_QUERY_PROPERTY(DevUid) failed, "
                    "Error=%u %s\n", (unsigned int)err,
                    get_err_str(err, sizeof(b), b));
        }
        return -ENOSYS;
    }
    if (verbose > 3)
        fprintf(stderr, "  IOCTL_STORAGE_QUERY_PROPERTY(DevUid) num_out=%u\n",
                (unsigned int)num_out);
    return 0;
}
Esempio n. 4
0
static int
enum_pds(void)
{
    int k;
    int hole_count = 0;
    HANDLE fh;
    DWORD err;
    char adapter_name[64];
    char b[256];
    struct storage_elem tmp_se;

    if (verbose > 2)
        fprintf(stderr, "%s: enter\n", __func__);
    for (k = 0; k < MAX_PHYSICALDRIVE_NUM; ++k) {
        memset(&tmp_se, 0, sizeof(tmp_se));
        snprintf(adapter_name, sizeof (adapter_name),
                 "\\\\.\\PhysicalDrive%d", k);
        snprintf(tmp_se.name, sizeof(tmp_se.name), "PD%d", k);
        fh = CreateFile(adapter_name, GENERIC_READ | GENERIC_WRITE,
                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                        OPEN_EXISTING, 0, NULL);
        if (fh != INVALID_HANDLE_VALUE) {
            if (query_dev_property(fh, &tmp_se.qp_descriptor) < 0)
                fprintf(stderr, "%s: query_dev_property failed\n", __func__);
            else
                tmp_se.qp_descriptor_valid = 1;
            if (query_dev_uid(fh, &tmp_se.qp_uid) < 0) {
                if (verbose > 2)
                    fprintf(stderr, "%s: query_dev_uid failed\n", __func__);
            } else
                tmp_se.qp_uid_valid = 1;
            hole_count = 0;
            memcpy(&storage_arr[next_unused_elem++], &tmp_se, sizeof(tmp_se));
            CloseHandle(fh);
        } else {
            err = GetLastError();
            if (ERROR_SHARING_VIOLATION == err)
                fprintf(stderr, "%s: in use by other process (sharing "
                        "violation [34])\n", adapter_name);
            else if (verbose > 3)
                fprintf(stderr, "%s: CreateFile failed err=%u\n\t%s",
                        adapter_name, (unsigned int)err,
                        get_err_str(err, sizeof(b), b));
            if (++hole_count >= MAX_HOLE_COUNT)
                break;
        }
    }
    return 0;
}
Esempio n. 5
0
static int
enum_scsi_adapters(void)
{
    int k, j;
    int hole_count = 0;
    HANDLE fh;
    ULONG dummy;
    DWORD err;
    BYTE bus;
    BOOL success;
    char adapter_name[64];
    char inqDataBuff[8192];
    PSCSI_ADAPTER_BUS_INFO  ai;
    char b[256];

    for (k = 0; k < MAX_ADAPTER_NUM; ++k) {
        snprintf(adapter_name, sizeof (adapter_name), "\\\\.\\SCSI%d:", k);
        fh = CreateFile(adapter_name, GENERIC_READ | GENERIC_WRITE,
                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                        OPEN_EXISTING, 0, NULL);
        if (fh != INVALID_HANDLE_VALUE) {
            hole_count = 0;
            success = DeviceIoControl(fh, IOCTL_SCSI_GET_INQUIRY_DATA,
                                      NULL, 0, inqDataBuff,
                                      sizeof(inqDataBuff), &dummy, NULL);
            if (success) {
                PSCSI_BUS_DATA pbd;
                PSCSI_INQUIRY_DATA pid;
                int num_lus, off;

                ai = (PSCSI_ADAPTER_BUS_INFO)inqDataBuff;
                for (bus = 0; bus < ai->NumberOfBusses; bus++) {
                    pbd = ai->BusData + bus;
                    num_lus = pbd->NumberOfLogicalUnits;
                    off = pbd->InquiryDataOffset;
                    for (j = 0; j < num_lus; ++j) {
                        if ((off < (int)sizeof(SCSI_ADAPTER_BUS_INFO)) ||
                            (off > ((int)sizeof(inqDataBuff) -
                                    (int)sizeof(SCSI_INQUIRY_DATA))))
                            break;
                        pid = (PSCSI_INQUIRY_DATA)(inqDataBuff + off);
                        snprintf(b, sizeof(b) - 1, "SCSI%d:%d,%d,%d ", k,
                                 pid->PathId, pid->TargetId, pid->Lun);
                        printf("%-15s", b);
                        snprintf(b, sizeof(b) - 1, "claimed=%d pdt=%xh %s ",
                                 pid->DeviceClaimed,
                                 pid->InquiryData[0] % 0x3f,
                                 ((0 == pid->InquiryData[4]) ? "dubious" :
                                                               ""));
                        printf("%-26s", b);
                        printf("%.8s  %.16s  %.4s\n", pid->InquiryData + 8,
                               pid->InquiryData + 16, pid->InquiryData + 32);
                        off = pid->NextInquiryDataOffset;
                    }
                }
            } else {
                err = GetLastError();
                fprintf(stderr, "%s: IOCTL_SCSI_GET_INQUIRY_DATA failed "
                        "err=%u\n\t%s",
                        adapter_name, (unsigned int)err,
                        get_err_str(err, sizeof(b), b));
            }
            CloseHandle(fh);
        } else {
            err = GetLastError();
            if (ERROR_SHARING_VIOLATION == err)
                fprintf(stderr, "%s: in use by other process (sharing "
                        "violation [34])\n", adapter_name);
            else if (verbose > 3)
                fprintf(stderr, "%s: CreateFile failed err=%u\n\t%s",
                        adapter_name, (unsigned int)err,
                        get_err_str(err, sizeof(b), b));
            if (++hole_count >= MAX_HOLE_COUNT)
                break;
        }
    }
    return 0;
}
Esempio n. 6
0
/*******************************************************************************
 * main()
 *
 * description: Send alarm message to alarm manager
 *
 ******************************************************************************/
int main(int argc, char *argv[])
{
    int position = 500;
    //print_menu();


    //printf("> \n");

    mc_init("eth1");
    #if 0
    while (1)
    {
        char cmd;

        scanf("%c", &cmd);
        switch(cmd)
        {
            case 'a':
            {
                epl_init("eth1");
                break;
            }
            case 'b':
            {
                epl_reset();
                break;
            }
            case 'c':
            {
                mc_init("eth1");
                break;
            }
            case 'd':
            {
                mc_reset_error();
                break;
            }
            case 'e':
            {
                int edge;
                scanf("%d", &edge);
                int ret = mc_set_positive_end_position(edge);
                printf("ret = %d\n", ret);
                break;
            }
            case 'f':
            {
                int edge;
                scanf("%d", &edge);
                int ret = mc_set_negative_end_position(edge);
                printf("ret = %d\n", ret);
                break;
            }
            case 'g':
            {
            	int cnt = 0;
            	while(cnt++<100)
            	{
                int ret = mc_move_absolute(1800,40,20,20,0);
                if(ret != 0)
                {
                	printf("ret = %d\n", ret);
                	PrintMCStatus();
                	break;
                }
                ret = mc_stop(10000);
                if(ret != 0)
                {
                	printf("ret = %d\n", ret);   
                	PrintMCStatus();   
                	break;
                }
                ret = mc_move_absolute(-1700,40,20,20,0);
                if(ret != 0)
                {
                	printf("ret = %d\n", ret);
                	PrintMCStatus();
                	break;
                }
                ret = mc_stop(10000);
                if(ret != 0)
                {
                	printf("ret = %d\n", ret);   
                	PrintMCStatus();   
                	break;
                }   
                }       	
                break;
            }            
            case '1':
            {
                mc_power();
                break;
            }
            case '2':
            {
                mc_home(0, 0);
                break;
            }
            case '3':
            {
                int pos, velocity;
                scanf("%d %d", &pos, &velocity);
                printf("pos is %d, velocity is %d\n", pos,velocity);
                mc_move_absolute(pos,velocity,20,20,0);
                position += 500;
                break;
            }
            case '4':
            {
                mc_move_additive(50,100,20,20);
                break;
            }
            case '5':
            {
            	int velocity, direction;
                scanf("%d %d", &velocity, &direction);
                mc_move_velocity(50,100,20,direction);
                break;
            }
            case '6':
            {
                PrintMCStatus();

                break;
            }
            case '7':
            {
                int ret = mc_stop(0);
                
                printf("ret =  %d\n", ret);
                break;
            }
            case '8':
            {
                printf("position is  %d\n", mc_get_position());
                break;
            }
            case '9':
            {
                printf("velocity is  %d\n", mc_get_velocity());
                break;
            }
            case '0':
            {
                unsigned short id;
                char str_err[256];
                id = mc_get_error_id();
                get_err_str(id, str_err);
                printf("error id is  %d\n", id);
                printf("error id is  %s\n", str_err);

                break;
            }
            case 'x':
            case 'X':
            {
                return 0;
            }
            case 'h':
            case 'H':
            {
                print_menu();
                break;
            }
            default:
            {
                printf("> ");
                break;
            }
        }
    }
    #else
    while(1)
        sleep(5);
    #endif

    return 0;
}