Ejemplo n.º 1
0
        void PushRegister(Register_t reg)
        {
            int size = registers.SizeOf(reg);

            switch (size)
            {
            case 8:
                uint64_t value64 = registers.Read <uint64_t>(reg);
                stack.Push(value64);
                break;

            case 4:
                uint32_t value32 = registers.Read <uint32_t>(reg);
                stack.Push(value32);
                break;

            case 2:
                uint16_t value16 = registers.Read <uint16_t>(reg);
                stack.Push(value16);
                break;

            case 1:
                uint8_t value8 = registers.Read <uint8_t>(reg);
                stack.Push(value8);
                break;
            }
        }
Ejemplo n.º 2
0
        public bool IsInfinite()
        {
            uint32_t d32 = AsUint32();

            return(((d32 & kExponentMask) == kExponentMask) &&
                   ((d32 & kSignificandMask) == 0));
        }
Ejemplo n.º 3
0
        public int get_fh_acess(nfs_fh4 file_handle)
        {
            uint32_t access = new uint32_t(0);

            //all acsses possible
            access.value = access.value +
                           NFSv4Protocol.ACCESS4_READ +
                           NFSv4Protocol.ACCESS4_LOOKUP +
                           NFSv4Protocol.ACCESS4_MODIFY +
                           NFSv4Protocol.ACCESS4_EXTEND +
                           NFSv4Protocol.ACCESS4_DELETE; //+
            //NFSv4Protocol.ACCESS4_EXECUTE;

            List <nfs_argop4> ops = new List <nfs_argop4>();


            ops.Add(SequenceStub.generateRequest(false, _sessionid.value,
                                                 _sequenceID.value.value, 12, 0));
            ops.Add(PutfhStub.generateRequest(file_handle));
            ops.Add(AcessStub.generateRequest(access));


            COMPOUND4res compound4res = sendCompound(ops, "");

            if (compound4res.status == nfsstat4.NFS4_OK)
            {
                return(compound4res.resarray[2].opaccess.resok4.access.value);
            }
            else
            {
                throw new NFSConnectionException(nfsstat4.getErrorString(compound4res.status));
            }
        }
Ejemplo n.º 4
0
        void PushRegister(Register_t reg)
        {
            int size = registers.SizeOf(reg);

            switch (size)
            {
            case 8:
                uint64_t value64 = registers.Read <uint64_t>(reg);
                System.Diagnostics.Debug.Assert(value64 != null);
                stack.Push(value64);
                break;

            case 4:
                uint32_t value32 = registers.Read <uint32_t>(reg);
                System.Diagnostics.Debug.Assert(value32 != null);
                stack.Push(value32);
                break;

            case 2:
                uint16_t value16 = registers.Read <uint16_t>(reg);
                System.Diagnostics.Debug.Assert(value16 != null);
                stack.Push(value16);
                break;

            case 1:
                uint8_t value8 = registers.Read <uint8_t>(reg);
                System.Diagnostics.Debug.Assert(value8 != null);
                stack.Push(value8);
                break;
            }
        }
Ejemplo n.º 5
0
        // Specialized decoding of the RC5 protocol.
        // In the future it would be nice to have a general manchester decoder.
        public bool decodeRC5(ref uint32_t value)
        {
            uint data = 0;
            int used = 0;
            _currentIndex = 1;  // Skip gap space

            if (_rawLen < IREncoding.MIN_RC5_SAMPLES + 2)
                return false;

            // Get start bits
            if (getRClevel(ref used, IREncoding.RC5_T1) != 1)
                return false;
            if (getRClevel(ref used, IREncoding.RC5_T1) != 0)
                return false;
            if (getRClevel(ref used, IREncoding.RC5_T1) != 1)
                return false;

            for (int nbits = 0; _currentIndex < _rawLen; nbits++)
            {
                int levelA = getRClevel(ref used, IREncoding.RC5_T1);
                int levelB = getRClevel(ref used, IREncoding.RC5_T1);

                if ((levelA == 0) && (levelB == 1))
                    data = (data << 1) | 1;
                else if ((levelA == 1) && (levelB == 0))
                    data = (data << 1) | 0;
                else
                    return false;
            }

            // Success
            value = data;
            return true;
        }
