bdoor.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Copyright 2016-2017 VMware, Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package bdoor
  15. const (
  16. BackdoorPort = uint16(0x5658)
  17. BackdoorHighBWPort = uint16(0x5659)
  18. CommandGetVersion = uint32(10)
  19. CommandMessage = uint16(0x1e)
  20. CommandHighBWMessage = uint16(0)
  21. CommandFlagCookie = uint32(0x80000000)
  22. )
  23. func (p *BackdoorProto) InOut() *BackdoorProto {
  24. p.DX.AsUInt32().Low = BackdoorPort
  25. p.AX.SetValue(BackdoorMagic)
  26. retax, retbx, retcx, retdx, retsi, retdi, retbp := bdoor_inout(
  27. p.AX.Value(),
  28. p.BX.Value(),
  29. p.CX.Value(),
  30. p.DX.Value(),
  31. p.SI.Value(),
  32. p.DI.Value(),
  33. p.BP.Value(),
  34. )
  35. ret := &BackdoorProto{}
  36. ret.AX.SetValue(retax)
  37. ret.BX.SetValue(retbx)
  38. ret.CX.SetValue(retcx)
  39. ret.DX.SetValue(retdx)
  40. ret.SI.SetValue(retsi)
  41. ret.DI.SetValue(retdi)
  42. ret.BP.SetValue(retbp)
  43. return ret
  44. }
  45. func (p *BackdoorProto) HighBandwidthOut() *BackdoorProto {
  46. p.DX.AsUInt32().Low = BackdoorHighBWPort
  47. p.AX.SetValue(BackdoorMagic)
  48. retax, retbx, retcx, retdx, retsi, retdi, retbp := bdoor_hbout(
  49. p.AX.Value(),
  50. p.BX.Value(),
  51. p.CX.Value(),
  52. p.DX.Value(),
  53. p.SI.Value(),
  54. p.DI.Value(),
  55. p.BP.Value(),
  56. )
  57. ret := &BackdoorProto{}
  58. ret.AX.SetValue(retax)
  59. ret.BX.SetValue(retbx)
  60. ret.CX.SetValue(retcx)
  61. ret.DX.SetValue(retdx)
  62. ret.SI.SetValue(retsi)
  63. ret.DI.SetValue(retdi)
  64. ret.BP.SetValue(retbp)
  65. return ret
  66. }
  67. func (p *BackdoorProto) HighBandwidthIn() *BackdoorProto {
  68. p.DX.AsUInt32().Low = BackdoorHighBWPort
  69. p.AX.SetValue(BackdoorMagic)
  70. retax, retbx, retcx, retdx, retsi, retdi, retbp := bdoor_hbin(
  71. p.AX.Value(),
  72. p.BX.Value(),
  73. p.CX.Value(),
  74. p.DX.Value(),
  75. p.SI.Value(),
  76. p.DI.Value(),
  77. p.BP.Value(),
  78. )
  79. ret := &BackdoorProto{}
  80. ret.AX.SetValue(retax)
  81. ret.BX.SetValue(retbx)
  82. ret.CX.SetValue(retcx)
  83. ret.DX.SetValue(retdx)
  84. ret.SI.SetValue(retsi)
  85. ret.DI.SetValue(retdi)
  86. ret.BP.SetValue(retbp)
  87. return ret
  88. }