Zane Shelley | 871adec | 2019-07-30 11:01:39 -0500 | [diff] [blame] | 1 | #pragma once |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 2 | |
| 3 | #include <algorithm> |
| 4 | |
| 5 | #include <iipscr.h> |
| 6 | #include <prdrCommon.H> |
| 7 | |
Zane Shelley | 871adec | 2019-07-30 11:01:39 -0500 | [diff] [blame] | 8 | namespace libhei |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 9 | { |
| 10 | |
| 11 | class NotRegister : public SCAN_COMM_REGISTER_CLASS |
| 12 | { |
| 13 | public: |
| 14 | NotRegister() : |
| 15 | SCAN_COMM_REGISTER_CLASS( ), iv_child(NULL), iv_iBS(0) |
| 16 | { |
| 17 | iv_bs = &iv_iBS; |
| 18 | } |
| 19 | |
| 20 | NotRegister(SCAN_COMM_REGISTER_CLASS & i_arg) : |
| 21 | SCAN_COMM_REGISTER_CLASS( ), iv_child(&i_arg), |
| 22 | iv_iBS(i_arg.GetBitLength()) |
| 23 | { |
| 24 | iv_bs = &iv_iBS; |
| 25 | } |
| 26 | |
| 27 | NotRegister & operator=(const NotRegister & r) |
| 28 | { |
| 29 | iv_child = r.iv_child; |
| 30 | iv_iBS = r.iv_iBS; |
| 31 | //iv_bs = r.iv_bs; <-- don't do this! |
| 32 | return *this; |
| 33 | } |
| 34 | |
| 35 | virtual uint32_t Read() const { return iv_child->Read(); } |
| 36 | virtual uint32_t Write() { return iv_child->Write(); } |
| 37 | |
| 38 | const BitString * GetBitString( |
| 39 | ATTENTION_TYPE i_type = INVALID_ATTENTION_TYPE) const |
| 40 | { |
| 41 | (*iv_bs) = ~(*iv_child->GetBitString(i_type)); |
| 42 | return iv_bs; |
| 43 | } |
| 44 | |
| 45 | virtual uint16_t GetId() const { return iv_child->GetId(); } |
| 46 | virtual void SetId(uint16_t i_id) {} |
| 47 | |
| 48 | bool operator==(const NotRegister & r) const |
| 49 | { return r.iv_child == iv_child; } |
| 50 | |
| 51 | bool operator<(const NotRegister & r) const |
| 52 | { return iv_child < r.iv_child; } |
| 53 | |
| 54 | bool operator>=(const NotRegister & r) const |
| 55 | { return iv_child >= r.iv_child; } |
| 56 | |
| 57 | protected: |
| 58 | BitString & AccessBitString(void) { return iv_iBS; } |
| 59 | void SetBitString(const BitString *) {} |
| 60 | |
| 61 | private: |
| 62 | SCAN_COMM_REGISTER_CLASS * iv_child; |
| 63 | |
| 64 | BitStringBuffer * iv_bs; |
| 65 | BitStringBuffer iv_iBS; |
| 66 | }; |
| 67 | |
| 68 | class SummaryRegister : public SCAN_COMM_REGISTER_CLASS |
| 69 | { |
| 70 | public: |
| 71 | SummaryRegister() : |
| 72 | SCAN_COMM_REGISTER_CLASS( ), iv_child(NULL), iv_amount(0), iv_iBS(0) |
| 73 | { |
| 74 | iv_bs = &iv_iBS; |
| 75 | } |
| 76 | |
| 77 | SummaryRegister(SCAN_COMM_REGISTER_CLASS & i_arg, uint16_t i_amount) : |
| 78 | SCAN_COMM_REGISTER_CLASS( ), iv_child(&i_arg), iv_amount(i_amount), |
| 79 | iv_iBS(i_arg.GetBitLength()) |
| 80 | { |
| 81 | iv_bs = &iv_iBS; |
| 82 | } |
| 83 | |
| 84 | SummaryRegister & operator=(const SummaryRegister & r) |
| 85 | { |
| 86 | iv_child = r.iv_child; |
| 87 | iv_amount = r.iv_amount; |
| 88 | iv_iBS = r.iv_iBS; |
| 89 | //iv_bs = r.iv_bs; <-- don't do this! |
| 90 | return *this; |
| 91 | } |
| 92 | |
| 93 | virtual uint32_t Read() const |
| 94 | { |
| 95 | uint32_t rc = iv_child->Read(); |
| 96 | if ( PRD_SCANCOM_FAILURE == rc ) |
| 97 | { |
| 98 | // This is a bit unusual, but we are going to ignore SCOM failures. |
| 99 | // This takes care of a corner case where one of the summary |
| 100 | // registers in the list returns an error, but there is another |
| 101 | // summary register with an active attention, which would be ignored |
| 102 | // if we return a bad rc. |
| 103 | PRDF_INF( "[SummaryRegister::read] SCOM failure on register ID " |
| 104 | "0x%04x, ignoring error", iv_child->GetId() ); |
| 105 | rc = SUCCESS; |
| 106 | iv_child->clearAllBits(); // just in case |
| 107 | } |
| 108 | return rc; |
| 109 | } |
| 110 | |
| 111 | virtual uint32_t Write() { return iv_child->Write(); } |
| 112 | |
| 113 | const BitString * GetBitString( |
| 114 | ATTENTION_TYPE i_type = INVALID_ATTENTION_TYPE) const |
| 115 | { |
| 116 | iv_bs->clearAll(); |
| 117 | |
| 118 | PRDF::BitString tmp = *iv_child->GetBitString(i_type); |
| 119 | |
| 120 | //if any bits are set in iv_child, then set the iv_amount bit |
| 121 | if (0 != tmp.getSetCount()) |
| 122 | { |
| 123 | iv_bs->setBit(0); |
| 124 | *iv_bs = *iv_bs >> iv_amount; |
| 125 | } |
| 126 | return iv_bs; |
| 127 | } |
| 128 | |
| 129 | virtual uint16_t GetId() const { return iv_child->GetId(); } |
| 130 | virtual void SetId(uint16_t i_id) {} |
| 131 | |
| 132 | bool operator==(const SummaryRegister & r) const |
| 133 | { return (r.iv_child == iv_child) && (r.iv_amount == iv_amount); } |
| 134 | |
| 135 | bool operator<(const SummaryRegister & r) const |
| 136 | { |
| 137 | if (iv_child == r.iv_child) |
| 138 | return iv_amount < r.iv_amount; |
| 139 | return iv_child < r.iv_child; |
| 140 | } |
| 141 | |
| 142 | bool operator>=(const SummaryRegister & r) const |
| 143 | { |
| 144 | if (iv_child == r.iv_child) |
| 145 | return iv_amount >= r.iv_amount; |
| 146 | return iv_child >= r.iv_child; |
| 147 | } |
| 148 | |
| 149 | protected: |
| 150 | BitString & AccessBitString(void) { return iv_iBS; } |
| 151 | void SetBitString(const BitString *) {} |
| 152 | |
| 153 | private: |
| 154 | SCAN_COMM_REGISTER_CLASS * iv_child; |
| 155 | uint16_t iv_amount; |
| 156 | |
| 157 | BitStringBuffer * iv_bs; |
| 158 | BitStringBuffer iv_iBS; |
| 159 | }; |
| 160 | |
| 161 | class LeftShiftRegister : public SCAN_COMM_REGISTER_CLASS |
| 162 | { |
| 163 | public: |
| 164 | LeftShiftRegister() : |
| 165 | SCAN_COMM_REGISTER_CLASS( ), iv_child(NULL), iv_amount(0), iv_iBS(0) |
| 166 | { |
| 167 | iv_bs = &iv_iBS; |
| 168 | } |
| 169 | |
| 170 | LeftShiftRegister(SCAN_COMM_REGISTER_CLASS & i_arg, uint16_t i_amount) : |
| 171 | SCAN_COMM_REGISTER_CLASS( ), iv_child(&i_arg), iv_amount(i_amount), |
| 172 | iv_iBS(i_arg.GetBitLength()) |
| 173 | { |
| 174 | iv_bs = &iv_iBS; |
| 175 | } |
| 176 | |
| 177 | LeftShiftRegister & operator=(const LeftShiftRegister & r) |
| 178 | { |
| 179 | iv_child = r.iv_child; |
| 180 | iv_amount = r.iv_amount; |
| 181 | iv_iBS = r.iv_iBS; |
| 182 | //iv_bs = r.iv_bs; <-- don't do this! |
| 183 | return *this; |
| 184 | } |
| 185 | |
| 186 | virtual uint32_t Read() const { return iv_child->Read(); } |
| 187 | virtual uint32_t Write() { return iv_child->Write(); } |
| 188 | |
| 189 | const BitString * GetBitString( |
| 190 | ATTENTION_TYPE i_type = INVALID_ATTENTION_TYPE) const |
| 191 | { |
| 192 | (*iv_bs) = (*iv_child->GetBitString(i_type)) << iv_amount; |
| 193 | return iv_bs; |
| 194 | } |
| 195 | |
| 196 | virtual uint16_t GetId() const { return iv_child->GetId(); } |
| 197 | virtual void SetId(uint16_t i_id) {} |
| 198 | |
| 199 | bool operator==(const LeftShiftRegister & r) const |
| 200 | { return (r.iv_child == iv_child) && (r.iv_amount == iv_amount); } |
| 201 | |
| 202 | bool operator<(const LeftShiftRegister & r) const |
| 203 | { |
| 204 | if (iv_child == r.iv_child) |
| 205 | return iv_amount < r.iv_amount; |
| 206 | return iv_child < r.iv_child; |
| 207 | } |
| 208 | |
| 209 | bool operator>=(const LeftShiftRegister & r) const |
| 210 | { |
| 211 | if (iv_child == r.iv_child) |
| 212 | return iv_amount >= r.iv_amount; |
| 213 | return iv_child >= r.iv_child; |
| 214 | } |
| 215 | |
| 216 | protected: |
| 217 | BitString & AccessBitString(void) { return iv_iBS; } |
| 218 | void SetBitString(const BitString *) {} |
| 219 | |
| 220 | private: |
| 221 | SCAN_COMM_REGISTER_CLASS * iv_child; |
| 222 | uint16_t iv_amount; |
| 223 | |
| 224 | BitStringBuffer * iv_bs; |
| 225 | BitStringBuffer iv_iBS; |
| 226 | }; |
| 227 | |
| 228 | class RightShiftRegister : public SCAN_COMM_REGISTER_CLASS |
| 229 | { |
| 230 | public: |
| 231 | RightShiftRegister() : |
| 232 | SCAN_COMM_REGISTER_CLASS( ), iv_child(NULL), iv_amount(0), iv_iBS(0) |
| 233 | { |
| 234 | iv_bs = &iv_iBS; |
| 235 | } |
| 236 | |
| 237 | RightShiftRegister(SCAN_COMM_REGISTER_CLASS & i_arg, uint16_t i_amount) : |
| 238 | SCAN_COMM_REGISTER_CLASS( ), iv_child(&i_arg), iv_amount(i_amount), |
| 239 | iv_iBS(i_arg.GetBitLength()) |
| 240 | { |
| 241 | iv_bs = &iv_iBS; |
| 242 | } |
| 243 | |
| 244 | RightShiftRegister & operator=(const RightShiftRegister & r) |
| 245 | { |
| 246 | iv_child = r.iv_child; |
| 247 | iv_amount = r.iv_amount; |
| 248 | iv_iBS = r.iv_iBS; |
| 249 | //iv_bs = r.iv_bs; <-- don't do this! |
| 250 | return *this; |
| 251 | } |
| 252 | |
| 253 | virtual uint32_t Read() const { return iv_child->Read(); } |
| 254 | virtual uint32_t Write() { return iv_child->Write(); } |
| 255 | |
| 256 | const BitString * GetBitString( |
| 257 | ATTENTION_TYPE i_type = INVALID_ATTENTION_TYPE) const |
| 258 | { |
| 259 | (*iv_bs) = (*iv_child->GetBitString(i_type)) >> iv_amount; |
| 260 | return iv_bs; |
| 261 | } |
| 262 | |
| 263 | virtual uint16_t GetId() const { return iv_child->GetId(); } |
| 264 | virtual void SetId(uint16_t i_id) {} |
| 265 | |
| 266 | bool operator==(const RightShiftRegister & r) const |
| 267 | { return (r.iv_child == iv_child) && (r.iv_amount == iv_amount); } |
| 268 | |
| 269 | bool operator<(const RightShiftRegister & r) const |
| 270 | { |
| 271 | if (iv_child == r.iv_child) |
| 272 | return iv_amount < r.iv_amount; |
| 273 | return iv_child < r.iv_child; |
| 274 | } |
| 275 | |
| 276 | bool operator>=(const RightShiftRegister & r) const |
| 277 | { |
| 278 | if (iv_child == r.iv_child) |
| 279 | return iv_amount >= r.iv_amount; |
| 280 | return iv_child >= r.iv_child; |
| 281 | } |
| 282 | |
| 283 | protected: |
| 284 | BitString & AccessBitString(void) { return iv_iBS; } |
| 285 | void SetBitString(const BitString *) {} |
| 286 | |
| 287 | private: |
| 288 | SCAN_COMM_REGISTER_CLASS * iv_child; |
| 289 | uint16_t iv_amount; |
| 290 | |
| 291 | BitStringBuffer * iv_bs; |
| 292 | BitStringBuffer iv_iBS; |
| 293 | }; |
| 294 | |
| 295 | |
| 296 | class AndRegister : public SCAN_COMM_REGISTER_CLASS |
| 297 | { |
| 298 | public: |
| 299 | AndRegister() : |
| 300 | SCAN_COMM_REGISTER_CLASS( ), iv_left(NULL), iv_right(NULL), iv_iBS(0) |
| 301 | { |
| 302 | iv_bs = &iv_iBS; |
| 303 | } |
| 304 | |
| 305 | AndRegister( SCAN_COMM_REGISTER_CLASS & i_left, |
| 306 | SCAN_COMM_REGISTER_CLASS & i_right ) : |
| 307 | SCAN_COMM_REGISTER_CLASS( ), iv_left(&i_left), iv_right(&i_right), |
| 308 | iv_iBS(std::min(i_left.GetBitLength(), |
| 309 | i_right.GetBitLength())) |
| 310 | { |
| 311 | iv_bs = &iv_iBS; |
| 312 | } |
| 313 | |
| 314 | AndRegister & operator=(const AndRegister & r) |
| 315 | { |
| 316 | iv_left = r.iv_left; |
| 317 | iv_right = r.iv_right; |
| 318 | iv_iBS = r.iv_iBS; |
| 319 | //iv_bs = r.iv_bs; <-- don't do this! |
| 320 | return *this; |
| 321 | } |
| 322 | |
| 323 | virtual uint32_t Read() const |
| 324 | { |
| 325 | return iv_left->Read() | iv_right->Read(); |
| 326 | } |
| 327 | virtual uint32_t Write() |
| 328 | { |
| 329 | return iv_left->Write() | iv_right->Write(); |
| 330 | } |
| 331 | |
| 332 | const BitString * GetBitString( |
| 333 | ATTENTION_TYPE i_type = INVALID_ATTENTION_TYPE) const |
| 334 | { |
| 335 | (*iv_bs) = *iv_left->GetBitString(i_type); |
| 336 | (*iv_bs) = (*iv_bs) & (*iv_right->GetBitString(i_type)); |
| 337 | return iv_bs; |
| 338 | } |
| 339 | |
| 340 | virtual uint16_t GetId() const |
| 341 | { |
| 342 | return Prdr::SignatureOp::combineSig(iv_left->GetId(), |
| 343 | iv_right->GetId()); |
| 344 | } |
| 345 | |
| 346 | virtual void SetId(uint16_t i_id) {} |
| 347 | |
| 348 | bool operator==(const AndRegister & r) const |
| 349 | { return (r.iv_left == iv_left) && (r.iv_right == iv_right); } |
| 350 | |
| 351 | bool operator<(const AndRegister & r) const |
| 352 | { |
| 353 | if (iv_left == r.iv_left) |
| 354 | return iv_right < r.iv_right; |
| 355 | return iv_left < r.iv_left; |
| 356 | } |
| 357 | |
| 358 | bool operator>=(const AndRegister & r) const |
| 359 | { |
| 360 | if (iv_left == r.iv_left) |
| 361 | return iv_right >= r.iv_right; |
| 362 | return iv_left >= r.iv_left; |
| 363 | } |
| 364 | |
| 365 | protected: |
| 366 | BitString & AccessBitString(void) { return iv_iBS; } |
| 367 | void SetBitString(const BitString *) {} |
| 368 | |
| 369 | private: |
| 370 | SCAN_COMM_REGISTER_CLASS * iv_left; |
| 371 | SCAN_COMM_REGISTER_CLASS * iv_right; |
| 372 | |
| 373 | BitStringBuffer * iv_bs; |
| 374 | BitStringBuffer iv_iBS; |
| 375 | }; |
| 376 | |
| 377 | class OrRegister : public SCAN_COMM_REGISTER_CLASS |
| 378 | { |
| 379 | public: |
| 380 | |
| 381 | OrRegister() : |
| 382 | SCAN_COMM_REGISTER_CLASS( ), iv_left(NULL), iv_right(NULL), iv_iBS(0) |
| 383 | { |
| 384 | iv_bs = &iv_iBS; |
| 385 | } |
| 386 | |
| 387 | OrRegister( SCAN_COMM_REGISTER_CLASS & i_left, |
| 388 | SCAN_COMM_REGISTER_CLASS & i_right ) : |
| 389 | SCAN_COMM_REGISTER_CLASS( ), iv_left(&i_left), iv_right(&i_right), |
| 390 | iv_iBS(std::min(i_left.GetBitLength(), |
| 391 | i_right.GetBitLength())) |
| 392 | { |
| 393 | iv_bs = &iv_iBS; |
| 394 | } |
| 395 | |
| 396 | OrRegister & operator=(const OrRegister & r) |
| 397 | { |
| 398 | iv_left = r.iv_left; |
| 399 | iv_right = r.iv_right; |
| 400 | iv_iBS = r.iv_iBS; |
| 401 | //iv_bs = r.iv_bs; <-- don't do this! |
| 402 | return *this; |
| 403 | } |
| 404 | |
| 405 | virtual uint32_t Read() const |
| 406 | { |
| 407 | return iv_left->Read() | iv_right->Read(); |
| 408 | } |
| 409 | |
| 410 | virtual uint32_t Write() |
| 411 | { |
| 412 | return iv_left->Write() | iv_right->Write(); |
| 413 | } |
| 414 | |
| 415 | const BitString * GetBitString( |
| 416 | ATTENTION_TYPE i_type = INVALID_ATTENTION_TYPE ) const |
| 417 | { |
| 418 | (*iv_bs) = *iv_left->GetBitString(i_type); |
| 419 | (*iv_bs) = (*iv_bs) | (*iv_right->GetBitString(i_type)); |
| 420 | return iv_bs; |
| 421 | } |
| 422 | |
| 423 | virtual uint16_t GetId() const |
| 424 | { |
| 425 | return Prdr::SignatureOp::combineSig( iv_left->GetId(), |
| 426 | iv_right->GetId() ); |
| 427 | } |
| 428 | |
| 429 | virtual void SetId(uint16_t i_id) {} |
| 430 | |
| 431 | bool operator==(const OrRegister & r) const |
| 432 | { return (r.iv_left == iv_left) && (r.iv_right == iv_right); } |
| 433 | |
| 434 | bool operator<(const OrRegister & r) const |
| 435 | { |
| 436 | if (iv_left == r.iv_left) |
| 437 | return iv_right < r.iv_right; |
| 438 | return iv_left < r.iv_left; |
| 439 | } |
| 440 | |
| 441 | bool operator>=(const OrRegister & r) const |
| 442 | { |
| 443 | if (iv_left == r.iv_left) |
| 444 | return iv_right >= r.iv_right; |
| 445 | return iv_left >= r.iv_left; |
| 446 | } |
| 447 | |
| 448 | protected: |
| 449 | BitString & AccessBitString(void) { return iv_iBS; } |
| 450 | void SetBitString(const BitString *) {} |
| 451 | |
| 452 | private: |
| 453 | SCAN_COMM_REGISTER_CLASS * iv_left; |
| 454 | SCAN_COMM_REGISTER_CLASS * iv_right; |
| 455 | |
| 456 | BitStringBuffer * iv_bs; |
| 457 | BitStringBuffer iv_iBS; |
| 458 | }; |
| 459 | |
| 460 | class NullRegister : public SCAN_COMM_REGISTER_CLASS |
| 461 | { |
| 462 | public: |
| 463 | NullRegister(int size) : |
| 464 | SCAN_COMM_REGISTER_CLASS( ), iv_iBS(size) |
| 465 | {} |
| 466 | |
| 467 | NullRegister & operator=(const NullRegister & r) |
| 468 | { |
| 469 | iv_iBS = r.iv_iBS; |
| 470 | return *this; |
| 471 | } |
| 472 | |
| 473 | virtual uint32_t Read() const { return 0; } |
| 474 | virtual uint32_t Write() { return 0; } |
| 475 | |
| 476 | const BitString * GetBitString( |
| 477 | ATTENTION_TYPE i_type = INVALID_ATTENTION_TYPE) const |
| 478 | { |
| 479 | return &iv_iBS; |
| 480 | } |
| 481 | |
| 482 | protected: |
| 483 | BitString & AccessBitString(void) { return iv_iBS; } |
| 484 | void SetBitString(const BitString *) {} |
| 485 | |
| 486 | private: |
| 487 | BitStringBuffer iv_iBS; |
| 488 | |
| 489 | virtual uint16_t GetId() const |
| 490 | { return Prdr::SignatureOp::DEFAULT_SIGNATURE; } |
| 491 | |
| 492 | virtual void SetId(uint16_t i_id) {} |
| 493 | |
| 494 | }; |
| 495 | |
| 496 | class AttnTypeRegister : public SCAN_COMM_REGISTER_CLASS |
| 497 | { |
| 498 | public: |
| 499 | AttnTypeRegister() : |
| 500 | SCAN_COMM_REGISTER_CLASS( ), iv_check(&cv_null), iv_recov(&cv_null), |
| 501 | iv_special(&cv_null), iv_proccs(&cv_null), iv_hostattn(&cv_null), |
| 502 | iv_iBS(0) |
| 503 | { |
| 504 | iv_bs = &iv_iBS; |
| 505 | } |
| 506 | |
| 507 | AttnTypeRegister( SCAN_COMM_REGISTER_CLASS *i_check, |
| 508 | SCAN_COMM_REGISTER_CLASS *i_recov, |
| 509 | SCAN_COMM_REGISTER_CLASS *i_special, |
| 510 | SCAN_COMM_REGISTER_CLASS *i_proccs, |
| 511 | SCAN_COMM_REGISTER_CLASS *i_hostattn ) : |
| 512 | SCAN_COMM_REGISTER_CLASS( ), |
| 513 | iv_check( NULL == i_check ? &cv_null : i_check), |
| 514 | iv_recov( NULL == i_recov ? &cv_null : i_recov), |
| 515 | iv_special( NULL == i_special ? &cv_null : i_special), |
| 516 | iv_proccs( NULL == i_proccs ? &cv_null : i_proccs), |
| 517 | iv_hostattn( NULL == i_hostattn ? &cv_null : i_hostattn), |
| 518 | iv_iBS(0) // will fully initialize this inside ctor. |
| 519 | { |
| 520 | uint32_t l_length = 1024; |
| 521 | l_length = std::min(l_length, iv_check->GetBitLength()); |
| 522 | l_length = std::min(l_length, iv_recov->GetBitLength()); |
| 523 | l_length = std::min(l_length, iv_special->GetBitLength()); |
| 524 | l_length = std::min(l_length, iv_proccs->GetBitLength()); |
| 525 | l_length = std::min(l_length, iv_hostattn->GetBitLength()); |
| 526 | iv_iBS = BitStringBuffer(l_length); |
| 527 | iv_bs = &iv_iBS; |
| 528 | } |
| 529 | |
| 530 | AttnTypeRegister & operator=(const AttnTypeRegister & r) |
| 531 | { |
| 532 | //iv_null = r.iv_null; <-- don't do this! |
| 533 | iv_check = (r.iv_check == &r.cv_null ? &cv_null : r.iv_check); |
| 534 | iv_recov = (r.iv_recov == &r.cv_null ? &cv_null : r.iv_recov); |
| 535 | iv_special = (r.iv_special == &r.cv_null ? &cv_null : r.iv_special); |
| 536 | iv_proccs = (r.iv_proccs == &r.cv_null ? &cv_null : r.iv_proccs); |
| 537 | iv_hostattn = (r.iv_hostattn == &r.cv_null ? &cv_null : r.iv_hostattn); |
| 538 | iv_iBS = r.iv_iBS; |
| 539 | //iv_bs = r.iv_bs; <-- don't do this! |
| 540 | return *this; |
| 541 | } |
| 542 | |
| 543 | virtual uint32_t Read() const |
| 544 | { |
| 545 | return iv_check->Read() | iv_recov->Read() | |
| 546 | iv_special->Read() | iv_proccs->Read() | |
| 547 | iv_hostattn->Read(); |
| 548 | } |
| 549 | |
| 550 | virtual uint32_t Write() |
| 551 | { |
| 552 | return iv_check->Write() | iv_recov->Write() | |
| 553 | iv_special->Write() | iv_proccs->Write() | |
| 554 | iv_hostattn->Write(); |
| 555 | } |
| 556 | |
| 557 | const BitString * GetBitString( |
| 558 | ATTENTION_TYPE i_type = INVALID_ATTENTION_TYPE) const |
| 559 | { |
| 560 | switch (i_type) |
| 561 | { |
| 562 | case CHECK_STOP: |
| 563 | (*iv_bs) = BitStringBuffer( |
| 564 | *iv_check->GetBitString(i_type)); |
| 565 | break; |
| 566 | |
| 567 | case RECOVERABLE: |
| 568 | (*iv_bs) = BitStringBuffer( |
| 569 | *iv_recov->GetBitString(i_type)); |
| 570 | break; |
| 571 | |
| 572 | case SPECIAL: |
| 573 | (*iv_bs) = BitStringBuffer( |
| 574 | *iv_special->GetBitString(i_type)); |
| 575 | break; |
| 576 | |
| 577 | case PROC_CS: |
| 578 | (*iv_bs) = BitStringBuffer( |
| 579 | *iv_proccs->GetBitString(i_type)); |
| 580 | break; |
| 581 | |
| 582 | case HOST_ATTN: |
| 583 | (*iv_bs) = BitStringBuffer( |
| 584 | *iv_hostattn->GetBitString(i_type)); |
| 585 | break; |
| 586 | } |
| 587 | |
| 588 | return iv_bs; |
| 589 | } |
| 590 | |
| 591 | virtual uint16_t GetId() const |
| 592 | { |
| 593 | uint16_t l_rc = Prdr::SignatureOp::DEFAULT_SIGNATURE; |
| 594 | l_rc = Prdr::SignatureOp::combineSig(l_rc, iv_check->GetId()); |
| 595 | l_rc = Prdr::SignatureOp::combineSig(l_rc, iv_recov->GetId()); |
| 596 | l_rc = Prdr::SignatureOp::combineSig(l_rc, iv_special->GetId()); |
| 597 | l_rc = Prdr::SignatureOp::combineSig(l_rc, iv_proccs->GetId()); |
| 598 | l_rc = Prdr::SignatureOp::combineSig(l_rc, iv_hostattn->GetId()); |
| 599 | return l_rc; |
| 600 | } |
| 601 | |
| 602 | virtual void SetId(uint16_t i_id) {} |
| 603 | |
| 604 | bool operator==(const AttnTypeRegister & r) const |
| 605 | { |
| 606 | return (r.iv_check == iv_check) && (r.iv_recov == iv_recov) && |
| 607 | (r.iv_special == iv_special) && (r.iv_proccs == iv_proccs) && |
| 608 | (r.iv_special == iv_hostattn); |
| 609 | } |
| 610 | |
| 611 | protected: |
| 612 | BitString & AccessBitString(void) { return iv_iBS; } |
| 613 | void SetBitString(const BitString *) {} |
| 614 | |
| 615 | private: |
| 616 | static NullRegister cv_null; |
| 617 | |
| 618 | SCAN_COMM_REGISTER_CLASS * iv_check; |
| 619 | SCAN_COMM_REGISTER_CLASS * iv_recov; |
| 620 | SCAN_COMM_REGISTER_CLASS * iv_special; |
| 621 | SCAN_COMM_REGISTER_CLASS * iv_proccs; |
| 622 | SCAN_COMM_REGISTER_CLASS * iv_hostattn; |
| 623 | |
| 624 | BitStringBuffer * iv_bs; |
| 625 | BitStringBuffer iv_iBS; |
| 626 | }; |
| 627 | |
| 628 | class ConstantRegister : public SCAN_COMM_REGISTER_CLASS |
| 629 | { |
| 630 | public: |
| 631 | ConstantRegister() : |
| 632 | SCAN_COMM_REGISTER_CLASS( ), iv_iBS(0) |
| 633 | {} |
| 634 | |
| 635 | ConstantRegister( const BitStringBuffer & i_arg ) : |
| 636 | SCAN_COMM_REGISTER_CLASS( ), iv_iBS(i_arg) |
| 637 | {} |
| 638 | |
| 639 | ConstantRegister & operator=(const ConstantRegister & r) |
| 640 | { |
| 641 | iv_iBS = r.iv_iBS; |
| 642 | return *this; |
| 643 | } |
| 644 | |
| 645 | virtual uint32_t Read() const { return SUCCESS; } |
| 646 | virtual uint32_t Write() { return SUCCESS; } |
| 647 | |
| 648 | const BitString * GetBitString( |
| 649 | ATTENTION_TYPE i_type = INVALID_ATTENTION_TYPE) const |
| 650 | { |
| 651 | return &iv_iBS; |
| 652 | } |
| 653 | |
| 654 | virtual uint16_t GetId() const |
| 655 | { return Prdr::SignatureOp::DEFAULT_SIGNATURE; } |
| 656 | |
| 657 | virtual void SetId(uint16_t i_id) {} |
| 658 | |
| 659 | bool operator==(const ConstantRegister & r) const |
| 660 | { return r.iv_iBS == iv_iBS; } |
| 661 | |
| 662 | protected: |
| 663 | BitString & AccessBitString(void) { return iv_iBS; } |
| 664 | void SetBitString(const BitString *) {} |
| 665 | |
| 666 | private: |
| 667 | BitStringBuffer iv_iBS; |
| 668 | }; |
| 669 | |
Zane Shelley | 871adec | 2019-07-30 11:01:39 -0500 | [diff] [blame] | 670 | } // end namespace libhei |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 671 | |