Ejemplo n.º 6
0
        public override uint32_t GetDisplayId(string pchBuffer, uint32_t unBufferLen)
        {
            CheckIfUsable();
            uint32_t result = NativeEntrypoints.SteamAPI_IHmd_GetDisplayId(m_hmd, pchBuffer, unBufferLen);

            return(result);
        }
Ejemplo n.º 7
0
        void _out()
        {
            uint32_t port    = registers.Read <uint32_t>(Register.EAX);
            uint32_t address = registers.Read <uint32_t>(Register.EBX);
            uint32_t length  = registers.Read <uint32_t>(Register.ECX);

            Northbridge.WriteToPort(port, address, length);
        }
Ejemplo n.º 8
0
        void _in()
        {
            uint32_t port    = registers.Read <uint32_t>(Register.EAX);
            uint32_t address = registers.Read <uint32_t>(Register.EBX);
            uint32_t buffer  = registers.Read <uint32_t>(Register.ECX);

            Northbridge.ReadFromPort(port, address, buffer);
        }
Ejemplo n.º 9
0
        void CPUID()
        {
            uint32_t eax = registers.Read <uint32_t>(Register.EAX);
            uint32_t ebx, ecx, edx;

            byte[] str = new byte[4];
            switch (eax.Value)
            {
            case 0:
                List <byte> name = new List <byte>(Encoding.ASCII.GetBytes(Name));
                while (name.Count < 12)
                {
                    name.Add(32);
                }
                while (name.Count > 12)
                {
                    name.RemoveAt(name.Count - 1);
                }

                byte[] bName = name.ToArray();
                Array.Copy(bName, str, 4);
                ebx = new uint32_t(str);
                Array.Copy(bName, 4, str, 0, 4);
                ecx = new uint32_t(str);
                Array.Copy(bName, 8, str, 0, 4);
                edx = new uint32_t(str);

                registers.Write(Register.EBX, ebx);
                registers.Write(Register.ECX, ecx);
                registers.Write(Register.EDX, edx);
                break;

            case 1:
                List <byte> speed = new List <byte>(Encoding.ASCII.GetBytes(string.Format("{0:F2} Hz\0", Speed)));
                while (speed.Count < 12)
                {
                    speed.Add(32);
                }
                while (speed.Count > 12)
                {
                    speed.RemoveAt(speed.Count - 1);
                }

                byte[] bSpeed = speed.ToArray();
                Array.Copy(bSpeed, str, 4);
                ebx = new uint32_t(str);
                Array.Copy(bSpeed, 4, str, 0, 4);
                ecx = new uint32_t(str);
                Array.Copy(bSpeed, 8, str, 0, 4);
                edx = new uint32_t(str);

                registers.Write(Register.EBX, ebx);
                registers.Write(Register.ECX, ecx);
                registers.Write(Register.EDX, edx);
                break;
            }
        }
Ejemplo n.º 10
0
        public static nfs_argop4 generateRequest(uint32_t acessargs)
        {
            nfs_argop4 op = new nfs_argop4();

            op.argop = nfs_opnum4.OP_ACCESS;

            op.opaccess        = new ACCESS4args();
            op.opaccess.access = acessargs;

            return(op);
        }
Ejemplo n.º 11
0
    public static nfs_argop4 generateRequest(uint32_t acessargs) {


        nfs_argop4 op = new nfs_argop4();
        op.argop = nfs_opnum4.OP_ACCESS;

        op.opaccess = new ACCESS4args();
        op.opaccess.access = acessargs;

        return op;

    }
Ejemplo n.º 12
0
        public int Exponent()
        {
            if (IsDenormal())
            {
                return(kDenormalExponent);
            }

            uint32_t d32      = AsUint32();
            int      biased_e = (int)((d32 & kExponentMask) >> kPhysicalSignificandSize);

            return(biased_e - kExponentBias);
        }
Ejemplo n.º 13
0
        public uint32_t Significand()
        {
            uint32_t d32         = AsUint32();
            uint32_t significand = d32 & kSignificandMask;

            if (!IsDenormal())
            {
                return(significand + kHiddenBit);
            }
            else
            {
                return(significand);
            }
        }
Ejemplo n.º 14
0
        public static JSValue JS_NewUint32(JSContext ctx, uint32_t val)
        {
            JSValue v;

            if (val <= 0x7fffffff)
            {
                v = JS_NewInt32(ctx, (int)val);
            }
            else
            {
                v = __JS_NewFloat64(ctx, val);
            }

            return(v);
        }
