1
0
mirror of https://github.com/rancher/os.git synced 2025-07-15 23:55:51 +00:00
os/vendor/github.com/sigma/bdoor/check.go
Sven Dowideit be2c4044ce cloudinit tests pass :)
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2017-02-28 13:58:34 +10:00

68 lines
2.0 KiB
Go

// Copyright 2016 Yann Hodique
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package bdoor
// #include <limits.h>
// #include <stdint.h>
// #include <signal.h>
// #include <setjmp.h>
//
// #define VMWARE_BDOOR_MAGIC 0x564D5868
// #define VMWARE_BDOOR_PORT 0x5658
// #define VMWARE_BDOOR_CMD_GETVERSION 10
// #define VMWARE_BDOOR_RUN(cmd, eax, ebx, ecx, edx) \
// __asm__("inl %%dx, %%eax" : \
// "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \
// "0"(VMWARE_BDOOR_MAGIC), \
// "1"(VMWARE_BDOOR_CMD_##cmd), \
// "2"(VMWARE_BDOOR_PORT), \
// "3"(UINT_MAX) : \
// "memory");
//
// static sigjmp_buf env;
//
// void handler(int signal) {
// siglongjmp(env, 1);
// }
//
// int hypervisor_bdoor_check(void) {
// uint32_t eax, ebx, ecx, edx;
// struct sigaction sa, save1, save2;
// int res = 0;
//
// sa.sa_handler = handler;
// sigemptyset(&sa.sa_mask);
// sa.sa_flags = SA_RESTART;
// sigaction(SIGSEGV, &sa, &save1);
// sigaction(SIGILL, &sa, &save2);
//
// if(sigsetjmp(env, 1)==0) {
// VMWARE_BDOOR_RUN(GETVERSION, eax, ebx, ecx, edx);
// if (ebx == VMWARE_BDOOR_MAGIC)
// res = 1;
// }
//
// sa.sa_handler = SIG_DFL;
// sigaction(SIGSEGV, &save1, 0);
// sigaction(SIGILL, &save2, 0);
// return res;
// }
//
import "C"
func HypervisorPortCheck() bool {
return C.hypervisor_bdoor_check() != 0
}