a5bd9f6
From 3f4af0c00ca064488a7186696fecf27a55a2165f Mon Sep 17 00:00:00 2001
a5bd9f6
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
a5bd9f6
Date: Thu, 11 Apr 2013 21:09:43 +0200
a5bd9f6
Subject: [PATCH 278/364] 	Use ACPI shutdown intests as traditional port
a5bd9f6
 was removed.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog                                   |  4 +++
a5bd9f6
 grub-core/tests/boot/kbsd.init-i386.S       | 20 +------------
a5bd9f6
 grub-core/tests/boot/kbsd.init-x86_64.S     | 19 +-----------
a5bd9f6
 grub-core/tests/boot/kernel-8086.S          | 21 +-------------
a5bd9f6
 grub-core/tests/boot/kernel-i386.S          | 21 ++------------
a5bd9f6
 grub-core/tests/boot/kfreebsd.init-i386.S   | 45 +++++++++++++----------------
a5bd9f6
 grub-core/tests/boot/kfreebsd.init-x86_64.S | 40 ++++++++++---------------
a5bd9f6
 grub-core/tests/boot/linux.init-i386.S      | 20 +------------
a5bd9f6
 grub-core/tests/boot/linux.init-x86_64.S    | 20 +------------
a5bd9f6
 grub-core/tests/boot/qemu-shutdown-x86.S    |  9 ++++++
a5bd9f6
 10 files changed, 56 insertions(+), 163 deletions(-)
a5bd9f6
 create mode 100644 grub-core/tests/boot/qemu-shutdown-x86.S
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index bb6d97b..614748a 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,3 +1,7 @@
a5bd9f6
+2013-04-11  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
+
a5bd9f6
+	Use ACPI shutdown intests as traditional port was removed.
a5bd9f6
+
a5bd9f6
 2013-04-11  Andrey Borzenkov <arvidjaar@gmail.com>
a5bd9f6
 
a5bd9f6
 	* util/grub.d/30_os-prober.in: Add onstr to entries for visual
a5bd9f6
diff --git a/grub-core/tests/boot/kbsd.init-i386.S b/grub-core/tests/boot/kbsd.init-i386.S
a5bd9f6
index 7011c79..72ddb7c 100644
a5bd9f6
--- a/grub-core/tests/boot/kbsd.init-i386.S
a5bd9f6
+++ b/grub-core/tests/boot/kbsd.init-i386.S
a5bd9f6
@@ -37,8 +37,6 @@
a5bd9f6
 #define RESET_HALT 0x8
a5bd9f6
 #define RESET_POWEROFF 0x800
a5bd9f6
 
a5bd9f6
-#define SHUTDOWN_PORT 0x8900
a5bd9f6
-
a5bd9f6
 	.section ".init", "ax"
a5bd9f6
 	.global start,_start
a5bd9f6
 start:
a5bd9f6
@@ -72,23 +70,7 @@ _start:
a5bd9f6
 	int $SYSCALL_INT
a5bd9f6
 	addl $12, %esp
a5bd9f6
 
a5bd9f6
-	movw $SHUTDOWN_PORT, %dx
a5bd9f6
-	movb $'S', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'h', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'u', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'t', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'d', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'o', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'w', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'n', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
+#include "qemu-shutdown-x86.S"
a5bd9f6
 
a5bd9f6
 	/* shutdown.  */
a5bd9f6
 	movl $SYSCALL_RESET, %eax
a5bd9f6
diff --git a/grub-core/tests/boot/kbsd.init-x86_64.S b/grub-core/tests/boot/kbsd.init-x86_64.S
a5bd9f6
index 81f810e..7486bc3 100644
a5bd9f6
--- a/grub-core/tests/boot/kbsd.init-x86_64.S
a5bd9f6
+++ b/grub-core/tests/boot/kbsd.init-x86_64.S
a5bd9f6
@@ -35,7 +35,6 @@
a5bd9f6
 #define RESET_NOSYNC 0x4
a5bd9f6
 #define RESET_HALT 0x8