Ejemplo n.º 15
0
    //-----------------------------------------------------------------------------
    // Purpose: Helper to get a string from a tracked device property and turn it
    //			into a std::string
    //-----------------------------------------------------------------------------
    public static string GetTrackedDeviceString(vr.IVRSystem pHmd, vr.TrackedDeviceIndex_t unDevice, vr.TrackedDeviceProperty prop, vr.TrackedPropertyError peError = null)
    {
        uint32_t unRequiredBufferLen = pHmd.GetStringTrackedDeviceProperty(unDevice, prop, null, 0, peError);

        if (unRequiredBufferLen == 0)
        {
            return("");
        }

        string pchBuffer = new string(new char[unRequiredBufferLen - 1]);

        unRequiredBufferLen = pHmd.GetStringTrackedDeviceProperty(unDevice, prop, pchBuffer, unRequiredBufferLen, peError);
        string sResult = ((char)pchBuffer).ToString();

        pchBuffer = null;
        return(sResult);
    }
Ejemplo n.º 16
0
        public bool decodePulseModulation(PulseModulationEncoding encoding, ref uint32_t value)
        {
            _currentIndex = 0;
            value = 0;

            // Skip leading space
            getNextInterval();

            // Match the header
            if (encoding.headerMark != 0) {
                if (!matchMark(getNextInterval(), encoding.headerMark)) {
                    return false;
                }

                if (!matchSpace(getNextInterval(), encoding.headerSpace)) {
                    return false;
                }
            }

            // Match the data
            for (int i = 0; i < (int)encoding.numBits; i++) {
                uint16_t mark = getNextInterval();
                uint16_t space = getNextInterval();

                if (matchMark(mark, encoding.oneMark) &&
                    matchSpace(space, encoding.oneSpace)) {
                    value = (value << 1) | 1;
                } else if (matchMark(mark, encoding.zeroMark) &&
                           matchSpace(space, encoding.zeroSpace)) {
                    value <<= 1;
                } else {
                    return false;
                }
            }

            // Match the stop mark
            if (encoding.stopMark != 0) {
                if (!matchMark(getNextInterval(), encoding.stopMark)) {
                    return false;
                }
            }

            // Success!
            return true;
        }
Ejemplo n.º 17
0
    public static vector <case_t> read_test_cases()
    {
        vector <case_t> cases = new vector <case_t>();

        uint8_t train_image  = read_file("train-images.idx3-ubyte");
        uint8_t train_labels = read_file("train-labels.idx1-ubyte");

        uint32_t case_count = byteswap_uint32((uint32_t)(train_image + 4));

        for (int i = 0; i < case_count; i++)
        {
            case_t c = new case_t(new tensor_t <float>(28, 28, 1), new tensor_t <float>(10, 1, 1));

            uint8_t[] img   = train_image + 16 + i * (28 * 28);
            uint8_t   label = train_labels + 8 + i;

            for (int x = 0; x < 28; x++)
            {
                for (int y = 0; y < 28; y++)
                {
                    c.data.functorMethod(x, y, 0) = img[x + y * 28] / 255.0f;
                }
            }

            for (int b = 0; b < 10; b++)
            {
                [email protected](b, 0, 0) = label == b != 0 ? 1.0f : 0.0f;
            }

            cases.push_back(c);
        }
        train_image  = null;
        train_labels = null;

        return(cases);
    }
Ejemplo n.º 18
0
public abstract uint32_t GetDriverId(string pchBuffer,uint32_t unBufferLen);
Ejemplo n.º 19
0
internal static extern void SteamAPI_IHmd_GetWindowBounds(IntPtr instancePtr, ref int32_t pnX, ref int32_t pnY, ref uint32_t pnWidth, ref uint32_t pnHeight);
Ejemplo n.º 20
0
 public static extern JSValue JS_GetPropertyUint32(JSContext ctx, JSValueConst this_obj, uint32_t idx);
