Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 1 | #ifndef __nosy_dump_h__ |
| 2 | #define __nosy_dump_h__ |
| 3 | |
| 4 | #define array_length(array) (sizeof(array) / sizeof(array[0])) |
| 5 | |
| 6 | #define TCODE_WRITE_QUADLET 0x0 |
| 7 | #define TCODE_WRITE_BLOCK 0x1 |
| 8 | #define TCODE_WRITE_RESPONSE 0x2 |
| 9 | #define TCODE_READ_QUADLET 0x4 |
| 10 | #define TCODE_READ_BLOCK 0x5 |
| 11 | #define TCODE_READ_QUADLET_RESPONSE 0x6 |
| 12 | #define TCODE_READ_BLOCK_RESPONSE 0x7 |
| 13 | #define TCODE_CYCLE_START 0x8 |
| 14 | #define TCODE_LOCK_REQUEST 0x9 |
| 15 | #define TCODE_ISO_DATA 0xa |
| 16 | #define TCODE_LOCK_RESPONSE 0xb |
| 17 | #define TCODE_PHY_PACKET 0x10 |
| 18 | |
| 19 | #define ACK_NO_ACK 0x0 |
| 20 | #define ACK_COMPLETE 0x1 |
| 21 | #define ACK_PENDING 0x2 |
| 22 | #define ACK_BUSY_X 0x4 |
| 23 | #define ACK_BUSY_A 0x5 |
| 24 | #define ACK_BUSY_B 0x6 |
| 25 | #define ACK_DATA_ERROR 0xd |
| 26 | #define ACK_TYPE_ERROR 0xe |
| 27 | |
| 28 | #define ACK_DONE(a) ((a >> 2) == 0) |
| 29 | #define ACK_BUSY(a) ((a >> 2) == 1) |
| 30 | #define ACK_ERROR(a) ((a >> 2) == 3) |
| 31 | |
| 32 | #define SPEED_100 0x0 |
| 33 | #define SPEED_200 0x1 |
| 34 | #define SPEED_400 0x2 |
| 35 | |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 36 | #include <stdint.h> |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 37 | |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 38 | struct phy_packet { |
| 39 | uint32_t timestamp; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 40 | union { |
| 41 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 42 | uint32_t zero:24; |
| 43 | uint32_t phy_id:6; |
| 44 | uint32_t identifier:2; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 45 | } common, link_on; |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 46 | |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 47 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 48 | uint32_t zero:16; |
| 49 | uint32_t gap_count:6; |
| 50 | uint32_t set_gap_count:1; |
| 51 | uint32_t set_root:1; |
| 52 | uint32_t root_id:6; |
| 53 | uint32_t identifier:2; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 54 | } phy_config; |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 55 | |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 56 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 57 | uint32_t more_packets:1; |
| 58 | uint32_t initiated_reset:1; |
| 59 | uint32_t port2:2; |
| 60 | uint32_t port1:2; |
| 61 | uint32_t port0:2; |
| 62 | uint32_t power_class:3; |
| 63 | uint32_t contender:1; |
| 64 | uint32_t phy_delay:2; |
| 65 | uint32_t phy_speed:2; |
| 66 | uint32_t gap_count:6; |
| 67 | uint32_t link_active:1; |
| 68 | uint32_t extended:1; |
| 69 | uint32_t phy_id:6; |
| 70 | uint32_t identifier:2; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 71 | } self_id; |
| 72 | |
| 73 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 74 | uint32_t more_packets:1; |
| 75 | uint32_t reserved1:1; |
| 76 | uint32_t porth:2; |
| 77 | uint32_t portg:2; |
| 78 | uint32_t portf:2; |
| 79 | uint32_t porte:2; |
| 80 | uint32_t portd:2; |
| 81 | uint32_t portc:2; |
| 82 | uint32_t portb:2; |
| 83 | uint32_t porta:2; |
| 84 | uint32_t reserved0:2; |
| 85 | uint32_t sequence:3; |
| 86 | uint32_t extended:1; |
| 87 | uint32_t phy_id:6; |
| 88 | uint32_t identifier:2; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 89 | } ext_self_id; |
| 90 | }; |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 91 | uint32_t inverted; |
| 92 | uint32_t ack; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | #define PHY_PACKET_CONFIGURATION 0x00 |
| 96 | #define PHY_PACKET_LINK_ON 0x01 |
| 97 | #define PHY_PACKET_SELF_ID 0x02 |
| 98 | |
| 99 | struct link_packet { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 100 | uint32_t timestamp; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 101 | union { |
| 102 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 103 | uint32_t priority:4; |
| 104 | uint32_t tcode:4; |
| 105 | uint32_t rt:2; |
| 106 | uint32_t tlabel:6; |
| 107 | uint32_t destination:16; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 108 | |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 109 | uint32_t offset_high:16; |
| 110 | uint32_t source:16; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 111 | |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 112 | uint32_t offset_low; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 113 | } common; |
| 114 | |
| 115 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 116 | uint32_t common[3]; |
| 117 | uint32_t crc; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 118 | } read_quadlet; |
| 119 | |
| 120 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 121 | uint32_t common[3]; |
| 122 | uint32_t data; |
| 123 | uint32_t crc; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 124 | } read_quadlet_response; |
| 125 | |
| 126 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 127 | uint32_t common[3]; |
| 128 | uint32_t extended_tcode:16; |
| 129 | uint32_t data_length:16; |
| 130 | uint32_t crc; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 131 | } read_block; |
| 132 | |
| 133 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 134 | uint32_t common[3]; |
| 135 | uint32_t extended_tcode:16; |
| 136 | uint32_t data_length:16; |
| 137 | uint32_t crc; |
| 138 | uint32_t data[0]; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 139 | /* crc and ack follows. */ |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 140 | } read_block_response; |
| 141 | |
| 142 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 143 | uint32_t common[3]; |
| 144 | uint32_t data; |
| 145 | uint32_t crc; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 146 | } write_quadlet; |
| 147 | |
| 148 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 149 | uint32_t common[3]; |
| 150 | uint32_t extended_tcode:16; |
| 151 | uint32_t data_length:16; |
| 152 | uint32_t crc; |
| 153 | uint32_t data[0]; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 154 | /* crc and ack follows. */ |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 155 | } write_block; |
| 156 | |
| 157 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 158 | uint32_t common[3]; |
| 159 | uint32_t crc; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 160 | } write_response; |
| 161 | |
| 162 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 163 | uint32_t common[3]; |
| 164 | uint32_t data; |
| 165 | uint32_t crc; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 166 | } cycle_start; |
| 167 | |
| 168 | struct { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 169 | uint32_t sy:4; |
| 170 | uint32_t tcode:4; |
| 171 | uint32_t channel:6; |
| 172 | uint32_t tag:2; |
| 173 | uint32_t data_length:16; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 174 | |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 175 | uint32_t crc; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 176 | } iso_data; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 177 | }; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | struct subaction { |
Stefan Richter | 1bcc69f | 2010-07-22 11:58:05 +0200 | [diff] [blame^] | 181 | uint32_t ack; |
Stefan Richter | 9f6d3c4 | 2010-07-22 11:58:05 +0200 | [diff] [blame] | 182 | size_t length; |
| 183 | struct list link; |
| 184 | struct link_packet packet; |
| 185 | }; |
| 186 | |
| 187 | struct link_transaction { |
| 188 | int request_node, response_node, tlabel; |
| 189 | struct subaction *request, *response; |
| 190 | struct list request_list, response_list; |
| 191 | struct list link; |
| 192 | }; |
| 193 | |
| 194 | int decode_fcp(struct link_transaction *t); |
| 195 | |
| 196 | #endif /* __nosy_dump_h__ */ |