a5bd9f6
 #define RESET_POWEROFF 0x800
a5bd9f6
-#define SHUTDOWN_PORT 0x8900
a5bd9f6
 
a5bd9f6
 	.section ".init", "ax"
a5bd9f6
 	.global start,_start
a5bd9f6
@@ -61,23 +60,7 @@ _start:
a5bd9f6
 	leaq iopl_arg, %rsi
a5bd9f6
 	syscall
a5bd9f6
 
a5bd9f6
-	movw $SHUTDOWN_PORT, %dx
a5bd9f6
-	movb $'S', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'h', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'u', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'t', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'d', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'o', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'w', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'n', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
+#include "qemu-shutdown-x86.S"
a5bd9f6
 
a5bd9f6
 	/* shutdown.  */
a5bd9f6
 	movq $SYSCALL_RESET, %rax
a5bd9f6
diff --git a/grub-core/tests/boot/kernel-8086.S b/grub-core/tests/boot/kernel-8086.S
a5bd9f6
index 20040da..510897c 100644
a5bd9f6
--- a/grub-core/tests/boot/kernel-8086.S
a5bd9f6
+++ b/grub-core/tests/boot/kernel-8086.S
a5bd9f6
@@ -1,6 +1,4 @@
a5bd9f6
 
a5bd9f6
-#define SHUTDOWN_PORT 0x8900
a5bd9f6
-
a5bd9f6
 	.text
a5bd9f6
 	.globl _start
a5bd9f6
 _start:
a5bd9f6
@@ -8,18 +6,6 @@ base:
a5bd9f6
 	.code16
a5bd9f6
 	jmp cont
a5bd9f6
 
a5bd9f6
-portmsg:
a5bd9f6
-	xorw %ax, %ax
a5bd9f6
-1:	
a5bd9f6
-	movb 0(%si), %al
a5bd9f6
-	test %ax, %ax
a5bd9f6
-	jz 1f
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	incw %si
a5bd9f6
-	jmp 1b
a5bd9f6
-1:
a5bd9f6
-	ret
a5bd9f6
-
a5bd9f6
 serialmsg:	
a5bd9f6
 1:	
a5bd9f6
 	movb 0(%si), %bl
a5bd9f6
@@ -50,17 +36,12 @@ cont:
a5bd9f6
 	movw %ax, %ds
a5bd9f6
 	lea message, %si
a5bd9f6
 	call serialmsg
a5bd9f6
-	lea shutdown, %si
a5bd9f6
-	movw $SHUTDOWN_PORT, %dx
a5bd9f6
-	call portmsg
a5bd9f6
+#include "qemu-shutdown-x86.S"
a5bd9f6
 
a5bd9f6
 1:
a5bd9f6
 	hlt
a5bd9f6
 	jmp 1b
a5bd9f6
 
a5bd9f6
-shutdown:
a5bd9f6
-	.ascii "Shutdown"
a5bd9f6
-	.byte 0
a5bd9f6
 message:
a5bd9f6
 	.ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
a5bd9f6
 	.byte 0
a5bd9f6
diff --git a/grub-core/tests/boot/kernel-i386.S b/grub-core/tests/boot/kernel-i386.S
a5bd9f6
index 904b0d4..2154d3b 100644
a5bd9f6
--- a/grub-core/tests/boot/kernel-i386.S
a5bd9f6
+++ b/grub-core/tests/boot/kernel-i386.S
a5bd9f6
@@ -5,8 +5,6 @@
a5bd9f6
 #include <multiboot.h>
a5bd9f6
 #endif
a5bd9f6
 
a5bd9f6
-#define SHUTDOWN_PORT 0x8900
a5bd9f6
-
a5bd9f6
 	.text
a5bd9f6
 	/* Align 32 bits boundary.  */
a5bd9f6
 	.align	8
a5bd9f6
@@ -38,17 +36,6 @@ multiboot_header:
a5bd9f6
 #endif
a5bd9f6
 	
a5bd9f6
 	.global start
