// arb.h - arbitration code declarations

// variables used in the main arbitration state machine
// beta_arb_functions.c, decode_phy_packet.c, ds_arb_functions.c, grant_actions.c
// idle_actions.c, receive_actions.c, receive_functions.c, reset.c, selfid.c,
// transmit_actions.c, transmit_functions.c, treeid.c

boolean ack;                        // Set if last packet observed was exactly 8 bits
boolean all_child_ports_identified; // Set if all child ports have been identified
int arb_delay;                      // Arbitration delay time (4 * gap_count / BASE_RATE)
boolean arb_enable;                 // Set if a node may arbitrate upon detection of a subaction gap
int arb_reset_gap;                  // Duration of an arbitration reset gap 
                                    // ((52 + 32 * gap_count) / BASE_RATE)
timer arb_timer;                    // Timer for arbitration state machines
boolean  arb_timer_max;             // Set true when arb timer has first reached maximum arbitration
                                    // time in A0:Idle.  Allows arb_timer to be reused for token
                                    // recovery without falsely disabling arbitration in a new fairness
                                    // interval
boolean Beta_port_request;          // TRUE if there's a request on a port to be granted
boolean child_ID_complete[NPORT];
boolean child[NPORT];
int children;                       // Number of child ports
boolean concatenated_packet;        // TRUE if a concatenated packet is being received
int contend_time;                   // Amount of time to wait during root contention
boolean converted_request;          // TRUE if a request has been converted from a Beta request into 
                                    // a Legacy request in order to be forwarded on a DS port
pktType cur_format;                 // format for the packet currently being transmitted
speedCode cur_speed;                // Current packet speed
boolean defer_grant;                // TRUE if the end of a subaction was detected, but the proxy_root
                                    // will temporarily defer issuing a grant in Idle to a beta request to
                                    // allow a Legacy link timer to make a bus request for a cycle start packet
boolean did_arbrst;                 // TRUE if already did reset, set false on async packet
boolean enab_accel;
boolean end_of_packet;              // Set when reception of packet is complete
boolean fly_by_OK;                  // TRUE when fly-by concatenation permitted
boolean force_root;                 // Set to delay start of tree-ID process for this node
boolean format_committed;           // TRUE if format of received packet has been committed (repeated)
boolean grant_self;                 // TRUE if can grant to self
ArbState grant_to_give;             // Specifies which grant type (GRANT or GRANT_ISOCH) to issue
                                    // in grant_actions
boolean idle_receive_port;          // TRUE to simulate idle after sending proxy self_ID
boolean initiated_reset;
int lctrl;
boolean link_concatenation;         // TRUE if a Legacy link intends to transmit a concatenated packet
boolean loop;                       // TRUE if config timeout occurs while in T0.  Reported in the
                                    // PHY register map and cleared by software
int lowest_unidentified_child;      // Lowest numbered active child that has not sent its self_ID
boolean OK_to_grant;                // TRUE if a request can be granted when in Idle (valid only in the
                                    // proxy_root). Gap times may need to be respected
                                    // and so PHY cannot always grant a favorite request instantaneously
boolean own_request;                // Latch the value of arb_OK() at the time it is evaluated
int parent_port;
boolean phy_response;               // TRUE to indicate that a PHY response packet is to be transmitted
boolean ping_response;              // Set if self_ID packet(s) needed in response to a ping
boolean received_speed_signal;      // TRUE if saw a speed signal in the packet (being) received
int requesting_port;                // Lowest numbered requesting port (child in 1394a)
int reset_duration;                 // Duration to assert bus reset signal
PHY_PKT self_ID_pkt;                // temporary storage during self_ID
boolean send_null_packet;           // TRUE when boss needs to send a null packet in order to
                                    // terminate cleanly a DATA_PREFIX which is being sent on DS
                                    // ports during Beta packet transmissions
boolean speed_OK[NPORT];            
int standby_c[NPORT];
int standby_L[NPORT];               // restored from standby
int standby_NPORT[NPORT];
int standby_packet_count[NPORT];
int standby_parent[NPORT];
int standby_pwr[NPORT];
#define STORES_GAP_COUNT TRUE       // a B only PHY may set this FALSE
int subaction_gap;                  // Duration of a subaction gap ((28 + 16 * gap_count) / BASE_RATE)

