Lines Matching +full:buffered +full:- +full:positive
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]"
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
267 # User-specifiable value formats
294 Int8Min = -128
296 Int16Min = -32768
298 Int32Min = -2147483648
348 VAccessInternal = obj_new(VAccess) # Implementation-Internal
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
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
682 errorx("'sromrev' entry has non-u8 type '" \
722 output_depth--
760 # Buffered?
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)
958 # Sanity-check range values
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
1292 # (private) Write a bind instance and all buffered opcodes
1308 errorx("invalid skip values in buffered bind")
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
1364 # Flush any buffered binding
1373 # Check the per-variable bind count to determine whether
1405 sprintf("/* bind (%s @ %#x -> %#x) */\n",
1413 # Write OPCODE_EOF after flushing any buffered writes
1417 # Flush any buffered writes
1468 # Write entry-specific array length (SROM layouts may define array
1485 output_depth--
1540 output_depth--
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
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
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")
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)
2852 return (_start "-" _end)
2969 # Return true if var is internal-only, and should not be included
3086 # The name is gauranteed to be unique across SROM layouts with non-overlapping
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")
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
3758 } else if ($2 ~ "[1-9][0-9]*") {
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 {
3996 # srom 4-7 {
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