a5bd9f6
-portmsg:
a5bd9f6
-	xorl %eax, %eax
a5bd9f6
-1:	
a5bd9f6
-	movb 0(%esi), %al
a5bd9f6
-	test %eax, %eax
a5bd9f6
-	jz 1f
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	incl %esi
a5bd9f6
-	jmp 1b
a5bd9f6
-1:
a5bd9f6
-	ret
a5bd9f6
 
a5bd9f6
 serialmsg:	
a5bd9f6
 1:	
a5bd9f6
@@ -73,17 +60,13 @@ serialmsg:
a5bd9f6
 _start:
a5bd9f6
 	lea message, %esi
a5bd9f6
 	call serialmsg
a5bd9f6
-	lea shutdown, %esi
a5bd9f6
-	movw $SHUTDOWN_PORT, %dx
a5bd9f6
-	call portmsg
a5bd9f6
+
a5bd9f6
+#include "qemu-shutdown-x86.S"
a5bd9f6
 
a5bd9f6
 1:
a5bd9f6
 	hlt
a5bd9f6
 	jmp 1b
a5bd9f6
 
a5bd9f6
-shutdown:
a5bd9f6
-	.ascii "Shutdown"
a5bd9f6
-	.byte 0
a5bd9f6
 message:
a5bd9f6
 	.ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
a5bd9f6
 	.byte 0
a5bd9f6
diff --git a/grub-core/tests/boot/kfreebsd.init-i386.S b/grub-core/tests/boot/kfreebsd.init-i386.S
a5bd9f6
index 12c94a0..a448152 100644
a5bd9f6
--- a/grub-core/tests/boot/kfreebsd.init-i386.S
a5bd9f6
+++ b/grub-core/tests/boot/kfreebsd.init-i386.S
a5bd9f6
@@ -24,13 +24,12 @@
a5bd9f6
 #define SYSCALL_FSYNC 95
a5bd9f6
 #define SYSCALL_ARCH 165
a5bd9f6
 #define SYSCALL_EXIT 1
a5bd9f6
-#define SYSCALL_ARCH_IOPL	4
a5bd9f6
+#define SYSCALL_ARCH_IOPERM	4
a5bd9f6
 #define SYSCALL_INT 0x80
a5bd9f6
 
a5bd9f6
 #define RESET_NOSYNC 0x4
a5bd9f6
 #define RESET_HALT 0x8
a5bd9f6
 #define RESET_POWEROFF 0x4000
a5bd9f6
-#define SHUTDOWN_PORT 0x8900
a5bd9f6
 
a5bd9f6
 	.section ".init", "ax"
a5bd9f6
 	.global start,_start
a5bd9f6
@@ -64,31 +63,23 @@ _start:
a5bd9f6
 	int $SYSCALL_INT
a5bd9f6
 	addl $8, %esp
a5bd9f6
 
a5bd9f6
-	/* IOPL.  */
a5bd9f6
+	/* IOPERM.  */
a5bd9f6
 	movl $SYSCALL_ARCH, %eax
a5bd9f6
-	pushl $iopl_arg
a5bd9f6
-	pushl $SYSCALL_ARCH_IOPL
a5bd9f6
+	pushl $iopl_arg1
a5bd9f6
+	pushl $SYSCALL_ARCH_IOPERM
a5bd9f6
 	pushl $0
a5bd9f6
 	int $SYSCALL_INT
a5bd9f6
 	addl $12, %esp
a5bd9f6
-	
a5bd9f6
-	movw $SHUTDOWN_PORT, %dx
a5bd9f6
-	movb $'S', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'h', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'u', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'t', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'d', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'o', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'w', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'n', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
+
a5bd9f6
+	/* IOPERM.  */
a5bd9f6
+	movl $SYSCALL_ARCH, %eax
a5bd9f6
+	pushl $iopl_arg2
a5bd9f6
+	pushl $SYSCALL_ARCH_IOPERM
a5bd9f6
+	pushl $0
a5bd9f6
+	int $SYSCALL_INT
a5bd9f6
+	addl $12, %esp
a5bd9f6
+
a5bd9f6
+#include "qemu-shutdown-x86.S"
a5bd9f6
 	
