# Usage: mawk -f dtable.awk dump.hex # # Print BIOS disk type table from dump.hex # # Assumes input was generated from Paul Vojta's DEBUG.COM version 1.25. # # The original instructions referred to a different version of DEBUG.COM. # Unlike hdtypes.c, this script doesn't scan for the record signature. # This script unconditionally assumes the table starts at F000:E400. # # Adapted FROM: https://aeb.win.tue.nl/linux/hdtypes/hdtypes.c BEGIN { for (i = 0; i < 256; i++) { str = sprintf("%02X", i) hex[str] = i } # $1 (unused) is the last byte of the previous record # plus, AWK array indexes start at 1 where C starts at 0 # "drive" is a convenience array for this 2 byte offset for (i = 0; i < 16; i++) { drive[i] = i + 2 } entry = 1 printf "\nDisk table at FFFF:E400\n" printf "\n\tType\tCyl.\tHead\tSect.\tWrite\tLand\tCap (MB)\n" printf "\t\t\t\t\tp-comp\tZone\n" printf "\t----------------------------------------------------------\n" } /^F000:E[456]/ { $0 = substr($0, 11, 48) sub(/-/, " ") cyl = hex[$drive[1]] * 256 + hex[$drive[0]] heads = hex[$drive[2]] wpcom = hex[$drive[6]] * 256 + hex[$drive[5]] lz = hex[$drive[13]] * 256 + hex[$drive[12]] sect = hex[$drive[14]] cap = (cyl * heads * sect) / (2 * 1024) if (wpcom == 65535) { wpcom = -1 } if (cyl == 0) { printf "\t%2d\t-- not used or user defined --\n", entry } else if (cyl < 2048) { printf "\t%2d\t%4d\t%2d\t%2d\t%5d\t%4d\t%6d\n", entry, cyl, heads, sect, wpcom, lz, cap } entry++ }