Lines Matching +full:revision +full:- +full:id

1 #!/usr/bin/awk -f
3 #-
4 # Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org>
39 print "usage: bhnd_nvram_map.awk <input map> [-hd] [-o output file]"
66 # Maximum revision
74 if (ARGV[_i] == "--debug") {
76 } else if (ARGV[_i] == "-d" && OUT_T == null) {
78 } else if (ARGV[_i] == "-h" && OUT_T == null) {
80 } else if (ARGV[_i] == "-v") {
82 } else if (ARGV[_i] == "-o") {
88 } else if (ARGV[_i] == "--") {
91 } else if (ARGV[_i] !~ /^-/) {
102 print("error: one of -d or -h required")
111 if (OUTPUT_FILE == "-") {
127 UINT_REGEX = "^(0|[1-9][0-9]*)$"
128 HEX_REGEX = "^(0x[A-Fa-f0-9]+)$"
129 OFF_REGEX = "^(0|[1-9][0-9]*)|^(0x[A-Fa-f0-9]+)"
130 REL_OFF_REGEX = "^\\+(0|[1-9][0-9]*)|^\\+(0x[A-Fa-f0-9]+)"
132 ARRAY_REGEX = "\\[(0|[1-9][0-9]*)\\]"
135 IDENT_REGEX = "[A-Za-z_][A-Za-z0-9_]*"
195 SPROM_OP_BIND_SKIP_IN_MIN = -3 # minimum SKIP_IN value
238 MTypeVarID = macro_type_new("id", "_ID") # var unique ID
267 # User-specifiable value formats
294 Int8Min = -128
296 Int16Min = -32768
298 Int32Min = -2147483648
348 VAccessInternal = obj_new(VAccess) # Implementation-Internal
369 # Revision Range
388 # ID is assigned once all variables are sorted
400 class_add_prop(SromLayout, p_output_var_counts, # Map<int, int> (rev->count)
454 # This also has a side-effect of generating a unique monotonic ID
471 # Set all variable ID properties to their newly assigned ID value
545 # mapping SROM revision to corresponding SROM layout
562 # Sort in ascending order, by SROM revision
574 output_depth--
593 # Write all top-level bhnd_sprom_layout entries
602 output_depth--
635 output_depth--
639 # Write a top-level bhnd_sprom_layout entry for the given revision
641 function write_data_srom_layout(layout, revision, _flags, _size,
650 _sromcrc = srom_layout_find_entry(layout, "<sromcrc>", revision)
652 errorx("missing '<sromcrc>' entry for '"revision"' layout, " \
662 _sromsig = srom_layout_find_entry(layout, "<sromsig>", revision)
675 _sromrev = srom_layout_find_entry(layout, "sromrev", revision)
677 errorx("missing 'sromrev' entry for '"revision"' layout, " \
682 errorx("'sromrev' entry has non-u8 type '" \
694 emit(".rev = "revision",\n")
718 emit(".num_vars = " srom_layout_num_output_vars(layout, revision) ",\n")
722 output_depth--
785 # opc: The standard opcode for non-IMM encoded data, or null if none
799 # SHIFT_IMM -- the imm value must be positive and divisible by
808 # OFFSET_REL_IMM -- the imm value must be positive, divisible
820 _delta = value - _offset
826 sprintf("/* %#x + %#x -> %#x */\n", _offset,
845 # Can't encode as immediate; do we have a non-immediate form?
848 "non-immediate form was provided")
930 if (_vid_prev <= _vid && (_vid - _vid_prev) <= SPROM_OP_IMM_MAX) {
933 _vid - _vid_prev, null)
942 # Emit OPCODE_REV/OPCODE_REV_RANGE (if necessary) for a new revision range
958 # Sanity-check range values
962 # If range covers a single revision, and can be encoded within
997 # Encode (possibly a relative, 1-byte form) of the offset opcode
1101 "range %d-%d", skip_in,
1107 "range %d-%d", skip_out,
1168 _delta = _seg_offset - _bind_off
1201 # skip_out values of 1, and must contain no buffered post-BIND opcodes
1321 # The one-byte BINDN form requires encoding the count
1325 _count -= _count
1339 _count -= _written
1342 # The 1-byte BIND form can encode the same SKIP values
1343 # as the 2-byte BINDN, with a implicit count of 1
1350 _count--
1357 # Write any buffered post-BIND opcodes
1373 # Check the per-variable bind count to determine whether
1405 sprintf("/* bind (%s @ %#x -> %#x) */\n",
1460 # Encode revision switch. This resets variable state, so must
1464 # Encode variable ID
1468 # Write entry-specific array length (SROM layouts may define array
1485 output_depth--
1498 # sort by their variable's assigned ID (ascending).
1515 # Sanity check variable ID assignment
1517 errorx("missing variable ID for " obj_to_string(_var))
1522 # Sort entries by (variable ID, revision range), ascending
1540 output_depth--
1557 # Variable ID
1566 emit("/* ID constants provide an index into the variable array */\n")
1576 _tab_align += (TAB_WIDTH - (_tab_align % TAB_WIDTH)) % TAB_WIDTH
1589 _lead -= (_lead % TAB_WIDTH);
1594 _pad = align_to - _lead;
1613 # Calculate the tab alignment to be used with a given integer-indexed array
1661 # SROM layout revision filter block
1746 # Return true if the given property property ID is defined on class
1757 # Check class<->prop cache
1772 # Found; add to class<->prop cache
1819 # Return the property ID for a given class-defined property
1832 # Return the property ID for a given class-defined property name
1858 # Assign ID and set superclass
1913 # Print an object's unique ID, class, and properties to
1995 # Return a debug string representation of an object's unique ID, class, and
2035 # Return true if the given property ID is defined by the object's superclass
2044 # Return the line (NR) at which a given property ID was set on the object
2069 # Return an abstract property ID for a given property
2078 # Return the property ID for a given property name
2096 # Set a property on obj, using a property ID returned by obj_get_prop_id() or
2118 # Convert a property ID to a property path.
2121 errorx("'" prop_id "' is not a property ID")
2130 errorx("prop_to_path() called with non-property head")
2140 errorx("prop_path() called with non-property head")
2143 errorx("prop_path() called with non-property tail")
2151 errorx("prop_path_append() called with non-property tail")
2156 # Append a property ID to the given property path
2159 errorx("'" tail_id "' is not a property ID")
2208 # Fetch a value property value from obj, using a property ID returned by
2302 # If `prop_path*` is non-NULL, the corresponding property path (or property ID)
2319 _qsort(array, prop_path0, prop_path1, prop_path2, 0, _size-1)
2351 return (-1)
2365 _qpivot = int(first + int((last-first+1) * rand()))
2382 _qright--
2394 _qright--
2407 # If `prop_path` is non-NULL, the corresponding property path (or property ID)
2449 return (array_get(array, _size-1))
2540 # Handle Type equality -- we just check for trivial identity
2628 # The lhs type must be able to represent -at least- as
2665 _count = substr(str, RSTART+1, RLENGTH-2)
2686 _count = substr(str, RSTART+1, RLENGTH-2)
2764 errorx("can't append to non-continuation string '" \
2784 line = substr(line, 1, RLENGTH-1)
2814 # Return true if the two revision ranges are equal
2839 # Return a string representation of the given revision range
2852 return (_start "-" _end)
2898 # revision:layout hash table
2908 error("SROM layout redeclares layout for revision '" \
2920 # Return the first SROM layout registered for a given SROM revision,
2922 function nvram_get_srom_layout(nvram, revision, _layouts, _nlayouts, _layout,
2932 if (srom_layout_has_rev(_layout, revision))
2969 # Return true if var is internal-only, and should not be included
3049 # Add to revision array
3052 # Add to the revision map tables
3061 "revision " _i " (previously defined on line " \
3065 # Add to the (varname,revision) map
3086 # The name is gauranteed to be unique across SROM layouts with non-overlapping
3087 # revision ranges
3097 # Return true if the given SROM revision is defined by the layout, false
3106 # in the SROM layout bindings) for the given SROM revision
3118 # Return the SromEntry defined for the given variable name and SROM revision,
3120 function srom_layout_find_entry(layout, vname, revision, _key, _srom_revmap) {
3125 # SromEntry are mapped by name,revision composite keys
3126 _key = vname SUBSEP revision
3135 # falls within the parent's revision range
3140 # Fetch our parent's revision range, confirm that we're
3211 # generated for the given revision, false otherwise.
3232 # Return the single, non-shifted, non-masked offset/segment for the given
3235 # This is used to fetch special-cased variable definitions that are required
3356 # Return a human-readable representation of a Segment instance
3422 return (i < 0 ? -i : i)
3446 # Populate hex parsing lookup table on-demand
3571 # Advance to the next non-comment input record
3591 return (-1)
3608 for (_i = 1; _i <= NF-n; _i++) {
3611 NF = NF - n
3645 _g_parse_stack_depth--
3669 _state = _g_parse_stack[_g_parse_stack_depth - _i]
3683 # Find opening brace and push a new parser state for a brace-delimited block.
3697 # brace-delimited block is discarded.
3701 error("internal error - no closing brace")
3725 # Parse and return a revision range from the current line.
3728 # 4-10 # revisions 4-10, inclusive
3738 if ($2 ~ "[0-9]*-[0-9*]") {
3739 split($2, _g_rev_range, "[ \t]*-[ \t]*")
3742 } else if ($2 ~ "(>|>=|<|<=)" && $3 ~ "[1-9][0-9]*") {
3751 _end = int($3)-1
3754 _end = int($3)-1
3756 error("invalid revision descriptor")
3758 } else if ($2 ~ "[1-9][0-9]*") {
3762 error("invalid revision descriptor")
3861 # Return a string containing the human-readable list of valid Fmt names
3971 # Parse a top-level SROM layout block starting at the current line
3973 # srom 4-7 {
3981 # Parse revision descriptor and register SROM
3996 # srom 4-7 {
4006 # Parse revision descriptor
4009 # Construct the filter (which also validates the revision range)
4052 _attrs = substr($0, RSTART+1, RLENGTH-2)
4055 $0 = substr($0, RSTART+RLENGTH, length($0) - RSTART+RLENGTH)
4065 _shift = - parse_uint_string(_attr)
4204 # Otherwise, we're using the simplified syntax -- create and