Ejemplo n.º 21
0
public abstract void GetRecommendedRenderTargetSize(out uint32_t pnWidth,out uint32_t pnHeight);
Ejemplo n.º 22
0
internal static extern void SteamAPI_IHmd_GetRecommendedRenderTargetSize(IntPtr instancePtr, ref uint32_t pnWidth, ref uint32_t pnHeight);
Ejemplo n.º 23
0
public abstract void GetEyeOutputViewport(vr::Hmd_Eye eEye,out uint32_t pnX,out uint32_t pnY,out uint32_t pnWidth,out uint32_t pnHeight);
Ejemplo n.º 24
0
public override void GetWindowBounds(out int32_t pnX,out int32_t pnY,out uint32_t pnWidth,out uint32_t pnHeight)
{
	CheckIfUsable();
	NativeEntrypoints.SteamAPI_IHmd_GetWindowBounds(m_hmd,ref pnX,ref pnY,ref pnWidth,ref pnHeight);
}
Ejemplo n.º 25
0
 public static extern int JS_SetPropertyUint32(JSContext ctx, JSValueConst this_obj, uint32_t idx, JSValue val);
Ejemplo n.º 26
0
 public static extern JS_BOOL JSB_ToUint32(JSContext ctx, out uint32_t pres, JSValueConst val);
Ejemplo n.º 27
0
public override uint32_t GetDisplayId(string pchBuffer,uint32_t unBufferLen)
{
	CheckIfUsable();
	uint32_t result = NativeEntrypoints.SteamAPI_IHmd_GetDisplayId(m_hmd,pchBuffer,unBufferLen);
	return result;
}
Ejemplo n.º 28
0
 public static extern void obs_display_set_background_color(obs_display_t display, uint32_t color);
Ejemplo n.º 29
0
internal static extern void SteamAPI_IHmd_GetEyeOutputViewport(IntPtr instancePtr, vr::Hmd_Eye eEye, ref uint32_t pnX, ref uint32_t pnY, ref uint32_t pnWidth, ref uint32_t pnHeight);
Ejemplo n.º 30
0
        public int IREncode(byte protocol, uint32_t value,byte[] data, byte maxLen)
        {
            for (int i = 0; i < NUM_IR_ENCODINGS; i++)
            {
                if (IREncodings[i].protocol == protocol)
                {
                    return encodePulseModulation(IREncodings[i], value,
                        data, maxLen);
                }
            }

            return 0;
        }
Ejemplo n.º 31
0
        static int encodePulseModulation(PulseModulationEncoding encoding,
                                            uint32_t data, uint8_t[] rawData, uint8_t maxLen)
        {

            // Index 0 is a space. Set it to 0 length.
            rawData[0] = 0;
            int length = 1;

            if ((encoding.headerMark != 0) && (length + 2 < maxLen))
            {
                rawData[length++] = (byte)(encoding.headerMark / USECPERTICK);
                rawData[length++] = (byte)(encoding.headerSpace / USECPERTICK);
            }

            for (int i = encoding.numBits - 1; i >= 0 && length + 2 < maxLen; i--)
            {
                if ((data & (1 << i)) != 0)
                {
                    rawData[length++] = (byte)(encoding.oneMark / USECPERTICK);
                    rawData[length++] = (byte)(encoding.oneSpace / USECPERTICK);
                }
                else {
                    rawData[length++] = (byte)(encoding.zeroMark / USECPERTICK);
                    rawData[length++] = (byte)(encoding.zeroSpace / USECPERTICK);
                }
            }

            if ((encoding.stopMark != 0) && length < maxLen)
            {
                rawData[length++] = (byte)(encoding.stopMark / USECPERTICK);
            }

            return length;
        }
Ejemplo n.º 32
0
internal static extern uint32_t SteamAPI_IHmd_GetDisplayId(IntPtr instancePtr, string pchBuffer, uint32_t unBufferLen);
Ejemplo n.º 33
0
public override void GetRecommendedRenderTargetSize(out uint32_t pnWidth,out uint32_t pnHeight)
{
	CheckIfUsable();
	NativeEntrypoints.SteamAPI_IHmd_GetRecommendedRenderTargetSize(m_hmd,ref pnWidth,ref pnHeight);
}
Ejemplo n.º 34
0
 public static extern unsafe int JS_GetOwnPropertyNames(JSContext ctx, out JSPropertyEnum *ptab, out uint32_t plen, JSValueConst obj, JSGPNFlags flags);
