Пример #1
0
        /** <summary>Convert a name that is either absolute or relative to the
         * current device to an absolute name in the namespace, and check we have
         * access to it (i.e. it is a subname of our current name)</summary> */
        Aml.ACPIName GetValidName(string name)
        {
            if (name == null)
            {
                return(null);
            }
            if (name.Length == 0)
            {
                name = "\\";
            }

            string act_name = null;

            if (name[0] == '\\')
            {
                act_name = name;
            }
            else if (name[0] == '.')
            {
                act_name = device.ToString() + name;
            }
            else
            {
                act_name = device.ToString() + "." + name;
            }

            Aml.ACPIName ret = act_name;

            /* Now check the new name is a subobject of the current device */
            if (ret.ElementCount < device.ElementCount)
            {
                return(null);
            }
            for (int i = 0; i < device.ElementCount; i++)
            {
                if (ret.NameElement(i).Equals(device.NameElement(i)) == false)
                {
                    return(null);
                }
            }

            return(ret);
        }
Пример #2
0
        public IList <Aml.ACPIName> GetDevices(int depth)
        {
            List <Aml.ACPIName> ret = new List <Aml.ACPIName>();

            foreach (var dev in acpi.n.Devices)
            {
                Aml.ACPIName dev_name = dev.Key;
                if (dev.Value.Initialized == false)
                {
                    continue;
                }

                /* Now check the new name is a subobject of the current device */
                if (dev_name.ElementCount < device.ElementCount)
                {
                    continue;
                }
                if (depth != -1 && dev_name.ElementCount > device.ElementCount + depth)
                {
                    continue;
                }

                bool subdevice = true;
                for (int i = 0; i < device.ElementCount; i++)
                {
                    if (dev_name.NameElement(i).Equals(device.NameElement(i)) == false)
                    {
                        subdevice = false;
                        break;
                    }
                }

                if (subdevice)
                {
                    ret.Add(dev_name);
                }
            }

            return(ret);
        }
Пример #3
0
 internal ACPIConfiguration(acpipc acpiDev, Aml.ACPIName deviceName)
 {
     acpi   = acpiDev;
     device = deviceName;
 }