On Fri, Aug 09, 2013 at 11:30:14PM -0400, Kevin O'Connor wrote: > On Fri, Aug 09, 2013 at 11:45:59AM +0200, Gerd Hoffmann wrote: > > Hi, > > > > > Converting src/smm.c to use a runtime value isn't hard - just change > > > the assembler from: "mov $" __stringify(PORT_ACPI_PM_BASE) " + 0x04, > > > %dx\n" to: "mov 4(my_acpi_base), %dx\n" and make sure to define the > > > global variable my_acpi_base as VARFSEG. > > > > The apm fix brought a ctl register variable we can use directly, so I > > tried the attached patch, then got this: > > > > Linking out/rom.o > > out/code32flat.o: In function `smm_relocation_end': > > (.text.asm./home/kraxel/projects/seabios/src/smm.c.72+0x37): relocation > > truncated to fit: R_386_16 against symbol `acpi_pm1a_cnt' defined in > > .data.varfseg./home/kraxel/projects/seabios/src/acpi.c.21 section in > > out/code32flat.o > > out/code32flat.o: In function `smm_relocation_end': > > (.text.asm./home/kraxel/projects/seabios/src/smm.c.72+0x46): relocation > > truncated to fit: R_386_16 against symbol `acpi_pm1a_cnt' defined in > > .data.varfseg./home/kraxel/projects/seabios/src/acpi.c.21 section in > > out/code32flat.o > > make: *** [out/rom.o] Error 1 > > Use "addr32 movw (acpi_pm1a_cnt), %dx" instead of "mov > (acpi_pm1a_cnt), %dx".
I ran a quick test and the two attached patches seem to work okay. -Kevin
>From 8799c75ad8f1c4b7573f5117dbf695f4b98a9131 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor <ke...@koconnor.net> Date: Sat, 10 Aug 2013 11:39:14 -0400 Subject: [PATCH 1/2] Minor cleanups to smm assembler. To: seab...@seabios.org Use size prefixes on assembler instructions. Split the relocation smm handler into a separate section from the main runtime smm handler. Signed-off-by: Kevin O'Connor <ke...@koconnor.net> --- src/smm.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/smm.c b/src/smm.c index a424a29..d8473fd 100644 --- a/src/smm.c +++ b/src/smm.c @@ -16,31 +16,35 @@ ASM32FLAT( ".global smm_relocation_start\n" ".global smm_relocation_end\n" - ".global smm_code_start\n" - ".global smm_code_end\n" - " .code16\n" + " .code16gcc\n" /* code to relocate SMBASE to 0xa0000 */ "smm_relocation_start:\n" - " mov $" __stringify(BUILD_SMM_INIT_ADDR) " + 0x7efc, %ebx\n" - " addr32 mov (%ebx), %al\n" /* revision ID to see if x86_64 or x86 */ - " cmp $0x64, %al\n" + " movl $" __stringify(BUILD_SMM_INIT_ADDR) " + 0x7efc, %ebx\n" + " addr32 movb (%ebx), %al\n" /* revision ID to see if x86_64 or x86 */ + " cmpb $0x64, %al\n" " je 1f\n" - " mov $" __stringify(BUILD_SMM_INIT_ADDR) " + 0x7ef8, %ebx\n" + " movl $" __stringify(BUILD_SMM_INIT_ADDR) " + 0x7ef8, %ebx\n" " jmp 2f\n" "1:\n" - " mov $" __stringify(BUILD_SMM_INIT_ADDR) " + 0x7f00, %ebx\n" + " movl $" __stringify(BUILD_SMM_INIT_ADDR) " + 0x7f00, %ebx\n" "2:\n" " movl $" __stringify(BUILD_SMM_ADDR) " - 0x8000, %eax\n" " addr32 movl %eax, (%ebx)\n" /* indicate to the BIOS that the SMM code was executed */ - " mov $0x00, %al\n" + " movb $0x00, %al\n" " movw $" __stringify(PORT_SMI_STATUS) ", %dx\n" " outb %al, %dx\n" " rsm\n" "smm_relocation_end:\n" + " .code32\n" + ); +ASM32FLAT( /* minimal SMM code to enable or disable ACPI */ + ".global smm_code_start\n" + ".global smm_code_end\n" + " .code16gcc\n" "smm_code_start:\n" " movw $" __stringify(PORT_SMI_CMD) ", %dx\n" " inb %dx, %al\n" @@ -48,7 +52,7 @@ ASM32FLAT( " jne 1f\n" /* ACPI disable */ - " mov $" __stringify(PORT_ACPI_PM_BASE) " + 0x04, %dx\n" /* PMCNTRL */ + " movw $" __stringify(PORT_ACPI_PM_BASE) " + 0x04, %dx\n" /* PMCNTRL */ " inw %dx, %ax\n" " andw $~1, %ax\n" " outw %ax, %dx\n" @@ -56,11 +60,11 @@ ASM32FLAT( " jmp 2f\n" "1:\n" - " cmp $0xf1, %al\n" + " cmpb $0xf1, %al\n" " jne 2f\n" /* ACPI enable */ - " mov $" __stringify(PORT_ACPI_PM_BASE) " + 0x04, %dx\n" /* PMCNTRL */ + " movw $" __stringify(PORT_ACPI_PM_BASE) " + 0x04, %dx\n" /* PMCNTRL */ " inw %dx, %ax\n" " orw $1, %ax\n" " outw %ax, %dx\n" -- 1.7.11.7
>From 8a1e7b8f698a3e459d61c489feae602ed9bc83fc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor <ke...@koconnor.net> Date: Sat, 10 Aug 2013 11:48:00 -0400 Subject: [PATCH 2/2] make pmbase runtime To: seab...@seabios.org Signed-off-by: Gerd Hoffmann <kra...@redhat.com> --- src/acpi.c | 2 +- src/acpi.h | 2 +- src/smm.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/acpi.c b/src/acpi.c index 8db1ed4..db33595 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -18,7 +18,7 @@ #include "acpi-dsdt.hex" -u32 acpi_pm1a_cnt VARFSEG; +u16 acpi_pm1a_cnt VARFSEG; static void build_header(struct acpi_table_header *h, u32 sig, int len, u8 rev) diff --git a/src/acpi.h b/src/acpi.h index f0d24d4..5c478a1 100644 --- a/src/acpi.h +++ b/src/acpi.h @@ -36,7 +36,7 @@ struct rsdp_descriptor { /* Root System Descriptor Pointer */ }; extern struct rsdp_descriptor *RsdpAddr; -extern u32 acpi_pm1a_cnt; +extern u16 acpi_pm1a_cnt; /* Table structure from Linux kernel (the ACPI tables are under the BSD license) */ diff --git a/src/smm.c b/src/smm.c index d8473fd..b06107e 100644 --- a/src/smm.c +++ b/src/smm.c @@ -52,7 +52,7 @@ ASM32FLAT( " jne 1f\n" /* ACPI disable */ - " movw $" __stringify(PORT_ACPI_PM_BASE) " + 0x04, %dx\n" /* PMCNTRL */ + " addr32 movw (acpi_pm1a_cnt), %dx\n" /* PMCNTRL */ " inw %dx, %ax\n" " andw $~1, %ax\n" " outw %ax, %dx\n" @@ -64,7 +64,7 @@ ASM32FLAT( " jne 2f\n" /* ACPI enable */ - " movw $" __stringify(PORT_ACPI_PM_BASE) " + 0x04, %dx\n" /* PMCNTRL */ + " addr32 movw (acpi_pm1a_cnt), %dx\n" /* PMCNTRL */ " inw %dx, %ax\n" " orw $1, %ax\n" " outw %ax, %dx\n" -- 1.7.11.7