Ejemplo n.º 35
0
        // Returns true if the single is a denormal.
        public bool IsDenormal()
        {
            uint32_t d32 = AsUint32();

            return((d32 & kExponentMask) == 0);
        }
Ejemplo n.º 36
0
 public Single(float f)
 {
     this.d32_ = new UnionFloatUInt {
         f = f
     }.u32;
 }
Ejemplo n.º 37
0
public override void GetEyeOutputViewport(vr::Hmd_Eye eEye,out uint32_t pnX,out uint32_t pnY,out uint32_t pnWidth,out uint32_t pnHeight)
{
	CheckIfUsable();
	NativeEntrypoints.SteamAPI_IHmd_GetEyeOutputViewport(m_hmd,eEye,ref pnX,ref pnY,ref pnWidth,ref pnHeight);
}
Ejemplo n.º 38
0
 public static extern void gs_draw(gs_draw_mode draw_mode, uint32_t start_vert, uint32_t num_verts);
Ejemplo n.º 39
0
public abstract uint32_t GetDisplayId(string pchBuffer,uint32_t unBufferLen);
Ejemplo n.º 40
0
        // We consider denormals not to be special.
        // Hence only Infinity and NaN are special.
        public bool IsSpecial()
        {
            uint32_t d32 = AsUint32();

            return((d32 & kExponentMask) == kExponentMask);
        }
Ejemplo n.º 41
0
 public static extern void gs_clear(uint32_t clear_flags, out Vector4 color, float depth, uint8_t stencil);
Ejemplo n.º 42
0
        public int Sign()
        {
            uint32_t d32 = AsUint32();

            return((d32 & kSignMask) == 0 ? 1 : -1);
        }
Ejemplo n.º 43
0
 public static extern obs_display_t obs_display_create(ref gs_init_data graphics_data, uint32_t background_color);
Ejemplo n.º 44
0
 public void deserialize(BinaryReader reader)
 {
     id = reader.ReadUInt32();
 }
Ejemplo n.º 45
0
public abstract void GetWindowBounds(out int32_t pnX,out int32_t pnY,out uint32_t pnWidth,out uint32_t pnHeight);
Ejemplo n.º 46
0
 public static extern void obs_display_resize(obs_display_t display, uint32_t cx, uint32_t cy);
Ejemplo n.º 47
0
 public static extern gs_vertbuffer_t gs_vertexbuffer_create(out gs_vb_data data, uint32_t flags);
Ejemplo n.º 48
0
 public static extern JSValue jsb_new_bridge_value(JSContext ctx, JSValue proto, uint32_t size);
Ejemplo n.º 49
0
        // Specialized decoding of the RC6 protocol.
        // In the future it would be nice to have a general manchester decoder.
        public bool decodeRC6(ref uint32_t value)
        {
            uint data = 0;
            int used = 0;
            _currentIndex = 1;  // Skip first space

            if (_rawLen < IREncoding.MIN_RC6_SAMPLES)
                return false;

            // Initial mark
            if (!matchMark(_rawData[_currentIndex++], IREncoding.RC6_HDR_MARK))
                return false;

            if (!matchSpace(_rawData[_currentIndex++], IREncoding.RC6_HDR_SPACE))
                return false;

            // Get start bit (1)
            if (getRClevel(ref used, IREncoding.RC6_T1) != 1)
                return false;

            if (getRClevel(ref used, IREncoding.RC6_T1) != 0)
                return false;

            for (int nbits = 0; _currentIndex < _rawLen; nbits++)
            {
                int levelA, levelB;  // Next two levels

                levelA = getRClevel(ref used, IREncoding.RC6_T1);
                if (nbits == 3)
                {
                    // T bit is double wide; make sure second half matches
                    if (levelA != getRClevel(ref used, IREncoding.RC6_T1)) return false;
                }

                levelB = getRClevel(ref used, IREncoding.RC6_T1);
                if (nbits == 3)
                {
                    // T bit is double wide; make sure second half matches
                    if (levelB != getRClevel(ref used, IREncoding.RC6_T1)) return false;
                }

                if ((levelA == 1) && (levelB == 0))
                    data = (data << 1) | 1;  // inverted compared to RC5
                else if ((levelA == 0) && (levelB == 1))
                    data = (data << 1) | 0;  // ...
                else
                    return false;            // Error
            }

            // Success
            value = data;
            return true;
        }