Exemple #1
0
        /// <summary>
        /// Load acpi objects from dll
        /// </summary>
        private void InitializeAcpiObjects()
        {
            InitializeAcpiTables();
            if (acpiLib == null)
            {
                return;
            }
            if (acpiLib.DriverLoaded())
            {
                statusStrip1.Items[0].Text = "Online Mode";
            }
            else
            {
                statusStrip1.Items[0].Text = "Offline Mode";
                //statusStrip1.Items.Add("Offline Mode");
                //statusStrip1.Text = "Offline Mode";
            }
            TreeNode root = acpiView.Nodes.Add("Acpi Namespace");
            //TreeNode root = root.Add("Acpi Namespace");
            TreeNode acpi_root = root.Nodes.Add("\\___ (Uninitialized)");

            acpi_root.Tag  = "\\___";
            acpi_root.Name = "\\___";
            BuildAcpiObjects(acpi_root, "\\___");
            //acpi_root.Expand();
            root.Expand();
            acpi_root.Expand();
        }
Exemple #2
0
        /// <summary>
        /// query a acpi data
        /// </summary>
        /// <param name="Path">path of acpi name</param>
        /// <param name="Name">acpi name</param>
        public void QueryData(string Path, string Name)
        {
            string Root = Path;

            // when driver loaded just to a evaluation to get the value in runtime
            if (acpiLib == null)
            {
                return;
            }

            int nameType = acpiLib.GetTypeFromPath(ref Root, Name);

            if (nameType == -1)
            {
                // did not find the AcpiNS from current and uplevel
                return;
            }
            // TODO: NSKNKS Enhance the acpi type code
            switch (nameType)
            {
            case 1:
                GetInt(Root + Name);
                break;

            case 2:
                GetString(Root + Name);
                break;

            case 3:
                GetBuffer(Root + Name);
                break;

            case 4:
                GetPackage(Root + Name);
                break;

            case 0xE:       // buffer field
            case 5:         // operation region feild
                this.Type = AcpiDataType.Int;
                if (acpiLib != null && acpiLib.DriverLoaded())
                {
                    // Driver is loaded get the value
                    IntPtr output = acpiLib.GetEvalOutput(Root + Name);
                    if (output != IntPtr.Zero)
                    {
                        FromAcpiOutput(output);
                    }

                    //if (GetBuffer(Root + Name, 5))
                    //{
                    //    // get the returned package from driver...
                    //    // display if possible
                    //    Log.Logs(this.bpValue);
                    //    DbgMessage("ERR 1");
                    //} else
                    //{
                    //    DbgMessage(Root + Name);
                    //}

                    //GetPackage(Root + Name);
                    //string result = "";
                    //if (acpiLib.GetEvalResult(Root + Name, ref result))
                    //{
                    //    //
                    //    result = result.Replace(" ", "");
                    //    result = result.Replace("\t", " ");
                    //    result = result.Replace("\r", " ");
                    //    result = result.Replace("\n", " ");
                    //    result = result.Replace("\t", " ");
                    //    // clear text
                    //    string[] values = result.Split(new char[] { ':' });
                    //    if (values != null && values.Length > 1)
                    //    {
                    //        switch (values[0])
                    //        {
                    //            // it's a integer
                    //            case "Integer":
                    //                UInt64 intValue = 0;
                    //                if (values[1].Contains("("))
                    //                {
                    //                    values[1] = values[1].Substring(0, values[1].IndexOf('('));
                    //                }
                    //                if (!IsIntString(values[1], ref intValue))
                    //                {
                    //                    DbgMessage("Not a integer");
                    //                } else
                    //                {
                    //                    this.Value = intValue;
                    //                }
                    //                break;
                    //            case "String":
                    //                this.strValue = values[1];
                    //                break;
                    //            default:
                    //                DbgMessage("ERR 2" + result);
                    //                break;
                    //        }
                    //    } else
                    //    {
                    //        if (values == null)
                    //        {
                    //            DbgMessage("ERR 1" + result);
                    //        } else
                    //        {
                    //            DbgMessage("ERR 1" + values.Length.ToString());
                    //        }
                    //    }
                    //}
                }
                break;

            case 9:
                this.Type = AcpiDataType.Mutex;
                break;
            }
            //if (nameType > 0 && nameType < 5)
            //{
            //    // Get Int, String, Buffer and Package data
            //    ushort nType = (ushort)nameType;
            //    IntPtr intPtr = acpiLib.GetValue(Root + Name, ref nType);

            //}

            if (acpiLib != null && acpiLib.DriverLoaded())
            {
                if (Type == AcpiDataType.FieldUnit)
                {
                    // it's field unit, need to get the refer Field and
                    // OpRegion information for method step debug at offline mode
                    // OpRegion need to put a virtual value for offline debug mode
                    // get the FieldRoot, off line mode only care about the width and offset
                    // dont need to care about the access mode
                    // int nameType = acpiLib.GetTypeFromPath(ref Root, Name);
                }
            }
        }