Overflow and underflow Analysis in the window of the iSCSI register)

Source: Internet
Author: User
Today, when reviewing the knowledge about the Linux system architecture, I found that I was a little confused about the overflow and underflow code of the register window. I would like to record it, for more information about the structure of the system, see http://www.sics.se /~ In the text of PSM/sparcstack.html, only the overflow and overflow processing functions are analyzed here. 1. Overflow trap processing function
  1. /* A save instruction caused a trap */
  2. Window_overflow:
  3. /* Rotate Wim on bit right, We have 8 windows */
  4. MoV % Wim, % L3
  5. Sll % L3, 7, % L4
  6. SRL % L3, 1, % L3
  7. Or % L3, % L4, % L3
  8. And % L3, 0xff, % L3
  9. /* Disable Wim traps */
  10. MoV % G0, % WIM
  11. NOP; NOP
  12. /* Point to correct window */
  13. Save
  14. /* Dump registers to stack */
  15. STD % l0, [% sp + 0]
  16. STD % L2, [% sp + 8]
  17. STD % L4, [% sp + 16]
  18. STD % L6, [% sp + 24]
  19. STD % I0, [% sp + 32]
  20. STD % I2, [% sp + 40]
  21. STD % I4, [% sp + 48]
  22. STD % I6, [% sp + 56]
  23. /* Back to where we shoshould be */
  24. Restore
  25. /* Set new value of window */
  26. MoV % L3, % WIM
  27. NOP; NOP
  28. /* Go home */
  29. JMP % L1
  30. RET % L2
Use the code above to analyze a specific instance. Example: CWP = 3, Wim = 2. At this time, execute the save operation. When the save operation is executed, the first thing to do is to judge (CWP-1) = Wim? If they are equal, the overflow trap will be triggered. The specific code is as follows: (1) first, calculate the correct Wim value, that is, the 4th-8th line of code (at this time, because of the overflow trap, CMP = 2) (2) execute the save operation (save causes CWP --, so CWP = 1) (3) a series of STD, the purpose is to write the content in the CWP = 1 window to the memory (4) perform the restore operation (the restore operation causes CWP ++. At this time, CWP = 2) (5) execute the RET operation (JTs causes CWP ++, at this time, CWP = 3) after the above 5 steps, CWP = 3, Wim = 1, so when you execute the save operation again, CWP-1 = 2, not equal to Wim. The save operation is successful.
2. underflow trap processing function

  1. /* A restore instruction caused a trap */
  2. Window_underflow:
  3. /* Rotate Wim on bit left, we have 8 windows */
  4. MoV % Wim, % L3
  5. SRL % L3, 7, % L4
  6. Sll % L3, 1, % L3
  7. Or % L3, % L4, % L3
  8. And % L3, 0xff, % L3
  9. /* Disable Wim traps */
  10. MoV % G0, % WIM
  11. NOP; NOP
  12. /* Point to correct window */
  13. Restore
  14. Restore
  15. /* Dump registers to stack */
  16. LDD [% sp + 0], % l0
  17. LDD [% sp + 8], % L2
  18. LDD [% sp + 16], % L4
  19. LDD [% sp + 24], % L6
  20. LDD [% sp + 32], % I0
  21. LDD [% sp + 40], % I2
  22. LDD [% sp + 48], % I4
  23. LDD [% sp + 56], % I6
  24. /* Back to where we shoshould be */
  25. Save
  26. Save
  27. /* Set new value of window */
  28. MoV % L3, % WIM
  29. NOP; NOP
  30. /* Go home */
  31. JMP % L1
  32. RET % L2
Example: CWP = 3, Wim = 4. In this case, perform the restore operation. Similar to the Save operation, the first thing the restore operation will do is check (CWP + 1) = Wim? If yes, the underflow trap is triggered and the underflow trap handler function is entered. The specific code is as follows: (1) Enter window_underflow (at this time, because it comes in through underflow trap, so CWP = 2)(2) Similarly, calculate the correct Wim value (3) Two restore operations (at this time, CWP = 4 because two restore operations are added) (4) restore the stored value in the memory to the CWP = 4 window (5) Two Save operations (at this time, CWP = 2) (6) the operation (at this time, CWP = 3) after the preceding six steps are completed, CWP = 3, Wim = 5. When the restore operation is executed again, CWP + 1 = 4. 3. to sum up, the most important thing to note here is that both overflow and underflow are traps, which will first enable CWP --. It is very difficult to understand the two restores of underflow, that is, when I forget to overflow, CWP must be reduced by one first.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.