| 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 |
|
| 15 |
//go:generate go run asm.go -out bdoor_amd64.s -arch amd64 |
| 16 |
//go:generate go run asm.go -out bdoor_386.s -arch 386 |
| 17 |
|
| 18 |
package bdoor |
| 19 |
|
| 20 |
const ( |
| 21 |
BackdoorPort = uint16(0x5658) |
| 22 |
BackdoorHighBWPort = uint16(0x5659) |
| 23 |
|
| 24 |
CommandGetVersion = uint32(10) |
| 25 |
|
| 26 |
CommandMessage = uint16(0x1e) |
| 27 |
CommandHighBWMessage = uint16(0) |
| 28 |
CommandFlagCookie = uint32(0x80000000) |
| 29 |
) |
| 30 |
|
| 31 |
func (p *BackdoorProto) InOut() *BackdoorProto { |
| 32 |
p.DX.AsUInt32().Low = BackdoorPort |
| 33 |
p.AX.SetValue(BackdoorMagic) |
| 34 |
|
| 35 |
retax, retbx, retcx, retdx, retsi, retdi, retbp := bdoor_inout( |
| 36 |
p.AX.Value(), |
| 37 |
p.BX.Value(), |
| 38 |
p.CX.Value(), |
| 39 |
p.DX.Value(), |
| 40 |
p.SI.Value(), |
| 41 |
p.DI.Value(), |
| 42 |
p.BP.Value(), |
| 43 |
) |
| 44 |
|
| 45 |
ret := &BackdoorProto{} |
| 46 |
ret.AX.SetValue(retax) |
| 47 |
ret.BX.SetValue(retbx) |
| 48 |
ret.CX.SetValue(retcx) |
| 49 |
ret.DX.SetValue(retdx) |
| 50 |
ret.SI.SetValue(retsi) |
| 51 |
ret.DI.SetValue(retdi) |
| 52 |
ret.BP.SetValue(retbp) |
| 53 |
|
| 54 |
return ret |
| 55 |
} |
| 56 |
|
| 57 |
func (p *BackdoorProto) HighBandwidthOut() *BackdoorProto { |
| 58 |
p.DX.AsUInt32().Low = BackdoorHighBWPort |
| 59 |
p.AX.SetValue(BackdoorMagic) |
| 60 |
|
| 61 |
retax, retbx, retcx, retdx, retsi, retdi, retbp := bdoor_hbout( |
| 62 |
p.AX.Value(), |
| 63 |
p.BX.Value(), |
| 64 |
p.CX.Value(), |
| 65 |
p.DX.Value(), |
| 66 |
p.SI.Value(), |
| 67 |
p.DI.Value(), |
| 68 |
p.BP.Value(), |
| 69 |
) |
| 70 |
|
| 71 |
ret := &BackdoorProto{} |
| 72 |
ret.AX.SetValue(retax) |
| 73 |
ret.BX.SetValue(retbx) |
| 74 |
ret.CX.SetValue(retcx) |
| 75 |
ret.DX.SetValue(retdx) |
| 76 |
ret.SI.SetValue(retsi) |
| 77 |
ret.DI.SetValue(retdi) |
| 78 |
ret.BP.SetValue(retbp) |
| 79 |
|
| 80 |
return ret |
| 81 |
} |
| 82 |
|
| 83 |
func (p *BackdoorProto) HighBandwidthIn() *BackdoorProto { |
| 84 |
p.DX.AsUInt32().Low = BackdoorHighBWPort |
| 85 |
p.AX.SetValue(BackdoorMagic) |
| 86 |
|
| 87 |
retax, retbx, retcx, retdx, retsi, retdi, retbp := bdoor_hbin( |
| 88 |
p.AX.Value(), |
| 89 |
p.BX.Value(), |
| 90 |
p.CX.Value(), |
| 91 |
p.DX.Value(), |
| 92 |
p.SI.Value(), |
| 93 |
p.DI.Value(), |
| 94 |
p.BP.Value(), |
| 95 |
) |
| 96 |
|
| 97 |
ret := &BackdoorProto{} |
| 98 |
ret.AX.SetValue(retax) |
| 99 |
ret.BX.SetValue(retbx) |
| 100 |
ret.CX.SetValue(retcx) |
| 101 |
ret.DX.SetValue(retdx) |
| 102 |
ret.SI.SetValue(retsi) |
| 103 |
ret.DI.SetValue(retdi) |
| 104 |
ret.BP.SetValue(retbp) |
| 105 |
|
| 106 |
return ret |
| 107 |
} |