2006-10-01 20:40:30 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 18:32:08 +03:00
|
|
|
// $Id$
|
2006-10-01 20:40:30 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 32 bit Bochs BIOS init code
|
|
|
|
// Copyright (C) 2006 Fabrice Bellard
|
2020-01-15 20:06:10 +03:00
|
|
|
// Copyright (C) 2020 The Bochs Project
|
2006-10-01 20:40:30 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
#include "rombios.h"
|
|
|
|
|
2006-09-28 23:01:04 +04:00
|
|
|
.globl _start
|
|
|
|
.globl smp_ap_boot_code_start
|
|
|
|
.globl smp_ap_boot_code_end
|
|
|
|
.global smm_relocation_start
|
|
|
|
.global smm_relocation_end
|
|
|
|
.global smm_code_start
|
|
|
|
.global smm_code_end
|
|
|
|
|
|
|
|
_start:
|
|
|
|
/* clear bss section */
|
|
|
|
xor %eax, %eax
|
|
|
|
mov $__bss_start, %edi
|
2008-12-04 21:44:14 +03:00
|
|
|
mov $__bss_end, %ecx
|
2006-09-28 23:01:04 +04:00
|
|
|
sub %edi, %ecx
|
|
|
|
rep stosb
|
|
|
|
|
2008-12-04 21:44:14 +03:00
|
|
|
/* copy data section */
|
|
|
|
mov $_end, %esi
|
|
|
|
mov $__data_start, %edi
|
|
|
|
mov $__data_end, %ecx
|
|
|
|
sub %edi, %ecx
|
|
|
|
rep movsb
|
|
|
|
|
2006-09-28 23:01:04 +04:00
|
|
|
jmp rombios32_init
|
|
|
|
|
2008-01-26 12:15:27 +03:00
|
|
|
.code16
|
2006-09-28 23:01:04 +04:00
|
|
|
smp_ap_boot_code_start:
|
2009-01-26 12:21:38 +03:00
|
|
|
cli
|
2006-09-28 23:01:04 +04:00
|
|
|
xor %ax, %ax
|
|
|
|
mov %ax, %ds
|
2009-01-26 12:21:38 +03:00
|
|
|
|
|
|
|
mov $SMP_MSR_ADDR, %ebx
|
|
|
|
11:
|
|
|
|
mov 0(%ebx), %ecx
|
|
|
|
test %ecx, %ecx
|
|
|
|
jz 12f
|
|
|
|
mov 4(%ebx), %eax
|
|
|
|
mov 8(%ebx), %edx
|
|
|
|
wrmsr
|
|
|
|
add $12, %ebx
|
|
|
|
jmp 11b
|
|
|
|
12:
|
2020-01-15 20:06:10 +03:00
|
|
|
mov $1, %eax
|
|
|
|
cpuid
|
|
|
|
and $CPUID_EXT_VMX, %ecx
|
|
|
|
jz 13f
|
|
|
|
mov $MSR_FEATURE_CTRL, %ecx
|
|
|
|
rdmsr
|
|
|
|
or $FEATURE_CTRL_LOCK | FEATURE_CTRL_VMX, %eax
|
|
|
|
wrmsr
|
|
|
|
13:
|
2009-01-26 12:21:38 +03:00
|
|
|
|
2008-12-04 21:46:55 +03:00
|
|
|
lock incw smp_cpus
|
2006-09-28 23:01:04 +04:00
|
|
|
1:
|
|
|
|
hlt
|
|
|
|
jmp 1b
|
|
|
|
smp_ap_boot_code_end:
|
|
|
|
|
|
|
|
/* code to relocate SMBASE to 0xa0000 */
|
|
|
|
smm_relocation_start:
|
|
|
|
mov $0x38000 + 0x7efc, %ebx
|
2006-10-01 20:40:30 +04:00
|
|
|
addr32 mov (%ebx), %al /* revision ID to see if x86_64 or x86 */
|
2006-09-28 23:01:04 +04:00
|
|
|
cmp $0x64, %al
|
|
|
|
je 1f
|
|
|
|
mov $0x38000 + 0x7ef8, %ebx
|
|
|
|
jmp 2f
|
|
|
|
1:
|
|
|
|
mov $0x38000 + 0x7f00, %ebx
|
|
|
|
2:
|
|
|
|
movl $0xa0000, %eax
|
2006-10-01 20:40:30 +04:00
|
|
|
addr32 movl %eax, (%ebx)
|
2006-10-02 10:30:36 +04:00
|
|
|
/* indicate to the BIOS that the SMM code was executed */
|
|
|
|
mov $0x00, %al
|
|
|
|
movw $0xb3, %dx
|
|
|
|
outb %al, %dx
|
2008-01-26 12:15:27 +03:00
|
|
|
rsm
|
2006-09-28 23:01:04 +04:00
|
|
|
smm_relocation_end:
|
2008-01-26 12:15:27 +03:00
|
|
|
|
2006-09-28 23:01:04 +04:00
|
|
|
/* minimal SMM code to enable or disable ACPI */
|
|
|
|
smm_code_start:
|
|
|
|
movw $0xb2, %dx
|
|
|
|
inb %dx, %al
|
|
|
|
cmp $0xf0, %al
|
|
|
|
jne 1f
|
|
|
|
|
|
|
|
/* ACPI disable */
|
|
|
|
mov $PM_IO_BASE + 0x04, %dx /* PMCNTRL */
|
|
|
|
inw %dx, %ax
|
|
|
|
andw $~1, %ax
|
|
|
|
outw %ax, %dx
|
|
|
|
|
|
|
|
jmp 2f
|
|
|
|
|
|
|
|
1:
|
|
|
|
cmp $0xf1, %al
|
|
|
|
jne 2f
|
|
|
|
|
|
|
|
/* ACPI enable */
|
|
|
|
mov $PM_IO_BASE + 0x04, %dx /* PMCNTRL */
|
|
|
|
inw %dx, %ax
|
|
|
|
orw $1, %ax
|
|
|
|
outw %ax, %dx
|
2008-01-26 12:15:27 +03:00
|
|
|
|
2006-09-28 23:01:04 +04:00
|
|
|
2:
|
|
|
|
rsm
|
|
|
|
smm_code_end:
|