1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 18:27:04 +03:00
systemd/hwdb/acpi-update.py
Federico Mena Quintero 3411164af3 hwdb: update UEFI/ACPI/PNP/EISA/EDID database from UEFI web site
Let's hook up the ACPI database we maintain from the upstream UEFI sources.
This adds a tool to convert the database provided upstream to our native
format, similar to how this is handled for the PCI and USB databases.

Note that the upstream web site claims to offer an XLS download, but the actual
data made available is an HTML file in reality, just one with the ".xls"
suffix...

The data provided from the UEFI folks is not very high quality nor complete,
hence apply a patch after the conversion step that fixes up a few things and
adds in more entries from various sources. For example, the EDID ids maintained
by GNOME and other sources have been added too, as they all appear to use the
same ID namespace.

This also adds explicit support for 4 character ACPI ids, in addition to the
normal 3 character PNP ids.

Also fixes:

https://bugs.freedesktop.org/show_bug.cgi?id=90524
2016-06-10 23:27:58 +02:00

80 lines
2.0 KiB
Python
Executable File

#!/usr/bin/python3
from html.parser import HTMLParser
from enum import Enum
class State(Enum):
NOWHERE = 0
COMPANY = 1
AFTER_COMPANY = 2
PNPID = 3
AFTER_PNPID = 4
DATE = 5
class PNPTableParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.state = State.NOWHERE
self.data = ""
self.pnpid = None
self.company = None
self.table = []
def handle_starttag(self, tag, attrs):
if tag == "td":
if self.state == State.NOWHERE:
self.state = State.COMPANY
elif self.state == State.AFTER_COMPANY:
self.state = State.PNPID
elif self.state == State.AFTER_PNPID:
self.state = State.DATE
else:
raise Error("Unexpected field")
self.data = ""
def handle_endtag(self, tag):
if tag == "td":
if self.state == State.COMPANY:
self.company = ' '.join(self.data.strip().split())
self.state = State.AFTER_COMPANY
elif self.state == State.PNPID:
self.pnpid = self.data.strip()
self.state = State.AFTER_PNPID
self.table.append((self.pnpid, self.company))
elif self.state == State.DATE:
self.state = State.NOWHERE
else:
raise Error("Unexpected field")
def handle_data(self, data):
self.data += data
def read_table(a):
parser = PNPTableParser()
for line in a:
parser.feed(line)
parser.close()
parser.table.sort()
for pnpid, company in parser.table:
print("\nacpi:{0}*:\n ID_VENDOR_FROM_DATABASE={1}".format(pnpid, company))
a = open("acpi_id_registry.html")
b = open("pnp_id_registry.html")
print('# This file is part of systemd.\n'
'#\n'
'# Data imported from:\n'
'# http://www.uefi.org/uefi-pnp-export\n'
'# http://www.uefi.org/uefi-acpi-export')
read_table(a)
read_table(b)