Created
May 13, 2025 09:05
-
-
Save sh1ma/e106e4503e9bbb1bcc1dbc151e9bc202 to your computer and use it in GitHub Desktop.
32-bit compressed EISA type ID decode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def decode_eisa_id(eisa_id: int): | |
| eisa_id = int.from_bytes(eisa_id.to_bytes(4, "little"), "big") | |
| vendor = "" | |
| vendor_bits = (eisa_id >> 16) & 0xFFFF | |
| char1_val = (vendor_bits >> 10) & 0x1F | |
| char2_val = (vendor_bits >> 5) & 0x1F | |
| char3_val = vendor_bits & 0x1F | |
| vendor += chr(char1_val + 0x40) | |
| vendor += chr(char2_val + 0x40) | |
| vendor += chr(char3_val + 0x40) | |
| product_id = eisa_id & 0xFFFF | |
| return f"{vendor}{product_id:04X}" | |
| id1 = 0x2A003434 | |
| id2 = 0x2B003434 | |
| print(f"0x{id1:08X} -> {decode_eisa_id(id1)}") | |
| print(f"0x{id2:08X} -> {decode_eisa_id(id2)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment