Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/i386/libi386/i386_module.c
| /*- | /*- | ||||
| * Copyright (c) 2016 Microsoft Corp. | |||||
| * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> | * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> | ||||
| * All rights reserved. | * All rights reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| * modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
| * are met: | * are met: | ||||
| * 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
| * notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
| Show All 16 Lines | |||||
| #include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
| __FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
| /* | /* | ||||
| * i386-specific module functionality. | * i386-specific module functionality. | ||||
| * | * | ||||
| */ | */ | ||||
| #include <bootstrap.h> | |||||
| #include <stand.h> | |||||
| #include <string.h> | |||||
| #include <machine/cpufunc.h> | |||||
| #define HV_UNKNOWN 0 | |||||
| #define HV_XEN 1 | |||||
| #define HV_HYPERV 2 | |||||
| /* See the kernel's function identify_hypervisor(). */ | |||||
| static int | |||||
| get_hypervisor(void) | |||||
| { | |||||
| unsigned int regs[4]; | |||||
| char hv_vendor[13]; | |||||
| do_cpuid(1, regs); | |||||
| if (regs[2] & 0x80000000) { | |||||
| do_cpuid(0x40000000, regs); | |||||
| if (regs[0] >= 0x40000000) { | |||||
| ((u_int *)&hv_vendor)[0] = regs[1]; | |||||
| ((u_int *)&hv_vendor)[1] = regs[2]; | |||||
| ((u_int *)&hv_vendor)[2] = regs[3]; | |||||
| hv_vendor[12] = '\0'; | |||||
| if (strcmp(hv_vendor, "Microsoft Hv") == 0) | |||||
| return (HV_HYPERV); | |||||
| } | |||||
| } | |||||
| return (HV_UNKNOWN); | |||||
| } | |||||
| /* | /* | ||||
| * Use voodoo to load modules required by current hardware. | * Use voodoo to load modules required by current hardware. | ||||
| */ | */ | ||||
| int | int | ||||
| i386_autoload(void) | i386_autoload(void) | ||||
| { | { | ||||
| switch(get_hypervisor()) { | |||||
| case HV_HYPERV: | |||||
| mod_loadkld("hyperv.ko", 0, NULL); | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| /* XXX use PnP to locate stuff here */ | /* XXX use PnP to locate stuff here */ | ||||
| return(0); | return(0); | ||||
| } | } | ||||