a5bd9f6
 	/* shutdown.  */
a5bd9f6
 	movl $SYSCALL_RESET, %eax
a5bd9f6
@@ -108,7 +99,11 @@ device:
a5bd9f6
 message:
a5bd9f6
 	.ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
a5bd9f6
 messageend:
a5bd9f6
-iopl_arg:
a5bd9f6
-	.long SHUTDOWN_PORT
a5bd9f6
+ioperm_arg1:
a5bd9f6
+	.long 0xcf8
a5bd9f6
+	.long 8
a5bd9f6
 	.long 1
a5bd9f6
+ioperm_arg2:
a5bd9f6
+	.long 0x1000
a5bd9f6
+	.long 8
a5bd9f6
 	.long 1
a5bd9f6
diff --git a/grub-core/tests/boot/kfreebsd.init-x86_64.S b/grub-core/tests/boot/kfreebsd.init-x86_64.S
a5bd9f6
index 0a9ff51..de7bab6 100644
a5bd9f6
--- a/grub-core/tests/boot/kfreebsd.init-x86_64.S
a5bd9f6
+++ b/grub-core/tests/boot/kfreebsd.init-x86_64.S
a5bd9f6
@@ -23,13 +23,12 @@
a5bd9f6
 #define SYSCALL_WRITE 4
a5bd9f6
 #define SYSCALL_RESET 55
a5bd9f6
 #define SYSCALL_EXIT 1
a5bd9f6
-#define SYSCALL_ARCH_IOPL	4
a5bd9f6
+#define SYSCALL_ARCH_IOPERM	4
a5bd9f6
 #define SYSCALL_FSYNC 95
a5bd9f6
 
a5bd9f6
 #define RESET_NOSYNC 0x4
a5bd9f6
 #define RESET_HALT 0x8
a5bd9f6
 #define RESET_POWEROFF 0x4000
a5bd9f6
-#define SHUTDOWN_PORT 0x8900
a5bd9f6
 
a5bd9f6
 	.section ".init", "ax"
a5bd9f6
 	.global start,_start
a5bd9f6
@@ -53,29 +52,18 @@ _start:
a5bd9f6
 	movq $SYSCALL_FSYNC, %rax
a5bd9f6
 	syscall
a5bd9f6
 
a5bd9f6
-	/* IOPL.  */
a5bd9f6
+	/* IOPERM.  */
a5bd9f6
 	movq $SYSCALL_ARCH, %rax
a5bd9f6
-	movq $SYSCALL_ARCH_IOPL, %rdi
a5bd9f6
-	leaq iopl_arg, %rsi
a5bd9f6
+	movq $SYSCALL_ARCH_IOPERM, %rdi
a5bd9f6
+	leaq ioperm_arg1, %rsi
a5bd9f6
 	syscall
a5bd9f6
 
a5bd9f6
-	movw $SHUTDOWN_PORT, %dx
a5bd9f6
-	movb $'S', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'h', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'u', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'t', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'d', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'o', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'w', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'n', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
+	movq $SYSCALL_ARCH, %rax
a5bd9f6
+	movq $SYSCALL_ARCH_IOPERM, %rdi
a5bd9f6
+	leaq ioperm_arg2, %rsi
a5bd9f6
+	syscall
a5bd9f6
+
a5bd9f6
+#include "qemu-shutdown-x86.S"
a5bd9f6
 	
a5bd9f6
 	/* shutdown.  */
a5bd9f6
 	movq $SYSCALL_RESET, %rax
a5bd9f6
@@ -92,7 +80,11 @@ device:
a5bd9f6
 message:
a5bd9f6
 	.ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
a5bd9f6
 messageend:
a5bd9f6
-iopl_arg:
a5bd9f6
-	.long SHUTDOWN_PORT
a5bd9f6
+ioperm_arg1:
a5bd9f6
+	.long 0xcf8
a5bd9f6
+	.long 8
a5bd9f6
 	.long 1
