From 66289aa8ecfa07b20bad424eb9860b196641ef52 Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Fri, 19 Mar 2021 10:54:25 -0500 Subject: first commit --- tools/edid/bparse-edid | 16 ++++++++++++++++ tools/edid/desktop_edid | Bin 0 -> 128 bytes tools/edid/laptop_edid | Bin 0 -> 128 bytes tools/page/page.py | 29 +++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100755 tools/edid/bparse-edid create mode 100644 tools/edid/desktop_edid create mode 100644 tools/edid/laptop_edid create mode 100755 tools/page/page.py (limited to 'tools') diff --git a/tools/edid/bparse-edid b/tools/edid/bparse-edid new file mode 100755 index 0000000..9983102 --- /dev/null +++ b/tools/edid/bparse-edid @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument('edid_file', type=str, help="edid file") +args = parser.parse_args() + +f = open(args.edid_file, 'rb') +edid = f.read() +x = edid[56] | ((edid[58] & 0xf0) << 4) +y = edid[59] | ((edid[61] & 0xf0) << 4) + +print("resolution: {} x {}".format(x, y)) + +f.close() + diff --git a/tools/edid/desktop_edid b/tools/edid/desktop_edid new file mode 100644 index 0000000..a0e0ae3 Binary files /dev/null and b/tools/edid/desktop_edid differ diff --git a/tools/edid/laptop_edid b/tools/edid/laptop_edid new file mode 100644 index 0000000..1e011e3 Binary files /dev/null and b/tools/edid/laptop_edid differ diff --git a/tools/page/page.py b/tools/page/page.py new file mode 100755 index 0000000..03d8e32 --- /dev/null +++ b/tools/page/page.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +from math import ceil as c +def get_offsets(addr): + if addr % 4096: + print("You must align to 4096!") + return 0 + if addr > 2 ** 47: + print("Address too big!") + return 0 + + + pte = (addr >> 12) & 0x1ff + pde = (addr >> 21) & 0x1ff + pdpe =(addr >> 30) & 0x1ff + pml4 =(addr >> 39) & 0x1ff + print("pte:\t{}\npde:\t{}\npdpe:\t{}\npml4:\t{}".format(pte, pde, pdpe, pml4)) + +def get_table_size(addr): + pte_cnt = c(c(addr / (1 << 12)) / 512) * 512 + pde_cnt = c(c(addr / (1 << 21)) / 512) * 512 + pdpe_cnt = c(c(addr / (1 << 30)) / 512) * 512 + pml4_cnt = c(c(addr / (1 << 39)) / 512) * 512 + + + return((pte_cnt + pde_cnt + pdpe_cnt + pml4_cnt) * 8) + +ts = get_table_size(68719476736) +print(hex(ts)) + -- cgit v1.2.3