From 64297e67ab392b01203fb17e678bc4e43b54d737 Mon Sep 17 00:00:00 2001 From: Nate Lawson Date: Thu, 8 Jun 2006 17:54:10 +0000 Subject: [PATCH] Minor tweaks to the resume code that might help people debug. * Add hw.acpi.resume_beep tunable and sysctl, default to 0. Beeps the PC speaker soon after waking to diagnose whether the wakeup code is even getting run before other drivers possibly hang the system. To stop the beep, cause another beep (i.e. keyboard bell). Submitted by takawata@, I changed the frequency to be lower. * Use 4096 instead of 4 byte alignment. Might be useful although doesn't seem to be necessary. * Remove a useless assignment to acpi_reset_video. It was overwritten by the default sysctl value anyway. --- sys/i386/acpica/acpi_machdep.c | 8 +++++++- sys/i386/acpica/acpi_wakecode.S | 21 +++++++++++++++++---- sys/i386/acpica/acpi_wakeup.c | 2 ++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/sys/i386/acpica/acpi_machdep.c b/sys/i386/acpica/acpi_machdep.c index e0d5b6787248..867c2e68e726 100644 --- a/sys/i386/acpica/acpi_machdep.c +++ b/sys/i386/acpica/acpi_machdep.c @@ -52,7 +52,9 @@ __FBSDID("$FreeBSD$"); #include -uint32_t acpi_reset_video = 1; +uint32_t acpi_resume_beep; +TUNABLE_INT("hw.acpi.resume_beep", &acpi_resume_beep); +uint32_t acpi_reset_video; TUNABLE_INT("hw.acpi.reset_video", &acpi_reset_video); static int intr_model = ACPI_INTR_PIC; @@ -318,6 +320,10 @@ acpi_machdep_init(device_t dev) else acpi_SetIntrModel(intr_model); + SYSCTL_ADD_UINT(&sc->acpi_sysctl_ctx, + SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, + "resume_beep", CTLFLAG_RD | CTLFLAG_RW, &acpi_resume_beep, 0, + "Beep the PC speaker when resuming"); SYSCTL_ADD_UINT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, "reset_video", CTLFLAG_RD | CTLFLAG_RW, &acpi_reset_video, 0, diff --git a/sys/i386/acpica/acpi_wakecode.S b/sys/i386/acpica/acpi_wakecode.S index c2d30397545d..ecbb4cdc2b32 100644 --- a/sys/i386/acpica/acpi_wakecode.S +++ b/sys/i386/acpica/acpi_wakecode.S @@ -34,7 +34,7 @@ #include "assym.s" - .align 4 + .align 4096 .code16 wakeup_16: nop @@ -49,9 +49,21 @@ wakeup_16: movw %ax,%ss movw $PAGE_SIZE,%sp + /* To debug resume hangs, beep the speaker if the user requested. */ + cmpl $1,resume_beep + jne nobeep + movb $0xc0,%al + outb %al,$0x42 + movb $0x04,%al + outb %al,$0x42 + inb $0x61,%al + orb $0x3,%al + outb %al,$0x61 +nobeep: + /* Re-initialize video BIOS if the reset_video tunable is set. */ - cmp $0,reset_video - je wakeup_16_gdt + cmpl $1,reset_video + jne nobiosreset lcall $0xc000,$3 /* @@ -61,8 +73,8 @@ wakeup_16: movw %cs,%ax movw %ax,%ds movw %ax,%ss +nobiosreset: -wakeup_16_gdt: /* Load GDT for real mode */ lgdt physical_gdt @@ -220,6 +232,7 @@ physical_esp: .long 0 previous_cr2: .long 0 previous_cr3: .long 0 previous_cr4: .long 0 +resume_beep: .long 0 reset_video: .long 0 /* transfer from real mode to protected mode */ diff --git a/sys/i386/acpica/acpi_wakeup.c b/sys/i386/acpica/acpi_wakeup.c index dec1088eaf8a..543c0f2cca8f 100644 --- a/sys/i386/acpica/acpi_wakeup.c +++ b/sys/i386/acpica/acpi_wakeup.c @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #error this file needs sys/cdefs.h as a prerequisite #endif +extern uint32_t acpi_resume_beep; extern uint32_t acpi_reset_video; extern void initializecpu(void); @@ -227,6 +228,7 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) WAKECODE_FIXUP(previous_cr3, uint32_t, r_cr3); WAKECODE_FIXUP(previous_cr4, uint32_t, r_cr4); + WAKECODE_FIXUP(resume_beep, uint32_t, acpi_resume_beep); WAKECODE_FIXUP(reset_video, uint32_t, acpi_reset_video); WAKECODE_FIXUP(previous_tr, uint16_t, r_tr);