a5bd9f6
+ioperm_arg2:
a5bd9f6
+	.long 0x1000
a5bd9f6
+	.long 8
a5bd9f6
 	.long 1
a5bd9f6
diff --git a/grub-core/tests/boot/linux.init-i386.S b/grub-core/tests/boot/linux.init-i386.S
a5bd9f6
index 5b0088e..c0983ac 100644
a5bd9f6
--- a/grub-core/tests/boot/linux.init-i386.S
a5bd9f6
+++ b/grub-core/tests/boot/linux.init-i386.S
a5bd9f6
@@ -27,8 +27,6 @@
a5bd9f6
 #define SHUTDOWN_MAGIC2 0x28121969
a5bd9f6
 #define SHUTDOWN_MAGIC3 0x4321fedc
a5bd9f6
 
a5bd9f6
-#define SHUTDOWN_PORT 0x8900
a5bd9f6
-
a5bd9f6
 	.text
a5bd9f6
 	.global start, _start
a5bd9f6
 _start:
a5bd9f6
@@ -44,23 +42,7 @@ start:
a5bd9f6
 	movl $3, %ebx
a5bd9f6
 	int $SYSCALL_INT
a5bd9f6
 
a5bd9f6
-	movw $SHUTDOWN_PORT, %dx
a5bd9f6
-	movb $'S', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'h', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'u', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'t', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'d', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'o', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'w', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'n', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
+#include "qemu-shutdown-x86.S"
a5bd9f6
 	
a5bd9f6
 	/* shutdown.  */
a5bd9f6
 	movl $SYSCALL_RESET, %eax
a5bd9f6
diff --git a/grub-core/tests/boot/linux.init-x86_64.S b/grub-core/tests/boot/linux.init-x86_64.S
a5bd9f6
index fc32dfd..90bdcc3 100644
a5bd9f6
--- a/grub-core/tests/boot/linux.init-x86_64.S
a5bd9f6
+++ b/grub-core/tests/boot/linux.init-x86_64.S
a5bd9f6
@@ -26,8 +26,6 @@
a5bd9f6
 #define SHUTDOWN_MAGIC2 0x28121969
a5bd9f6
 #define SHUTDOWN_MAGIC3 0x4321fedc
a5bd9f6
 
a5bd9f6
-#define SHUTDOWN_PORT 0x8900
a5bd9f6
-
a5bd9f6
 	.text
a5bd9f6
 	.global start, _start
a5bd9f6
 _start:
a5bd9f6
@@ -43,23 +41,7 @@ start:
a5bd9f6
 	movq $3, %rdi
a5bd9f6
 	syscall
a5bd9f6
 
a5bd9f6
-	movw $SHUTDOWN_PORT, %dx
a5bd9f6
-	movb $'S', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'h', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'u', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'t', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'d', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'o', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'w', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
-	movb $'n', %al
a5bd9f6
-	outb %al, %dx
a5bd9f6
+#include "qemu-shutdown-x86.S"
a5bd9f6
 	
a5bd9f6
 	/* shutdown.  */
a5bd9f6
 	movq $SYSCALL_RESET, %rax
a5bd9f6
diff --git a/grub-core/tests/boot/qemu-shutdown-x86.S b/grub-core/tests/boot/qemu-shutdown-x86.S
a5bd9f6
new file mode 100644
a5bd9f6
index 0000000..8f794fc
a5bd9f6
--- /dev/null
a5bd9f6
+++ b/grub-core/tests/boot/qemu-shutdown-x86.S
a5bd9f6
@@ -0,0 +1,9 @@
a5bd9f6
+	movl $0x80000b40, %eax
a5bd9f6
+	movw $0xcf8, %dx
a5bd9f6
+	outl  %eax, %dx
a5bd9f6
+	movl $0x1001, %eax
a5bd9f6
+	movw $0xcfc, %dx
a5bd9f6
+	outl  %eax, %dx
a5bd9f6
+	movw $0x2000, %ax
a5bd9f6
+	movw $0x1004, %dx	
a5bd9f6
+	outw  %ax, %dx
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6