diff options
| author | jmcneill <jmcneill@NetBSD.org> | 2007-12-09 20:27:42 +0000 |
|---|---|---|
| committer | jmcneill <jmcneill@NetBSD.org> | 2007-12-09 20:27:42 +0000 |
| commit | 4c1d81b2b5fa658e9fd5e7151eb40ba71ba676da (patch) | |
| tree | 3f8b0d6c63745bde8809b8c6f9e4f6b1514f335e /sys | |
| parent | 3947df41d16da8b387239b9b87789bfbe950a3b2 (diff) | |
Merge jmcneill-pm branch.
Diffstat (limited to 'sys')
414 files changed, 30189 insertions, 18889 deletions
diff --git a/sys/arch/amd64/acpi/acpi_wakecode.S b/sys/arch/amd64/acpi/acpi_wakecode.S new file mode 100644 index 00000000000..942b150e617 --- /dev/null +++ b/sys/arch/amd64/acpi/acpi_wakecode.S @@ -0,0 +1,249 @@ +/* $NetBSD: acpi_wakecode.S,v 1.2 2007/12/09 20:27:42 jmcneill Exp $ */ + +/*- + * Copyright (c) 2007 Joerg Sonnenberger <joerg@netbsd.org> + * + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Takuya SHIOZAKI. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +/* + * This code is derived from FreeBSD. Original copyrights: + * + * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org> + * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * FreeBSD: src/sys/i386/acpica/acpi_wakecode.S,v 1.1 2001/07/20 06:07:31 takawata Exp + */ + +#define _LOCORE + +#include <machine/psl.h> +#include <machine/specialreg.h> +#include <machine/segments.h> + +#define ACPI_WAKEUP_ADDR 0x3000 + + .text + .code16 + .org 0 /* ACPI spec says: cs==(phys>>8), ip==(phys&0x000F) */ + .globl wakeup_16 +wakeup_16: + nop + cli + cld + + /* Set up segment registers for real mode */ + movw %cs,%ax + movw %ax,%ds + movw %ax,%ss + + /* Small call stack */ + mov $0x1000,%sp + + /* Clear flags */ + pushl $0 + popfl + + /* Only beep on reset if machdep.acpi_beep_on_reset=1 */ + cmpb $1,WAKEUP_beep_on_reset + jne 1f + movb $0xc0,%al + outb %al,$0x42 + movb $0x04,%al + outb %al,$0x42 + inb $0x61,%al + orb $0x3,%al + outb %al,$0x61 +1: + + /* Only reset the VBIOS if machdep.acpi_vbios_reset=1 */ + cmpb $1,WAKEUP_vbios_reset + jne 1f + + /* Kick the VBIOS. */ + lcall $0xc000,$3 + + /* Reset registers in case the VBIOS changed them. */ + movw %cs,%ax + movw %ax,%ds + movw %ax,%ss +1: + + /* Disable beep again if machdep.acpi_beep_on_reset=1 */ + cmpb $1,WAKEUP_beep_on_reset + jne 1f + inb $0x61,%al + andb $0xfc,%al + outb %al,$0x61 +1: + + /* Load temporary 32bit GDT */ + data32 addr32 lgdt tmp_gdt + + /* Enable protected mode w/o paging */ + mov %cr0,%eax + orl $(CR0_PE),%eax + mov %eax,%cr0 + +wakeup_sw32: + /* + * Switch to protected mode by intersegmental jump. + * Target and everything else has to compensate for the new origin + * as this is using the flat memory model now. + */ + + ljmpl $0x8,$wakeup_32 + ACPI_WAKEUP_ADDR + + .code32 + .align 16 +wakeup_32: + /* + * Switched to protected mode w/o paging + */ + + nop + /* Set up segment registers and initial stack for protected mode */ + movw $0x10, %ax + movw %ax,%ds + movw %ax,%ss + + movl $(ACPI_WAKEUP_ADDR + 4096),%esp + + /* First, reset the PSL. */ + pushl $PSL_MBO + popfl + + /* Enable PAE and potentially PSE */ + movl $(CR4_PAE|CR4_OSFXSR|CR4_OSXMMEXCPT|CR4_PSE),%eax + movl %eax,%cr4 + + /* Enable SYSCALL extension and Long Mode */ + movl $MSR_EFER,%ecx + rdmsr + xorl %eax,%eax + orl $(EFER_LME|EFER_SCE),%eax + wrmsr + + /* Load temporary PML4, code will switch to full PML4 later */ + movl WAKEUP_r_cr3 + ACPI_WAKEUP_ADDR,%eax + movl %eax,%cr3 + + /* Enable paging */ + movl %cr0,%eax + orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP),%eax + movl %eax,%cr0 + /* Flush prefetch queue */ + jmp 1f +1: + /* Switch to temporary 64bit GDT */ + lgdt tmp_gdt64 + ACPI_WAKEUP_ADDR + + /* Switch to long mode using intersegmental jump. */ + ljmp $0x8, $wakeup_64 + ACPI_WAKEUP_ADDR + + .code64 +wakeup_64: + + /* Reload normal segment registers with correct values */ + movw $GSEL(GDATA_SEL, SEL_KPL),%ax + movw %ax,%ds + movw %ax,%es + movw %ax,%ss + + movq WAKEUP_restorecpu + ACPI_WAKEUP_ADDR,%rbx + + /* Continue with wakeup in the high-level wakeup code */ + jmp *%rbx + + .align 8 +tmp_gdt: + .word 0xffff + .long tmp_gdtable + ACPI_WAKEUP_ADDR + + .align 8, 0 +tmp_gdtable: + /* null */ + .word 0, 0 + .byte 0, 0, 0, 0 + /* code */ + .word 0xffff, 0 + .byte 0, 0x9f, 0xcf, 0 + /* data */ + .word 0xffff, 0 + .byte 0, 0x93, 0xcf, 0 + +tmp_gdt64: + .word 0xffff + .long tmp_gdtable64 + ACPI_WAKEUP_ADDR + +tmp_gdtable64: + .quad 0x0000000000000000 + .quad 0x00af9a000000ffff + .quad 0x00cf92000000ffff + + .align 16, 0 + .global WAKEUP_r_cr3 +WAKEUP_r_cr3: .quad 0 + + .global WAKEUP_restorecpu +WAKEUP_restorecpu: .quad 0 + + .global WAKEUP_vbios_reset +WAKEUP_vbios_reset: .byte 0 + .global WAKEUP_beep_on_reset +WAKEUP_beep_on_reset: .byte 0 diff --git a/sys/arch/amd64/acpi/acpi_wakeup.c b/sys/arch/amd64/acpi/acpi_wakeup.c index 138b642e517..c7b6c70a04b 100644 --- a/sys/arch/amd64/acpi/acpi_wakeup.c +++ b/sys/arch/amd64/acpi/acpi_wakeup.c @@ -1,19 +1,299 @@ -/* $NetBSD: acpi_wakeup.c,v 1.3 2005/12/11 12:16:21 christos Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.4 2007/12/09 20:27:42 jmcneill Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Takuya SHIOZAKI. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.3 2005/12/11 12:16:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.4 2007/12/09 20:27:42 jmcneill Exp $"); + +/*- + * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org> + * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * FreeBSD: src/sys/i386/acpica/acpi_wakeup.c,v 1.9 2002/01/10 03:26:46 wes Exp + */ -#include <sys/types.h> +#include <sys/param.h> #include <sys/systm.h> +#include <sys/kernel.h> +#include <machine/bus.h> +#include <sys/proc.h> +#include <sys/sysctl.h> + +#include <uvm/uvm_extern.h> +#include <uvm/uvm_page.h> + +#include "ioapic.h" +#include "lapic.h" +#if NLAPIC > 0 +#include <machine/i82489var.h> +#endif +#if NIOAPIC > 0 +#include <machine/i82093var.h> +#endif +#include <machine/i8259.h> + +#include "acpi.h" + +#include <dev/ic/i8253reg.h> #include <dev/acpi/acpica.h> #include <dev/acpi/acpivar.h> #define ACPI_MACHDEP_PRIVATE #include <machine/acpi_machdep.h> +#include <machine/cpu.h> +#include <machine/fpu.h> +#include <machine/mtrr.h> + +#include <x86/cpuvar.h> + +#include "acpi_wakecode.h" + +static paddr_t acpi_wakeup_paddr = 3 * PAGE_SIZE; +static vaddr_t acpi_wakeup_vaddr; + +static int acpi_md_node = CTL_EOL; +static int acpi_md_vbios_reset = 1; +static int acpi_md_beep_on_reset = 1; + +static int sysctl_md_acpi_vbios_reset(SYSCTLFN_ARGS); +static int sysctl_md_acpi_beep_on_reset(SYSCTLFN_ARGS); + +/* XXX shut gcc up */ +extern int acpi_md_sleep_prepare(int); +extern int acpi_md_sleep_exit(int); + +void acpi_md_sleep_enter(int); + +void +acpi_md_sleep_enter(int state) +{ +#define WAKECODE_FIXUP(offset, type, val) do { \ + type *addr; \ + addr = (type *)(acpi_wakeup_vaddr + offset); \ + *addr = val; \ +} while (0) + +#define WAKECODE_BCOPY(offset, type, val) do { \ + void **addr; \ + addr = (void **)(acpi_wakeup_vaddr + offset); \ + bcopy(&(val), addr, sizeof(type)); \ +} while (0) + + ACPI_STATUS status; + paddr_t tmp_pdir; + + tmp_pdir = pmap_init_tmp_pgtbl(acpi_wakeup_paddr); + + /* Execute Sleep */ + bcopy(wakecode, (void *)acpi_wakeup_vaddr, sizeof(wakecode)); + + WAKECODE_FIXUP(WAKEUP_vbios_reset, uint8_t, acpi_md_vbios_reset); + WAKECODE_FIXUP(WAKEUP_beep_on_reset, uint8_t, acpi_md_beep_on_reset); + + WAKECODE_FIXUP(WAKEUP_r_cr3, uint64_t, tmp_pdir); + WAKECODE_FIXUP(WAKEUP_restorecpu, void *, acpi_md_sleep_exit); + + ACPI_FLUSH_CPU_CACHE(); + + status = AcpiEnterSleepState(state); + + if (ACPI_FAILURE(status)) { + printf("acpi: AcpiEnterSleepState failed: %s\n", + AcpiFormatException(status)); + return; + } + + for (;;) ; +#undef WAKECODE_FIXUP +#undef WAKECODE_BCOPY +} int acpi_md_sleep(int state) { - printf("ACPI: sleep not implemented\n"); - return -1; + int s, ret = 0; + + KASSERT(acpi_wakeup_paddr != 0); + KASSERT(sizeof(wakecode) <= PAGE_SIZE); + + if (acpi_wakeup_vaddr == 0) { + /* Map ACPI wakecode */ + acpi_wakeup_vaddr = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, + UVM_KMF_VAONLY); + if (acpi_wakeup_vaddr == 0) { + printf("acpi: can't allocate address for wakecode.\n"); + return -1; + } + pmap_kenter_pa(acpi_wakeup_vaddr, acpi_wakeup_paddr, + VM_PROT_READ | VM_PROT_WRITE); + pmap_update(pmap_kernel()); + } + + if (!CPU_IS_PRIMARY(curcpu())) { + printf("acpi0: WARNING: ignoring sleep from secondary CPU\n"); + return -1; + } + + AcpiSetFirmwareWakingVector(acpi_wakeup_paddr); + +#ifdef MULTIPROCESSOR + /* Shutdown all other CPUs */ + x86_broadcast_ipi(X86_IPI_HALT); +#endif + + s = splipi(); + fpusave_cpu(curcpu(), 1); + splx(s); + + s = splhigh(); + x86_disable_intr(); + + if (acpi_md_sleep_prepare(state)) + goto out; + + /* Execute Wakeup */ + cpu_init_msrs(&cpu_info_primary, false); + fpuinit(&cpu_info_primary); + i8259_reinit(); +#if NLAPIC > 0 + lapic_enable(); + lapic_set_lvt(); + lapic_initclocks(); +#endif +#if NIOAPIC > 0 + ioapic_reenable(); +#endif + + initrtclock(TIMER_FREQ); + inittodr(time_second); + + AcpiClearEvent(ACPI_EVENT_POWER_BUTTON); + +out: + x86_enable_intr(); + splx(s); + + if (mtrr_funcs != NULL) + mtrr_commit(); + + return (ret); +} + +SYSCTL_SETUP(sysctl_md_acpi_setup, "acpi amd64 sysctl setup") +{ + const struct sysctlnode *node; + const struct sysctlnode *ssnode; + + if (sysctl_createv(NULL, 0, NULL, &node, CTLFLAG_PERMANENT, + CTLTYPE_NODE, "machdep", NULL, NULL, 0, NULL, 0, CTL_MACHDEP, + CTL_EOL) != 0) + return; + if (sysctl_createv(NULL, 0, &node, &ssnode, CTLFLAG_READWRITE, + CTLTYPE_INT, "acpi_vbios_reset", NULL, sysctl_md_acpi_vbios_reset, + 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0) + return; + if (sysctl_createv(NULL, 0, &node, &ssnode, CTLFLAG_READWRITE, + CTLTYPE_INT, "acpi_beep_on_reset", NULL, sysctl_md_acpi_beep_on_reset, + 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0) + return; + + acpi_md_node = node->sysctl_num; +} + +static int +sysctl_md_acpi_vbios_reset(SYSCTLFN_ARGS) +{ + int error, t; + struct sysctlnode node; + + node = *rnode; + t = acpi_md_vbios_reset; + node.sysctl_data = &t; + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + if (error || newp == NULL) + return error; + + if (t < 0 || t > 1) + return EINVAL; + + acpi_md_vbios_reset = t; + + return 0; +} + +static int +sysctl_md_acpi_beep_on_reset(SYSCTLFN_ARGS) +{ + int error, t; + struct sysctlnode node; + + node = *rnode; + t = acpi_md_beep_on_reset; + node.sysctl_data = &t; + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + if (error || newp == NULL) + return error; + + if (t < 0 || t > 1) + return EINVAL; + + acpi_md_beep_on_reset = t; + + return 0; } diff --git a/sys/arch/amd64/acpi/acpi_wakeup_low.S b/sys/arch/amd64/acpi/acpi_wakeup_low.S new file mode 100644 index 00000000000..86bf3839f87 --- /dev/null +++ b/sys/arch/amd64/acpi/acpi_wakeup_low.S @@ -0,0 +1,204 @@ +/* $NetBSD: acpi_wakeup_low.S,v 1.2 2007/12/09 20:27:42 jmcneill Exp $ */ + +/*- + * Copyright (c) 2007 Joerg Sonnenberger <joerg@netbsd.org> + * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org> + * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "assym.h" +#include <machine/asm.h> +#include <machine/specialreg.h> + + .text + .p2align 2, 0x90 + .globl acpi_md_sleep_exit +acpi_md_sleep_exit: + lgdt r_gdt + + xorw %ax,%ax + movw %ax,%fs + movw %ax,%gs + + movl $MSR_EFER,%ecx + movl r_msr_efer,%eax + wrmsr + + movl $MSR_FSBASE,%ecx + movl r_fs_base_l,%eax + movl r_fs_base_h,%edx + wrmsr + + movl $MSR_GSBASE,%ecx + movl r_gs_base_l,%eax + movl r_gs_base_h,%edx + wrmsr + + movl $MSR_KERNELGSBASE,%ecx + movl r_gs_kernelbase_l,%eax + movl r_gs_kernelbase_h,%edx + wrmsr + + movq r_cr8,%rax + movq %rax,%cr8 + movq r_cr4,%rax + movq %rax,%cr4 + movq r_cr3,%rax + movq %rax,%cr3 + movq r_cr2,%rax + movq %rax,%cr2 + movq r_cr0,%rax + movq %rax,%cr0 + + jmp 1f +1: + + movq CPUVAR(GDT),%rax + movq %rax, r_save_gdt + movzwq r_tr,%rdx + andq $~0x0200,4(%rax,%rdx, 1) + + ltr %dx + lldt r_ldt + lidt r_idt + + movq r_rsp,%rsp + + movq r_rbx,%rbx + movq r_rbp,%rbp + movq r_r12,%r12 + movq r_r13,%r13 + movq r_r14,%r14 + movq r_r15,%r15 + + movq ret_addr,%rax + movq %rax,(%rsp) + xorq %rax,%rax + + pushq r_rfl + popfq + ret + + .p2align 2, 0x90 + .type acpi_md_sleep_prepare, @function + .globl acpi_md_sleep_prepare +acpi_md_sleep_prepare: + movq %rbx,r_rbx + movq %rbp,r_rbp + movq %r12,r_r12 + movq %r13,r_r13 + movq %r14,r_r14 + movq %r15,r_r15 + + movq %cr0,%rax + movq %rax,r_cr0 + movq %cr2,%rax + movq %rax,r_cr2 + movq %cr3,%rax + movq %rax,r_cr3 + movq %cr4,%rax + movq %rax,r_cr4 + movq %cr8,%rax + movq %rax,r_cr8 + + pushfq + popq r_rfl + + movq %rsp,r_rsp + + movl $MSR_FSBASE,%ecx + rdmsr + movl %eax,r_fs_base_l + movl %edx,r_fs_base_h + + movl $MSR_GSBASE,%ecx + rdmsr + movl %eax,r_gs_base_l + movl %edx,r_gs_base_h + + movl $MSR_KERNELGSBASE,%ecx + rdmsr + movl %eax,r_gs_kernelbase_l + movl %edx,r_gs_kernelbase_h + + movl $MSR_EFER,%ecx + rdmsr + movl %eax,r_msr_efer + + sgdt r_gdt + sidt r_idt + sldt r_ldt + str r_tr + + movq (%rsp),%rax + movq %rax,ret_addr + + call acpi_md_sleep_enter + /* acpi_md_sleep_enter only returns on failure. */ + movl $-1,%eax + ret + + .data + .align 16 + +r_tr: .word 0 +r_ldt: .word 0 + +r_fs_base_l: + .long 0 +r_fs_base_h: + .long 0 +r_gs_base_l: + .long 0 +r_gs_base_h: + .long 0 +r_gs_kernelbase_l: + .long 0 +r_gs_kernelbase_h: + .long 0 +r_msr_efer: + .long 0 +r_rbx: .quad 0 +r_rbp: .quad 0 +r_rsp: .quad 0 +r_r12: .quad 0 +r_r13: .quad 0 +r_r14: .quad 0 +r_r15: .quad 0 +r_rfl: .quad 0 + +r_cr0: .quad 0 +r_cr2: .quad 0 +r_cr3: .quad 0 +r_cr4: .quad 0 +r_cr8: .quad 0 + +r_gdt: .word 0 + .quad 0 +r_idt: .word 0 + .quad 0 + +ret_addr: .quad 0 +r_save_gdt: .quad 0 diff --git a/sys/arch/amd64/amd64/autoconf.c b/sys/arch/amd64/amd64/autoconf.c index 0365dbbd078..ec3f2a51469 100644 --- a/sys/arch/amd64/amd64/autoconf.c +++ b/sys/arch/amd64/amd64/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.17 2007/10/17 19:52:59 garbled Exp $ */ +/* $NetBSD: autoconf.c,v 1.18 2007/12/09 20:27:43 jmcneill Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -46,7 +46,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.17 2007/10/17 19:52:59 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.18 2007/12/09 20:27:43 jmcneill Exp $"); #include "opt_multiprocessor.h" @@ -71,6 +71,8 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.17 2007/10/17 19:52:59 garbled Exp $" #include "bios32.h" #if NBIOS32 > 0 #include <machine/bios32.h> +/* XXX */ +extern void platform_init(void); #endif #include <x86/x86/tsc.h> @@ -86,6 +88,7 @@ cpu_configure() #if NBIOS32 > 0 bios32_init(); + platform_init(); #endif x86_64_proc0_tss_ldt_init(); diff --git a/sys/arch/amd64/amd64/bios32.c b/sys/arch/amd64/amd64/bios32.c index f157312d5ff..447ac49b76e 100644 --- a/sys/arch/amd64/amd64/bios32.c +++ b/sys/arch/amd64/amd64/bios32.c @@ -1,4 +1,4 @@ -/* $NetBSD: bios32.c,v 1.10 2007/12/01 16:59:13 jmcneill Exp $ */ +/* $NetBSD: bios32.c,v 1.11 2007/12/09 20:27:43 jmcneill Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.10 2007/12/01 16:59:13 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.11 2007/12/09 20:27:43 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -139,7 +139,6 @@ bios32_init() bios32_entry.segment = GSEL(GCODE_SEL, SEL_KPL); } #endif -#if NIPMI > 0 uint8_t *p; int i; @@ -194,7 +193,6 @@ bios32_init() break; } -#endif } /* @@ -243,7 +241,6 @@ bios32_service(service, e, ei) return (1); } -#if NIPMI > 0 /* * smbios_find_table() takes a caller supplied smbios struct type and * a pointer to a handle (struct smbtable) returning one if the structure @@ -327,4 +324,3 @@ smbios_get_string(struct smbtable *st, u_int8_t indx, char *dest, size_t len) return ret; } -#endif diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index c72b99a13b8..302ea004577 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.71 2007/12/03 15:33:09 ad Exp $ */ +/* $NetBSD: machdep.c,v 1.72 2007/12/09 20:27:43 jmcneill Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007 @@ -120,7 +120,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.71 2007/12/03 15:33:09 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.72 2007/12/09 20:27:43 jmcneill Exp $"); /* #define XENDEBUG_LOW */ @@ -1113,6 +1113,96 @@ extern vector *IDTVEC(exceptions)[]; #define KBTOB(x) ((size_t)(x) * 1024UL) +static void +init_x86_64_msgbuf(void) +{ + /* Message buffer is located at end of core. */ + struct vm_physseg *vps; + psize_t sz = round_page(MSGBUFSIZE); + psize_t reqsz = sz; + int x; + + search_again: + vps = NULL; + + for (x = 0; x < vm_nphysseg; x++) { + vps = &vm_physmem[x]; + if (ptoa(vps->avail_end) == avail_end) + break; + } + if (x == vm_nphysseg) + panic("init_x86_64: can't find end of memory"); + + /* Shrink so it'll fit in the last segment. */ + if ((vps->avail_end - vps->avail_start) < atop(sz)) + sz = ptoa(vps->avail_end - vps->avail_start); + + vps->avail_end -= atop(sz); + vps->end -= atop(sz); + msgbuf_p_seg[msgbuf_p_cnt].sz = sz; + msgbuf_p_seg[msgbuf_p_cnt++].paddr = ptoa(vps->avail_end); + + /* Remove the last segment if it now has no pages. */ + if (vps->start == vps->end) { + for (vm_nphysseg--; x < vm_nphysseg; x++) + vm_physmem[x] = vm_physmem[x + 1]; + } + + /* Now find where the new avail_end is. */ + for (avail_end = 0, x = 0; x < vm_nphysseg; x++) + if (vm_physmem[x].avail_end > avail_end) + avail_end = vm_physmem[x].avail_end; + avail_end = ptoa(avail_end); + + if (sz == reqsz) + return; + + reqsz -= sz; + if (msgbuf_p_cnt == VM_PHYSSEG_MAX) { + /* No more segments available, bail out. */ + printf("WARNING: MSGBUFSIZE (%zu) too large, using %zu.\n", + (size_t)MSGBUFSIZE, (size_t)(MSGBUFSIZE - reqsz)); + return; + } + + sz = reqsz; + goto search_again; +} + +static void +init_x86_64_ksyms(void) +{ +#if NKSYMS || defined(DDB) || defined(LKM) + extern int end; + extern int *esym; +#ifndef XEN + struct btinfo_symtab *symtab; + vaddr_t tssym, tesym; +#endif + +#ifdef DDB + db_machine_init(); +#endif + +#ifndef XEN + symtab = lookup_bootinfo(BTINFO_SYMTAB); + if (symtab) { + tssym = (vaddr_t)symtab->ssym + KERNBASE; + tesym = (vaddr_t)symtab->esym + KERNBASE; + ksyms_init(symtab->nsym, (void *)tssym, (void *)tesym); + } else + ksyms_init(*(long *)(void *)&end, + ((long *)(void *)&end) + 1, esym); +#else /* XEN */ + esym = xen_start_info.mod_start ? + (void *)xen_start_info.mod_start : + (void *)xen_start_info.mfn_list; + ksyms_init(*(int *)(void *)&end, + ((int *)(void *)&end) + 1, esym); +#endif /* XEN */ +#endif +} + void init_x86_64(paddr_t first_avail) { @@ -1139,7 +1229,7 @@ init_x86_64(paddr_t first_avail) cpu_feature &= ~(CPUID_PGE|CPUID_PSE|CPUID_MTRR|CPUID_FXSR|CPUID_NOX); #endif /* XEN */ - cpu_init_msrs(&cpu_info_primary); + cpu_init_msrs(&cpu_info_primary, true); lwp0.l_addr = proc0paddr; #ifdef XEN @@ -1161,8 +1251,18 @@ init_x86_64(paddr_t first_avail) uvmexp.ncolors = 2; #ifndef XEN - avail_start = PAGE_SIZE; /* BIOS leaves data in low memory */ - /* and VM system doesn't work with phys 0 */ + /* + * Low memory reservations: + * Page 0: BIOS data + * Page 1: BIOS callback (not used yet, for symmetry with i386) + * Page 2: MP bootstrap + * Page 3: ACPI wakeup code + * Page 4: Temporary page table for 0MB-4MB + * Page 5: Temporary page directory + * Page 6: Temporary page map level 3 + * Page 7: Temporary page map level 4 + */ + avail_start = 8 * PAGE_SIZE; #else /* XEN */ /* Parse Xen command line (replace bootinfo */ xen_parse_cmdline(XEN_PARSE_BOOTFLAGS, NULL); @@ -1176,11 +1276,6 @@ init_x86_64(paddr_t first_avail) pmap_pa_start, avail_start, avail_end)); #endif /* !XEN */ -#ifdef MULTIPROCESSOR - if (avail_start < MP_TRAMPOLINE + PAGE_SIZE) - avail_start = MP_TRAMPOLINE + PAGE_SIZE; -#endif - /* * Call pmap initialization to make new kernel address space. * We must do this before loading pages into the VM system. @@ -1479,62 +1574,7 @@ init_x86_64(paddr_t first_avail) atop(avail_end), VM_FREELIST_DEFAULT); #endif /* !XEN */ - /* - * Steal memory for the message buffer (at end of core). - */ - { - struct vm_physseg *vps = NULL; - psize_t sz = round_page(MSGBUFSIZE); - psize_t reqsz = sz; - - search_again: - - for (x = 0; x < vm_nphysseg; x++) { - vps = &vm_physmem[x]; - if (ptoa(vps->avail_end) == avail_end) - break; - } - if (x == vm_nphysseg) - panic("init_x86_64: can't find end of memory"); - - /* Shrink so it'll fit in the last segment. */ - if ((vps->avail_end - vps->avail_start) < atop(sz)) - sz = ptoa(vps->avail_end - vps->avail_start); - - vps->avail_end -= atop(sz); - vps->end -= atop(sz); - msgbuf_p_seg[msgbuf_p_cnt].sz = sz; - msgbuf_p_seg[msgbuf_p_cnt++].paddr = ptoa(vps->avail_end); - - /* Remove the last segment if it now has no pages. */ - if (vps->start == vps->end) { - for (vm_nphysseg--; x < vm_nphysseg; x++) - vm_physmem[x] = vm_physmem[x + 1]; - } - - /* Now find where the new avail_end is. */ - for (avail_end = 0, x = 0; x < vm_nphysseg; x++) - if (vm_physmem[x].avail_end > avail_end) - avail_end = vm_physmem[x].avail_end; - avail_end = ptoa(avail_end); - - if (sz != reqsz) { - reqsz -= sz; - if (msgbuf_p_cnt != VM_PHYSSEG_MAX) { - /* if still segments available, get memory from next one ... */ - sz = reqsz; - goto search_again; - } - /* Warn if the message buffer had to be shrunk. */ - printf("WARNING: %ld bytes not available for msgbuf " - "in last cluster (%ld used)\n", reqsz, sz); - } - - } - - /* - * XXXfvdl todo: acpi wakeup code. - */ + init_x86_64_msgbuf(); pmap_growkernel(VM_MIN_KERNEL_ADDRESS + 32 * 1024 * 1024); @@ -1673,37 +1713,9 @@ init_x86_64(paddr_t first_avail) #endif /* XEN */ cpu_init_idt(); -#if NKSYMS || defined(DDB) || defined(LKM) - { - extern int end; - extern int *esym; -#ifndef XEN - struct btinfo_symtab *symtab; - vaddr_t tssym, tesym; -#endif + init_x86_64_ksyms(); #ifdef DDB - db_machine_init(); -#endif -#ifndef XEN - symtab = lookup_bootinfo(BTINFO_SYMTAB); - if (symtab) { - tssym = (vaddr_t)symtab->ssym + KERNBASE; - tesym = (vaddr_t)symtab->esym + KERNBASE; - ksyms_init(symtab->nsym, (void *)tssym, (void *)tesym); - } else - ksyms_init(*(long *)(void *)&end, - ((long *)(void *)&end) + 1, esym); -#else /* XEN */ - esym = xen_start_info.mod_start ? - (void *)xen_start_info.mod_start : - (void *)xen_start_info.mfn_list; - ksyms_init(*(int *)(void *)&end, - ((int *)(void *)&end) + 1, esym); -#endif /* XEN */ - } -#endif -#ifdef DDB if (boothowto & RB_KDB) Debugger(); #endif diff --git a/sys/arch/amd64/amd64/mainbus.c b/sys/arch/amd64/amd64/mainbus.c index 1a2199f4adf..b2cb435d6a1 100644 --- a/sys/arch/amd64/amd64/mainbus.c +++ b/sys/arch/amd64/amd64/mainbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.19 2007/12/01 14:38:44 jmcneill Exp $ */ +/* $NetBSD: mainbus.c,v 1.20 2007/12/09 20:27:43 jmcneill Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.19 2007/12/01 14:38:44 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.20 2007/12/09 20:27:43 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -262,6 +262,8 @@ mainbus_attach(struct device *parent, struct device *self, void *aux) config_found_ia(self, "isabus", &mba_iba, isabusprint); #endif + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } int diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index d1ad424233b..e8f20c35f0f 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.179 2007/12/05 00:19:40 xtraeme Exp $ +# $NetBSD: GENERIC,v 1.180 2007/12/09 20:27:43 jmcneill Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.179 $" +#ident "GENERIC-$Revision: 1.180 $" maxusers 32 # estimated number of users @@ -255,7 +255,11 @@ options MPBIOS_SCANPCI # MPBIOS configures PCI roots acpiacad* at acpi? # ACPI AC Adapter acpibat* at acpi? # ACPI Battery acpibut* at acpi? # ACPI Button -acpiec* at acpi? # ACPI Embedded Controller +# The ACPI Embedded Controller is generally configured via the special ECDT. +# This is required as parts of the DSDT can reference the EC before the normal +# attach phase. +acpiec* at acpi? # ACPI Embedded Controller (late binding) +acpiecdt* at acpi? # ACPI Embedded Controller (early binding) acpilid* at acpi? # ACPI Lid Switch acpitz* at acpi? # ACPI Thermal Zone @@ -270,6 +274,7 @@ joy* at acpi? # Joystick/Game port #lpt* at acpi? # Parallel port mpu* at acpi? # Roland MPU-401 MIDI UART pckbc* at acpi? # PC keyboard controller +attimer* at acpi? # AT Timer pcppi* at acpi? # AT-style speaker sound ug* at acpi? # Abit uGuru Hardware monitor wss* at acpi? # NeoMagic 256AV in wss mode @@ -325,6 +330,8 @@ cardslot* at cbb? cardbus* at cardslot? pcmcia* at cardslot? +# Coprocessor Support + # Console Devices # wscons @@ -358,7 +365,7 @@ cz* at pci? dev ? function ? # Cyclades-Z multi-port serial boards # PCMCIA serial interfaces com* at pcmcia? function ? # Modems and serial cards -pcmcom* at pcmcia? function ? # PCMCIA multi-port serial cards +pcmcom* at pcmcia? function ? # PCMCIA multi-port serial cards com* at pcmcom? slave ? # ...and the slave devices # CardBus serial interfaces @@ -519,9 +526,6 @@ viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers # PCMCIA IDE controllers wdc* at pcmcia? function ? -# CardBus IDE controllers -njata* at cardbus? function ? flags 0x01 # Workbit NinjaATA-32 - # ISA ST506, ESDI, and IDE controllers # Use flags 0x01 if you want to try to use 32bits data I/O (the driver will # fall back to 16bits I/O if 32bits I/O are not functional). @@ -626,7 +630,6 @@ xge* at pci? dev ? function ? # Neterion (S2io) Xframe-I 10GbE an* at pcmcia? function ? # Aironet PC4500/PC4800 (802.11) awi* at pcmcia? function ? # BayStack 650/660 (802.11FH/DS) cnw* at pcmcia? function ? # Xircom/Netwave AirSurfer -cs* at pcmcia? function ? # CS89xx Ethernet ep* at pcmcia? function ? # 3Com 3c589 and 3c562 Ethernet mbe* at pcmcia? function ? # MB8696x based Ethernet ne* at pcmcia? function ? # NE2000-compatible Ethernet @@ -645,14 +648,12 @@ sm* at mhzc? # CardBus network cards ath* at cardbus? function ? # Atheros 5210/5211/5212 802.11 -atw* at cardbus? function ? # ADMtek ADM8211 (802.11) ex* at cardbus? function ? # 3Com 3C575TX fxp* at cardbus? function ? # Intel i8255x -ral* at cardbus? function ? # Ralink Technology RT25x0 802.11a/b/g -re* at cardbus? function ? # Realtek 8139C+/8169/8169S/8110S rtk* at cardbus? function ? # Realtek 8129/8139 rtw* at cardbus? function ? # Realtek 8180L (802.11) tlp* at cardbus? function ? # DECchip 21143 +ral* at cardbus? function ? # Ralink Technology RT25x0 802.11a/b/g # MII/PHY support acphy* at mii? phy ? # DAltima AC101 and AMD Am79c874 PHYs @@ -695,19 +696,18 @@ uhci* at pci? dev ? function ? # Universal Host Controller (Intel) # CardBus USB controllers ehci* at cardbus? function ? # Enhanced Host Controller ohci* at cardbus? function ? # Open Host Controller -uhci* at cardbus? function ? # Universal Host Controller (Intel) # ISA USB controllers #slhci0 at isa? port 0x300 irq 5 # ScanLogic SL811HS # PCMCIA USB controllers -slhci* at pcmcia? function ? # ScanLogic SL811HS +#slhci* at pcmcia? function ? # ScanLogic SL811HS # USB bus support usb* at ehci? usb* at ohci? usb* at uhci? -usb* at slhci? +#usb* at slhci? # USB Hubs uhub* at usb? @@ -852,7 +852,7 @@ ucom* at ugensa? fwohci* at pci? dev ? function ? # IEEE1394 Open Host Controller # CardBus IEEE1394 controllers -fwohci* at cardbus? function ? # IEEE1394 Open Host Controller +fwohci* at cardbus? function ? # IEEE1394 Open Host Controller ieee1394if* at fwohci? fwip* at ieee1394if? # IP over IEEE1394 diff --git a/sys/arch/amd64/conf/Makefile.amd64 b/sys/arch/amd64/conf/Makefile.amd64 index accad631721..eb5987d8c52 100644 --- a/sys/arch/amd64/conf/Makefile.amd64 +++ b/sys/arch/amd64/conf/Makefile.amd64 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.amd64,v 1.17 2007/10/24 06:26:56 joerg Exp $ +# $NetBSD: Makefile.amd64,v 1.18 2007/12/09 20:27:43 jmcneill Exp $ # Makefile for NetBSD # @@ -77,7 +77,7 @@ LINKFORMAT= -T ${AMD64}/conf/${KERN_LDSCRIPT} # depend on CPU configuration locore.o machdep.o: Makefile -busfunc.o cpufunc.o mptramp.o netbsd32_sigcode.o: assym.h +acpi_wakeup_low.o busfunc.o cpufunc.o mptramp.o netbsd32_sigcode.o: assym.h clock.o: config_time.h ## @@ -100,8 +100,7 @@ clock.o: config_time.h %RULES ## Include rules for Atheros WLAN .include "$S/contrib/dev/ath/netbsd/Makefile.ath.inc" - - +.include "$S/arch/x86/acpi/Makefile.wakecode.inc" # XXX - Ugly, but make doesn't easily handle .o.uu (assumes it's a suffix) # XXX - Also, config has no simple was to just add foo.o to the Makefile. diff --git a/sys/arch/amd64/conf/files.amd64 b/sys/arch/amd64/conf/files.amd64 index fd7e1a0253a..d7a75bf0796 100644 --- a/sys/arch/amd64/conf/files.amd64 +++ b/sys/arch/amd64/conf/files.amd64 @@ -1,4 +1,4 @@ -# $NetBSD: files.amd64,v 1.49 2007/11/22 16:16:44 bouyer Exp $ +# $NetBSD: files.amd64,v 1.50 2007/12/09 20:27:43 jmcneill Exp $ # # new style config file for amd64 architecture # @@ -187,7 +187,8 @@ include "dev/bluetooth/files.bluetooth" include "dev/ieee1394/files.ieee1394" include "dev/apm/files.apm" include "dev/acpi/files.acpi" -file arch/amd64/acpi/acpi_wakeup.c acpi +file arch/amd64/acpi/acpi_wakeup.c acpi +file arch/amd64/acpi/acpi_wakeup_low.S acpi include "arch/amd64/conf/majors.amd64" endif #xen diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index ff0d2d46b32..20438940b32 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.34 2007/12/03 22:17:27 joerg Exp $ */ +/* $NetBSD: cpu.h,v 1.35 2007/12/09 20:27:44 jmcneill Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -307,7 +307,7 @@ void i8254_microtime(struct timeval *); void i8254_initclocks(void); #endif -void cpu_init_msrs(struct cpu_info *); +void cpu_init_msrs(struct cpu_info *, bool); /* vm_machdep.c */ diff --git a/sys/arch/i386/acpi/Makefile.wakecode b/sys/arch/i386/acpi/Makefile.wakecode index 0defbee4dac..e69de29bb2d 100644 --- a/sys/arch/i386/acpi/Makefile.wakecode +++ b/sys/arch/i386/acpi/Makefile.wakecode @@ -1,12 +0,0 @@ -# $NetBSD: Makefile.wakecode,v 1.4 2005/12/11 12:17:40 christos Exp $ -# FreeBSD: src/sys/i386/acpica/Makefile,v 1.3 2002/05/01 21:54:07 peter Exp - -.include <bsd.sys.mk> # for HOST_SH - -all: acpi_wakecode.h - -acpi_wakecode.h: acpi_wakecode.S genwakecode.sh - ${CC} -c acpi_wakecode.S - objcopy -S -O binary acpi_wakecode.o acpi_wakecode.bin - ${HOST_SH} ${.CURDIR}/genwakecode.sh > acpi_wakecode.h - rm -f acpi_wakecode.bin acpi_wakecode.o diff --git a/sys/arch/i386/acpi/acpi_wakecode.S b/sys/arch/i386/acpi/acpi_wakecode.S index 006456f6f0a..da3a06ac5be 100644 --- a/sys/arch/i386/acpi/acpi_wakecode.S +++ b/sys/arch/i386/acpi/acpi_wakecode.S @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakecode.S,v 1.9 2007/04/28 14:03:00 joerg Exp $ */ +/* $NetBSD: acpi_wakecode.S,v 1.10 2007/12/09 20:27:44 jmcneill Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -70,13 +70,15 @@ #define _LOCORE -#include <machine/asm.h> #include <machine/specialreg.h> -#include <machine/param.h> #include <machine/segments.h> +#define ACPI_WAKEUP_ADDR 0x3000 + + .text .code16 .org 0 /* ACPI spec says: cs==(phys>>8), ip==(phys&0x000F) */ + .globl wakeup_16 wakeup_16: nop cli @@ -88,21 +90,27 @@ wakeup_16: movw %ax,%ss /* Small call stack */ - movw $0x1000,%sp + mov $0x1000,%sp /* Clear flags */ pushl $0 popfl /* Only beep on reset if machdep.acpi_beep_on_reset=1 */ - cmpb $1,beep_on_reset - jne nobeepon - call beepon -nobeepon: + cmpb $1,WAKEUP_beep_on_reset + jne 1f + movb $0xc0,%al + outb %al,$0x42 + movb $0x04,%al + outb %al,$0x42 + inb $0x61,%al + orb $0x3,%al + outb %al,$0x61 +1: /* Only reset the VBIOS if machdep.acpi_vbios_reset=1 */ - cmpb $1,vbios_reset - jne novbiosreset + cmpb $1,WAKEUP_vbios_reset + jne 1f /* Kick the VBIOS. */ lcall $0xc000,$3 @@ -110,31 +118,17 @@ nobeepon: movw %cs,%ax movw %ax,%ds movw %ax,%ss -novbiosreset: +1: - /* Only beep on reset if machdep.acpi_beep_on_reset=1 */ - cmpb $1,beep_on_reset - jne nobeepoff - call beepoff -nobeepoff: - - /* Get physical address of the code */ - xorl %esi,%esi - movw %cs,%si - shll $4,%esi - - /* Fill 16->32 address */ - movl %esi,%eax - addl $wakeup_32,%eax - movl %eax,wakeup_sw32+2 - jmp 1f /* flush prefetch queue */ -1: jmp 1f + /* Disable beep again if machdep.acpi_beep_on_reset=1 */ + cmpb $1,WAKEUP_beep_on_reset + jne 1 + inb $0x61,%al + andb $0xfc,%al + outb %al,$0x61 1: /* Load GDT while non-paging */ - movl %esi,%eax - addl $tmp_gdtable,%eax - movl %eax,tmp_gdt+2 lgdt tmp_gdt /* Enable protected mode */ @@ -142,9 +136,8 @@ nobeepoff: orl $(CR0_PE),%eax mov %eax,%cr0 -wakeup_sw32: /* Switch to protected mode by intersegmental jump */ - ljmpl $0x8,$0x12345678 /* Code location, to be replaced */ + ljmpl $0x8,$wakeup_32 + ACPI_WAKEUP_ADDR .code32 @@ -158,22 +151,15 @@ wakeup_32: /* Set up segment registers for protected mode */ movw $GSEL(GDATA_SEL,SEL_KPL),%ax movw %ax,%ds - movw %ax,%es - movw %ax,%gs - movw %ax,%ss - movw %ax,%fs - /* Fixup TSS type field; 386 busy TSS (11) -> 386 available TSS (9) */ -#define TSS_TYPEFIX_MASK 0xf9 - movl physical_gdt+2(%esi),%ebx - movzxw previous_tr(%esi),%ecx - leal (%ebx,%ecx),%eax /* get TSS segment descriptor */ - andb $TSS_TYPEFIX_MASK,5(%eax) + /* Restore PSE and other settings before enabling paging. */ + movl WAKEUP_r_cr4 + ACPI_WAKEUP_ADDR,%eax + movl %eax,%cr4 /* Enable paging (assumes identical mapping) */ - movl previous_cr3(%esi),%eax + movl WAKEUP_r_cr3 + ACPI_WAKEUP_ADDR,%eax movl %eax,%cr3 - movl previous_cr0(%esi),%eax + movl WAKEUP_r_cr0 + ACPI_WAKEUP_ADDR,%eax movl %eax,%cr0 /* Flush the prefetch queue */ @@ -183,52 +169,18 @@ wakeup_32: nop - /* Restore registers */ - lgdt previous_gdt(%esi) - lidt previous_idt(%esi) - lldt previous_ldt(%esi) -#if 0 - ltr previous_tr(%esi) -#endif - - mov previous_cr2(%esi),%eax - mov %eax,%cr2 - mov previous_cr4(%esi),%eax - mov %eax,%cr4 - - movw previous_es(%esi),%ax - movw %ax,%es - movw previous_fs(%esi),%ax - movw %ax,%fs - movw previous_gs(%esi),%ax - movw %ax,%gs - movw previous_ss(%esi),%ax - movw %ax,%ss - movl where_to_recover(%esi),%ebx - movw previous_ds(%esi),%ax - movw %ax,%ds - jmp *%ebx - -beepon: - movb $0xc0,%al - outb %al,$0x42 - movb $0x04,%al - outb %al,$0x42 - inb $0x61,%al - orb $0x3,%al - outb %al,$0x61 - ret + /* Restore registers */ + lgdt WAKEUP_r_gdt + ACPI_WAKEUP_ADDR -beepoff: - inb $0x61,%al - andb $0xfc,%al - outb %al,$0x61 - ret + movl WAKEUP_restorecpu + ACPI_WAKEUP_ADDR,%ebx + movw WAKEUP_r_ds + ACPI_WAKEUP_ADDR,%ax + movw %ax,%ds + jmp *%ebx .align 8 tmp_gdt: .word 0xffff - .long 0 + .long tmp_gdtable + ACPI_WAKEUP_ADDR .align 8, 0 tmp_gdtable: @@ -243,23 +195,22 @@ tmp_gdtable: .byte 0, 0x93, 0xcf, 0 .align 16, 0 -physical_gdt: .word 0 - .long 0 -previous_cr2: .long 0 -previous_cr3: .long 0 -previous_cr4: .long 0 -previous_cr0: .long 0 -previous_tr: .word 0 -previous_gdt: .word 0 - .long 0 -previous_ldt: .word 0 -previous_idt: .word 0 + .global WAKEUP_r_cr0 +WAKEUP_r_cr0: .long 0 + .global WAKEUP_r_cr3 +WAKEUP_r_cr3: .long 0 + .global WAKEUP_r_cr4 +WAKEUP_r_cr4: .long 0 + + .global WAKEUP_r_gdt +WAKEUP_r_gdt: .word 0 .long 0 -previous_ds: .word 0 -previous_es: .word 0 -previous_fs: .word 0 -previous_gs: .word 0 -previous_ss: .word 0 -where_to_recover: .long 0 -vbios_reset: .byte 0 -beep_on_reset: .byte 0 + .global WAKEUP_r_ds +WAKEUP_r_ds: .word 0 + .global WAKEUP_restorecpu +WAKEUP_restorecpu: .long 0 + + .global WAKEUP_vbios_reset +WAKEUP_vbios_reset: .byte 0 + .global WAKEUP_beep_on_reset +WAKEUP_beep_on_reset: .byte 0 diff --git a/sys/arch/i386/acpi/acpi_wakecode.h b/sys/arch/i386/acpi/acpi_wakecode.h deleted file mode 100644 index 4d97b7adc9d..00000000000 --- a/sys/arch/i386/acpi/acpi_wakecode.h +++ /dev/null @@ -1,83 +0,0 @@ -/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. */ -/* from: NetBSD: acpi_wakecode.S,v 1.8 2006/06/20 22:36:58 jmcneill Exp */ -/* $NetBSD: acpi_wakecode.h,v 1.8 2007/04/28 14:03:00 joerg Exp $ */ - -#define wakeup_16 0x00000000 -#define nobeepon 0x0000001b -#define novbiosreset 0x0000002d -#define nobeepoff 0x00000037 -#define wakeup_sw32 0x0000006d -#define wakeup_32 0x00000080 -#define beepon 0x00000117 -#define beepoff 0x00000126 -#define tmp_gdt 0x00000130 -#define tmp_gdtable 0x00000138 -#define physical_gdt 0x00000150 -#define previous_cr2 0x00000156 -#define previous_cr3 0x0000015a -#define previous_cr4 0x0000015e -#define previous_cr0 0x00000162 -#define previous_tr 0x00000166 -#define previous_gdt 0x00000168 -#define previous_ldt 0x0000016e -#define previous_idt 0x00000170 -#define previous_ds 0x00000176 -#define previous_es 0x00000178 -#define previous_fs 0x0000017a -#define previous_gs 0x0000017c -#define previous_ss 0x0000017e -#define where_to_recover 0x00000180 -#define vbios_reset 0x00000184 -#define beep_on_reset 0x00000185 - -static const unsigned char wakecode[] = { - 0x90, 0xfa, 0xfc, 0x8c, 0xc8, 0x8e, 0xd8, 0x8e, - 0xd0, 0xbc, 0x00, 0x10, 0x66, 0x6a, 0x00, 0x66, - 0x9d, 0x80, 0x3e, 0x85, 0x01, 0x01, 0x75, 0x03, - 0xe8, 0xfc, 0x00, 0x80, 0x3e, 0x84, 0x01, 0x01, - 0x75, 0x0b, 0x9a, 0x03, 0x00, 0x00, 0xc0, 0x8c, - 0xc8, 0x8e, 0xd8, 0x8e, 0xd0, 0x80, 0x3e, 0x85, - 0x01, 0x01, 0x75, 0x03, 0xe8, 0xef, 0x00, 0x66, - 0x31, 0xf6, 0x8c, 0xce, 0x66, 0xc1, 0xe6, 0x04, - 0x66, 0x89, 0xf0, 0x66, 0x05, 0x80, 0x00, 0x00, - 0x00, 0x66, 0xa3, 0x6f, 0x00, 0xeb, 0x00, 0xeb, - 0x00, 0x66, 0x89, 0xf0, 0x66, 0x05, 0x38, 0x01, - 0x00, 0x00, 0x66, 0xa3, 0x32, 0x01, 0x0f, 0x01, - 0x16, 0x30, 0x01, 0x0f, 0x20, 0xc0, 0x66, 0x83, - 0xc8, 0x01, 0x0f, 0x22, 0xc0, 0x66, 0xea, 0x78, - 0x56, 0x34, 0x12, 0x08, 0x00, 0x8d, 0x74, 0x26, - 0x00, 0x8d, 0xbc, 0x27, 0x00, 0x00, 0x00, 0x00, - 0x90, 0x66, 0xb8, 0x10, 0x00, 0x8e, 0xd8, 0x8e, - 0xc0, 0x8e, 0xe8, 0x8e, 0xd0, 0x8e, 0xe0, 0x8b, - 0x9e, 0x52, 0x01, 0x00, 0x00, 0x66, 0x0f, 0xb7, - 0x8e, 0x66, 0x01, 0x00, 0x00, 0x8d, 0x04, 0x0b, - 0x80, 0x60, 0x05, 0xf9, 0x8b, 0x86, 0x5a, 0x01, - 0x00, 0x00, 0x0f, 0x22, 0xd8, 0x8b, 0x86, 0x62, - 0x01, 0x00, 0x00, 0x0f, 0x22, 0xc0, 0xeb, 0x00, - 0xeb, 0x00, 0x90, 0x0f, 0x01, 0x96, 0x68, 0x01, - 0x00, 0x00, 0x0f, 0x01, 0x9e, 0x70, 0x01, 0x00, - 0x00, 0x0f, 0x00, 0x96, 0x6e, 0x01, 0x00, 0x00, - 0x8b, 0x86, 0x56, 0x01, 0x00, 0x00, 0x0f, 0x22, - 0xd0, 0x8b, 0x86, 0x5e, 0x01, 0x00, 0x00, 0x0f, - 0x22, 0xe0, 0x66, 0x8b, 0x86, 0x78, 0x01, 0x00, - 0x00, 0x8e, 0xc0, 0x66, 0x8b, 0x86, 0x7a, 0x01, - 0x00, 0x00, 0x8e, 0xe0, 0x66, 0x8b, 0x86, 0x7c, - 0x01, 0x00, 0x00, 0x8e, 0xe8, 0x66, 0x8b, 0x86, - 0x7e, 0x01, 0x00, 0x00, 0x8e, 0xd0, 0x8b, 0x9e, - 0x80, 0x01, 0x00, 0x00, 0x66, 0x8b, 0x86, 0x76, - 0x01, 0x00, 0x00, 0x8e, 0xd8, 0xff, 0xe3, 0xb0, - 0xc0, 0xe6, 0x42, 0xb0, 0x04, 0xe6, 0x42, 0xe4, - 0x61, 0x0c, 0x03, 0xe6, 0x61, 0xc3, 0xe4, 0x61, - 0x24, 0xfc, 0xe6, 0x61, 0xc3, 0x8d, 0x76, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x9f, 0xcf, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x93, 0xcf, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; diff --git a/sys/arch/i386/acpi/acpi_wakeup.c b/sys/arch/i386/acpi/acpi_wakeup.c index 33a1af17bcd..a81831b7fb0 100644 --- a/sys/arch/i386/acpi/acpi_wakeup.c +++ b/sys/arch/i386/acpi/acpi_wakeup.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.40 2007/10/17 19:54:41 garbled Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.41 2007/12/09 20:27:44 jmcneill Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.40 2007/10/17 19:54:41 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.41 2007/12/09 20:27:44 jmcneill Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org> @@ -78,8 +78,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.40 2007/10/17 19:54:41 garbled Exp #include <uvm/uvm_extern.h> #include <uvm/uvm_page.h> -#include "lapic.h" #include "ioapic.h" +#include "lapic.h" #if NLAPIC > 0 #include <machine/i82489var.h> @@ -98,10 +98,14 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.40 2007/10/17 19:54:41 garbled Exp #include <machine/acpi_machdep.h> #include <machine/cpu.h> #include <machine/npx.h> +#include <machine/mtrr.h> #include "acpi_wakecode.h" -static paddr_t phys_wakeup = 0; +/* Address is also hard-coded in acpi_wakecode.S */ +static paddr_t acpi_wakeup_paddr = 3 * PAGE_SIZE; +static vaddr_t acpi_wakeup_vaddr; + static int acpi_md_node = CTL_EOL; static int acpi_md_vbios_reset = 1; static int acpi_md_beep_on_reset = 1; @@ -109,22 +113,6 @@ static int acpi_md_beep_on_reset = 1; static int sysctl_md_acpi_vbios_reset(SYSCTLFN_ARGS); static int sysctl_md_acpi_beep_on_reset(SYSCTLFN_ARGS); -uint32_t -acpi_md_get_npages_of_wakecode(void) -{ - return (atop(round_page(sizeof(wakecode)))); -} - -void -acpi_md_install_wakecode(paddr_t pa) -{ - bcopy(wakecode, (void *)pa, sizeof(wakecode)); - phys_wakeup = pa; - aprint_verbose("acpi: wakecode is installed at 0x%lX, size=%u\n", - pa, sizeof(wakecode)); -} - - /* * S4 sleep using S4BIOS support, from FreeBSD. * @@ -155,7 +143,7 @@ enter_s4_with_bios(void) /* clear wake status */ - AcpiSetRegister(ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_LOCK); + AcpiSetRegister(ACPI_BITREG_WAKE_STATUS, 1); ef = x86_read_psl(); x86_disable_intr(); @@ -172,10 +160,9 @@ enter_s4_with_bios(void) */ do { AcpiOsStall(1000000); - AcpiOsWritePort(AcpiGbl_FADT->SmiCmd, - AcpiGbl_FADT->S4BiosReq, 8); - status = AcpiGetRegister(ACPI_BITREG_WAKE_STATUS, - &ret, ACPI_MTX_LOCK); + AcpiOsWritePort(AcpiGbl_FADT.SmiCommand, + AcpiGbl_FADT.S4BiosRequest, 8); + status = AcpiGetRegister(ACPI_BITREG_WAKE_STATUS, &ret); if (ACPI_FAILURE(status)) break; } while (!ret); @@ -188,291 +175,146 @@ enter_s4_with_bios(void) return (AE_OK); } -static uint16_t r_ldt; -static uint16_t r_cs __used; -static uint16_t r_ds, r_es, r_fs, r_gs, r_ss, r_tr; -static uint32_t r_eax __used; -static uint32_t r_ebx __used; -static uint32_t r_ecx __used; -static uint32_t r_edx __used; -static uint32_t r_ebp __used; -static uint32_t r_esi __used; -static uint32_t r_edi __used; -static uint32_t r_efl __used; -static uint32_t r_cr0 __used; -static uint32_t r_cr2 __used; -static uint32_t r_cr3 __used; -static uint32_t r_cr4 __used; -static uint32_t r_esp __used; -static uint32_t ret_addr; -static struct region_descriptor r_idt, r_gdt; - +extern uint8_t acpi_wakeup_gdt[6]; +extern uint32_t acpi_wakeup_ds; +extern uint32_t acpi_wakeup_cr0; +extern uint32_t acpi_wakeup_cr4; /* XXX shut gcc up */ -extern int acpi_savecpu(void); -extern int acpi_restorecpu(void); +extern int acpi_md_sleep_prepare(int state); +extern int acpi_md_sleep_exit(void); -static inline void -clear_reg(void) -{ - r_ldt = 0; - r_cs = r_ds = r_es = r_fs = r_gs = r_ss = r_tr = 0; - r_eax = r_ebx = r_ecx = r_edx = r_ebp = r_esi = r_edi = 0; - r_efl = r_cr0 = r_cr2 = r_cr3 = r_cr4 = r_esp = 0; - memset(&r_idt, 0, sizeof(r_idt)); - memset(&r_gdt, 0, sizeof(r_gdt)); -} - -__asm(" \ - .text; \ - .p2align 2, 0x90; \ - .type acpi_restorecpu, @function; \ -acpi_restorecpu: \ - .align 4; \ - movl r_cr3,%eax; \ - movl %eax,%cr3; \ - movl r_eax,%eax; \ - movl r_ebx,%ebx; \ - movl r_ecx,%ecx; \ - movl r_edx,%edx; \ - movl r_ebp,%ebp; \ - movl r_esi,%esi; \ - movl r_edi,%edi; \ - movl r_esp,%esp; \ - \ - pushl r_efl; \ - popfl; \ - \ - movl ret_addr,%eax; \ - movl %eax,(%esp); \ - xorl %eax,%eax; \ - ret; \ - \ - .text; \ - .p2align 2, 0x90; \ - .type acpi_savecpu, @function; \ -acpi_savecpu: \ - movw %cs,r_cs; \ - movw %ds,r_ds; \ - movw %es,r_es; \ - movw %fs,r_fs; \ - movw %gs,r_gs; \ - movw %ss,r_ss; \ - \ - movl %eax,r_eax; \ - movl %ebx,r_ebx; \ - movl %ecx,r_ecx; \ - movl %edx,r_edx; \ - movl %ebp,r_ebp; \ - movl %esi,r_esi; \ - movl %edi,r_edi; \ - \ - movl %cr0,%eax; \ - movl %eax,r_cr0; \ - movl %cr2,%eax; \ - movl %eax,r_cr2; \ - movl %cr3,%eax; \ - movl %eax,r_cr3; \ - movl %cr4,%eax; \ - movl %eax,r_cr4; \ - \ - pushfl; \ - popl r_efl; \ - \ - movl %esp,r_esp; \ - \ - sgdt r_gdt; \ - sidt r_idt; \ - sldt r_ldt; \ - str r_tr; \ - \ - movl (%esp),%eax; \ - movl %eax,ret_addr; \ - movl $1,%eax; \ - ret; \ -"); - -#ifdef ACPI_PRINT_REG -static void -acpi_printcpu(void) -{ +void acpi_md_sleep_enter(int); - printf("======== acpi_printcpu() debug dump ========\n"); - printf("gdt[%04x:%08x] idt[%04x:%08x] ldt[%04x] tr[%04x] efl[%08x]\n", - r_gdt.rd_limit, r_gdt.rd_base, r_idt.rd_limit, r_idt.rd_base, - r_ldt, r_tr, r_efl); - printf("eax[%08x] ebx[%08x] ecx[%08x] edx[%08x]\n", - r_eax, r_ebx, r_ecx, r_edx); - printf("esi[%08x] edi[%08x] ebp[%08x] esp[%08x]\n", - r_esi, r_edi, r_ebp, r_esp); - printf("cr0[%08x] cr2[%08x] cr3[%08x] cr4[%08x]\n", - r_cr0, r_cr2, r_cr3, r_cr4); - printf("cs[%04x] ds[%04x] es[%04x] fs[%04x] gs[%04x] ss[%04x]\n", - r_cs, r_ds, r_es, r_fs, r_gs, r_ss); -} -#endif - -int -acpi_md_sleep(int state) +void +acpi_md_sleep_enter(int state) { #define WAKECODE_FIXUP(offset, type, val) do { \ type *addr; \ - addr = (type *)(phys_wakeup + offset); \ + addr = (type *)(acpi_wakeup_vaddr + offset); \ *addr = val; \ } while (0) #define WAKECODE_BCOPY(offset, type, val) do { \ void **addr; \ - addr = (void **)(phys_wakeup + offset); \ + addr = (void **)(acpi_wakeup_vaddr + offset); \ bcopy(&(val), addr, sizeof(type)); \ } while (0) ACPI_STATUS status; - int ret = 0; - u_long ef; - struct region_descriptor *p_gdt; - struct proc *p; - struct pmap *pm; - uint32_t cr3; - paddr_t oldphys = 0; - - if (!phys_wakeup) { - printf("acpi: can't sleep since wakecode is not installed.\n"); - return (-1); - } + ACPI_TABLE_FACS *facs; + paddr_t tmp_pdir; - AcpiSetFirmwareWakingVector(phys_wakeup); + tmp_pdir = pmap_init_tmp_pgtbl(acpi_wakeup_paddr); - ef = x86_read_psl(); + /* Execute Sleep */ + bcopy(wakecode, (void *)acpi_wakeup_vaddr, sizeof(wakecode)); + WAKECODE_FIXUP(WAKEUP_vbios_reset, uint8_t, acpi_md_vbios_reset); + WAKECODE_FIXUP(WAKEUP_beep_on_reset, uint8_t, acpi_md_beep_on_reset); - /* Create identity mapping */ - if ((p = curproc) == NULL) - p = &proc0; - - pm = vm_map_pmap(&p->p_vmspace->vm_map); - if (pm != pmap_kernel()) { - if (!pmap_extract(pm, phys_wakeup, &oldphys)) - oldphys = 0; - pmap_enter(pm, phys_wakeup, phys_wakeup, - VM_PROT_READ | VM_PROT_WRITE, - PMAP_WIRED | VM_PROT_READ | VM_PROT_WRITE); - pmap_update(pm); - } - cr3 = rcr3(); + WAKECODE_FIXUP(WAKEUP_r_cr0, uint32_t, acpi_wakeup_cr0); + WAKECODE_FIXUP(WAKEUP_r_cr3, uint32_t, tmp_pdir); + WAKECODE_FIXUP(WAKEUP_r_cr4, uint32_t, acpi_wakeup_cr4); - ret_addr = 0; - x86_disable_intr(); - if (acpi_savecpu()) { - /* Execute Sleep */ - - /* load proc 0 PTD */ - __asm( "movl %0,%%cr3;" : : "a" (PDPpaddr) ); - - p_gdt = (struct region_descriptor *)(phys_wakeup+physical_gdt); - p_gdt->rd_limit = r_gdt.rd_limit; - p_gdt->rd_base = vtophys(r_gdt.rd_base); - - WAKECODE_FIXUP(vbios_reset, uint8_t, acpi_md_vbios_reset); - WAKECODE_FIXUP(beep_on_reset, uint8_t, acpi_md_beep_on_reset); - - WAKECODE_FIXUP(previous_cr0, uint32_t, r_cr0); - WAKECODE_FIXUP(previous_cr2, uint32_t, r_cr2); - WAKECODE_FIXUP(previous_cr4, uint32_t, r_cr4); - - /* - * Make sure the wake code to temporarily use the proc 0 PTD. - * The PTD keeps the identical mapping for the page of - * the trampoline code, which is required just after - * entering to protect mode. The current PTD will be restored - * in acpi_restorecpu(). - */ - WAKECODE_FIXUP(previous_cr3, uint32_t, PDPpaddr); - - WAKECODE_FIXUP(previous_tr, uint16_t, r_tr); - WAKECODE_BCOPY(previous_gdt, struct region_descriptor, r_gdt); - WAKECODE_FIXUP(previous_ldt, uint16_t, r_ldt); - WAKECODE_BCOPY(previous_idt, struct region_descriptor, r_idt); - - WAKECODE_FIXUP(where_to_recover, void *, acpi_restorecpu); - - WAKECODE_FIXUP(previous_ds, uint16_t, r_ds); - WAKECODE_FIXUP(previous_es, uint16_t, r_es); - WAKECODE_FIXUP(previous_fs, uint16_t, r_fs); - WAKECODE_FIXUP(previous_gs, uint16_t, r_gs); - WAKECODE_FIXUP(previous_ss, uint16_t, r_ss); - - /* - * XXX: restore curproc's PTD here - - * - * AcpiEnterSleepState() may switch the context. - * (ltsleep() may probably be called from Osd.) - * Such context switching may causes the kernel - * to crash under the inconsistent PTD. - * Curproc's PTD must be restored to prevent the crash. - * Anyway, leaving the inconsistent PTD is unpreferable, - * although the context switching during sleep - * process is also unpreferable. - */ - __asm( "movl %0,%%cr3;" : : "a" (r_cr3) ); - -#ifdef ACPI_PRINT_REG - acpi_printcpu(); -#endif + WAKECODE_BCOPY(WAKEUP_r_gdt, struct region_descriptor, acpi_wakeup_gdt); - ACPI_FLUSH_CPU_CACHE(); + WAKECODE_FIXUP(WAKEUP_restorecpu, void *, acpi_md_sleep_exit); - if (state == ACPI_STATE_S4 && AcpiGbl_FACS->S4Bios_f) { - status = enter_s4_with_bios(); - } else { - status = AcpiEnterSleepState(state); - } + WAKECODE_FIXUP(WAKEUP_r_ds, uint16_t, acpi_wakeup_ds); + ACPI_FLUSH_CPU_CACHE(); + + if (state == ACPI_STATE_S4) { + status = AcpiGetTable(ACPI_SIG_FACS, 0, (ACPI_TABLE_HEADER **)&facs); if (ACPI_FAILURE(status)) { - printf("acpi: AcpiEnterSleepState failed: %s\n", - AcpiFormatException(status)); - ret = -1; - goto out; + printf("acpi: S4BIOS not supported: cannot load FACS\n"); + return; } - - for (;;) ; + if (facs == NULL || + (facs->Flags & ACPI_FACS_S4_BIOS_PRESENT) == 0) { + printf("acpi: S4BIOS not supported: not present"); + return; + } + status = enter_s4_with_bios(); } else { - printf("acpi0: good morning!\n"); - /* Execute Wakeup */ + status = AcpiEnterSleepState(state); + } - npxinit(&cpu_info_primary); - i8259_reinit(); -#if NIOAPIC > 0 - ioapic_enable(); + if (ACPI_FAILURE(status)) { + printf("acpi: AcpiEnterSleepState failed: %s\n", + AcpiFormatException(status)); + return; + } + + for (;;) ; +} + +int +acpi_md_sleep(int state) +{ + int s, ret = 0; + + KASSERT(acpi_wakeup_paddr != 0); + KASSERT(sizeof(wakecode) <= PAGE_SIZE); + + if (acpi_wakeup_vaddr == 0) { + /* Map ACPI wakecode */ + acpi_wakeup_vaddr = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, + UVM_KMF_VAONLY); + if (acpi_wakeup_vaddr == 0) { + printf("acpi: can't allocate address for wakecode.\n"); + return -1; + } + pmap_kenter_pa(acpi_wakeup_vaddr, acpi_wakeup_paddr, + VM_PROT_READ | VM_PROT_WRITE); + pmap_update(pmap_kernel()); + } + + if (!CPU_IS_PRIMARY(curcpu())) { + printf("acpi: apci_md_sleep called from secondary CPU ignored\n"); + return -1; + } + + AcpiSetFirmwareWakingVector(acpi_wakeup_paddr); + +#ifdef MULTIPROCESSOR + /* Shutdown all other CPUs */ + x86_broadcast_ipi(X86_IPI_HALT); #endif + + s = splipi(); + npxsave_cpu(curcpu(), 1); + splx(s); + + s = splhigh(); + x86_disable_intr(); + + if (acpi_md_sleep_prepare(state)) + goto out; + + /* Execute Wakeup */ + + npxinit(&cpu_info_primary); + i8259_reinit(); #if NLAPIC > 0 - lapic_enable(); - lapic_initclocks(); + lapic_enable(); + lapic_set_lvt(); + lapic_initclocks(); +#endif +#if NIOAPIC > 0 + ioapic_reenable(); #endif - initrtclock(TIMER_FREQ); - inittodr(time_second); + initrtclock(TIMER_FREQ); + inittodr(time_second); -#ifdef ACPI_PRINT_REG - acpi_savecpu(); - acpi_printcpu(); -#endif - } + AcpiClearEvent(ACPI_EVENT_POWER_BUTTON); out: x86_enable_intr(); + splx(s); - lcr3(cr3); - if (pm != pmap_kernel()) { - /* Clean up identity mapping. */ - pmap_remove(pm, phys_wakeup, phys_wakeup + PAGE_SIZE); - if (oldphys) { - pmap_enter(pm, phys_wakeup, oldphys, - VM_PROT_READ | VM_PROT_WRITE, - PMAP_WIRED | VM_PROT_READ | VM_PROT_WRITE); - } - pmap_update(pm); - } - - x86_write_psl(ef); + if (mtrr_funcs != NULL) + mtrr_commit(); return (ret); #undef WAKECODE_FIXUP diff --git a/sys/arch/i386/acpi/acpi_wakeup_low.S b/sys/arch/i386/acpi/acpi_wakeup_low.S new file mode 100644 index 00000000000..e6da20b25b3 --- /dev/null +++ b/sys/arch/i386/acpi/acpi_wakeup_low.S @@ -0,0 +1,166 @@ +/* $NetBSD: acpi_wakeup_low.S,v 1.2 2007/12/09 20:27:44 jmcneill Exp $ */ + +/*- + * Copyright (c) 2007 Joerg Sonnenberger <joerg@netbsd.org> + * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org> + * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "assym.h" +#include <machine/asm.h> + + .text + .p2align 2, 0x90 + .globl acpi_md_sleep_exit +acpi_md_sleep_exit: + movw r_es,%ax + movw %ax,%es + movw r_fs,%ax + movw %ax,%fs + movw r_gs,%ax + movw %ax,%gs + movw r_ss,%ax + movw %ax,%ss + + movl r_cr2,%eax + movl %eax,%cr2 + movl r_cr4,%eax + movl %eax,%cr4 + movl r_cr3,%eax + movl %eax,%cr3 + + jmp 1f +1: + + lidt r_idt + lldt r_ldt + + movl CPUVAR(GDT),%eax + movzwl r_tr,%edx + andl $~0x0200,4(%eax,%edx, 1) + ltr %dx + + movl r_esp,%esp + + movl r_ebx,%ebx + movl r_ecx,%ecx + movl r_edx,%edx + movl r_ebp,%ebp + movl r_esi,%esi + movl r_edi,%edi + + pushl r_efl + popfl + + movl ret_addr,%eax + movl %eax,(%esp) + xorl %eax,%eax + + ret + + .p2align 2, 0x90 + .type acpi_md_sleep_prepare, @function + .globl acpi_md_sleep_prepare +acpi_md_sleep_prepare: + movw %ds,r_ds + movw %es,r_es + movw %fs,r_fs + movw %gs,r_gs + movw %ss,r_ss + + movl %ebx,r_ebx + movl %ecx,r_ecx + movl %edx,r_edx + movl %ebp,r_ebp + movl %esi,r_esi + movl %edi,r_edi + + movl %cr0,%eax + movl %eax,r_cr0 + movl %cr2,%eax + movl %eax,r_cr2 + movl %cr3,%eax + movl %eax,r_cr3 + movl %cr4,%eax + movl %eax,r_cr4 + + pushfl + popl r_efl + + movl %esp,r_esp + + sgdt r_gdt + sidt r_idt + sldt r_ldt + str r_tr + + movl (%esp),%eax + movl %eax,ret_addr + movl 4(%esp),%eax + pushl %eax + call acpi_md_sleep_enter + /* acpi_md_sleep_enter only returns on failure. */ + popl %eax + movl $-1,%eax + ret + + .data + .align 16 + .globl acpi_wakeup_ds +acpi_wakeup_ds: +r_ds: .word 0 +r_es: .word 0 +r_fs: .word 0 +r_gs: .word 0 +r_ss: .word 0 +r_tr: .word 0 +r_ldt: .word 0 + +r_ebx: .long 0 +r_ecx: .long 0 +r_edx: .long 0 +r_ebp: .long 0 +r_esi: .long 0 +r_edi: .long 0 +r_esp: .long 0 +r_efl: .long 0 + + .globl acpi_wakeup_cr0 +acpi_wakeup_cr0: +r_cr0: .long 0 +r_cr2: .long 0 +r_cr3: .long 0 + .globl acpi_wakeup_cr4 +acpi_wakeup_cr4: +r_cr4: .long 0 + + .globl acpi_wakeup_gdt +acpi_wakeup_gdt: +r_gdt: .word 0 + .long 0 +r_idt: .word 0 + .long 0 + +ret_addr: .long 0 diff --git a/sys/arch/i386/acpi/genwakecode.sh b/sys/arch/i386/acpi/genwakecode.sh index d6e10f19716..e69de29bb2d 100644 --- a/sys/arch/i386/acpi/genwakecode.sh +++ b/sys/arch/i386/acpi/genwakecode.sh @@ -1,31 +0,0 @@ -#!/bin/sh -# $NetBSD: genwakecode.sh,v 1.4 2006/03/11 00:31:42 jmcneill Exp $ -# FreeBSD: src/sys/i386/acpica/genwakecode.sh,v 1.1 2002/05/01 21:52:34 peter Exp $ -echo '/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. */' -head -1 acpi_wakecode.S | sed 's@^.*\$\(NetBSD:.*\)\$.*$@/* from: \1 */@' -echo -n '/* $' -echo 'NetBSD: $ */' -echo - -nm -n acpi_wakecode.o | while read offset dummy what -do - if [ x"${offset}" = x"U" ]; then - echo error: undefined symbol \"${dummy}\". 1>&2 - exit 1 - fi - case $dummy in - t) - echo "#define ${what} 0x${offset}" - ;; - *) - ;; - esac - true -done || exit 1 - -echo -echo 'static const unsigned char wakecode[] = {'; -hexdump -v -e '"\t" 8/1 "0x%02x, " "\n"' < acpi_wakecode.bin | sed 's/0x /0x00/g' -echo '};' - -exit 0 diff --git a/sys/arch/i386/acpi/sony_acpi.c b/sys/arch/i386/acpi/sony_acpi.c index 7aea33be30a..c1062b11fdc 100644 --- a/sys/arch/i386/acpi/sony_acpi.c +++ b/sys/arch/i386/acpi/sony_acpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: sony_acpi.c,v 1.5 2006/11/16 01:32:38 christos Exp $ */ +/* $NetBSD: sony_acpi.c,v 1.6 2007/12/09 20:27:45 jmcneill Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sony_acpi.c,v 1.5 2006/11/16 01:32:38 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sony_acpi.c,v 1.6 2007/12/09 20:27:45 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -51,10 +51,53 @@ __KERNEL_RCSID(0, "$NetBSD: sony_acpi.c,v 1.5 2006/11/16 01:32:38 christos Exp $ #include <dev/acpi/acpica.h> #include <dev/acpi/acpivar.h> +#include <dev/wscons/wsconsio.h> +#include <dev/wscons/wskbdvar.h> +#include <dev/wscons/wsksymdef.h> +#include <dev/wscons/wsksymvar.h> + +#define SONY_NOTIFY_FnKeyEvent 0x92 +#define SONY_NOTIFY_BrightnessDownPressed 0x85 +#define SONY_NOTIFY_BrightnessDownReleased 0x05 +#define SONY_NOTIFY_BrightnessUpPressed 0x86 +#define SONY_NOTIFY_BrightnessUpReleased 0x06 +#define SONY_NOTIFY_DisplaySwitchPressed 0x87 +#define SONY_NOTIFY_DisplaySwitchReleased 0x07 +#define SONY_NOTIFY_ZoomPressed 0x8a +#define SONY_NOTIFY_ZoomReleased 0x0a +#define SONY_NOTIFY_SuspendPressed 0x8c +#define SONY_NOTIFY_SuspendReleased 0x0c + struct sony_acpi_softc { struct device sc_dev; struct sysctllog *sc_log; struct acpi_devnode *sc_node; + + struct device *sc_wskbddev; + + struct sysmon_pswitch sc_smpsw; + int sc_smpsw_valid; + + struct sony_acpi_pmstate { + ACPI_INTEGER brt; + } sc_pmstate; +}; + +static int sony_acpi_wskbd_enable(void *, int); +static void sony_acpi_wskbd_set_leds(void *, int); +static int sony_acpi_wskbd_ioctl(void *, u_long, void *, int, struct lwp *); + +static const struct wskbd_accessops sony_acpi_accessops = { + sony_acpi_wskbd_enable, + sony_acpi_wskbd_set_leds, + sony_acpi_wskbd_ioctl, +}; + +extern const struct wscons_keydesc ukbd_keydesctab[]; + +static const struct wskbd_mapdata sony_acpi_keymapdata = { + ukbd_keydesctab, + KB_US, }; static const char * const sony_acpi_ids[] = { @@ -62,11 +105,26 @@ static const char * const sony_acpi_ids[] = { NULL }; +#define SONY_ACPI_QUIRK_FNINIT 0x01 + +static const struct sony_acpi_quirk_table { + const char * product_name; + int quirks; +} sony_acpi_quirks[] = { + { "VGN-N250E", SONY_ACPI_QUIRK_FNINIT }, + { NULL, -1 } +}; + static int sony_acpi_match(struct device *, struct cfdata *, void *); static void sony_acpi_attach(struct device *, struct device *, void *); static ACPI_STATUS sony_acpi_eval_set_integer(ACPI_HANDLE, const char *, ACPI_INTEGER, ACPI_INTEGER *); - +static void sony_acpi_quirk_setup(struct sony_acpi_softc *); +static void sony_acpi_notify_handler(ACPI_HANDLE, UINT32, void *); +static bool sony_acpi_suspend(device_t); +static bool sony_acpi_resume(device_t); +static void sony_acpi_brightness_down(device_t); +static void sony_acpi_brightness_up(device_t); CFATTACH_DECL(sony_acpi, sizeof(struct sony_acpi_softc), sony_acpi_match, sony_acpi_attach, NULL, NULL); @@ -100,7 +158,7 @@ sony_sysctl_helper(SYSCTLFN_ARGS) rv = acpi_eval_integer(sc->sc_node->ad_handle, buf, &acpi_val); if (ACPI_FAILURE(rv)) { #ifdef DIAGNOSTIC - printf("%s: couldn't get `%s'\n", sc->sc_dev.dv_xname, buf); + printf("%s: couldn't get `%s'\n", device_xname(&sc->sc_dev), buf); #endif return EIO; } @@ -120,7 +178,7 @@ sony_sysctl_helper(SYSCTLFN_ARGS) if (ACPI_FAILURE(rv)) { #ifdef DIAGNOSTIC printf("%s: couldn't set `%s' to %d\n", - sc->sc_dev.dv_xname, buf, val); + device_xname(&sc->sc_dev), buf, val); #endif return EIO; } @@ -163,7 +221,8 @@ sony_walk_cb(ACPI_HANDLE hnd, UINT32 v, void *context, goto out; if ((rv = sysctl_createv(&sc->sc_log, 0, &node, &snode, 0, - CTLTYPE_NODE, sc->sc_dev.dv_xname, SYSCTL_DESCR("sony controls"), + CTLTYPE_NODE, device_xname(&sc->sc_dev), + SYSCTL_DESCR("sony controls"), NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0) goto out; @@ -176,7 +235,7 @@ out: #ifdef DIAGNOSTIC if (rv) printf("%s: sysctl_createv failed (rv = %d)\n", - sc->sc_dev.dv_xname, rv); + device_xname(&sc->sc_dev), rv); #endif return AE_OK; } @@ -216,6 +275,7 @@ sony_acpi_attach(struct device *parent, struct device *self, void *aux) { struct sony_acpi_softc *sc = (void *)self; struct acpi_attach_args *aa = aux; + struct wskbddev_attach_args wska; ACPI_STATUS rv; aprint_naive(": Sony Miscellaneous Controller\n"); @@ -223,12 +283,222 @@ sony_acpi_attach(struct device *parent, struct device *self, void *aux) sc->sc_node = aa->aa_node; + sony_acpi_quirk_setup(sc); + + /* Configure suspend button */ + sc->sc_smpsw.smpsw_name = sc->sc_dev.dv_xname; + sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_SLEEP; + sc->sc_smpsw_valid = 1; + + if (sysmon_pswitch_register(&sc->sc_smpsw) != 0) { + aprint_error("%s: couldn't register with sysmon\n", + device_xname(self)); + sc->sc_smpsw_valid = 0; + } + + /* Install notify handler */ + rv = AcpiInstallNotifyHandler(sc->sc_node->ad_handle, + ACPI_DEVICE_NOTIFY, sony_acpi_notify_handler, self); + if (ACPI_FAILURE(rv)) + aprint_error("%s: couldn't install notify handler (%d)\n", + device_xname(self), rv); + /* Install sysctl handler */ rv = AcpiWalkNamespace(ACPI_TYPE_METHOD, sc->sc_node->ad_handle, 1, sony_walk_cb, sc, NULL); #ifdef DIAGNOSTIC if (ACPI_FAILURE(rv)) aprint_error("%s: Cannot walk ACPI namespace (%d)\n", - sc->sc_dev.dv_xname, rv); + device_xname(self), rv); #endif + + if (!pmf_device_register(self, sony_acpi_suspend, sony_acpi_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + + if (!pmf_event_register(self, PMFE_DISPLAY_BRIGHTNESS_UP, + sony_acpi_brightness_up, true)) + aprint_error_dev(self, "couldn't register BRIGHTNESS UP handler\n"); + + if (!pmf_event_register(self, PMFE_DISPLAY_BRIGHTNESS_DOWN, + sony_acpi_brightness_down, true)) + aprint_error_dev(self, "couldn't register BRIGHTNESS DOWN handler\n"); + + wska.console = 0; + wska.keymap = &sony_acpi_keymapdata; + wska.accessops = &sony_acpi_accessops; + wska.accesscookie = sc; + + sc->sc_wskbddev = config_found(self, &wska, wskbddevprint); +} + +static void +sony_acpi_quirk_setup(struct sony_acpi_softc *sc) +{ + const char *product_name; + ACPI_HANDLE hdl; + int i; + + hdl = sc->sc_node->ad_handle; + + product_name = pnp_get_platform("system-product-name"); + if (product_name == NULL) + return; + + for (i = 0; sony_acpi_quirks[i].product_name != NULL; i++) + if (strcmp(sony_acpi_quirks[i].product_name, product_name) == 0) + break; + + if (sony_acpi_quirks[i].product_name == NULL) + return; + + if (sony_acpi_quirks[i].quirks & SONY_ACPI_QUIRK_FNINIT) { + /* Initialize extra Fn keys */ + sony_acpi_eval_set_integer(hdl, "SN02", 0x04, NULL); + sony_acpi_eval_set_integer(hdl, "SN07", 0x02, NULL); + sony_acpi_eval_set_integer(hdl, "SN02", 0x10, NULL); + sony_acpi_eval_set_integer(hdl, "SN07", 0x00, NULL); + sony_acpi_eval_set_integer(hdl, "SN03", 0x02, NULL); + sony_acpi_eval_set_integer(hdl, "SN07", 0x101, NULL); + } + + return; +} + +static void +sony_acpi_notify_handler(ACPI_HANDLE hdl, UINT32 notify, void *opaque) +{ + device_t dv = opaque; + struct sony_acpi_softc *sc = device_private(dv); + ACPI_STATUS rv; + ACPI_INTEGER arg; + int s; + + if (notify == SONY_NOTIFY_FnKeyEvent) { + rv = sony_acpi_eval_set_integer(hdl, "SN07", 0x202, &arg); + if (ACPI_FAILURE(rv)) + return; + + notify = arg & 0xff; + } + + s = spltty(); + switch (notify) { + case SONY_NOTIFY_BrightnessDownPressed: + sony_acpi_brightness_down(dv); + break; + case SONY_NOTIFY_BrightnessUpPressed: + sony_acpi_brightness_up(dv); + break; + case SONY_NOTIFY_BrightnessDownReleased: + case SONY_NOTIFY_BrightnessUpReleased: + break; + case SONY_NOTIFY_SuspendPressed: + if (!sc->sc_smpsw_valid) + break; + sysmon_pswitch_event(&sc->sc_smpsw, PSWITCH_EVENT_PRESSED); + break; + case SONY_NOTIFY_SuspendReleased: + break; + case SONY_NOTIFY_DisplaySwitchPressed: + case SONY_NOTIFY_DisplaySwitchReleased: + case SONY_NOTIFY_ZoomPressed: + case SONY_NOTIFY_ZoomReleased: + if (sc->sc_wskbddev == NULL) + break; + wskbd_input(sc->sc_wskbddev, + notify & 0x80 ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN, + notify); /* XXX */ + break; + default: + printf("%s: unknown notify event 0x%x\n", + device_xname(&sc->sc_dev), notify); + break; + } + splx(s); + + return; +} + +static bool +sony_acpi_suspend(device_t dv) +{ + struct sony_acpi_softc *sc = device_private(dv); + + acpi_eval_integer(sc->sc_node->ad_handle, "GBRT", &sc->sc_pmstate.brt); + + return true; +} + +static bool +sony_acpi_resume(device_t dv) +{ + struct sony_acpi_softc *sc = device_private(dv); + + sony_acpi_eval_set_integer(sc->sc_node->ad_handle, "SBRT", + sc->sc_pmstate.brt, NULL); + sony_acpi_quirk_setup(sc); + + return true; +} + +static int +sony_acpi_wskbd_enable(void *opaque, int on) +{ + + return 0; +} + +static void +sony_acpi_wskbd_set_leds(void *opaque, int leds) +{ + + return; +} + +static int +sony_acpi_wskbd_ioctl(void *opaque, u_long cmd, void *data, int flags, + struct lwp *l) +{ + + switch (cmd) { + case WSKBDIO_GTYPE: + *(int *)data = WSKBD_TYPE_USB; /* close enough */ + return 0; + default: + break; + } + + return EPASSTHROUGH; +} + +static void +sony_acpi_brightness_up(device_t dv) +{ + struct sony_acpi_softc *sc = device_private(dv); + ACPI_INTEGER arg; + ACPI_STATUS rv; + + rv = acpi_eval_integer(sc->sc_node->ad_handle, "GBRT", &arg); + if (ACPI_FAILURE(rv) || arg > 8) + return; + arg++; + sony_acpi_eval_set_integer(sc->sc_node->ad_handle, "SBRT", arg, NULL); + + return; +} + +static void +sony_acpi_brightness_down(device_t dv) +{ + struct sony_acpi_softc *sc = device_private(dv); + ACPI_INTEGER arg; + ACPI_STATUS rv; + + rv = acpi_eval_integer(sc->sc_node->ad_handle, "GBRT", &arg); + if (ACPI_FAILURE(rv) || arg == 0) + return; + arg--; + sony_acpi_eval_set_integer(sc->sc_node->ad_handle, "SBRT", arg, NULL); + + return; } diff --git a/sys/arch/i386/acpi/vald_acpi.c b/sys/arch/i386/acpi/vald_acpi.c index 66b33e40b8b..3edb1c7f7c8 100644 --- a/sys/arch/i386/acpi/vald_acpi.c +++ b/sys/arch/i386/acpi/vald_acpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: vald_acpi.c,v 1.25 2007/04/04 01:34:44 rmind Exp $ */ +/* $NetBSD: vald_acpi.c,v 1.26 2007/12/09 20:27:45 jmcneill Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -83,7 +83,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vald_acpi.c,v 1.25 2007/04/04 01:34:44 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vald_acpi.c,v 1.26 2007/12/09 20:27:45 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -272,8 +272,7 @@ vald_acpi_notify_handler(ACPI_HANDLE handle, UINT32 notify, sc->sc_dev.dv_xname); #endif /* VALD_ACPI_DEBUG */ - rv = AcpiOsQueueForExecution(OSD_PRIORITY_LO, - vald_acpi_event, sc); + rv = AcpiOsExecute(OSL_NOTIFY_HANDLER, vald_acpi_event, sc); if (ACPI_FAILURE(rv)) printf("%s: WARNING: unable to queue vald change " diff --git a/sys/arch/i386/bios/vesafb.c b/sys/arch/i386/bios/vesafb.c index af1f208f949..df7c7d82791 100644 --- a/sys/arch/i386/bios/vesafb.c +++ b/sys/arch/i386/bios/vesafb.c @@ -1,4 +1,4 @@ -/* $NetBSD: vesafb.c,v 1.24 2007/10/17 19:54:41 garbled Exp $ */ +/* $NetBSD: vesafb.c,v 1.25 2007/12/09 20:27:45 jmcneill Exp $ */ /*- * Copyright (c) 2006 Jared D. McNeill <jmcneill@invisible.ca> @@ -37,7 +37,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vesafb.c,v 1.24 2007/10/17 19:54:41 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vesafb.c,v 1.25 2007/12/09 20:27:45 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -81,10 +81,9 @@ static void vesafb_show_screen_cb(struct vcons_screen *); static void vesafb_init_screen(void *, struct vcons_screen *, int, long *); -static void vesafb_init(struct vesafb_softc *); -static void vesafb_powerhook(int, void *); +static void vesafb_init(struct vesafb_softc *, int); -static int vesafb_svideo(struct vesafb_softc *, u_int *); +static int vesafb_svideo(struct vesafb_softc *, int); static int vesafb_gvideo(struct vesafb_softc *, u_int *); static int vesafb_putcmap(struct vesafb_softc *, struct wsdisplay_cmap *); @@ -93,6 +92,12 @@ static int vesafb_getcmap(struct vesafb_softc *, static void vesafb_set_palette(struct vesafb_softc *, int, struct paletteentry); +static void vesafb_display_on(device_t); +static void vesafb_display_standby(device_t); +static void vesafb_display_suspend(device_t); +static void vesafb_display_off(device_t); +static void vesafb_display_reduced(device_t); + struct wsdisplay_accessops vesafb_accessops = { vesafb_ioctl, vesafb_mmap, @@ -250,22 +255,14 @@ vesafb_attach(struct device *parent, struct device *dev, void *aux) "possible\n", sc->sc_dev.dv_xname); if (sc->sc_pm) { - aprint_normal("%s: VBE/PM %d.%d", sc->sc_dev.dv_xname, + aprint_normal("%s: VBE/PM %d.%d\n", sc->sc_dev.dv_xname, (sc->sc_pmver >> 4), sc->sc_pmver & 0xf); - if (sc->sc_pmstates & 1) - aprint_normal(" [standby]"); - if (sc->sc_pmstates & 2) - aprint_normal(" [suspend]"); - if (sc->sc_pmstates & 4) - aprint_normal(" [off]"); - if (sc->sc_pmstates & 8) - aprint_normal(" [reduced on]"); - aprint_normal("\n"); } res = _x86_memio_map(X86_BUS_SPACE_MEM, mi->PhysBasePtr, sc->sc_fbsize, /* was sc_screensize */ - BUS_SPACE_MAP_LINEAR, &h); + BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, + &h); if (res) { aprint_error("%s: framebuffer mapping failed\n", sc->sc_dev.dv_xname); @@ -293,7 +290,7 @@ vesafb_attach(struct device *parent, struct device *dev, void *aux) sc->sc_displ_hwbits = NULL; #endif /* !VESAFB_SHADOW_FB */ - vesafb_init(sc); + vesafb_init(sc, 1); vesafb_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; vcons_init_screen(&sc->sc_vd, &vesafb_console_screen, 1, &defattr); @@ -341,11 +338,33 @@ vesafb_attach(struct device *parent, struct device *dev, void *aux) sc->sc_isconsole = 1; - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - vesafb_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: unable to establish powerhook\n", - sc->sc_dev.dv_xname); + if (!pmf_device_register(dev, NULL, NULL)) + aprint_error_dev(dev, "couldn't establish power handler\n"); + else if (!pmf_class_display_register(dev)) + aprint_error_dev(dev, "couldn't set display class\n"); + + if (!pmf_event_register(dev, PMFE_DISPLAY_ON, vesafb_display_on, true)) + aprint_error_dev(dev, "couldn't register DISPLAY ON event\n"); + if ((sc->sc_pmstates & 1) != 0 && + !pmf_event_register(dev, PMFE_DISPLAY_STANDBY, + vesafb_display_standby, true)) + aprint_error_dev(dev, + "couldn't register DISPLAY STANDBY event\n"); + if ((sc->sc_pmstates & 2) != 0 && + !pmf_event_register(dev, PMFE_DISPLAY_SUSPEND, + vesafb_display_suspend, true)) + aprint_error_dev(dev, + "couldn't register DISPLAY SUSPEND event\n"); + if ((sc->sc_pmstates & 4) != 0 && + !pmf_event_register(dev, PMFE_DISPLAY_OFF, + vesafb_display_off, true)) + aprint_error_dev(dev, + "couldn't register DISPLAY OFF event\n"); + if ((sc->sc_pmstates & 8) != 0 && + !pmf_event_register(dev, PMFE_DISPLAY_REDUCED, + vesafb_display_reduced, true)) + aprint_error_dev(dev, + "couldn't register DISPLAY REDUCED event\n"); config_found(dev, &aa, wsemuldisplaydevprint); @@ -384,9 +403,13 @@ vesafb_ioctl(void *v, void *vs, u_long cmd, void *data, else return ENODEV; case WSDISPLAYIO_SVIDEO: - if (sc->sc_pm) - return vesafb_svideo(sc, (u_int *)data); - else + if (sc->sc_pm) { + u_int on = *(u_int *)data; + if (on == WSDISPLAYIO_VIDEO_OFF) + return vesafb_svideo(sc, 4); + else + return vesafb_svideo(sc, 0); + } else return ENODEV; case WSDISPLAYIO_GETCMAP: if (sc->sc_mi.BitsPerPixel == 8) @@ -408,8 +431,10 @@ vesafb_ioctl(void *v, void *vs, u_long cmd, void *data, int new_mode = *(int *)data; if (new_mode != sc->sc_wsmode) { sc->sc_wsmode = new_mode; - if (new_mode == WSDISPLAYIO_MODE_EMUL) + if (new_mode == WSDISPLAYIO_MODE_EMUL) { + /* vesafb_init(sc, 0); */ vcons_redraw_screen(vd->active); + } } } return 0; @@ -617,53 +642,40 @@ vesafb_init_screen(void *c, struct vcons_screen *scr, int existing, } static void -vesafb_init(struct vesafb_softc *sc) +vesafb_init(struct vesafb_softc *sc, int setmode) { - struct trapframe tf; -#if notyet struct bioscallregs regs; -#endif struct modeinfoblock *mi; struct paletteentry pe; - int res; - int i, j; + int i, j, s; mi = &sc->sc_mi; - /* set mode */ -#if 1 - memset(&tf, 0, sizeof(struct trapframe)); - tf.tf_eax = 0x4f02; /* function code */ - tf.tf_ebx = sc->sc_mode | 0x4000; /* flat */ + s = splsched(); - res = kvm86_bioscall(0x10, &tf); - if (res || (tf.tf_eax & 0xff) != 0x4f) { - aprint_error("%s: vbecall: res=%d, ax=%x\n", - sc->sc_dev.dv_xname, res, tf.tf_eax); - return; - } -#else - regs.EAX = 0x4f02; - regs.EBX = sc->sc_mode | 0x4000; - bioscall(0x10, ®s); - if ((regs.EAX & 0xff) != 0x4f) { - aprint_error("%s: bioscall failed\n", - sc->sc_dev.dv_xname); - return; + if (setmode) { + /* set mode */ + regs.EAX = 0x4f02; + regs.EBX = sc->sc_mode | 0x4000; + kvm86_bioscall_simple(0x10, ®s); + if ((regs.EAX & 0xff) != 0x4f) { + aprint_error("%s: bioscall failed\n", + sc->sc_dev.dv_xname); + goto out; + } } -#endif /* setup palette, not required in direct colour mode */ if (mi->BitsPerPixel == 8) { - memset(&tf, 0, sizeof(struct trapframe)); - tf.tf_eax = 0x4f08; /* function code */ - tf.tf_ebx = 0x0600; /* we want a 6-bit palette */ - - res = kvm86_bioscall(0x10, &tf); - if (res || (tf.tf_eax & 0xff) != 0x4f) { - aprint_error("%s: vbecall: res=%d, ax=%x\n", - sc->sc_dev.dv_xname, res, tf.tf_eax); - return; + memset(®s, 0, sizeof(struct bioscallregs)); + regs.EAX = 0x4f08; /* function code */ + regs.EBX = 0x0600; /* we want a 6-bit palette */ + + kvm86_bioscall_simple(0x10, ®s); + if ((regs.EAX & 0xff) != 0x4f) { + aprint_error("%s: vbecall failed: ax=%x\n", + sc->sc_dev.dv_xname, regs.EAX); + goto out; } j = 0; @@ -702,28 +714,54 @@ vesafb_init(struct vesafb_softc *sc) } } +out: + splx(s); return; } static void -vesafb_powerhook(int why, void *opaque) +vesafb_display_on(device_t dv) { -#if notyet - struct vesafb_softc *sc; + struct vesafb_softc *sc = device_private(dv); + + if (sc->sc_wsmode == WSDISPLAYIO_MODE_EMUL) + vesafb_svideo(sc, 0); +} - sc = (struct vesafb_softc *)opaque; +static void +vesafb_display_standby(device_t dv) +{ + struct vesafb_softc *sc = device_private(dv); - switch (why) { - case PWR_STANDBY: - case PWR_SUSPEND: - break; - case PWR_RESUME: - vesafb_init(sc); - break; - } -#endif + if (sc->sc_wsmode == WSDISPLAYIO_MODE_EMUL) + vesafb_svideo(sc, 1); +} - return; +static void +vesafb_display_suspend(device_t dv) +{ + struct vesafb_softc *sc = device_private(dv); + + if (sc->sc_wsmode == WSDISPLAYIO_MODE_EMUL) + vesafb_svideo(sc, 2); +} + +static void +vesafb_display_off(device_t dv) +{ + struct vesafb_softc *sc = device_private(dv); + + if (sc->sc_wsmode == WSDISPLAYIO_MODE_EMUL) + vesafb_svideo(sc, 4); +} + +static void +vesafb_display_reduced(device_t dv) +{ + struct vesafb_softc *sc = device_private(dv); + + if (sc->sc_wsmode == WSDISPLAYIO_MODE_EMUL) + vesafb_svideo(sc, 8); } static void @@ -764,28 +802,23 @@ vesafb_set_palette(struct vesafb_softc *sc, int reg, } static int -vesafb_svideo(struct vesafb_softc *sc, u_int *on) +vesafb_svideo(struct vesafb_softc *sc, int bh) { #ifdef VESAFB_PM - struct trapframe tf; - int res, bh; + struct bioscallregs regs; + int s; - if (*on == WSDISPLAYIO_VIDEO_OFF) - bh = 1; /* 1:standby 2:suspend, 4:off, 8:reduced_on */ - else - bh = 0; /* 0:on */ + /* If the power management state is not supported, bail */ + if ((sc->sc_pmstates & bh) != bh) + return ENODEV; - /* set video pm state */ - memset(&tf, 0, sizeof(struct trapframe)); - tf.tf_eax = 0x4f10; /* function code */ - tf.tf_ebx = (bh << 8) | 1; + memset(®s, 0, sizeof(struct bioscallregs)); + regs.EAX = 0x4f10; + regs.EBX = (bh << 8) | 1; - res = kvm86_bioscall(0x10, &tf); - if (res || (tf.tf_eax & 0xff) != 0x4f) { - aprint_error("%s: unable to set power state (0x%04x)\n", - sc->sc_dev.dv_xname, (tf.tf_eax & 0xffff)); - return ENODEV; - } + s = splsched(); + kvm86_bioscall_simple(0x10, ®s); + splx(s); return 0; #else diff --git a/sys/arch/i386/conf/ALL b/sys/arch/i386/conf/ALL index 69bbd60806e..2f91c225417 100644 --- a/sys/arch/i386/conf/ALL +++ b/sys/arch/i386/conf/ALL @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.145 2007/12/05 00:19:41 xtraeme Exp $ +# $NetBSD: ALL,v 1.146 2007/12/09 20:27:45 jmcneill Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "ALL-$Revision: 1.145 $" +#ident "ALL-$Revision: 1.146 $" maxusers 32 # estimated number of users @@ -343,7 +343,11 @@ options ACPICA_PEDANTIC # force strict conformance to the Spec. acpiacad* at acpi? # ACPI AC Adapter acpibat* at acpi? # ACPI Battery acpibut* at acpi? # ACPI Button -acpiec* at acpi? # ACPI Embedded Controller +# The ACPI Embedded Controller is generally configured via the special ECDT. +# This is required as parts of the DSDT can reference the EC before the normal +# attach phase. +acpiec* at acpi? # ACPI Embedded Controller (late binding) +acpiecdt* at acpi? # ACPI Embedded Controller (early binding) acpilid* at acpi? # ACPI Lid Switch acpitz* at acpi? # ACPI Thermal Zone @@ -434,6 +438,7 @@ amdpcib* at pci? dev ? function ? # AMD 8111 PCI-ISA w/ HPET hpet* at amdpcib? ichlpcib* at pci? dev ? function ? # Intel ICH PCI-ISA w/ watchdog and # SpeedStep support +hpet0 at ichlpcib? # High Precision Event Timer piixpcib* at pci? dev ? function ? # Intel PIIX4 PCI-ISA w/ SpeedStep gscpcib* at pci? dev ? function ? # NS Geode PCI-ISA w/ GPIO support viapcib* at pci? dev ? function ? # VIA VT8235 PCI-ISA w/ SMBus support diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 87521280d9a..e577bf8004a 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.866 2007/12/05 00:19:41 xtraeme Exp $ +# $NetBSD: GENERIC,v 1.867 2007/12/09 20:27:46 jmcneill Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.866 $" +#ident "GENERIC-$Revision: 1.867 $" maxusers 32 # estimated number of users @@ -340,7 +340,11 @@ apm* at acpi? # ACPI apm emulation acpiacad* at acpi? # ACPI AC Adapter acpibat* at acpi? # ACPI Battery acpibut* at acpi? # ACPI Button -acpiec* at acpi? # ACPI Embedded Controller +# The ACPI Embedded Controller is generally configured via the special ECDT. +# This is required as parts of the DSDT can reference the EC before the normal +# attach phase. +acpiec* at acpi? # ACPI Embedded Controller (late binding) +acpiecdt* at acpi? # ACPI Embedded Controller (early binding) acpilid* at acpi? # ACPI Lid Switch acpitz* at acpi? # ACPI Thermal Zone diff --git a/sys/arch/i386/conf/Makefile.i386 b/sys/arch/i386/conf/Makefile.i386 index b2ffecda365..4482172cf9f 100644 --- a/sys/arch/i386/conf/Makefile.i386 +++ b/sys/arch/i386/conf/Makefile.i386 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.i386,v 1.153 2007/12/02 04:24:44 christos Exp $ +# $NetBSD: Makefile.i386,v 1.154 2007/12/09 20:27:46 jmcneill Exp $ # Makefile for NetBSD # @@ -86,7 +86,7 @@ freebsd_sigcode.o ibcs2_sigcode.o linux_sigcode.o: assym.h svr4_sigcode.o mach_sigcode.o: assym.h apmcall.o cpufunc.o in_cksum.o pnpbioscall.o bioscall.o: assym.h mptramp.o: assym.h -busfunc.o kvm86call.o: assym.h +acpi_wakeup_low.o busfunc.o kvm86call.o: assym.h clock.o: config_time.h ## @@ -110,6 +110,7 @@ clock.o: config_time.h ## Include rules for Atheros WLAN .include "$S/contrib/dev/ath/netbsd/Makefile.ath.inc" +.include "$S/arch/x86/acpi/Makefile.wakecode.inc" ## ## (9) port independent kernel machinery diff --git a/sys/arch/i386/conf/VIRTUALPC b/sys/arch/i386/conf/VIRTUALPC index 8a4831dc031..7119eac1680 100644 --- a/sys/arch/i386/conf/VIRTUALPC +++ b/sys/arch/i386/conf/VIRTUALPC @@ -1,4 +1,4 @@ -# $NetBSD: VIRTUALPC,v 1.57 2007/11/14 17:54:58 ad Exp $ +# $NetBSD: VIRTUALPC,v 1.58 2007/12/09 20:27:46 jmcneill Exp $ # # VIRTUALPC machine description file -- # @@ -11,7 +11,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "VIRTUALPC-$Revision: 1.57 $" +#ident "VIRTUALPC-$Revision: 1.58 $" maxusers 32 # estimated number of users @@ -277,7 +277,8 @@ cpu* at mainbus? #acpiacad* at acpi? # ACPI AC Adapter #acpibat* at acpi? # ACPI Battery #acpibut* at acpi? # ACPI Button -#acpiec* at acpi? # ACPI Embedded Controller +#acpiec* at acpi? # ACPI Embedded Controller (late binding) +#acpiecdt* at acpi? # ACPI Embedded Controller (early binding) #acpilid* at acpi? # ACPI Lid Switch #acpitz* at acpi? # ACPI Thermal Zone diff --git a/sys/arch/i386/conf/XEN3_DOM0 b/sys/arch/i386/conf/XEN3_DOM0 index 0f2f0389b43..c2b3506deb8 100644 --- a/sys/arch/i386/conf/XEN3_DOM0 +++ b/sys/arch/i386/conf/XEN3_DOM0 @@ -1,4 +1,4 @@ -# $NetBSD: XEN3_DOM0,v 1.6 2006/10/17 19:57:24 bouyer Exp $ +# $NetBSD: XEN3_DOM0,v 1.7 2007/12/09 20:27:46 jmcneill Exp $ # # XEN3_0: Xen 3.0 domain0 kernel @@ -29,7 +29,11 @@ ioapic* at mainbus? apid ? acpiacad* at acpi? # ACPI AC Adapter acpibat* at acpi? # ACPI Battery acpibut* at acpi? # ACPI Button -acpiec* at acpi? # ACPI Embedded Controller +# The ACPI Embedded Controller is generally configured via the special ECDT. +# This is required as parts of the DSDT can reference the EC before the normal +# attach phase. +acpiec* at acpi? # ACPI Embedded Controller (late binding) +acpiecdt* at acpi? # ACPI Embedded Controller (early binding) acpilid* at acpi? # ACPI Lid Switch pseudo-device xvif diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386 index a86fcc86fe6..fec1cb20f5d 100644 --- a/sys/arch/i386/conf/files.i386 +++ b/sys/arch/i386/conf/files.i386 @@ -1,4 +1,4 @@ -# $NetBSD: files.i386,v 1.322 2007/11/22 16:16:46 bouyer Exp $ +# $NetBSD: files.i386,v 1.323 2007/12/09 20:27:46 jmcneill Exp $ # # new style config file for i386 architecture # @@ -142,7 +142,8 @@ define vesabiosbus {} # XXX BIOS32 only if something that uses it is configured! device mainbus: isabus, eisabus, mcabus, pcibus, bios32, acpibus, - cpubus, ioapicbus, apmbus, pnpbiosbus, vesabiosbus, ipmibus + cpubus, ioapicbus, apmbus, pnpbiosbus, vesabiosbus, ipmibus, + bioscall attach mainbus at root file arch/i386/i386/mainbus.c mainbus @@ -471,7 +472,8 @@ include "dev/ieee1394/files.ieee1394" include "arch/i386/pnpbios/files.pnpbios" include "dev/acpi/files.acpi" -file arch/i386/acpi/acpi_wakeup.c acpi +file arch/i386/acpi/acpi_wakeup.c acpi +file arch/i386/acpi/acpi_wakeup_low.S acpi # Toshiba VALD device vald @@ -483,7 +485,7 @@ attach spic at acpinodebus with spic_acpi file arch/i386/acpi/spic_acpi.c spic_acpi # Sony Misc (brightness etc.) -device sony +device sony: displaydev, wskbddev attach sony at acpinodebus with sony_acpi file arch/i386/acpi/sony_acpi.c sony_acpi @@ -498,11 +500,11 @@ defflag opt_vesabios.h VESABIOSVERBOSE include "dev/rasops/files.rasops" -device vesafb: wsemuldisplaydev, vcons, rasops8, rasops16, rasops32, splash, bioscall +device vesafb: displaydev, wsemuldisplaydev, vcons, rasops8, rasops16, rasops32, splash, bioscall attach vesafb at vesabios file arch/i386/bios/vesafb.c vesafb needs-flag -defparam opt_vesafb.h VESAFB_WIDTH VESAFB_HEIGHT VESAFB_DEPTH -defflag opt_vesafb.h VESAFB_PM +defparam opt_vesafb.h VESAFB_WIDTH VESAFB_HEIGHT VESAFB_DEPTH +defflag opt_vesafb.h VESAFB_PM device vesatext attach vesatext at vesabios diff --git a/sys/arch/i386/i386/autoconf.c b/sys/arch/i386/i386/autoconf.c index 2bb05769b05..61e49d49920 100644 --- a/sys/arch/i386/i386/autoconf.c +++ b/sys/arch/i386/i386/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.88 2007/11/14 17:54:59 ad Exp $ */ +/* $NetBSD: autoconf.c,v 1.89 2007/12/09 20:27:47 jmcneill Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -46,7 +46,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.88 2007/11/14 17:54:59 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.89 2007/12/09 20:27:47 jmcneill Exp $"); #include "opt_compat_oldboot.h" #include "opt_multiprocessor.h" @@ -77,6 +77,8 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.88 2007/11/14 17:54:59 ad Exp $"); #include "bios32.h" #if NBIOS32 > 0 #include <machine/bios32.h> +/* XXX */ +extern void platform_init(void); #endif #include "opt_pcibios.h" @@ -104,6 +106,7 @@ cpu_configure(void) #if NBIOS32 > 0 bios32_init(); + platform_init(); #endif #ifdef PCIBIOS pcibios_init(); diff --git a/sys/arch/i386/i386/bios32.c b/sys/arch/i386/i386/bios32.c index a82b034b2c9..dfbfd21b6af 100644 --- a/sys/arch/i386/i386/bios32.c +++ b/sys/arch/i386/i386/bios32.c @@ -1,4 +1,4 @@ -/* $NetBSD: bios32.c,v 1.16 2007/12/01 16:59:13 jmcneill Exp $ */ +/* $NetBSD: bios32.c,v 1.17 2007/12/09 20:27:47 jmcneill Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -93,7 +93,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.16 2007/12/01 16:59:13 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.17 2007/12/09 20:27:47 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -162,7 +162,6 @@ bios32_init() bios32_entry.offset = (void *)ISA_HOLE_VADDR(entry); bios32_entry.segment = GSEL(GCODE_SEL, SEL_KPL); } -#if NIPMI > 0 /* see if we have SMBIOS extentions */ for (p = ISA_HOLE_VADDR(SMBIOS_START); p < (char *)ISA_HOLE_VADDR(SMBIOS_END); p+= 16) { @@ -210,8 +209,6 @@ bios32_init() break; } pmap_update(pmap_kernel()); -#endif - } /* @@ -259,7 +256,6 @@ bios32_service(service, e, ei) return (1); } -#if NIPMI > 0 /* * smbios_find_table() takes a caller supplied smbios struct type and * a pointer to a handle (struct smbtable) returning one if the structure @@ -343,4 +339,3 @@ smbios_get_string(struct smbtable *st, u_int8_t indx, char *dest, size_t len) return ret; } -#endif diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 3fc47c93397..535f3d212f8 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.616 2007/12/03 15:33:46 ad Exp $ */ +/* $NetBSD: machdep.c,v 1.617 2007/12/09 20:27:47 jmcneill Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.616 2007/12/03 15:33:46 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.617 2007/12/09 20:27:47 jmcneill Exp $"); #include "opt_beep.h" #include "opt_compat_ibcs2.h" @@ -1440,6 +1440,103 @@ initgdt(union descriptor *tgdt) lgdt(®ion); } +static void +init386_msgbuf(void) +{ + /* Message buffer is located at end of core. */ + struct vm_physseg *vps; + psize_t sz = round_page(MSGBUFSIZE); + psize_t reqsz = sz; + unsigned int x; + + search_again: + vps = NULL; + for (x = 0; x < vm_nphysseg; ++x) { + vps = &vm_physmem[x]; + if (ptoa(vps->avail_end) == avail_end) { + break; + } + } + if (x == vm_nphysseg) + panic("init386: can't find end of memory"); + + /* Shrink so it'll fit in the last segment. */ + if (vps->avail_end - vps->avail_start < atop(sz)) + sz = ptoa(vps->avail_end - vps->avail_start); + + vps->avail_end -= atop(sz); + vps->end -= atop(sz); + msgbuf_p_seg[msgbuf_p_cnt].sz = sz; + msgbuf_p_seg[msgbuf_p_cnt++].paddr = ptoa(vps->avail_end); + + /* Remove the last segment if it now has no pages. */ + if (vps->start == vps->end) { + for (--vm_nphysseg; x < vm_nphysseg; x++) + vm_physmem[x] = vm_physmem[x + 1]; + } + + /* Now find where the new avail_end is. */ + for (avail_end = 0, x = 0; x < vm_nphysseg; x++) + if (vm_physmem[x].avail_end > avail_end) + avail_end = vm_physmem[x].avail_end; + avail_end = ptoa(avail_end); + + if (sz == reqsz) + return; + + reqsz -= sz; + if (msgbuf_p_cnt == VM_PHYSSEG_MAX) { + /* No more segments available, bail out. */ + printf("WARNING: MSGBUFSIZE (%zu) too large, using %zu.\n", + (size_t)MSGBUFSIZE, (size_t)(MSGBUFSIZE - reqsz)); + return; + } + + sz = reqsz; + goto search_again; +} + +static void +init386_pte0(void) +{ + paddr_t paddr; + vaddr_t vaddr; + + paddr = 4 * PAGE_SIZE; + vaddr = (vaddr_t)vtopte(0); + pmap_kenter_pa(vaddr, paddr, VM_PROT_READ | VM_PROT_WRITE); + pmap_update(pmap_kernel()); + /* make sure it is clean before using */ + memset((void *)vaddr, 0, PAGE_SIZE); +} + +static void +init386_ksyms(void) +{ +#if NKSYMS || defined(DDB) || defined(LKM) + extern int end; + struct btinfo_symtab *symtab; + +#ifdef DDB + db_machine_init(); +#endif + +#if defined(MULTIBOOT) + if (multiboot_ksyms_init()) + return; +#endif + + if ((symtab = lookup_bootinfo(BTINFO_SYMTAB)) == NULL) { + ksyms_init(*(int *)&end, ((int *)&end) + 1, esym); + return; + } + + symtab->ssym += KERNBASE; + symtab->esym += KERNBASE; + ksyms_init(symtab->nsym, (int *)symtab->ssym, (int *)symtab->esym); +#endif +} + void init386(paddr_t first_avail) { @@ -1451,9 +1548,6 @@ init386(paddr_t first_avail) int x, first16q; uint64_t seg_start, seg_end; uint64_t seg_start1, seg_end1; - paddr_t realmode_reserved_start; - psize_t realmode_reserved_size; - int needs_earlier_install_pte0; #if NBIOSCALL > 0 extern int biostramp_image_size; extern u_char biostramp_image[]; @@ -1514,45 +1608,15 @@ init386(paddr_t first_avail) uvmexp.ncolors = 2; /* - * BIOS leaves data in physical page 0 - * Even if it didn't, our VM system doesn't like using zero as a - * physical page number. - * We may also need pages in low memory (one each) for secondary CPU - * startup, for BIOS calls, and for ACPI, plus a page table page to map - * them into the first few pages of the kernel's pmap. - */ - avail_start = PAGE_SIZE; - - /* - * reserve memory for real-mode call + * Low memory reservations: + * Page 0: BIOS data + * Page 1: BIOS callback + * Page 2: MP bootstrap + * Page 3: ACPI wakeup code + * Page 4: Temporary page table for 0MB-4MB + * Page 5: Temporary page directory */ - needs_earlier_install_pte0 = 0; - realmode_reserved_start = 0; - realmode_reserved_size = 0; -#if NBIOSCALL > 0 - /* save us a page for trampoline code */ - realmode_reserved_size += PAGE_SIZE; - needs_earlier_install_pte0 = 1; -#endif -#ifdef MULTIPROCESSOR /* XXX */ - KASSERT(avail_start == PAGE_SIZE); /* XXX */ - if (realmode_reserved_size < MP_TRAMPOLINE) /* XXX */ - realmode_reserved_size = MP_TRAMPOLINE; /* XXX */ - needs_earlier_install_pte0 = 1; /* XXX */ -#endif /* XXX */ -#if NACPI > 0 - /* trampoline code for wake handler */ - realmode_reserved_size += ptoa(acpi_md_get_npages_of_wakecode()+1); - needs_earlier_install_pte0 = 1; -#endif - if (needs_earlier_install_pte0) { - /* page table for directory entry 0 */ - realmode_reserved_size += PAGE_SIZE; - } - if (realmode_reserved_size>0) { - realmode_reserved_start = avail_start; - avail_start += realmode_reserved_size; - } + avail_start = 6 * PAGE_SIZE; #ifdef DEBUG_MEMLOAD printf("mem_cluster_count: %d\n", mem_cluster_cnt); @@ -1817,135 +1881,25 @@ init386(paddr_t first_avail) } } + init386_msgbuf(); /* - * Steal memory for the message buffer (at end of core). - */ - { - struct vm_physseg *vps; - psize_t sz = round_page(MSGBUFSIZE); - psize_t reqsz = sz; - - search_again: - for (x = 0; x < vm_nphysseg; x++) { - vps = &vm_physmem[x]; - if (ptoa(vps->avail_end) == avail_end) - goto found; - } - panic("init386: can't find end of memory"); - - found: - /* Shrink so it'll fit in the last segment. */ - if ((vps->avail_end - vps->avail_start) < atop(sz)) - sz = ptoa(vps->avail_end - vps->avail_start); - - vps->avail_end -= atop(sz); - vps->end -= atop(sz); - msgbuf_p_seg[msgbuf_p_cnt].sz = sz; - msgbuf_p_seg[msgbuf_p_cnt++].paddr = ptoa(vps->avail_end); - - /* Remove the last segment if it now has no pages. */ - if (vps->start == vps->end) { - for (vm_nphysseg--; x < vm_nphysseg; x++) - vm_physmem[x] = vm_physmem[x + 1]; - } - - /* Now find where the new avail_end is. */ - for (avail_end = 0, x = 0; x < vm_nphysseg; x++) - if (vm_physmem[x].avail_end > avail_end) - avail_end = vm_physmem[x].avail_end; - avail_end = ptoa(avail_end); - - if (sz != reqsz) { - reqsz -= sz; - if (msgbuf_p_cnt != VM_PHYSSEG_MAX) { - /* if still segments available, get memory from next one ... */ - sz = reqsz; - goto search_again; - } - /* Warn if the message buffer had to be shrunk. */ - printf("WARNING: %ld bytes not available for msgbuf " - "in last cluster (%ld used)\n", (long)MSGBUFSIZE, MSGBUFSIZE - reqsz); - } - } - - /* - * install PT page for the first 4M if needed. + * XXX Remove this + * + * Setup a temporary Page Table Entry to allow identity mappings of + * the real mode address. This is required by: + * - bioscall + * - MP bootstrap + * - ACPI wakecode */ - if (needs_earlier_install_pte0) { - paddr_t paddr; -#ifdef DIAGNOSTIC - if (realmode_reserved_size < PAGE_SIZE) { - panic("cannot steal memory for first 4M PT page."); - } -#endif - paddr=realmode_reserved_start+realmode_reserved_size-PAGE_SIZE; - pmap_kenter_pa((vaddr_t)vtopte(0), paddr, - VM_PROT_READ|VM_PROT_WRITE); - pmap_update(pmap_kernel()); - /* make sure it is clean before using */ - memset(vtopte(0), 0, PAGE_SIZE); - realmode_reserved_size -= PAGE_SIZE; - } + init386_pte0(); #if NBIOSCALL > 0 - /* - * this should be caught at kernel build time, but put it here - * in case someone tries to fake it out... - */ -#ifdef DIAGNOSTIC - if (realmode_reserved_start > BIOSTRAMP_BASE || - (realmode_reserved_start+realmode_reserved_size) < (BIOSTRAMP_BASE+ - PAGE_SIZE)) { - panic("cannot steal memory for PT page of bioscall."); - } - if (biostramp_image_size > PAGE_SIZE) - panic("biostramp_image_size too big: %x vs. %x", - biostramp_image_size, PAGE_SIZE); -#endif + KASSERT(biostramp_image_size <= PAGE_SIZE); pmap_kenter_pa((vaddr_t)BIOSTRAMP_BASE, /* virtual */ (paddr_t)BIOSTRAMP_BASE, /* physical */ VM_PROT_ALL); /* protection */ pmap_update(pmap_kernel()); memcpy((void *)BIOSTRAMP_BASE, biostramp_image, biostramp_image_size); -#ifdef DEBUG_BIOSCALL - printf("biostramp installed @ %x\n", BIOSTRAMP_BASE); -#endif - realmode_reserved_size -= PAGE_SIZE; - realmode_reserved_start += PAGE_SIZE; -#endif - -#if NACPI > 0 - /* - * Steal memory for the acpi wake code - */ - { - paddr_t paddr, p; - psize_t sz; - int npg; - - paddr = realmode_reserved_start; - npg = acpi_md_get_npages_of_wakecode(); - sz = ptoa(npg); -#ifdef DIAGNOSTIC - if (realmode_reserved_size < sz) { - panic("cannot steal memory for ACPI wake code."); - } -#endif - - /* identical mapping */ - p = paddr; - for (x=0; x<npg; x++) { - aprint_debug("kenter: 0x%08X\n", (unsigned)p); - pmap_kenter_pa((vaddr_t)p, p, VM_PROT_ALL); - p += PAGE_SIZE; - } - pmap_update(pmap_kernel()); - - acpi_md_install_wakecode(paddr); - - realmode_reserved_size -= sz; - realmode_reserved_start += sz; - } #endif pmap_kenter_pa(idt_vaddr, idt_paddr, VM_PROT_READ|VM_PROT_WRITE); @@ -2000,33 +1954,8 @@ init386(paddr_t first_avail) mutex_init(&idt_lock, MUTEX_DEFAULT, IPL_NONE); cpu_init_idt(); -#if NKSYMS || defined(DDB) || defined(LKM) - { - extern int end; - bool loaded; - struct btinfo_symtab *symtab; - -#ifdef DDB - db_machine_init(); -#endif + init386_ksyms(); -#if defined(MULTIBOOT) - loaded = multiboot_ksyms_init(); -#else - loaded = false; -#endif - if (!loaded) { - symtab = lookup_bootinfo(BTINFO_SYMTAB); - if (symtab) { - symtab->ssym += KERNBASE; - symtab->esym += KERNBASE; - ksyms_init(symtab->nsym, (int *)symtab->ssym, - (int *)symtab->esym); - } else - ksyms_init(*(int *)&end, ((int *)&end) + 1, esym); - } - } -#endif #ifdef DDB if (boothowto & RB_KDB) Debugger(); diff --git a/sys/arch/i386/i386/mainbus.c b/sys/arch/i386/i386/mainbus.c index bc0bd1a8218..2b7b88e13e7 100644 --- a/sys/arch/i386/i386/mainbus.c +++ b/sys/arch/i386/i386/mainbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.71 2007/03/05 16:51:02 drochner Exp $ */ +/* $NetBSD: mainbus.c,v 1.72 2007/12/09 20:27:47 jmcneill Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.71 2007/03/05 16:51:02 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.72 2007/12/09 20:27:47 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -373,6 +373,9 @@ mainbus_attach(struct device *parent, struct device *self, void *aux) if (apm_busprobe()) config_found_ia(self, "apmbus", 0, 0); #endif + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } int diff --git a/sys/arch/i386/include/acpi_func.h b/sys/arch/i386/include/acpi_func.h index 05c7b71942e..0896318425e 100644 --- a/sys/arch/i386/include/acpi_func.h +++ b/sys/arch/i386/include/acpi_func.h @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_func.h,v 1.6 2005/12/24 20:07:10 perry Exp $ */ +/* $NetBSD: acpi_func.h,v 1.7 2007/12/09 20:27:47 jmcneill Exp $ */ #include <machine/cpufunc.h> @@ -24,6 +24,7 @@ do { \ : "=&a" (Acq), "+m" (*GLptr) \ : "i" (~1L) \ : "edx"); \ + (Acq) = -1; \ } while (0) #define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ diff --git a/sys/arch/i386/isa/npx.c b/sys/arch/i386/isa/npx.c index 552b1acbd03..04487b299a3 100644 --- a/sys/arch/i386/isa/npx.c +++ b/sys/arch/i386/isa/npx.c @@ -1,4 +1,4 @@ -/* $NetBSD: npx.c,v 1.119 2007/11/14 17:51:36 ad Exp $ */ +/* $NetBSD: npx.c,v 1.120 2007/12/09 20:27:47 jmcneill Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.119 2007/11/14 17:51:36 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.120 2007/12/09 20:27:47 jmcneill Exp $"); #if 0 #define IPRINTF(x) printf x @@ -303,6 +303,9 @@ npxattach(struct npx_softc *sc) npxdna_func = npxdna_xmm; else npxdna_func = npxdna_s87; + + if (!pmf_device_register(&sc->sc_dev, NULL, NULL)) + aprint_error_dev(&sc->sc_dev, "couldn't establish power handler\n"); } /* diff --git a/sys/arch/i386/pci/piixpcib.c b/sys/arch/i386/pci/piixpcib.c index 7d66846aa5a..95e42c3286c 100644 --- a/sys/arch/i386/pci/piixpcib.c +++ b/sys/arch/i386/pci/piixpcib.c @@ -1,4 +1,4 @@ -/* $NetBSD: piixpcib.c,v 1.10 2006/11/16 01:32:39 christos Exp $ */ +/* $NetBSD: piixpcib.c,v 1.11 2007/12/09 20:27:48 jmcneill Exp $ */ /*- * Copyright (c) 2004, 2006 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: piixpcib.c,v 1.10 2006/11/16 01:32:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: piixpcib.c,v 1.11 2007/12/09 20:27:48 jmcneill Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -77,9 +77,6 @@ struct piixpcib_softc { bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; - void *sc_powerhook; - struct pci_conf_state sc_pciconf; - pcireg_t sc_pirqrc; uint8_t sc_elcr[2]; }; @@ -87,7 +84,8 @@ struct piixpcib_softc { static int piixpcibmatch(struct device *, struct cfdata *, void *); static void piixpcibattach(struct device *, struct device *, void *); -static void piixpcib_powerhook(int, void *); +static bool piixpcib_suspend(device_t); +static bool piixpcib_resume(device_t); static void speedstep_configure(struct piixpcib_softc *, struct pci_attach_args *); @@ -157,50 +155,40 @@ piixpcibattach(struct device *parent, struct device *self, void *aux) return; } - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - piixpcib_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: can't establish powerhook\n", - sc->sc_dev.dv_xname); + if (!pmf_device_register(self, piixpcib_suspend, piixpcib_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); return; } -static void -piixpcib_powerhook(int why, void *opaque) +static bool +piixpcib_suspend(device_t dv) { - struct piixpcib_softc *sc; - pci_chipset_tag_t pc; - pcitag_t tag; + struct piixpcib_softc *sc = device_private(dv); - sc = (struct piixpcib_softc *)opaque; - pc = sc->sc_pc; - tag = sc->sc_pcitag; + /* capture PIRQX route control registers */ + sc->sc_pirqrc = pci_conf_read(sc->sc_pc, sc->sc_pcitag, PIIX4_PIRQRC); - switch (why) { - case PWR_SUSPEND: - pci_conf_capture(pc, tag, &sc->sc_pciconf); + /* capture edge/level control registers */ + sc->sc_elcr[0] = bus_space_read_1(sc->sc_iot, sc->sc_ioh, 0); + sc->sc_elcr[1] = bus_space_read_1(sc->sc_iot, sc->sc_ioh, 1); - /* capture PIRQX route control registers */ - sc->sc_pirqrc = pci_conf_read(pc, tag, PIIX4_PIRQRC); + return true; +} - /* capture edge/level control registers */ - sc->sc_elcr[0] = bus_space_read_1(sc->sc_iot, sc->sc_ioh, 0); - sc->sc_elcr[1] = bus_space_read_1(sc->sc_iot, sc->sc_ioh, 1); - break; - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->sc_pciconf); +static bool +piixpcib_resume(device_t dv) +{ + struct piixpcib_softc *sc = device_private(dv); - /* restore PIRQX route control registers */ - pci_conf_write(pc, tag, PIIX4_PIRQRC, sc->sc_pirqrc); + /* restore PIRQX route control registers */ + pci_conf_write(sc->sc_pc, sc->sc_pcitag, PIIX4_PIRQRC, sc->sc_pirqrc); - /* restore edge/level control registers */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, 0, sc->sc_elcr[0]); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, 1, sc->sc_elcr[1]); - break; - } + /* restore edge/level control registers */ + bus_space_write_1(sc->sc_iot, sc->sc_ioh, 0, sc->sc_elcr[0]); + bus_space_write_1(sc->sc_iot, sc->sc_ioh, 1, sc->sc_elcr[1]); - return; + return true; } /* diff --git a/sys/arch/macppc/dev/if_wi_obio.c b/sys/arch/macppc/dev/if_wi_obio.c index 575e889b3f4..c9f5648740e 100644 --- a/sys/arch/macppc/dev/if_wi_obio.c +++ b/sys/arch/macppc/dev/if_wi_obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wi_obio.c,v 1.15 2007/10/22 19:29:13 macallan Exp $ */ +/* $NetBSD: if_wi_obio.c,v 1.16 2007/12/09 20:27:48 jmcneill Exp $ */ /*- * Copyright (c) 2001 Tsubai Masanari. All rights reserved. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wi_obio.c,v 1.15 2007/10/22 19:29:13 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wi_obio.c,v 1.16 2007/12/09 20:27:48 jmcneill Exp $"); #include "opt_inet.h" @@ -60,8 +60,7 @@ static void wi_obio_disable(struct wi_softc *); struct wi_obio_softc { struct wi_softc sc_wi; - void *sc_powerhook; - void *sc_sdhook; + pnp_state_t sc_state; bus_space_tag_t sc_tag; bus_space_handle_t sc_bsh; bus_space_handle_t sc_fcr2h; @@ -117,10 +116,10 @@ wi_obio_attach(struct device *parent, struct device *self, void *aux) return; } - sc->sc_sdhook = shutdownhook_establish( - (void (*)(void *))wi_shutdown, wisc); - sc->sc_powerhook = powerhook_establish( - self->dv_xname, (void (*)(int, void *))wi_power, wisc); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pnp_class_network_register(self, &sc->sc_wi.sc_if); /* Disable the card. */ wisc->sc_enabled = 0; diff --git a/sys/arch/x86/conf/files.x86 b/sys/arch/x86/conf/files.x86 index 588314b4387..f44e9659d0e 100644 --- a/sys/arch/x86/conf/files.x86 +++ b/sys/arch/x86/conf/files.x86 @@ -1,4 +1,4 @@ -# $NetBSD: files.x86,v 1.35 2007/12/03 15:34:27 ad Exp $ +# $NetBSD: files.x86,v 1.36 2007/12/09 20:27:48 jmcneill Exp $ # options for MP configuration through the MP spec defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI @@ -54,6 +54,7 @@ file arch/x86/x86/ipi.c multiprocessor file arch/x86/x86/msr_ipifuncs.c file arch/x86/x86/mtrr_i686.c mtrr file arch/x86/x86/patch.c +file arch/x86/x86/platform.c file arch/x86/x86/pmap.c file arch/x86/x86/sys_machdep.c file arch/x86/x86/x86_autoconf.c diff --git a/sys/arch/x86/include/acpi_machdep.h b/sys/arch/x86/include/acpi_machdep.h index 75fa46034da..10c1cffd6a6 100644 --- a/sys/arch/x86/include/acpi_machdep.h +++ b/sys/arch/x86/include/acpi_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.h,v 1.2 2005/05/02 14:55:12 kochi Exp $ */ +/* $NetBSD: acpi_machdep.h,v 1.3 2007/12/09 20:27:48 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -41,10 +41,12 @@ */ #include <machine/pio.h> +#include <machine/i82489var.h> +#include <machine/i82489reg.h> ACPI_STATUS acpi_md_OsInitialize(void); ACPI_STATUS acpi_md_OsTerminate(void); -ACPI_STATUS acpi_md_OsGetRootPointer(UINT32, ACPI_POINTER *); +ACPI_PHYSICAL_ADDRESS acpi_md_OsGetRootPointer(void); #define acpi_md_OsIn8(x) inb((x)) #define acpi_md_OsIn16(x) inw((x)) @@ -68,9 +70,4 @@ BOOLEAN acpi_md_OsWritable(void *, UINT32); void acpi_md_OsDisableInterrupt(void); int acpi_md_sleep(int); -void acpi_md_callback(struct device *); - -#ifdef ACPI_MACHDEP_PRIVATE -u_int32_t acpi_md_get_npages_of_wakecode(void); -void acpi_md_install_wakecode(paddr_t); -#endif +void acpi_md_callback(void); diff --git a/sys/arch/x86/include/i82093var.h b/sys/arch/x86/include/i82093var.h index bcf8e7c66d2..db4d28fddec 100644 --- a/sys/arch/x86/include/i82093var.h +++ b/sys/arch/x86/include/i82093var.h @@ -1,4 +1,4 @@ -/* $NetBSD: i82093var.h,v 1.3 2005/05/29 21:37:02 christos Exp $ */ +/* $NetBSD: i82093var.h,v 1.4 2007/12/09 20:27:48 jmcneill Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -94,6 +94,7 @@ struct ioapic_softc *ioapic_find(int); struct ioapic_softc *ioapic_find_bybase(int); void ioapic_enable(void); +void ioapic_reenable(void); void lapic_vectorset(void); /* XXX */ extern int ioapic_bsp_id; diff --git a/sys/arch/x86/include/i82489var.h b/sys/arch/x86/include/i82489var.h index d207ac0755d..c98af7ce9bc 100644 --- a/sys/arch/x86/include/i82489var.h +++ b/sys/arch/x86/include/i82489var.h @@ -1,4 +1,4 @@ -/* $NetBSD: i82489var.h,v 1.9 2007/12/03 23:29:26 joerg Exp $ */ +/* $NetBSD: i82489var.h,v 1.10 2007/12/09 20:27:48 jmcneill Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -122,6 +122,8 @@ struct cpu_info; extern void lapic_boot_init(paddr_t); extern void lapic_set_lvt(void); extern void lapic_enable(void); +extern void lapic_suspend(void); +extern void lapic_resume(void); extern void lapic_calibrate_timer(struct cpu_info *ci); extern void lapic_initclocks(void); diff --git a/sys/arch/x86/include/pmap.h b/sys/arch/x86/include/pmap.h index a2cb977879d..f5fa74cf720 100644 --- a/sys/arch/x86/include/pmap.h +++ b/sys/arch/x86/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.5 2007/11/22 16:17:12 bouyer Exp $ */ +/* $NetBSD: pmap.h,v 1.6 2007/12/09 20:27:48 jmcneill Exp $ */ /* * @@ -250,6 +250,7 @@ void pmap_remove(struct pmap *, vaddr_t, vaddr_t); bool pmap_test_attrs(struct vm_page *, unsigned); void pmap_write_protect(struct pmap *, vaddr_t, vaddr_t, vm_prot_t); void pmap_load(void); +paddr_t pmap_init_tmp_pgtbl(paddr_t); vaddr_t reserve_dumppages(vaddr_t); /* XXX: not a pmap fn */ diff --git a/sys/arch/x86/isa/clock.c b/sys/arch/x86/isa/clock.c index bba66729572..e5676e9172a 100644 --- a/sys/arch/x86/isa/clock.c +++ b/sys/arch/x86/isa/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.14 2007/12/04 16:05:34 ad Exp $ */ +/* $NetBSD: clock.c,v 1.15 2007/12/09 20:27:49 jmcneill Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -121,7 +121,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.14 2007/12/04 16:05:34 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.15 2007/12/09 20:27:49 jmcneill Exp $"); /* #define CLOCKDEBUG */ /* #define CLOCK_PARANOIA */ @@ -554,6 +554,9 @@ sysbeepattach(struct device *parent, struct device *self, ppicookie = ((struct pcppi_attach_args *)aux)->pa_cookie; ppi_attached = 1; + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } #endif diff --git a/sys/arch/x86/pci/files.pci b/sys/arch/x86/pci/files.pci index 2a5c1c55d76..274ed60f4db 100644 --- a/sys/arch/x86/pci/files.pci +++ b/sys/arch/x86/pci/files.pci @@ -1,4 +1,4 @@ -# $NetBSD: files.pci,v 1.3 2007/10/26 22:17:14 xtraeme Exp $ +# $NetBSD: files.pci,v 1.4 2007/12/09 20:27:49 jmcneill Exp $ device aapic attach aapic at pci @@ -32,7 +32,9 @@ attach hpet at amdpcib with amdpcib_hpet file arch/x86/pci/amdpcib_hpet.c amdpcib_hpet # PCI-LPC bridges -device ichlpcib: acpipmtimer, isabus, sysmon_wdog +define hpetichbus {} +device ichlpcib: acpipmtimer, isabus, sysmon_wdog, hpetichbus attach ichlpcib at pci +attach hpet at hpetichbus with ichlpcib_hpet file arch/x86/pci/ichlpcib.c ichlpcib diff --git a/sys/arch/x86/pci/ichlpcib.c b/sys/arch/x86/pci/ichlpcib.c index 10cbf2104b8..bb53f18cab9 100644 --- a/sys/arch/x86/pci/ichlpcib.c +++ b/sys/arch/x86/pci/ichlpcib.c @@ -1,4 +1,4 @@ -/* $NetBSD: ichlpcib.c,v 1.5 2007/11/23 11:21:14 xtraeme Exp $ */ +/* $NetBSD: ichlpcib.c,v 1.6 2007/12/09 20:27:49 jmcneill Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -46,13 +46,14 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.5 2007/11/23 11:21:14 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.6 2007/12/09 20:27:49 jmcneill Exp $"); #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> #include <sys/device.h> #include <sys/sysctl.h> +#include <sys/timetc.h> #include <machine/bus.h> #include <dev/pci/pcivar.h> @@ -61,8 +62,12 @@ __KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.5 2007/11/23 11:21:14 xtraeme Exp $") #include <dev/sysmon/sysmonvar.h> -#include <dev/ic/i82801lpcreg.h> #include <dev/ic/acpipmtimer.h> +#include <dev/ic/i82801lpcreg.h> +#include <dev/ic/hpetreg.h> +#include <dev/ic/hpetvar.h> + +#include "hpet.h" struct lpcib_softc { /* Device object. */ @@ -71,37 +76,54 @@ struct lpcib_softc { pci_chipset_tag_t sc_pc; pcitag_t sc_pcitag; + struct pci_attach_args sc_pa; + int sc_has_rcba; + int sc_has_ich5_hpet; + + /* RCBA */ + bus_space_tag_t sc_rcbat; + bus_space_handle_t sc_rcbah; + pcireg_t sc_rcba_reg; + /* Watchdog variables. */ struct sysmon_wdog sc_smw; bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; - + +#if NHPET > 0 + /* HPET variables. */ + uint32_t sc_hpet_reg; +#endif + /* Power management */ - void *sc_powerhook; - struct pci_conf_state sc_pciconf; pcireg_t sc_pirq[8]; + pcireg_t sc_pmcon; + pcireg_t sc_fwhsel2; }; static int lpcibmatch(struct device *, struct cfdata *, void *); static void lpcibattach(struct device *, struct device *, void *); -static void lpcib_powerhook(int, void *); +static bool lpcib_suspend(device_t); +static bool lpcib_resume(device_t); -static void pmtimer_configure(struct lpcib_softc *, struct pci_attach_args *); +static void pmtimer_configure(struct lpcib_softc *); -static void tcotimer_configure(struct lpcib_softc *, struct pci_attach_args *); +static void tcotimer_configure(struct lpcib_softc *); static int tcotimer_setmode(struct sysmon_wdog *); static int tcotimer_tickle(struct sysmon_wdog *); static void tcotimer_stop(struct lpcib_softc *); static void tcotimer_start(struct lpcib_softc *); static void tcotimer_status_reset(struct lpcib_softc *); -static int tcotimer_disable_noreboot(struct lpcib_softc *, bus_space_tag_t, - bus_space_handle_t); +static int tcotimer_disable_noreboot(struct lpcib_softc *); -static void speedstep_configure(struct lpcib_softc *, struct pci_attach_args *); +static void speedstep_configure(struct lpcib_softc *); static int speedstep_sysctl_helper(SYSCTLFN_ARGS); +#if NHPET > 0 +static void lpcib_hpet_configure(struct lpcib_softc *); +#endif + struct lpcib_softc *speedstep_cookie; /* XXX */ -static int lpcib_ich6 = 0; /* Defined in arch/.../pci/pcib.c. */ extern void pcibattach(struct device *, struct device *, void *); @@ -109,6 +131,36 @@ extern void pcibattach(struct device *, struct device *, void *); CFATTACH_DECL(ichlpcib, sizeof(struct lpcib_softc), lpcibmatch, lpcibattach, NULL, NULL); +static struct lpcib_device { + pcireg_t vendor, product; + int has_rcba; + int has_ich5_hpet; +} lpcib_devices[] = { + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AA_LPC, 0, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_LPC, 0, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BAM_LPC, 0, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_LPC, 0, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CAM_LPC, 0, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_LPC, 0, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_ISA, 0, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_LPC, 0, 1 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FBM_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GBM_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GHM_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HEM_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HH_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HO_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HBM_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IH_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IO_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IR_LPC, 1, 0 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IB_LPC, 1, 0 }, + { 0, 0, 0, 0 }, +}; + /* * Autoconf callbacks. */ @@ -116,40 +168,17 @@ static int lpcibmatch(struct device *parent, struct cfdata *match, void *aux) { struct pci_attach_args *pa = aux; + struct lpcib_device *lpcib_dev; /* We are ISA bridge, of course */ if (PCI_CLASS(pa->pa_class) != PCI_CLASS_BRIDGE || PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_ISA) return 0; - /* Matches only Intel ICH */ - if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL) { - switch (PCI_PRODUCT(pa->pa_id)) { - case PCI_PRODUCT_INTEL_82801AA_LPC: /* ICH */ - case PCI_PRODUCT_INTEL_82801AB_LPC: /* ICH0 */ - case PCI_PRODUCT_INTEL_82801BA_LPC: /* ICH2 */ - case PCI_PRODUCT_INTEL_82801BAM_LPC: /* ICH2-M */ - case PCI_PRODUCT_INTEL_82801CA_LPC: /* ICH3-S */ - case PCI_PRODUCT_INTEL_82801CAM_LPC: /* ICH3-M */ - case PCI_PRODUCT_INTEL_82801DB_LPC: /* ICH4 */ - case PCI_PRODUCT_INTEL_82801DB_ISA: /* ICH4-M */ - case PCI_PRODUCT_INTEL_82801EB_LPC: /* ICH5 */ + for (lpcib_dev = lpcib_devices; lpcib_dev->vendor; ++lpcib_dev) { + if (PCI_VENDOR(pa->pa_id) == lpcib_dev->vendor && + PCI_PRODUCT(pa->pa_id) == lpcib_dev->product) return 10; - case PCI_PRODUCT_INTEL_82801FB_LPC: /* ICH6 */ - case PCI_PRODUCT_INTEL_82801FBM_LPC: /* ICH6-M */ - case PCI_PRODUCT_INTEL_82801G_LPC: /* ICH7 */ - case PCI_PRODUCT_INTEL_82801GBM_LPC: /* ICH7-M */ - case PCI_PRODUCT_INTEL_82801GHM_LPC: /* ICH7-M DH */ - case PCI_PRODUCT_INTEL_82801H_LPC: /* ICH8 */ - case PCI_PRODUCT_INTEL_82801HH_LPC: /* ICH8 DH */ - case PCI_PRODUCT_INTEL_82801HO_LPC: /* ICH8 DO */ - case PCI_PRODUCT_INTEL_82801HBM_LPC: /* iCH8-M */ - case PCI_PRODUCT_INTEL_82801IH_LPC: /* ICH9 */ - case PCI_PRODUCT_INTEL_82801IR_LPC: /* ICH9-R */ - case PCI_PRODUCT_INTEL_82801IB_LPC: /* ICH9 ? */ - lpcib_ich6 = 1; - return 10; /* prior to pcib */ - } } return 0; @@ -159,10 +188,21 @@ static void lpcibattach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; - struct lpcib_softc *sc = (void*) self; + struct lpcib_softc *sc = device_private(self); + struct lpcib_device *lpcib_dev; sc->sc_pc = pa->pa_pc; sc->sc_pcitag = pa->pa_tag; + sc->sc_pa = *pa; + + for (lpcib_dev = lpcib_devices; lpcib_dev->vendor; ++lpcib_dev) { + if (PCI_VENDOR(pa->pa_id) != lpcib_dev->vendor || + PCI_PRODUCT(pa->pa_id) != lpcib_dev->product) + continue; + sc->sc_has_rcba = lpcib_dev->has_rcba; + sc->sc_has_ich5_hpet = lpcib_dev->has_ich5_hpet; + break; + } pcibattach(parent, self, aux); @@ -178,72 +218,122 @@ lpcibattach(struct device *parent, struct device *self, void *aux) return; } + /* For ICH6 and later, always enable RCBA */ + if (sc->sc_has_rcba) { + pcireg_t rcba; + + sc->sc_rcbat = sc->sc_pa.pa_memt; + + rcba = pci_conf_read(sc->sc_pc, sc->sc_pcitag, LPCIB_RCBA); + if ((rcba & LPCIB_RCBA_EN) == 0) { + aprint_error("%s: RCBA is not enabled", + sc->sc_dev.dv_xname); + return; + } + rcba &= ~LPCIB_RCBA_EN; + + if (bus_space_map(sc->sc_rcbat, rcba, LPCIB_RCBA_SIZE, 0, + &sc->sc_rcbah)) { + aprint_error("%s: RCBA could not be mapped", + sc->sc_dev.dv_xname); + return; + } + } + /* Set up the power management timer. */ - pmtimer_configure(sc, pa); + pmtimer_configure(sc); /* Set up the TCO (watchdog). */ - tcotimer_configure(sc, pa); + tcotimer_configure(sc); /* Set up SpeedStep. */ - speedstep_configure(sc, pa); - - /* Install powerhook */ - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - lpcib_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: can't establish powerhook\n", - sc->sc_dev.dv_xname); -} + speedstep_configure(sc); -static void -lpcib_powerhook(int why, void *opaque) -{ - struct lpcib_softc *sc; - pci_chipset_tag_t pc; - pcitag_t tag; - - sc = (struct lpcib_softc *)opaque; - pc = sc->sc_pc; - tag = sc->sc_pcitag; - - switch (why) { - case PWR_SUSPEND: - pci_conf_capture(pc, tag, &sc->sc_pciconf); - - /* capture PIRQ routing control registers */ - sc->sc_pirq[0] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQA_ROUT); - sc->sc_pirq[1] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQB_ROUT); - sc->sc_pirq[2] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQC_ROUT); - sc->sc_pirq[3] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQD_ROUT); - sc->sc_pirq[4] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQE_ROUT); - sc->sc_pirq[5] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQF_ROUT); - sc->sc_pirq[6] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQG_ROUT); - sc->sc_pirq[7] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQH_ROUT); +#if NHPET > 0 + /* Set up HPET. */ + lpcib_hpet_configure(sc); +#endif - break; + /* Install power handler */ + if (!pmf_device_register(self, lpcib_suspend, lpcib_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); +} - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->sc_pciconf); +static bool +lpcib_suspend(device_t dv) +{ + struct lpcib_softc *sc = device_private(dv); + pci_chipset_tag_t pc = sc->sc_pc; + pcitag_t tag = sc->sc_pcitag; + + /* capture PIRQ routing control registers */ + sc->sc_pirq[0] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQA_ROUT); + sc->sc_pirq[1] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQB_ROUT); + sc->sc_pirq[2] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQC_ROUT); + sc->sc_pirq[3] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQD_ROUT); + sc->sc_pirq[4] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQE_ROUT); + sc->sc_pirq[5] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQF_ROUT); + sc->sc_pirq[6] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQG_ROUT); + sc->sc_pirq[7] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQH_ROUT); + + sc->sc_pmcon = pci_conf_read(pc, tag, LPCIB_PCI_GEN_PMCON_1); + sc->sc_fwhsel2 = pci_conf_read(pc, tag, LPCIB_PCI_GEN_STA); + + if (sc->sc_has_rcba) { + sc->sc_rcba_reg = pci_conf_read(pc, tag, LPCIB_RCBA); +#if NHPET > 0 + sc->sc_hpet_reg = bus_space_read_4(sc->sc_rcbat, sc->sc_rcbah, + LPCIB_RCBA_HPTC); +#endif + } else if (sc->sc_has_ich5_hpet) { +#if NHPET > 0 + sc->sc_hpet_reg = pci_conf_read(pc, tag, LPCIB_PCI_GEN_CNTL); +#endif + } - /* restore PIRQ routing control registers */ - pci_conf_write(pc, tag, LPCIB_PCI_PIRQA_ROUT, sc->sc_pirq[0]); - pci_conf_write(pc, tag, LPCIB_PCI_PIRQB_ROUT, sc->sc_pirq[1]); - pci_conf_write(pc, tag, LPCIB_PCI_PIRQC_ROUT, sc->sc_pirq[2]); - pci_conf_write(pc, tag, LPCIB_PCI_PIRQD_ROUT, sc->sc_pirq[3]); - pci_conf_write(pc, tag, LPCIB_PCI_PIRQE_ROUT, sc->sc_pirq[4]); - pci_conf_write(pc, tag, LPCIB_PCI_PIRQF_ROUT, sc->sc_pirq[5]); - pci_conf_write(pc, tag, LPCIB_PCI_PIRQG_ROUT, sc->sc_pirq[6]); - pci_conf_write(pc, tag, LPCIB_PCI_PIRQH_ROUT, sc->sc_pirq[7]); + return true; +} - break; +static bool +lpcib_resume(device_t dv) +{ + struct lpcib_softc *sc = device_private(dv); + pci_chipset_tag_t pc = sc->sc_pc; + pcitag_t tag = sc->sc_pcitag; + + /* restore PIRQ routing control registers */ + pci_conf_write(pc, tag, LPCIB_PCI_PIRQA_ROUT, sc->sc_pirq[0]); + pci_conf_write(pc, tag, LPCIB_PCI_PIRQB_ROUT, sc->sc_pirq[1]); + pci_conf_write(pc, tag, LPCIB_PCI_PIRQC_ROUT, sc->sc_pirq[2]); + pci_conf_write(pc, tag, LPCIB_PCI_PIRQD_ROUT, sc->sc_pirq[3]); + pci_conf_write(pc, tag, LPCIB_PCI_PIRQE_ROUT, sc->sc_pirq[4]); + pci_conf_write(pc, tag, LPCIB_PCI_PIRQF_ROUT, sc->sc_pirq[5]); + pci_conf_write(pc, tag, LPCIB_PCI_PIRQG_ROUT, sc->sc_pirq[6]); + pci_conf_write(pc, tag, LPCIB_PCI_PIRQH_ROUT, sc->sc_pirq[7]); + + pci_conf_write(pc, tag, LPCIB_PCI_GEN_PMCON_1, sc->sc_pmcon); + pci_conf_write(pc, tag, LPCIB_PCI_GEN_STA, sc->sc_fwhsel2); + + if (sc->sc_has_rcba) { + pci_conf_write(pc, tag, LPCIB_RCBA, sc->sc_rcba_reg); +#if NHPET > 0 + bus_space_write_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_RCBA_HPTC, + sc->sc_hpet_reg); +#endif + } else if (sc->sc_has_ich5_hpet) { +#if NHPET > 0 + pci_conf_write(pc, tag, LPCIB_PCI_GEN_CNTL, sc->sc_hpet_reg); +#endif } + + return true; } /* * Initialize the power management timer. */ static void -pmtimer_configure(struct lpcib_softc *sc, struct pci_attach_args *pa) +pmtimer_configure(struct lpcib_softc *sc) { pcireg_t control; @@ -251,10 +341,10 @@ pmtimer_configure(struct lpcib_softc *sc, struct pci_attach_args *pa) * Check if power management I/O space is enabled and enable the ACPI_EN * bit if it's disabled. */ - control = pci_conf_read(pa->pa_pc, pa->pa_tag, LPCIB_PCI_ACPI_CNTL); + control = pci_conf_read(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_ACPI_CNTL); if ((control & LPCIB_PCI_ACPI_CNTL_EN) == 0) { control |= LPCIB_PCI_ACPI_CNTL_EN; - pci_conf_write(pa->pa_pc, pa->pa_tag, LPCIB_PCI_ACPI_CNTL, + pci_conf_write(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_ACPI_CNTL, control); } @@ -267,34 +357,16 @@ pmtimer_configure(struct lpcib_softc *sc, struct pci_attach_args *pa) * Initialize the watchdog timer. */ static void -tcotimer_configure(struct lpcib_softc *sc, struct pci_attach_args *pa) +tcotimer_configure(struct lpcib_softc *sc) { - bus_space_handle_t gcs_memh; - pcireg_t pcireg; uint32_t ioreg; unsigned int period; - /* - * Map the memory space necessary for GCS (General Control - * and Status Register). This is where the No Reboot (NR) bit - * lives on ICH6 and newer. - */ - if (lpcib_ich6) { - pcireg = pci_conf_read(pa->pa_pc, pa->pa_tag, LPCIB_RCBA); - pcireg &= 0xffffc000; - if (bus_space_map(pa->pa_memt, pcireg + LPCIB_GCS_OFFSET, - LPCIB_GCS_SIZE, 0, &gcs_memh)) { - aprint_error("%s: can't map GCS memory space; " - "TCO timer disabled\n", sc->sc_dev.dv_xname); - return; - } - } - /* * Clear the No Reboot (NR) bit. If this fails, enabling the TCO_EN bit * in the SMI_EN register is the last chance. */ - if (tcotimer_disable_noreboot(sc, pa->pa_memt, gcs_memh)) { + if (tcotimer_disable_noreboot(sc)) { ioreg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, LPCIB_SMI_EN); ioreg |= LPCIB_SMI_EN_TCO_EN; bus_space_write_4(sc->sc_iot, sc->sc_ioh, LPCIB_SMI_EN, ioreg); @@ -313,7 +385,7 @@ tcotimer_configure(struct lpcib_softc *sc, struct pci_attach_args *pa) sc->sc_smw.smw_cookie = sc; sc->sc_smw.smw_setmode = tcotimer_setmode; sc->sc_smw.smw_tickle = tcotimer_tickle; - if (lpcib_ich6) + if (sc->sc_has_rcba) period = LPCIB_TCOTIMER2_MAX_TICK; else period = LPCIB_TCOTIMER_MAX_TICK; @@ -345,17 +417,17 @@ tcotimer_setmode(struct sysmon_wdog *smw) tcotimer_stop(sc); } else { /* - * ICH5 or older are limited to 4s min and 39s max. * ICH6 or newer are limited to 2s min and 613s max. + * ICH5 or older are limited to 4s min and 39s max. */ - if (!lpcib_ich6) { - if (smw->smw_period < LPCIB_TCOTIMER_MIN_TICK || - smw->smw_period > LPCIB_TCOTIMER_MAX_TICK) - return EINVAL; - } else { + if (sc->sc_has_rcba) { if (smw->smw_period < LPCIB_TCOTIMER2_MIN_TICK || smw->smw_period > LPCIB_TCOTIMER2_MAX_TICK) return EINVAL; + } else { + if (smw->smw_period < LPCIB_TCOTIMER_MIN_TICK || + smw->smw_period > LPCIB_TCOTIMER_MAX_TICK) + return EINVAL; } period = lpcib_tcotimer_second_to_tick(smw->smw_period); @@ -363,7 +435,7 @@ tcotimer_setmode(struct sysmon_wdog *smw) tcotimer_stop(sc); /* set the timeout, */ - if (lpcib_ich6) { + if (sc->sc_has_rcba) { /* ICH6 or newer */ ich6period = bus_space_read_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO_TMR2); @@ -393,10 +465,10 @@ tcotimer_tickle(struct sysmon_wdog *smw) struct lpcib_softc *sc = smw->smw_cookie; /* any value is allowed */ - if (!lpcib_ich6) - bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_TCO_RLD, 1); - else + if (sc->sc_has_rcba) bus_space_write_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO_RLD, 1); + else + bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_TCO_RLD, 1); return 0; } @@ -437,13 +509,21 @@ tcotimer_status_reset(struct lpcib_softc *sc) * reaches the timeout for the second time. */ static int -tcotimer_disable_noreboot(struct lpcib_softc *sc, bus_space_tag_t gcs_memt, - bus_space_handle_t gcs_memh) +tcotimer_disable_noreboot(struct lpcib_softc *sc) { - pcireg_t pcireg; - uint16_t status = 0; - if (!lpcib_ich6) { + if (sc->sc_has_rcba) { + uint32_t status; + + status = bus_space_read_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_GCS_OFFSET); + status &= ~LPCIB_GCS_NO_REBOOT; + bus_space_write_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_GCS_OFFSET, status); + status = bus_space_read_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_GCS_OFFSET); + if (status & LPCIB_GCS_NO_REBOOT) + goto error; + } else { + pcireg_t pcireg; + pcireg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_GEN_STA); if (pcireg & LPCIB_PCI_GEN_STA_NO_REBOOT) { @@ -454,14 +534,6 @@ tcotimer_disable_noreboot(struct lpcib_softc *sc, bus_space_tag_t gcs_memt, if (pcireg & LPCIB_PCI_GEN_STA_NO_REBOOT) goto error; } - } else { - status = bus_space_read_4(gcs_memt, gcs_memh, 0); - status &= ~LPCIB_GCS_NO_REBOOT; - bus_space_write_4(gcs_memt, gcs_memh, 0, status); - status = bus_space_read_4(gcs_memt, gcs_memh, 0); - bus_space_unmap(gcs_memt, gcs_memh, LPCIB_GCS_SIZE); - if (status & LPCIB_GCS_NO_REBOOT) - goto error; } return 0; @@ -496,23 +568,23 @@ speedstep_bad_hb_check(struct pci_attach_args *pa) } static void -speedstep_configure(struct lpcib_softc *sc, struct pci_attach_args *pa) +speedstep_configure(struct lpcib_softc *sc) { const struct sysctlnode *node, *ssnode; int rv; /* Supported on ICH2-M, ICH3-M and ICH4-M. */ - if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82801DB_ISA || - PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82801CAM_LPC || - (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82801BAM_LPC && - pci_find_device(pa, speedstep_bad_hb_check) == 0)) { + if (PCI_PRODUCT(sc->sc_pa.pa_id) == PCI_PRODUCT_INTEL_82801DB_ISA || + PCI_PRODUCT(sc->sc_pa.pa_id) == PCI_PRODUCT_INTEL_82801CAM_LPC || + (PCI_PRODUCT(sc->sc_pa.pa_id) == PCI_PRODUCT_INTEL_82801BAM_LPC && + pci_find_device(&sc->sc_pa, speedstep_bad_hb_check) == 0)) { uint8_t pmcon; /* Enable SpeedStep if it isn't already enabled. */ - pmcon = pci_conf_read(pa->pa_pc, pa->pa_tag, + pmcon = pci_conf_read(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_GEN_PMCON_1); if ((pmcon & LPCIB_PCI_GEN_PMCON_1_SS_EN) == 0) - pci_conf_write(pa->pa_pc, pa->pa_tag, + pci_conf_write(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_GEN_PMCON_1, pmcon | LPCIB_PCI_GEN_PMCON_1_SS_EN); @@ -604,3 +676,112 @@ speedstep_sysctl_helper(SYSCTLFN_ARGS) out: return error; } + +#if NHPET > 0 +struct lpcib_hpet_attach_arg { + bus_space_tag_t hpet_mem_t; + uint32_t hpet_reg; +}; + +static int +lpcib_hpet_match(device_t parent, struct cfdata *match, void *aux) +{ + struct lpcib_hpet_attach_arg *arg = aux; + bus_space_tag_t tag; + bus_space_handle_t handle; + + tag = arg->hpet_mem_t; + + if (bus_space_map(tag, arg->hpet_reg, HPET_WINDOW_SIZE, 0, &handle)) { + aprint_verbose("%s: HPET window not mapped, skipping\n", + parent->dv_xname); + return 0; + } + bus_space_unmap(tag, handle, HPET_WINDOW_SIZE); + + return 1; +} + +static void +lpcib_hpet_attach(device_t parent, device_t self, void *aux) +{ + struct hpet_softc *sc = device_private(self); + struct lpcib_hpet_attach_arg *arg = aux; + + aprint_naive("\n"); + aprint_normal("\n"); + + sc->sc_memt = arg->hpet_mem_t; + + if (bus_space_map(sc->sc_memt, arg->hpet_reg, HPET_WINDOW_SIZE, 0, + &sc->sc_memh)) { + aprint_error("%s: HPET memory window could not be mapped", + sc->sc_dev.dv_xname); + return; + } + + hpet_attach_subr(sc); +} + +CFATTACH_DECL(ichlpcib_hpet, sizeof(struct hpet_softc), lpcib_hpet_match, + lpcib_hpet_attach, NULL, NULL); + +static void +lpcib_hpet_configure(struct lpcib_softc *sc) +{ + struct lpcib_hpet_attach_arg arg; + uint32_t hpet_reg, val; + + if (sc->sc_has_ich5_hpet) { + val = pci_conf_read(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_GEN_CNTL); + switch (val & LPCIB_ICH5_HPTC_WIN_MASK) { + case LPCIB_ICH5_HPTC_0000: + hpet_reg = LPCIB_ICH5_HPTC_0000_BASE; + break; + case LPCIB_ICH5_HPTC_1000: + hpet_reg = LPCIB_ICH5_HPTC_1000_BASE; + break; + case LPCIB_ICH5_HPTC_2000: + hpet_reg = LPCIB_ICH5_HPTC_2000_BASE; + break; + case LPCIB_ICH5_HPTC_3000: + hpet_reg = LPCIB_ICH5_HPTC_3000_BASE; + break; + default: + return; + } + val |= sc->sc_hpet_reg | LPCIB_ICH5_HPTC_EN; + pci_conf_write(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_GEN_CNTL, val); + } else if (sc->sc_has_rcba) { + val = bus_space_read_4(sc->sc_rcbat, sc->sc_rcbah, + LPCIB_RCBA_HPTC); + switch (val & LPCIB_RCBA_HPTC_WIN_MASK) { + case LPCIB_RCBA_HPTC_0000: + hpet_reg = LPCIB_RCBA_HPTC_0000_BASE; + break; + case LPCIB_RCBA_HPTC_1000: + hpet_reg = LPCIB_RCBA_HPTC_1000_BASE; + break; + case LPCIB_RCBA_HPTC_2000: + hpet_reg = LPCIB_RCBA_HPTC_2000_BASE; + break; + case LPCIB_RCBA_HPTC_3000: + hpet_reg = LPCIB_RCBA_HPTC_3000_BASE; + break; + default: + return; + } + val |= LPCIB_RCBA_HPTC_EN; + bus_space_write_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_RCBA_HPTC, + val); + } else { + /* No HPET here */ + return; + } + + arg.hpet_mem_t = sc->sc_pa.pa_memt; + arg.hpet_reg = hpet_reg; + + config_found_ia((struct device *)sc, "hpetichbus", &arg, NULL); +} +#endif diff --git a/sys/arch/x86/pci/pchb.c b/sys/arch/x86/pci/pchb.c index 4c406f6a0ca..d240af98ec6 100644 --- a/sys/arch/x86/pci/pchb.c +++ b/sys/arch/x86/pci/pchb.c @@ -1,4 +1,4 @@ -/* $NetBSD: pchb.c,v 1.4 2007/11/24 02:18:48 markd Exp $ */ +/* $NetBSD: pchb.c,v 1.5 2007/12/09 20:27:49 jmcneill Exp $ */ /*- * Copyright (c) 1996, 1998, 2000 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.4 2007/11/24 02:18:48 markd Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.5 2007/12/09 20:27:49 jmcneill Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -81,6 +81,9 @@ __KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.4 2007/11/24 02:18:48 markd Exp $"); int pchbmatch(struct device *, struct cfdata *, void *); void pchbattach(struct device *, struct device *, void *); +static bool pchb_resume(device_t); +static bool pchb_suspend(device_t); + CFATTACH_DECL(pchb, sizeof(struct pchb_softc), pchbmatch, pchbattach, NULL, NULL); @@ -351,6 +354,9 @@ pchbattach(struct device *parent, struct device *self, void *aux) pchb_attach_rnd(sc, pa); #endif + if (!pmf_device_register(self, pchb_suspend, pchb_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + /* * If we haven't detected AGP yet (via a product ID), * then check for AGP capability on the device. @@ -377,3 +383,37 @@ pchbattach(struct device *parent, struct device *self, void *aux) config_found_ia(self, "pcibus", &pba, pcibusprint); } } + +static bool +pchb_suspend(device_t dv) +{ + struct pchb_softc *sc = device_private(dv); + pci_chipset_tag_t pc; + pcitag_t tag; + int off; + + pc = sc->sc_pc; + tag = sc->sc_tag; + + for (off = 0x40; off <= 0xff; off += 4) + sc->sc_pciconfext[(off - 0x40) / 4] = pci_conf_read(pc, tag, off); + + return true; +} + +static bool +pchb_resume(device_t dv) +{ + struct pchb_softc *sc = device_private(dv); + pci_chipset_tag_t pc; + pcitag_t tag; + int off; + + pc = sc->sc_pc; + tag = sc->sc_tag; + + for (off = 0x40; off <= 0xff; off += 4) + pci_conf_write(pc, tag, off, sc->sc_pciconfext[(off - 0x40) / 4]); + + return true; +} diff --git a/sys/arch/x86/pci/pchbvar.h b/sys/arch/x86/pci/pchbvar.h index fc1f4e3db63..e62ef5e111a 100644 --- a/sys/arch/x86/pci/pchbvar.h +++ b/sys/arch/x86/pci/pchbvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: pchbvar.h,v 1.1 2006/02/12 18:16:01 tron Exp $ */ +/* $NetBSD: pchbvar.h,v 1.2 2007/12/09 20:27:49 jmcneill Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -45,6 +45,9 @@ struct pchb_softc { struct device sc_dev; + pci_chipset_tag_t sc_pc; + pcitag_t sc_tag; + bus_space_tag_t sc_st; bus_space_handle_t sc_sh; @@ -53,6 +56,8 @@ struct pchb_softc { int sc_rnd_i; uint32_t sc_rnd_ax; + + pcireg_t sc_pciconfext[48]; }; void pchb_attach_rnd(struct pchb_softc *, struct pci_attach_args *); diff --git a/sys/arch/x86/pci/pcib.c b/sys/arch/x86/pci/pcib.c index a6125c2aeab..9e6b552906d 100644 --- a/sys/arch/x86/pci/pcib.c +++ b/sys/arch/x86/pci/pcib.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcib.c,v 1.1 2007/10/26 22:17:14 xtraeme Exp $ */ +/* $NetBSD: pcib.c,v 1.2 2007/12/09 20:27:49 jmcneill Exp $ */ /*- * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.1 2007/10/26 22:17:14 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.2 2007/12/09 20:27:49 jmcneill Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -55,10 +55,15 @@ __KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.1 2007/10/26 22:17:14 xtraeme Exp $"); #include "isa.h" +struct pcib_softc { + pci_chipset_tag_t sc_pc; + pcitag_t sc_tag; +}; + int pcibmatch(struct device *, struct cfdata *, void *); void pcibattach(struct device *, struct device *, void *); -CFATTACH_DECL(pcib, sizeof(struct device), +CFATTACH_DECL_NEW(pcib, sizeof(struct pcib_softc), pcibmatch, pcibattach, NULL, NULL); void pcib_callback(struct device *); @@ -187,6 +192,7 @@ pcibmatch(struct device *parent, struct cfdata *match, void *aux) void pcibattach(struct device *parent, struct device *self, void *aux) { + struct pcib_softc *sc = device_private(self); struct pci_attach_args *pa = aux; char devinfo[256]; @@ -201,6 +207,17 @@ pcibattach(struct device *parent, struct device *self, void *aux) aprint_normal("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo, PCI_REVISION(pa->pa_class)); + sc->sc_pc = pa->pa_pc; + sc->sc_tag = pa->pa_tag; + + /* If a more specific pcib implementation has already registered a + * power handler, don't overwrite it. + */ + if (!device_pmf_is_registered(self)) { + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + } + config_defer(self, pcib_callback); } diff --git a/sys/arch/x86/x86/acpi_machdep.c b/sys/arch/x86/x86/acpi_machdep.c index b7dcd107c66..5d4e4ddb590 100644 --- a/sys/arch/x86/x86/acpi_machdep.c +++ b/sys/arch/x86/x86/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.17 2007/10/17 19:58:16 garbled Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.18 2007/12/09 20:27:49 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.17 2007/10/17 19:58:16 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.18 2007/12/09 20:27:49 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -73,19 +73,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.17 2007/10/17 19:58:16 garbled Ex #include "opt_mpbios.h" #include "opt_acpi.h" -static int acpi_intrcold = 1; - -struct acpi_intr_defer { - UINT32 number; - ACPI_OSD_HANDLER function; - void *context; - void *ih; - LIST_ENTRY(acpi_intr_defer) list; -}; - -static LIST_HEAD(, acpi_intr_defer) acpi_intr_deferq = - LIST_HEAD_INITIALIZER(acpi_intr_deferq); - ACPI_STATUS acpi_md_OsInitialize(void) { @@ -102,11 +89,17 @@ acpi_md_OsTerminate(void) return (AE_OK); } -ACPI_STATUS -acpi_md_OsGetRootPointer(UINT32 Flags, ACPI_POINTER *PhysicalAddress) +ACPI_PHYSICAL_ADDRESS +acpi_md_OsGetRootPointer(void) { + ACPI_PHYSICAL_ADDRESS PhysicalAddress; + ACPI_STATUS Status; + + Status = AcpiFindRootPointer(&PhysicalAddress); + if (ACPI_FAILURE(Status)) + PhysicalAddress = 0; - return (AcpiFindRootPointer(Flags, PhysicalAddress)); + return PhysicalAddress; } ACPI_STATUS @@ -116,24 +109,8 @@ acpi_md_OsInstallInterruptHandler(UINT32 InterruptNumber, void *ih; struct pic *pic; int irq, pin, trigger; - struct acpi_intr_defer *aip; - - if (acpi_intrcold) { - aip = malloc(sizeof(struct acpi_intr_defer), M_TEMP, M_WAITOK); - aip->number = InterruptNumber; - aip->function = ServiceRoutine; - aip->context = Context; - aip->ih = NULL; - LIST_INSERT_HEAD(&acpi_intr_deferq, aip, list); - - *cookiep = (void *)aip; - return AE_OK; - } - - trigger = IST_LEVEL; - -#if NACPI > 0 && NIOAPIC > 0 +#if NIOAPIC > 0 /* * Can only match on ACPI global interrupt numbers if the ACPI * interrupt info was extracted, which is in the ACPI case. @@ -153,13 +130,13 @@ acpi_md_OsInstallInterruptHandler(UINT32 InterruptNumber, } #endif - /* - * There was no ACPI interrupt source override, - * - * If the interrupt is handled via IOAPIC, mark it - * as level-triggered, active low in the table. - */ - + /* + * There was no ACPI interrupt source override, + * + * If the interrupt is handled via IOAPIC, mark it + * as level-triggered, active low in the table. + */ + #if NIOAPIC > 0 pic = (struct pic *)ioapic_find_bybase(InterruptNumber); if (pic != NULL) { @@ -186,14 +163,12 @@ acpi_md_OsInstallInterruptHandler(UINT32 InterruptNumber, irq = pin = (int)InterruptNumber; } -#if NACPI > 0 && NIOAPIC > 0 -#endif - trigger = IST_LEVEL; #if NIOAPIC > 0 sci_override: #endif + /* * XXX probably, IPL_BIO is enough. */ @@ -208,16 +183,6 @@ sci_override: void acpi_md_OsRemoveInterruptHandler(void *cookie) { - struct acpi_intr_defer *aip; - - LIST_FOREACH(aip, &acpi_intr_deferq, list) { - if (aip == cookie) { - if (aip->ih != NULL) - intr_disestablish(aip->ih); - return; - } - } - intr_disestablish(cookie); } @@ -310,21 +275,10 @@ acpi_md_OsDisableInterrupt(void) } void -acpi_md_callback(struct device *acpi) +acpi_md_callback(void) { - struct acpi_intr_defer *aip; - -#if NACPI > 0 #ifdef MPBIOS if (!mpbios_scanned) #endif - mpacpi_find_interrupts(acpi); -#endif - acpi_intrcold = 0; - - /* Proces deferred interrupt handler establish calls. */ - LIST_FOREACH(aip, &acpi_intr_deferq, list) { - acpi_md_OsInstallInterruptHandler(aip->number, aip->function, - aip->context, &aip->ih); - } + mpacpi_find_interrupts(acpi_softc); } diff --git a/sys/arch/x86/x86/cpu.c b/sys/arch/x86/x86/cpu.c index f66b3627c9f..9172117dc57 100644 --- a/sys/arch/x86/x86/cpu.c +++ b/sys/arch/x86/x86/cpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.11 2007/12/04 16:05:34 ad Exp $ */ +/* $NetBSD: cpu.c,v 1.12 2007/12/09 20:27:49 jmcneill Exp $ */ /*- * Copyright (c) 2000, 2006, 2007 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.11 2007/12/04 16:05:34 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.12 2007/12/09 20:27:49 jmcneill Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -123,6 +123,9 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.11 2007/12/04 16:05:34 ad Exp $"); int cpu_match(struct device *, struct cfdata *, void *); void cpu_attach(struct device *, struct device *, void *); +static bool cpu_suspend(device_t); +static bool cpu_resume(device_t); + struct cpu_softc { struct device sc_dev; /* device tree glue */ struct cpu_info *sc_info; /* pointer to CPU info */ @@ -157,17 +160,24 @@ struct cpu_info cpu_info_primary = { struct cpu_info *cpu_info_list = &cpu_info_primary; -static void cpu_set_tss_gates(struct cpu_info *ci); +static void cpu_set_tss_gates(struct cpu_info *); #ifdef i386 static void cpu_init_tss(struct i386tss *, void *, void *); #endif +#ifdef MULTIPROCESSOR +static void cpu_init_idle_lwp(struct cpu_info *); +#endif + uint32_t cpus_attached = 0; uint32_t cpus_running = 0; extern char x86_64_doubleflt_stack[]; +bool x86_mp_online; +paddr_t mp_trampoline_paddr = MP_TRAMPOLINE; + #ifdef MULTIPROCESSOR /* * Array of CPU info structures. Must be statically-allocated because @@ -389,6 +399,9 @@ cpu_attach(struct device *parent, struct device *self, void *aux) cpus_attached |= ci->ci_cpumask; + if (!pmf_device_register(self, cpu_suspend, cpu_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + #if defined(MULTIPROCESSOR) if (mp_verbose) { struct lwp *l = ci->ci_data.cpu_idlelwp; @@ -484,11 +497,9 @@ cpu_init(struct cpu_info *ci) #endif } -bool x86_mp_online; - #ifdef MULTIPROCESSOR void -cpu_boot_secondary_processors() +cpu_boot_secondary_processors(void) { struct cpu_info *ci; u_long i; @@ -522,7 +533,7 @@ cpu_init_idle_lwp(struct cpu_info *ci) } void -cpu_init_idle_lwps() +cpu_init_idle_lwps(void) { struct cpu_info *ci; u_long i; @@ -540,28 +551,12 @@ cpu_init_idle_lwps() } void -cpu_start_secondary(ci) - struct cpu_info *ci; +cpu_start_secondary(struct cpu_info *ci) { int i; - struct pmap *kpm = pmap_kernel(); extern paddr_t mp_pdirpa; -#ifdef __x86_64__ - /* - * The initial PML4 pointer must be below 4G, so if the - * current one isn't, use a "bounce buffer" - * - * XXX move elsewhere, not per CPU. - */ - if (kpm->pm_pdirpa > 0xffffffff) { - extern vaddr_t lo32_vaddr; - extern paddr_t lo32_paddr; - memcpy((void *)lo32_vaddr, kpm->pm_pdir, PAGE_SIZE); - mp_pdirpa = lo32_paddr; - } else -#endif - mp_pdirpa = kpm->pm_pdirpa; + mp_pdirpa = pmap_init_tmp_pgtbl(mp_trampoline_paddr); atomic_or_32(&ci->ci_flags, CPUF_AP); @@ -589,8 +584,7 @@ cpu_start_secondary(ci) } void -cpu_boot_secondary(ci) - struct cpu_info *ci; +cpu_boot_secondary(struct cpu_info *ci) { int i; @@ -620,7 +614,7 @@ cpu_hatch(void *v) int s, i; #ifdef __x86_64__ - cpu_init_msrs(ci); + cpu_init_msrs(ci, true); #endif cpu_probe_features(ci); cpu_feature &= ci->ci_feature_flags; @@ -640,6 +634,8 @@ cpu_hatch(void *v) KASSERT((ci->ci_flags & CPUF_RUNNING) == 0); + lcr3(pmap_kernel()->pm_pdirpa); + curlwp->l_addr->u_pcb.pcb_cr3 = pmap_kernel()->pm_pdirpa; lcr0(ci->ci_data.cpu_idlelwp->l_addr->u_pcb.pcb_cr0); cpu_init_idt(); gdt_init_cpu(ci); @@ -699,20 +695,29 @@ cpu_debug_dump(void) #endif static void -cpu_copy_trampoline() +cpu_copy_trampoline(void) { /* * Copy boot code. */ extern u_char cpu_spinup_trampoline[]; extern u_char cpu_spinup_trampoline_end[]; - pmap_kenter_pa((vaddr_t)MP_TRAMPOLINE, /* virtual */ - (paddr_t)MP_TRAMPOLINE, /* physical */ - VM_PROT_ALL); /* protection */ + + vaddr_t mp_trampoline_vaddr; + + mp_trampoline_vaddr = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, + UVM_KMF_VAONLY); + + pmap_kenter_pa(mp_trampoline_vaddr, mp_trampoline_paddr, + VM_PROT_READ | VM_PROT_WRITE); pmap_update(pmap_kernel()); - memcpy((void *)MP_TRAMPOLINE, + memcpy((void *)mp_trampoline_vaddr, cpu_spinup_trampoline, cpu_spinup_trampoline_end-cpu_spinup_trampoline); + + pmap_kremove(mp_trampoline_vaddr, PAGE_SIZE); + pmap_update(pmap_kernel()); + uvm_km_free(kernel_map, mp_trampoline_vaddr, PAGE_SIZE, UVM_KMF_VAONLY); } #endif @@ -796,6 +801,7 @@ mp_cpu_start(struct cpu_info *ci) int error; #endif unsigned short dwordptr[2]; + vaddr_t kva; /* * "The BSP must initialize CMOS shutdown code to 0Ah ..." @@ -810,13 +816,17 @@ mp_cpu_start(struct cpu_info *ci) */ dwordptr[0] = 0; - dwordptr[1] = MP_TRAMPOLINE >> 4; + dwordptr[1] = mp_trampoline_paddr >> 4; - pmap_kenter_pa(0, 0, VM_PROT_READ|VM_PROT_WRITE); + kva = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_VAONLY); + if ((void *)kva == NULL) + return ENOMEM; + pmap_kenter_pa(kva, 0, VM_PROT_READ|VM_PROT_WRITE); pmap_update(pmap_kernel()); - memcpy((uint8_t *)0x467, dwordptr, 4); - pmap_kremove(0, PAGE_SIZE); + memcpy((uint8_t *)(kva + 0x467), dwordptr, 4); + pmap_kremove(kva, PAGE_SIZE); pmap_update(pmap_kernel()); + uvm_km_free(kernel_map, kva, PAGE_SIZE, UVM_KMF_VAONLY); #if NLAPIC > 0 /* @@ -831,13 +841,13 @@ mp_cpu_start(struct cpu_info *ci) if (cpu_feature & CPUID_APIC) { - if ((error = x86_ipi(MP_TRAMPOLINE/PAGE_SIZE, + if ((error = x86_ipi(mp_trampoline_paddr / PAGE_SIZE, ci->ci_apicid, LAPIC_DLMODE_STARTUP)) != 0) return error; i8254_delay(200); - if ((error = x86_ipi(MP_TRAMPOLINE/PAGE_SIZE, + if ((error = x86_ipi(mp_trampoline_paddr / PAGE_SIZE, ci->ci_apicid, LAPIC_DLMODE_STARTUP)) != 0) return error; @@ -864,7 +874,7 @@ typedef void (vector)(void); extern vector Xsyscall, Xsyscall32; void -cpu_init_msrs(struct cpu_info *ci) +cpu_init_msrs(struct cpu_info *ci, bool full) { wrmsr(MSR_STAR, ((uint64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) | @@ -873,15 +883,85 @@ cpu_init_msrs(struct cpu_info *ci) wrmsr(MSR_CSTAR, (uint64_t)Xsyscall32); wrmsr(MSR_SFMASK, PSL_NT|PSL_T|PSL_I|PSL_C); - wrmsr(MSR_FSBASE, 0); - wrmsr(MSR_GSBASE, (u_int64_t)ci); - wrmsr(MSR_KERNELGSBASE, 0); + if (full) { + wrmsr(MSR_FSBASE, 0); + wrmsr(MSR_GSBASE, (u_int64_t)ci); + wrmsr(MSR_KERNELGSBASE, 0); + } if (cpu_feature & CPUID_NOX) wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_NXE); } #endif /* __x86_64__ */ +/* XXX joerg restructure and restart CPUs individually */ +static bool +cpu_suspend(device_t dv) +{ + struct cpu_softc *sc = device_private(dv); + struct cpu_info *ci = sc->sc_info; + int err; + + if (ci->ci_flags & CPUF_PRIMARY) { + x86_mp_online = false; + return true; + } + + if (ci->ci_data.cpu_idlelwp == NULL) + return true; + if ((ci->ci_flags & CPUF_PRESENT) == 0) + return true; + + ci->ci_flags &= ~CPUF_GO; + ci->ci_flags &= ~CPUF_RUNNING; + + mutex_enter(&cpu_lock); + err = cpu_setonline(ci, false); + mutex_exit(&cpu_lock); + if (err) + return false; + return true; +} + +static bool +cpu_resume(device_t dv) +{ + struct cpu_softc *sc = device_private(dv); + struct cpu_info *ci = sc->sc_info; + int err; + + if (ci->ci_flags & CPUF_PRIMARY) { +#ifdef MULTIPROCESSOR + struct cpu_info *sci; + CPU_INFO_ITERATOR cii; + int s; + + s = splhigh(); + for (CPU_INFO_FOREACH(cii, sci)) { + if (sci->ci_flags & CPUF_PRIMARY) + continue; + cpu_start_secondary(sci); + cpu_init_idle_lwp(sci); + } + splx(s); + cpu_boot_secondary_processors(); +#endif + return true; + } + + if (ci->ci_data.cpu_idlelwp == NULL) + return true; + if ((ci->ci_flags & CPUF_PRESENT) == 0) + return true; + + mutex_enter(&cpu_lock); + err = cpu_setonline(ci, true); + mutex_exit(&cpu_lock); + if (err) + return false; + return true; +} + void cpu_get_tsc_freq(struct cpu_info *ci) { diff --git a/sys/arch/x86/x86/est.c b/sys/arch/x86/x86/est.c index 1ecc027e09b..d22614f81f6 100644 --- a/sys/arch/x86/x86/est.c +++ b/sys/arch/x86/x86/est.c @@ -1,4 +1,4 @@ -/* $NetBSD: est.c,v 1.6 2007/12/07 20:33:27 xtraeme Exp $ */ +/* $NetBSD: est.c,v 1.7 2007/12/09 20:27:50 jmcneill Exp $ */ /* * Copyright (c) 2003 Michael Eriksson. * All rights reserved. @@ -85,8 +85,10 @@ * ACPI objects: _PCT is MSR location, _PSS is freq/voltage, _PPC is caps. */ +/* #define EST_DEBUG */ + #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.6 2007/12/07 20:33:27 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.7 2007/12/09 20:27:50 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> diff --git a/sys/arch/x86/x86/ioapic.c b/sys/arch/x86/x86/ioapic.c index ddfd10fcbb7..aaa77a77f28 100644 --- a/sys/arch/x86/x86/ioapic.c +++ b/sys/arch/x86/x86/ioapic.c @@ -1,4 +1,4 @@ -/* $NetBSD: ioapic.c,v 1.28 2007/12/02 06:51:52 jmcneill Exp $ */ +/* $NetBSD: ioapic.c,v 1.29 2007/12/09 20:27:50 jmcneill Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.28 2007/12/02 06:51:52 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.29 2007/12/09 20:27:50 jmcneill Exp $"); #include "opt_ddb.h" @@ -80,6 +80,7 @@ __KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.28 2007/12/02 06:51:52 jmcneill Exp $") #include <sys/systm.h> #include <sys/device.h> #include <sys/malloc.h> +#include <sys/kernel.h> #include <uvm/uvm_extern.h> @@ -389,6 +390,10 @@ ioapic_attach(struct device *parent, struct device *self, void *aux) sc->sc_pic.pic_apicid); } } + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + #if 0 /* output of this was boring. */ if (mp_verbose) @@ -471,6 +476,31 @@ ioapic_enable(void) } void +ioapic_reenable(void) +{ + int p; + struct ioapic_softc *sc; + + if (ioapics == NULL) + return; + + aprint_normal("%s reenabling\n", device_xname(&ioapics->sc_pic.pic_dev)); + + for (sc = ioapics; sc != NULL; sc = sc->sc_next) { + ioapic_write(sc,IOAPIC_ID, + (ioapic_read(sc,IOAPIC_ID)&~IOAPIC_ID_MASK) + |(sc->sc_pic.pic_apicid<<IOAPIC_ID_SHIFT)); + + for (p = 0; p < sc->sc_apic_sz; p++) { + apic_set_redir(sc, p, sc->sc_pins[p].ip_vector, + sc->sc_pins[p].ip_cpu); + } + } + + ioapic_enable(); +} + +void ioapic_hwmask(struct pic *pic, int pin) { u_int32_t redlo; diff --git a/sys/arch/x86/x86/lapic.c b/sys/arch/x86/x86/lapic.c index b3b7bcbfe81..81591dc2e3f 100644 --- a/sys/arch/x86/x86/lapic.c +++ b/sys/arch/x86/x86/lapic.c @@ -1,4 +1,4 @@ -/* $NetBSD: lapic.c,v 1.28 2007/12/03 22:17:28 joerg Exp $ */ +/* $NetBSD: lapic.c,v 1.29 2007/12/09 20:27:50 jmcneill Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.28 2007/12/03 22:17:28 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.29 2007/12/09 20:27:50 jmcneill Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -139,6 +139,11 @@ lapic_enable(void) } void +lapic_suspend(void) +{ +} + +void lapic_set_lvt(void) { struct cpu_info *ci = curcpu(); @@ -304,7 +309,7 @@ lapic_clockintr(void *arg, struct intrframe *frame) last_tsc[X86_MAXPROCS], last_tscdelta[X86_MAXPROCS], last_factor[X86_MAXPROCS]; -#endif /* TIMECOUNTER_DEBUG && __HAVE_TIMECOUNTER */ +#endif /* TIMECOUNTER_DEBUG */ struct cpu_info *ci = curcpu(); ci->ci_lapic_counter += lapic_tval; @@ -313,7 +318,6 @@ lapic_clockintr(void *arg, struct intrframe *frame) #if defined(TIMECOUNTER_DEBUG) { int cid = ci->ci_cpuid; - extern u_int i8254_get_timecount(struct timecounter *); u_int c_count = i8254_get_timecount(NULL); u_int c_tsc = cpu_counter32(); u_int delta, ddelta, tsc_delta, factor = 0; @@ -374,12 +378,8 @@ lapic_clockintr(void *arg, struct intrframe *frame) hardclock((struct clockframe *)frame); } -#if !defined(__HAVE_TIMECOUNTER) && defined(NTP) -extern int fixtick; -#endif /* !__HAVE_TIMECOUNTER && NTP */ - void -lapic_initclocks() +lapic_initclocks(void) { /* * Start local apic countdown timer running, in repeated mode. diff --git a/sys/arch/x86/x86/mpacpi.c b/sys/arch/x86/x86/mpacpi.c index c07402861f6..432ff9cdc84 100644 --- a/sys/arch/x86/x86/mpacpi.c +++ b/sys/arch/x86/x86/mpacpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: mpacpi.c,v 1.54 2007/12/01 05:12:29 jmcneill Exp $ */ +/* $NetBSD: mpacpi.c,v 1.55 2007/12/09 20:27:50 jmcneill Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.54 2007/12/01 05:12:29 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.55 2007/12/09 20:27:50 jmcneill Exp $"); #include "acpi.h" #include "opt_acpi.h" @@ -101,10 +101,10 @@ static int mpacpi_cpuprint(void *, const char *); static int mpacpi_ioapicprint(void *, const char *); /* acpi_madt_walk callbacks */ -static ACPI_STATUS mpacpi_count(APIC_HEADER *, void *); -static ACPI_STATUS mpacpi_config_cpu(APIC_HEADER *, void *); -static ACPI_STATUS mpacpi_config_ioapic(APIC_HEADER *, void *); -static ACPI_STATUS mpacpi_nonpci_intr(APIC_HEADER *, void *); +static ACPI_STATUS mpacpi_count(ACPI_SUBTABLE_HEADER *, void *); +static ACPI_STATUS mpacpi_config_cpu(ACPI_SUBTABLE_HEADER *, void *); +static ACPI_STATUS mpacpi_config_ioapic(ACPI_SUBTABLE_HEADER *, void *); +static ACPI_STATUS mpacpi_nonpci_intr(ACPI_SUBTABLE_HEADER *, void *); #if NPCI > 0 /* Callbacks for the ACPI namespace walk */ @@ -170,20 +170,20 @@ mpacpi_ioapicprint(void *aux, const char *pnp) * This is a callback function for acpi_madt_walk(). */ static ACPI_STATUS -mpacpi_nonpci_intr(APIC_HEADER *hdrp, void *aux) +mpacpi_nonpci_intr(ACPI_SUBTABLE_HEADER *hdrp, void *aux) { int *index = aux, pin, lindex; struct mp_intr_map *mpi; - MADT_NMI_SOURCE *ioapic_nmi; - MADT_LOCAL_APIC_NMI *lapic_nmi; - MADT_INTERRUPT_OVERRIDE *isa_ovr; + ACPI_MADT_NMI_SOURCE *ioapic_nmi; + ACPI_MADT_LOCAL_APIC_NMI *lapic_nmi; + ACPI_MADT_INTERRUPT_OVERRIDE *isa_ovr; struct pic *pic; extern struct acpi_softc *acpi_softc; /* XXX */ switch (hdrp->Type) { - case APIC_NMI: - ioapic_nmi = (MADT_NMI_SOURCE *)hdrp; - pic = intr_findpic(ioapic_nmi->Interrupt); + case ACPI_MADT_TYPE_NMI_SOURCE: + ioapic_nmi = (ACPI_MADT_NMI_SOURCE *)hdrp; + pic = intr_findpic(ioapic_nmi->GlobalIrq); if (pic == NULL) break; #if NIOAPIC == 0 @@ -196,7 +196,7 @@ mpacpi_nonpci_intr(APIC_HEADER *hdrp, void *aux) mpi->bus = NULL; mpi->type = MPS_INTTYPE_NMI; mpi->ioapic = pic; - pin = ioapic_nmi->Interrupt - pic->pic_vecbase; + pin = ioapic_nmi->GlobalIrq - pic->pic_vecbase; mpi->ioapic_pin = pin; mpi->bus_pin = -1; mpi->redir = (IOAPIC_REDLO_DEL_NMI<<IOAPIC_REDLO_DEL_SHIFT); @@ -209,12 +209,11 @@ mpacpi_nonpci_intr(APIC_HEADER *hdrp, void *aux) } else #endif mpi->ioapic_ih = pin; - mpi->flags = ioapic_nmi->Polarity | - (ioapic_nmi->TriggerMode << 2); - mpi->global_int = ioapic_nmi->Interrupt; + mpi->flags = ioapic_nmi->IntiFlags; + mpi->global_int = ioapic_nmi->GlobalIrq; break; - case APIC_LOCAL_NMI: - lapic_nmi = (MADT_LOCAL_APIC_NMI *)hdrp; + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: + lapic_nmi = (ACPI_MADT_LOCAL_APIC_NMI *)hdrp; mpi = &mp_intrs[*index]; (*index)++; mpi->next = NULL; @@ -226,27 +225,27 @@ mpacpi_nonpci_intr(APIC_HEADER *hdrp, void *aux) mpi->redir = (IOAPIC_REDLO_DEL_NMI<<IOAPIC_REDLO_DEL_SHIFT); mpi->global_int = -1; break; - case APIC_XRUPT_OVERRIDE: - isa_ovr = (MADT_INTERRUPT_OVERRIDE *)hdrp; + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: + isa_ovr = (ACPI_MADT_INTERRUPT_OVERRIDE *)hdrp; if (mp_verbose) { printf("mpacpi: ISA interrupt override %d -> %d (%d/%d)\n", - isa_ovr->Source, isa_ovr->Interrupt, - isa_ovr->Polarity, - isa_ovr->TriggerMode); + isa_ovr->SourceIrq, isa_ovr->GlobalIrq, + isa_ovr->IntiFlags & ACPI_MADT_POLARITY_MASK, + (isa_ovr->IntiFlags & ACPI_MADT_TRIGGER_MASK) >> 2); } - if (isa_ovr->Source > 15 || isa_ovr->Source == 2 || - (isa_ovr->Source == 0 && isa_ovr->Interrupt == 2 && + if (isa_ovr->SourceIrq > 15 || isa_ovr->SourceIrq == 2 || + (isa_ovr->SourceIrq == 0 && isa_ovr->GlobalIrq == 2 && (acpi_softc->sc_quirks & ACPI_QUIRK_IRQ0))) break; - pic = intr_findpic(isa_ovr->Interrupt); + pic = intr_findpic(isa_ovr->GlobalIrq); if (pic == NULL) break; #if NIOAPIC == 0 if (pic->pic_type == PIC_IOAPIC) break; #endif - pin = isa_ovr->Interrupt - pic->pic_vecbase; - lindex = isa_ovr->Source; + pin = isa_ovr->GlobalIrq - pic->pic_vecbase; + lindex = isa_ovr->SourceIrq; /* * IRQ 2 was skipped in the default setup. */ @@ -261,39 +260,50 @@ mpacpi_nonpci_intr(APIC_HEADER *hdrp, void *aux) } else #endif mpi->ioapic_ih = pin; - mpi->bus_pin = isa_ovr->Source; + mpi->bus_pin = isa_ovr->SourceIrq; mpi->ioapic = (struct pic *)pic; mpi->ioapic_pin = pin; mpi->sflags |= MPI_OVR; mpi->redir = 0; - mpi->global_int = isa_ovr->Interrupt; - switch (isa_ovr->Polarity) { - case MPS_INTPO_ACTHI: + mpi->global_int = isa_ovr->GlobalIrq; + switch (isa_ovr->IntiFlags & ACPI_MADT_POLARITY_MASK) { + case ACPI_MADT_POLARITY_ACTIVE_HIGH: mpi->redir &= ~IOAPIC_REDLO_ACTLO; break; - case MPS_INTPO_DEF: - case MPS_INTPO_ACTLO: + case ACPI_MADT_POLARITY_ACTIVE_LOW: mpi->redir |= IOAPIC_REDLO_ACTLO; break; + case ACPI_MADT_POLARITY_CONFORMS: + if (isa_ovr->SourceIrq == AcpiGbl_FADT.SciInterrupt) + mpi->redir |= IOAPIC_REDLO_ACTLO; + else + mpi->redir &= ~IOAPIC_REDLO_ACTLO; + break; } mpi->redir |= (IOAPIC_REDLO_DEL_FIXED<<IOAPIC_REDLO_DEL_SHIFT); - switch (isa_ovr->TriggerMode) { - case MPS_INTTR_DEF: - case MPS_INTTR_LEVEL: + switch (isa_ovr->IntiFlags & ACPI_MADT_TRIGGER_MASK) { + case ACPI_MADT_TRIGGER_LEVEL: mpi->redir |= IOAPIC_REDLO_LEVEL; break; - case MPS_INTTR_EDGE: + case ACPI_MADT_TRIGGER_EDGE: mpi->redir &= ~IOAPIC_REDLO_LEVEL; break; + case ACPI_MADT_TRIGGER_CONFORMS: + if (isa_ovr->SourceIrq == AcpiGbl_FADT.SciInterrupt) + mpi->redir |= IOAPIC_REDLO_LEVEL; + else + mpi->redir &= ~IOAPIC_REDLO_LEVEL; + break; } - mpi->flags = isa_ovr->Polarity | (isa_ovr->TriggerMode << 2); + mpi->flags = isa_ovr->IntiFlags; #if NIOAPIC > 0 if (pic->pic_type == PIC_IOAPIC) ((struct ioapic_softc *)pic)->sc_pins[pin].ip_map = mpi; #endif - if (isa_ovr->Source == AcpiGbl_FADT->SciInt) + if (isa_ovr->SourceIrq == AcpiGbl_FADT.SciInterrupt) mpacpi_sci_override = mpi; - + + break; default: break; } @@ -305,23 +315,23 @@ mpacpi_nonpci_intr(APIC_HEADER *hdrp, void *aux) * This is a callback function for acpi_madt_walk(). */ static ACPI_STATUS -mpacpi_count(APIC_HEADER *hdrp, void *aux) +mpacpi_count(ACPI_SUBTABLE_HEADER *hdrp, void *aux) { - MADT_ADDRESS_OVERRIDE *lop; + ACPI_MADT_LOCAL_APIC_OVERRIDE *lop; switch (hdrp->Type) { - case APIC_PROCESSOR: + case ACPI_MADT_TYPE_LOCAL_APIC: mpacpi_ncpu++; break; - case APIC_IO: + case ACPI_MADT_TYPE_IO_APIC: mpacpi_nioapic++; break; - case APIC_NMI: - case APIC_LOCAL_NMI: + case ACPI_MADT_TYPE_NMI_SOURCE: + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: mpacpi_nintsrc++; break; - case APIC_ADDRESS_OVERRIDE: - lop = (MADT_ADDRESS_OVERRIDE *)hdrp; + case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: + lop = (ACPI_MADT_LOCAL_APIC_OVERRIDE *)hdrp; mpacpi_lapic_base = lop->Address;; default: break; @@ -330,10 +340,10 @@ mpacpi_count(APIC_HEADER *hdrp, void *aux) } static ACPI_STATUS -mpacpi_config_cpu(APIC_HEADER *hdrp, void *aux) +mpacpi_config_cpu(ACPI_SUBTABLE_HEADER *hdrp, void *aux) { struct device *parent = aux; - MADT_PROCESSOR_APIC *p; + ACPI_MADT_LOCAL_APIC *p; struct cpu_attach_args caa; int cpunum = 0; int locs[CPUBUSCF_NLOCS]; @@ -343,14 +353,14 @@ mpacpi_config_cpu(APIC_HEADER *hdrp, void *aux) cpunum = lapic_cpu_number(); #endif - if (hdrp->Type == APIC_PROCESSOR) { - p = (MADT_PROCESSOR_APIC *)hdrp; - if (p->ProcessorEnabled) { - if (p->LocalApicId != cpunum) + if (hdrp->Type == ACPI_MADT_TYPE_LOCAL_APIC) { + p = (ACPI_MADT_LOCAL_APIC *)hdrp; + if (p->LapicFlags & ACPI_MADT_ENABLED) { + if (p->Id != cpunum) caa.cpu_role = CPU_ROLE_AP; else caa.cpu_role = CPU_ROLE_BP; - caa.cpu_number = p->LocalApicId; + caa.cpu_number = p->Id; caa.cpu_func = &mp_cpu_funcs; locs[CPUBUSCF_APID] = caa.cpu_number; config_found_sm_loc(parent, "cpubus", locs, @@ -361,20 +371,20 @@ mpacpi_config_cpu(APIC_HEADER *hdrp, void *aux) } static ACPI_STATUS -mpacpi_config_ioapic(APIC_HEADER *hdrp, void *aux) +mpacpi_config_ioapic(ACPI_SUBTABLE_HEADER *hdrp, void *aux) { struct device *parent = aux; struct apic_attach_args aaa; - MADT_IO_APIC *p; + ACPI_MADT_IO_APIC *p; int locs[IOAPICBUSCF_NLOCS]; - if (hdrp->Type == APIC_IO) { - p = (MADT_IO_APIC *)hdrp; - aaa.apic_id = p->IoApicId; + if (hdrp->Type == ACPI_MADT_TYPE_IO_APIC) { + p = (ACPI_MADT_IO_APIC *)hdrp; + aaa.apic_id = p->Id; aaa.apic_address = p->Address; aaa.apic_version = -1; aaa.flags = IOAPIC_VWIRE; - aaa.apic_vecbase = p->Interrupt; + aaa.apic_vecbase = p->GlobalIrqBase; locs[IOAPICBUSCF_APID] = aaa.apic_id; config_found_sm_loc(parent, "ioapicbus", locs, &aaa, mpacpi_ioapicprint, config_stdsubmatch); diff --git a/sys/arch/x86/x86/platform.c b/sys/arch/x86/x86/platform.c new file mode 100644 index 00000000000..9e13522b80d --- /dev/null +++ b/sys/arch/x86/x86/platform.c @@ -0,0 +1,103 @@ +/* $NetBSD: platform.c,v 1.2 2007/12/09 20:27:50 jmcneill Exp $ */ + +/*- + * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jared D. McNeill. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: platform.c,v 1.2 2007/12/09 20:27:50 jmcneill Exp $"); + +#include <sys/types.h> +#include <sys/param.h> +#include <sys/malloc.h> +#include <sys/kernel.h> +#include <sys/pmf.h> + +#include <arch/x86/include/smbiosvar.h> + +void platform_init(void); /* XXX */ +static void platform_add(struct smbtable *, const char *, int); +static void platform_print(void); + +void +platform_init(void) +{ + struct smbtable smbios; + struct smbios_sys *psys; + + smbios.cookie = 0; + + if (smbios_find_table(SMBIOS_TYPE_SYSTEM, &smbios)) { + psys = smbios.tblhdr; + + platform_add(&smbios, "system-manufacturer", psys->vendor); + platform_add(&smbios, "system-product-name", psys->product); + platform_add(&smbios, "system-version", psys->version); + platform_add(&smbios, "system-serial-number", psys->serial); + } + + platform_print(); +} + +static void +platform_print(void) +{ + const char *manuf, *prod, *ver; + + manuf = pmf_get_platform("system-manufacturer"); + prod = pmf_get_platform("system-product-name"); + ver = pmf_get_platform("system-version"); + + if (manuf == NULL) + aprint_normal("Generic"); + else + aprint_normal("%s", manuf); + if (prod == NULL) + aprint_normal(" PC"); + else + aprint_normal(" %s", prod); + if (ver != NULL) + aprint_normal(" (%s)", ver); + aprint_normal("\n"); + + return; +} + +static void +platform_add(struct smbtable *tbl, const char *key, int idx) +{ + char tmpbuf[128]; /* XXX is this long enough? */ + + if (smbios_get_string(tbl, idx, tmpbuf, 128) != NULL) + pmf_set_platform(key, tmpbuf); + + return; +} diff --git a/sys/arch/x86/x86/pmap.c b/sys/arch/x86/x86/pmap.c index bf0677b159e..e9ae9f2cdf0 100644 --- a/sys/arch/x86/x86/pmap.c +++ b/sys/arch/x86/x86/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.12 2007/12/09 15:31:03 ad Exp $ */ +/* $NetBSD: pmap.c,v 1.13 2007/12/09 20:27:51 jmcneill Exp $ */ /* * Copyright (c) 2007 Manuel Bouyer. @@ -154,7 +154,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.12 2007/12/09 15:31:03 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.13 2007/12/09 20:27:51 jmcneill Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -4195,3 +4195,67 @@ pmap_update(struct pmap *pm) pmap_tlb_shootwait(); crit_exit(); } + +#if PTP_LEVELS > 4 +#error "Unsupported number of page table mappings" +#endif + +paddr_t +pmap_init_tmp_pgtbl(paddr_t pg) +{ + static bool maps_loaded; + static const paddr_t x86_tmp_pml_paddr[] = { + 4 * PAGE_SIZE, + 5 * PAGE_SIZE, + 6 * PAGE_SIZE, + 7 * PAGE_SIZE + }; + static vaddr_t x86_tmp_pml_vaddr[] = { 0, 0, 0, 0 }; + + pd_entry_t *tmp_pml, *kernel_pml; + + int level; + + if (!maps_loaded) { + for (level = 0; level < PTP_LEVELS; ++level) { + x86_tmp_pml_vaddr[level] = + uvm_km_alloc(kernel_map, PAGE_SIZE, 0, + UVM_KMF_VAONLY); + + if (x86_tmp_pml_vaddr[level] == 0) + panic("mapping of real mode PML failed\n"); + pmap_kenter_pa(x86_tmp_pml_vaddr[level], + x86_tmp_pml_paddr[level], + VM_PROT_READ | VM_PROT_WRITE); + pmap_update(pmap_kernel()); + } + maps_loaded = true; + } + + /* Zero levels 1-3 */ + for (level = 0; level < PTP_LEVELS - 1; ++level) { + tmp_pml = (void *)x86_tmp_pml_vaddr[level]; + memset(tmp_pml, 0, PAGE_SIZE); + } + + /* Copy PML4 */ + kernel_pml = pmap_kernel()->pm_pdir; + tmp_pml = (void *)x86_tmp_pml_vaddr[PTP_LEVELS - 1]; + memcpy(tmp_pml, kernel_pml, PAGE_SIZE); + + /* Hook our own level 3 in */ + tmp_pml[pl_i(pg, PTP_LEVELS)] = + (x86_tmp_pml_paddr[PTP_LEVELS - 2] & PG_FRAME) | PG_RW | PG_V; + + for (level = PTP_LEVELS - 1; level > 0; --level) { + tmp_pml = (void *)x86_tmp_pml_vaddr[level]; + + tmp_pml[pl_i(pg, level + 1)] = + (x86_tmp_pml_paddr[level - 1] & PG_FRAME) | PG_RW | PG_V; + } + + tmp_pml = (void *)x86_tmp_pml_vaddr[0]; + tmp_pml[pl_i(pg, 1)] = (pg & PG_FRAME) | PG_RW | PG_V; + + return x86_tmp_pml_paddr[PTP_LEVELS - 1]; +} diff --git a/sys/conf/files b/sys/conf/files index 516ebaf161a..2c5c6c89830 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.875 2007/11/20 18:54:31 pooka Exp $ +# $NetBSD: files,v 1.876 2007/12/09 20:27:51 jmcneill Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -11,6 +11,9 @@ devclass disk devclass tape devclass ifnet devclass tty +devclass audiodev +devclass displaydev +devclass bus # options understood by the machine-independent part of the kernel # (note, these are case-sensitive) @@ -273,7 +276,7 @@ define aurateconv # audio and midi devices, attaches to audio hardware driver # -device audio +device audio: audiodev attach audio at audiobus device midi attach midi at midibus @@ -1017,7 +1020,7 @@ defparam opt_vga.h VGA_CONSOLE_SCREENTYPE defflag opt_vga.h VGA_CONSOLE_ATI_BROKEN_FONTSEL defflag opt_vga.h VGA_RASTERCONSOLE defflag opt_vga.h VGA_RESET -device vga: wsemuldisplaydev, pcdisplayops, drm +device vga: displaydev, wsemuldisplaydev, pcdisplayops, drm file dev/ic/vga.c vga & !vga_rasterconsole needs-flag file dev/ic/vga_raster.c vga_rasterconsole needs-flag file dev/ic/vga_subr.c vga | vga_rasterconsole @@ -1350,6 +1353,7 @@ file kern/kern_fileassoc.c fileassoc file kern/kern_ntptime.c file kern/kern_pax.c pax_mprotect | pax_segvguard file kern/kern_physio.c +file kern/kern_pmf.c file kern/kern_proc.c file kern/kern_prot.c file kern/kern_ras.c diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index bed7d0a6fb4..f94dc796ada 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi.c,v 1.103 2007/12/05 07:06:50 ad Exp $ */ +/* $NetBSD: acpi.c,v 1.104 2007/12/09 20:27:52 jmcneill Exp $ */ /*- * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.103 2007/12/05 07:06:50 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.104 2007/12/09 20:27:52 jmcneill Exp $"); #include "opt_acpi.h" #include "opt_pcifixup.h" @@ -122,6 +122,8 @@ MALLOC_DECLARE(M_ACPI); static int acpi_dbgr = 0x00; #endif +static ACPI_TABLE_DESC acpi_initial_tables[128]; + static int acpi_match(struct device *, struct cfdata *, void *); static void acpi_attach(struct device *, struct device *, void *); @@ -203,6 +205,9 @@ acpi_probe(void) acpi_osd_debugger(); #endif + AcpiGbl_AllMethodsSerialized = FALSE; + AcpiGbl_EnableInterpreterSlack = TRUE; + rv = AcpiInitializeSubsystem(); if (ACPI_FAILURE(rv)) { printf("ACPI: unable to initialize ACPICA: %s\n", @@ -210,6 +215,20 @@ acpi_probe(void) return 0; } + rv = AcpiInitializeTables(acpi_initial_tables, 128, 0); + if (ACPI_FAILURE(rv)) { + printf("ACPI: unable to initialize ACPI tables: %s\n", + AcpiFormatException(rv)); + return 0; + } + + rv = AcpiReallocateRootTable(); + if (ACPI_FAILURE(rv)) { + printf("ACPI: unable to reallocate root table: %s\n", + AcpiFormatException(rv)); + return 0; + } + #ifdef ACPI_DEBUGGER if (acpi_dbgr & ACPI_DBGR_TABLES) acpi_osd_debugger(); @@ -222,7 +241,7 @@ acpi_probe(void) return 0; } - +#if notyet if (!acpi_force_load && (acpi_find_quirks() & ACPI_QUIRK_BROKEN)) { printf("ACPI: BIOS implementation in listed as broken:\n"); printf("ACPI: X/RSDT: OemId <%6.6s,%8.8s,%08x>, " @@ -235,6 +254,36 @@ acpi_probe(void) return 0; } + /* Install the default address space handlers. */ + rv = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, + ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE(rv)) { + printf("ACPI: unable to initialise SystemMemory handler: %s\n", + AcpiFormatException(rv)); + return 0; + } + rv = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, + ACPI_ADR_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE(rv)) { + printf("ACPI: unable to initialise SystemIO handler: %s\n", + AcpiFormatException(rv)); + return 0; + } + rv = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, + ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE(rv)) { + printf("ACPI: unabled to initialise PciConfig handler: %s\n", + AcpiFormatException(rv)); + return 0; + } +#endif + + rv = AcpiEnableSubsystem(~(ACPI_NO_HARDWARE_INIT|ACPI_NO_ACPI_ENABLE)); + if (ACPI_FAILURE(rv)) { + printf("ACPI: unable to enable: %s\n", AcpiFormatException(rv)); + return 0; + } + /* * Looks like we have ACPI! */ @@ -257,10 +306,10 @@ acpi_check(device_t parent, const char *ifattr) return (config_search_ia(acpi_submatch, parent, ifattr, NULL) != NULL); } -ACPI_STATUS -acpi_OsGetRootPointer(UINT32 Flags, ACPI_POINTER *PhysicalAddress) +ACPI_PHYSICAL_ADDRESS +acpi_OsGetRootPointer(void) { - ACPI_STATUS rv; + ACPI_PHYSICAL_ADDRESS PhysicalAddress; /* * IA-32: Use AcpiFindRootPointer() to locate the RSDP. @@ -271,13 +320,12 @@ acpi_OsGetRootPointer(UINT32 Flags, ACPI_POINTER *PhysicalAddress) * ways to do it. */ - rv = acpi_md_OsGetRootPointer(Flags, PhysicalAddress); + PhysicalAddress = acpi_md_OsGetRootPointer(); - if (acpi_root_pointer == 0 && ACPI_SUCCESS(rv)) - acpi_root_pointer = - (uint64_t)PhysicalAddress->Pointer.Physical; + if (acpi_root_pointer == 0) + acpi_root_pointer = PhysicalAddress; - return rv; + return PhysicalAddress; } /* @@ -324,11 +372,13 @@ acpi_attach(struct device *parent, struct device *self, void *aux) aprint_verbose("%s: using Intel ACPI CA subsystem version %08x\n", sc->sc_dev.dv_xname, ACPI_CA_VERSION); +#if 0 aprint_verbose("%s: X/RSDT: OemId <%6.6s,%8.8s,%08x>, AslId <%4.4s,%08x>\n", sc->sc_dev.dv_xname, AcpiGbl_XSDT->OemId, AcpiGbl_XSDT->OemTableId, AcpiGbl_XSDT->OemRevision, AcpiGbl_XSDT->AslCompilerId, AcpiGbl_XSDT->AslCompilerRevision); +#endif sc->sc_quirks = acpi_find_quirks(); @@ -341,6 +391,12 @@ acpi_attach(struct device *parent, struct device *self, void *aux) acpi_softc = sc; /* + * Register null power management handler + */ + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + + /* * Bring ACPI on-line. */ #ifdef ACPI_DEBUGGER @@ -348,7 +404,22 @@ acpi_attach(struct device *parent, struct device *self, void *aux) acpi_osd_debugger(); #endif - rv = AcpiEnableSubsystem(0); +#define ACPI_ENABLE_PHASE1 \ + (ACPI_NO_HANDLER_INIT | ACPI_NO_EVENT_INIT) +#define ACPI_ENABLE_PHASE2 \ + (ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE | \ + ACPI_NO_ADDRESS_SPACE_INIT) + + rv = AcpiEnableSubsystem(ACPI_ENABLE_PHASE1); + if (ACPI_FAILURE(rv)) { + aprint_error("%s: unable to enable ACPI: %s\n", + sc->sc_dev.dv_xname, AcpiFormatException(rv)); + return; + } + + acpi_md_callback(); + + rv = AcpiEnableSubsystem(ACPI_ENABLE_PHASE2); if (ACPI_FAILURE(rv)) { aprint_error("%s: unable to enable ACPI: %s\n", sc->sc_dev.dv_xname, AcpiFormatException(rv)); @@ -356,11 +427,9 @@ acpi_attach(struct device *parent, struct device *self, void *aux) } /* early EC handler initialization if ECDT table is available */ -#if NACPIEC > 0 - acpiec_early_attach(&sc->sc_dev); -#endif + config_found_ia(&sc->sc_dev, "acpiecdtbus", NULL, NULL); - rv = AcpiInitializeObjects(0); + rv = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION); if (ACPI_FAILURE(rv)) { aprint_error("%s: unable to initialize ACPI objects: %s\n", sc->sc_dev.dv_xname, AcpiFormatException(rv)); @@ -372,9 +441,9 @@ acpi_attach(struct device *parent, struct device *self, void *aux) sc->sc_sleepstate = ACPI_STATE_S0; /* Show SCI interrupt. */ - if (AcpiGbl_FADT != NULL) - aprint_verbose("%s: SCI interrupting at int %d\n", - sc->sc_dev.dv_xname, AcpiGbl_FADT->SciInt); + aprint_verbose("%s: SCI interrupting at int %d\n", + sc->sc_dev.dv_xname, AcpiGbl_FADT.SciInterrupt); + /* * Check for fixed-hardware features. */ @@ -388,7 +457,6 @@ acpi_attach(struct device *parent, struct device *self, void *aux) if (acpi_dbgr & ACPI_DBGR_PROBE) acpi_osd_debugger(); #endif - acpi_md_callback((struct device *)sc); acpi_build_tree(sc); if (acpi_root_pointer != 0 && acpi_node != CTL_EOL) { @@ -529,15 +597,18 @@ acpi_build_tree(struct acpi_softc *sc) (ACPI_STA_DEV_PRESENT|ACPI_STA_DEV_ENABLED| ACPI_STA_DEV_OK)) continue; - - /* - * XXX Same problem as above... - */ - if ((ad->ad_devinfo->Valid & ACPI_VALID_HID) - == 0) - continue; } + /* + * XXX Same problem as above... + * + * Do this check only for devices, as e.g. + * a Thermal Zone doesn't have a HID. + */ + if (ad->ad_devinfo->Type == ACPI_TYPE_DEVICE && + (ad->ad_devinfo->Valid & ACPI_VALID_HID) == 0) + continue; + ad->ad_device = config_found_ia(&sc->sc_dev, "acpinodebus", &aa, acpi_print); } @@ -658,7 +729,8 @@ acpi_make_devnode(ACPI_HANDLE handle, UINT32 level, void *context, TAILQ_INSERT_TAIL(&as->as_devnodes, ad, ad_list); - if ((ad->ad_devinfo->Valid & ACPI_VALID_HID) == 0) + if (type == ACPI_TYPE_DEVICE && + (ad->ad_devinfo->Valid & ACPI_VALID_HID) == 0) goto out; #ifdef ACPI_EXTRA_DEBUG @@ -722,13 +794,15 @@ acpi_print(void *aux, const char *pnp) } #endif - } else { + aprint_normal("at %s", pnp); + } else if (aa->aa_node->ad_devinfo->Type != ACPI_TYPE_DEVICE) { aprint_normal("%s (ACPI Object Type '%s' " "[0x%02x]) ", aa->aa_node->ad_name, AcpiUtGetTypeName(aa->aa_node->ad_devinfo->Type), aa->aa_node->ad_devinfo->Type); - } - aprint_normal("at %s", pnp); + aprint_normal("at %s", pnp); + } else + return 0; } else { aprint_normal(" (%s", aa->aa_node->ad_name); if (aa->aa_node->ad_devinfo->Valid & ACPI_VALID_HID) { @@ -773,7 +847,7 @@ acpi_enable_fixed_events(struct acpi_softc *sc) * Check for fixed-hardware buttons. */ - if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->PwrButton == 0) { + if ((AcpiGbl_FADT.Flags & ACPI_FADT_POWER_BUTTON) == 0) { aprint_verbose("%s: fixed-feature power button present\n", sc->sc_dev.dv_xname); sc->sc_smpsw_power.smpsw_name = sc->sc_dev.dv_xname; @@ -794,7 +868,7 @@ acpi_enable_fixed_events(struct acpi_softc *sc) } } - if (AcpiGbl_FADT != NULL && AcpiGbl_FADT->SleepButton == 0) { + if ((AcpiGbl_FADT.Flags & ACPI_FADT_SLEEP_BUTTON) == 0) { aprint_verbose("%s: fixed-feature sleep button present\n", sc->sc_dev.dv_xname); sc->sc_smpsw_sleep.smpsw_name = sc->sc_dev.dv_xname; @@ -831,7 +905,7 @@ acpi_fixed_button_handler(void *context) printf("%s: fixed button handler\n", smpsw->smpsw_name); #endif - rv = AcpiOsQueueForExecution(OSD_PRIORITY_LO, + rv = AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_fixed_button_pressed, smpsw); if (ACPI_FAILURE(rv)) printf("%s: WARNING: unable to queue fixed button pressed " @@ -1085,7 +1159,7 @@ is_available_state(struct acpi_softc *sc, int state) ACPI_STATUS acpi_enter_sleep_state(struct acpi_softc *sc, int state) { - int s; + int err; ACPI_STATUS ret = AE_OK; if (state == acpi_sleepstate) @@ -1105,32 +1179,33 @@ acpi_enter_sleep_state(struct acpi_softc *sc, int state) sc->sc_dev.dv_xname, state); break; } + + if (state != ACPI_STATE_S1 && !pmf_system_suspend()) { + aprint_error_dev(&sc->sc_dev, "aborting suspend"); + break; + } + ret = AcpiEnterSleepStatePrep(state); if (ACPI_FAILURE(ret)) { aprint_error("%s: failed preparing to sleep (%s)\n", sc->sc_dev.dv_xname, AcpiFormatException(ret)); break; } + acpi_sleepstate = state; if (state == ACPI_STATE_S1) { /* just enter the state */ acpi_md_OsDisableInterrupt(); AcpiEnterSleepState((UINT8)state); + AcpiLeaveSleepState((UINT8)state); } else { - /* XXX: powerhooks(9) framework is too poor to - * support ACPI sleep state... - */ - dopowerhooks(PWR_SOFTSUSPEND); - s = splhigh(); - dopowerhooks(PWR_SUSPEND); - acpi_md_sleep(state); - dopowerhooks(PWR_RESUME); - splx(s); - dopowerhooks(PWR_SOFTRESUME); - if (state==ACPI_STATE_S4) + err = acpi_md_sleep(state); + if (state == ACPI_STATE_S4) AcpiEnable(); + AcpiLeaveSleepState((UINT8)state); + pmf_system_resume(); } - AcpiLeaveSleepState((UINT8)state); + break; case ACPI_STATE_S5: ret = AcpiEnterSleepStatePrep(ACPI_STATE_S5); @@ -1139,6 +1214,7 @@ acpi_enter_sleep_state(struct acpi_softc *sc, int state) sc->sc_dev.dv_xname, AcpiFormatException(ret)); break; } + DELAY(1000000); acpi_sleepstate = state; acpi_md_OsDisableInterrupt(); AcpiEnterSleepState(ACPI_STATE_S5); @@ -1147,7 +1223,6 @@ acpi_enter_sleep_state(struct acpi_softc *sc, int state) break; } - aprint_normal("%s: resuming\n", sc->sc_dev.dv_xname); acpi_sleepstate = ACPI_STATE_S0; return ret; } diff --git a/sys/dev/acpi/acpi_acad.c b/sys/dev/acpi/acpi_acad.c index da2e9154292..9b762ccc462 100644 --- a/sys/dev/acpi/acpi_acad.c +++ b/sys/dev/acpi/acpi_acad.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_acad.c,v 1.30 2007/12/05 07:06:50 ad Exp $ */ +/* $NetBSD: acpi_acad.c,v 1.31 2007/12/09 20:27:52 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_acad.c,v 1.30 2007/12/05 07:06:50 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_acad.c,v 1.31 2007/12/09 20:27:52 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -151,6 +151,9 @@ acpiacad_attach(device_t parent, device_t self, void *aux) sc->sc_flags = AACAD_F_VERBOSE; #endif + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + acpiacad_init_envsys(self); } @@ -247,7 +250,7 @@ acpiacad_notify_handler(ACPI_HANDLE handle, UINT32 notify, void *context) acpiacad_clear_status(sc); mutex_exit(&sc->sc_mtx); if (sc->sc_status == -1 || !sc->sc_notifysent) { - rv = AcpiOsQueueForExecution(OSD_PRIORITY_LO, + rv = AcpiOsExecute(OSL_NOTIFY_HANDLER, acpiacad_get_status, dv); if (ACPI_FAILURE(rv)) aprint_error_dev(dv, diff --git a/sys/dev/acpi/acpi_apm.c b/sys/dev/acpi/acpi_apm.c index 64ece3a11ed..e69b2772356 100644 --- a/sys/dev/acpi/acpi_apm.c +++ b/sys/dev/acpi/acpi_apm.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_apm.c,v 1.11 2007/10/27 19:51:29 plunky Exp $ */ +/* $NetBSD: acpi_apm.c,v 1.12 2007/12/09 20:27:52 jmcneill Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_apm.c,v 1.11 2007/10/27 19:51:29 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_apm.c,v 1.12 2007/12/09 20:27:52 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -337,7 +337,8 @@ acpiapm_get_powstat(void *opaque, u_int batteryid, else if (strstr(desc, " design cap")) descap = data / 1000; else if (strstr(desc, " charge") && - strstr(desc, " charge rate") == NULL) { + strstr(desc, " charge rate") == NULL && + strstr(desc, " charge state") == NULL) { cap += data / 1000; cap_valid = 1; pinfo->nbattery++; diff --git a/sys/dev/acpi/acpi_bat.c b/sys/dev/acpi/acpi_bat.c index ea32f286a71..e9778224a80 100644 --- a/sys/dev/acpi/acpi_bat.c +++ b/sys/dev/acpi/acpi_bat.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_bat.c,v 1.63 2007/12/05 07:06:50 ad Exp $ */ +/* $NetBSD: acpi_bat.c,v 1.64 2007/12/09 20:27:52 jmcneill Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -86,7 +86,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.63 2007/12/05 07:06:50 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.64 2007/12/09 20:27:52 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -239,6 +239,9 @@ acpibat_attach(device_t parent, device_t self, void *aux) ABAT_SET(sc, ABAT_F_VERBOSE); #endif + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + acpibat_init_envsys(self); } @@ -648,8 +651,7 @@ acpibat_notify_handler(ACPI_HANDLE handle, UINT32 notify, void *context) mutex_enter(&sc->sc_mtx); acpibat_clear_presence(sc); mutex_exit(&sc->sc_mtx); - rv = AcpiOsQueueForExecution(OSD_PRIORITY_LO, - acpibat_update, dv); + rv = AcpiOsExecute(OSL_NOTIFY_HANDLER, acpibat_update, dv); if (ACPI_FAILURE(rv)) aprint_error_dev(dv, "unable to queue status check: %s\n", @@ -660,8 +662,7 @@ acpibat_notify_handler(ACPI_HANDLE handle, UINT32 notify, void *context) mutex_enter(&sc->sc_mtx); acpibat_clear_stat(sc); mutex_exit(&sc->sc_mtx); - rv = AcpiOsQueueForExecution(OSD_PRIORITY_LO, - acpibat_update, dv); + rv = AcpiOsExecute(OSL_NOTIFY_HANDLER, acpibat_update, dv); if (ACPI_FAILURE(rv)) aprint_error_dev(dv, "unable to queue status check: %s\n", diff --git a/sys/dev/acpi/acpi_button.c b/sys/dev/acpi/acpi_button.c index d38e7bf5f70..9a68ab11057 100644 --- a/sys/dev/acpi/acpi_button.c +++ b/sys/dev/acpi/acpi_button.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_button.c,v 1.24 2007/10/24 07:05:35 joerg Exp $ */ +/* $NetBSD: acpi_button.c,v 1.25 2007/12/09 20:27:52 jmcneill Exp $ */ /* * Copyright 2001, 2003 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_button.c,v 1.24 2007/10/24 07:05:35 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_button.c,v 1.25 2007/12/09 20:27:52 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -151,6 +151,9 @@ acpibut_attach(device_t parent, device_t self, void *aux) /* Display the current state when it changes. */ sc->sc_flags = ACPIBUT_F_VERBOSE; #endif + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } /* @@ -189,7 +192,7 @@ acpibut_notify_handler(ACPI_HANDLE handle, UINT32 notify, void *context) #ifdef ACPI_BUT_DEBUG aprint_debug_dev(dv, "received ButtonPressed message\n"); #endif - rv = AcpiOsQueueForExecution(OSD_PRIORITY_LO, + rv = AcpiOsExecute(OSL_NOTIFY_HANDLER, acpibut_pressed_event, dv); if (ACPI_FAILURE(rv)) aprint_error_dev(dv, diff --git a/sys/dev/acpi/acpi_ec.c b/sys/dev/acpi/acpi_ec.c index 62dd477ab51..c3e686ff68f 100644 --- a/sys/dev/acpi/acpi_ec.c +++ b/sys/dev/acpi/acpi_ec.c @@ -1,355 +1,207 @@ -/* $NetBSD: acpi_ec.c,v 1.43 2007/12/05 07:58:29 ad Exp $ */ - -/* - * Copyright 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Jason R. Thorpe for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/* $NetBSD: acpi_ec.c,v 1.44 2007/12/09 20:27:52 jmcneill Exp $ */ /*- - * Copyright (c) 2000 Michael Smith - * Copyright (c) 2000 BSDi + * Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights - * reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.43 2007/12/05 07:58:29 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.44 2007/12/09 20:27:52 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> +#include <sys/condvar.h> #include <sys/device.h> -#include <sys/malloc.h> -#include <sys/proc.h> #include <sys/kernel.h> +#include <sys/kthread.h> +#include <sys/mutex.h> #include <sys/bus.h> -#include <dev/acpi/acpica.h> -#include <dev/acpi/acpireg.h> #include <dev/acpi/acpivar.h> -#include <dev/acpi/acpi_ecreg.h> -MALLOC_DECLARE(M_ACPI); +/* Maximum time to wait for global ACPI lock in ms */ +#define EC_LOCK_TIMEOUT 5 + +/* Maximum time to poll for completion of a command in ms */ +#define EC_POLL_TIMEOUT 5 + +/* From ACPI 3.0b, chapter 12.3 */ +#define EC_COMMAND_READ 0x80 +#define EC_COMMAND_WRITE 0x81 +#define EC_COMMAND_BURST_EN 0x82 +#define EC_COMMAND_BURST_DIS 0x83 +#define EC_COMMAND_QUERY 0x84 -#define _COMPONENT ACPI_EC_COMPONENT -ACPI_MODULE_NAME("EC") +/* From ACPI 3.0b, chapter 12.2.1 */ +#define EC_STATUS_OBF 0x01 +#define EC_STATUS_IBF 0x02 +#define EC_STATUS_CMD 0x08 +#define EC_STATUS_BURST 0x10 +#define EC_STATUS_SCI 0x20 +#define EC_STATUS_SMI 0x40 -struct acpi_ec_softc { - struct device sc_dev; /* base device glue */ - ACPI_HANDLE sc_handle; /* ACPI handle */ +static const char *ec_hid[] = { + "PNP0C09", + NULL, +}; - UINT32 sc_gpebit; /* our GPE interrupt bit */ +enum ec_state_t { + EC_STATE_QUERY, + EC_STATE_QUERY_VAL, + EC_STATE_READ, + EC_STATE_READ_ADDR, + EC_STATE_READ_VAL, + EC_STATE_WRITE, + EC_STATE_WRITE_ADDR, + EC_STATE_WRITE_VAL, + EC_STATE_FREE +}; - bus_space_tag_t sc_data_st; /* space tag for data register */ - bus_space_handle_t sc_data_sh; /* space handle for data register */ +struct acpiec_softc { + ACPI_HANDLE sc_ech; - bus_space_tag_t sc_csr_st; /* space tag for control register */ - bus_space_handle_t sc_csr_sh; /* space handle for control register */ + ACPI_HANDLE sc_gpeh; + UINT8 sc_gpebit; - int sc_flags; /* see below */ + bus_space_tag_t sc_data_st; + bus_space_handle_t sc_data_sh; - uint32_t sc_csrvalue; /* saved control register */ - uint32_t sc_uid; /* _UID in namespace (ECDT only) */ + bus_space_tag_t sc_csr_st; + bus_space_handle_t sc_csr_sh; - kmutex_t sc_lock; /* serialize operations to this EC */ - struct simplelock sc_slock; /* protect against interrupts */ - UINT32 sc_glkhandle; /* global lock handle */ - UINT32 sc_glk; /* need global lock? */ -}; + bool sc_need_global_lock; + UINT32 sc_global_lock; -static const char * const ec_hid[] = { - "PNP0C09", - NULL + kmutex_t sc_mtx, sc_access_mtx; + kcondvar_t sc_cv, sc_cv_sci; + enum ec_state_t sc_state; + bool sc_got_sci; + + uint8_t sc_cur_addr, sc_cur_val; }; -#define EC_F_TRANSACTION 0x01 /* doing transaction */ -#define EC_F_PENDQUERY 0x02 /* query is pending */ +static int acpiecdt_match(device_t, struct cfdata *, void *); +static void acpiecdt_attach(device_t, device_t, void *); -/* - * how long to wait to acquire global lock. - * the value is taken from FreeBSD driver. - */ -#define EC_LOCK_TIMEOUT 1000 - -#define EC_DATA_READ(sc) \ - bus_space_read_1((sc)->sc_data_st, (sc)->sc_data_sh, 0) -#define EC_DATA_WRITE(sc, v) \ - bus_space_write_1((sc)->sc_data_st, (sc)->sc_data_sh, 0, (v)) - -#define EC_CSR_READ(sc) \ - bus_space_read_1((sc)->sc_csr_st, (sc)->sc_csr_sh, 0) -#define EC_CSR_WRITE(sc, v) \ - bus_space_write_1((sc)->sc_csr_st, (sc)->sc_csr_sh, 0, (v)) - -typedef struct { - EC_COMMAND Command; - UINT8 Address; - UINT8 Data; -} EC_REQUEST; - -static UINT32 EcGpeHandler(void *); -static ACPI_STATUS EcSpaceSetup(ACPI_HANDLE, UINT32, void *, void **); -static ACPI_STATUS EcSpaceHandler(UINT32, ACPI_PHYSICAL_ADDRESS, UINT32, - ACPI_INTEGER *, void *, void *); - -static ACPI_STATUS EcWaitEvent(struct acpi_ec_softc *, EC_EVENT); -static ACPI_STATUS EcQuery(struct acpi_ec_softc *, UINT8 *); -static ACPI_STATUS EcTransaction(struct acpi_ec_softc *, EC_REQUEST *); -static ACPI_STATUS EcRead(struct acpi_ec_softc *, UINT8, UINT8 *); -static ACPI_STATUS EcWrite(struct acpi_ec_softc *, UINT8, UINT8 *); -static void EcGpeQueryHandler(void *); -static inline int EcIsLocked(struct acpi_ec_softc *); -static inline void EcLock(struct acpi_ec_softc *); -static inline void EcUnlock(struct acpi_ec_softc *); - - -static int acpiec_match(struct device *, struct cfdata *, void *); -static void acpiec_attach(struct device *, struct device *, void *); - -CFATTACH_DECL(acpiec, sizeof(struct acpi_ec_softc), +static int acpiec_match(device_t, struct cfdata *, void *); +static void acpiec_attach(device_t, device_t, void *); + +static void acpiec_common_attach(device_t, device_t, ACPI_HANDLE, + bus_addr_t, bus_addr_t, ACPI_HANDLE, uint8_t); + +static bool acpiec_resume(device_t); +static bool acpiec_suspend(device_t); + +static bool acpiec_parse_gpe_package(device_t, ACPI_HANDLE, + ACPI_HANDLE *, uint8_t *); + +static void acpiec_gpe_query(void *); +static UINT32 acpiec_gpe_handler(void *); +static ACPI_STATUS acpiec_space_setup(ACPI_HANDLE, UINT32, void *, void **); +static ACPI_STATUS acpiec_space_handler(UINT32, ACPI_PHYSICAL_ADDRESS, + UINT32, ACPI_INTEGER *, void *, void *); + +static void acpiec_gpe_state_maschine(device_t); + +CFATTACH_DECL_NEW(acpiec, sizeof(struct acpiec_softc), acpiec_match, acpiec_attach, NULL, NULL); -static struct acpi_ec_softc *ecdt_sc; +CFATTACH_DECL_NEW(acpiecdt, sizeof(struct acpiec_softc), + acpiecdt_match, acpiecdt_attach, NULL, NULL); -static inline int -EcIsLocked(struct acpi_ec_softc *sc) +static device_t ec_singleton = NULL; +static bool acpiec_cold = false; + +static bool +acpiecdt_find(device_t parent, ACPI_HANDLE *ec_handle, + bus_addr_t *cmd_reg, bus_addr_t *data_reg, uint8_t *gpebit) { + ACPI_TABLE_ECDT *ecdt; + ACPI_STATUS rv; + + rv = AcpiGetTable(ACPI_SIG_ECDT, 1, (ACPI_TABLE_HEADER **)&ecdt); + if (ACPI_FAILURE(rv)) + return false; - return (mutex_owned(&sc->sc_lock)); + if (ecdt->Control.BitWidth != 8 || ecdt->Data.BitWidth != 8) { + aprint_error_dev(parent, + "ECDT register width invalid (%d/%d)\n", + ecdt->Control.BitWidth, ecdt->Data.BitWidth); + return false; + } + + rv = AcpiGetHandle(ACPI_ROOT_OBJECT, ecdt->Id, ec_handle); + if (ACPI_FAILURE(rv)) { + aprint_error_dev(parent, + "failed to look up EC object %s: %s\n", + ecdt->Id, AcpiFormatException(rv)); + return false; + } + + *cmd_reg = ecdt->Control.Address; + *data_reg = ecdt->Data.Address; + *gpebit = ecdt->Gpe; + + return true; } -static inline void -EcLock(struct acpi_ec_softc *sc) +static int +acpiecdt_match(device_t parent, struct cfdata *match, void *aux) { - ACPI_STATUS rv; - int s; - - mutex_enter(&sc->sc_lock); - if (sc->sc_glk) { - rv = AcpiAcquireGlobalLock(EC_LOCK_TIMEOUT, - &sc->sc_glkhandle); - if (ACPI_FAILURE(rv)) { - printf("%s: failed to acquire global lock\n", - sc->sc_dev.dv_xname); - mutex_exit(&sc->sc_lock); - return; - } - } + ACPI_HANDLE ec_handle; + bus_addr_t cmd_reg, data_reg; + uint8_t gpebit; - s = splvm(); /* XXX */ - simple_lock(&sc->sc_slock); - sc->sc_flags |= EC_F_TRANSACTION; - simple_unlock(&sc->sc_slock); - splx(s); + if (acpiecdt_find(parent, &ec_handle, &cmd_reg, &data_reg, &gpebit)) + return 1; + else + return 0; } -static inline void -EcUnlock(struct acpi_ec_softc *sc) +static void +acpiecdt_attach(device_t parent, device_t self, void *aux) { - ACPI_STATUS rv; - int s; + ACPI_HANDLE ec_handle; + bus_addr_t cmd_reg, data_reg; + uint8_t gpebit; - /* - * Clear & Re-Enable the EC GPE: - * ----------------------------- - * 'Consume' any EC GPE events that we generated while performing - * the transaction (e.g. IBF/OBF). Clearing the GPE here shouldn't - * have an adverse affect on outstanding EC-SCI's, as the source - * (EC-SCI) will still be high and thus should trigger the GPE - * immediately after we re-enabling it. - */ - s = splvm(); /* XXX */ - simple_lock(&sc->sc_slock); - if (sc->sc_flags & EC_F_PENDQUERY) { - ACPI_STATUS rv2; - - rv2 = AcpiOsQueueForExecution(OSD_PRIORITY_HIGH, - EcGpeQueryHandler, sc); - if (ACPI_FAILURE(rv2)) - printf("%s: unable to queue pending query: %s\n", - sc->sc_dev.dv_xname, AcpiFormatException(rv2)); - sc->sc_flags &= ~EC_F_PENDQUERY; - } - sc->sc_flags &= ~EC_F_TRANSACTION; - simple_unlock(&sc->sc_slock); - splx(s); - - if (sc->sc_glk) { - rv = AcpiReleaseGlobalLock(sc->sc_glkhandle); - if (ACPI_FAILURE(rv)) - printf("%s: failed to release global lock\n", - sc->sc_dev.dv_xname); - } - mutex_exit(&sc->sc_lock); + if (!acpiecdt_find(parent, &ec_handle, &cmd_reg, &data_reg, &gpebit)) + panic("ECDT disappeared"); + + aprint_naive(": ACPI Embedded Controller via ECDT\n"); + aprint_normal(": ACPI Embedded Controller via ECDT\n"); + + acpiec_common_attach(parent, self, ec_handle, cmd_reg, data_reg, + NULL, gpebit); } -/* - * acpiec_match: - * - * Autoconfiguration `match' routine. - */ static int -acpiec_match(struct device *parent, struct cfdata *match, - void *aux) +acpiec_match(device_t parent, struct cfdata *match, void *aux) { struct acpi_attach_args *aa = aux; @@ -359,672 +211,596 @@ acpiec_match(struct device *parent, struct cfdata *match, return acpi_match_hid(aa->aa_node->ad_devinfo, ec_hid); } -void -acpiec_early_attach(struct device *parent) +static void +acpiec_attach(device_t parent, device_t self, void *aux) { - struct acpi_softc *sc = (struct acpi_softc *)parent; - EC_BOOT_RESOURCES *ep; - ACPI_HANDLE handle; + struct acpi_attach_args *aa = aux; + struct acpi_resources ec_res; + struct acpi_io *io0, *io1; + ACPI_HANDLE gpe_handle; + uint8_t gpebit; ACPI_STATUS rv; - ACPI_INTEGER tmp; - rv = AcpiGetFirmwareTable("ECDT", 1, ACPI_LOGICAL_ADDRESSING, - (void *)&ep); - if (ACPI_FAILURE(rv)) + if (ec_singleton != NULL) { + aprint_naive(": ACPI Embedded Controller (disabled)\n"); + aprint_normal(": ACPI Embedded Controller (disabled)\n"); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); return; + } + + aprint_naive(": ACPI Embedded Controller\n"); + aprint_normal(": ACPI Embedded Controller\n"); - if (ep->EcControl.RegisterBitWidth != 8 || - ep->EcData.RegisterBitWidth != 8) { - printf("%s: ECDT data is invalid, RegisterBitWidth=%d/%d\n", - parent->dv_xname, - ep->EcControl.RegisterBitWidth, - ep->EcData.RegisterBitWidth); + if (!acpiec_parse_gpe_package(self, aa->aa_node->ad_handle, + &gpe_handle, &gpebit)) return; - } - rv = AcpiGetHandle(ACPI_ROOT_OBJECT, ep->EcId, &handle); - if (ACPI_FAILURE(rv)) { - printf("%s: failed to look up EC object %s: %s\n", - parent->dv_xname, - ep->EcId, AcpiFormatException(rv)); + rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", + &ec_res, &acpi_resource_parse_ops_default); + if (rv != AE_OK) { + aprint_error_dev(self, "resource parsing failed: %s\n", + AcpiFormatException(rv)); return; } - ecdt_sc = malloc(sizeof(*ecdt_sc), M_ACPI, M_ZERO); + if ((io0 = acpi_res_io(&ec_res, 0)) == NULL) { + aprint_error_dev(self, "no data register resource\n"); + goto free_res; + } + if ((io1 = acpi_res_io(&ec_res, 1)) == NULL) { + aprint_error_dev(self, "no CSR register resource\n"); + goto free_res; + } - strcpy(ecdt_sc->sc_dev.dv_xname, "acpiecdt0"); /* XXX */ - ecdt_sc->sc_handle = handle; + acpiec_common_attach(parent, self, aa->aa_node->ad_handle, + io1->ar_base, io0->ar_base, gpe_handle, gpebit); - ecdt_sc->sc_gpebit = ep->GpeBit; - ecdt_sc->sc_uid = ep->Uid; +free_res: + acpi_resource_cleanup(&ec_res); +} - ecdt_sc->sc_data_st = sc->sc_iot; - if (bus_space_map(ecdt_sc->sc_data_st, - (bus_addr_t)(ep->EcData.Address), 1, 0, - &ecdt_sc->sc_data_sh) != 0) { - printf("%s: bus_space_map failed for EC data.\n", - parent->dv_xname); - goto out1; - } +static void +acpiec_common_attach(device_t parent, device_t self, + ACPI_HANDLE ec_handle, bus_addr_t cmd_reg, bus_addr_t data_reg, + ACPI_HANDLE gpe_handle, uint8_t gpebit) +{ + struct acpiec_softc *sc = device_private(self); + ACPI_STATUS rv; + ACPI_INTEGER val; - ecdt_sc->sc_csr_st = sc->sc_iot; - if (bus_space_map(ecdt_sc->sc_csr_st, - (bus_addr_t)(ep->EcControl.Address), 1, 0, - &ecdt_sc->sc_csr_sh) != 0) { - printf("%s: bus_space_map failed for EC control.\n", - parent->dv_xname); - goto out2; - } + sc->sc_ech = ec_handle; + sc->sc_gpeh = gpe_handle; + sc->sc_gpebit = gpebit; - rv = acpi_eval_integer(handle, "_GLK", &tmp); - if (ACPI_SUCCESS(rv) && tmp == 1) - ecdt_sc->sc_glk = 1; + sc->sc_state = EC_STATE_FREE; + mutex_init(&sc->sc_mtx, MUTEX_DRIVER, IPL_TTY); + mutex_init(&sc->sc_access_mtx, MUTEX_DEFAULT, IPL_NONE); + cv_init(&sc->sc_cv, "eccv"); + cv_init(&sc->sc_cv_sci, "ecsci"); - rv = AcpiInstallGpeHandler(NULL, ecdt_sc->sc_gpebit, - ACPI_GPE_EDGE_TRIGGERED, EcGpeHandler, ecdt_sc); - if (ACPI_FAILURE(rv)) { - printf("%s: unable to install GPE handler: %s\n", - parent->dv_xname, AcpiFormatException(rv)); - goto out3; + if (bus_space_map(sc->sc_data_st, data_reg, 1, 0, + &sc->sc_data_sh) != 0) { + aprint_error_dev(self, "unable to map data register\n"); + return; } - rv = AcpiSetGpeType(NULL, ecdt_sc->sc_gpebit, ACPI_GPE_TYPE_RUNTIME); - if (ACPI_FAILURE(rv)) { - printf("%s: unable to set GPE type: %s\n", - parent->dv_xname, AcpiFormatException(rv)); - goto out4; + if (bus_space_map(sc->sc_csr_st, cmd_reg, 1, 0, &sc->sc_csr_sh) != 0) { + aprint_error_dev(self, "unable to map CSR register\n"); + goto post_data_map; } - rv = AcpiEnableGpe(NULL, ecdt_sc->sc_gpebit, ACPI_NOT_ISR); - if (ACPI_FAILURE(rv)) { - printf("%s: unable to enable GPE: %s\n", - parent->dv_xname, AcpiFormatException(rv)); - goto out4; + rv = acpi_eval_integer(sc->sc_ech, "_GLK", &val); + if (rv == AE_OK) { + sc->sc_need_global_lock = val != 0; + } else if (rv != AE_NOT_FOUND) { + aprint_error_dev(self, "unable to evaluate _GLK: %s\n", + AcpiFormatException(rv)); + goto post_csr_map; + } else { + sc->sc_need_global_lock = false; } + if (sc->sc_need_global_lock) + aprint_normal_dev(self, "using global ACPI lock\n"); - rv = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_EC, EcSpaceHandler, EcSpaceSetup, ecdt_sc); - if (ACPI_FAILURE(rv)) { - printf("%s: unable to install address space handler: %s\n", - parent->dv_xname, + rv = AcpiInstallAddressSpaceHandler(sc->sc_ech, ACPI_ADR_SPACE_EC, + acpiec_space_handler, acpiec_space_setup, self); + if (rv != AE_OK) { + aprint_error_dev(self, + "unable to install address space handler: %s\n", AcpiFormatException(rv)); - goto out4; + goto post_csr_map; } - printf("%s: found ECDT, GPE %d\n", parent->dv_xname, - ecdt_sc->sc_gpebit); + rv = AcpiInstallGpeHandler(sc->sc_gpeh, sc->sc_gpebit, + ACPI_GPE_EDGE_TRIGGERED, acpiec_gpe_handler, self); + if (rv != AE_OK) { + aprint_error_dev(self, "unable to install GPE handler: %s\n", + AcpiFormatException(rv)); + goto post_csr_map; + } - mutex_init(&ecdt_sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); - simple_lock_init(&ecdt_sc->sc_slock); + rv = AcpiSetGpeType(sc->sc_gpeh, sc->sc_gpebit, ACPI_GPE_TYPE_RUNTIME); + if (rv != AE_OK) { + aprint_error_dev(self, "unable to set GPE type: %s\n", + AcpiFormatException(rv)); + goto post_csr_map; + } - AcpiOsUnmapMemory(ep, ep->Length); - return; + rv = AcpiEnableGpe(sc->sc_gpeh, sc->sc_gpebit, ACPI_ISR); + if (rv != AE_OK) { + aprint_error_dev(self, "unable to enable GPE: %s\n", + AcpiFormatException(rv)); + goto post_csr_map; + } - out4: - AcpiRemoveGpeHandler(NULL, ecdt_sc->sc_gpebit, EcGpeHandler); - out3: - bus_space_unmap(ecdt_sc->sc_csr_st, ecdt_sc->sc_csr_sh, 1); - out2: - bus_space_unmap(ecdt_sc->sc_data_st, ecdt_sc->sc_data_sh, 1); - out1: - free(ecdt_sc, M_ACPI); - ecdt_sc = NULL; + if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, acpiec_gpe_query, + self, NULL, "acpiec sci thread")) { + aprint_error_dev(self, "unable to create query kthread\n"); + goto post_csr_map; + } + + ec_singleton = self; - AcpiOsUnmapMemory(ep, ep->Length); + if (!pmf_device_register(self, acpiec_suspend, acpiec_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); return; + +post_csr_map: + (void)AcpiRemoveGpeHandler(sc->sc_gpeh, sc->sc_gpebit, + acpiec_gpe_handler); + (void)AcpiRemoveAddressSpaceHandler(sc->sc_ech, + ACPI_ADR_SPACE_EC, acpiec_space_handler); + bus_space_unmap(sc->sc_csr_st, sc->sc_csr_sh, 1); +post_data_map: + bus_space_unmap(sc->sc_data_st, sc->sc_data_sh, 1); } -/* - * acpiec_attach: - * - * Autoconfiguration `attach' routine. - */ -static void -acpiec_attach(struct device *parent, struct device *self, void *aux) +static bool +acpiec_suspend(device_t dv) { - struct acpi_ec_softc *sc = (void *) self; - struct acpi_attach_args *aa = aux; - struct acpi_io *io0, *io1; - struct acpi_resources res; - ACPI_STATUS rv; - ACPI_INTEGER v; - - ACPI_FUNCTION_TRACE(__FUNCTION__); + acpiec_cold = true; - aprint_naive(": ACPI Embedded Controller\n"); - aprint_normal(": ACPI Embedded Controller\n"); - - mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); - simple_lock_init(&sc->sc_slock); - - sc->sc_handle = aa->aa_node->ad_handle; + return true; +} - /* Parse our resources. */ - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "parsing EC resources\n")); - rv = acpi_resource_parse(&sc->sc_dev, sc->sc_handle, "_CRS", - &res, &acpi_resource_parse_ops_default); - if (ACPI_FAILURE(rv)) - return; +static bool +acpiec_resume(device_t dv) +{ + acpiec_cold = false; -#define adi aa->aa_node->ad_devinfo - - /* check if we already attached EC via ECDT */ - if (ecdt_sc && - ((adi->Valid & ACPI_VALID_UID) == ACPI_VALID_UID) && - ecdt_sc->sc_uid == strtoul(adi->UniqueId.Value, NULL, 10)) { - /* detach all ECDT handles */ - rv = AcpiRemoveAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_EC, EcSpaceHandler); - if (ACPI_FAILURE(rv)) - aprint_error("ERROR: RemoveAddressSpaceHandler: %s\n", - AcpiFormatException(rv)); - rv = AcpiRemoveGpeHandler(NULL, ecdt_sc->sc_gpebit, - EcGpeHandler); - if (ACPI_FAILURE(rv)) - aprint_error("ERROR: RemoveAddressSpaceHandler: %s\n", - AcpiFormatException(rv)); + return true; +} - bus_space_unmap(ecdt_sc->sc_csr_st, - ecdt_sc->sc_csr_sh, 1); - bus_space_unmap(ecdt_sc->sc_data_st, - ecdt_sc->sc_data_sh, 1); +static bool +acpiec_parse_gpe_package(device_t self, ACPI_HANDLE ec_handle, + ACPI_HANDLE *gpe_handle, uint8_t *gpebit) +{ + ACPI_BUFFER buf; + ACPI_OBJECT *p, *c; + ACPI_STATUS rv; - mutex_destroy(&ecdt_sc->sc_lock); - free(ecdt_sc, M_ACPI); - ecdt_sc = NULL; + rv = acpi_eval_struct(ec_handle, "_GPE", &buf); + if (rv != AE_OK) { + aprint_error_dev(self, "unable to evaluate _GPE: %s\n", + AcpiFormatException(rv)); + return false; } -#undef adi + p = buf.Pointer; - sc->sc_data_st = aa->aa_iot; - io0 = acpi_res_io(&res, 0); - if (io0 == NULL) { - aprint_error("%s: unable to find data register resource\n", - sc->sc_dev.dv_xname); - goto out; - } - if (bus_space_map(sc->sc_data_st, io0->ar_base, io0->ar_length, - 0, &sc->sc_data_sh) != 0) { - aprint_error("%s: unable to map data register\n", - sc->sc_dev.dv_xname); - goto out; + if (p->Type == ACPI_TYPE_INTEGER) { + *gpe_handle = NULL; + *gpebit = p->Integer.Value; + AcpiOsFree(p); + return true; } - sc->sc_csr_st = aa->aa_iot; - io1 = acpi_res_io(&res, 1); - if (io1 == NULL) { - aprint_error("%s: unable to find csr register resource\n", - sc->sc_dev.dv_xname); - goto out; + if (p->Type != ACPI_TYPE_PACKAGE) { + aprint_error_dev(self, "_GPE is neither integer nor package\n"); + AcpiOsFree(p); + return false; } - if (bus_space_map(sc->sc_csr_st, io1->ar_base, io1->ar_length, - 0, &sc->sc_csr_sh) != 0) { - aprint_error("%s: unable to map csr register\n", - sc->sc_dev.dv_xname); - goto out; + + if (p->Package.Count != 2) { + aprint_error_dev(self, "_GPE package does not contain 2 elements\n"); + AcpiOsFree(p); + return false; } - /* - * evaluate _GLK to see if we should acquire global lock - * when accessing the EC. - */ - rv = acpi_eval_integer(sc->sc_handle, "_GLK", &v); - if (ACPI_FAILURE(rv)) { - if (rv != AE_NOT_FOUND) - aprint_error("%s: unable to evaluate _GLK: %s\n", - sc->sc_dev.dv_xname, - AcpiFormatException(rv)); - sc->sc_glk = 0; - } else - sc->sc_glk = v; - - /* - * Install GPE handler. - * - * We evaluate the _GPE method to find the GPE bit used by the - * Embedded Controller to signal status (SCI). - */ - rv = acpi_eval_integer(sc->sc_handle, "_GPE", &v); - if (ACPI_FAILURE(rv)) { - aprint_error("%s: unable to evaluate _GPE: %s\n", - sc->sc_dev.dv_xname, AcpiFormatException(rv)); - goto out; - } - sc->sc_gpebit = v; + c = &p->Package.Elements[0]; + switch (c->Type) { + case ACPI_TYPE_LOCAL_REFERENCE: + case ACPI_TYPE_ANY: + *gpe_handle = c->Reference.Handle; + break; + case ACPI_TYPE_STRING: + /* XXX should be using real scope here */ + rv = AcpiGetHandle(NULL, p->String.Pointer, gpe_handle); + if (rv != AE_OK) { + aprint_error_dev(self, + "_GPE device reference unresolvable\n"); + AcpiOsFree(p); + return false; + } + break; + default: + aprint_error_dev(self, "_GPE device reference incorrect\n"); + AcpiOsFree(p); + return false; + } + c = &p->Package.Elements[1]; + if (c->Type != ACPI_TYPE_INTEGER) { + aprint_error_dev(self, + "_GPE package needs integer as 2nd field\n"); + AcpiOsFree(p); + return false; + } + *gpebit = c->Integer.Value; + AcpiOsFree(p); + return true; +} - /* - * Install a handler for this EC's GPE bit. Note that EC SCIs are - * treated as both edge- and level-triggered interrupts; in other words - * we clear the status bit immediately after getting an EC-SCI, then - * again after we're done processing the event. This guarantees that - * events we cause while performing a transaction (e.g. IBE/OBF) get - * cleared before re-enabling the GPE. - */ - rv = AcpiInstallGpeHandler(NULL, sc->sc_gpebit, - ACPI_GPE_EDGE_TRIGGERED, EcGpeHandler, sc); - if (ACPI_FAILURE(rv)) { - aprint_error("%s: unable to install GPE handler: %s\n", - sc->sc_dev.dv_xname, AcpiFormatException(rv)); - goto out; - } +static uint8_t +acpiec_read_data(struct acpiec_softc *sc) +{ + return bus_space_read_1(sc->sc_data_st, sc->sc_data_sh, 0); +} - rv = AcpiSetGpeType(NULL, sc->sc_gpebit, ACPI_GPE_TYPE_RUNTIME); - if (ACPI_FAILURE(rv)) { - aprint_error("%s: unable to set GPE type: %s\n", - sc->sc_dev.dv_xname, AcpiFormatException(rv)); - goto out2; - } +static void +acpiec_write_data(struct acpiec_softc *sc, uint8_t val) +{ + bus_space_write_1(sc->sc_data_st, sc->sc_data_sh, 0, val); +} - rv = AcpiEnableGpe(NULL, sc->sc_gpebit, ACPI_NOT_ISR); - if (ACPI_FAILURE(rv)) { - aprint_error("%s: unable to enable GPE: %s\n", - sc->sc_dev.dv_xname, AcpiFormatException(rv)); - goto out2; - } +static uint8_t +acpiec_read_status(struct acpiec_softc *sc) +{ + return bus_space_read_1(sc->sc_csr_st, sc->sc_csr_sh, 0); +} - /* Install address space handler. */ - rv = AcpiInstallAddressSpaceHandler(sc->sc_handle, - ACPI_ADR_SPACE_EC, EcSpaceHandler, EcSpaceSetup, sc); - if (ACPI_FAILURE(rv)) { - aprint_error("%s: unable to install address space handler: %s\n", - sc->sc_dev.dv_xname, AcpiFormatException(rv)); - goto out2; - } +static void +acpiec_write_command(struct acpiec_softc *sc, uint8_t cmd) +{ + bus_space_write_1(sc->sc_csr_st, sc->sc_csr_sh, 0, cmd); +} - return_VOID; - out2: - (void)AcpiRemoveGpeHandler(NULL, sc->sc_gpebit, EcGpeHandler); +static ACPI_STATUS +acpiec_space_setup(ACPI_HANDLE region, UINT32 func, void *arg, + void **region_arg) +{ + if (func == ACPI_REGION_DEACTIVATE) + *region_arg = NULL; + else + *region_arg = arg; - out: - acpi_resource_cleanup(&res); - return_VOID; + return AE_OK; } static void -EcGpeQueryHandler(void *Context) +acpiec_lock(device_t dv) { - struct acpi_ec_softc *sc = Context; - UINT8 Data = 0; + struct acpiec_softc *sc = device_private(dv); ACPI_STATUS rv; - char qxx[5]; - ACPI_FUNCTION_TRACE(__FUNCTION__); - - for (;;) { - /* - * Check EC_SCI. - * - * Bail out if the EC_SCI bit of the status register is not - * set. Note that this function should only be called when - * this bit is set (polling is used to detect IBE/OBF events). - * - * It is safe to do this without locking the controller, as - * it's OK to call EcQuery when there's no data ready; in the - * worst case we should just find nothing waiting for us and - * bail. - */ - if ((EC_CSR_READ(sc) & EC_EVENT_SCI) == 0) - break; - - EcLock(sc); - - /* - * Find out why the EC is signalling us - */ - rv = EcQuery(sc, &Data); - - EcUnlock(sc); - - /* - * If we failed to get anything from the EC, give up. - */ - if (ACPI_FAILURE(rv)) { - printf("%s: GPE query failed: %s\n", - sc->sc_dev.dv_xname, AcpiFormatException(rv)); - break; - } + mutex_enter(&sc->sc_access_mtx); - /* - * Evaluate _Qxx to respond to the controller. - */ - snprintf(qxx, sizeof(qxx), "_Q%02X", Data); - rv = AcpiEvaluateObject(sc->sc_handle, qxx, - NULL, NULL); - - /* - * Ignore spurious query requests. - */ - if (ACPI_FAILURE(rv) && - (Data != 0 || rv != AE_NOT_FOUND)) { - printf("%s: evaluation of GPE query method %s " - "failed: %s\n", sc->sc_dev.dv_xname, qxx, + if (sc->sc_need_global_lock) { + rv = AcpiAcquireGlobalLock(EC_LOCK_TIMEOUT, &sc->sc_global_lock); + if (rv != AE_OK) { + aprint_error_dev(dv, "failed to acquire global lock: %s\n", AcpiFormatException(rv)); + return; } } - - /* I know I request Level trigger cleanup */ - rv = AcpiClearGpe(NULL, sc->sc_gpebit, ACPI_NOT_ISR); - if (ACPI_FAILURE(rv)) - printf("%s: AcpiClearGpe failed: %s\n", sc->sc_dev.dv_xname, - AcpiFormatException(rv)); - - return_VOID; } -static UINT32 -EcGpeHandler(void *Context) +static void +acpiec_unlock(device_t dv) { - struct acpi_ec_softc *sc = Context; - uint32_t csrvalue; + struct acpiec_softc *sc = device_private(dv); ACPI_STATUS rv; - /* - * If EC is locked, the intr must process EcRead/Write wait only. - * Query request must be pending. - */ - simple_lock(&sc->sc_slock); - if (sc->sc_flags & EC_F_TRANSACTION) { - csrvalue = EC_CSR_READ(sc); - sc->sc_flags |= EC_F_PENDQUERY; - - if ((csrvalue & EC_FLAG_OUTPUT_BUFFER) != 0 || - (csrvalue & EC_FLAG_INPUT_BUFFER) == 0) { - sc->sc_csrvalue = csrvalue; - wakeup(&sc->sc_csrvalue); + if (sc->sc_need_global_lock) { + rv = AcpiReleaseGlobalLock(sc->sc_global_lock); + if (rv != AE_OK) { + aprint_error_dev(dv, "failed to release global lock: %s\n", + AcpiFormatException(rv)); } - simple_unlock(&sc->sc_slock); - } else { - simple_unlock(&sc->sc_slock); - /* Enqueue GpeQuery handler. */ - rv = AcpiOsQueueForExecution(OSD_PRIORITY_HIGH, - EcGpeQueryHandler, Context); - if (ACPI_FAILURE(rv)) - printf("%s: failed to enqueue query handler: %s\n", - sc->sc_dev.dv_xname, AcpiFormatException(rv)); + } + mutex_exit(&sc->sc_access_mtx); +} + +static ACPI_STATUS +acpiec_read(device_t dv, uint8_t addr, uint8_t *val) +{ + struct acpiec_softc *sc = device_private(dv); + int i, timeouts = 0; + + acpiec_lock(dv); + mutex_enter(&sc->sc_mtx); + +retry: + sc->sc_cur_addr = addr; + sc->sc_state = EC_STATE_READ; + + for (i = 0; i < EC_POLL_TIMEOUT; ++i) { + acpiec_gpe_state_maschine(dv); + if (sc->sc_state == EC_STATE_FREE) + goto done; + delay(1); } - return 0; /* XXX not yet used in ACPI-CA */ + if (cold || acpiec_cold) { + while (sc->sc_state != EC_STATE_FREE) { + delay(1); + acpiec_gpe_state_maschine(dv); + } + } else while (cv_timedwait(&sc->sc_cv, &sc->sc_mtx, hz)) { + mutex_exit(&sc->sc_mtx); + AcpiClearGpe(sc->sc_gpeh, sc->sc_gpebit, ACPI_NOT_ISR); + mutex_enter(&sc->sc_mtx); + if (++timeouts < 5) + goto retry; + mutex_exit(&sc->sc_mtx); + acpiec_unlock(dv); + aprint_error_dev(dv, "command takes over 5sec...\n"); + return AE_ERROR; + } + +done: + *val = sc->sc_cur_val; + + mutex_exit(&sc->sc_mtx); + acpiec_unlock(dv); + return AE_OK; } static ACPI_STATUS -EcSpaceSetup(ACPI_HANDLE Region, UINT32 Function, void *Context, - void **RegionContext) +acpiec_write(device_t dv, uint8_t addr, uint8_t val) { + struct acpiec_softc *sc = device_private(dv); + int i, timeouts = 0; - ACPI_FUNCTION_TRACE(__FUNCTION__); + acpiec_lock(dv); + mutex_enter(&sc->sc_mtx); - /* - * Just pass the context through, there's nothing to do here. - */ - if (Function == ACPI_REGION_DEACTIVATE) - *RegionContext = NULL; - else - *RegionContext = Context; +retry: + sc->sc_cur_addr = addr; + sc->sc_cur_val = val; + sc->sc_state = EC_STATE_WRITE; - return_ACPI_STATUS(AE_OK); + for (i = 0; i < EC_POLL_TIMEOUT; ++i) { + acpiec_gpe_state_maschine(dv); + if (sc->sc_state == EC_STATE_FREE) + goto done; + delay(1); + } + + if (cold || acpiec_cold) { + while (sc->sc_state != EC_STATE_FREE) { + delay(1); + acpiec_gpe_state_maschine(dv); + } + } else while (cv_timedwait(&sc->sc_cv, &sc->sc_mtx, hz)) { + mutex_exit(&sc->sc_mtx); + AcpiClearGpe(sc->sc_gpeh, sc->sc_gpebit, ACPI_NOT_ISR); + mutex_enter(&sc->sc_mtx); + if (++timeouts < 5) + goto retry; + mutex_exit(&sc->sc_mtx); + acpiec_unlock(dv); + aprint_error_dev(dv, "command takes over 5sec...\n"); + return AE_ERROR; + } + +done: + mutex_exit(&sc->sc_mtx); + acpiec_unlock(dv); + return AE_OK; } static ACPI_STATUS -EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width, - ACPI_INTEGER *Value, void *Context, void *RegionContext) +acpiec_space_handler(UINT32 func, ACPI_PHYSICAL_ADDRESS paddr, + UINT32 width, ACPI_INTEGER *value, void *arg, void *region_arg) { - struct acpi_ec_softc *sc = Context; - ACPI_STATUS rv = AE_OK; - EC_REQUEST EcRequest; - int i; + device_t dv; + struct acpiec_softc *sc; + ACPI_STATUS rv; + uint8_t addr, reg; + unsigned int i; - ACPI_FUNCTION_TRACE_U32(__FUNCTION__, (UINT32)Address); + if (paddr > 0xff || width % 8 != 0 || value == NULL || arg == NULL || + paddr + width / 8 > 0xff) + return AE_BAD_PARAMETER; - if ((Address > 0xFF) || (width % 8 != 0) || (Value == NULL) || - (Context == NULL)) - return_ACPI_STATUS(AE_BAD_PARAMETER); + addr = paddr; + dv = arg; + sc = device_private(dv); - switch (Function) { + rv = AE_OK; + + switch (func) { case ACPI_READ: - EcRequest.Command = EC_COMMAND_READ; - EcRequest.Address = Address; - (*Value) = 0; + *value = 0; + for (i = 0; i < width; i += 8, ++addr) { + rv = acpiec_read(dv, addr, ®); + if (rv != AE_OK) + break; + *value |= (ACPI_INTEGER)reg << i; + } break; - case ACPI_WRITE: - EcRequest.Command = EC_COMMAND_WRITE; - EcRequest.Address = Address; + for (i = 0; i < width; i += 8, ++addr) { + reg = (*value >>i) & 0xff; + rv = acpiec_write(dv, addr, reg); + if (rv != AE_OK) + break; + } break; - default: - printf("%s: invalid Address Space function: %d\n", - sc->sc_dev.dv_xname, Function); - return_ACPI_STATUS(AE_BAD_PARAMETER); + aprint_error("%s: invalid Address Space function called: %x\n", + device_xname(dv), (unsigned int)func); + return AE_BAD_PARAMETER; } - /* - * Perform the transaction. - */ - for (i = 0; i < width; i += 8) { - if (Function == ACPI_READ) - EcRequest.Data = 0; - else - EcRequest.Data = (UINT8)((*Value) >> i); - - rv = EcTransaction(sc, &EcRequest); - if (ACPI_FAILURE(rv)) - break; - - (*Value) |= (UINT32)EcRequest.Data << i; - if (++EcRequest.Address == 0) - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - - return_ACPI_STATUS(rv); + return rv; } -static ACPI_STATUS -EcWaitEventIntr(struct acpi_ec_softc *sc, EC_EVENT Event) +static void +acpiec_gpe_query(void *arg) { - EC_STATUS EcStatus; + device_t dv = arg; + struct acpiec_softc *sc = device_private(dv); + uint8_t reg; + char qxx[5]; + ACPI_STATUS rv; int i; - ACPI_FUNCTION_TRACE_U32(__FUNCTION__, (UINT32)Event); - - /* XXX Need better test for "yes, you have interrupts". */ - if (cold) - return_ACPI_STATUS(EcWaitEvent(sc, Event)); +loop: + mutex_enter(&sc->sc_mtx); - if (EcIsLocked(sc) == 0) - printf("%s: EcWaitEventIntr called without EC lock!\n", - sc->sc_dev.dv_xname); + if (sc->sc_got_sci == false) + cv_wait(&sc->sc_cv_sci, &sc->sc_mtx); + mutex_exit(&sc->sc_mtx); - EcStatus = EC_CSR_READ(sc); + acpiec_lock(dv); + mutex_enter(&sc->sc_mtx); - /* Too long? */ - for (i = 0; i < 10; i++) { - /* Check EC status against the desired event. */ - if ((Event == EC_EVENT_OUTPUT_BUFFER_FULL) && - (EcStatus & EC_FLAG_OUTPUT_BUFFER) != 0) - return_ACPI_STATUS(AE_OK); + /* The Query command can always be issued, so be defensive here. */ + sc->sc_got_sci = false; + sc->sc_state = EC_STATE_QUERY; - if ((Event == EC_EVENT_INPUT_BUFFER_EMPTY) && - (EcStatus & EC_FLAG_INPUT_BUFFER) == 0) - return_ACPI_STATUS(AE_OK); - - sc->sc_csrvalue = 0; - /* XXXJRT Sleeping with a lock held? */ - if (tsleep(&sc->sc_csrvalue, 0, "EcWait", (hz + 99) / 100) - != EWOULDBLOCK) - EcStatus = sc->sc_csrvalue; - else - EcStatus = EC_CSR_READ(sc); + for (i = 0; i < EC_POLL_TIMEOUT; ++i) { + acpiec_gpe_state_maschine(dv); + if (sc->sc_state == EC_STATE_FREE) + goto done; + delay(1); } - return_ACPI_STATUS(AE_ERROR); -} -static ACPI_STATUS -EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT Event) -{ - EC_STATUS EcStatus; - UINT32 i = 0; + cv_wait(&sc->sc_cv, &sc->sc_mtx); - if (EcIsLocked(sc) == 0) - printf("%s: EcWaitEvent called without EC lock!\n", - sc->sc_dev.dv_xname); +done: + reg = sc->sc_cur_val; - /* - * Stall 10us: - * ---------- - * Stall for 10 microseconds before reading the status register - * for the first time. This allows the EC to set the IBF/OBF - * bit to its proper state. - */ - AcpiOsStall(10); + mutex_exit(&sc->sc_mtx); + acpiec_unlock(dv); + + if (reg == 0) + goto loop; /* Spurious query result */ /* - * Wait For Event: - * --------------- - * Poll the EC status register to detect completion of the last - * command. Wait up to 100ms (in 100us chunks) for this to occur. + * Evaluate _Qxx to respond to the controller. */ - for (i = 0; i < 1000; i++) { - EcStatus = EC_CSR_READ(sc); - - if ((Event == EC_EVENT_OUTPUT_BUFFER_FULL) && - (EcStatus & EC_FLAG_OUTPUT_BUFFER) != 0) - return AE_OK; - - if ((Event == EC_EVENT_INPUT_BUFFER_EMPTY) && - (EcStatus & EC_FLAG_INPUT_BUFFER) == 0) - return AE_OK; - - AcpiOsStall(10); + snprintf(qxx, sizeof(qxx), "_Q%02X", (unsigned int)reg); + rv = AcpiEvaluateObject(sc->sc_ech, qxx, NULL, NULL); + if (rv != AE_OK && rv != AE_NOT_FOUND) { + aprint_error("%s: GPE query method %s failed: %s", + device_xname(dv), qxx, AcpiFormatException(rv)); } - return AE_ERROR; + goto loop; } -static ACPI_STATUS -EcQuery(struct acpi_ec_softc *sc, UINT8 *Data) +static void +acpiec_gpe_state_maschine(device_t dv) { - ACPI_STATUS rv; + struct acpiec_softc *sc = device_private(dv); + uint8_t reg; - if (EcIsLocked(sc) == 0) - printf("%s: EcQuery called without EC lock!\n", - sc->sc_dev.dv_xname); + reg = acpiec_read_status(sc); - EC_CSR_WRITE(sc, EC_COMMAND_QUERY); - rv = EcWaitEventIntr(sc, EC_EVENT_OUTPUT_BUFFER_FULL); - if (ACPI_SUCCESS(rv)) - *Data = EC_DATA_READ(sc); + if (reg & EC_STATUS_SCI) + sc->sc_got_sci = true; - if (ACPI_FAILURE(rv)) - printf("%s: timed out waiting for EC to respond to " - "EC_COMMAND_QUERY\n", sc->sc_dev.dv_xname); - - return rv; -} + switch (sc->sc_state) { + case EC_STATE_QUERY: + if ((reg & EC_STATUS_IBF) != 0) + break; /* Nothing of interest here. */ + acpiec_write_command(sc, EC_COMMAND_QUERY); + sc->sc_state = EC_STATE_QUERY_VAL; + break; -static ACPI_STATUS -EcTransaction(struct acpi_ec_softc *sc, EC_REQUEST *EcRequest) -{ - ACPI_STATUS rv; + case EC_STATE_QUERY_VAL: + if ((reg & EC_STATUS_OBF) == 0) + break; /* Nothing of interest here. */ - EcLock(sc); + sc->sc_cur_val = acpiec_read_data(sc); + sc->sc_state = EC_STATE_FREE; - /* - * Perform the transaction, and make sure GPE is enabled before - * doing so. - */ - rv = AcpiEnableGpe(NULL, sc->sc_gpebit, ACPI_NOT_ISR); - if (ACPI_FAILURE(rv)) - return rv; - switch (EcRequest->Command) { - case EC_COMMAND_READ: - rv = EcRead(sc, EcRequest->Address, &(EcRequest->Data)); + cv_signal(&sc->sc_cv); break; - case EC_COMMAND_WRITE: - rv = EcWrite(sc, EcRequest->Address, &(EcRequest->Data)); - break; + case EC_STATE_READ: + if ((reg & EC_STATUS_IBF) != 0) + break; /* Nothing of interest here. */ - default: - rv = AE_SUPPORT; + acpiec_write_command(sc, EC_COMMAND_READ); + sc->sc_state = EC_STATE_READ_ADDR; break; - } - EcUnlock(sc); + case EC_STATE_READ_ADDR: + if ((reg & EC_STATUS_IBF) != 0) + break; /* Nothing of interest here. */ - return rv; -} + acpiec_write_data(sc, sc->sc_cur_addr); + sc->sc_state = EC_STATE_READ_VAL; + break; -static ACPI_STATUS -EcRead(struct acpi_ec_softc *sc, UINT8 Address, UINT8 *Data) -{ - ACPI_STATUS rv; + case EC_STATE_READ_VAL: + if ((reg & EC_STATUS_OBF) == 0) + break; /* Nothing of interest here. */ + sc->sc_cur_val = acpiec_read_data(sc); + sc->sc_state = EC_STATE_FREE; - if (EcIsLocked(sc) == 0) - printf("%s: EcRead called without EC lock!\n", - sc->sc_dev.dv_xname); + cv_signal(&sc->sc_cv); + break; - /* EcBurstEnable(EmbeddedController); */ + case EC_STATE_WRITE: + if ((reg & EC_STATUS_IBF) != 0) + break; /* Nothing of interest here. */ - EC_CSR_WRITE(sc, EC_COMMAND_READ); - if ((rv = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY)) != - AE_OK) { - printf("%s: EcRead: timeout waiting for EC to process " - "read command\n", sc->sc_dev.dv_xname); - return rv; - } + acpiec_write_command(sc, EC_COMMAND_WRITE); + sc->sc_state = EC_STATE_WRITE_ADDR; + break; - EC_DATA_WRITE(sc, Address); - if ((rv = EcWaitEventIntr(sc, EC_EVENT_OUTPUT_BUFFER_FULL)) != - AE_OK) { - printf("%s: EcRead: timeout waiting for EC to send data\n", - sc->sc_dev.dv_xname); - return rv; - } + case EC_STATE_WRITE_ADDR: + if ((reg & EC_STATUS_IBF) != 0) + break; /* Nothing of interest here. */ + acpiec_write_data(sc, sc->sc_cur_addr); + sc->sc_state = EC_STATE_WRITE_VAL; + break; - (*Data) = EC_DATA_READ(sc); + case EC_STATE_WRITE_VAL: + if ((reg & EC_STATUS_IBF) != 0) + break; /* Nothing of interest here. */ + sc->sc_state = EC_STATE_FREE; + cv_signal(&sc->sc_cv); - /* EcBurstDisable(EmbeddedController); */ + acpiec_write_data(sc, sc->sc_cur_val); + break; - return AE_OK; + case EC_STATE_FREE: + if (sc->sc_got_sci) + cv_signal(&sc->sc_cv_sci); + break; + default: + panic("invalid state"); + } } -static ACPI_STATUS -EcWrite(struct acpi_ec_softc *sc, UINT8 Address, UINT8 *Data) +static UINT32 +acpiec_gpe_handler(void *arg) { - ACPI_STATUS rv; + device_t dv = arg; + struct acpiec_softc *sc = device_private(dv); - if (EcIsLocked(sc) == 0) - printf("%s: EcWrite called without EC lock!\n", - sc->sc_dev.dv_xname); + AcpiClearGpe(sc->sc_gpeh, sc->sc_gpebit, ACPI_ISR); - /* EcBurstEnable(EmbeddedController); */ + mutex_enter(&sc->sc_mtx); + acpiec_gpe_state_maschine(dv); + mutex_exit(&sc->sc_mtx); - EC_CSR_WRITE(sc, EC_COMMAND_WRITE); - if ((rv = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY)) != - AE_OK) { - printf("%s: EcWrite: timeout waiting for EC to process " - "write command\n", sc->sc_dev.dv_xname); - return rv; - } - - EC_DATA_WRITE(sc, Address); - if ((rv = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY)) != - AE_OK) { - printf("%s: EcWrite: timeout waiting for EC to process " - "address\n", sc->sc_dev.dv_xname); - return rv; - } - - EC_DATA_WRITE(sc, *Data); - if ((rv = EcWaitEventIntr(sc, EC_EVENT_INPUT_BUFFER_EMPTY)) != - AE_OK) { - printf("%s: EcWrite: timeout waiting for EC to process " - "data\n", sc->sc_dev.dv_xname); - return rv; - } - - /* EcBurstDisable(EmbeddedController); */ - - return AE_OK; + return 0; } diff --git a/sys/dev/acpi/acpi_ecreg.h b/sys/dev/acpi/acpi_ecreg.h index 3562febf905..e69de29bb2d 100644 --- a/sys/dev/acpi/acpi_ecreg.h +++ b/sys/dev/acpi/acpi_ecreg.h @@ -1,161 +0,0 @@ -/* $NetBSD: acpi_ecreg.h,v 1.3 2005/12/11 12:21:01 christos Exp $ */ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights - * reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -/* - * EC_COMMAND: - * ----------- - */ -typedef UINT8 EC_COMMAND; - -#define EC_COMMAND_UNKNOWN ((EC_COMMAND) 0x00) -#define EC_COMMAND_READ ((EC_COMMAND) 0x80) -#define EC_COMMAND_WRITE ((EC_COMMAND) 0x81) -#define EC_COMMAND_BURST_ENABLE ((EC_COMMAND) 0x82) -#define EC_COMMAND_BURST_DISABLE ((EC_COMMAND) 0x83) -#define EC_COMMAND_QUERY ((EC_COMMAND) 0x84) - -/* - * EC_STATUS: - * ---------- - * The encoding of the EC status register is illustrated below. - * Note that a set bit (1) indicates the property is TRUE - * (e.g. if bit 0 is set then the output buffer is full). - * +-+-+-+-+-+-+-+-+ - * |7|6|5|4|3|2|1|0| - * +-+-+-+-+-+-+-+-+ - * | | | | | | | | - * | | | | | | | +- Output Buffer Full? - * | | | | | | +--- Input Buffer Full? - * | | | | | +----- <reserved> - * | | | | +------- Data Register is Command Byte? - * | | | +--------- Burst Mode Enabled? - * | | +----------- SCI Event? - * | +------------- SMI Event? - * +--------------- <Reserved> - * - */ -typedef UINT8 EC_STATUS; - -#define EC_FLAG_OUTPUT_BUFFER ((EC_STATUS) 0x01) -#define EC_FLAG_INPUT_BUFFER ((EC_STATUS) 0x02) -#define EC_FLAG_BURST_MODE ((EC_STATUS) 0x10) -#define EC_FLAG_SCI ((EC_STATUS) 0x20) - -/* - * EC_EVENT: - * --------- - */ -typedef UINT8 EC_EVENT; - -#define EC_EVENT_UNKNOWN ((EC_EVENT) 0x00) -#define EC_EVENT_OUTPUT_BUFFER_FULL ((EC_EVENT) 0x01) -#define EC_EVENT_INPUT_BUFFER_EMPTY ((EC_EVENT) 0x02) -#define EC_EVENT_SCI ((EC_EVENT) 0x20) diff --git a/sys/dev/acpi/acpi_lid.c b/sys/dev/acpi/acpi_lid.c index 447952bc966..805fe7eda6b 100644 --- a/sys/dev/acpi/acpi_lid.c +++ b/sys/dev/acpi/acpi_lid.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_lid.c,v 1.21 2006/11/16 01:32:47 christos Exp $ */ +/* $NetBSD: acpi_lid.c,v 1.22 2007/12/09 20:27:53 jmcneill Exp $ */ /* * Copyright 2001, 2003 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_lid.c,v 1.21 2006/11/16 01:32:47 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_lid.c,v 1.22 2007/12/09 20:27:53 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -72,6 +72,8 @@ CFATTACH_DECL(acpilid, sizeof(struct acpilid_softc), static void acpilid_status_changed(void *); static void acpilid_notify_handler(ACPI_HANDLE, UINT32, void *); +static bool acpilid_suspend(device_t); + /* * acpilid_match: * @@ -123,6 +125,30 @@ acpilid_attach(struct device *parent, struct device *self, void *aux) } acpi_set_wake_gpe(sc->sc_node->ad_handle); + + if (!pmf_device_register(self, acpilid_suspend, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); +} + +static void +acpilid_wake_event(struct acpilid_softc *sc, bool enable) +{ + ACPI_STATUS rv; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = enable ? 1 : 0; + + rv = AcpiEvaluateObject (sc->sc_node->ad_handle, "_PSW", + &ArgList, NULL); + if (ACPI_FAILURE(rv) && rv != AE_NOT_FOUND) + aprint_error_dev(&sc->sc_dev, + "unable to evaluate _PSW handler: %s\n", + AcpiFormatException(rv)); } /* @@ -163,7 +189,7 @@ acpilid_notify_handler(ACPI_HANDLE handle, UINT32 notify, printf("%s: received LidStatusChanged message\n", sc->sc_dev.dv_xname); #endif - rv = AcpiOsQueueForExecution(OSD_PRIORITY_LO, + rv = AcpiOsExecute(OSL_NOTIFY_HANDLER, acpilid_status_changed, sc); if (ACPI_FAILURE(rv)) printf("%s: WARNING: unable to queue lid change " @@ -176,3 +202,18 @@ acpilid_notify_handler(ACPI_HANDLE handle, UINT32 notify, sc->sc_dev.dv_xname, notify); } } + +static bool +acpilid_suspend(device_t dv) +{ + struct acpilid_softc *sc = device_private(dv); + ACPI_INTEGER status; + ACPI_STATUS rv; + + rv = acpi_eval_integer(sc->sc_node->ad_handle, "_LID", &status); + if (ACPI_FAILURE(rv)) + return true; + + acpilid_wake_event(sc, status == 0); + return true; +} diff --git a/sys/dev/acpi/acpi_madt.c b/sys/dev/acpi/acpi_madt.c index d3b553554dd..bc398e29672 100644 --- a/sys/dev/acpi/acpi_madt.c +++ b/sys/dev/acpi/acpi_madt.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_madt.c,v 1.17 2006/11/16 01:32:47 christos Exp $ */ +/* $NetBSD: acpi_madt.c,v 1.18 2007/12/09 20:27:53 jmcneill Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_madt.c,v 1.17 2006/11/16 01:32:47 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_madt.c,v 1.18 2007/12/09 20:27:53 jmcneill Exp $"); #include <sys/param.h> #include <sys/ioctl.h> @@ -74,8 +74,7 @@ acpi_madt_map(void) if (madt_header != NULL) return AE_ALREADY_EXISTS; - rv = AcpiGetFirmwareTable(APIC_SIG, 1, ACPI_LOGICAL_ADDRESSING, - &madt_header); + rv = AcpiGetTable(ACPI_SIG_MADT, 1, &madt_header); if (ACPI_FAILURE(rv)) return rv; @@ -90,7 +89,6 @@ acpi_madt_map(void) void acpi_madt_unmap(void) { - AcpiOsUnmapMemory(madt_header, madt_header->Length); madt_header = NULL; } @@ -161,15 +159,15 @@ acpi_print_platint(MADT_INTERRUPT_SOURCE *p) #endif void -acpi_madt_walk(ACPI_STATUS (*func)(APIC_HEADER *, void *), void *aux) +acpi_madt_walk(ACPI_STATUS (*func)(ACPI_SUBTABLE_HEADER *, void *), void *aux) { char *madtend, *where; - APIC_HEADER *hdrp; + ACPI_SUBTABLE_HEADER *hdrp; madtend = (char *)madt_header + madt_header->Length; - where = (char *)madt_header + sizeof (MULTIPLE_APIC_TABLE); + where = (char *)madt_header + sizeof (ACPI_TABLE_MADT); while (where < madtend) { - hdrp = (APIC_HEADER *)where; + hdrp = (ACPI_SUBTABLE_HEADER *)where; if (ACPI_FAILURE(func(hdrp, aux))) break; where += hdrp->Length; @@ -193,34 +191,34 @@ acpi_madt_print(void) } static ACPI_STATUS -acpi_madt_print_entry(APIC_HEADER *hdrp, void *aux) +acpi_madt_print_entry(ACPI_SUBTABLE_HEADER *hdrp, void *aux) { switch (hdrp->Type) { - case APIC_PROCESSOR: + case ACPI_MADT_TYPE_LOCAL_APIC: acpi_print_apic_proc((void *)hdrp); break; - case APIC_IO: + case ACPI_MADT_TYPE_IO_APIC: acpi_print_ioapic((void *)hdrp); break; - case APIC_XRUPT_OVERRIDE: + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: acpi_print_intsrc_ovr((void *)hdrp); break; - case APIC_NMI: + case ACPI_MADT_TYPE_NMI_SOURCE: acpi_print_intsrc_nmi((void *)hdrp); break; - case APIC_LOCAL_NMI: + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: acpi_print_lapic_nmi((void *)hdrp); break; - case APIC_ADDRESS_OVERRIDE: + case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: acpi_print_lapic_addr_ovr((void *)hdrp); break; - case APIC_IO_SAPIC: + case ACPI_MADT_TYPE_IO_SAPIC: acpi_print_iosapic((void *)hdrp); break; - case APIC_LOCAL_SAPIC: + case ACPI_MADT_TYPE_LOCAL_SAPIC: acpi_print_local_sapic((void *)hdrp); break; - case APIC_XRUPT_SOURCE: + case ACPI_MADT_TYPE_INTERRUPT_SOURCE: acpi_print_platint((void *)hdrp); break; default: diff --git a/sys/dev/acpi/acpi_madt.h b/sys/dev/acpi/acpi_madt.h index 5702e76b0d8..f8588316e53 100644 --- a/sys/dev/acpi/acpi_madt.h +++ b/sys/dev/acpi/acpi_madt.h @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_madt.h,v 1.6 2005/12/11 12:21:01 christos Exp $ */ +/* $NetBSD: acpi_madt.h,v 1.7 2007/12/09 20:27:53 jmcneill Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -41,4 +41,4 @@ ACPI_STATUS acpi_madt_map(void); void acpi_madt_unmap(void); -void acpi_madt_walk(ACPI_STATUS (*)(APIC_HEADER *, void *), void *); +void acpi_madt_walk(ACPI_STATUS (*)(ACPI_SUBTABLE_HEADER *, void *), void *); diff --git a/sys/dev/acpi/acpi_pci_link.c b/sys/dev/acpi/acpi_pci_link.c index 15e48da0883..5d117c0cf2a 100644 --- a/sys/dev/acpi/acpi_pci_link.c +++ b/sys/dev/acpi/acpi_pci_link.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_pci_link.c,v 1.9 2007/11/07 15:29:15 joerg Exp $ */ +/* $NetBSD: acpi_pci_link.c,v 1.10 2007/12/09 20:27:53 jmcneill Exp $ */ /*- * Copyright (c) 2002 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_pci_link.c,v 1.9 2007/11/07 15:29:15 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_pci_link.c,v 1.10 2007/12/09 20:27:53 jmcneill Exp $"); #include "opt_acpi.h" #include <sys/param.h> @@ -384,7 +384,7 @@ link_valid_irq(struct link *link, int irq) * For links routed via an ISA interrupt, if the SCI is routed via * an ISA interrupt, the SCI is always treated as a valid IRQ. */ - if (link->l_isa_irq && AcpiGbl_FADT->SciInt == irq && + if (link->l_isa_irq && AcpiGbl_FADT.SciInterrupt == irq && irq < NUM_ISA_INTERRUPTS) return (TRUE); @@ -1039,7 +1039,7 @@ acpi_pci_link_choose_irq(struct acpi_pci_link_softc *sc, struct link *link) * interrupt as a fallback. */ if (link->l_isa_irq && !PCI_INTERRUPT_VALID(best_irq)) { - pos_irq = AcpiGbl_FADT->SciInt; + pos_irq = AcpiGbl_FADT.SciInterrupt; pos_weight = pci_link_interrupt_weights[pos_irq]; if (pos_weight < best_weight) { best_weight = pos_weight; @@ -1136,8 +1136,8 @@ acpi_pci_link_init(struct acpi_pci_link_softc *sc) * if we are using the APIC, we also shouldn't be having any PCI * interrupts routed via ISA IRQs, so this is probably ok. */ - if (AcpiGbl_FADT->SciInt < NUM_ISA_INTERRUPTS) - pci_link_bios_isa_irqs |= (1 << AcpiGbl_FADT->SciInt); + if (AcpiGbl_FADT.SciInterrupt < NUM_ISA_INTERRUPTS) + pci_link_bios_isa_irqs |= (1 << AcpiGbl_FADT.SciInterrupt); sc->pl_powerhook = powerhook_establish(acpipcilinkname, acpi_pci_link_resume, sc); diff --git a/sys/dev/acpi/acpi_quirks.c b/sys/dev/acpi/acpi_quirks.c index 972463330bf..14acc6135ce 100644 --- a/sys/dev/acpi/acpi_quirks.c +++ b/sys/dev/acpi/acpi_quirks.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_quirks.c,v 1.8 2006/09/23 17:04:26 fvdl Exp $ */ +/* $NetBSD: acpi_quirks.c,v 1.9 2007/12/09 20:27:53 jmcneill Exp $ */ /* * Copyright 2002 Wasabi Systems, Inc. @@ -37,7 +37,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_quirks.c,v 1.8 2006/09/23 17:04:26 fvdl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_quirks.c,v 1.9 2007/12/09 20:27:53 jmcneill Exp $"); #include "opt_acpi.h" @@ -58,9 +58,9 @@ static int acpi_rev_cmp(uint32_t, uint32_t, int); * XXX add more */ static struct acpi_quirk acpi_quirks[] = { - { ACPI_TABLE_FADT, "PTLTD ", 0x06040000, AQ_LTE, " FACP ", + { ACPI_SIG_FADT, "PTLTD ", 0x06040000, AQ_LTE, " FACP ", ACPI_QUIRK_BROKEN }, - { ACPI_TABLE_FADT, "NVIDIA", 0x06040000, AQ_EQ, "CK8 ", + { ACPI_SIG_FADT, "NVIDIA", 0x06040000, AQ_EQ, "CK8 ", ACPI_QUIRK_IRQ0 }, }; @@ -106,26 +106,27 @@ acpi_find_quirks(void) { int i, nquirks; struct acpi_quirk *aqp; - ACPI_TABLE_HEADER *hdr; + ACPI_TABLE_HEADER fadt, dsdt, xsdt, *hdr; nquirks = sizeof(acpi_quirks) / sizeof(struct acpi_quirk); + if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_FADT, 0, &fadt))) + memset(&fadt, 0, sizeof(fadt)); + if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_DSDT, 0, &dsdt))) + memset(&dsdt, 0, sizeof(dsdt)); + if (ACPI_FAILURE(AcpiGetTableHeader(ACPI_SIG_XSDT, 0, &xsdt))) + memset(&xsdt, 0, sizeof(xsdt)); + for (i = 0; i < nquirks; i++) { aqp = &acpi_quirks[i]; - /* XXX AcpiGetTableHeader doesn't work for some reason */ - switch (aqp->aq_tabletype) { - case ACPI_TABLE_DSDT: - hdr = (ACPI_TABLE_HEADER *)AcpiGbl_DSDT; - break; - case ACPI_TABLE_XSDT: - hdr = (ACPI_TABLE_HEADER *)AcpiGbl_XSDT; - break; - case ACPI_TABLE_FADT: - hdr = (ACPI_TABLE_HEADER *)AcpiGbl_FADT; - break; - default: + if (!strncmp(aqp->aq_tabletype, ACPI_SIG_DSDT, 4)) + hdr = &dsdt; + else if (!strncmp(aqp->aq_tabletype, ACPI_SIG_XSDT, 4)) + hdr = &xsdt; + else if (!strncmp(aqp->aq_tabletype, ACPI_SIG_FADT, 4)) + hdr = &fadt; + else continue; - } if (strncmp(aqp->aq_oemid, hdr->OemId, strlen(aqp->aq_oemid))) continue; if (acpi_rev_cmp(aqp->aq_oemrev, hdr->OemRevision, diff --git a/sys/dev/acpi/acpi_tz.c b/sys/dev/acpi/acpi_tz.c index 53c00901617..2fc7e3fe24d 100644 --- a/sys/dev/acpi/acpi_tz.c +++ b/sys/dev/acpi/acpi_tz.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_tz.c,v 1.31 2007/12/08 23:01:30 jmcneill Exp $ */ +/* $NetBSD: acpi_tz.c,v 1.32 2007/12/09 20:27:53 jmcneill Exp $ */ /* * Copyright (c) 2003 Jared D. McNeill <jmcneill@invisible.ca> @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_tz.c,v 1.31 2007/12/08 23:01:30 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_tz.c,v 1.32 2007/12/09 20:27:53 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -200,6 +200,9 @@ acpitz_attach(struct device *parent, struct device *self, void *aux) acpitz_init_envsys(sc); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error(": couldn't establish power handler\n"); + callout_schedule(&sc->sc_callout, sc->sc_zone.tzp * hz / 10); } @@ -523,7 +526,7 @@ acpitz_notify_handler(ACPI_HANDLE hdl, UINT32 notify, void *opaque) KASSERT(func != NULL); - rv = AcpiOsQueueForExecution(OSD_PRIORITY_LO, func, sc); + rv = AcpiOsExecute(OSL_NOTIFY_HANDLER, func, sc); if (rv != AE_OK) printf("%s: unable to queue %s\n", sc->sc_dev.dv_xname, name); @@ -564,7 +567,7 @@ acpitz_tick(void *opaque) { struct acpitz_softc *sc = opaque; - AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpitz_get_status, sc); + AcpiOsExecute(OSL_NOTIFY_HANDLER, acpitz_get_status, sc); callout_schedule(&sc->sc_callout, sc->sc_zone.tzp * hz / 10); } diff --git a/sys/dev/acpi/acpica/OsdEnvironment.c b/sys/dev/acpi/acpica/OsdEnvironment.c index 8bc26e81981..dca9b7a0ab5 100644 --- a/sys/dev/acpi/acpica/OsdEnvironment.c +++ b/sys/dev/acpi/acpica/OsdEnvironment.c @@ -1,4 +1,4 @@ -/* $NetBSD: OsdEnvironment.c,v 1.1 2006/03/23 13:41:13 kochi Exp $ */ +/* $NetBSD: OsdEnvironment.c,v 1.2 2007/12/09 20:27:53 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: OsdEnvironment.c,v 1.1 2006/03/23 13:41:13 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: OsdEnvironment.c,v 1.2 2007/12/09 20:27:53 jmcneill Exp $"); #include <sys/types.h> @@ -100,8 +100,8 @@ AcpiOsTerminate(void) * * Obtain the Root ACPI talbe pointer (RSDP) */ -ACPI_STATUS -AcpiOsGetRootPointer(UINT32 Flags, ACPI_POINTER *PhysicalAddress) +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer(void) { - return acpi_OsGetRootPointer(Flags, PhysicalAddress); + return acpi_OsGetRootPointer(); } diff --git a/sys/dev/acpi/acpica/OsdHardware.c b/sys/dev/acpi/acpica/OsdHardware.c index b9e369809ff..c2c7258205c 100644 --- a/sys/dev/acpi/acpica/OsdHardware.c +++ b/sys/dev/acpi/acpica/OsdHardware.c @@ -1,4 +1,4 @@ -/* $NetBSD: OsdHardware.c,v 1.2 2006/05/14 21:42:26 elad Exp $ */ +/* $NetBSD: OsdHardware.c,v 1.3 2007/12/09 20:27:54 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: OsdHardware.c,v 1.2 2006/05/14 21:42:26 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: OsdHardware.c,v 1.3 2007/12/09 20:27:54 jmcneill Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -129,9 +129,9 @@ AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 *Value, UINT32 Width) void *LogicalAddress; ACPI_STATUS rv; - rv = AcpiOsMapMemory(Address, Width / 8, &LogicalAddress); - if (rv != AE_OK) - return rv; + LogicalAddress = AcpiOsMapMemory(Address, Width / 8); + if (LogicalAddress == NULL) + return AE_NOT_EXIST; switch (Width) { case 8: @@ -166,9 +166,9 @@ AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT32 Value, UINT32 Width) void *LogicalAddress; ACPI_STATUS rv; - rv = AcpiOsMapMemory(Address, Width / 8, &LogicalAddress); - if (rv != AE_OK) - return rv; + LogicalAddress = AcpiOsMapMemory(Address, Width / 8); + if (LogicalAddress == NULL) + return AE_NOT_FOUND; switch (Width) { case 8: diff --git a/sys/dev/acpi/acpica/OsdMemory.c b/sys/dev/acpi/acpica/OsdMemory.c index 718983fa97c..326a0496ce0 100644 --- a/sys/dev/acpi/acpica/OsdMemory.c +++ b/sys/dev/acpi/acpica/OsdMemory.c @@ -1,4 +1,4 @@ -/* $NetBSD: OsdMemory.c,v 1.1 2006/03/23 13:41:13 kochi Exp $ */ +/* $NetBSD: OsdMemory.c,v 1.2 2007/12/09 20:27:54 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: OsdMemory.c,v 1.1 2006/03/23 13:41:13 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: OsdMemory.c,v 1.2 2007/12/09 20:27:54 jmcneill Exp $"); #include <sys/param.h> #include <sys/malloc.h> @@ -58,12 +58,16 @@ MALLOC_DECLARE(M_ACPI); * * Map physical memory into the caller's address space. */ -ACPI_STATUS -AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length, - void **LogicalAddress) +void * +AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length) { + ACPI_STATUS Status; + void *LogicalAddress = NULL; - return acpi_md_OsMapMemory(PhysicalAddress, Length, LogicalAddress); + Status = acpi_md_OsMapMemory(PhysicalAddress, Length, &LogicalAddress); + if (ACPI_FAILURE (Status)) + return NULL; + return LogicalAddress; } /* @@ -139,3 +143,18 @@ AcpiOsWritable(void *Pointer, ACPI_SIZE Length) return acpi_md_OsWritable(Pointer, Length); } + +ACPI_STATUS +AcpiOsValidateInterface(char *Interface) +{ + + return AE_SUPPORT; +} + +ACPI_STATUS +AcpiOsValidateAddress(UINT8 SpaceId, ACPI_PHYSICAL_ADDRESS Address, + ACPI_SIZE Length) +{ + + return AE_OK; +} diff --git a/sys/dev/acpi/acpica/OsdSchedule.c b/sys/dev/acpi/acpica/OsdSchedule.c index a75b5f47f31..62a912f3519 100644 --- a/sys/dev/acpi/acpica/OsdSchedule.c +++ b/sys/dev/acpi/acpica/OsdSchedule.c @@ -1,4 +1,4 @@ -/* $NetBSD: OsdSchedule.c,v 1.1 2006/03/23 13:41:13 kochi Exp $ */ +/* $NetBSD: OsdSchedule.c,v 1.2 2007/12/09 20:27:54 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: OsdSchedule.c,v 1.1 2006/03/23 13:41:13 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: OsdSchedule.c,v 1.2 2007/12/09 20:27:54 jmcneill Exp $"); #include <sys/param.h> #include <sys/malloc.h> @@ -96,7 +96,7 @@ acpi_osd_sched_fini(void) * * Obtain the ID of the currently executing thread. */ -UINT32 +ACPI_THREAD_ID AcpiOsGetThreadId(void) { @@ -114,30 +114,28 @@ AcpiOsGetThreadId(void) * Schedule a procedure for deferred execution. */ ACPI_STATUS -AcpiOsQueueForExecution(UINT32 Priority, ACPI_OSD_EXEC_CALLBACK Function, +AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function, void *Context) { int pri; ACPI_FUNCTION_TRACE(__FUNCTION__); - switch (Priority) { - case OSD_PRIORITY_GPE: - pri = 3; + switch (Type) { + case OSL_GPE_HANDLER: + pri = 10; break; - - case OSD_PRIORITY_HIGH: - pri = 2; + case OSL_GLOBAL_LOCK_HANDLER: + case OSL_EC_POLL_HANDLER: + case OSL_EC_BURST_HANDLER: + pri = 5; break; - - case OSD_PRIORITY_MED: - pri = 1; + case OSL_NOTIFY_HANDLER: + pri = 3; break; - - case OSD_PRIORITY_LO: + case OSL_DEBUGGER_THREAD: pri = 0; break; - default: return_ACPI_STATUS(AE_BAD_PARAMETER); } diff --git a/sys/dev/acpi/acpica/OsdSynch.c b/sys/dev/acpi/acpica/OsdSynch.c index 5ea8c88f502..2819c1980c8 100644 --- a/sys/dev/acpi/acpica/OsdSynch.c +++ b/sys/dev/acpi/acpica/OsdSynch.c @@ -1,4 +1,4 @@ -/* $NetBSD: OsdSynch.c,v 1.8 2007/12/05 07:06:51 ad Exp $ */ +/* $NetBSD: OsdSynch.c,v 1.9 2007/12/09 20:27:54 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -69,7 +69,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: OsdSynch.c,v 1.8 2007/12/05 07:06:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: OsdSynch.c,v 1.9 2007/12/09 20:27:54 jmcneill Exp $"); #include <sys/param.h> #include <sys/malloc.h> @@ -165,7 +165,7 @@ AcpiOsDeleteSemaphore(ACPI_HANDLE Handle) * Wait for units from a semaphore. */ ACPI_STATUS -AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT16 Timeout) +AcpiOsWaitSemaphore(ACPI_SEMAPHORE Handle, UINT32 Units, UINT16 Timeout) { struct acpi_semaphore *as = (void *) Handle; ACPI_STATUS rv; @@ -181,6 +181,8 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT16 Timeout) if (as == NULL) return_ACPI_STATUS(AE_BAD_PARAMETER); + if (cold) + return_ACPI_STATUS(AE_OK); /* A timeout of 0xFFFF means "forever". */ if (Timeout == 0xFFFF) @@ -285,7 +287,7 @@ AcpiOsCreateLock(ACPI_HANDLE *OutHandle) * Delete a lock. */ void -AcpiOsDeleteLock(ACPI_HANDLE Handle) +AcpiOsDeleteLock(ACPI_SPINLOCK Handle) { struct acpi_lock *al = (void *) Handle; @@ -308,7 +310,7 @@ AcpiOsDeleteLock(ACPI_HANDLE Handle) * Acquire a lock. */ ACPI_NATIVE_UINT -AcpiOsAcquireLock(ACPI_HANDLE Handle) +AcpiOsAcquireLock(ACPI_SPINLOCK Handle) { struct acpi_lock *al = (void *) Handle; diff --git a/sys/dev/acpi/acpica/files.acpica b/sys/dev/acpi/acpica/files.acpica index 95c58e830e5..2e178ad153c 100644 --- a/sys/dev/acpi/acpica/files.acpica +++ b/sys/dev/acpi/acpica/files.acpica @@ -1,4 +1,4 @@ -# $NetBSD: files.acpica,v 1.12 2006/03/23 13:44:10 kochi Exp $ +# $NetBSD: files.acpica,v 1.13 2007/12/09 20:27:54 jmcneill Exp $ file dev/acpi/acpica/OsdEnvironment.c acpi file dev/acpi/acpica/OsdHardware.c acpi @@ -132,11 +132,9 @@ file dist/acpica/rsutils.c acpi file dist/acpica/rsxface.c acpi # tables/ -file dist/acpica/tbconvrt.c acpi -file dist/acpica/tbget.c acpi -file dist/acpica/tbgetall.c acpi +file dist/acpica/tbfadt.c acpi +file dist/acpica/tbfind.c acpi file dist/acpica/tbinstal.c acpi -file dist/acpica/tbrsdt.c acpi file dist/acpica/tbutils.c acpi file dist/acpica/tbxface.c acpi file dist/acpica/tbxfroot.c acpi @@ -156,5 +154,6 @@ file dist/acpica/utmutex.c acpi file dist/acpica/utobject.c acpi file dist/acpica/utresrc.c acpi file dist/acpica/utstate.c acpi +file dist/acpica/uttrack.c acpi file dist/acpica/utxface.c acpi diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index 67a5fb97815..4a6f289c646 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: acpivar.h,v 1.30 2007/10/19 11:59:35 ad Exp $ */ +/* $NetBSD: acpivar.h,v 1.31 2007/12/09 20:27:53 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -260,7 +260,7 @@ extern const struct acpi_resource_parse_ops acpi_resource_parse_ops_default; int acpi_check(device_t, const char *); int acpi_probe(void); -ACPI_STATUS acpi_OsGetRootPointer(UINT32, ACPI_POINTER *); +ACPI_PHYSICAL_ADDRESS acpi_OsGetRootPointer(void); int acpi_match_hid(ACPI_DEVICE_INFO *, const char * const *); void acpi_set_wake_gpe(ACPI_HANDLE); @@ -289,19 +289,6 @@ char * acpi_pci_link_name(void *); ACPI_HANDLE acpi_pci_link_handle(void *); void acpi_pci_link_state(void); - - - -#if defined(_KERNEL_OPT) -#include "acpiec.h" - -#if NACPIEC > 0 -void acpiec_early_attach(struct device *); -#endif -#else -#define NACPIEC 0 -#endif - struct acpi_io *acpi_res_io(struct acpi_resources *, int); struct acpi_iorange *acpi_res_iorange(struct acpi_resources *, int); struct acpi_mem *acpi_res_mem(struct acpi_resources *, int); @@ -318,7 +305,7 @@ ACPI_STATUS acpi_enter_sleep_state(struct acpi_softc *, int); * quirk handling */ struct acpi_quirk { - uint32_t aq_tabletype; /* what type of table (FADT, DSDT, etc) */ + const char *aq_tabletype; /* what type of table (FADT, DSDT, etc) */ const char *aq_oemid; /* compared against the table OemId */ int aq_oemrev; /* compared against the table OemRev */ int aq_cmpop; /* how to compare the oemrev number */ diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi index 28ddbee53bf..2f0badc306a 100644 --- a/sys/dev/acpi/files.acpi +++ b/sys/dev/acpi/files.acpi @@ -1,4 +1,4 @@ -# $NetBSD: files.acpi,v 1.46 2007/08/23 10:04:07 tnn Exp $ +# $NetBSD: files.acpi,v 1.47 2007/12/09 20:27:53 jmcneill Exp $ include "dev/acpi/acpica/files.acpica" @@ -8,8 +8,9 @@ defparam opt_acpi.h ACPI_DSDT_FILE := "\"/dev/null\"" define acpiapmbus { } define acpinodebus { } +define acpiecdtbus { } -device acpi: acpiapmbus, acpinodebus, sysmon_power, sysmon_taskq +device acpi: acpiapmbus, acpinodebus, acpiecdtbus, sysmon_power, sysmon_taskq attach acpi at acpibus file dev/acpi/acpi.c acpi needs-flag file dev/acpi/acpi_resource.c acpi @@ -26,7 +27,9 @@ file dev/acpi/acpi_apm.c acpiapm # ACPI Embedded Controller device acpiec attach acpiec at acpinodebus -file dev/acpi/acpi_ec.c acpiec needs-flag +device acpiecdt +attach acpiecdt at acpiecdtbus +file dev/acpi/acpi_ec.c acpiec|acpiecdt # ACPI Lid Switch device acpilid: sysmon_power diff --git a/sys/dev/acpi/pckbc_acpi.c b/sys/dev/acpi/pckbc_acpi.c index 063db3f85cd..e39b6d692ea 100644 --- a/sys/dev/acpi/pckbc_acpi.c +++ b/sys/dev/acpi/pckbc_acpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: pckbc_acpi.c,v 1.22 2007/10/19 11:59:35 ad Exp $ */ +/* $NetBSD: pckbc_acpi.c,v 1.23 2007/12/09 20:27:53 jmcneill Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -49,7 +49,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pckbc_acpi.c,v 1.22 2007/10/19 11:59:35 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pckbc_acpi.c,v 1.23 2007/12/09 20:27:53 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -232,10 +232,14 @@ pckbc_acpi_attach(struct device *parent, struct device *self, t->t_sc = &first->sc_pckbc; first->sc_pckbc.id = t; + if (!pmf_device_register(self, NULL, pckbc_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + first->sc_pckbc.intr_establish = pckbc_acpi_intr_establish; config_defer(&first->sc_pckbc.sc_dv, (void(*)(struct device *))pckbc_attach); - } + } else if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); out: acpi_resource_cleanup(&res); } diff --git a/sys/dev/acpi/pcppi_acpi.c b/sys/dev/acpi/pcppi_acpi.c index 5a60dc74ade..7e516caae4c 100644 --- a/sys/dev/acpi/pcppi_acpi.c +++ b/sys/dev/acpi/pcppi_acpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcppi_acpi.c,v 1.7 2007/10/19 11:59:35 ad Exp $ */ +/* $NetBSD: pcppi_acpi.c,v 1.8 2007/12/09 20:27:53 jmcneill Exp $ */ /* * Copyright (c) 2002 Jared D. McNeill <jmcneill@invisible.ca> @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pcppi_acpi.c,v 1.7 2007/10/19 11:59:35 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcppi_acpi.c,v 1.8 2007/12/09 20:27:53 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -121,6 +121,9 @@ pcppi_acpi_attach(struct device *parent, struct device *self, pcppi_attach(sc); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + out: acpi_resource_cleanup(&res); } diff --git a/sys/dev/apm/apm.c b/sys/dev/apm/apm.c index 8b4a8f9ce9f..a0dd710e288 100644 --- a/sys/dev/apm/apm.c +++ b/sys/dev/apm/apm.c @@ -1,4 +1,4 @@ -/* $NetBSD: apm.c,v 1.15 2007/12/05 17:19:48 pooka Exp $ */ +/* $NetBSD: apm.c,v 1.16 2007/12/09 20:27:54 jmcneill Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.15 2007/12/05 17:19:48 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.16 2007/12/09 20:27:54 jmcneill Exp $"); #include "opt_apm.h" @@ -316,11 +316,8 @@ apm_suspend(struct apm_softc *sc) sc->sc_power_state = PWR_SUSPEND; if (!(sc->sc_hwflags & APM_F_DONT_RUN_HOOKS)) { - dopowerhooks(PWR_SOFTSUSPEND); - + pmf_system_suspend(); apm_spl = splhigh(); - - dopowerhooks(PWR_SUSPEND); } error = (*sc->sc_ops->aa_set_powstate)(sc->sc_cookie, APM_DEV_ALLDEVS, @@ -345,11 +342,8 @@ apm_standby(struct apm_softc *sc) sc->sc_power_state = PWR_STANDBY; if (!(sc->sc_hwflags & APM_F_DONT_RUN_HOOKS)) { - dopowerhooks(PWR_SOFTSTANDBY); - + pmf_system_suspend(); apm_spl = splhigh(); - - dopowerhooks(PWR_STANDBY); } error = (*sc->sc_ops->aa_set_powstate)(sc->sc_cookie, APM_DEV_ALLDEVS, APM_SYS_STANDBY); @@ -379,11 +373,8 @@ apm_resume(struct apm_softc *sc, u_int event_type, u_int event_info) inittodr(time_second); if (!(sc->sc_hwflags & APM_F_DONT_RUN_HOOKS)) { - dopowerhooks(PWR_RESUME); - splx(apm_spl); - - dopowerhooks(PWR_SOFTRESUME); + pmf_system_resume(); } apm_record_event(sc, event_type); @@ -694,6 +685,9 @@ apm_attach(struct apm_softc *sc) "kernel APM support disabled\n", sc->sc_dev.dv_xname); } + + if (!pmf_device_register(&sc->sc_dev, NULL, NULL)) + aprint_error_dev(&sc->sc_dev, "couldn't establish power handler\n"); } void diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c index bd1f556f060..fa55e3929d8 100644 --- a/sys/dev/ata/ata.c +++ b/sys/dev/ata/ata.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.91 2007/10/19 11:59:36 ad Exp $ */ +/* $NetBSD: ata.c,v 1.92 2007/12/09 20:27:54 jmcneill Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.91 2007/10/19 11:59:36 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.92 2007/12/09 20:27:54 jmcneill Exp $"); #include "opt_ata.h" @@ -106,7 +106,8 @@ const struct cdevsw atabus_cdevsw = { extern struct cfdriver atabus_cd; -static void atabus_powerhook(int, void *); +static bool atabus_resume(device_t); +static bool atabus_suspend(device_t); /* * atabusprint: @@ -416,11 +417,8 @@ atabus_attach(struct device *parent, struct device *self, void *aux) aprint_error("%s: unable to create kernel thread: error %d\n", sc->sc_dev.dv_xname, error); - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - atabus_powerhook, sc); - if (sc->sc_powerhook == NULL) - printf("%s: WARNING: unable to establish power hook\n", - sc->sc_dev.dv_xname); + if (!pmf_device_register(self, atabus_suspend, atabus_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } /* @@ -502,10 +500,6 @@ atabus_detach(struct device *self, int flags) while (chp->ch_thread != NULL) (void) tsleep(&chp->ch_flags, PRIBIO, "atadown", 0); - /* power hook */ - if (sc->sc_powerhook) - powerhook_disestablish(sc->sc_powerhook); - /* * Detach atapibus and its children. */ @@ -1475,33 +1469,38 @@ atabusioctl(dev_t dev, u_long cmd, void *addr, int flag, return (error); }; -static void -atabus_powerhook(int why, void *hdl) +static bool +atabus_suspend(device_t dv) { - struct atabus_softc *sc = (struct atabus_softc *)hdl; + struct atabus_softc *sc = device_private(dv); + struct ata_channel *chp = sc->sc_chan; + + ata_queue_idle(chp->ch_queue); + + return true; +} + +static bool +atabus_resume(device_t dv) +{ + struct atabus_softc *sc = device_private(dv); struct ata_channel *chp = sc->sc_chan; int s; - switch (why) { - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - /* freeze the queue and wait for the controller to be idle */ - ata_queue_idle(chp->ch_queue); - break; - case PWR_RESUME: - printf("%s: resuming...\n", sc->sc_dev.dv_xname); - s = splbio(); - KASSERT(chp->ch_queue->queue_freeze > 0); - /* unfreeze the queue and reset drives (to wake them up) */ - chp->ch_queue->queue_freeze--; - ata_reset_channel(chp, AT_WAIT); + /* + * XXX joerg: with wdc, the first channel unfreezes the controler. + * Move this the reset and queue idling into wdc. + */ + s = splbio(); + if (chp->ch_queue->queue_freeze == 0) { splx(s); - break; - case PWR_SUSPEND: - case PWR_STANDBY: - case PWR_SOFTRESUME: - break; + return true; } + KASSERT(chp->ch_queue->queue_freeze > 0); + /* unfreeze the queue and reset drives */ + chp->ch_queue->queue_freeze--; + ata_reset_channel(chp, AT_WAIT); + splx(s); - return; + return true; } diff --git a/sys/dev/ata/atavar.h b/sys/dev/ata/atavar.h index 3460505104a..b5e5bd0688b 100644 --- a/sys/dev/ata/atavar.h +++ b/sys/dev/ata/atavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.74 2007/07/09 21:00:31 ad Exp $ */ +/* $NetBSD: atavar.h,v 1.75 2007/12/09 20:27:54 jmcneill Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -102,7 +102,6 @@ struct atabus_softc { struct ata_channel *sc_chan; int sc_flags; #define ATABUSCF_OPEN 0x01 - void *sc_powerhook; }; /* diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index 94358fb8622..8c87abc7b27 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.350 2007/11/07 08:59:03 itohy Exp $ */ +/* $NetBSD: wd.c,v 1.351 2007/12/09 20:27:54 jmcneill Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.350 2007/11/07 08:59:03 itohy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.351 2007/12/09 20:27:54 jmcneill Exp $"); #include "opt_ata.h" @@ -139,6 +139,8 @@ int wdactivate(struct device *, enum devact); int wdprint(void *, char *); void wdperror(const struct wd_softc *); +static bool wd_suspend(device_t); + CFATTACH_DECL(wd, sizeof(struct wd_softc), wdprobe, wdattach, wddetach, wdactivate); @@ -189,9 +191,8 @@ void __wdstart(struct wd_softc*, struct buf *); void wdrestart(void *); void wddone(void *); int wd_get_params(struct wd_softc *, u_int8_t, struct ataparams *); -int wd_standby(struct wd_softc *, int); +static int wd_standby(struct wd_softc *, int); int wd_flushcache(struct wd_softc *, int); -void wd_shutdown(void *); int wd_getcache(struct wd_softc *, int *); int wd_setcache(struct wd_softc *, int); @@ -414,10 +415,6 @@ wdattach(struct device *parent, struct device *self, void *aux) disk_init(&wd->sc_dk, wd->sc_dev.dv_xname, &wddkdriver); disk_attach(&wd->sc_dk); wd->sc_wdc_bio.lp = wd->sc_dk.dk_label; - wd->sc_sdhook = shutdownhook_establish(wd_shutdown, wd); - if (wd->sc_sdhook == NULL) - aprint_error("%s: WARNING: unable to establish shutdown hook\n", - wd->sc_dev.dv_xname); #if NRND > 0 rnd_attach_source(&wd->rnd_source, wd->sc_dev.dv_xname, RND_TYPE_DISK, 0); @@ -425,6 +422,20 @@ wdattach(struct device *parent, struct device *self, void *aux) /* Discover wedges on this disk. */ dkwedge_discover(&wd->sc_dk); + + if (!pmf_device_register(self, wd_suspend, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); +} + +static bool +wd_suspend(device_t dv) +{ + struct wd_softc *sc = device_private(dv); + + wd_flushcache(sc, AT_WAIT | AT_POLL); + wd_standby(sc, AT_WAIT | AT_POLL); + + return true; } int @@ -489,9 +500,7 @@ wddetach(struct device *self, int flags) sc->sc_bscount = 0; #endif - /* Get rid of the shutdown hook. */ - if (sc->sc_sdhook != NULL) - shutdownhook_disestablish(sc->sc_sdhook); + pmf_device_deregister(self); #if NRND > 0 /* Unhook the entropy source. */ @@ -1857,7 +1866,7 @@ wd_setcache(struct wd_softc *wd, int bits) return 0; } -int +static int wd_standby(struct wd_softc *wd, int flags) { struct ata_command ata_c; @@ -1869,8 +1878,8 @@ wd_standby(struct wd_softc *wd, int flags) ata_c.flags = flags; ata_c.timeout = 30000; /* 30s timeout */ if (wd->atabus->ata_exec_command(wd->drvp, &ata_c) != ATACMD_COMPLETE) { - printf("%s: standby immediate command didn't complete\n", - wd->sc_dev.dv_xname); + aprint_error_dev(&wd->sc_dev, + "standby immediate command didn't complete\n"); return EIO; } if (ata_c.flags & AT_ERROR) { @@ -1880,8 +1889,7 @@ wd_standby(struct wd_softc *wd, int flags) if (ata_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) { char sbuf[sizeof(at_errbits) + 64]; bitmask_snprintf(ata_c.flags, at_errbits, sbuf, sizeof(sbuf)); - printf("%s: wd_standby: status=%s\n", wd->sc_dev.dv_xname, - sbuf); + aprint_error_dev(&wd->sc_dev, "wd_standby: status=%s\n", sbuf); return EIO; } return 0; @@ -1929,14 +1937,6 @@ wd_flushcache(struct wd_softc *wd, int flags) return 0; } -void -wd_shutdown(void *arg) -{ - - struct wd_softc *wd = arg; - wd_flushcache(wd, AT_POLL); -} - /* * Allocate space for a ioctl queue structure. Mostly taken from * scsipi_ioctl.c diff --git a/sys/dev/ata/wdvar.h b/sys/dev/ata/wdvar.h index 5bd337fda8b..f909abab5c0 100644 --- a/sys/dev/ata/wdvar.h +++ b/sys/dev/ata/wdvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: wdvar.h,v 1.32 2005/12/11 12:21:14 christos Exp $ */ +/* $NetBSD: wdvar.h,v 1.33 2007/12/09 20:27:55 jmcneill Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -66,8 +66,6 @@ struct wd_softc { int retries; /* number of xfer retry */ - void *sc_sdhook; /* our shutdown hook */ - #ifdef WD_SOFTBADSECT SLIST_HEAD(, disk_badsectors) sc_bslist; u_int sc_bscount; diff --git a/sys/dev/audio.c b/sys/dev/audio.c index f086955e929..dee292c5ab2 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.226 2007/12/05 17:19:47 pooka Exp $ */ +/* $NetBSD: audio.c,v 1.227 2007/12/09 20:27:51 jmcneill Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.226 2007/12/05 17:19:47 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.227 2007/12/09 20:27:51 jmcneill Exp $"); #include "audio.h" #if NAUDIO > 0 @@ -102,6 +102,7 @@ int audiodebug = AUDIO_DEBUG; #define SPECIFIED(x) (x != ~0) #define SPECIFIED_CH(x) (x != (u_char)~0) +int audio_idle_timeout = 30; int audio_blk_ms = AUDIO_BLK_MS; int audiosetinfo(struct audio_softc *, struct audio_info *); @@ -173,7 +174,17 @@ void audioattach(struct device *, struct device *, void *); int audiodetach(struct device *, int); int audioactivate(struct device *, enum devact); -void audio_powerhook(int, void *); +static void audio_idle(void *); +static void audio_activity(device_t, devactive_t); + +static bool audio_suspend(device_t dv); +static bool audio_resume(device_t dv); +static void audio_volume_down(device_t); +static void audio_volume_up(device_t); +static void audio_volume_toggle(device_t); + +static void audio_mixer_capture(struct audio_softc *); +static void audio_mixer_restore(struct audio_softc *); static void audio_softintr_rd(void *); static void audio_softintr_wr(void *); @@ -333,6 +344,8 @@ audioattach(struct device *parent, struct device *self, void *aux) return; } + sc->sc_lastgain = 128; + if ((error = audio_set_defaults(sc, 0))) { aprint_error("audioattach: audio_set_defaults() failed\n"); sc->hw_if = NULL; @@ -419,6 +432,9 @@ audioattach(struct device *parent, struct device *self, void *aux) au_setup_ports(sc, &sc->sc_inports, &mi, itable); } + if (strcmp(mi.label.name, AudioNdac) == 0 && + sc->sc_outports.master == -1) + sc->sc_outports.master = mi.index; } else if (mi.mixer_class == mclass) { if (strcmp(mi.label.name, AudioNmonitor) == 0) sc->sc_monitor_port = mi.index; @@ -467,11 +483,25 @@ audioattach(struct device *parent, struct device *self, void *aux) sc->sc_inports.allports, sc->sc_inports.master, sc->sc_outports.allports, sc->sc_outports.master)); - sc->sc_powerhook = powerhook_establish(sc->dev.dv_xname, - audio_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: can't establish powerhook\n", - sc->dev.dv_xname); + callout_init(&sc->sc_idle_counter, 0); + callout_setfunc(&sc->sc_idle_counter, audio_idle, self); + + if (!pmf_device_register(self, audio_suspend, audio_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + if (!device_active_register(self, audio_activity)) + aprint_error_dev(self, "couldn't register activity handler\n"); + + if (!pmf_event_register(self, PMFE_AUDIO_VOLUME_DOWN, + audio_volume_down, true)) + aprint_error_dev(self, "couldn't add volume down handler\n"); + if (!pmf_event_register(self, PMFE_AUDIO_VOLUME_UP, + audio_volume_up, true)) + aprint_error_dev(self, "couldn't add volume up handler\n"); + if (!pmf_event_register(self, PMFE_AUDIO_VOLUME_TOGGLE, + audio_volume_toggle, true)) + aprint_error_dev(self, "couldn't add volume toggle handler\n"); + + callout_schedule(&sc->sc_idle_counter, audio_idle_timeout * hz); } int @@ -503,6 +533,17 @@ audiodetach(struct device *self, int flags) sc->sc_dying = true; + pmf_event_deregister(self, PMFE_AUDIO_VOLUME_DOWN, + audio_volume_down, true); + pmf_event_deregister(self, PMFE_AUDIO_VOLUME_UP, + audio_volume_up, true); + pmf_event_deregister(self, PMFE_AUDIO_VOLUME_TOGGLE, + audio_volume_toggle, true); + + callout_stop(&sc->sc_idle_counter); + + pmf_device_deregister(self); + wakeup(&sc->sc_wchan); wakeup(&sc->sc_rchan); s = splaudio(); @@ -529,10 +570,6 @@ audiodetach(struct device *self, int flags) vdevgone(maj, mn | AUDIOCTL_DEVICE, mn | AUDIOCTL_DEVICE, VCHR); vdevgone(maj, mn | MIXER_DEVICE, mn | MIXER_DEVICE, VCHR); - if (sc->sc_powerhook != NULL) { - powerhook_disestablish(sc->sc_powerhook); - sc->sc_powerhook = NULL; - } if (sc->sc_sih_rd) { softint_disestablish(sc->sc_sih_rd); sc->sc_sih_rd = NULL; @@ -542,6 +579,8 @@ audiodetach(struct device *self, int flags) sc->sc_sih_wr = NULL; } + callout_destroy(&sc->sc_idle_counter); + return 0; } @@ -949,8 +988,8 @@ audioopen(dev_t dev, int flags, int ifmt, struct lwp *l) if (sc->sc_dying) return EIO; - if (sc->hw_if->powerstate && sc->sc_opencnt <= 0) - sc->hw_if->powerstate(sc->hw_hdl, AUDIOPOWER_ON); + device_active(&sc->dev, DVA_SYSTEM); + sc->sc_opencnt++; sc->sc_refcnt++; @@ -983,6 +1022,9 @@ audioclose(dev_t dev, int flags, int ifmt, struct lwp *l) unit = AUDIOUNIT(dev); sc = audio_cd.cd_devs[unit]; + + device_active(&sc->dev, DVA_SYSTEM); + switch (AUDIODEV(dev)) { case SOUND_DEVICE: case AUDIO_DEVICE: @@ -1000,8 +1042,6 @@ audioclose(dev_t dev, int flags, int ifmt, struct lwp *l) } sc->sc_opencnt--; - if (sc->hw_if->powerstate && sc->sc_opencnt <= 0) - sc->hw_if->powerstate(sc->hw_hdl, AUDIOPOWER_OFF); return error; } @@ -1019,6 +1059,8 @@ audioread(dev_t dev, struct uio *uio, int ioflag) if (sc->sc_dying) return EIO; + device_active(&sc->dev, DVA_SYSTEM); + sc->sc_refcnt++; switch (AUDIODEV(dev)) { case SOUND_DEVICE: @@ -1051,6 +1093,8 @@ audiowrite(dev_t dev, struct uio *uio, int ioflag) if (sc->sc_dying) return EIO; + device_active(&sc->dev, DVA_SYSTEM); + sc->sc_refcnt++; switch (AUDIODEV(dev)) { case SOUND_DEVICE: @@ -1085,6 +1129,7 @@ audioioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) case SOUND_DEVICE: case AUDIO_DEVICE: case AUDIOCTL_DEVICE: + device_active(&sc->dev, DVA_SYSTEM); error = audio_ioctl(sc, cmd, addr, flag, l); break; case MIXER_DEVICE: @@ -1109,6 +1154,8 @@ audiopoll(dev_t dev, int events, struct lwp *l) if (sc->sc_dying) return POLLHUP; + device_active(&sc->dev, DVA_SYSTEM); + sc->sc_refcnt++; switch (AUDIODEV(dev)) { case SOUND_DEVICE: @@ -1138,6 +1185,8 @@ audiokqfilter(dev_t dev, struct knote *kn) if (sc->sc_dying) return 1; + device_active(&sc->dev, DVA_SYSTEM); + sc->sc_refcnt++; switch (AUDIODEV(dev)) { case SOUND_DEVICE: @@ -1166,6 +1215,8 @@ audiommap(dev_t dev, off_t off, int prot) if (sc->sc_dying) return -1; + device_active(&sc->dev, DVA_SYSTEM); /* XXXJDM */ + sc->sc_refcnt++; switch (AUDIODEV(dev)) { case SOUND_DEVICE: @@ -3713,12 +3764,18 @@ mixer_ioctl(struct audio_softc *sc, u_long cmd, void *addr, int flag, struct lwp *l) { const struct audio_hw_if *hw; + mixer_ctrl_t *mc; int error; DPRINTF(("mixer_ioctl(%lu,'%c',%lu)\n", IOCPARM_LEN(cmd), (char)IOCGROUP(cmd), cmd&0xff)); hw = sc->hw_if; error = EINVAL; + + /* we can return cached values if we are sleeping */ + if (cmd != AUDIO_MIXER_READ) + device_active(&sc->dev, DVA_SYSTEM); + switch (cmd) { case FIOASYNC: mixer_remove(sc, l); /* remove old entry */ @@ -3746,7 +3803,19 @@ mixer_ioctl(struct audio_softc *sc, u_long cmd, void *addr, int flag, case AUDIO_MIXER_READ: DPRINTF(("AUDIO_MIXER_READ\n")); - error = hw->get_port(sc->hw_hdl, (mixer_ctrl_t *)addr); + mc = (mixer_ctrl_t *)addr; + + if (device_is_active(sc->sc_dev) || + sc->sc_mixer_state == NULL) + error = hw->get_port(sc->hw_hdl, mc); + else if (mc->dev >= sc->sc_nmixer_states) + error = ENXIO; + else { + int dev = mc->dev; + memcpy(mc, &sc->sc_mixer_state[dev], + sizeof(mixer_ctrl_t)); + error = 0; + } break; case AUDIO_MIXER_WRITE: @@ -3814,30 +3883,195 @@ audioprint(void *aux, const char *pnp) #endif /* NAUDIO > 0 || (NMIDI > 0 || NMIDIBUS > 0) */ #if NAUDIO > 0 -void -audio_powerhook(int why, void *aux) +static void +audio_mixer_capture(struct audio_softc *sc) { - struct audio_softc *sc; - const struct audio_hw_if *hwp; + mixer_devinfo_t mi; + mixer_ctrl_t *mc; - sc = (struct audio_softc *)aux; - hwp = sc->hw_if; + for (mi.index = 0; ; mi.index++) + if (sc->hw_if->query_devinfo(sc->hw_hdl, &mi) != 0) + break; - switch (why) { - case PWR_SOFTSUSPEND: - if (sc->sc_pbus == true) - hwp->halt_output(sc->hw_hdl); - if (sc->sc_rbus == true) - hwp->halt_input(sc->hw_hdl); - break; - case PWR_SOFTRESUME: - if (sc->sc_pbus == true) - audiostartp(sc); - if (sc->sc_rbus == true) - audiostartr(sc); - break; +#ifdef DIAGNOSTIC + if (sc->sc_mixer_state != NULL && sc->sc_nmixer_states != mi.index) { + free(sc->sc_mixer_state, M_DEVBUF); + sc->sc_mixer_state = NULL; + } +#endif + + sc->sc_nmixer_states = mi.index; + if (sc->sc_mixer_state == NULL) + sc->sc_mixer_state = malloc( + sizeof(mixer_ctrl_t) * sc->sc_nmixer_states, + M_DEVBUF, M_NOWAIT); + if (sc->sc_mixer_state == NULL) { + aprint_error("%s: couldn't allocate memory for mixer state\n", + device_xname(&sc->dev)); + return; + } + + for (mi.index = 0; ; mi.index++) { + if (sc->hw_if->query_devinfo(sc->hw_hdl, &mi) != 0) + break; + if (mi.type == AUDIO_MIXER_CLASS) + continue; + mc = &sc->sc_mixer_state[mi.index]; + mc->dev = mi.index; + mc->type = mi.type; + (void)sc->hw_if->get_port(sc->hw_hdl, mc); } return; } + +static void +audio_mixer_restore(struct audio_softc *sc) +{ + mixer_devinfo_t mi; + mixer_ctrl_t *mc; + + if (sc->sc_mixer_state == NULL) + return; + + for (mi.index = 0; ; mi.index++) { + if (sc->hw_if->query_devinfo(sc->hw_hdl, &mi) != 0) + break; + if (mi.type == AUDIO_MIXER_CLASS) + continue; + mc = &sc->sc_mixer_state[mi.index]; + (void)sc->hw_if->set_port(sc->hw_hdl, mc); + } + if (sc->hw_if->commit_settings) + sc->hw_if->commit_settings(sc->hw_hdl); + + return; +} + +static void +audio_idle(void *arg) +{ + device_t dv = arg; + struct audio_softc *sc = device_private(dv); + +#ifdef PNP_DEBUG + extern int pnp_debug_idle; + if (pnp_debug_idle) + printf("%s: idle handler called\n", device_xname(dv)); +#endif + + /* XXX joerg Make pmf_device_suspend handle children? */ + if (!pmf_device_suspend(dv)) + return; + + if (!pmf_device_suspend(sc->sc_dev)) + pmf_device_resume(dv); +} + +static void +audio_activity(device_t dv, devactive_t type) +{ + struct audio_softc *sc = device_private(dv); + + if (type != DVA_SYSTEM) + return; + + callout_schedule(&sc->sc_idle_counter, audio_idle_timeout * hz); + + if (!device_is_active(dv)) { + /* XXX joerg How to deal with a failing resume... */ + pmf_device_resume(sc->sc_dev); + pmf_device_resume(dv); + } +} + +static bool +audio_suspend(device_t dv) +{ + struct audio_softc *sc = device_private(dv); + const struct audio_hw_if *hwp = sc->hw_if; + int (s); + + s = splaudio(); + audio_mixer_capture(sc); + if (sc->sc_pbus == true) + hwp->halt_output(sc->hw_hdl); + if (sc->sc_rbus == true) + hwp->halt_input(sc->hw_hdl); + callout_stop(&sc->sc_idle_counter); + splx(s); + + return true; +} + +static bool +audio_resume(device_t dv) +{ + struct audio_softc *sc = device_private(dv); + int s; + + s = splaudio(); + audio_mixer_restore(sc); + if (sc->sc_pbus == true) + audiostartp(sc); + if (sc->sc_rbus == true) + audiostartr(sc); + splx(s); + + return true; +} + +static void +audio_volume_down(device_t dv) +{ + struct audio_softc *sc = device_private(dv); + u_int gain, newgain; + u_char balance; + int s; + + s = splaudio(); + au_get_gain(sc, &sc->sc_outports, &gain, &balance); + newgain = gain - 32; + if (newgain > 255) + newgain = 0; + au_set_gain(sc, &sc->sc_outports, newgain, balance); + splx(s); +} + +static void +audio_volume_up(device_t dv) +{ + struct audio_softc *sc = device_private(dv); + u_int gain, newgain; + u_char balance; + int s; + + s = splaudio(); + au_get_gain(sc, &sc->sc_outports, &gain, &balance); + newgain = gain + 32; + if (newgain > 255) + newgain = 255; + au_set_gain(sc, &sc->sc_outports, newgain, balance); + splx(s); +} + +static void +audio_volume_toggle(device_t dv) +{ + struct audio_softc *sc = device_private(dv); + u_int gain, newgain; + u_char balance; + int s; + + s = splaudio(); + au_get_gain(sc, &sc->sc_outports, &gain, &balance); + if (gain != 0) { + sc->sc_lastgain = gain; + newgain = sc->sc_lastgain; + } else + newgain = 0; + au_set_gain(sc, &sc->sc_outports, newgain, balance); + splx(s); +} + #endif /* NAUDIO > 0 */ diff --git a/sys/dev/audiovar.h b/sys/dev/audiovar.h index 40026d79e35..75fc2193d41 100644 --- a/sys/dev/audiovar.h +++ b/sys/dev/audiovar.h @@ -1,4 +1,4 @@ -/* $NetBSD: audiovar.h,v 1.39 2007/02/21 22:59:58 thorpej Exp $ */ +/* $NetBSD: audiovar.h,v 1.40 2007/12/09 20:27:52 jmcneill Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -225,7 +225,12 @@ struct audio_softc { long sc_rblktime; /* nominal time between interrupts */ #endif - void *sc_powerhook; + u_int sc_lastgain; + + mixer_ctrl_t *sc_mixer_state; + int sc_nmixer_states; + + callout_t sc_idle_counter; }; #endif /* _SYS_DEV_AUDIOVAR_H_ */ diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index f960ca48875..d52caf5f88a 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: cardbus.c,v 1.80 2007/12/01 17:56:59 jmcneill Exp $ */ +/* $NetBSD: cardbus.c,v 1.81 2007/12/09 20:27:55 jmcneill Exp $ */ /* * Copyright (c) 1997, 1998, 1999 and 2000 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cardbus.c,v 1.80 2007/12/01 17:56:59 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cardbus.c,v 1.81 2007/12/09 20:27:55 jmcneill Exp $"); #include "opt_cardbus.h" @@ -88,6 +88,8 @@ static int cardbus_read_tuples(struct cardbus_attach_args *, static void enable_function(struct cardbus_softc *, int, int); static void disable_function(struct cardbus_softc *, int); +static bool cardbus_child_register(device_t); + CFATTACH_DECL2(cardbus, sizeof(struct cardbus_softc), cardbusmatch, cardbusattach, NULL, NULL, cardbus_rescan, cardbus_childdetached); @@ -141,6 +143,9 @@ cardbusattach(struct device *parent, struct device *self, void *aux) sc->sc_rbus_iot = cba->cba_rbus_iot; sc->sc_rbus_memt = cba->cba_rbus_memt; #endif + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int @@ -403,6 +408,7 @@ cardbus_attach_card(struct cardbus_softc *sc) return (0); } + device_pmf_driver_set_child_register(&sc->sc_dev, cardbus_child_register); cardbus_rescan(&sc->sc_dev, "cardbus", wildcard); return (1); /* XXX */ } @@ -925,76 +931,92 @@ decode_tuple(u_int8_t *tuple, u_int8_t *end, /* * XXX: this is another reason why this code should be shared with PCI. */ -int -cardbus_powerstate(cardbus_devfunc_t ct, pcitag_t tag, const int *newstate, - int *oldstate) +static int +cardbus_get_powerstate_int(cardbus_devfunc_t ct, cardbustag_t tag, + cardbusreg_t *state, int offset) { + cardbusreg_t value, now; cardbus_chipset_tag_t cc = ct->ct_cc; cardbus_function_tag_t cf = ct->ct_cf; + value = cardbus_conf_read(cc, cf, tag, offset + PCI_PMCSR); + now = value & PCI_PMCSR_STATE_MASK; + switch (now) { + case PCI_PMCSR_STATE_D0: + case PCI_PMCSR_STATE_D1: + case PCI_PMCSR_STATE_D2: + case PCI_PMCSR_STATE_D3: + *state = now; + return 0; + default: + return EINVAL; + } +} + +int +cardbus_get_powerstate(cardbus_devfunc_t ct, cardbustag_t tag, + cardbusreg_t *state) +{ + cardbus_chipset_tag_t cc = ct->ct_cc; + cardbus_function_tag_t cf = ct->ct_cf; int offset; - pcireg_t value, cap, now; + cardbusreg_t value; - if (!cardbus_get_capability(cc, cf, tag, PCI_CAP_PWRMGMT, &offset, - &value)) + if (!cardbus_get_capability(cc, cf, tag, PCI_CAP_PWRMGMT, &offset, &value)) return EOPNOTSUPP; - cap = value >> 16; + return cardbus_get_powerstate_int(ct, tag, state, offset); +} + +static int +cardbus_set_powerstate_int(cardbus_devfunc_t ct, cardbustag_t tag, + cardbusreg_t state, int offset, cardbusreg_t cap_reg) +{ + cardbus_chipset_tag_t cc = ct->ct_cc; + cardbus_function_tag_t cf = ct->ct_cf; + + cardbusreg_t value, cap, now; + + cap = cap_reg >> PCI_PMCR_SHIFT; value = cardbus_conf_read(cc, cf, tag, offset + PCI_PMCSR); now = value & PCI_PMCSR_STATE_MASK; - value &= ~PCI_PMCSR_STATE_MASK; - if (oldstate) { - switch (now) { - case PCI_PMCSR_STATE_D0: - *oldstate = PCI_PWR_D0; - break; - case PCI_PMCSR_STATE_D1: - *oldstate = PCI_PWR_D1; - break; - case PCI_PMCSR_STATE_D2: - *oldstate = PCI_PWR_D2; - break; - case PCI_PMCSR_STATE_D3: - *oldstate = PCI_PWR_D3; - break; - default: - return EINVAL; - } - } - if (newstate == NULL) + value &= ~PCI_PMCSR_STATE_MASK; + + if (now == state) return 0; - switch (*newstate) { - case PCI_PWR_D0: - if (now == PCI_PMCSR_STATE_D0) - return 0; + switch (state) { + case PCI_PMCSR_STATE_D0: value |= PCI_PMCSR_STATE_D0; break; - case PCI_PWR_D1: - if (now == PCI_PMCSR_STATE_D1) - return 0; - if (now == PCI_PMCSR_STATE_D2 || now == PCI_PMCSR_STATE_D3) + case PCI_PMCSR_STATE_D1: + if (now == PCI_PMCSR_STATE_D2 || now == PCI_PMCSR_STATE_D3) { + printf("invalid transition from %d to D1\n", (int)now); return EINVAL; - if (!(cap & PCI_PMCR_D1SUPP)) + } + if (!(cap & PCI_PMCR_D1SUPP)) { + printf("D1 not supported\n"); return EOPNOTSUPP; + } value |= PCI_PMCSR_STATE_D1; break; - case PCI_PWR_D2: - if (now == PCI_PMCSR_STATE_D2) - return 0; - if (now == PCI_PMCSR_STATE_D3) + case PCI_PMCSR_STATE_D2: + if (now == PCI_PMCSR_STATE_D3) { + printf("invalid transition from %d to D2\n", (int)now); return EINVAL; - if (!(cap & PCI_PMCR_D2SUPP)) + } + if (!(cap & PCI_PMCR_D2SUPP)) { + printf("D2 not supported\n"); return EOPNOTSUPP; + } value |= PCI_PMCSR_STATE_D2; break; - case PCI_PWR_D3: - if (now == PCI_PMCSR_STATE_D3) - return 0; + case PCI_PMCSR_STATE_D3: value |= PCI_PMCSR_STATE_D3; break; default: return EINVAL; } + cardbus_conf_write(cc, cf, tag, offset + PCI_PMCSR, value); DELAY(1000); @@ -1002,41 +1024,20 @@ cardbus_powerstate(cardbus_devfunc_t ct, pcitag_t tag, const int *newstate, } int -cardbus_setpowerstate(const char *dvname, cardbus_devfunc_t ct, pcitag_t tag, - int newpwr) +cardbus_set_powerstate(cardbus_devfunc_t ct, cardbustag_t tag, cardbusreg_t state) { - int oldpwr, error; - - if ((error = cardbus_powerstate(ct, tag, &newpwr, &oldpwr)) != 0) - return error; - - if (oldpwr == newpwr) - return 0; + cardbus_chipset_tag_t cc = ct->ct_cc; + cardbus_function_tag_t cf = ct->ct_cf; + int offset; + cardbusreg_t value; - if (oldpwr > newpwr) { - printf("%s: sleeping to power state D%d\n", dvname, oldpwr); - return 0; - } + if (!cardbus_get_capability(cc, cf, tag, PCI_CAP_PWRMGMT, &offset, + &value)) + return EOPNOTSUPP; - /* oldpwr < newpwr */ - switch (oldpwr) { - case PCI_PWR_D3: - /* - * XXX: This is because none of the devices do - * the necessary song and dance for now to wakeup - * Once this - */ - printf("%s: cannot wake up from power state D%d\n", - dvname, oldpwr); - return EINVAL; - default: - printf("%s: waking up from power state D%d\n", - dvname, oldpwr); - return 0; - } + return cardbus_set_powerstate_int(ct, tag, state, offset, value); } - #ifdef CARDBUS_DEBUG static const char *tuple_name(int); static const char *tuple_names[] = { @@ -1095,3 +1096,137 @@ print_tuple(u_int8_t *tuple, int len, void *data) } } #endif + +void +cardbus_conf_capture(cardbus_chipset_tag_t cc, cardbus_function_tag_t cf, + cardbustag_t tag, struct cardbus_conf_state *pcs) +{ + int off; + + for (off = 0; off < 16; off++) + pcs->reg[off] = cardbus_conf_read(cc, cf, tag, (off * 4)); +} + +void +cardbus_conf_restore(cardbus_chipset_tag_t cc, cardbus_function_tag_t cf, + cardbustag_t tag, struct cardbus_conf_state *pcs) +{ + int off; + cardbusreg_t val; + + for (off = 15; off >= 0; off--) { + val = cardbus_conf_read(cc, cf, tag, (off * 4)); + if (val != pcs->reg[off]) + cardbus_conf_write(cc, cf,tag, (off * 4), pcs->reg[off]); + } +} + +void +cardbus_disable_retry(cardbus_chipset_tag_t cc, cardbus_function_tag_t cf, + cardbustag_t tag) +{ + cardbusreg_t retry; + + /* + * Disable retry timeout to keep PCI Tx retries from + * interfering with ACPI C3 CPU state. + */ + retry = cardbus_conf_read(cc, cf, tag, PCI_RETRY_TIMEOUT_REG); + retry &= ~PCI_RETRY_TIMEOUT_REG_MASK; + cardbus_conf_write(cc, cf, tag, PCI_RETRY_TIMEOUT_REG, retry); +} + +struct cardbus_child_power { + struct cardbus_conf_state p_cardbusconf; + cardbus_devfunc_t p_ct; + cardbustag_t p_tag; + cardbus_chipset_tag_t p_cc; + cardbus_function_tag_t p_cf; + cardbusreg_t p_pm_cap; + bool p_has_pm; + int p_pm_offset; +}; + +static bool +cardbus_child_suspend(device_t dv) +{ + struct cardbus_child_power *priv = device_pmf_bus_private(dv); + + cardbus_conf_capture(priv->p_cc, priv->p_cf, priv->p_tag, + &priv->p_cardbusconf); + + if (priv->p_has_pm && + cardbus_set_powerstate_int(priv->p_ct, priv->p_tag, + PCI_PMCSR_STATE_D3, priv->p_pm_offset, priv->p_pm_cap)) { + aprint_error_dev(dv, "unsupported state, continuing.\n"); + return false; + } + + Cardbus_function_disable(priv->p_ct); + + return true; +} + +static bool +cardbus_child_resume(device_t dv) +{ + struct cardbus_child_power *priv = device_pmf_bus_private(dv); + + Cardbus_function_enable(priv->p_ct); + + if (priv->p_has_pm && + cardbus_set_powerstate_int(priv->p_ct, priv->p_tag, + PCI_PMCSR_STATE_D0, priv->p_pm_offset, priv->p_pm_cap)) { + aprint_error_dev(dv, "unsupported state, continuing.\n"); + return false; + } + + cardbus_conf_restore(priv->p_cc, priv->p_cf, priv->p_tag, + &priv->p_cardbusconf); + + return true; +} + +static void +cardbus_child_deregister(device_t dv) +{ + struct cardbus_child_power *priv = device_pmf_bus_private(dv); + + free(priv, M_DEVBUF); +} + +static bool +cardbus_child_register(device_t child) +{ + device_t self = device_parent(child); + struct cardbus_softc *sc = device_private(self); + struct cardbus_devfunc *ct; + struct cardbus_child_power *priv; + int off; + cardbusreg_t reg; + + ct = sc->sc_funcs[device_locator(child, CARDBUSCF_FUNCTION)]; + + priv = malloc(sizeof(*priv), M_DEVBUF, M_WAITOK); + + priv->p_ct = ct; + priv->p_cc = ct->ct_cf; + priv->p_cf = ct->ct_cf; + priv->p_tag = cardbus_make_tag(priv->p_cc, priv->p_cf, ct->ct_bus, + ct->ct_func); + + if (cardbus_get_capability(priv->p_cc, priv->p_cf, priv->p_tag, + PCI_CAP_PWRMGMT, &off, ®)) { + priv->p_has_pm = true; + priv->p_pm_offset = off; + priv->p_pm_cap = reg; + } else { + priv->p_has_pm = false; + priv->p_pm_offset = -1; + } + + device_pmf_bus_register(child, priv, cardbus_child_suspend, + cardbus_child_resume, cardbus_child_deregister); + + return true; +} diff --git a/sys/dev/cardbus/cardbusvar.h b/sys/dev/cardbus/cardbusvar.h index 00e6b0e4986..5472db2ee4f 100644 --- a/sys/dev/cardbus/cardbusvar.h +++ b/sys/dev/cardbus/cardbusvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: cardbusvar.h,v 1.36 2007/11/16 18:36:53 dyoung Exp $ */ +/* $NetBSD: cardbusvar.h,v 1.37 2007/12/09 20:27:55 jmcneill Exp $ */ /* * Copyright (c) 1998, 1999 and 2000 @@ -199,6 +199,9 @@ struct cardbus_softc { struct cardbus_devfunc *sc_funcs[8]; /* list of cardbus device functions */ }; +struct cardbus_conf_state { + cardbusreg_t reg[16]; +}; /* * struct cardbus_devfunc: @@ -326,10 +329,18 @@ int cardbus_restore_bar(cardbus_devfunc_t); int cardbus_function_enable(struct cardbus_softc *, int); int cardbus_function_disable(struct cardbus_softc *, int); +void cardbus_disable_retry(cardbus_chipset_tag_t, cardbus_function_tag_t, + cardbustag_t); + int cardbus_get_capability(cardbus_chipset_tag_t, cardbus_function_tag_t, cardbustag_t, int, int *, cardbusreg_t *); -int cardbus_powerstate(cardbus_devfunc_t, pcitag_t, const int *, int *); -int cardbus_setpowerstate(const char *, cardbus_devfunc_t, pcitag_t, int); +int cardbus_get_powerstate(cardbus_devfunc_t, cardbustag_t, cardbusreg_t *); +int cardbus_set_powerstate(cardbus_devfunc_t, cardbustag_t, cardbusreg_t); + +void cardbus_conf_capture(cardbus_chipset_tag_t, cardbus_function_tag_t, + cardbustag_t, struct cardbus_conf_state *); +void cardbus_conf_restore(cardbus_chipset_tag_t, cardbus_function_tag_t, + cardbustag_t, struct cardbus_conf_state *); #define Cardbus_function_enable(ct) cardbus_function_enable((ct)->ct_sc, (ct)->ct_func) #define Cardbus_function_disable(ct) cardbus_function_disable((ct)->ct_sc, (ct)->ct_func) diff --git a/sys/dev/cardbus/cardslot.c b/sys/dev/cardbus/cardslot.c index 85bb8ab12ab..053e0d19d8b 100644 --- a/sys/dev/cardbus/cardslot.c +++ b/sys/dev/cardbus/cardslot.c @@ -1,4 +1,4 @@ -/* $NetBSD: cardslot.c,v 1.37 2007/12/01 05:51:16 jmcneill Exp $ */ +/* $NetBSD: cardslot.c,v 1.38 2007/12/09 20:27:55 jmcneill Exp $ */ /* * Copyright (c) 1999 and 2000 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cardslot.c,v 1.37 2007/12/01 05:51:16 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cardslot.c,v 1.38 2007/12/09 20:27:55 jmcneill Exp $"); #include "opt_cardslot.h" @@ -166,6 +166,9 @@ cardslotattach(struct device *parent, struct device *self, /* attach deferred */ cardslot_event_throw(sc, CARDSLOT_EVENT_INSERTION_16); } + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } diff --git a/sys/dev/cardbus/if_ath_cardbus.c b/sys/dev/cardbus/if_ath_cardbus.c index 53def036ac3..7ac2f0b28a2 100644 --- a/sys/dev/cardbus/if_ath_cardbus.c +++ b/sys/dev/cardbus/if_ath_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ath_cardbus.c,v 1.20 2007/11/21 02:10:45 dyoung Exp $ */ +/* $NetBSD: if_ath_cardbus.c,v 1.21 2007/12/09 20:27:55 jmcneill Exp $ */ /* * Copyright (c) 2003 * Ichiro FUKUHARA <ichiro@ichiro.org>. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ath_cardbus.c,v 1.20 2007/11/21 02:10:45 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ath_cardbus.c,v 1.21 2007/12/09 20:27:55 jmcneill Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -107,13 +107,11 @@ struct ath_cardbus_softc { int sc_intrline; /* interrupt line */ bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; - void *sc_sdhook; }; int ath_cardbus_match(struct device *, struct cfdata *, void *); void ath_cardbus_attach(struct device *, struct device *, void *); int ath_cardbus_detach(struct device *, int); -void ath_cardbus_shutdown(void *arg); CFATTACH_DECL(ath_cardbus, sizeof(struct ath_cardbus_softc), ath_cardbus_match, ath_cardbus_attach, ath_cardbus_detach, ath_activate); @@ -122,7 +120,20 @@ void ath_cardbus_setup(struct ath_cardbus_softc *); int ath_cardbus_enable(struct ath_softc *); void ath_cardbus_disable(struct ath_softc *); -void ath_cardbus_power(struct ath_softc *, int); + +static bool +ath_cardbus_resume(device_t dv) +{ + struct ath_cardbus_softc *csc = device_private(dv); + cardbus_devfunc_t ct = csc->sc_ct; + cardbus_chipset_tag_t cc = ct->ct_cc; + cardbus_function_tag_t cf = ct->ct_cf; + + cardbus_disable_retry(cc, cf, csc->sc_tag); + ath_resume(&csc->sc_ath); + + return true; +} int ath_cardbus_match(struct device *parent, struct cfdata *match, @@ -161,13 +172,6 @@ ath_cardbus_attach(struct device *parent, struct device *self, */ sc->sc_enable = ath_cardbus_enable; sc->sc_disable = ath_cardbus_disable; - sc->sc_power = ath_cardbus_power; - - csc->sc_sdhook = shutdownhook_establish(ath_cardbus_shutdown, csc); - if (csc->sc_sdhook == NULL) { - aprint_error("couldn't establish shutdown hook\n"); - return; - } /* * Map the device. @@ -184,7 +188,6 @@ ath_cardbus_attach(struct device *parent, struct device *self, else { printf("%s: unable to map device registers\n", sc->sc_dev.dv_xname); - shutdownhook_disestablish(csc->sc_sdhook); return; } @@ -199,15 +202,15 @@ ath_cardbus_attach(struct device *parent, struct device *self, /* Remember which interrupt line. */ csc->sc_intrline = ca->ca_intrline; + if (!pmf_device_register(self, NULL, ath_cardbus_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->sc_if); + /* * Finish off the attach. */ ath_attach(PCI_PRODUCT(ca->ca_id), sc); - - /* - * Power down the socket. - */ - Cardbus_function_disable(csc->sc_ct); } int @@ -223,12 +226,12 @@ ath_cardbus_detach(struct device *self, int flags) panic("%s: data structure lacks", sc->sc_dev.dv_xname); #endif - shutdownhook_disestablish(csc->sc_sdhook); - rv = ath_detach(sc); if (rv) return (rv); + pmf_device_deregister(self); + /* * Unhook the interrupt handler. */ @@ -245,16 +248,6 @@ ath_cardbus_detach(struct device *self, int flags) return (0); } -void -ath_cardbus_shutdown(void *arg) -{ - struct ath_cardbus_softc *csc; - - csc = arg; - - ath_shutdown(&csc->sc_ath); -} - int ath_cardbus_enable(struct ath_softc *sc) { @@ -301,44 +294,20 @@ ath_cardbus_disable(struct ath_softc *sc) /* Unhook the interrupt handler. */ cardbus_intr_disestablish(cc, cf, csc->sc_ih); csc->sc_ih = NULL; - - /* Power down the socket. */ - Cardbus_function_disable(ct); -} - -void -ath_cardbus_power(struct ath_softc *sc, int why) -{ - struct ath_cardbus_softc *csc = (void *) sc; - - printf("%s: ath_cardbus_power\n", sc->sc_dev.dv_xname); - - if (why == PWR_RESUME) { - /* - * Give the PCI configuration registers a kick - * in the head. - */ -#ifdef DIAGNOSTIC - if (ATH_IS_ENABLED(sc) == 0) - panic("ath_cardbus_power"); -#endif - ath_cardbus_setup(csc); - } } void ath_cardbus_setup(struct ath_cardbus_softc *csc) { - struct ath_softc *sc = &csc->sc_ath; cardbus_devfunc_t ct = csc->sc_ct; cardbus_chipset_tag_t cc = ct->ct_cc; cardbus_function_tag_t cf = ct->ct_cf; int error; pcireg_t reg; - if ((error = cardbus_setpowerstate(sc->sc_dev.dv_xname, ct, csc->sc_tag, + if ((error = cardbus_set_powerstate(ct, csc->sc_tag, PCI_PWR_D0)) != 0) - aprint_debug("%s: cardbus_setpowerstate %d\n", __func__, error); + aprint_debug("%s: cardbus_set_powerstate %d\n", __func__, error); /* Program the BAR. */ cardbus_conf_write(cc, cf, csc->sc_tag, ATH_PCI_MMBA, diff --git a/sys/dev/cardbus/if_atw_cardbus.c b/sys/dev/cardbus/if_atw_cardbus.c index 16f5338c082..c65bc2e4245 100644 --- a/sys/dev/cardbus/if_atw_cardbus.c +++ b/sys/dev/cardbus/if_atw_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_atw_cardbus.c,v 1.18 2007/10/19 11:59:38 ad Exp $ */ +/* $NetBSD: if_atw_cardbus.c,v 1.19 2007/12/09 20:27:56 jmcneill Exp $ */ /*- * Copyright (c) 1999, 2000, 2003 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_atw_cardbus.c,v 1.18 2007/10/19 11:59:38 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_atw_cardbus.c,v 1.19 2007/12/09 20:27:56 jmcneill Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -400,14 +400,12 @@ atw_cardbus_power(struct atw_softc *sc, int why) void atw_cardbus_setup(struct atw_cardbus_softc *csc) { - struct atw_softc *sc = &csc->sc_atw; cardbus_devfunc_t ct = csc->sc_ct; cardbus_chipset_tag_t cc = ct->ct_cc; cardbus_function_tag_t cf = ct->ct_cf; pcireg_t reg; - (void)cardbus_setpowerstate(sc->sc_dev.dv_xname, ct, csc->sc_tag, - PCI_PWR_D0); + (void)cardbus_set_powerstate(ct, csc->sc_tag, PCI_PWR_D0); /* Program the BAR. */ cardbus_conf_write(cc, cf, csc->sc_tag, csc->sc_bar_reg, diff --git a/sys/dev/cardbus/if_ex_cardbus.c b/sys/dev/cardbus/if_ex_cardbus.c index f9a7af5a51f..43ffbea5cbe 100644 --- a/sys/dev/cardbus/if_ex_cardbus.c +++ b/sys/dev/cardbus/if_ex_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ex_cardbus.c,v 1.40 2007/10/19 11:59:38 ad Exp $ */ +/* $NetBSD: if_ex_cardbus.c,v 1.41 2007/12/09 20:27:56 jmcneill Exp $ */ /* * CardBus specific routines for 3Com 3C575-family CardBus ethernet adapter @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ex_cardbus.c,v 1.40 2007/10/19 11:59:38 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ex_cardbus.c,v 1.41 2007/12/09 20:27:56 jmcneill Exp $"); /* #define EX_DEBUG 4 */ /* define to report information for debugging */ @@ -413,14 +413,12 @@ void ex_cardbus_setup(csc) struct ex_cardbus_softc *csc; { - struct ex_softc *sc = &csc->sc_softc; cardbus_devfunc_t ct = csc->sc_ct; cardbus_chipset_tag_t cc = ct->ct_cc; cardbus_function_tag_t cf = ct->ct_cf; cardbusreg_t reg; - (void)cardbus_setpowerstate(sc->sc_dev.dv_xname, ct, csc->sc_tag, - PCI_PWR_D0); + (void)cardbus_set_powerstate(ct, csc->sc_tag, PCI_PWR_D0); /* Program the BAR */ cardbus_conf_write(cc, cf, csc->sc_tag, diff --git a/sys/dev/cardbus/if_ral_cardbus.c b/sys/dev/cardbus/if_ral_cardbus.c index 1ed918966f9..adbb743b64a 100644 --- a/sys/dev/cardbus/if_ral_cardbus.c +++ b/sys/dev/cardbus/if_ral_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ral_cardbus.c,v 1.9 2007/10/19 11:59:39 ad Exp $ */ +/* $NetBSD: if_ral_cardbus.c,v 1.10 2007/12/09 20:27:56 jmcneill Exp $ */ /* $OpenBSD: if_ral_cardbus.c,v 1.6 2006/01/09 20:03:31 damien Exp $ */ /*- @@ -22,7 +22,7 @@ * CardBus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ral_cardbus.c,v 1.9 2007/10/19 11:59:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ral_cardbus.c,v 1.10 2007/12/09 20:27:56 jmcneill Exp $"); #include "bpfilter.h" @@ -148,7 +148,6 @@ ral_cardbus_attach(struct device *parent, struct device *self, /* power management hooks */ sc->sc_enable = ral_cardbus_enable; sc->sc_disable = ral_cardbus_disable; - sc->sc_power = ral_cardbus_power; /* map control/status registers */ error = Cardbus_mapreg_map(ct, CARDBUS_BASE0_REG, @@ -247,22 +246,6 @@ ral_cardbus_disable(struct rt2560_softc *sc) } void -ral_cardbus_power(struct rt2560_softc *sc, int why) -{ - - switch (why) { - case PWR_RESUME: - ral_cardbus_enable(sc); - break; - case PWR_SUSPEND: - ral_cardbus_disable(sc); - break; - } - - return; -} - -void ral_cardbus_setup(struct ral_cardbus_softc *csc) { cardbus_devfunc_t ct = csc->sc_ct; diff --git a/sys/dev/cardbus/if_re_cardbus.c b/sys/dev/cardbus/if_re_cardbus.c index 3b0724a50d4..9b1cdba24f0 100644 --- a/sys/dev/cardbus/if_re_cardbus.c +++ b/sys/dev/cardbus/if_re_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_re_cardbus.c,v 1.14 2007/10/19 11:59:39 ad Exp $ */ +/* $NetBSD: if_re_cardbus.c,v 1.15 2007/12/09 20:27:56 jmcneill Exp $ */ /* * Copyright (c) 2004 Jonathan Stone @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_re_cardbus.c,v 1.14 2007/10/19 11:59:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_re_cardbus.c,v 1.15 2007/12/09 20:27:56 jmcneill Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -133,7 +133,6 @@ void re_cardbus_setup(struct re_cardbus_softc *); int re_cardbus_enable(struct rtk_softc *); void re_cardbus_disable(struct rtk_softc *); -void re_cardbus_power(struct rtk_softc *, int); const struct rtk_type * re_cardbus_lookup(const struct cardbus_attach_args *ca) @@ -188,7 +187,6 @@ re_cardbus_attach(struct device *parent, struct device *self, void *aux) */ sc->sc_enable = re_cardbus_enable; sc->sc_disable = re_cardbus_disable; - sc->sc_power = re_cardbus_power; /* * Map control/status registers. @@ -233,6 +231,11 @@ re_cardbus_attach(struct device *parent, struct device *self, void *aux) sc->sc_dmat = ca->ca_dmat; re_attach(sc); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->ethercom.ec_if); + /* * Power down the socket. */ @@ -252,9 +255,13 @@ re_cardbus_detach(struct device *self, int flags) panic("%s: cardbus softc, cardbus_devfunc NULL", sc->sc_dev.dv_xname); #endif + rv = re_detach(sc); if (rv) return rv; + + pmf_device_deregister(self); + /* * Unhook the interrupt handler. */ @@ -394,21 +401,3 @@ re_cardbus_disable(struct rtk_softc *sc) /* Power down the socket. */ Cardbus_function_disable(ct); } - -void -re_cardbus_power(struct rtk_softc *sc, int why) -{ - struct re_cardbus_softc *csc = (void *) sc; - - if (why == PWR_RESUME) { - /* - * Give the PCI configuration registers a kick - * in the head. - */ -#ifdef DIAGNOSTIC - if (RTK_IS_ENABLED(sc) == 0) - panic("re_cardbus_power"); -#endif - re_cardbus_setup(csc); - } -} diff --git a/sys/dev/cardbus/if_rtk_cardbus.c b/sys/dev/cardbus/if_rtk_cardbus.c index 9e3f843a165..166e1390e60 100644 --- a/sys/dev/cardbus/if_rtk_cardbus.c +++ b/sys/dev/cardbus/if_rtk_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_rtk_cardbus.c,v 1.33 2007/10/19 11:59:39 ad Exp $ */ +/* $NetBSD: if_rtk_cardbus.c,v 1.34 2007/12/09 20:27:56 jmcneill Exp $ */ /* * Copyright (c) 2000 Masanori Kanaoka @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_rtk_cardbus.c,v 1.33 2007/10/19 11:59:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_rtk_cardbus.c,v 1.34 2007/12/09 20:27:56 jmcneill Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -206,7 +206,6 @@ rtk_cardbus_attach(struct device *parent, struct device *self, */ sc->sc_enable = rtk_cardbus_enable; sc->sc_disable = rtk_cardbus_disable; - sc->sc_power = rtk_cardbus_power; /* * Map control/status registers. @@ -250,6 +249,11 @@ rtk_cardbus_attach(struct device *parent, struct device *self, rtk_attach(sc); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->ethercom.ec_if); + /* * Power down the socket. */ @@ -413,23 +417,3 @@ rtk_cardbus_disable(sc) /* Power down the socket. */ Cardbus_function_disable(ct); } - -void -rtk_cardbus_power(sc, why) - struct rtk_softc *sc; - int why; -{ - struct rtk_cardbus_softc *csc = (void *) sc; - - if (why == PWR_RESUME) { - /* - * Give the PCI configuration registers a kick - * in the head. - */ -#ifdef DIAGNOSTIC - if (RTK_IS_ENABLED(sc) == 0) - panic("rtk_cardbus_power"); -#endif - rtk_cardbus_setup(csc); - } -} diff --git a/sys/dev/cardbus/if_rtw_cardbus.c b/sys/dev/cardbus/if_rtw_cardbus.c index cde48f8d9da..d23df1a05e3 100644 --- a/sys/dev/cardbus/if_rtw_cardbus.c +++ b/sys/dev/cardbus/if_rtw_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_rtw_cardbus.c,v 1.18 2007/11/16 18:47:41 dyoung Exp $ */ +/* $NetBSD: if_rtw_cardbus.c,v 1.19 2007/12/09 20:27:56 jmcneill Exp $ */ /*- * Copyright (c) 2004, 2005 David Young. All rights reserved. @@ -74,7 +74,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_rtw_cardbus.c,v 1.18 2007/11/16 18:47:41 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_rtw_cardbus.c,v 1.19 2007/12/09 20:27:56 jmcneill Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -464,15 +464,13 @@ rtw_cardbus_power(struct rtw_softc *sc, int why) void rtw_cardbus_setup(struct rtw_cardbus_softc *csc) { - struct rtw_softc *sc = &csc->sc_rtw; cardbustag_t tag = csc->sc_tag; cardbus_devfunc_t ct = csc->sc_ct; cardbus_chipset_tag_t cc = ct->ct_cc; cardbusreg_t bhlc, csr, lattimer; cardbus_function_tag_t cf = ct->ct_cf; - (void)cardbus_setpowerstate(device_xname(&sc->sc_dev), ct, tag, - PCI_PWR_D0); + (void)cardbus_set_powerstate(ct, tag, PCI_PWR_D0); /* I believe the datasheet tries to warn us that the RTL8180 * wants for 16 (0x10) to divide the latency timer. diff --git a/sys/dev/cardbus/if_tlp_cardbus.c b/sys/dev/cardbus/if_tlp_cardbus.c index e388c8150b5..6d90b018999 100644 --- a/sys/dev/cardbus/if_tlp_cardbus.c +++ b/sys/dev/cardbus/if_tlp_cardbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_tlp_cardbus.c,v 1.54 2007/10/19 11:59:39 ad Exp $ */ +/* $NetBSD: if_tlp_cardbus.c,v 1.55 2007/12/09 20:27:56 jmcneill Exp $ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_tlp_cardbus.c,v 1.54 2007/10/19 11:59:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tlp_cardbus.c,v 1.55 2007/12/09 20:27:56 jmcneill Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -612,8 +612,7 @@ tlp_cardbus_setup(csc) break; } - (void)cardbus_setpowerstate(sc->sc_dev.dv_xname, ct, csc->sc_tag, - PCI_PWR_D0); + (void)cardbus_set_powerstate(ct, csc->sc_tag, PCI_PWR_D0); /* Program the BAR. */ cardbus_conf_write(cc, cf, csc->sc_tag, csc->sc_bar_reg, diff --git a/sys/dev/dkwedge/dk.c b/sys/dev/dkwedge/dk.c index 9c4fd442c99..932682a9b5d 100644 --- a/sys/dev/dkwedge/dk.c +++ b/sys/dev/dkwedge/dk.c @@ -1,4 +1,4 @@ -/* $NetBSD: dk.c,v 1.30 2007/11/26 19:01:37 pooka Exp $ */ +/* $NetBSD: dk.c,v 1.31 2007/12/09 20:27:56 jmcneill Exp $ */ /*- * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.30 2007/11/26 19:01:37 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.31 2007/12/09 20:27:56 jmcneill Exp $"); #include "opt_dkwedge.h" @@ -150,7 +150,8 @@ dkwedge_attach(struct device *parent, struct device *self, void *aux) { - /* Nothing to do. */ + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } /* @@ -162,6 +163,7 @@ static int dkwedge_detach(struct device *self, int flags) { + pmf_device_deregister(self); /* Always succeeds. */ return (0); } diff --git a/sys/dev/i2c/i2c.c b/sys/dev/i2c/i2c.c index bef090b4481..3c7dc60c8d6 100644 --- a/sys/dev/i2c/i2c.c +++ b/sys/dev/i2c/i2c.c @@ -1,4 +1,4 @@ -/* $NetBSD: i2c.c,v 1.16 2007/11/12 19:42:44 joerg Exp $ */ +/* $NetBSD: i2c.c,v 1.17 2007/12/09 20:27:57 jmcneill Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -152,6 +152,9 @@ iic_attach(struct device *parent, struct device *self, void *aux) } #endif + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + /* * Attach all i2c devices described in the kernel * configuration file. diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c index 85274e44824..8c5da46371c 100644 --- a/sys/dev/ic/an.c +++ b/sys/dev/ic/an.c @@ -1,4 +1,4 @@ -/* $NetBSD: an.c,v 1.49 2007/10/19 11:59:47 ad Exp $ */ +/* $NetBSD: an.c,v 1.50 2007/12/09 20:27:57 jmcneill Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.49 2007/10/19 11:59:47 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.50 2007/12/09 20:27:57 jmcneill Exp $"); #include "bpfilter.h" @@ -448,41 +448,6 @@ an_activate(struct device *self, enum devact act) return error; } -void -an_power(int why, void *arg) -{ - int s; - struct an_softc *sc = arg; - struct ifnet *ifp = &sc->sc_if; - - s = splnet(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - an_stop(ifp, 1); - break; - case PWR_RESUME: - if (ifp->if_flags & IFF_UP) { - an_init(ifp); - (void)an_intr(sc); - } - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } - splx(s); -} - -void -an_shutdown(struct an_softc *sc) -{ - - if (sc->sc_attached) - an_stop(&sc->sc_if, 1); -} - int an_intr(void *arg) { diff --git a/sys/dev/ic/anvar.h b/sys/dev/ic/anvar.h index eb0be9d34f3..b0f931f0d3e 100644 --- a/sys/dev/ic/anvar.h +++ b/sys/dev/ic/anvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: anvar.h,v 1.14 2007/03/04 06:01:49 christos Exp $ */ +/* $NetBSD: anvar.h,v 1.15 2007/12/09 20:27:57 jmcneill Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -165,8 +165,6 @@ struct an_softc { int an_attach(struct an_softc *); int an_detach(struct an_softc *); int an_activate(struct device *, enum devact); -void an_power(int, void *); -void an_shutdown(struct an_softc *); int an_intr(void *); #endif /* _DEV_IC_ANVAR_H */ diff --git a/sys/dev/ic/ath.c b/sys/dev/ic/ath.c index d5d8a15db92..57ff814bf43 100644 --- a/sys/dev/ic/ath.c +++ b/sys/dev/ic/ath.c @@ -1,4 +1,4 @@ -/* $NetBSD: ath.c,v 1.92 2007/11/27 00:07:42 dyoung Exp $ */ +/* $NetBSD: ath.c,v 1.93 2007/12/09 20:27:57 jmcneill Exp $ */ /*- * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.92 2007/11/27 00:07:42 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.93 2007/12/09 20:27:57 jmcneill Exp $"); #endif /* @@ -203,7 +203,6 @@ static void ath_setcurmode(struct ath_softc *, enum ieee80211_phymode); #ifdef __NetBSD__ int ath_enable(struct ath_softc *); void ath_disable(struct ath_softc *); -void ath_power(int, void *); #endif #if NBPFILTER > 0 @@ -526,6 +525,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) ifp->if_softc = sc; ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; ifp->if_start = ath_start; + ifp->if_stop = ath_stop; ifp->if_watchdog = ath_watchdog; ifp->if_ioctl = ath_ioctl; ifp->if_init = ath_ifinit; @@ -639,14 +639,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) ath_bpfattach(sc); #endif -#ifdef __NetBSD__ sc->sc_flags |= ATH_ATTACHED; - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - ath_power, sc); - if (sc->sc_powerhook == NULL) - printf("%s: WARNING: unable to establish power hook\n", - sc->sc_dev.dv_xname); -#endif /* * Setup dynamic sysctl's now that country code and @@ -713,78 +706,15 @@ ath_detach(struct ath_softc *sc) return 0; } -#ifdef __NetBSD__ -void -ath_power(int why, void *arg) -{ - struct ath_softc *sc = arg; - int s; - - DPRINTF(sc, ATH_DEBUG_ANY, "ath_power(%d)\n", why); - - s = splnet(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - ath_suspend(sc, why); - break; - case PWR_RESUME: - ath_resume(sc, why); - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } - splx(s); -} -#endif - -void -ath_suspend(struct ath_softc *sc, int why) -{ - struct ifnet *ifp = &sc->sc_if; - - DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n", - __func__, ifp->if_flags); - - ath_stop(ifp, 1); - if (sc->sc_power != NULL) - (*sc->sc_power)(sc, why); -} - void -ath_resume(struct ath_softc *sc, int why) +ath_resume(struct ath_softc *sc) { - struct ifnet *ifp = &sc->sc_if; - - DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n", - __func__, ifp->if_flags); - - if (ifp->if_flags & IFF_UP) { - ath_init(sc); -#if 0 - (void)ath_intr(sc); -#endif - if (sc->sc_power != NULL) - (*sc->sc_power)(sc, why); - if (ifp->if_flags & IFF_RUNNING) - ath_start(ifp); - } if (sc->sc_softled) { ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin); ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon); } } -void -ath_shutdown(void *arg) -{ - struct ath_softc *sc = arg; - - ath_stop(&sc->sc_if, 1); -} - /* * Interrupt handler. Most of the actual processing is deferred. */ diff --git a/sys/dev/ic/athvar.h b/sys/dev/ic/athvar.h index 783387b0eb4..e34bf253896 100644 --- a/sys/dev/ic/athvar.h +++ b/sys/dev/ic/athvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: athvar.h,v 1.21 2007/07/17 01:26:17 dyoung Exp $ */ +/* $NetBSD: athvar.h,v 1.22 2007/12/09 20:27:57 jmcneill Exp $ */ /*- * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting @@ -306,11 +306,8 @@ struct ath_softc { int ath_attach(u_int16_t, struct ath_softc *); int ath_detach(struct ath_softc *); -void ath_resume(struct ath_softc *, int); -void ath_suspend(struct ath_softc *, int); int ath_activate(struct device *, enum devact); -void ath_power(int, void *); -void ath_shutdown(void *); +void ath_resume(struct ath_softc *); int ath_intr(void *); int ath_reset(struct ifnet *); void ath_sysctlattach(struct ath_softc *); diff --git a/sys/dev/ic/attimer.c b/sys/dev/ic/attimer.c index 413a09b3603..f78aade6e87 100644 --- a/sys/dev/ic/attimer.c +++ b/sys/dev/ic/attimer.c @@ -1,4 +1,4 @@ -/* $NetBSD: attimer.c,v 1.4 2007/10/19 11:59:48 ad Exp $ */ +/* $NetBSD: attimer.c,v 1.5 2007/12/09 20:27:58 jmcneill Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: attimer.c,v 1.4 2007/10/19 11:59:48 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: attimer.c,v 1.5 2007/12/09 20:27:58 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -56,6 +56,9 @@ void attimer_attach(struct attimer_softc *sc) { sc->sc_flags |= ATT_CONFIGURED; + + if (!pmf_device_register(&sc->sc_dev, NULL, NULL)) + aprint_error_dev(&sc->sc_dev, "couldn't establish power handler\n"); } /* diff --git a/sys/dev/ic/hpet.c b/sys/dev/ic/hpet.c index 0794eb1b974..9b22e4d0e75 100644 --- a/sys/dev/ic/hpet.c +++ b/sys/dev/ic/hpet.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpet.c,v 1.3 2007/12/01 16:51:22 ad Exp $ */ +/* $NetBSD: hpet.c,v 1.4 2007/12/09 20:27:58 jmcneill Exp $ */ /* * Copyright (c) 2006 Nicolas Joly @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hpet.c,v 1.3 2007/12/01 16:51:22 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hpet.c,v 1.4 2007/12/09 20:27:58 jmcneill Exp $"); #include <sys/systm.h> #include <sys/device.h> @@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: hpet.c,v 1.3 2007/12/01 16:51:22 ad Exp $"); #include <dev/ic/hpetvar.h> static u_int hpet_get_timecount(struct timecounter *); +static bool hpet_resume(device_t); void hpet_attach_subr(struct hpet_softc *sc) { @@ -60,12 +61,6 @@ hpet_attach_subr(struct hpet_softc *sc) { tc->tc_get_timecount = hpet_get_timecount; tc->tc_quality = 2000; - /* XXX Only 32-bits supported for now */ - val = bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_INFO); - if ((val & HPET_INFO_64BITS) != 0) { - aprint_debug("%s: Found 64-bits HPET, will only use lowest" - " 32-bits\n", sc->sc_dev.dv_xname); - } tc->tc_counter_mask = 0xffffffff; /* Get frequency */ @@ -81,12 +76,27 @@ hpet_attach_subr(struct hpet_softc *sc) { tc->tc_priv = sc; tc_init(tc); + + if (!pmf_device_register(&sc->sc_dev, NULL, hpet_resume)) + aprint_error_dev(&sc->sc_dev, "couldn't establish power handler\n"); } static u_int hpet_get_timecount(struct timecounter *tc) { struct hpet_softc *sc = tc->tc_priv; - return bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_MCOUNT); + return bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_MCOUNT_LO); } +static bool +hpet_resume(device_t dv) +{ + struct hpet_softc *sc = device_private(dv); + uint32_t val; + + val = bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_CONFIG); + val |= HPET_CONFIG_ENABLE; + bus_space_write_4(sc->sc_memt, sc->sc_memh, HPET_CONFIG, val); + + return true; +} diff --git a/sys/dev/ic/hpetreg.h b/sys/dev/ic/hpetreg.h index 16648a20bf1..dcde6ee447a 100644 --- a/sys/dev/ic/hpetreg.h +++ b/sys/dev/ic/hpetreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: hpetreg.h,v 1.1 2007/03/08 14:26:28 njoly Exp $ */ +/* $NetBSD: hpetreg.h,v 1.2 2007/12/09 20:27:58 jmcneill Exp $ */ /* * Copyright (c) 2006 Nicolas Joly @@ -31,11 +31,27 @@ #ifndef _DEV_IC_HPETREG_H_ #define _DEV_IC_HPETREG_H_ -#define HPET_INFO 0x00 -#define HPET_INFO_64BITS 0x2000 -#define HPET_PERIOD 0x04 -#define HPET_CONFIG 0x10 -#define HPET_CONFIG_ENABLE 0x0001 -#define HPET_MCOUNT 0xf0 +#define HPET_WINDOW_SIZE 0x400 + +#define HPET_INFO 0x00 +#define HPET_INFO_64BITS 0x2000 +#define HPET_PERIOD 0x04 +#define HPET_CONFIG 0x10 +#define HPET_CONFIG_ENABLE 0x0001 +#define HPET_MCOUNT_LO 0xf0 +#define HPET_MCOUNT_HI 0xf4 +#define HPET_INT_STATUS 0x20 +#define HPET_INT_STS_TIMER0 0x00000001 + +#define HPET_TIMER_USE_LEVEL_INTR 0x00000002 +#define HPET_TIMER_ENABLE_INTR 0x00000004 +#define HPET_TIMER_IS_PERIODIC_INTR 0x00000008 +#define HPET_TIMER_HAS_PERIODIC_INTR 0x00000010 +#define HPET_TIMER_INTR_SHIFT 9 + +#define HPET_TIMER0_CONFIG 0x0100 +#define HPET_TIMER0_INTCAP 0x0104 +#define HPET_TIMER0_CMPREG_LO 0x0108 +#define HPET_TIMER0_CMPREG_HI 0x010C #endif /* _DEV_IC_HPETREG_H_ */ diff --git a/sys/dev/ic/i82801lpcreg.h b/sys/dev/ic/i82801lpcreg.h index c2cfbe2f86c..ddddbc28418 100644 --- a/sys/dev/ic/i82801lpcreg.h +++ b/sys/dev/ic/i82801lpcreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: i82801lpcreg.h,v 1.6 2007/08/26 18:39:43 xtraeme Exp $ */ +/* $NetBSD: i82801lpcreg.h,v 1.7 2007/12/09 20:27:58 jmcneill Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -78,6 +78,16 @@ #define LPCIB_PCI_MON7_TRP_RNG 0xc7 #define LPCIB_PCI_MON_TRP_MSK oxcc #define LPCIB_PCI_GEN_CNTL 0xd0 +#define LPCIB_ICH5_HPTC_EN 0x00020000 +#define LPCIB_ICH5_HPTC_WIN_MASK 0x0000c000 +#define LPCIB_ICH5_HPTC_0000 0x00000000 +#define LPCIB_ICH5_HPTC_0000_BASE 0xfed00000 +#define LPCIB_ICH5_HPTC_1000 0x00008000 +#define LPCIB_ICH5_HPTC_1000_BASE 0xfed01000 +#define LPCIB_ICH5_HPTC_2000 0x00010000 +#define LPCIB_ICH5_HPTC_2000_BASE 0xfed02000 +#define LPCIB_ICH5_HPTC_3000 0x00018000 +#define LPCIB_ICH5_HPTC_3000_BASE 0xfed03000 #define LPCIB_PCI_GEN_STA 0xd4 # define LPCIB_PCI_GEN_STA_SAFE_MODE (1 << 2) # define LPCIB_PCI_GEN_STA_NO_REBOOT (1 << 1) @@ -209,9 +219,21 @@ /* ICH Chipset Configuration Registers (ICH6 and newer) */ #define LPCIB_RCBA 0xf0 -#define LPCIB_GCS_OFFSET 0x3410 -#define LPCIB_GCS_SIZE 4 -#define LPCIB_GCS_NO_REBOOT 0x20 +#define LPCIB_RCBA_EN 0x00000001 +#define LPCIB_RCBA_SIZE 0x00004000 +#define LPCIB_GCS_OFFSET 0x3410 +#define LPCIB_GCS_NO_REBOOT 0x20 +#define LPCIB_RCBA_HPTC 0x00003404 +#define LPCIB_RCBA_HPTC_EN 0x00000080 +#define LPCIB_RCBA_HPTC_WIN_MASK 0x00000003 +#define LPCIB_RCBA_HPTC_0000 0x00000000 +#define LPCIB_RCBA_HPTC_0000_BASE 0xfed00000 +#define LPCIB_RCBA_HPTC_1000 0x00000001 +#define LPCIB_RCBA_HPTC_1000_BASE 0xfed01000 +#define LPCIB_RCBA_HPTC_2000 0x00000002 +#define LPCIB_RCBA_HPTC_2000_BASE 0xfed02000 +#define LPCIB_RCBA_HPTC_3000 0x00000003 +#define LPCIB_RCBA_HPTC_3000_BASE 0xfed03000 /* * System management TCO registers diff --git a/sys/dev/ic/pckbc.c b/sys/dev/ic/pckbc.c index bf1ce784220..ed39bd94af1 100644 --- a/sys/dev/ic/pckbc.c +++ b/sys/dev/ic/pckbc.c @@ -1,4 +1,4 @@ -/* $NetBSD: pckbc.c,v 1.38 2007/10/19 11:59:59 ad Exp $ */ +/* $NetBSD: pckbc.c,v 1.39 2007/12/09 20:27:58 jmcneill Exp $ */ /* * Copyright (c) 2004 Ben Harris. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.38 2007/10/19 11:59:59 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.39 2007/12/09 20:27:58 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -714,3 +714,20 @@ pckbc_cnattach(iot, addr, cmd_offset, slot) return (res); } + +bool +pckbc_resume(device_t dv) +{ + struct pckbc_softc *sc = device_private(dv); + struct pckbc_internal *t; + + t = sc->id; + (void)pckbc_poll_data1(t, PCKBC_KBD_SLOT); + if (!pckbc_send_cmd(t->t_iot, t->t_ioh_c, KBC_SELFTEST)) + return false; + (void)pckbc_poll_data1(t, PCKBC_KBD_SLOT); + (void)pckbc_put8042cmd(t); + pckbcintr(t->t_sc); + + return true; +} diff --git a/sys/dev/ic/pckbcvar.h b/sys/dev/ic/pckbcvar.h index aac2d483393..0288621ed07 100644 --- a/sys/dev/ic/pckbcvar.h +++ b/sys/dev/ic/pckbcvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: pckbcvar.h,v 1.12 2005/12/11 12:21:28 christos Exp $ */ +/* $NetBSD: pckbcvar.h,v 1.13 2007/12/09 20:27:58 jmcneill Exp $ */ /* * Copyright (c) 1998 @@ -111,4 +111,7 @@ void pckbcintr_soft(void *); /* md hook for use without mi wscons */ int pckbc_machdep_cnattach(pckbc_tag_t, pckbc_slot_t); +/* power management */ +bool pckbc_resume(device_t); + #endif /* _DEV_IC_PCKBCVAR_H_ */ diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c index 7cdca7ae351..a21b62ef31b 100644 --- a/sys/dev/ic/rt2560.c +++ b/sys/dev/ic/rt2560.c @@ -1,4 +1,4 @@ -/* $NetBSD: rt2560.c,v 1.14 2007/10/21 17:03:37 degroote Exp $ */ +/* $NetBSD: rt2560.c,v 1.15 2007/12/09 20:27:58 jmcneill Exp $ */ /* $OpenBSD: rt2560.c,v 1.15 2006/04/20 20:31:12 miod Exp $ */ /* $FreeBSD: rt2560.c,v 1.3 2006/03/21 21:15:43 damien Exp $*/ @@ -24,7 +24,7 @@ * http://www.ralinktech.com/ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.14 2007/10/21 17:03:37 degroote Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.15 2007/12/09 20:27:58 jmcneill Exp $"); #include "bpfilter.h" @@ -148,8 +148,7 @@ static const char *rt2560_get_rf(int); static void rt2560_read_eeprom(struct rt2560_softc *); static int rt2560_bbp_init(struct rt2560_softc *); static int rt2560_init(struct ifnet *); -static void rt2560_stop(void *); -static void rt2560_powerhook(int, void *); +static void rt2560_stop(struct ifnet *, int); /* * Supported rates for 802.11a/b/g modes (in 500Kbps unit). @@ -401,16 +400,10 @@ rt2560_attach(void *xsc, int id) goto fail5; } - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - rt2560_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: can't establish powerhook\n", - sc->sc_dev.dv_xname); - sc->sc_suspend = PWR_RESUME; - ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_init = rt2560_init; + ifp->if_stop = rt2560_stop; ifp->if_ioctl = rt2560_ioctl; ifp->if_start = rt2560_start; ifp->if_watchdog = rt2560_watchdog; @@ -496,6 +489,11 @@ rt2560_attach(void *xsc, int id) ieee80211_announce(ic); + if (!pmf_device_register(&sc->sc_dev, NULL, NULL)) + aprint_error_dev(&sc->sc_dev, "couldn't establish power handler\n"); + else + pmf_class_network_register(&sc->sc_dev, ifp); + return 0; fail5: rt2560_free_tx_ring(sc, &sc->bcnq); @@ -516,10 +514,9 @@ rt2560_detach(void *xsc) callout_stop(&sc->scan_ch); callout_stop(&sc->rssadapt_ch); - if (sc->sc_powerhook != NULL) - powerhook_disestablish(sc->sc_powerhook); + pmf_device_deregister(&sc->sc_dev); - rt2560_stop(sc); + rt2560_stop(ifp, 1); ieee80211_ifdetach(&sc->sc_ic); /* free all nodes */ if_detach(ifp); @@ -1463,7 +1460,7 @@ rt2560_shutdown(void *xsc) { struct rt2560_softc *sc = xsc; - rt2560_stop(sc); + rt2560_stop(&sc->sc_if, 1); } void @@ -1471,7 +1468,7 @@ rt2560_suspend(void *xsc) { struct rt2560_softc *sc = xsc; - rt2560_stop(sc); + rt2560_stop(&sc->sc_if, 1); } void @@ -1534,6 +1531,9 @@ rt2560_intr(void *arg) struct ifnet *ifp = &sc->sc_if; uint32_t r; + if (!device_is_active(&sc->sc_dev)) + return 0; + /* disable interrupts */ RAL_WRITE(sc, RT2560_CSR8, 0xffffffff); @@ -1541,10 +1541,6 @@ rt2560_intr(void *arg) if (!(ifp->if_flags & IFF_RUNNING)) return 0; - /* if we're suspended, don't bother */ - if (sc->sc_suspend != PWR_RESUME) - return 0; - r = RAL_READ(sc, RT2560_CSR7); RAL_WRITE(sc, RT2560_CSR7, r); @@ -2257,7 +2253,7 @@ rt2560_ioctl(struct ifnet *ifp, u_long cmd, void *data) rt2560_init(ifp); } else { if (ifp->if_flags & IFF_RUNNING) - rt2560_stop(sc); + rt2560_stop(ifp, 1); } break; @@ -2819,7 +2815,7 @@ rt2560_init(struct ifnet *ifp) sc->sc_flags |= RT2560_ENABLED; } - rt2560_stop(sc); + rt2560_stop(ifp, 1); /* setup tx rings */ tmp = RT2560_PRIO_RING_COUNT << 24 | @@ -2860,7 +2856,7 @@ rt2560_init(struct ifnet *ifp) RAL_WRITE(sc, RT2560_CSR1, RT2560_HOST_READY); if (rt2560_bbp_init(sc) != 0) { - rt2560_stop(sc); + rt2560_stop(ifp, 1); return EIO; } @@ -2902,11 +2898,10 @@ rt2560_init(struct ifnet *ifp) } static void -rt2560_stop(void *priv) +rt2560_stop(struct ifnet *ifp, int disable) { - struct rt2560_softc *sc = priv; + struct rt2560_softc *sc = ifp->if_softc; struct ieee80211com *ic = &sc->sc_ic; - struct ifnet *ifp = ic->ic_ifp; sc->sc_tx_timer = 0; ifp->if_timer = 0; @@ -2938,41 +2933,3 @@ rt2560_stop(void *priv) rt2560_reset_rx_ring(sc, &sc->rxq); } - -static void -rt2560_powerhook(int why, void *opaque) -{ - struct rt2560_softc *sc; - struct ifnet *ifp; - int s; - - sc = (struct rt2560_softc *)opaque; - ifp = &sc->sc_if; - - s = splnet(); - switch (why) { - case PWR_SUSPEND: - sc->sc_suspend = why; - rt2560_stop(sc); - if (sc->sc_power != NULL) - (*sc->sc_power)(sc, why); - break; - case PWR_RESUME: - sc->sc_suspend = why; - if (ifp->if_flags & IFF_UP) { - if (sc->sc_power != NULL) - (*sc->sc_power)(sc, why); - rt2560_init(ifp); - if (ifp->if_flags & IFF_RUNNING) - rt2560_start(ifp); - } - break; - case PWR_STANDBY: - case PWR_SOFTSUSPEND: - case PWR_SOFTRESUME: - break; - } - splx(s); - - return; -} diff --git a/sys/dev/ic/rt2560var.h b/sys/dev/ic/rt2560var.h index a4183608eab..23acf28d946 100644 --- a/sys/dev/ic/rt2560var.h +++ b/sys/dev/ic/rt2560var.h @@ -1,4 +1,4 @@ -/* $NetBSD: rt2560var.h,v 1.5 2007/03/04 06:02:00 christos Exp $ */ +/* $NetBSD: rt2560var.h,v 1.6 2007/12/09 20:27:58 jmcneill Exp $ */ /* $OpenBSD: rt2560var.h,v 1.2 2006/01/14 12:43:27 damien Exp $ */ /*- @@ -105,7 +105,6 @@ struct rt2560_softc { int (*sc_enable)(struct rt2560_softc *); void (*sc_disable)(struct rt2560_softc *); - void (*sc_power)(struct rt2560_softc *, int); bus_dma_tag_t sc_dmat; bus_space_tag_t sc_st; @@ -167,9 +166,6 @@ struct rt2560_softc { #define sc_txtap sc_txtapu.th int sc_txtap_len; #endif - - void *sc_powerhook; - int sc_suspend; }; #define sc_if sc_ec.ec_if diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c index f5b0e2d2cbc..06caca4c4bc 100644 --- a/sys/dev/ic/rt2661.c +++ b/sys/dev/ic/rt2661.c @@ -1,4 +1,4 @@ -/* $NetBSD: rt2661.c,v 1.20 2007/10/21 17:03:37 degroote Exp $ */ +/* $NetBSD: rt2661.c,v 1.21 2007/12/09 20:27:58 jmcneill Exp $ */ /* $OpenBSD: rt2661.c,v 1.17 2006/05/01 08:41:11 damien Exp $ */ /* $FreeBSD: rt2560.c,v 1.5 2006/06/02 19:59:31 csjp Exp $ */ @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.20 2007/10/21 17:03:37 degroote Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.21 2007/12/09 20:27:58 jmcneill Exp $"); #include "bpfilter.h" @@ -427,6 +427,7 @@ rt2661_attach(void *xsc, int id) ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_init = rt2661_init; + ifp->if_stop = rt2661_stop; ifp->if_ioctl = rt2661_ioctl; ifp->if_start = rt2661_start; ifp->if_watchdog = rt2661_watchdog; @@ -509,6 +510,11 @@ rt2661_attach(void *xsc, int id) ieee80211_announce(ic); + if (!pmf_device_register(&sc->sc_dev, NULL, NULL)) + aprint_error_dev(&sc->sc_dev, "couldn't establish power handler\n"); + else + pmf_class_network_register(&sc->sc_dev, ifp); + return 0; fail6: rt2661_free_tx_ring(sc, &sc->mgtq); @@ -528,6 +534,8 @@ rt2661_detach(void *xsc) callout_stop(&sc->scan_ch); callout_stop(&sc->rssadapt_ch); + pmf_device_deregister(&sc->sc_dev); + ieee80211_ifdetach(&sc->sc_ic); if_detach(ifp); diff --git a/sys/dev/ic/rt2661var.h b/sys/dev/ic/rt2661var.h index 0e7221432f6..e754bbd72ec 100644 --- a/sys/dev/ic/rt2661var.h +++ b/sys/dev/ic/rt2661var.h @@ -1,4 +1,4 @@ -/* $NetBSD: rt2661var.h,v 1.6 2007/03/04 06:02:00 christos Exp $ */ +/* $NetBSD: rt2661var.h,v 1.7 2007/12/09 20:27:59 jmcneill Exp $ */ /* $OpenBSD: rt2661var.h,v 1.4 2006/02/25 12:56:47 damien Exp $ */ /*- @@ -98,7 +98,6 @@ struct rt2661_softc { int (*sc_enable)(struct rt2661_softc *); void (*sc_disable)(struct rt2661_softc *); - void (*sc_power)(struct rt2661_softc *, int); bus_dma_tag_t sc_dmat; bus_space_tag_t sc_st; diff --git a/sys/dev/ic/rtl8169.c b/sys/dev/ic/rtl8169.c index 1b6286e83b7..5459da14f8b 100644 --- a/sys/dev/ic/rtl8169.c +++ b/sys/dev/ic/rtl8169.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtl8169.c,v 1.89 2007/10/19 11:59:59 ad Exp $ */ +/* $NetBSD: rtl8169.c,v 1.90 2007/12/09 20:27:59 jmcneill Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -162,10 +162,8 @@ static int re_init(struct ifnet *); static void re_stop(struct ifnet *, int); static void re_watchdog(struct ifnet *); -static void re_shutdown(void *); static int re_enable(struct rtk_softc *); static void re_disable(struct rtk_softc *); -static void re_power(int, void *); static int re_ifmedia_upd(struct ifnet *); static void re_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -794,25 +792,6 @@ re_attach(struct rtk_softc *sc) if_attach(ifp); ether_ifattach(ifp, eaddr); - - /* - * Make sure the interface is shutdown during reboot. - */ - sc->sc_sdhook = shutdownhook_establish(re_shutdown, sc); - if (sc->sc_sdhook == NULL) - aprint_error("%s: WARNING: unable to establish shutdown hook\n", - sc->sc_dev.dv_xname); - /* - * Add a suspend hook to make sure we come back up after a - * resume. - */ - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - re_power, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: WARNING: unable to establish power hook\n", - sc->sc_dev.dv_xname); - - return; fail_8: @@ -936,10 +915,6 @@ re_detach(struct rtk_softc *sc) bus_dmamem_free(sc->sc_dmat, &sc->re_ldata.re_tx_listseg, sc->re_ldata.re_tx_listnseg); - - shutdownhook_disestablish(sc->sc_sdhook); - powerhook_disestablish(sc->sc_powerhook); - return 0; } @@ -976,41 +951,6 @@ re_disable(struct rtk_softc *sc) } } -/* - * re_power: - * Power management (suspend/resume) hook. - */ -void -re_power(int why, void *arg) -{ - struct rtk_softc *sc = (void *)arg; - struct ifnet *ifp = &sc->ethercom.ec_if; - int s; - - s = splnet(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - re_stop(ifp, 0); - if (sc->sc_power != NULL) - (*sc->sc_power)(sc, why); - break; - case PWR_RESUME: - if (ifp->if_flags & IFF_UP) { - if (sc->sc_power != NULL) - (*sc->sc_power)(sc, why); - re_init(ifp); - } - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } - splx(s); -} - - static int re_newbuf(struct rtk_softc *sc, int idx, struct mbuf *m) { @@ -1376,20 +1316,6 @@ re_txeof(struct rtk_softc *sc) ifp->if_timer = 0; } -/* - * Stop all chip I/O so that the kernel's probe routines don't - * get confused by errant DMAs when rebooting. - */ -static void -re_shutdown(void *vsc) - -{ - struct rtk_softc *sc = vsc; - - re_stop(&sc->ethercom.ec_if, 0); -} - - static void re_tick(void *xsc) { diff --git a/sys/dev/ic/rtl81x9.c b/sys/dev/ic/rtl81x9.c index 524b1ec3a78..f38755c8e44 100644 --- a/sys/dev/ic/rtl81x9.c +++ b/sys/dev/ic/rtl81x9.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtl81x9.c,v 1.78 2007/11/06 02:29:20 uwe Exp $ */ +/* $NetBSD: rtl81x9.c,v 1.79 2007/12/09 20:27:59 jmcneill Exp $ */ /* * Copyright (c) 1997, 1998 @@ -86,7 +86,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rtl81x9.c,v 1.78 2007/11/06 02:29:20 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtl81x9.c,v 1.79 2007/12/09 20:27:59 jmcneill Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -140,7 +140,6 @@ STATIC int rtk_init(struct ifnet *); STATIC void rtk_stop(struct ifnet *, int); STATIC void rtk_watchdog(struct ifnet *); -STATIC void rtk_shutdown(void *); STATIC int rtk_ifmedia_upd(struct ifnet *); STATIC void rtk_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -157,7 +156,6 @@ STATIC void rtk_tick(void *); STATIC int rtk_enable(struct rtk_softc *); STATIC void rtk_disable(struct rtk_softc *); -STATIC void rtk_power(int, void *); STATIC void rtk_list_tx_init(struct rtk_softc *); @@ -755,24 +753,6 @@ rtk_attach(struct rtk_softc *sc) if_attach(ifp); ether_ifattach(ifp, eaddr); - /* - * Make sure the interface is shutdown during reboot. - */ - sc->sc_sdhook = shutdownhook_establish(rtk_shutdown, sc); - if (sc->sc_sdhook == NULL) - aprint_error_dev(self, - "WARNING: unable to establish shutdown hook\n"); - /* - * Add a suspend hook to make sure we come back up after a - * resume. - */ - sc->sc_powerhook = powerhook_establish(device_xname(self), - rtk_power, sc); - if (sc->sc_powerhook == NULL) - aprint_error_dev(self, - "WARNING: unable to establish power hook\n"); - - #if NRND > 0 rnd_attach_source(&sc->rnd_source, device_xname(self), RND_TYPE_NET, 0); @@ -886,9 +866,6 @@ rtk_detach(struct rtk_softc *sc) RTK_RXBUFLEN + 16); bus_dmamem_free(sc->sc_dmat, &sc->sc_dmaseg, sc->sc_dmanseg); - shutdownhook_disestablish(sc->sc_sdhook); - powerhook_disestablish(sc->sc_powerhook); - return 0; } @@ -926,40 +903,6 @@ rtk_disable(struct rtk_softc *sc) } /* - * rtk_power: - * Power management (suspend/resume) hook. - */ -void -rtk_power(int why, void *arg) -{ - struct rtk_softc *sc = (void *)arg; - struct ifnet *ifp = &sc->ethercom.ec_if; - int s; - - s = splnet(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - rtk_stop(ifp, 0); - if (sc->sc_power != NULL) - (*sc->sc_power)(sc, why); - break; - case PWR_RESUME: - if (ifp->if_flags & IFF_UP) { - if (sc->sc_power != NULL) - (*sc->sc_power)(sc, why); - rtk_init(ifp); - } - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } - splx(s); -} - -/* * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. * @@ -1619,18 +1562,6 @@ rtk_stop(struct ifnet *ifp, int disable) ifp->if_timer = 0; } -/* - * Stop all chip I/O so that the kernel's probe routines don't - * get confused by errant DMAs when rebooting. - */ -STATIC void -rtk_shutdown(void *arg) -{ - struct rtk_softc *sc = (struct rtk_softc *)arg; - - rtk_stop(&sc->ethercom.ec_if, 0); -} - STATIC void rtk_tick(void *arg) { diff --git a/sys/dev/ic/rtl81x9var.h b/sys/dev/ic/rtl81x9var.h index e1bb8b955d3..c35edd47750 100644 --- a/sys/dev/ic/rtl81x9var.h +++ b/sys/dev/ic/rtl81x9var.h @@ -1,4 +1,4 @@ -/* $NetBSD: rtl81x9var.h,v 1.39 2007/03/21 12:17:31 tsutsui Exp $ */ +/* $NetBSD: rtl81x9var.h,v 1.40 2007/12/09 20:27:59 jmcneill Exp $ */ /* * Copyright (c) 1997, 1998 @@ -215,13 +215,9 @@ struct rtk_softc { int sc_txthresh; /* Early tx threshold */ int sc_rev; /* MII revision */ - void *sc_sdhook; /* shutdown hook */ - void *sc_powerhook; /* power management hook */ - /* Power management hooks. */ int (*sc_enable) (struct rtk_softc *); void (*sc_disable) (struct rtk_softc *); - void (*sc_power) (struct rtk_softc *, int); #if NRND > 0 rndsource_element_t rnd_source; #endif diff --git a/sys/dev/ic/spic.c b/sys/dev/ic/spic.c index f169291355c..a9732c0f33c 100644 --- a/sys/dev/ic/spic.c +++ b/sys/dev/ic/spic.c @@ -1,4 +1,4 @@ -/* $NetBSD: spic.c,v 1.9 2007/10/19 12:00:02 ad Exp $ */ +/* $NetBSD: spic.c,v 1.10 2007/12/09 20:28:00 jmcneill Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: spic.c,v 1.9 2007/10/19 12:00:02 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spic.c,v 1.10 2007/12/09 20:28:00 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -74,6 +74,9 @@ __KERNEL_RCSID(0, "$NetBSD: spic.c,v 1.9 2007/10/19 12:00:02 ad Exp $"); #include <dev/wscons/wsconsio.h> #include <dev/wscons/wsmousevar.h> +#define SPIC_EVENT_BRIGHTNESS_DOWN 0x15 +#define SPIC_EVENT_BRIGHTNESS_UP 0x16 + #define POLLRATE (hz/30) /* Some hardware constants */ @@ -205,6 +208,12 @@ spic_intr(void *v) { case 0x1d: dz -= 0x20; break; + case SPIC_EVENT_BRIGHTNESS_UP: + pmf_event_inject(&sc->sc_dev, PMFE_DISPLAY_BRIGHTNESS_UP); + break; + case SPIC_EVENT_BRIGHTNESS_DOWN: + pmf_event_inject(&sc->sc_dev, PMFE_DISPLAY_BRIGHTNESS_DOWN); + break; default: printf("spic0: v1=0x%02x v2=0x%02x\n", v1, v2); goto skip; diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c index 2fe1cef7466..5a08014a6ef 100644 --- a/sys/dev/ic/vga.c +++ b/sys/dev/ic/vga.c @@ -1,4 +1,4 @@ -/* $NetBSD: vga.c,v 1.96 2007/10/19 12:00:04 ad Exp $ */ +/* $NetBSD: vga.c,v 1.97 2007/12/09 20:28:00 jmcneill Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.96 2007/10/19 12:00:04 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.97 2007/12/09 20:28:00 jmcneill Exp $"); /* for WSCONS_SUPPORT_PCVTFONTS */ #include "opt_wsdisplay_compat.h" @@ -1488,3 +1488,11 @@ vga_setborder(struct vga_config *vc, u_int value) return (0); } #endif /* WSDISPLAY_CUSTOM_BORDER */ + +void +vga_resume(struct vga_softc *sc) +{ +#ifdef VGA_RESET_ON_RESUME + vga_initregs(&sc->sc_vc->hdl); +#endif +} diff --git a/sys/dev/ic/vga_subr.c b/sys/dev/ic/vga_subr.c index 45f4b4e5807..ca951eeb3a3 100644 --- a/sys/dev/ic/vga_subr.c +++ b/sys/dev/ic/vga_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: vga_subr.c,v 1.22 2007/10/19 12:00:04 ad Exp $ */ +/* $NetBSD: vga_subr.c,v 1.23 2007/12/09 20:28:00 jmcneill Exp $ */ /* * Copyright (c) 1998 @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vga_subr.c,v 1.22 2007/10/19 12:00:04 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vga_subr.c,v 1.23 2007/12/09 20:28:00 jmcneill Exp $"); /* for WSDISPLAY_BORDER_COLOR */ #include "opt_wsdisplay_border.h" @@ -48,9 +48,6 @@ __KERNEL_RCSID(0, "$NetBSD: vga_subr.c,v 1.22 2007/10/19 12:00:04 ad Exp $"); static void fontram(struct vga_handle *); static void textram(struct vga_handle *); -#ifdef VGA_RESET -static void vga_initregs(struct vga_handle *); -#endif static void fontram(struct vga_handle *vh) @@ -214,7 +211,6 @@ vga_load_builtinfont(struct vga_handle *vh, u_int8_t *font, int firstchar, } #endif /* !VGA_RASTERCONSOLE */ -#ifdef VGA_RESET /* * vga_reset(): * Reset VGA registers to put it into 80x25 text mode. (mode 3) @@ -375,7 +371,7 @@ static const u_int8_t vga_dacpal[] = { 0x3f, 0x3f, 0x3f /* WHITE */ }; -static void +void vga_initregs(vh) struct vga_handle *vh; { @@ -427,4 +423,3 @@ vga_initregs(vh) /* reenable video */ vga_ts_write(vh, mode, vga_ts[1] & ~VGA_TS_MODE_BLANK); } -#endif /* VGA_RESET */ diff --git a/sys/dev/ic/vgavar.h b/sys/dev/ic/vgavar.h index 83552d6e7a8..20575f84f61 100644 --- a/sys/dev/ic/vgavar.h +++ b/sys/dev/ic/vgavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: vgavar.h,v 1.26 2007/03/04 06:02:03 christos Exp $ */ +/* $NetBSD: vgavar.h,v 1.27 2007/12/09 20:28:00 jmcneill Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -192,6 +192,8 @@ int vga_is_console(bus_space_tag_t, int); int vga_cnattach(bus_space_tag_t, bus_space_tag_t, int, int); int vga_cndetach(void); +void vga_resume(struct vga_softc *); + #ifndef VGA_RASTERCONSOLE struct wsscreen_descr; void vga_loadchars(struct vga_handle *, int, int, int, int, const char *); @@ -204,8 +206,7 @@ void vga_setscreentype(struct vga_handle *, const struct wsscreen_descr *); #else /* !VGA_RASTERCONSOLE */ void vga_load_builtinfont(struct vga_handle *, u_int8_t *, int, int); #endif /* !VGA_RASTERCONSOLE */ -#ifdef VGA_RESET void vga_reset(struct vga_handle *, void (*)(struct vga_handle *)); -#endif +void vga_initregs(struct vga_handle *); extern int vga_no_builtinfont; diff --git a/sys/dev/ic/wi.c b/sys/dev/ic/wi.c index 23c90e2ab32..af4ca44a71a 100644 --- a/sys/dev/ic/wi.c +++ b/sys/dev/ic/wi.c @@ -1,4 +1,4 @@ -/* $NetBSD: wi.c,v 1.222 2007/10/19 12:00:05 ad Exp $ */ +/* $NetBSD: wi.c,v 1.223 2007/12/09 20:28:00 jmcneill Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -106,7 +106,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.222 2007/10/19 12:00:05 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.223 2007/12/09 20:28:00 jmcneill Exp $"); #define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */ #define WI_HERMES_STATS_WAR /* Work around stats counter bug. */ @@ -630,43 +630,8 @@ wi_activate(struct device *self, enum devact act) splx(s); return rv; } - -void -wi_power(struct wi_softc *sc, int why) -{ - struct ifnet *ifp = &sc->sc_if; - int s; - - s = splnet(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - wi_stop(ifp, 1); - break; - case PWR_RESUME: - if (ifp->if_flags & IFF_UP) { - wi_init(ifp); - (void)wi_intr(sc); - } - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } - splx(s); -} #endif /* __NetBSD__ */ -void -wi_shutdown(struct wi_softc *sc) -{ - struct ifnet *ifp = &sc->sc_if; - - if (sc->sc_attached) - wi_stop(ifp, 1); -} - int wi_intr(void *arg) { diff --git a/sys/dev/ic/wivar.h b/sys/dev/ic/wivar.h index d63ae1cdb39..e6e288be062 100644 --- a/sys/dev/ic/wivar.h +++ b/sys/dev/ic/wivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: wivar.h,v 1.59 2007/03/04 06:02:04 christos Exp $ */ +/* $NetBSD: wivar.h,v 1.60 2007/12/09 20:28:00 jmcneill Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -285,5 +285,3 @@ int wi_attach(struct wi_softc *, const u_int8_t *); int wi_detach(struct wi_softc *); int wi_activate(struct device *, enum devact); int wi_intr(void *arg); -void wi_power(struct wi_softc *, int); -void wi_shutdown(struct wi_softc *); diff --git a/sys/dev/ieee1394/firewire.c b/sys/dev/ieee1394/firewire.c index fe7c10d1b44..bd7bb26375b 100644 --- a/sys/dev/ieee1394/firewire.c +++ b/sys/dev/ieee1394/firewire.c @@ -1,4 +1,4 @@ -/* $NetBSD: firewire.c,v 1.16 2007/11/05 19:08:56 kiyohara Exp $ */ +/* $NetBSD: firewire.c,v 1.17 2007/12/09 20:28:01 jmcneill Exp $ */ /*- * Copyright (c) 2003 Hidetoshi Shimokawa * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa @@ -563,6 +563,11 @@ FW_ATTACH(firewire) fw_busreset(fc, FWBUSNOTREADY); fc->ibr(fc); +#ifdef __NetBSD__ + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); +#endif + FW_ATTACH_RETURN(0); } diff --git a/sys/dev/ieee1394/fwohci.c b/sys/dev/ieee1394/fwohci.c index 4fc0eb99351..8e8b8784e45 100644 --- a/sys/dev/ieee1394/fwohci.c +++ b/sys/dev/ieee1394/fwohci.c @@ -1,4 +1,4 @@ -/* $NetBSD: fwohci.c,v 1.112 2007/11/06 15:24:11 kiyohara Exp $ */ +/* $NetBSD: fwohci.c,v 1.113 2007/12/09 20:28:01 jmcneill Exp $ */ /*- * Copyright (c) 2003 Hidetoshi Shimokawa @@ -37,7 +37,7 @@ * */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.112 2007/11/06 15:24:11 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.113 2007/12/09 20:28:01 jmcneill Exp $"); #define ATRQ_CH 0 #define ATRS_CH 1 @@ -2208,6 +2208,11 @@ fwohci_filt(void *arg) { struct fwohci_softc *sc = (struct fwohci_softc *)arg; +#if defined(__NetBSD__) + if (!device_is_active(sc->fc.dev)) + return (FILTER_STRAY); +#endif + if (!(sc->intmask & OHCI_INT_EN)) { /* polling mode */ return (FILTER_STRAY); diff --git a/sys/dev/ieee1394/if_fwip.c b/sys/dev/ieee1394/if_fwip.c index 20e2b177f26..be6a1f7a8d7 100644 --- a/sys/dev/ieee1394/if_fwip.c +++ b/sys/dev/ieee1394/if_fwip.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_fwip.c,v 1.10 2007/11/05 19:08:57 kiyohara Exp $ */ +/* $NetBSD: if_fwip.c,v 1.11 2007/12/09 20:28:01 jmcneill Exp $ */ /*- * Copyright (c) 2004 * Doug Rabson @@ -313,6 +313,13 @@ FW_ATTACH(fwip) FIREWIRE_IFATTACH(ifp, hwaddr); splx(s); +#if defined(__NetBSD__) + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, ifp); +#endif + FWIPDEBUG(ifp, "interface created\n"); FW_ATTACH_RETURN(0); } diff --git a/sys/dev/isa/aps.c b/sys/dev/isa/aps.c index 7d6227f1e2b..d3d6036704f 100644 --- a/sys/dev/isa/aps.c +++ b/sys/dev/isa/aps.c @@ -1,4 +1,4 @@ -/* $NetBSD: aps.c,v 1.4 2007/11/17 08:30:35 kefren Exp $ */ +/* $NetBSD: aps.c,v 1.5 2007/12/09 20:28:01 jmcneill Exp $ */ /* $OpenBSD: aps.c,v 1.15 2007/05/19 19:14:11 tedu Exp $ */ /* @@ -23,7 +23,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: aps.c,v 1.4 2007/11/17 08:30:35 kefren Exp $"); +__KERNEL_RCSID(0, "$NetBSD: aps.c,v 1.5 2007/12/09 20:28:01 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -103,7 +103,6 @@ struct aps_softc { struct callout sc_callout; struct sensor_rec aps_data; - void *sc_powerhook; }; static int aps_match(struct device *, struct cfdata *, void *); @@ -115,7 +114,8 @@ static uint8_t aps_mem_read_1(bus_space_tag_t, bus_space_handle_t, int, uint8_t); static void aps_refresh_sensor_data(struct aps_softc *sc); static void aps_refresh(void *); -static void aps_power(int, void *); +static bool aps_suspend(device_t); +static bool aps_resume(device_t); CFATTACH_DECL(aps, sizeof(struct aps_softc), aps_match, aps_attach, aps_detach, NULL); @@ -251,12 +251,8 @@ aps_attach(struct device *parent, struct device *self, void *aux) return; } - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - aps_power, - sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: can't establish powerhook\n", - device_xname(&sc->sc_dev)); + if (!pmf_device_register(self, aps_suspend, aps_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); /* Refresh sensor data every 0.5 seconds */ callout_init(&sc->sc_callout, 0); @@ -404,28 +400,36 @@ aps_refresh(void *arg) callout_schedule(&sc->sc_callout, (hz) / 2); } -static void -aps_power(int why, void *arg) +static bool +aps_suspend(device_t dv) { - struct aps_softc *sc = (struct aps_softc *)arg; + struct aps_softc *sc = device_private(dv); - if (why != PWR_RESUME) { - callout_stop(&sc->sc_callout); - } else { - /* - * Redo the init sequence on resume, because APS is - * as forgetful as it is deaf. - */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, APS_INIT, 0x13); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, APS_CMD, 0x01); - bus_space_read_1(sc->sc_iot, sc->sc_ioh, APS_CMD); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, APS_INIT, 0x13); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, APS_CMD, 0x01); - - if (aps_mem_read_1(sc->sc_iot, sc->sc_ioh, APS_CMD, 0x00) && - aps_init(sc)) - callout_schedule(&sc->sc_callout, (hz) / 2); - else - printf("aps: failed to wake up\n"); - } + callout_stop(&sc->sc_callout); + + return true; +} + +static bool +aps_resume(device_t dv) +{ + struct aps_softc *sc = device_private(dv); + + /* + * Redo the init sequence on resume, because APS is + * as forgetful as it is deaf. + */ + bus_space_write_1(sc->sc_iot, sc->sc_ioh, APS_INIT, 0x13); + bus_space_write_1(sc->sc_iot, sc->sc_ioh, APS_CMD, 0x01); + bus_space_read_1(sc->sc_iot, sc->sc_ioh, APS_CMD); + bus_space_write_1(sc->sc_iot, sc->sc_ioh, APS_INIT, 0x13); + bus_space_write_1(sc->sc_iot, sc->sc_ioh, APS_CMD, 0x01); + + if (aps_mem_read_1(sc->sc_iot, sc->sc_ioh, APS_CMD, 0x00) && + aps_init(sc)) + callout_schedule(&sc->sc_callout, (hz) / 2); + else + aprint_error_dev(dv, "failed to wake up\n"); + + return true; } diff --git a/sys/dev/isa/isa.c b/sys/dev/isa/isa.c index 08a81d0dcbc..dbe2640d4ce 100644 --- a/sys/dev/isa/isa.c +++ b/sys/dev/isa/isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: isa.c,v 1.130 2007/12/01 04:50:23 jmcneill Exp $ */ +/* $NetBSD: isa.c,v 1.131 2007/12/09 20:28:01 jmcneill Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: isa.c,v 1.130 2007/12/01 04:50:23 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isa.c,v 1.131 2007/12/09 20:28:01 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -136,6 +136,9 @@ isaattach(struct device *parent, struct device *self, void *aux) /* Attach all indrect-config children. */ isarescan(self, "isa", wildcard); + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } int diff --git a/sys/dev/isapnp/isapnp.c b/sys/dev/isapnp/isapnp.c index 6e431927d1a..ffe98d8004a 100644 --- a/sys/dev/isapnp/isapnp.c +++ b/sys/dev/isapnp/isapnp.c @@ -1,4 +1,4 @@ -/* $NetBSD: isapnp.c,v 1.54 2007/12/01 16:58:36 ad Exp $ */ +/* $NetBSD: isapnp.c,v 1.55 2007/12/09 20:28:02 jmcneill Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: isapnp.c,v 1.54 2007/12/01 16:58:36 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isapnp.c,v 1.55 2007/12/09 20:28:02 jmcneill Exp $"); #include "isadma.h" @@ -960,6 +960,9 @@ isapnp_attach(struct device *parent, struct device *self, void *aux) #else isapnp_callback(self); #endif + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } /* isapnp_callback diff --git a/sys/dev/mii/acphy.c b/sys/dev/mii/acphy.c index 804fa205ae4..8e2f6997e14 100644 --- a/sys/dev/mii/acphy.c +++ b/sys/dev/mii/acphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: acphy.c,v 1.19 2006/11/16 21:24:06 christos Exp $ */ +/* $NetBSD: acphy.c,v 1.20 2007/12/09 20:28:02 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acphy.c,v 1.19 2006/11/16 21:24:06 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acphy.c,v 1.20 2007/12/09 20:28:02 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -146,6 +146,9 @@ acphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/amhphy.c b/sys/dev/mii/amhphy.c index 80403732903..0ad58bc13c2 100644 --- a/sys/dev/mii/amhphy.c +++ b/sys/dev/mii/amhphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: amhphy.c,v 1.15 2006/11/16 21:24:06 christos Exp $ */ +/* $NetBSD: amhphy.c,v 1.16 2007/12/09 20:28:02 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: amhphy.c,v 1.15 2006/11/16 21:24:06 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amhphy.c,v 1.16 2007/12/09 20:28:02 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -120,6 +120,9 @@ amhphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/bmtphy.c b/sys/dev/mii/bmtphy.c index 948a851bb80..b892f7dc3f9 100644 --- a/sys/dev/mii/bmtphy.c +++ b/sys/dev/mii/bmtphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: bmtphy.c,v 1.22 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: bmtphy.c,v 1.23 2007/12/09 20:28:02 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bmtphy.c,v 1.22 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bmtphy.c,v 1.23 2007/12/09 20:28:02 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -169,6 +169,9 @@ bmtphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 5eed9bd2a90..ee85941be5e 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: brgphy.c,v 1.34 2007/08/06 12:16:33 markd Exp $ */ +/* $NetBSD: brgphy.c,v 1.35 2007/12/09 20:28:02 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.34 2007/08/06 12:16:33 markd Exp $"); +__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.35 2007/12/09 20:28:02 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -300,6 +300,9 @@ brgphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/ciphy.c b/sys/dev/mii/ciphy.c index 38e4a3610a5..4b09c5a32e4 100644 --- a/sys/dev/mii/ciphy.c +++ b/sys/dev/mii/ciphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: ciphy.c,v 1.12 2007/10/19 12:00:35 ad Exp $ */ +/* $NetBSD: ciphy.c,v 1.13 2007/12/09 20:28:02 jmcneill Exp $ */ /*- * Copyright (c) 2004 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ciphy.c,v 1.12 2007/10/19 12:00:35 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ciphy.c,v 1.13 2007/12/09 20:28:02 jmcneill Exp $"); /* * Driver for the Cicada CS8201 10/100/1000 copper PHY. @@ -141,6 +141,9 @@ ciphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/dmphy.c b/sys/dev/mii/dmphy.c index 81a7a0f7a0f..54533cfeaf4 100644 --- a/sys/dev/mii/dmphy.c +++ b/sys/dev/mii/dmphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: dmphy.c,v 1.27 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: dmphy.c,v 1.28 2007/12/09 20:28:02 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmphy.c,v 1.27 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmphy.c,v 1.28 2007/12/09 20:28:02 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -158,6 +158,9 @@ dmphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/exphy.c b/sys/dev/mii/exphy.c index 851534c053b..f6c114fc28d 100644 --- a/sys/dev/mii/exphy.c +++ b/sys/dev/mii/exphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: exphy.c,v 1.44 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: exphy.c,v 1.45 2007/12/09 20:28:02 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exphy.c,v 1.44 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exphy.c,v 1.45 2007/12/09 20:28:02 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -158,6 +158,9 @@ exphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/gentbi.c b/sys/dev/mii/gentbi.c index ea6cbc30fc3..70f1afecaf1 100644 --- a/sys/dev/mii/gentbi.c +++ b/sys/dev/mii/gentbi.c @@ -1,4 +1,4 @@ -/* $NetBSD: gentbi.c,v 1.18 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: gentbi.c,v 1.19 2007/12/09 20:28:02 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gentbi.c,v 1.18 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gentbi.c,v 1.19 2007/12/09 20:28:02 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -172,6 +172,9 @@ gentbiattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/glxtphy.c b/sys/dev/mii/glxtphy.c index 572a32ae893..089f71443c9 100644 --- a/sys/dev/mii/glxtphy.c +++ b/sys/dev/mii/glxtphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: glxtphy.c,v 1.17 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: glxtphy.c,v 1.18 2007/12/09 20:28:02 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: glxtphy.c,v 1.17 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: glxtphy.c,v 1.18 2007/12/09 20:28:02 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -158,6 +158,9 @@ glxtphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/gphyter.c b/sys/dev/mii/gphyter.c index 79d038d085e..121702801d2 100644 --- a/sys/dev/mii/gphyter.c +++ b/sys/dev/mii/gphyter.c @@ -1,4 +1,4 @@ -/* $NetBSD: gphyter.c,v 1.19 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: gphyter.c,v 1.20 2007/12/09 20:28:03 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gphyter.c,v 1.19 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gphyter.c,v 1.20 2007/12/09 20:28:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -183,6 +183,9 @@ gphyterattach(struct device *parent, struct device *self, void *aux) if (strap & STRAP_NC_MODE) aprint_normal(", pre-C5 BCM5400 compat enabled"); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/icsphy.c b/sys/dev/mii/icsphy.c index 73598a58c9b..189790a5899 100644 --- a/sys/dev/mii/icsphy.c +++ b/sys/dev/mii/icsphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: icsphy.c,v 1.41 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: icsphy.c,v 1.42 2007/12/09 20:28:03 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: icsphy.c,v 1.41 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: icsphy.c,v 1.42 2007/12/09 20:28:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -162,6 +162,9 @@ icsphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/igphy.c b/sys/dev/mii/igphy.c index db95a44a086..83e223187c1 100644 --- a/sys/dev/mii/igphy.c +++ b/sys/dev/mii/igphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: igphy.c,v 1.12 2007/08/28 01:11:50 msaitoh Exp $ */ +/* $NetBSD: igphy.c,v 1.13 2007/12/09 20:28:03 jmcneill Exp $ */ /* * The Intel copyright applies to the analog register setup, and the @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.12 2007/08/28 01:11:50 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.13 2007/12/09 20:28:03 jmcneill Exp $"); #include "opt_mii.h" @@ -174,6 +174,9 @@ igphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static void diff --git a/sys/dev/mii/ikphy.c b/sys/dev/mii/ikphy.c index 2185b9af9a9..3c9ab3ce748 100644 --- a/sys/dev/mii/ikphy.c +++ b/sys/dev/mii/ikphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: ikphy.c,v 1.3 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: ikphy.c,v 1.4 2007/12/09 20:28:03 jmcneill Exp $ */ /******************************************************************************* Copyright (c) 2001-2005, Intel Corporation @@ -64,7 +64,7 @@ POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ikphy.c,v 1.3 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ikphy.c,v 1.4 2007/12/09 20:28:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -148,6 +148,9 @@ ikphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/inphy.c b/sys/dev/mii/inphy.c index 1d8e19fbafd..b6e1e0be5f6 100644 --- a/sys/dev/mii/inphy.c +++ b/sys/dev/mii/inphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: inphy.c,v 1.43 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: inphy.c,v 1.44 2007/12/09 20:28:03 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: inphy.c,v 1.43 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: inphy.c,v 1.44 2007/12/09 20:28:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -164,6 +164,9 @@ inphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/iophy.c b/sys/dev/mii/iophy.c index f819445aad0..d3848235796 100644 --- a/sys/dev/mii/iophy.c +++ b/sys/dev/mii/iophy.c @@ -1,4 +1,4 @@ -/* $NetBSD: iophy.c,v 1.28 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: iophy.c,v 1.29 2007/12/09 20:28:03 jmcneill Exp $ */ /* * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: iophy.c,v 1.28 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iophy.c,v 1.29 2007/12/09 20:28:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -153,6 +153,9 @@ iophyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c index 4d9fc9f3825..a4aa2a7d6dc 100644 --- a/sys/dev/mii/lxtphy.c +++ b/sys/dev/mii/lxtphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: lxtphy.c,v 1.41 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: lxtphy.c,v 1.42 2007/12/09 20:28:03 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lxtphy.c,v 1.41 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lxtphy.c,v 1.42 2007/12/09 20:28:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -178,6 +178,9 @@ lxtphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/makphy.c b/sys/dev/mii/makphy.c index e9d2be069a6..a92ba99a1fd 100644 --- a/sys/dev/mii/makphy.c +++ b/sys/dev/mii/makphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: makphy.c,v 1.23 2007/02/23 03:03:10 msaitoh Exp $ */ +/* $NetBSD: makphy.c,v 1.24 2007/12/09 20:28:03 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.23 2007/02/23 03:03:10 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.24 2007/12/09 20:28:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -165,6 +165,9 @@ makphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static void diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c index d891a148c4b..3fd1ed65249 100644 --- a/sys/dev/mii/mii_physubr.c +++ b/sys/dev/mii/mii_physubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: mii_physubr.c,v 1.53 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: mii_physubr.c,v 1.54 2007/12/09 20:28:03 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.53 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.54 2007/12/09 20:28:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -633,3 +633,12 @@ mii_phy_flowstatus(struct mii_softc *sc) } /* NOTREACHED */ } + +bool +mii_phy_resume(device_t dv) +{ + struct mii_softc *sc = device_private(dv); + + PHY_RESET(sc); + return true; +} diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h index e9c37b2fd94..17cac6a965d 100644 --- a/sys/dev/mii/miivar.h +++ b/sys/dev/mii/miivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: miivar.h,v 1.47 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: miivar.h,v 1.48 2007/12/09 20:28:03 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -233,6 +233,7 @@ void mii_attach(struct device *, struct mii_data *, int, int, int, int); void mii_activate(struct mii_data *, enum devact, int, int); void mii_detach(struct mii_data *, int, int); +bool mii_phy_resume(device_t); int mii_mediachg(struct mii_data *); void mii_tick(struct mii_data *); diff --git a/sys/dev/mii/mvphy.c b/sys/dev/mii/mvphy.c index f9ec87904bb..420fb5a3af3 100644 --- a/sys/dev/mii/mvphy.c +++ b/sys/dev/mii/mvphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: mvphy.c,v 1.3 2007/02/17 23:23:38 jmcneill Exp $ */ +/* $NetBSD: mvphy.c,v 1.4 2007/12/09 20:28:03 jmcneill Exp $ */ /*- * Copyright (c) 2006 Sam Leffler, Errno Consulting @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mvphy.c,v 1.3 2007/02/17 23:23:38 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mvphy.c,v 1.4 2007/12/09 20:28:03 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -212,6 +212,9 @@ mvphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c index c51753b8bb4..0f6f38773a8 100644 --- a/sys/dev/mii/nsphy.c +++ b/sys/dev/mii/nsphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: nsphy.c,v 1.49 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: nsphy.c,v 1.50 2007/12/09 20:28:04 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsphy.c,v 1.49 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsphy.c,v 1.50 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -153,6 +153,9 @@ nsphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/nsphyter.c b/sys/dev/mii/nsphyter.c index f647a689bee..274fcc5075a 100644 --- a/sys/dev/mii/nsphyter.c +++ b/sys/dev/mii/nsphyter.c @@ -1,4 +1,4 @@ -/* $NetBSD: nsphyter.c,v 1.26 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: nsphyter.c,v 1.27 2007/12/09 20:28:04 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsphyter.c,v 1.26 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsphyter.c,v 1.27 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -161,6 +161,9 @@ nsphyterattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/pnaphy.c b/sys/dev/mii/pnaphy.c index 0d065408908..c23ba94abdc 100644 --- a/sys/dev/mii/pnaphy.c +++ b/sys/dev/mii/pnaphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: pnaphy.c,v 1.16 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: pnaphy.c,v 1.17 2007/12/09 20:28:04 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pnaphy.c,v 1.16 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pnaphy.c,v 1.17 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -130,6 +130,9 @@ pnaphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/qsphy.c b/sys/dev/mii/qsphy.c index 8e6bf5a1334..529b31e4724 100644 --- a/sys/dev/mii/qsphy.c +++ b/sys/dev/mii/qsphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: qsphy.c,v 1.40 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: qsphy.c,v 1.41 2007/12/09 20:28:04 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: qsphy.c,v 1.40 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: qsphy.c,v 1.41 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -152,6 +152,9 @@ qsphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/rgephy.c b/sys/dev/mii/rgephy.c index b66b119be99..56a28aca2b7 100644 --- a/sys/dev/mii/rgephy.c +++ b/sys/dev/mii/rgephy.c @@ -1,4 +1,4 @@ -/* $NetBSD: rgephy.c,v 1.16 2006/12/03 03:16:48 tsutsui Exp $ */ +/* $NetBSD: rgephy.c,v 1.17 2007/12/09 20:28:04 jmcneill Exp $ */ /* * Copyright (c) 2003 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.16 2006/12/03 03:16:48 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.17 2007/12/09 20:28:04 jmcneill Exp $"); /* @@ -153,6 +153,9 @@ rgephy_attach(struct device *parent, struct device *self, void *aux) PHY_RESET(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c index 28359af8313..3daf968022f 100644 --- a/sys/dev/mii/rlphy.c +++ b/sys/dev/mii/rlphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: rlphy.c,v 1.18 2007/11/06 00:58:32 uwe Exp $ */ +/* $NetBSD: rlphy.c,v 1.19 2007/12/09 20:28:04 jmcneill Exp $ */ /* $OpenBSD: rlphy.c,v 1.20 2005/07/31 05:27:30 pvalchev Exp $ */ /* @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rlphy.c,v 1.18 2007/11/06 00:58:32 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rlphy.c,v 1.19 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -140,6 +140,9 @@ rlphyattach(struct device *parent, struct device *self, void *aux) if (sc->mii_capabilities & BMSR_MEDIAMASK) mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } int diff --git a/sys/dev/mii/sqphy.c b/sys/dev/mii/sqphy.c index 56c1fb175a0..1298f0b43ce 100644 --- a/sys/dev/mii/sqphy.c +++ b/sys/dev/mii/sqphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: sqphy.c,v 1.42 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: sqphy.c,v 1.43 2007/12/09 20:28:04 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sqphy.c,v 1.42 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sqphy.c,v 1.43 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -173,6 +173,9 @@ sqphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/tlphy.c b/sys/dev/mii/tlphy.c index de7229de166..ca2940d71ba 100644 --- a/sys/dev/mii/tlphy.c +++ b/sys/dev/mii/tlphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: tlphy.c,v 1.51 2007/10/19 12:00:36 ad Exp $ */ +/* $NetBSD: tlphy.c,v 1.52 2007/12/09 20:28:04 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tlphy.c,v 1.51 2007/10/19 12:00:36 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tlphy.c,v 1.52 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -200,6 +200,9 @@ tlphyattach(struct device *parent, struct device *self, void *aux) aprint_normal("\n"); #undef ADD #undef PRINT + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/tqphy.c b/sys/dev/mii/tqphy.c index 9f5e63d2748..442f9c2932a 100644 --- a/sys/dev/mii/tqphy.c +++ b/sys/dev/mii/tqphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: tqphy.c,v 1.31 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: tqphy.c,v 1.32 2007/12/09 20:28:04 jmcneill Exp $ */ /* * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tqphy.c,v 1.31 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tqphy.c,v 1.32 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -165,6 +165,9 @@ tqphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/ukphy.c b/sys/dev/mii/ukphy.c index b868d5e89c8..5d8fe3e535b 100644 --- a/sys/dev/mii/ukphy.c +++ b/sys/dev/mii/ukphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: ukphy.c,v 1.30 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: ukphy.c,v 1.31 2007/12/09 20:28:04 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ukphy.c,v 1.30 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ukphy.c,v 1.31 2007/12/09 20:28:04 jmcneill Exp $"); #include "opt_mii.h" @@ -175,6 +175,9 @@ ukphyattach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/mii/urlphy.c b/sys/dev/mii/urlphy.c index 5b34f138e08..87e61fd138b 100644 --- a/sys/dev/mii/urlphy.c +++ b/sys/dev/mii/urlphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: urlphy.c,v 1.18 2006/11/16 21:24:07 christos Exp $ */ +/* $NetBSD: urlphy.c,v 1.19 2007/12/09 20:28:04 jmcneill Exp $ */ /* * Copyright (c) 2001, 2002 * Shingo WATANABE <nabe@nabechan.org>. All rights reserved. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: urlphy.c,v 1.18 2006/11/16 21:24:07 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: urlphy.c,v 1.19 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -131,6 +131,9 @@ urlphy_attach(struct device *parent, struct device *self, void *aux) else mii_phy_add_media(sc); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, mii_phy_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/pad/pad.c b/sys/dev/pad/pad.c index 8c6f91e678e..84564631508 100644 --- a/sys/dev/pad/pad.c +++ b/sys/dev/pad/pad.c @@ -1,4 +1,4 @@ -/* $NetBSD: pad.c,v 1.3 2007/12/05 07:06:52 ad Exp $ */ +/* $NetBSD: pad.c,v 1.4 2007/12/09 20:28:04 jmcneill Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.3 2007/12/05 07:06:52 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.4 2007/12/09 20:28:04 jmcneill Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -254,7 +254,6 @@ pad_attach(struct device *parent, struct device *self, void *opaque) sc = (pad_softc_t *)self; - aprint_normal_dev(self, "Pseudo Audio Device\n"); aprint_normal_dev(self, "outputs: 44100Hz, 16-bit, stereo\n"); sc->sc_open = 0; @@ -272,6 +271,9 @@ pad_attach(struct device *parent, struct device *self, void *opaque) sc->sc_rpos = sc->sc_wpos = 0; sc->sc_audiodev = (void *)audio_attach_mi(&pad_hw_if, sc, &sc->sc_dev); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + return; } diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c index 8bcece80232..dadf6b5f536 100644 --- a/sys/dev/pci/agp.c +++ b/sys/dev/pci/agp.c @@ -1,4 +1,4 @@ -/* $NetBSD: agp.c,v 1.53 2007/12/05 07:06:52 ad Exp $ */ +/* $NetBSD: agp.c,v 1.54 2007/12/09 20:28:05 jmcneill Exp $ */ /*- * Copyright (c) 2000 Doug Rabson @@ -65,7 +65,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: agp.c,v 1.53 2007/12/05 07:06:52 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: agp.c,v 1.54 2007/12/09 20:28:05 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -103,6 +103,7 @@ static int agp_deallocate_user(struct agp_softc *, int); static int agp_bind_user(struct agp_softc *, agp_bind *); static int agp_unbind_user(struct agp_softc *, agp_unbind *); static int agpdev_match(struct pci_attach_args *); +static bool agp_resume(device_t); #include "agp_ali.h" #include "agp_amd.h" @@ -334,6 +335,11 @@ agpattach(struct device *parent, struct device *self, void *aux) (unsigned long)AGP_GET_APERTURE(sc)); else sc->as_chipc = NULL; + + if (!device_pmf_is_registered(self)) { + if (!pmf_device_register(self, NULL, agp_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + } } CFATTACH_DECL(agp, sizeof(struct agp_softc), @@ -1082,3 +1088,11 @@ agp_free_dmamem(bus_dma_tag_t tag, size_t size, bus_dmamap_t map, bus_dmamem_unmap(tag, vaddr, size); bus_dmamem_free(tag, seg, nseg); } + +static bool +agp_resume(device_t dv) +{ + agp_flush_cache(); + + return true; +} diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c index c3aff255fd3..0b141f8d186 100644 --- a/sys/dev/pci/agp_i810.c +++ b/sys/dev/pci/agp_i810.c @@ -1,4 +1,4 @@ -/* $NetBSD: agp_i810.c,v 1.46 2007/11/24 02:19:37 markd Exp $ */ +/* $NetBSD: agp_i810.c,v 1.47 2007/12/09 20:28:05 jmcneill Exp $ */ /*- * Copyright (c) 2000 Doug Rabson @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.46 2007/11/24 02:19:37 markd Exp $"); +__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.47 2007/12/09 20:28:05 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -95,8 +95,7 @@ struct agp_i810_softc { bus_space_handle_t gtt_bsh; /* GTT bus_space handle */ struct pci_attach_args vga_pa; - void *sc_powerhook; - struct pci_conf_state sc_pciconf; + u_int32_t pgtblctl; }; static u_int32_t agp_i810_get_aperture(struct agp_softc *); @@ -110,7 +109,9 @@ static struct agp_memory *agp_i810_alloc_memory(struct agp_softc *, int, static int agp_i810_free_memory(struct agp_softc *, struct agp_memory *); static int agp_i810_bind_memory(struct agp_softc *, struct agp_memory *, off_t); static int agp_i810_unbind_memory(struct agp_softc *, struct agp_memory *); -static void agp_i810_powerhook(int, void *); + +static bool agp_i810_resume(device_t); +static int agp_i810_init(struct agp_softc *); static int agp_i810_init(struct agp_softc *); @@ -331,6 +332,9 @@ agp_i810_attach(struct device *parent, struct device *self, void *aux) gatt->ag_entries = AGP_GET_APERTURE(sc) >> AGP_PAGE_SHIFT; + if (!pmf_device_register(self, NULL, agp_i810_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + return agp_i810_init(sc); } @@ -500,12 +504,6 @@ static int agp_i810_init(struct agp_softc *sc) */ agp_flush_cache(); - isc->sc_powerhook = powerhook_establish(sc->as_dev.dv_xname, - agp_i810_powerhook, sc); - if (isc->sc_powerhook == NULL) - printf("%s: WARNING: unable to establish PCI power hook\n", - sc->as_dev.dv_xname); - #if 0 /* * another device (drm) may need access to this region @@ -888,17 +886,14 @@ agp_i810_unbind_memory(struct agp_softc *sc, struct agp_memory *mem) return 0; } -static void -agp_i810_powerhook(int why, void *arg) +static bool +agp_i810_resume(device_t dv) { - struct agp_softc *sc = (struct agp_softc *)arg; + struct agp_softc *sc = device_private(dv); struct agp_i810_softc *isc = sc->as_chipc; - if (why == PWR_RESUME) { - pci_conf_restore(sc->as_pc, sc->as_tag, &isc->sc_pciconf); - agp_flush_cache(); - } else if ((why == PWR_STANDBY) || (why == PWR_SUSPEND)) - pci_conf_capture(sc->as_pc, sc->as_tag, &isc->sc_pciconf); + isc->pgtblctl = READ4(AGP_I810_PGTBL_CTL); + agp_flush_cache(); - return; + return true; } diff --git a/sys/dev/pci/agp_intel.c b/sys/dev/pci/agp_intel.c index c83fc2ddad4..46c56ccb104 100644 --- a/sys/dev/pci/agp_intel.c +++ b/sys/dev/pci/agp_intel.c @@ -1,4 +1,4 @@ -/* $NetBSD: agp_intel.c,v 1.24 2007/11/12 20:00:17 joerg Exp $ */ +/* $NetBSD: agp_intel.c,v 1.25 2007/12/09 20:28:05 jmcneill Exp $ */ /*- * Copyright (c) 2000 Doug Rabson @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: agp_intel.c,v 1.24 2007/11/12 20:00:17 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: agp_intel.c,v 1.25 2007/12/09 20:28:05 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -64,8 +64,6 @@ struct agp_intel_softc { #define CHIP_I850 0x4 #define CHIP_I865 0x5 - void *sc_powerhook; - struct pci_conf_state sc_pciconf; }; static u_int32_t agp_intel_get_aperture(struct agp_softc *); @@ -73,8 +71,8 @@ static int agp_intel_set_aperture(struct agp_softc *, u_int32_t); static int agp_intel_bind_page(struct agp_softc *, off_t, bus_addr_t); static int agp_intel_unbind_page(struct agp_softc *, off_t); static void agp_intel_flush_tlb(struct agp_softc *); -static void agp_intel_powerhook(int, void *); static int agp_intel_init(struct agp_softc *); +static bool agp_intel_resume(device_t); static struct agp_methods agp_intel_methods = { agp_intel_get_aperture, @@ -190,6 +188,9 @@ agp_intel_attach(struct device *parent, struct device *self, void *aux) } isc->gatt = gatt; + if (!pmf_device_register(self, NULL, agp_intel_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + return agp_intel_init(sc); } @@ -267,12 +268,6 @@ agp_intel_init(struct agp_softc *sc) AGP_INTEL_ERRSTS, 0x70); } - isc->sc_powerhook = powerhook_establish(sc->as_dev.dv_xname, - agp_intel_powerhook, sc); - if (isc->sc_powerhook == NULL) - aprint_error("%s: couldn't establish powerhook\n", - sc->as_dev.dv_xname); - return (0); } @@ -284,9 +279,6 @@ agp_intel_detach(struct agp_softc *sc) pcireg_t reg; struct agp_intel_softc *isc = sc->as_chipc; - if (isc->sc_powerhook) - powerhook_disestablish(isc->sc_powerhook); - error = agp_generic_detach(sc); if (error) return error; @@ -402,29 +394,13 @@ agp_intel_flush_tlb(struct agp_softc *sc) } } -static void -agp_intel_powerhook(int why, void *opaque) +static bool +agp_intel_resume(device_t dv) { - struct agp_softc *sc; - struct agp_intel_softc *isc; + struct agp_softc *sc = device_private(dv); - sc = (struct agp_softc *)opaque; - isc = (struct agp_intel_softc *)sc->as_chipc; - - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - pci_conf_capture(sc->as_pc, sc->as_tag, &isc->sc_pciconf); - break; - case PWR_RESUME: - pci_conf_restore(sc->as_pc, sc->as_tag, &isc->sc_pciconf); - agp_flush_cache(); - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } + agp_intel_init(sc); + agp_flush_cache(); - return; + return true; } diff --git a/sys/dev/pci/ahcisata_pci.c b/sys/dev/pci/ahcisata_pci.c index 30088a929ef..0f861877325 100644 --- a/sys/dev/pci/ahcisata_pci.c +++ b/sys/dev/pci/ahcisata_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_pci.c,v 1.1 2007/05/12 11:04:59 bouyer Exp $ */ +/* $NetBSD: ahcisata_pci.c,v 1.2 2007/12/09 20:28:05 jmcneill Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.1 2007/05/12 11:04:59 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.2 2007/12/09 20:28:05 jmcneill Exp $"); #include <sys/types.h> #include <sys/malloc.h> @@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.1 2007/05/12 11:04:59 bouyer Exp #include <sys/kernel.h> #include <sys/systm.h> #include <sys/disklabel.h> +#include <sys/pmf.h> #include <uvm/uvm_extern.h> @@ -48,10 +49,19 @@ __KERNEL_RCSID(0, "$NetBSD: ahcisata_pci.c,v 1.1 2007/05/12 11:04:59 bouyer Exp #include <dev/pci/pciidevar.h> #include <dev/ic/ahcisatavar.h> +struct ahci_pci_softc { + struct ahci_softc ah_sc; /* must come first, struct device */ + pci_chipset_tag_t sc_pc; + pcitag_t sc_pcitag; +}; + + static int ahci_pci_match(struct device *, struct cfdata *, void *); static void ahci_pci_attach(struct device *, struct device *, void *); +static bool ahci_pci_resume(device_t); + -CFATTACH_DECL(ahcisata_pci, sizeof(struct ahci_softc), +CFATTACH_DECL(ahcisata_pci, sizeof(struct ahci_pci_softc), ahci_pci_match, ahci_pci_attach, NULL, NULL); static int @@ -85,7 +95,8 @@ static void ahci_pci_attach(struct device *parent, struct device *self, void *aux) { struct pci_attach_args *pa = aux; - struct ahci_softc *sc = (struct ahci_softc *)self; + struct ahci_pci_softc *psc = (struct ahci_pci_softc *)self; + struct ahci_softc *sc = &psc->ah_sc; bus_size_t size; char devinfo[256]; const char *intrstr; @@ -98,6 +109,9 @@ ahci_pci_attach(struct device *parent, struct device *self, void *aux) aprint_error("%s: can't map ahci registers\n", AHCINAME(sc)); return; } + psc->sc_pc = pa->pa_pc; + psc->sc_pcitag = pa->pa_tag; + pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo)); aprint_naive(": AHCI disk controller\n"); aprint_normal(": %s\n", devinfo); @@ -116,4 +130,24 @@ ahci_pci_attach(struct device *parent, struct device *self, void *aux) intrstr ? intrstr : "unknown interrupt"); sc->sc_dmat = pa->pa_dmat; ahci_attach(sc); + + if (!pmf_device_register(self, NULL, ahci_pci_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); +} + +static bool +ahci_pci_resume(device_t dv) +{ + struct ahci_pci_softc *psc = device_private(dv); + struct ahci_softc *sc = &psc->ah_sc; + int s; + + s = splbio(); + ahci_reset(sc); + ahci_setup_ports(sc); + ahci_reprobe_drives(sc); + ahci_enable_intrs(sc); + splx(s); + + return true; } diff --git a/sys/dev/pci/auacer.c b/sys/dev/pci/auacer.c index e49c72079b9..e9ebbdc5a87 100644 --- a/sys/dev/pci/auacer.c +++ b/sys/dev/pci/auacer.c @@ -1,4 +1,4 @@ -/* $NetBSD: auacer.c,v 1.17 2007/10/19 12:00:40 ad Exp $ */ +/* $NetBSD: auacer.c,v 1.18 2007/12/09 20:28:05 jmcneill Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -51,7 +51,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: auacer.c,v 1.17 2007/10/19 12:00:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auacer.c,v 1.18 2007/12/09 20:28:05 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -133,10 +133,6 @@ struct auacer_softc { int sc_dmamap_flags; - /* Power Management */ - void *sc_powerhook; - int sc_suspend; - #define AUACER_NFORMATS 3 struct audio_format sc_formats[AUACER_NFORMATS]; struct audio_encoding_set *sc_encodings; @@ -194,7 +190,7 @@ static int auacer_allocmem(struct auacer_softc *, size_t, size_t, struct auacer_dma *); static int auacer_freemem(struct auacer_softc *, struct auacer_dma *); -static void auacer_powerhook(int, void *); +static bool auacer_resume(device_t); static int auacer_set_rate(struct auacer_softc *, int, u_int); static void auacer_reset(struct auacer_softc *sc); @@ -350,14 +346,12 @@ auacer_attach(struct device *parent, struct device *self, void *aux) return; } - /* Watch for power change */ - sc->sc_suspend = PWR_RESUME; - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - auacer_powerhook, sc); - audio_attach_mi(&auacer_hw_if, sc, &sc->sc_dev); auacer_reset(sc); + + if (!pmf_device_register(self, NULL, auacer_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } CFATTACH_DECL(auacer, sizeof(struct auacer_softc), @@ -1030,38 +1024,14 @@ auacer_alloc_cdata(struct auacer_softc *sc) return error; } -static void -auacer_powerhook(int why, void *addr) +static bool +auacer_resume(device_t dv) { - struct auacer_softc *sc; + struct auacer_softc *sc = device_private(dv); - sc = (struct auacer_softc *)addr; - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - /* Power down */ - DPRINTF(1, ("%s: power down\n", sc->sc_dev.dv_xname)); - sc->sc_suspend = why; - break; - - case PWR_RESUME: - /* Wake up */ - DPRINTF(1, ("%s: power resume\n", sc->sc_dev.dv_xname)); - if (sc->sc_suspend == PWR_RESUME) { - printf("%s: resume without suspend.\n", - sc->sc_dev.dv_xname); - sc->sc_suspend = why; - return; - } - sc->sc_suspend = why; - auacer_reset_codec(sc); - delay(1000); - sc->codec_if->vtbl->restore_ports(sc->codec_if); - break; - - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } + auacer_reset_codec(sc); + delay(1000); + sc->codec_if->vtbl->restore_ports(sc->codec_if); + + return true; } diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c index 924947dbdc0..624f379bd4d 100644 --- a/sys/dev/pci/auich.c +++ b/sys/dev/pci/auich.c @@ -1,4 +1,4 @@ -/* $NetBSD: auich.c,v 1.119 2007/10/19 12:00:40 ad Exp $ */ +/* $NetBSD: auich.c,v 1.120 2007/12/09 20:28:05 jmcneill Exp $ */ /*- * Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc. @@ -118,7 +118,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.119 2007/10/19 12:00:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.120 2007/12/09 20:28:05 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -217,12 +217,6 @@ struct auich_softc { /* 440MX workaround */ int sc_dmamap_flags; - /* Power Management */ - void *sc_powerhook; - int sc_suspend; - int sc_powerstate; - struct pci_conf_state sc_pciconf; - /* sysctl */ struct sysctllog *sc_log; uint32_t sc_ac97_clock; @@ -291,7 +285,7 @@ static int auich_allocmem(struct auich_softc *, size_t, size_t, struct auich_dma *); static int auich_freemem(struct auich_softc *, struct auich_dma *); -static void auich_powerhook(int, void *); +static bool auich_resume(device_t); static int auich_set_rate(struct auich_softc *, int, u_long); static int auich_sysctl_verify(SYSCTLFN_ARGS); static void auich_finish_attach(struct device *); @@ -645,11 +639,9 @@ auich_attach(struct device *parent, struct device *self, void *aux) return; } - /* Watch for power change */ - sc->sc_suspend = PWR_RESUME; - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - auich_powerhook, sc); + if (!pmf_device_register(self, NULL, auich_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); config_interrupts(self, auich_finish_attach); @@ -777,10 +769,6 @@ auich_finish_attach(struct device *self) sc->sc_audiodev = audio_attach_mi(&auich_hw_if, sc, &sc->sc_dev); -#if notyet - auich_powerhook(PWR_SUSPEND, sc); -#endif - return; } @@ -1245,6 +1233,10 @@ auich_intr(void *v) #endif sc = v; + + if (!device_has_power(&sc->sc_dev)) + return (0); + ret = 0; #ifdef DIAGNOSTIC csts = pci_conf_read(sc->sc_pc, sc->sc_pt, PCI_COMMAND_STATUS_REG); @@ -1479,31 +1471,7 @@ auich_trigger_input(void *v, void *start, void *end, int blksize, static int auich_powerstate(void *v, int state) { -#if notyet - struct auich_softc *sc; - int rv; - - sc = (struct auich_softc *)v; - rv = 0; - - switch (state) { - case AUDIOPOWER_OFF: - auich_powerhook(PWR_SUSPEND, sc); - break; - case AUDIOPOWER_ON: - auich_powerhook(PWR_RESUME, sc); - break; - default: - aprint_error("%s: unknown power state %d\n", - sc->sc_dev.dv_xname, state); - rv = 1; - break; - } - - return rv; -#else return 0; -#endif } static int @@ -1615,62 +1583,15 @@ auich_alloc_cdata(struct auich_softc *sc) return error; } -static void -auich_powerhook(int why, void *addr) +static bool +auich_resume(device_t dv) { - struct auich_softc *sc; - - sc = (struct auich_softc *)addr; - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - /* Power down */ - DPRINTF(1, ("%s: power down\n", sc->sc_dev.dv_xname)); - - /* if we're already asleep, don't try to sleep again */ - if (sc->sc_suspend == PWR_SUSPEND || - sc->sc_suspend == PWR_STANDBY) - break; - sc->sc_suspend = why; - - DELAY(1000); - pci_conf_capture(sc->sc_pc, sc->sc_pt, &sc->sc_pciconf); - - if (sc->sc_ih != NULL) - pci_intr_disestablish(sc->sc_pc, sc->sc_ih); - - break; + struct auich_softc *sc = device_private(dv); - case PWR_RESUME: - /* Wake up */ - DPRINTF(1, ("%s: power resume\n", sc->sc_dev.dv_xname)); - if (sc->sc_suspend == PWR_RESUME) { - printf("%s: resume without suspend.\n", - sc->sc_dev.dv_xname); - sc->sc_suspend = why; - return; - } - - sc->sc_ih = pci_intr_establish(sc->sc_pc, sc->intrh, IPL_AUDIO, - auich_intr, sc); - if (sc->sc_ih == NULL) { - aprint_error("%s: can't establish interrupt", - sc->sc_dev.dv_xname); - /* XXX jmcneill what should we do here? */ - return; - } - pci_conf_restore(sc->sc_pc, sc->sc_pt, &sc->sc_pciconf); - sc->sc_suspend = why; - auich_reset_codec(sc); - DELAY(1000); - (sc->codec_if->vtbl->restore_ports)(sc->codec_if); - break; - - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } + auich_reset_codec(sc); + DELAY(1000); + (sc->codec_if->vtbl->restore_ports)(sc->codec_if); + return true; } /* diff --git a/sys/dev/pci/auixp.c b/sys/dev/pci/auixp.c index 06702904ec0..f4aabc8ffa2 100644 --- a/sys/dev/pci/auixp.c +++ b/sys/dev/pci/auixp.c @@ -1,4 +1,4 @@ -/* $NetBSD: auixp.c,v 1.24 2007/10/19 12:00:40 ad Exp $ */ +/* $NetBSD: auixp.c,v 1.25 2007/12/09 20:28:05 jmcneill Exp $ */ /* * Copyright (c) 2004, 2005 Reinoud Zandijk <reinoud@netbsd.org> @@ -50,7 +50,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: auixp.c,v 1.24 2007/10/19 12:00:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auixp.c,v 1.25 2007/12/09 20:28:05 jmcneill Exp $"); #include <sys/types.h> #include <sys/errno.h> @@ -164,15 +164,6 @@ static int auixp_allocmem(struct auixp_softc *, size_t, size_t, static int auixp_freemem(struct auixp_softc *, struct auixp_dma *); static paddr_t auixp_mappage(void *, void *, off_t, int); - -/* power management (do we support that already?) */ -#if 0 -static void auixp_powerhook(int, void *); -static int auixp_suspend(struct auixp_softc *); -static int auixp_resume(struct auixp_softc *); -#endif - - /* Supporting subroutines */ static int auixp_init(struct auixp_softc *); static void auixp_autodetect_codecs(struct auixp_softc *); @@ -203,6 +194,8 @@ static void auixp_program_dma_chain(struct auixp_softc *, static void auixp_dma_update(struct auixp_softc *, struct auixp_dma *); static void auixp_update_busbusy(struct auixp_softc *); +static bool auixp_resume(device_t); + #ifdef DEBUG_AUIXP static struct auixp_softc *static_sc; @@ -1107,7 +1100,7 @@ auixp_attach(struct device *parent, struct device *self, void *aux) const char *intrstr; uint32_t data; char devinfo[256]; - int revision, len, error; + int revision, error; sc = (struct auixp_softc *)self; pa = (struct pci_attach_args *)aux; @@ -1202,27 +1195,8 @@ auixp_attach(struct device *parent, struct device *self, void *aux) return; } - /* XXX set up power hooks; not implemented yet XXX */ - - len = 1; /* shut up gcc */ -#ifdef notyet - /* create suspend save area */ - len = sizeof(uint16_t) * (ESA_REV_B_CODE_MEMORY_LENGTH - + ESA_REV_B_DATA_MEMORY_LENGTH + 1); - sc->savemem = (uint16_t *)malloc(len, M_DEVBUF, M_NOWAIT | M_ZERO); - if (sc->savemem == NULL) { - aprint_error("%s: unable to allocate suspend buffer\n", - sc->sc_dev.dv_xname); - return; - } - - sc->powerhook = powerhook_establish(sc->sc_dev.dv_xname, - auixp_powerhook, sc); - if (sc->powerhook == NULL) - aprint_error("%s: WARNING: unable to establish powerhook\n", - sc->sc_dev.dv_xname); - -#endif + if (!pmf_device_register(self, NULL, auixp_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); /* * delay further configuration of codecs and audio after interrupts @@ -1393,8 +1367,7 @@ auixp_detach(struct device *self, int flags) if (sc->sc_ios) bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); - if (sc->savemem) - free(sc->savemem, M_DEVBUF); + pmf_device_deregister(self); return 0; } @@ -1785,52 +1758,17 @@ auixp_init(struct auixp_softc *sc) return 0; } - -/* - * TODO power saving and suspend / resume support - * - */ - -#if 0 -static void -auixp_powerhook(int why, void *hdl) -{ - struct auixp_softc *sc; - - sc = (struct auixp_softc *)hdl; - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - auixp_suspend(sc); - break; - case PWR_RESUME: - auixp_resume(sc); -#if notyet - /* XXX fix me XXX */ - (sc->codec_if->vtbl->restore_ports)(sc->codec_if); -#endif - break; - } -} - - -static int -auixp_suspend(struct auixp_softc *sc) +static bool +auixp_resume(device_t dv) { + struct auixp_softc *sc = device_private(dv); - /* XXX no power functions yet XXX */ - return 0; -} - + auixp_reset_codec(sc); + delay(1000); + (sc->sc_codec[0].codec_if->vtbl->restore_ports)(sc->sc_codec[0].codec_if); -static int -auixp_resume(struct auixp_softc *sc) -{ - - /* XXX no power functions yet XXX */ - return 0; + return true; } -#endif /* 0 */ #ifdef DEBUG_AUIXP diff --git a/sys/dev/pci/auixpvar.h b/sys/dev/pci/auixpvar.h index 00c4843f0d4..8ab76770088 100644 --- a/sys/dev/pci/auixpvar.h +++ b/sys/dev/pci/auixpvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: auixpvar.h,v 1.5 2007/03/04 06:02:16 christos Exp $*/ +/* $NetBSD: auixpvar.h,v 1.6 2007/12/09 20:28:06 jmcneill Exp $*/ /* * Copyright (c) 2004, 2005 Reinoud Zandijk <reinoud@netbsd.org> @@ -138,10 +138,6 @@ struct auixp_softc { /* last set audio parameters */ struct audio_params sc_play_params; struct audio_params sc_rec_params; - - /* suspend/resume */ - void *powerhook; - uint16_t *savemem; }; diff --git a/sys/dev/pci/autri.c b/sys/dev/pci/autri.c index 75ba1cb1c22..c7a105e3a48 100644 --- a/sys/dev/pci/autri.c +++ b/sys/dev/pci/autri.c @@ -1,4 +1,4 @@ -/* $NetBSD: autri.c,v 1.35 2007/10/19 12:00:40 ad Exp $ */ +/* $NetBSD: autri.c,v 1.36 2007/12/09 20:28:06 jmcneill Exp $ */ /* * Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autri.c,v 1.35 2007/10/19 12:00:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autri.c,v 1.36 2007/12/09 20:28:06 jmcneill Exp $"); #include "midi.h" @@ -97,7 +97,7 @@ static int autri_write_codec(void *, uint8_t, uint16_t); static int autri_reset_codec(void *); static enum ac97_host_flags autri_flags_codec(void *); -static void autri_powerhook(int, void *); +static bool autri_resume(device_t); static int autri_init(void *); static struct autri_dma *autri_find_dma(struct autri_softc *, void *); static void autri_setup_channel(struct autri_softc *, int, @@ -592,32 +592,28 @@ autri_attach(struct device *parent, struct device *self, void *aux) return; } + if (!pmf_device_register(self, NULL, autri_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + audio_attach_mi(&autri_hw_if, sc, &sc->sc_dev); #if NMIDI > 0 midi_attach_mi(&autri_midi_hw_if, sc, &sc->sc_dev); #endif - - sc->sc_old_power = PWR_RESUME; - powerhook_establish(sc->sc_dev.dv_xname, autri_powerhook, sc); } CFATTACH_DECL(autri, sizeof(struct autri_softc), autri_match, autri_attach, NULL, NULL); -static void -autri_powerhook(int why, void *addr) +static bool +autri_resume(device_t dv) { - struct autri_softc *sc; + struct autri_softc *sc = device_private(dv); - sc = addr; - if (why == PWR_RESUME && sc->sc_old_power == PWR_SUSPEND) { - DPRINTF(("PWR_RESUME\n")); - autri_init(sc); - /*autri_reset_codec(&sc->sc_codec);*/ - (sc->sc_codec.codec_if->vtbl->restore_ports)(sc->sc_codec.codec_if); - } - sc->sc_old_power = why; + autri_init(sc); + (sc->sc_codec.codec_if->vtbl->restore_ports)(sc->sc_codec.codec_if); + + return true; } static int diff --git a/sys/dev/pci/autrivar.h b/sys/dev/pci/autrivar.h index 87b2e5d90f4..3ea4da811c1 100644 --- a/sys/dev/pci/autrivar.h +++ b/sys/dev/pci/autrivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: autrivar.h,v 1.3 2007/03/04 06:02:16 christos Exp $ */ +/* $NetBSD: autrivar.h,v 1.4 2007/12/09 20:28:06 jmcneill Exp $ */ /* * Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro. @@ -86,8 +86,6 @@ struct autri_softc { u_int32_t sc_class; int sc_revision; - int sc_old_power; - /* * Play/record status */ diff --git a/sys/dev/pci/auvia.c b/sys/dev/pci/auvia.c index bad34ff3308..8f7fd927f7e 100644 --- a/sys/dev/pci/auvia.c +++ b/sys/dev/pci/auvia.c @@ -1,4 +1,4 @@ -/* $NetBSD: auvia.c,v 1.60 2007/03/04 06:02:16 christos Exp $ */ +/* $NetBSD: auvia.c,v 1.61 2007/12/09 20:28:06 jmcneill Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.60 2007/03/04 06:02:16 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.61 2007/12/09 20:28:06 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -118,7 +118,7 @@ static int auvia_trigger_output(void *, void *, void *, int, static int auvia_trigger_input(void *, void *, void *, int, void (*)(void *), void *, const audio_params_t *); -static void auvia_powerhook(int, void *); +static bool auvia_resume(device_t); static int auvia_intr(void *); static int auvia_attach_codec(void *, struct ac97_codec_if *); @@ -453,10 +453,8 @@ auvia_attach(struct device *parent, struct device *self, void *aux) return; } - /* Watch for power change */ - sc->sc_suspend = PWR_RESUME; - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - auvia_powerhook, sc); + if (!pmf_device_register(self, NULL, auvia_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); audio_attach_mi(&auvia_hw_if, sc, &sc->sc_dev); sc->codec_if->vtbl->unlock(sc->codec_if); @@ -1113,36 +1111,14 @@ auvia_intr(void *arg) return rval; } -static void -auvia_powerhook(int why, void *addr) +static bool +auvia_resume(device_t dv) { - struct auvia_softc *sc; - - sc = addr; - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - /* Power down */ - sc->sc_suspend = why; - break; + struct auvia_softc *sc = device_private(dv); - case PWR_RESUME: - /* Wake up */ - if (sc->sc_suspend == PWR_RESUME) { - printf("%s: resume without suspend.\n", - sc->sc_dev.dv_xname); - sc->sc_suspend = why; - return; - } - sc->sc_suspend = why; - auvia_reset_codec(sc); - DELAY(1000); - (sc->codec_if->vtbl->restore_ports)(sc->codec_if); - break; + auvia_reset_codec(sc); + DELAY(1000); + (sc->codec_if->vtbl->restore_ports)(sc->codec_if); - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } + return true; } diff --git a/sys/dev/pci/auviavar.h b/sys/dev/pci/auviavar.h index 8df24181c84..cb583372d66 100644 --- a/sys/dev/pci/auviavar.h +++ b/sys/dev/pci/auviavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: auviavar.h,v 1.11 2007/02/21 23:00:00 thorpej Exp $ */ +/* $NetBSD: auviavar.h,v 1.12 2007/12/09 20:28:06 jmcneill Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -75,10 +75,6 @@ struct auvia_softc { struct auvia_softc_chan sc_play, sc_record; - /* Power Management */ - void *sc_powerhook; - int sc_suspend; - #define AUVIA_NFORMATS 8 struct audio_format sc_formats[AUVIA_NFORMATS]; struct audio_encoding_set *sc_encodings; diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index a4a4ecabe91..44d17a12d94 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $NetBSD: azalia.c,v 1.51 2007/08/14 13:57:56 kent Exp $ */ +/* $NetBSD: azalia.c,v 1.52 2007/12/09 20:28:06 jmcneill Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: azalia.c,v 1.51 2007/08/14 13:57:56 kent Exp $"); +__KERNEL_RCSID(0, "$NetBSD: azalia.c,v 1.52 2007/12/09 20:28:06 jmcneill Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -115,6 +115,7 @@ typedef struct azalia_t { struct device *audiodev; pci_chipset_tag_t pc; + pcitag_t tag; void *ih; bus_space_tag_t iot; bus_space_handle_t ioh; @@ -142,6 +143,7 @@ typedef struct azalia_t { int nistreams, nostreams, nbstreams; stream_t pstream; stream_t rstream; + int mode_cap; } azalia_t; #define XNAME(sc) ((sc)->dev.dv_xname) @@ -158,12 +160,13 @@ static int azalia_pci_match(struct device *, struct cfdata *, void *); static void azalia_pci_attach(struct device *, struct device *, void *); static int azalia_pci_activate(struct device *, enum devact); static int azalia_pci_detach(struct device *, int); +static bool azalia_pci_resume(device_t); static int azalia_intr(void *); static int azalia_attach(azalia_t *); static void azalia_attach_intr(struct device *); -static int azalia_init_corb(azalia_t *); +static int azalia_init_corb(azalia_t *, int); static int azalia_delete_corb(azalia_t *); -static int azalia_init_rirb(azalia_t *); +static int azalia_init_rirb(azalia_t *, int); static int azalia_delete_rirb(azalia_t *); static int azalia_set_command(const azalia_t *, nid_t, int, uint32_t, uint32_t); @@ -173,7 +176,7 @@ static void azalia_rirb_intr(azalia_t *); static int azalia_alloc_dmamem(azalia_t *, size_t, size_t, azalia_dma_t *); static int azalia_free_dmamem(const azalia_t *, azalia_dma_t*); -static int azalia_codec_init(codec_t *); +static int azalia_codec_init(codec_t *, int); static int azalia_codec_delete(codec_t *); static void azalia_codec_add_bits(codec_t *, int, uint32_t, int); static void azalia_codec_add_format(codec_t *, int, int, int, uint32_t, @@ -185,7 +188,9 @@ static int azalia_codec_disconnect_stream(codec_t *, int); static int azalia_widget_init(widget_t *, const codec_t *, int, const char *); static int azalia_widget_init_audio(widget_t *, const codec_t *, const char *); +#ifdef AZALIA_DEBUG static int azalia_widget_print_audio(const widget_t *, const char *, int); +#endif static int azalia_widget_init_pin(widget_t *, const codec_t *); static int azalia_widget_print_pin(const widget_t *, const char *); static int azalia_widget_init_connection(widget_t *, const codec_t *, const char *); @@ -327,6 +332,7 @@ azalia_pci_attach(struct device *parent, struct device *self, return; } sc->pc = pa->pa_pc; + sc->tag = pa->pa_tag; intrrupt_str = pci_intr_string(pa->pa_pc, ih); sc->ih = pci_intr_establish(pa->pa_pc, ih, IPL_AUDIO, azalia_intr, sc); if (sc->ih == NULL) { @@ -338,6 +344,9 @@ azalia_pci_attach(struct device *parent, struct device *self, } aprint_normal("%s: interrupting at %s\n", XNAME(sc), intrrupt_str); + if (!pmf_device_register(self, NULL, azalia_pci_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + sc->pciid = pa->pa_id; vendor = pci_findvendor(pa->pa_id); name = pci_findproduct(pa->pa_id); @@ -418,6 +427,21 @@ azalia_pci_detach(struct device *self, int flags) return 0; } +static bool +azalia_pci_resume(device_t dv) +{ + azalia_t *az = device_private(dv); + int s; + + s = splaudio(); + azalia_attach(az); + splx(s); + + azalia_attach_intr(&az->dev); + + return true; +} + static int azalia_intr(void *v) { @@ -429,6 +453,9 @@ azalia_intr(void *v) az = v; ret = 0; + if (!device_has_power(&az->dev)) + return 0; + intsts = AZ_READ_4(az, INTSTS); if (intsts == 0) return ret; @@ -463,8 +490,10 @@ azalia_attach(azalia_t *az) uint16_t gcap; uint16_t statests; - aprint_normal("%s: host: High Definition Audio rev. %d.%d\n", - XNAME(az), AZ_READ_1(az, VMAJ), AZ_READ_1(az, VMIN)); + if (az->audiodev == NULL) + aprint_normal("%s: host: High Definition Audio rev. %d.%d\n", + XNAME(az), AZ_READ_1(az, VMAJ), AZ_READ_1(az, VMIN)); + gcap = AZ_READ_2(az, GCAP); az->nistreams = HDA_GCAP_ISS(gcap); az->nostreams = HDA_GCAP_OSS(gcap); @@ -531,9 +560,10 @@ static void azalia_attach_intr(struct device *self) { azalia_t *az; - int err, i, c; + int err, i, c, reinit; az = (azalia_t*)self; + reinit = az->audiodev == NULL ? 0 : 1; AZ_WRITE_2(az, STATESTS, HDA_STATESTS_SDIWAKE); AZ_WRITE_1(az, RIRBSTS, HDA_RIRBSTS_RINTFL | HDA_RIRBSTS_RIRBOIS); @@ -542,10 +572,10 @@ azalia_attach_intr(struct device *self) AZ_WRITE_4(az, DPUBASE, 0); /* 4.4.1 Command Outbound Ring Buffer */ - if (azalia_init_corb(az)) + if (azalia_init_corb(az, reinit)) goto err_exit; /* 4.4.2 Response Inbound Ring Buffer */ - if (azalia_init_rirb(az)) + if (azalia_init_rirb(az, reinit)) goto err_exit; AZ_WRITE_4(az, INTCTL, @@ -553,7 +583,7 @@ azalia_attach_intr(struct device *self) c = -1; for (i = 0; i < az->ncodecs; i++) { - err = azalia_codec_init(&az->codecs[i]); + err = azalia_codec_init(&az->codecs[i], reinit); if (!err && c < 0) c = i; } @@ -568,15 +598,15 @@ azalia_attach_intr(struct device *self) az->mode_cap &= ~AUMODE_RECORD; /* Use stream#1 and #2. Don't use stream#0. */ - if (az->nostreams > 0 && - azalia_stream_init(&az->pstream, az, az->nistreams + 0, - 1, AUMODE_PLAY)) - goto err_exit; - if (az->nistreams > 0 && - azalia_stream_init(&az->rstream, az, 0, 2, AUMODE_RECORD)) - goto err_exit; + if (reinit == 0) { + if (azalia_stream_init(&az->pstream, az, az->nistreams + 0, + 1, AUMODE_PLAY)) + goto err_exit; + if (azalia_stream_init(&az->rstream, az, 0, 2, AUMODE_RECORD)) + goto err_exit; - az->audiodev = audio_attach_mi(&azalia_hw_if, az, &az->dev); + az->audiodev = audio_attach_mi(&azalia_hw_if, az, &az->dev); + } return; err_exit: azalia_pci_detach(self, 0); @@ -584,7 +614,7 @@ err_exit: } static int -azalia_init_corb(azalia_t *az) +azalia_init_corb(azalia_t *az, int reinit) { int entries, err, i; uint16_t corbrp, corbwp; @@ -624,11 +654,14 @@ azalia_init_corb(azalia_t *az) return -1; } - err = azalia_alloc_dmamem(az, entries * sizeof(corb_entry_t), - 128, &az->corb_dma); - if (err) { - aprint_error("%s: can't allocate CORB buffer\n", XNAME(az)); - return err; + if (reinit == 0) { + err = azalia_alloc_dmamem(az, entries * sizeof(corb_entry_t), + 128, &az->corb_dma); + if (err) { + aprint_error("%s: can't allocate CORB buffer\n", + XNAME(az)); + return err; + } } AZ_WRITE_4(az, CORBLBASE, (uint32_t)AZALIA_DMA_DMAADDR(&az->corb_dma)); AZ_WRITE_4(az, CORBUBASE, PTR_UPPER32(AZALIA_DMA_DMAADDR(&az->corb_dma))); @@ -686,7 +719,7 @@ azalia_delete_corb(azalia_t *az) } static int -azalia_init_rirb(azalia_t *az) +azalia_init_rirb(azalia_t *az, int reinit) { int entries, err, i; uint16_t rirbwp; @@ -726,11 +759,14 @@ azalia_init_rirb(azalia_t *az) return -1; } - err = azalia_alloc_dmamem(az, entries * sizeof(rirb_entry_t), - 128, &az->rirb_dma); - if (err) { - aprint_error("%s: can't allocate RIRB buffer\n", XNAME(az)); - return err; + if (reinit == 0) { + err = azalia_alloc_dmamem(az, entries * sizeof(rirb_entry_t), + 128, &az->rirb_dma); + if (err) { + aprint_error("%s: can't allocate RIRB buffer\n", + XNAME(az)); + return err; + } } AZ_WRITE_4(az, RIRBLBASE, (uint32_t)AZALIA_DMA_DMAADDR(&az->rirb_dma)); AZ_WRITE_4(az, RIRBUBASE, PTR_UPPER32(AZALIA_DMA_DMAADDR(&az->rirb_dma))); @@ -743,8 +779,12 @@ azalia_init_rirb(azalia_t *az) az->unsolq_rp = 0; az->unsolq_wp = 0; az->unsolq_kick = FALSE; - az->unsolq = malloc(sizeof(rirb_entry_t) * UNSOLQ_SIZE, - M_DEVBUF, M_ZERO | M_NOWAIT); + if (reinit == 0) { + az->unsolq = malloc(sizeof(rirb_entry_t) * UNSOLQ_SIZE, + M_DEVBUF, M_ZERO | M_NOWAIT); + } else { + memset(az->unsolq, 0, sizeof(rirb_entry_t) * UNSOLQ_SIZE); + } if (az->unsolq == NULL) { aprint_error("%s: can't allocate unsolicited response queue.\n", XNAME(az)); @@ -984,7 +1024,7 @@ azalia_free_dmamem(const azalia_t *az, azalia_dma_t* d) * ================================================================ */ static int -azalia_codec_init(codec_t *this) +azalia_codec_init(codec_t *this, int reinit) { #define LEAD_LEN 100 char lead[LEAD_LEN]; @@ -1006,21 +1046,26 @@ azalia_codec_init(codec_t *this) return err; this->vid = id; this->subid = this->az->subid; - err = azalia_codec_init_vtbl(this); - if (err) - return err; - aprint_normal("%s: codec[%d]: ", XNAME(this->az), addr); - if (this->name == NULL) { - aprint_normal("0x%4.4x/0x%4.4x (rev. %u.%u)\n", - id >> 16, id & 0xffff, - COP_RID_REVISION(rev), COP_RID_STEPPING(rev)); - } else { - aprint_normal("%s (rev. %u.%u)\n", this->name, - COP_RID_REVISION(rev), COP_RID_STEPPING(rev)); + if (!reinit) { + err = azalia_codec_init_vtbl(this); + if (err) + return err; + } + + if (!reinit) { + aprint_normal("%s: codec[%d]: ", XNAME(this->az), addr); + if (this->name == NULL) { + aprint_normal("0x%4.4x/0x%4.4x (rev. %u.%u)\n", + id >> 16, id & 0xffff, + COP_RID_REVISION(rev), COP_RID_STEPPING(rev)); + } else { + aprint_normal("%s (rev. %u.%u)\n", this->name, + COP_RID_REVISION(rev), COP_RID_STEPPING(rev)); + } + aprint_normal("%s: codec[%d]: High Definition Audio rev. %u.%u\n", + XNAME(this->az), addr, COP_RID_MAJ(rev), COP_RID_MIN(rev)); } - aprint_normal("%s: codec[%d]: High Definition Audio rev. %u.%u\n", - XNAME(this->az), addr, COP_RID_MAJ(rev), COP_RID_MIN(rev)); /* identify function nodes */ err = this->comresp(this, CORB_NID_ROOT, CORB_GET_PARAMETER, @@ -1046,12 +1091,12 @@ azalia_codec_init(codec_t *this) if (COP_FTYPE(result) == COP_FTYPE_AUDIO) { this->audiofunc = n + i; break; /* XXX multiple audio functions? */ - } else if (COP_FTYPE(result) == COP_FTYPE_MODEM) { + } else if (COP_FTYPE(result) == COP_FTYPE_MODEM && !reinit) { aprint_normal("%s: codec[%d]: No support for modem function groups\n", XNAME(this->az), addr); } } - if (this->audiofunc < 0) { + if (this->audiofunc < 0 && !reinit) { aprint_error("%s: codec[%d] has no audio function groups\n", XNAME(this->az), addr); return -1; @@ -1070,16 +1115,21 @@ azalia_codec_init(codec_t *this) __func__, COP_NSUBNODES(result))); this->wstart = COP_START_NID(result); if (this->wstart < 2) { - aprint_error("%s: invalid node structure\n", XNAME(this->az)); + if (!reinit) + aprint_error("%s: invalid node structure\n", + XNAME(this->az)); return -1; } this->wend = this->wstart + COP_NSUBNODES(result); - this->w = malloc(sizeof(widget_t) * this->wend, M_DEVBUF, - M_ZERO | M_NOWAIT); - if (this->w == NULL) { - aprint_error("%s: out of memory\n", XNAME(this->az)); - return ENOMEM; - } + if (!reinit) { + this->w = malloc(sizeof(widget_t) * this->wend, M_DEVBUF, + M_ZERO | M_NOWAIT); + if (this->w == NULL) { + aprint_error("%s: out of memory\n", XNAME(this->az)); + return ENOMEM; + } + } else + memset(this->w, 0, sizeof(widget_t) * this->wend); /* query the base parameters */ this->comresp(this, this->audiofunc, CORB_GET_PARAMETER, @@ -1245,7 +1295,9 @@ azalia_codec_delete(codec_t *this) int azalia_codec_construct_format(codec_t *this, int newdac, int newadc) { +#ifdef AZALIA_DEBUG char flagbuf[FLAGBUFLEN]; +#endif const convgroup_t *group; uint32_t bits_rates; int prev_dac, prev_adc; @@ -1329,6 +1381,7 @@ azalia_codec_construct_format(codec_t *this, int newdac, int newadc) azalia_codec_add_bits(this, chan, bits_rates, AUMODE_PLAY); } +#ifdef AZALIA_DEBUG /* print playback capability */ if (prev_dac != this->dacs.cur) { snprintf(flagbuf, FLAGBUFLEN, "%s: playback: ", @@ -1336,6 +1389,7 @@ azalia_codec_construct_format(codec_t *this, int newdac, int newadc) azalia_widget_print_audio(&this->w[group->conv[0]], flagbuf, chan); } +#endif } /* register formats for recording */ @@ -1352,6 +1406,7 @@ azalia_codec_construct_format(codec_t *this, int newdac, int newadc) azalia_codec_add_bits(this, chan, bits_rates, AUMODE_RECORD); } +#ifdef AZALIA_DEBUG /* print recording capability */ if (prev_adc != this->adcs.cur) { snprintf(flagbuf, FLAGBUFLEN, "%s: recording: ", @@ -1359,6 +1414,7 @@ azalia_codec_construct_format(codec_t *this, int newdac, int newadc) azalia_widget_print_audio(&this->w[group->conv[0]], flagbuf, chan); } +#endif } #ifdef DIAGNOSTIC @@ -1706,6 +1762,7 @@ azalia_widget_init_audio(widget_t *this, const codec_t *codec, const char *lead) return 0; } +#ifdef AZALIA_DEBUG static int azalia_widget_print_audio(const widget_t *this, const char *lead, int channels) { @@ -1730,6 +1787,7 @@ azalia_widget_print_audio(const widget_t *this, const char *lead, int channels) aprint_normal("%sPCM formats=%s\n", lead, flagbuf); return 0; } +#endif static int azalia_widget_init_pin(widget_t *this, const codec_t *codec) diff --git a/sys/dev/pci/azalia_codec.c b/sys/dev/pci/azalia_codec.c index c04fabb2fb2..4a7a69661fa 100644 --- a/sys/dev/pci/azalia_codec.c +++ b/sys/dev/pci/azalia_codec.c @@ -1,4 +1,4 @@ -/* $NetBSD: azalia_codec.c,v 1.49 2007/11/26 15:47:36 christos Exp $ */ +/* $NetBSD: azalia_codec.c,v 1.50 2007/12/09 20:28:06 jmcneill Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: azalia_codec.c,v 1.49 2007/11/26 15:47:36 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: azalia_codec.c,v 1.50 2007/12/09 20:28:06 jmcneill Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -111,6 +111,7 @@ static int alc260_mixer_init(codec_t *); static int alc260_set_port(codec_t *, mixer_ctrl_t *); static int alc260_get_port(codec_t *, mixer_ctrl_t *); static int alc260_unsol_event(codec_t *, int); +static int alc262_init_widget(const codec_t *, widget_t *, nid_t); static int alc861_init_dacgroup(codec_t *); static int alc861vdgr_init_dacgroup(codec_t *); static int alc880_init_dacgroup(codec_t *); @@ -167,6 +168,7 @@ azalia_codec_init_vtbl(codec_t *this) break; case 0x10ec0262: this->name = "Realtek ALC262"; + this->init_widget = alc262_init_widget; break; case 0x10ec0268: this->name = "Realtek ALC268"; @@ -1998,6 +2000,22 @@ alc260_unsol_event(codec_t *this, int tag) * ---------------------------------------------------------------- */ static int +alc262_init_widget(const codec_t *this, widget_t *w, nid_t nid) +{ + switch (nid) { + case 0x0c: + strlcpy(w->name, AudioNmaster, sizeof(w->name)); + break; + } + + return 0; +} + +/* ---------------------------------------------------------------- + * Realtek ALC861 + * ---------------------------------------------------------------- */ + +static int alc861_init_dacgroup(codec_t *this) { static const convgroupset_t dacs = { diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c index 96df6aa8b39..26eb558f9cb 100644 --- a/sys/dev/pci/cs4280.c +++ b/sys/dev/pci/cs4280.c @@ -1,4 +1,4 @@ -/* $NetBSD: cs4280.c,v 1.47 2007/10/19 12:00:41 ad Exp $ */ +/* $NetBSD: cs4280.c,v 1.48 2007/12/09 20:28:07 jmcneill Exp $ */ /* * Copyright (c) 1999, 2000 Tatoku Ogaito. All rights reserved. @@ -52,7 +52,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cs4280.c,v 1.47 2007/10/19 12:00:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cs4280.c,v 1.48 2007/12/09 20:28:07 jmcneill Exp $"); #include "midi.h" @@ -110,8 +110,8 @@ static int cs4280_reset_codec(void *); #endif static enum ac97_host_flags cs4280_flags_codec(void *); -/* For PowerHook */ -static void cs4280_power(int, void *); +static bool cs4280_resume(device_t); +static bool cs4280_suspend(device_t); /* Internal functions */ static const struct cs4280_card_t * cs4280_identify_card(struct pci_attach_args *); @@ -365,9 +365,8 @@ cs4280_attach(struct device *parent, struct device *self, void *aux) midi_attach_mi(&cs4280_midi_hw_if, sc, &sc->sc_dev); #endif - sc->sc_suspend = PWR_RESUME; - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - cs4280_power, sc); + if (!pmf_device_register(self, cs4280_suspend, cs4280_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } /* Interrupt handling function */ @@ -912,99 +911,79 @@ cs4280_trigger_input(void *addr, void *start, void *end, int blksize, return 0; } -/* Power Hook */ -static void -cs4280_power(int why, void *v) +static bool +cs4280_suspend(device_t dv) { - static uint32_t pctl = 0, pba = 0, pfie = 0, pdtc = 0; - static uint32_t cctl = 0, cba = 0, cie = 0; - struct cs428x_softc *sc; - - sc = (struct cs428x_softc *)v; - DPRINTF(("%s: cs4280_power why=%d\n", sc->sc_dev.dv_xname, why)); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - sc->sc_suspend = why; - - /* save current playback status */ - if (sc->sc_prun) { - pctl = BA1READ4(sc, CS4280_PCTL); - pfie = BA1READ4(sc, CS4280_PFIE); - pba = BA1READ4(sc, CS4280_PBA); - pdtc = BA1READ4(sc, CS4280_PDTC); - DPRINTF(("pctl=0x%08x pfie=0x%08x pba=0x%08x pdtc=0x%08x\n", - pctl, pfie, pba, pdtc)); - } - - /* save current capture status */ - if (sc->sc_rrun) { - cctl = BA1READ4(sc, CS4280_CCTL); - cie = BA1READ4(sc, CS4280_CIE); - cba = BA1READ4(sc, CS4280_CBA); - DPRINTF(("cctl=0x%08x cie=0x%08x cba=0x%08x\n", - cctl, cie, cba)); - } + struct cs428x_softc *sc = device_private(dv); + + if (sc->sc_prun) { + sc->sc_suspend_state.cs4280.pctl = BA1READ4(sc, CS4280_PCTL); + sc->sc_suspend_state.cs4280.pfie = BA1READ4(sc, CS4280_PFIE); + sc->sc_suspend_state.cs4280.pba = BA1READ4(sc, CS4280_PBA); + sc->sc_suspend_state.cs4280.pdtc = BA1READ4(sc, CS4280_PDTC); + DPRINTF(("pctl=0x%08x pfie=0x%08x pba=0x%08x pdtc=0x%08x\n", + sc->sc_suspend_state.cs4280.pctl, + sc->sc_suspend_state.cs4280.pfie, + sc->sc_suspend_state.cs4280.pba, + sc->sc_suspend_state.cs4280.pdtc)); + } - /* Stop DMA */ - BA1WRITE4(sc, CS4280_PCTL, pctl & ~PCTL_MASK); - BA1WRITE4(sc, CS4280_CCTL, BA1READ4(sc, CS4280_CCTL) & ~CCTL_MASK); + /* save current capture status */ + if (sc->sc_rrun) { + sc->sc_suspend_state.cs4280.cctl = BA1READ4(sc, CS4280_CCTL); + sc->sc_suspend_state.cs4280.cie = BA1READ4(sc, CS4280_CIE); + sc->sc_suspend_state.cs4280.cba = BA1READ4(sc, CS4280_CBA); + DPRINTF(("cctl=0x%08x cie=0x%08x cba=0x%08x\n", + sc->sc_suspend_state.cs4280.cctl, + sc->sc_suspend_state.cs4280.cie, + sc->sc_suspend_state.cs4280.cba)); + } - pci_conf_capture(sc->sc_pc, sc->sc_pt, &sc->sc_pciconf); - if (sc->sc_ih != NULL) - pci_intr_disestablish(sc->sc_pc, sc->sc_ih); + /* Stop DMA */ + BA1WRITE4(sc, CS4280_PCTL, sc->sc_suspend_state.cs4280.pctl & ~PCTL_MASK); + BA1WRITE4(sc, CS4280_CCTL, BA1READ4(sc, CS4280_CCTL) & ~CCTL_MASK); - break; - case PWR_RESUME: - if (sc->sc_suspend == PWR_RESUME) { - printf("cs4280_power: odd, resume without suspend.\n"); - sc->sc_suspend = why; - return; - } + return true; +} - sc->sc_ih = pci_intr_establish(sc->sc_pc, sc->intrh, - IPL_AUDIO, cs4280_intr, sc); - if (sc->sc_ih == NULL) { - aprint_error("%s: can't establish interrupt", - sc->sc_dev.dv_xname); - /* XXX jmcneill what should we do here? */ - return; - } - pci_conf_restore(sc->sc_pc, sc->sc_pt, &sc->sc_pciconf); +static bool +cs4280_resume(device_t dv) +{ + struct cs428x_softc *sc = device_private(dv); - sc->sc_suspend = why; - cs4280_init(sc, 0); + cs4280_init(sc, 0); #if 0 - cs4280_reset_codec(sc); + cs4280_reset_codec(sc); #endif - /* restore ac97 registers */ - (*sc->codec_if->vtbl->restore_ports)(sc->codec_if); - - /* restore DMA related status */ - if(sc->sc_prun) { - DPRINTF(("pctl=0x%08x pfie=0x%08x pba=0x%08x pdtc=0x%08x\n", - pctl, pfie, pba, pdtc)); - cs4280_set_dac_rate(sc, sc->sc_prate); - BA1WRITE4(sc, CS4280_PDTC, pdtc); - BA1WRITE4(sc, CS4280_PBA, pba); - BA1WRITE4(sc, CS4280_PFIE, pfie); - BA1WRITE4(sc, CS4280_PCTL, pctl); - } + /* restore ac97 registers */ + (*sc->codec_if->vtbl->restore_ports)(sc->codec_if); + + /* restore DMA related status */ + if(sc->sc_prun) { + DPRINTF(("pctl=0x%08x pfie=0x%08x pba=0x%08x pdtc=0x%08x\n", + sc->sc_suspend_state.cs4280.pctl, + sc->sc_suspend_state.cs4280.pfie, + sc->sc_suspend_state.cs4280.pba, + sc->sc_suspend_state.cs4280.pdtc)); + cs4280_set_dac_rate(sc, sc->sc_prate); + BA1WRITE4(sc, CS4280_PDTC, sc->sc_suspend_state.cs4280.pdtc); + BA1WRITE4(sc, CS4280_PBA, sc->sc_suspend_state.cs4280.pba); + BA1WRITE4(sc, CS4280_PFIE, sc->sc_suspend_state.cs4280.pfie); + BA1WRITE4(sc, CS4280_PCTL, sc->sc_suspend_state.cs4280.pctl); + } - if (sc->sc_rrun) { - DPRINTF(("cctl=0x%08x cie=0x%08x cba=0x%08x\n", - cctl, cie, cba)); - cs4280_set_adc_rate(sc, sc->sc_rrate); - BA1WRITE4(sc, CS4280_CBA, cba); - BA1WRITE4(sc, CS4280_CIE, cie); - BA1WRITE4(sc, CS4280_CCTL, cctl); - } - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; + if (sc->sc_rrun) { + DPRINTF(("cctl=0x%08x cie=0x%08x cba=0x%08x\n", + sc->sc_suspend_state.cs4280.cctl, + sc->sc_suspend_state.cs4280.cie, + sc->sc_suspend_state.cs4280.cba)); + cs4280_set_adc_rate(sc, sc->sc_rrate); + BA1WRITE4(sc, CS4280_CBA, sc->sc_suspend_state.cs4280.cba); + BA1WRITE4(sc, CS4280_CIE, sc->sc_suspend_state.cs4280.cie); + BA1WRITE4(sc, CS4280_CCTL, sc->sc_suspend_state.cs4280.cctl); } + + return true; } static int diff --git a/sys/dev/pci/cs4281.c b/sys/dev/pci/cs4281.c index bf4e8ec5713..3e32a67213b 100644 --- a/sys/dev/pci/cs4281.c +++ b/sys/dev/pci/cs4281.c @@ -1,4 +1,4 @@ -/* $NetBSD: cs4281.c,v 1.35 2007/10/19 12:00:41 ad Exp $ */ +/* $NetBSD: cs4281.c,v 1.36 2007/12/09 20:28:07 jmcneill Exp $ */ /* * Copyright (c) 2000 Tatoku Ogaito. All rights reserved. @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cs4281.c,v 1.35 2007/10/19 12:00:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cs4281.c,v 1.36 2007/12/09 20:28:07 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -106,7 +106,8 @@ static void cs4281_set_adc_rate(struct cs428x_softc *, int); static int cs4281_init(struct cs428x_softc *, int); /* Power Management */ -static void cs4281_power(int, void *); +static bool cs4281_suspend(device_t); +static bool cs4281_resume(device_t); static const struct audio_hw_if cs4281_hw_if = { NULL, /* open */ @@ -292,9 +293,8 @@ cs4281_attach(struct device *parent, struct device *self, void *aux) midi_attach_mi(&cs4281_midi_hw_if, sc, &sc->sc_dev); #endif - sc->sc_suspend = PWR_RESUME; - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - cs4281_power, sc); + if (!pmf_device_register(self, cs4281_suspend, cs4281_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int @@ -721,93 +721,64 @@ cs4281_trigger_input(void *addr, void *start, void *end, int blksize, return 0; } -/* Power Hook */ -static void -cs4281_power(int why, void *v) +static bool +cs4281_suspend(device_t dv) { - static uint32_t dba0 = 0, dbc0 = 0, dmr0 = 0, dcr0 = 0; - static uint32_t dba1 = 0, dbc1 = 0, dmr1 = 0, dcr1 = 0; - struct cs428x_softc *sc; - - sc = (struct cs428x_softc *)v; - DPRINTF(("%s: cs4281_power why=%d\n", sc->sc_dev.dv_xname, why)); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - sc->sc_suspend = why; - - /* save current playback status */ - if (sc->sc_prun) { - dcr0 = BA0READ4(sc, CS4281_DCR0); - dmr0 = BA0READ4(sc, CS4281_DMR0); - dbc0 = BA0READ4(sc, CS4281_DBC0); - dba0 = BA0READ4(sc, CS4281_DBA0); - } - - /* save current capture status */ - if (sc->sc_rrun) { - dcr1 = BA0READ4(sc, CS4281_DCR1); - dmr1 = BA0READ4(sc, CS4281_DMR1); - dbc1 = BA0READ4(sc, CS4281_DBC1); - dba1 = BA0READ4(sc, CS4281_DBA1); - } - /* Stop DMA */ - BA0WRITE4(sc, CS4281_DCR0, BA0READ4(sc, CS4281_DCR0) | DCRn_MSK); - BA0WRITE4(sc, CS4281_DCR1, BA0READ4(sc, CS4281_DCR1) | DCRn_MSK); + struct cs428x_softc *sc = device_private(dv); + + /* save current playback status */ + if (sc->sc_prun) { + sc->sc_suspend_state.cs4281.dcr0 = BA0READ4(sc, CS4281_DCR0); + sc->sc_suspend_state.cs4281.dmr0 = BA0READ4(sc, CS4281_DMR0); + sc->sc_suspend_state.cs4281.dbc0 = BA0READ4(sc, CS4281_DBC0); + sc->sc_suspend_state.cs4281.dba0 = BA0READ4(sc, CS4281_DBA0); + } - pci_conf_capture(sc->sc_pc, sc->sc_pt, &sc->sc_pciconf); - if (sc->sc_ih != NULL) - pci_intr_disestablish(sc->sc_pc, sc->sc_ih); + /* save current capture status */ + if (sc->sc_rrun) { + sc->sc_suspend_state.cs4281.dcr1 = BA0READ4(sc, CS4281_DCR1); + sc->sc_suspend_state.cs4281.dmr1 = BA0READ4(sc, CS4281_DMR1); + sc->sc_suspend_state.cs4281.dbc1 = BA0READ4(sc, CS4281_DBC1); + sc->sc_suspend_state.cs4281.dba1 = BA0READ4(sc, CS4281_DBA1); + } + /* Stop DMA */ + BA0WRITE4(sc, CS4281_DCR0, BA0READ4(sc, CS4281_DCR0) | DCRn_MSK); + BA0WRITE4(sc, CS4281_DCR1, BA0READ4(sc, CS4281_DCR1) | DCRn_MSK); - break; - case PWR_RESUME: - if (sc->sc_suspend == PWR_RESUME) { - printf("cs4281_power: odd, resume without suspend.\n"); - sc->sc_suspend = why; - return; - } + return true; +} - sc->sc_ih = pci_intr_establish(sc->sc_pc, sc->intrh, - IPL_AUDIO, cs4281_intr, sc); - if (sc->sc_ih == NULL) { - aprint_error("%s: can't establish interrupt", - sc->sc_dev.dv_xname); - /* XXX jmcneill what should we do here? */ - return; - } - pci_conf_restore(sc->sc_pc, sc->sc_pt, &sc->sc_pciconf); +static bool +cs4281_resume(device_t dv) +{ + struct cs428x_softc *sc = device_private(dv); - sc->sc_suspend = why; - cs4281_init(sc, 0); - cs4281_reset_codec(sc); + cs4281_init(sc, 0); + cs4281_reset_codec(sc); - /* restore ac97 registers */ - (*sc->codec_if->vtbl->restore_ports)(sc->codec_if); + /* restore ac97 registers */ + (*sc->codec_if->vtbl->restore_ports)(sc->codec_if); - /* restore DMA related status */ - if (sc->sc_prun) { - cs4281_set_dac_rate(sc, sc->sc_prate); - BA0WRITE4(sc, CS4281_DBA0, dba0); - BA0WRITE4(sc, CS4281_DBC0, dbc0); - BA0WRITE4(sc, CS4281_DMR0, dmr0); - BA0WRITE4(sc, CS4281_DCR0, dcr0); - } - if (sc->sc_rrun) { - cs4281_set_adc_rate(sc, sc->sc_rrate); - BA0WRITE4(sc, CS4281_DBA1, dba1); - BA0WRITE4(sc, CS4281_DBC1, dbc1); - BA0WRITE4(sc, CS4281_DMR1, dmr1); - BA0WRITE4(sc, CS4281_DCR1, dcr1); - } - /* enable intterupts */ - if (sc->sc_prun || sc->sc_rrun) - BA0WRITE4(sc, CS4281_HICR, HICR_IEV | HICR_CHGM); - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; + /* restore DMA related status */ + if (sc->sc_prun) { + cs4281_set_dac_rate(sc, sc->sc_prate); + BA0WRITE4(sc, CS4281_DBA0, sc->sc_suspend_state.cs4281.dba0); + BA0WRITE4(sc, CS4281_DBC0, sc->sc_suspend_state.cs4281.dbc0); + BA0WRITE4(sc, CS4281_DMR0, sc->sc_suspend_state.cs4281.dmr0); + BA0WRITE4(sc, CS4281_DCR0, sc->sc_suspend_state.cs4281.dcr0); + } + if (sc->sc_rrun) { + cs4281_set_adc_rate(sc, sc->sc_rrate); + BA0WRITE4(sc, CS4281_DBA1, sc->sc_suspend_state.cs4281.dba1); + BA0WRITE4(sc, CS4281_DBC1, sc->sc_suspend_state.cs4281.dbc1); + BA0WRITE4(sc, CS4281_DMR1, sc->sc_suspend_state.cs4281.dmr1); + BA0WRITE4(sc, CS4281_DCR1, sc->sc_suspend_state.cs4281.dcr1); } + /* enable intterupts */ + if (sc->sc_prun || sc->sc_rrun) + BA0WRITE4(sc, CS4281_HICR, HICR_IEV | HICR_CHGM); + + return true; } /* control AC97 codec */ diff --git a/sys/dev/pci/cs428x.h b/sys/dev/pci/cs428x.h index ef5e180e667..97cffe2a79b 100644 --- a/sys/dev/pci/cs428x.h +++ b/sys/dev/pci/cs428x.h @@ -1,4 +1,4 @@ -/* $NetBSD: cs428x.h,v 1.13 2007/06/15 13:26:57 joerg Exp $ */ +/* $NetBSD: cs428x.h,v 1.14 2007/12/09 20:28:07 jmcneill Exp $ */ /* * Copyright (c) 2000 Tatoku Ogaito. All rights reserved. @@ -141,9 +141,27 @@ struct cs428x_softc { struct ac97_host_if host_if; /* Power Management */ - char sc_suspend; - void *sc_powerhook; /* Power Hook */ - struct pci_conf_state sc_pciconf; + union { + struct { + uint32_t pctl; + uint32_t pba; + uint32_t pfie; + uint32_t pdtc; + uint32_t cctl; + uint32_t cba; + uint32_t cie; + } cs4280; + struct { + uint32_t dba0; + uint32_t dbc0; + uint32_t dmr0; + uint32_t dcr0; + uint32_t dba1; + uint32_t dbc1; + uint32_t dmr1; + uint32_t dcr1; + } cs4281; + } sc_suspend_state; /* CLKRUN hack (CS428X_FLAG_CLKRUN), only for CS4280 */ int sc_active; diff --git a/sys/dev/pci/ehci_pci.c b/sys/dev/pci/ehci_pci.c index 9d8d06cbdb9..943144bf4a2 100644 --- a/sys/dev/pci/ehci_pci.c +++ b/sys/dev/pci/ehci_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ehci_pci.c,v 1.31 2007/10/19 12:00:43 ad Exp $ */ +/* $NetBSD: ehci_pci.c,v 1.32 2007/12/09 20:28:07 jmcneill Exp $ */ /* * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.31 2007/10/19 12:00:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.32 2007/12/09 20:28:07 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -69,16 +69,13 @@ extern int ehcidebug; static void ehci_get_ownership(ehci_softc_t *sc, pci_chipset_tag_t pc, pcitag_t tag); -static void ehci_pci_powerhook(int, void *); +static bool ehci_pci_resume(device_t); struct ehci_pci_softc { ehci_softc_t sc; pci_chipset_tag_t sc_pc; pcitag_t sc_tag; void *sc_ih; /* interrupt vectoring */ - - void *sc_powerhook; - struct pci_conf_state sc_pciconf; }; #define EHCI_MAX_BIOS_WAIT 1000 /* ms */ @@ -210,21 +207,15 @@ ehci_pci_attach(struct device *parent, struct device *self, void *aux) ehci_get_ownership(&sc->sc, pc, tag); - /* - * Establish our powerhook before ehci_init() does its powerhook. - */ - sc->sc_powerhook = powerhook_establish( - USBDEVNAME(sc->sc.sc_bus.bdev) , ehci_pci_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: couldn't establish powerhook\n", - devname); - r = ehci_init(&sc->sc); if (r != USBD_NORMAL_COMPLETION) { aprint_error("%s: init failed, error=%d\n", devname, r); return; } + if (!pmf_device_register(self, ehci_suspend, ehci_pci_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + /* Attach usb device. */ sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, usbctlprint); @@ -236,9 +227,7 @@ ehci_pci_detach(device_ptr_t self, int flags) struct ehci_pci_softc *sc = (struct ehci_pci_softc *)self; int rv; - if (sc->sc_powerhook != NULL) - powerhook_disestablish(sc->sc_powerhook); - + pmf_device_deregister(self); rv = ehci_detach(&sc->sc, flags); if (rv) return (rv); @@ -336,27 +325,11 @@ ehci_get_ownership(ehci_softc_t *sc, pci_chipset_tag_t pc, pcitag_t tag) } } -static void -ehci_pci_powerhook(int why, void *opaque) +static bool +ehci_pci_resume(device_t dv) { - struct ehci_pci_softc *sc; - pci_chipset_tag_t pc; - pcitag_t tag; - - sc = (struct ehci_pci_softc *)opaque; - pc = sc->sc_pc; - tag = sc->sc_tag; - - switch (why) { - case PWR_STANDBY: - case PWR_SUSPEND: - pci_conf_capture(pc, tag, &sc->sc_pciconf); - break; - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->sc_pciconf); - ehci_get_ownership(&sc->sc, pc, tag); - break; - } + struct ehci_pci_softc *sc = device_private(dv); - return; + ehci_get_ownership(&sc->sc, sc->sc_pc, sc->sc_tag); + return ehci_resume(dv); } diff --git a/sys/dev/pci/esa.c b/sys/dev/pci/esa.c index 396a56bd2e4..33ba3304cad 100644 --- a/sys/dev/pci/esa.c +++ b/sys/dev/pci/esa.c @@ -1,4 +1,4 @@ -/* $NetBSD: esa.c,v 1.42 2007/10/19 12:00:43 ad Exp $ */ +/* $NetBSD: esa.c,v 1.43 2007/12/09 20:28:07 jmcneill Exp $ */ /* * Copyright (c) 2001, 2002, 2006 Jared D. McNeill <jmcneill@invisible.ca> @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: esa.c,v 1.42 2007/10/19 12:00:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: esa.c,v 1.43 2007/12/09 20:28:07 jmcneill Exp $"); #include <sys/types.h> #include <sys/errno.h> @@ -162,9 +162,8 @@ static void esa_remove_list(struct esa_voice *, struct esa_list *, int); /* power management */ -static void esa_powerhook(int, void *); -static int esa_suspend(struct esa_softc *); -static int esa_resume(struct esa_softc *); +static bool esa_suspend(device_t); +static bool esa_resume(device_t); #define ESA_NENCODINGS 8 @@ -1136,11 +1135,8 @@ esa_attach(struct device *parent, struct device *self, void *aux) audio_attach_mi(&esa_hw_if, &sc->voice[i], &sc->sc_dev); } - sc->powerhook = powerhook_establish(sc->sc_dev.dv_xname, - esa_powerhook, sc); - if (sc->powerhook == NULL) - aprint_error("%s: WARNING: unable to establish powerhook\n", - sc->sc_dev.dv_xname); + if (!pmf_device_register(self, esa_suspend, esa_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); return; } @@ -1637,33 +1633,14 @@ esa_remove_list(struct esa_voice *vc, struct esa_list *el, int index) return; } -static void -esa_powerhook(int why, void *hdl) -{ - struct esa_softc *sc; - - sc = (struct esa_softc *)hdl; - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - esa_suspend(sc); - break; - case PWR_RESUME: - esa_resume(sc); - sc->codec_if->vtbl->restore_ports(sc->codec_if); - break; - } -} - -static int -esa_suspend(struct esa_softc *sc) +static bool +esa_suspend(device_t dv) { - bus_space_tag_t iot; - bus_space_handle_t ioh; + struct esa_softc *sc = device_private(dv); + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh = sc->sc_ioh; int i, index; - iot = sc->sc_iot; - ioh = sc->sc_ioh; index = 0; bus_space_write_2(iot, ioh, ESA_HOST_INT_CTRL, 0); @@ -1681,19 +1658,18 @@ esa_suspend(struct esa_softc *sc) sc->savemem[index++] = esa_read_assp(sc, ESA_MEMTYPE_INTERNAL_DATA, i); - return 0; + return true; } -static int -esa_resume(struct esa_softc *sc) +static bool +esa_resume(device_t dv) { - bus_space_tag_t iot; - bus_space_handle_t ioh; + struct esa_softc *sc = device_private(dv); + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh = sc->sc_ioh; int i, index; uint8_t reset_state; - iot = sc->sc_iot; - ioh = sc->sc_ioh; index = 0; delay(10000); @@ -1721,7 +1697,7 @@ esa_resume(struct esa_softc *sc) esa_enable_interrupts(sc); esa_amp_enable(sc); - return 0; + return true; } static uint32_t diff --git a/sys/dev/pci/esavar.h b/sys/dev/pci/esavar.h index bc725c238e3..6e065c14cc8 100644 --- a/sys/dev/pci/esavar.h +++ b/sys/dev/pci/esavar.h @@ -1,4 +1,4 @@ -/* $NetBSD: esavar.h,v 1.8 2007/03/04 06:02:18 christos Exp $ */ +/* $NetBSD: esavar.h,v 1.9 2007/12/09 20:28:07 jmcneill Exp $ */ /* * Copyright (c) 2001, 2002 Jared D. McNeill <jmcneill@invisible.ca> @@ -132,6 +132,5 @@ struct esa_softc int type; /* Allegro-1 or Maestro 3? */ int delay1, delay2; - void *powerhook; uint16_t *savemem; }; diff --git a/sys/dev/pci/esm.c b/sys/dev/pci/esm.c index af6f11e37fa..25d90204b00 100644 --- a/sys/dev/pci/esm.c +++ b/sys/dev/pci/esm.c @@ -1,4 +1,4 @@ -/* $NetBSD: esm.c,v 1.43 2007/10/19 12:00:43 ad Exp $ */ +/* $NetBSD: esm.c,v 1.44 2007/12/09 20:28:07 jmcneill Exp $ */ /*- * Copyright (c) 2002, 2003 Matt Fredette @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.43 2007/10/19 12:00:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.44 2007/12/09 20:28:07 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -146,8 +146,8 @@ static void esmch_set_format(struct esm_chinfo *, static void esmch_combine_input(struct esm_softc *, struct esm_chinfo *); -/* Power Management */ -void esm_powerhook(int, void *); +static bool esm_suspend(device_t); +static bool esm_resume(device_t); CFATTACH_DECL(esm, sizeof(struct esm_softc), esm_match, esm_attach, NULL, NULL); @@ -1700,39 +1700,14 @@ esm_attach(struct device *parent, struct device *self, void *aux) audio_attach_mi(&esm_hw_if, self, &ess->sc_dev); - ess->esm_suspend = PWR_RESUME; - ess->esm_powerhook = powerhook_establish(ess->sc_dev.dv_xname, - esm_powerhook, ess); + if (!pmf_device_register(self, esm_suspend, esm_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } -/* Power Hook */ -void -esm_powerhook(int why, void *v) -{ - struct esm_softc *ess; - - ess = (struct esm_softc *)v; - DPRINTF(ESM_DEBUG_PARAM, - ("%s: ESS maestro 2E why=%d\n", ess->sc_dev.dv_xname, why)); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - ess->esm_suspend = why; - esm_suspend(ess); - DPRINTF(ESM_DEBUG_RESUME, ("esm_suspend\n")); - break; - - case PWR_RESUME: - ess->esm_suspend = why; - esm_resume(ess); - DPRINTF(ESM_DEBUG_RESUME, ("esm_resumed\n")); - break; - } -} - -int -esm_suspend(struct esm_softc *ess) +static bool +esm_suspend(device_t dv) { + struct esm_softc *ess = device_private(dv); int x; x = splaudio(); @@ -1749,12 +1724,13 @@ esm_suspend(struct esm_softc *ess) bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, 0); delay(1); - return 0; + return true; } -int -esm_resume(struct esm_softc *ess) +static bool +esm_resume(device_t dv) { + struct esm_softc *ess = device_private(dv); int x; uint16_t pcmbar; @@ -1787,21 +1763,6 @@ esm_resume(struct esm_softc *ess) wp_starttimer(ess); } splx(x); - return 0; -} - -#if 0 -int -esm_shutdown(struct esm_softc *ess) -{ - int i; - - wp_stoptimer(ess); - bus_space_write_2(ess->st, ess->sh, PORT_HOSTINT_CTRL, 0); - esm_halt_output(ess); - esm_halt_input(ess); - - return 0; + return true; } -#endif diff --git a/sys/dev/pci/esmvar.h b/sys/dev/pci/esmvar.h index 38ce882e0ce..188e1488b39 100644 --- a/sys/dev/pci/esmvar.h +++ b/sys/dev/pci/esmvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: esmvar.h,v 1.14 2007/03/04 06:02:18 christos Exp $ */ +/* $NetBSD: esmvar.h,v 1.15 2007/12/09 20:28:08 jmcneill Exp $ */ /*- * Copyright (c) 2002, 2003 Matt Fredette @@ -178,10 +178,6 @@ struct esm_softc { void (*sc_rintr)(void *); void *sc_rarg; - - /* Power Management */ - char esm_suspend; - void *esm_powerhook; }; enum esm_quirk_flags { @@ -202,7 +198,6 @@ int esm_attach_codec(void *, struct ac97_codec_if *); int esm_reset_codec(void *); enum ac97_host_flags esm_flags_codec(void *); -void esm_power(struct esm_softc *, int); void esm_init(struct esm_softc *); void esm_initcodec(struct esm_softc *); @@ -235,8 +230,4 @@ int esm_intr(void *); int esm_allocmem(struct esm_softc *, size_t, size_t, struct esm_dma *); -int esm_suspend(struct esm_softc *); -int esm_resume(struct esm_softc *); -int esm_shutdown(struct esm_softc *); - enum esm_quirk_flags esm_get_quirks(pcireg_t); diff --git a/sys/dev/pci/fwohci_pci.c b/sys/dev/pci/fwohci_pci.c index 9703d4e76aa..1c7c9719626 100644 --- a/sys/dev/pci/fwohci_pci.c +++ b/sys/dev/pci/fwohci_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: fwohci_pci.c,v 1.27 2007/11/06 15:24:10 kiyohara Exp $ */ +/* $NetBSD: fwohci_pci.c,v 1.28 2007/12/09 20:28:08 jmcneill Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fwohci_pci.c,v 1.27 2007/11/06 15:24:10 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fwohci_pci.c,v 1.28 2007/12/09 20:28:08 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -62,17 +62,15 @@ struct fwohci_pci_softc { pci_chipset_tag_t psc_pc; pcitag_t psc_tag; - struct pci_conf_state psc_pciconf; void *psc_ih; - void *psc_shutdownhook; - void *psc_powerhook; }; static int fwohci_pci_match(struct device *, struct cfdata *, void *); static void fwohci_pci_attach(struct device *, struct device *, void *); -static void fwohci_pci_shutdown(void *); -static void fwohci_pci_power(int, void *); + +static bool fwohci_pci_suspend(device_t); +static bool fwohci_pci_resume(device_t); CFATTACH_DECL(fwohci_pci, sizeof(struct fwohci_pci_softc), fwohci_pci_match, fwohci_pci_attach, NULL, NULL); @@ -118,7 +116,7 @@ fwohci_pci_attach(struct device *parent, struct device *self, NULL, &psc->psc_sc.bssize)) { aprint_error("%s: can't map OHCI register space\n", self->dv_xname); - return; + goto fail; } /* Disable interrupts, so we don't get any spurious ones. */ @@ -132,7 +130,7 @@ fwohci_pci_attach(struct device *parent, struct device *self, /* Map and establish the interrupt. */ if (pci_intr_map(pa, &ih)) { aprint_error("%s: couldn't map interrupt\n", self->dv_xname); - return; + goto fail; } intrstr = pci_intr_string(pa->pa_pc, ih); psc->psc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, fwohci_filt, @@ -143,57 +141,51 @@ fwohci_pci_attach(struct device *parent, struct device *self, if (intrstr != NULL) aprint_normal(" at %s", intrstr); aprint_normal("\n"); - return; + goto fail; } aprint_normal("%s: interrupting at %s\n", self->dv_xname, intrstr); - psc->psc_shutdownhook = - shutdownhook_establish(fwohci_pci_shutdown, psc); - psc->psc_powerhook = - powerhook_establish(self->dv_xname, fwohci_pci_power, psc); + if (!pmf_device_register(self, fwohci_pci_suspend, fwohci_pci_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); if (fwohci_init(&(psc->psc_sc), &(psc->psc_sc.fc._dev)) != 0) { pci_intr_disestablish(pa->pa_pc, psc->psc_ih); bus_space_unmap(psc->psc_sc.bst, psc->psc_sc.bsh, psc->psc_sc.bssize); } + + return; + +fail: + /* In the event that we fail to attach, register a null pnp handler */ + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + + return; } -static void -fwohci_pci_shutdown(void *arg) +static bool +fwohci_pci_suspend(device_t dv) { - struct fwohci_pci_softc *psc = arg; + struct fwohci_pci_softc *psc = device_private(dv); + int s; + s = splbio(); fwohci_stop(&psc->psc_sc, psc->psc_sc.fc.dev); + splx(s); + + return true; } -static void -fwohci_pci_power(int why, void *arg) +static bool +fwohci_pci_resume(device_t dv) { - struct fwohci_pci_softc *psc = arg; + struct fwohci_pci_softc *psc = device_private(dv); int s; s = splbio(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - printf("%s: suspending...\n", psc->psc_sc.fc._dev.dv_xname); - - pci_conf_capture(psc->psc_pc, psc->psc_tag, &psc->psc_pciconf); - fwohci_stop(&psc->psc_sc, psc->psc_sc.fc.dev); - break; - - case PWR_RESUME: - printf("%s: resuming...\n", psc->psc_sc.fc._dev.dv_xname); - - pci_conf_restore(psc->psc_pc, psc->psc_tag, &psc->psc_pciconf); - fwohci_resume(&psc->psc_sc, psc->psc_sc.fc.dev); - break; - - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } + fwohci_resume(&psc->psc_sc, psc->psc_sc.fc.dev); splx(s); + + return true; } diff --git a/sys/dev/pci/ichsmb.c b/sys/dev/pci/ichsmb.c index bcd13d04aef..7f210d61693 100644 --- a/sys/dev/pci/ichsmb.c +++ b/sys/dev/pci/ichsmb.c @@ -1,4 +1,4 @@ -/* $NetBSD: ichsmb.c,v 1.10 2007/10/19 12:00:44 ad Exp $ */ +/* $NetBSD: ichsmb.c,v 1.11 2007/12/09 20:28:08 jmcneill Exp $ */ /* $OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $ */ /* @@ -22,7 +22,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.10 2007/10/19 12:00:44 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.11 2007/12/09 20:28:08 jmcneill Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -175,7 +175,8 @@ ichsmb_attach(struct device *parent, struct device *self, void *aux) iba.iba_tag = &sc->sc_i2c_tag; config_found(self, &iba, iicbus_print); - return; + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/pci/if_an_pci.c b/sys/dev/pci/if_an_pci.c index 083974a0525..41ddad4aa46 100644 --- a/sys/dev/pci/if_an_pci.c +++ b/sys/dev/pci/if_an_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_an_pci.c,v 1.23 2007/10/19 12:00:44 ad Exp $ */ +/* $NetBSD: if_an_pci.c,v 1.24 2007/12/09 20:28:08 jmcneill Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_an_pci.c,v 1.23 2007/10/19 12:00:44 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_an_pci.c,v 1.24 2007/12/09 20:28:08 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -81,6 +81,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_an_pci.c,v 1.23 2007/10/19 12:00:44 ad Exp $"); struct an_pci_softc { struct an_softc sc_an; /* real "an" softc */ + pci_chipset_tag_t sc_pct; + pcitag_t sc_pcitag; /* PCI-specific goo. */ void *sc_ih; /* interrupt handle */ @@ -130,6 +132,9 @@ an_pci_attach(struct device *parent, struct device *self, void *aux) bus_size_t iosize; u_int32_t csr; + psc->sc_pct = pa->pa_pc; + psc->sc_pcitag = pa->pa_tag; + aprint_naive(": 802.11 controller\n"); pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo)); @@ -171,4 +176,9 @@ an_pci_attach(struct device *parent, struct device *self, void *aux) pci_intr_disestablish(pa->pa_pc, psc->sc_ih); bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize); } + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->sc_if); } diff --git a/sys/dev/pci/if_ath_pci.c b/sys/dev/pci/if_ath_pci.c index 3516ee7056c..2445df619f0 100644 --- a/sys/dev/pci/if_ath_pci.c +++ b/sys/dev/pci/if_ath_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ath_pci.c,v 1.21 2007/04/17 21:50:31 dyoung Exp $ */ +/* $NetBSD: if_ath_pci.c,v 1.22 2007/12/09 20:28:08 jmcneill Exp $ */ /*- * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath_pci.c,v 1.11 2005/01/18 18:08:16 sam Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: if_ath_pci.c,v 1.21 2007/04/17 21:50:31 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ath_pci.c,v 1.22 2007/12/09 20:28:08 jmcneill Exp $"); #endif /* @@ -84,22 +84,16 @@ struct ath_pci_softc { struct ath_softc sc_sc; pci_chipset_tag_t sc_pc; pcitag_t sc_pcitag; - struct pci_conf_state sc_pciconf; void *sc_ih; /* interrupt handler */ bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; - void *sc_sdhook; }; #define BS_BAR 0x10 -#define PCIR_RETRY_TIMEOUT_REG 0x40 -#define PCIR_RETRY_TIMEOUT_MASK __BITS(15,8) static void ath_pci_attach(struct device *, struct device *, void *); static int ath_pci_detach(struct device *, int); static int ath_pci_match(struct device *, struct cfdata *, void *); -static void ath_pci_shutdown(void *); -static void ath_pci_powerhook(int, void *); static int ath_pci_detach(struct device *, int); CFATTACH_DECL(ath_pci, @@ -109,8 +103,6 @@ CFATTACH_DECL(ath_pci, ath_pci_detach, NULL); -static int ath_pci_setup(struct pci_attach_args *); - static int ath_pci_match(struct device *parent, struct cfdata *match, void *aux) { @@ -123,34 +115,28 @@ ath_pci_match(struct device *parent, struct cfdata *match, void *aux) return 0; } -static void -ath_disable_retry(pci_chipset_tag_t pc, pcitag_t tag) +static bool +ath_pci_resume(device_t dv) { -#if 0 - pcireg_t retry; + struct ath_pci_softc *sc = device_private(dv); - /* - * Disable retry timeout to keep PCI Tx retries from - * interfering with ACPI C3 CPU state. - */ - retry = pci_conf_read(pc, tag, PCIR_RETRY_TIMEOUT_REG); - pci_conf_write(pc, tag, PCIR_RETRY_TIMEOUT_REG, - retry & ~PCIR_RETRY_TIMEOUT_MASK); -#endif + pci_disable_retry(sc->sc_pc, sc->sc_pcitag); + ath_resume(&sc->sc_sc); + + return true; } static int -ath_pci_setup(struct pci_attach_args *pa) +ath_pci_setup(struct ath_pci_softc *sc) { - pci_chipset_tag_t pc = pa->pa_pc; pcireg_t bhlc, csr, icr, lattimer; /* * Enable memory mapping and bus mastering. */ - pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, - pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG) | - PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_MEM_ENABLE); - csr = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); + csr = pci_conf_read(sc->sc_pc, sc->sc_pcitag, PCI_COMMAND_STATUS_REG); + csr |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_MEM_ENABLE; + pci_conf_write(sc->sc_pc, sc->sc_pcitag, PCI_COMMAND_STATUS_REG, csr); + csr = pci_conf_read(sc->sc_pc, sc->sc_pcitag, PCI_COMMAND_STATUS_REG); if ((csr & PCI_COMMAND_MEM_ENABLE) == 0) { aprint_error("couldn't enable memory mapping\n"); @@ -161,7 +147,7 @@ ath_pci_setup(struct pci_attach_args *pa) return 0; } - ath_disable_retry(pc, pa->pa_tag); + pci_disable_retry(sc->sc_pc, sc->sc_pcitag); /* * XXX Both this comment and code are replicated in @@ -184,13 +170,13 @@ ath_pci_setup(struct pci_attach_args *pa) * I never set a Latency Timer less than 0x10, since that * is what the old code did. */ - bhlc = pci_conf_read(pc, pa->pa_tag, PCI_BHLC_REG); - icr = pci_conf_read(pc, pa->pa_tag, PCI_INTERRUPT_REG); + bhlc = pci_conf_read(sc->sc_pc, sc->sc_pcitag, PCI_BHLC_REG); + icr = pci_conf_read(sc->sc_pc, sc->sc_pcitag, PCI_INTERRUPT_REG); lattimer = MAX(0x10, MIN(0xf8, 8 * PCI_MIN_GNT(icr))); if (PCI_LATTIMER(bhlc) < lattimer) { bhlc &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT); bhlc |= (lattimer << PCI_LATTIMER_SHIFT); - pci_conf_write(pc, pa->pa_tag, PCI_BHLC_REG, bhlc); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, PCI_BHLC_REG, bhlc); } return 1; } @@ -204,15 +190,14 @@ ath_pci_attach(struct device *parent, struct device *self, void *aux) pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; pcireg_t mem_type; - void *phook; const char *intrstr = NULL; psc->sc_pc = pc; psc->sc_pcitag = pa->pa_tag; - if (!ath_pci_setup(pa)) - goto bad; + if (!ath_pci_setup(psc)) + goto bad; /* * Setup memory-mapping of PCI registers. @@ -254,26 +239,15 @@ ath_pci_attach(struct device *parent, struct device *self, void *aux) sc->sc_dmat = pa->pa_dmat; - psc->sc_sdhook = shutdownhook_establish(ath_pci_shutdown, psc); - if (psc->sc_sdhook == NULL) { - aprint_error("couldn't make shutdown hook\n"); - goto bad3; - } - - phook = powerhook_establish(sc->sc_dev.dv_xname, - ath_pci_powerhook, psc); - if (phook == NULL) { - aprint_error("couldn't make power hook\n"); - goto bad3; - } + if (!pmf_device_register(self, NULL, ath_pci_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->sc_if); if (ath_attach(PCI_PRODUCT(pa->pa_id), sc) == 0) return; - shutdownhook_disestablish(psc->sc_sdhook); - powerhook_disestablish(phook); - -bad3: pci_intr_disestablish(pc, psc->sc_ih); + pci_intr_disestablish(pc, psc->sc_ih); bad2: /* XXX */ bad1: /* XXX */ bad: @@ -285,40 +259,9 @@ ath_pci_detach(struct device *self, int flags) { struct ath_pci_softc *psc = (struct ath_pci_softc *)self; - shutdownhook_disestablish(psc->sc_sdhook); ath_detach(&psc->sc_sc); + pmf_device_deregister(self); pci_intr_disestablish(psc->sc_pc, psc->sc_ih); return (0); } - -static void -ath_pci_shutdown(void *self) -{ - struct ath_pci_softc *psc = (struct ath_pci_softc *)self; - - ath_shutdown(&psc->sc_sc); -} - -static void -ath_pci_powerhook(int why, void *arg) -{ - struct ath_pci_softc *sc = arg; - pci_chipset_tag_t pc = sc->sc_pc; - pcitag_t tag = sc->sc_pcitag; - - switch (why) { - case PWR_SOFTSUSPEND: - ath_pci_shutdown(sc); - break; - case PWR_SUSPEND: - pci_conf_capture(pc, tag, &sc->sc_pciconf); - break; - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->sc_pciconf); - ath_disable_retry(pc, tag); - break; - } - - return; -} diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index 1f3b28a99db..e5c3d228af4 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_bge.c,v 1.140 2007/11/07 00:23:18 ad Exp $ */ +/* $NetBSD: if_bge.c,v 1.141 2007/12/09 20:28:08 jmcneill Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.140 2007/11/07 00:23:18 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.141 2007/12/09 20:28:08 jmcneill Exp $"); #include "bpfilter.h" #include "vlan.h" @@ -183,7 +183,6 @@ static int bge_rxthresh_nodenum; static int bge_probe(device_t, cfdata_t, void *); static void bge_attach(device_t, device_t, void *); -static void bge_powerhook(int, void *); static void bge_release_resources(struct bge_softc *); static void bge_txeof(struct bge_softc *); static void bge_rxeof(struct bge_softc *); @@ -196,9 +195,8 @@ static int bge_intr(void *); static void bge_start(struct ifnet *); static int bge_ioctl(struct ifnet *, u_long, void *); static int bge_init(struct ifnet *); -static void bge_stop(struct bge_softc *); +static void bge_stop(struct ifnet *, int); static void bge_watchdog(struct ifnet *); -static void bge_shutdown(void *); static int bge_ifmedia_upd(struct ifnet *); static void bge_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -296,41 +294,34 @@ CFATTACH_DECL_NEW(bge, sizeof(struct bge_softc), static u_int32_t bge_readmem_ind(struct bge_softc *sc, int off) { - struct pci_attach_args *pa = &(sc->bge_pa); pcireg_t val; - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_MEMWIN_BASEADDR, off); - val = pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_MEMWIN_DATA); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_BASEADDR, off); + val = pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_DATA); return val; } static void bge_writemem_ind(struct bge_softc *sc, int off, int val) { - struct pci_attach_args *pa = &(sc->bge_pa); - - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_MEMWIN_BASEADDR, off); - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_MEMWIN_DATA, val); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_BASEADDR, off); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_DATA, val); } #ifdef notdef static u_int32_t bge_readreg_ind(struct bge_softc *sc, int off) { - struct pci_attach_args *pa = &(sc->bge_pa); - - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_REG_BASEADDR, off); - return(pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_REG_DATA)); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_REG_BASEADDR, off); + return(pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_REG_DATA)); } #endif static void bge_writereg_ind(struct bge_softc *sc, int off, int val) { - struct pci_attach_args *pa = &(sc->bge_pa); - - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_REG_BASEADDR, off); - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_REG_DATA, val); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_REG_BASEADDR, off); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_REG_DATA, val); } #ifdef notdef @@ -339,12 +330,11 @@ bge_vpd_readbyte(struct bge_softc *sc, int addr) { int i; u_int32_t val; - struct pci_attach_args *pa = &(sc->bge_pa); - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_VPD_ADDR, addr); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_VPD_ADDR, addr); for (i = 0; i < BGE_TIMEOUT * 10; i++) { DELAY(10); - if (pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_VPD_ADDR) & + if (pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_VPD_ADDR) & BGE_VPD_FLAG) break; } @@ -354,7 +344,7 @@ bge_vpd_readbyte(struct bge_softc *sc, int addr) return(0); } - val = pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_VPD_DATA); + val = pci_conf_read(sc->sc_pc, sc->sca_pcitag, BGE_PCI_VPD_DATA); return((val >> ((addr % 4) * 8)) & 0xFF); } @@ -1220,11 +1210,10 @@ bge_chipinit(struct bge_softc *sc) u_int32_t cachesize; int i; u_int32_t dma_rw_ctl; - struct pci_attach_args *pa = &(sc->bge_pa); /* Set endianness before we access any non-PCI registers. */ - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_MISC_CTL, + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MISC_CTL, BGE_INIT); /* Set power state to D0. */ @@ -1249,11 +1238,11 @@ bge_chipinit(struct bge_softc *sc) */ for (i = BGE_STATS_BLOCK; i < BGE_STATS_BLOCK_END + 1; i += sizeof(u_int32_t)) - BGE_MEMWIN_WRITE(pa->pa_pc, pa->pa_tag, i, 0); + BGE_MEMWIN_WRITE(sc->sc_pc, sc->sc_pcitag, i, 0); for (i = BGE_STATUS_BLOCK; i < BGE_STATUS_BLOCK_END + 1; i += sizeof(u_int32_t)) - BGE_MEMWIN_WRITE(pa->pa_pc, pa->pa_tag, i, 0); + BGE_MEMWIN_WRITE(sc->sc_pc, sc->sc_pcitag, i, 0); /* Set up the PCI DMA control register. */ if (sc->bge_pcie) { @@ -1271,7 +1260,7 @@ bge_chipinit(struct bge_softc *sc) #define DMA_CTRL_WRITE_PCIE_H20MARK_256 0x00380000 dma_rw_ctl = 0x76000000; /* XXX XXX XXX */; - device_ctl = pci_conf_read(pa->pa_pc, pa->pa_tag, + device_ctl = pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CONF_DEV_CTRL); aprint_debug_dev(sc->bge_dev, "pcie mode=0x%x\n", device_ctl); @@ -1287,7 +1276,7 @@ bge_chipinit(struct bge_softc *sc) } else { dma_rw_ctl |= BGE_PCIDMA_RWCTL_PCIE_WRITE_WATRMARK_128; } - } else if (pci_conf_read(pa->pa_pc, pa->pa_tag,BGE_PCI_PCISTATE) & + } else if (pci_conf_read(sc->sc_pc, sc->sc_pcitag,BGE_PCI_PCISTATE) & BGE_PCISTATE_PCI_BUSMODE) { /* Conventional PCI bus */ DPRINTFN(4, ("(%s: PCI 2.2 DMA setting)\n", @@ -1335,7 +1324,7 @@ bge_chipinit(struct bge_softc *sc) } } - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_DMA_RW_CTL, dma_rw_ctl); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_DMA_RW_CTL, dma_rw_ctl); /* * Set up general mode register. @@ -1345,40 +1334,40 @@ bge_chipinit(struct bge_softc *sc) BGE_MODECTL_TX_NO_PHDR_CSUM|BGE_MODECTL_RX_NO_PHDR_CSUM); /* Get cache line size. */ - cachesize = pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_CACHESZ); + cachesize = pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CACHESZ); /* * Avoid violating PCI spec on certain chip revs. */ - if (pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_CMD) & + if (pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CMD) & PCIM_CMD_MWIEN) { switch(cachesize) { case 1: - PCI_SETBIT(pa->pa_pc, pa->pa_tag, BGE_PCI_DMA_RW_CTL, + PCI_SETBIT(sc->sc_pc, sc->sc_pcitag, BGE_PCI_DMA_RW_CTL, BGE_PCI_WRITE_BNDRY_16BYTES); break; case 2: - PCI_SETBIT(pa->pa_pc, pa->pa_tag, BGE_PCI_DMA_RW_CTL, + PCI_SETBIT(sc->sc_pc, sc->sc_pcitag, BGE_PCI_DMA_RW_CTL, BGE_PCI_WRITE_BNDRY_32BYTES); break; case 4: - PCI_SETBIT(pa->pa_pc, pa->pa_tag, BGE_PCI_DMA_RW_CTL, + PCI_SETBIT(sc->sc_pc, sc->sc_pcitag, BGE_PCI_DMA_RW_CTL, BGE_PCI_WRITE_BNDRY_64BYTES); break; case 8: - PCI_SETBIT(pa->pa_pc, pa->pa_tag, BGE_PCI_DMA_RW_CTL, + PCI_SETBIT(sc->sc_pc, sc->sc_pcitag, BGE_PCI_DMA_RW_CTL, BGE_PCI_WRITE_BNDRY_128BYTES); break; case 16: - PCI_SETBIT(pa->pa_pc, pa->pa_tag, BGE_PCI_DMA_RW_CTL, + PCI_SETBIT(sc->sc_pc, sc->sc_pcitag, BGE_PCI_DMA_RW_CTL, BGE_PCI_WRITE_BNDRY_256BYTES); break; case 32: - PCI_SETBIT(pa->pa_pc, pa->pa_tag, BGE_PCI_DMA_RW_CTL, + PCI_SETBIT(sc->sc_pc, sc->sc_pcitag, BGE_PCI_DMA_RW_CTL, BGE_PCI_WRITE_BNDRY_512BYTES); break; case 64: - PCI_SETBIT(pa->pa_pc, pa->pa_tag, BGE_PCI_DMA_RW_CTL, + PCI_SETBIT(sc->sc_pc, sc->sc_pcitag, BGE_PCI_DMA_RW_CTL, BGE_PCI_WRITE_BNDRY_1024BYTES); break; default: @@ -1389,7 +1378,7 @@ bge_chipinit(struct bge_softc *sc) "cache line size %d not supported " "disabling PCI MWI\n", #endif - PCI_CLRBIT(pa->pa_pc, pa->pa_tag, BGE_PCI_CMD, + PCI_CLRBIT(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CMD, PCIM_CMD_MWIEN); break; } @@ -1399,7 +1388,7 @@ bge_chipinit(struct bge_softc *sc) * Disable memory write invalidate. Apparently it is not supported * properly by these devices. */ - PCI_CLRBIT(pa->pa_pc, pa->pa_tag, BGE_PCI_CMD, PCIM_CMD_MWIEN); + PCI_CLRBIT(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CMD, PCIM_CMD_MWIEN); #ifdef __brokenalpha__ @@ -1434,8 +1423,7 @@ bge_blockinit(struct bge_softc *sc) * ring RCBs, plus other things which live in NIC memory. */ - pci_conf_write(sc->bge_pa.pa_pc, sc->bge_pa.pa_tag, - BGE_PCI_MEMWIN_BASEADDR, 0); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MEMWIN_BASEADDR, 0); /* Configure mbuf memory pool */ if ((sc->bge_quirks & BGE_QUIRK_5705_CORE) == 0) { @@ -2424,7 +2412,7 @@ bge_attach(device_t parent, device_t self, void *aux) struct pci_attach_args *pa = aux; const struct bge_product *bp; const struct bge_revision *br; - pci_chipset_tag_t pc = pa->pa_pc; + pci_chipset_tag_t pc = sc->sc_pc; pci_intr_handle_t ih; const char *intrstr = NULL; bus_dma_segment_t seg; @@ -2443,8 +2431,9 @@ bge_attach(device_t parent, device_t self, void *aux) bp = bge_lookup(pa); KASSERT(bp != NULL); + sc->sc_pc = pa->pa_pc; + sc->sc_pcitag = pa->pa_tag; sc->bge_dev = self; - sc->bge_pa = *pa; aprint_naive(": Ethernet controller\n"); aprint_normal(": %s\n", bp->bp_name); @@ -2453,10 +2442,10 @@ bge_attach(device_t parent, device_t self, void *aux) * Map control/status registers. */ DPRINTFN(5, ("Map control/status regs\n")); - command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); + command = pci_conf_read(pc, sc->sc_pcitag, PCI_COMMAND_STATUS_REG); command |= PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE; - pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, command); - command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); + pci_conf_write(pc, sc->sc_pcitag, PCI_COMMAND_STATUS_REG, command); + command = pci_conf_read(pc, sc->sc_pcitag, PCI_COMMAND_STATUS_REG); if (!(command & PCI_COMMAND_MEM_ENABLE)) { aprint_error_dev(sc->bge_dev, @@ -2465,7 +2454,7 @@ bge_attach(device_t parent, device_t self, void *aux) } DPRINTFN(5, ("pci_mem_find\n")); - memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, BGE_PCI_BAR0); + memtype = pci_mapreg_type(sc->sc_pc, sc->sc_pcitag, BGE_PCI_BAR0); switch (memtype) { case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: @@ -2505,10 +2494,10 @@ bge_attach(device_t parent, device_t self, void *aux) * We do not have memory-mapped registers in this state, * so force device into D0 state before starting initialization. */ - pm_ctl = pci_conf_read(pc, pa->pa_tag, BGE_PCI_PWRMGMT_CMD); + pm_ctl = pci_conf_read(pc, sc->sc_pcitag, BGE_PCI_PWRMGMT_CMD); pm_ctl &= ~(PCI_PWR_D0|PCI_PWR_D1|PCI_PWR_D2|PCI_PWR_D3); pm_ctl |= (1 << 8) | PCI_PWR_D0 ; /* D0 state */ - pci_conf_write(pc, pa->pa_tag, BGE_PCI_PWRMGMT_CMD, pm_ctl); + pci_conf_write(pc, sc->sc_pcitag, BGE_PCI_PWRMGMT_CMD, pm_ctl); DELAY(1000); /* 27 usec is allegedly sufficent */ /* @@ -2516,14 +2505,14 @@ bge_attach(device_t parent, device_t self, void *aux) * ASIC. */ sc->bge_chipid = - pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_MISC_CTL) & + pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MISC_CTL) & BGE_PCIMISCCTL_ASICREV; /* * Detect PCI-Express devices * XXX: guessed from Linux/FreeBSD; no documentation */ - if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_PCIEXPRESS, + if (pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_PCIEXPRESS, NULL, NULL) != 0) sc->bge_pcie = 1; else @@ -2651,6 +2640,7 @@ bge_attach(device_t parent, device_t self, void *aux) ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = bge_ioctl; + ifp->if_stop = bge_stop; ifp->if_start = bge_start; ifp->if_init = bge_init; ifp->if_watchdog = bge_watchdog; @@ -2698,7 +2688,7 @@ bge_attach(device_t parent, device_t self, void *aux) sc->bge_tbi = 1; /* The SysKonnect SK-9D41 is a 1000baseSX card. */ - if ((pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_SUBSYS) >> 16) == + if ((pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_SUBSYS) >> 16) == SK_SUBSYSID_9D41) sc->bge_tbi = 1; @@ -2741,7 +2731,7 @@ bge_attach(device_t parent, device_t self, void *aux) */ if (sc->bge_quirks & BGE_QUIRK_PCIX_DMA_ALIGN_BUG) { /* If in PCI-X mode, work around the alignment bug. */ - if ((pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_PCISTATE) & + if ((pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_PCISTATE) & (BGE_PCISTATE_PCI_BUSMODE | BGE_PCISTATE_PCI_BUSSPEED)) == BGE_PCISTATE_PCI_BUSSPEED) sc->bge_rx_alignment_bug = 1; @@ -2776,11 +2766,10 @@ bge_attach(device_t parent, device_t self, void *aux) DPRINTFN(5, ("callout_init\n")); callout_init(&sc->bge_timeout, 0); - sc->bge_powerhook = powerhook_establish(device_xname(sc->bge_dev), - bge_powerhook, sc); - if (sc->bge_powerhook == NULL) - aprint_error_dev(sc->bge_dev, - "unable to establish PCI power hook\n"); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, ifp); } static void @@ -2796,16 +2785,15 @@ bge_release_resources(struct bge_softc *sc) static void bge_reset(struct bge_softc *sc) { - struct pci_attach_args *pa = &sc->bge_pa; u_int32_t cachesize, command, pcistate, new_pcistate; int i, val; /* Save some important PCI state. */ - cachesize = pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_CACHESZ); - command = pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_CMD); - pcistate = pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_PCISTATE); + cachesize = pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CACHESZ); + command = pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CMD); + pcistate = pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_PCISTATE); - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_MISC_CTL, + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MISC_CTL, BGE_PCIMISCCTL_INDIRECT_ACCESS|BGE_PCIMISCCTL_MASK_PCI_INTR| BGE_HIF_SWAP_OPTIONS|BGE_PCIMISCCTL_PCISTATE_RW); @@ -2846,8 +2834,8 @@ bge_reset(struct bge_softc *sc) DELAY(500000); /* XXX: Magic Numbers */ - reg = pci_conf_read(pa->pa_pc, pa->pa_tag, BGE_PCI_UNKNOWN0); - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_UNKNOWN0, + reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_UNKNOWN0); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_UNKNOWN0, reg | (1 << 15)); } /* @@ -2856,17 +2844,17 @@ bge_reset(struct bge_softc *sc) * Should be replaced with references to PCI config-space * capability block for PCI-Express. */ - pci_conf_write(pa->pa_pc, pa->pa_tag, + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CONF_DEV_CTRL, 0xf5000); } /* Reset some of the PCI state that got zapped by reset */ - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_MISC_CTL, + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_MISC_CTL, BGE_PCIMISCCTL_INDIRECT_ACCESS|BGE_PCIMISCCTL_MASK_PCI_INTR| BGE_HIF_SWAP_OPTIONS|BGE_PCIMISCCTL_PCISTATE_RW); - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_CMD, command); - pci_conf_write(pa->pa_pc, pa->pa_tag, BGE_PCI_CACHESZ, cachesize); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CMD, command); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, BGE_PCI_CACHESZ, cachesize); bge_writereg_ind(sc, BGE_MISC_CFG, (65 << 1)); /* Enable memory arbiter. */ @@ -2918,7 +2906,7 @@ bge_reset(struct bge_softc *sc) * results. */ for (i = 0; i < 10000; i++) { - new_pcistate = pci_conf_read(pa->pa_pc, pa->pa_tag, + new_pcistate = pci_conf_read(sc->sc_pc, sc->sc_pcitag, BGE_PCI_PCISTATE); if ((new_pcistate & ~BGE_PCISTATE_RESERVED) == (pcistate & ~BGE_PCISTATE_RESERVED)) @@ -3943,7 +3931,7 @@ bge_init(struct ifnet *ifp) ifp = &sc->ethercom.ec_if; /* Cancel pending I/O and flush buffers. */ - bge_stop(sc); + bge_stop(ifp, 0); bge_reset(sc); bge_chipinit(sc); @@ -4123,9 +4111,8 @@ bge_ioctl(struct ifnet *ifp, u_long command, void *data) } else if (!(sc->bge_if_flags & IFF_UP)) bge_init(ifp); } else { - if (ifp->if_flags & IFF_RUNNING) { - bge_stop(sc); - } + if (ifp->if_flags & IFF_RUNNING) + bge_stop(ifp, 1); } sc->bge_if_flags = ifp->if_flags; error = 0; @@ -4215,9 +4202,9 @@ bge_stop_block(struct bge_softc *sc, bus_addr_t reg, uint32_t bit) * RX and TX lists. */ static void -bge_stop(struct bge_softc *sc) +bge_stop(struct ifnet *ifp, int disable) { - struct ifnet *ifp = &sc->ethercom.ec_if; + struct bge_softc *sc = ifp->if_softc; callout_stop(&sc->bge_timeout); @@ -4296,20 +4283,6 @@ bge_stop(struct bge_softc *sc) ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); } -/* - * Stop all chip I/O so that the kernel's probe routines don't - * get confused by errant DMAs when rebooting. - */ -static void -bge_shutdown(void *xsc) -{ - struct bge_softc *sc = (struct bge_softc *)xsc; - - bge_stop(sc); - bge_reset(sc); -} - - static int sysctl_bge_verify(SYSCTLFN_ARGS) { @@ -4384,35 +4357,3 @@ SYSCTL_SETUP(sysctl_bge, "sysctl bge subtree setup") err: aprint_error("%s: sysctl_createv failed (rc = %d)\n", __func__, rc); } - -static void -bge_powerhook(int why, void *hdl) -{ - struct bge_softc *sc = (struct bge_softc *)hdl; - struct ifnet *ifp = &sc->ethercom.ec_if; - struct pci_attach_args *pa = &(sc->bge_pa); - pci_chipset_tag_t pc = pa->pa_pc; - pcitag_t tag = pa->pa_tag; - - switch (why) { - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - bge_shutdown(sc); - break; - case PWR_SOFTRESUME: - if (ifp->if_flags & IFF_UP) { - ifp->if_flags &= ~IFF_RUNNING; - bge_init(ifp); - } - break; - case PWR_SUSPEND: - case PWR_STANDBY: - pci_conf_capture(pc, tag, &sc->bge_pciconf); - break; - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->bge_pciconf); - break; - } - - return; -} diff --git a/sys/dev/pci/if_bgereg.h b/sys/dev/pci/if_bgereg.h index a643ca3bb8a..edc459bcbc1 100644 --- a/sys/dev/pci/if_bgereg.h +++ b/sys/dev/pci/if_bgereg.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_bgereg.h,v 1.44 2007/09/24 21:25:45 joerg Exp $ */ +/* $NetBSD: if_bgereg.h,v 1.45 2007/12/09 20:28:08 jmcneill Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2001 @@ -2385,7 +2385,9 @@ struct bge_softc { bus_space_handle_t bge_bhandle; bus_space_tag_t bge_btag; void *bge_intrhand; - struct pci_attach_args bge_pa; + pci_chipset_tag_t sc_pc; + pcitag_t sc_pcitag; + struct mii_data bge_mii; struct ifmedia bge_ifmedia; /* media info */ u_int8_t bge_extram; /* has external SSRAM */ @@ -2437,6 +2439,4 @@ struct bge_softc { int bge_pending_rxintr_change; SLIST_HEAD(, txdmamap_pool_entry) txdma_list; struct txdmamap_pool_entry *txdma[BGE_TX_RING_CNT]; - void *bge_powerhook; - struct pci_conf_state bge_pciconf; }; diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index 9c28578fe4b..5595a48fabc 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ipw.c,v 1.34 2007/10/19 12:00:45 ad Exp $ */ +/* $NetBSD: if_ipw.c,v 1.35 2007/12/09 20:28:09 jmcneill Exp $ */ /* FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.15 2005/11/13 17:17:40 damien Exp */ /*- @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.34 2007/10/19 12:00:45 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.35 2007/12/09 20:28:09 jmcneill Exp $"); /*- * Intel(R) PRO/Wireless 2100 MiniPCI driver @@ -94,10 +94,7 @@ static int ipw_match(struct device *, struct cfdata *, void *); static void ipw_attach(struct device *, struct device *, void *); static int ipw_detach(struct device *, int); -static void ipw_shutdown(void *); -static int ipw_suspend(struct ipw_softc *); -static int ipw_resume(struct ipw_softc *); -static void ipw_powerhook(int, void *); +static bool ipw_resume(device_t); static int ipw_media_change(struct ifnet *); static void ipw_media_status(struct ifnet *, struct ifmediareq *); @@ -204,10 +201,7 @@ ipw_attach(struct device *parent, struct device *self, void *aux) data |= PCI_COMMAND_MASTER_ENABLE; pci_conf_write(sc->sc_pct, pa->pa_tag, PCI_COMMAND_STATUS_REG, data); - /* clear device specific PCI configuration register 0x41 */ - data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); - data &= ~0x0000ff00; - pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); + pci_disable_retry(sc->sc_pct, sc->sc_pcitag); /* map the register window */ error = pci_mapreg_map(pa, IPW_PCI_BAR0, PCI_MAPREG_TYPE_MEM | @@ -340,18 +334,10 @@ ipw_attach(struct device *parent, struct device *self, void *aux) */ sc->dwelltime = 100; - /* - * Make sure the interface is shutdown during reboot. - */ - sc->sc_sdhook = shutdownhook_establish(ipw_shutdown, sc); - if (sc->sc_sdhook == NULL) - aprint_error("%s: WARNING: unable to establish shutdown hook\n", - sc->sc_dev.dv_xname); - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - ipw_powerhook, sc); - if (sc->sc_powerhook == NULL) - printf("%s: WARNING: unable to establish power hook\n", - sc->sc_dev.dv_xname); + if (!pmf_device_register(self, NULL, ipw_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, ifp); ieee80211_announce(ic); @@ -756,67 +742,14 @@ ipw_release(struct ipw_softc *sc) } -static void -ipw_shutdown(void *arg) +static bool +ipw_resume(device_t dv) { - struct ipw_softc *sc = (struct ipw_softc *)arg; - struct ifnet *ifp = sc->sc_ic.ic_ifp; + struct ipw_softc *sc = device_private(dv); - ipw_stop(ifp, 1); -} + pci_disable_retry(sc->sc_pct, sc->sc_pcitag); - -static int -ipw_suspend(struct ipw_softc *sc) -{ - struct ifnet *ifp = sc->sc_ic.ic_ifp; - - ipw_stop(ifp, 1); - - return 0; -} - -static int -ipw_resume(struct ipw_softc *sc) -{ - struct ifnet *ifp = sc->sc_ic.ic_ifp; - pcireg_t data; - - /* clear device specific PCI configuration register 0x41 */ - data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); - data &= ~0x0000ff00; - pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); - - if (ifp->if_flags & IFF_UP) { - ipw_init(ifp); - if (ifp->if_flags & IFF_RUNNING) - ipw_start(ifp); - } - - return 0; -} - -static void -ipw_powerhook(int why, void *arg) -{ - struct ipw_softc *sc = arg; - int s; - - s = splnet(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - ipw_suspend(sc); - break; - case PWR_RESUME: - ipw_resume(sc); - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } - splx(s); + return true; } static int diff --git a/sys/dev/pci/if_ipwvar.h b/sys/dev/pci/if_ipwvar.h index 53afc561a4c..a71c4a07c85 100644 --- a/sys/dev/pci/if_ipwvar.h +++ b/sys/dev/pci/if_ipwvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_ipwvar.h,v 1.11 2006/04/17 20:57:24 rpaulo Exp $ */ +/* $NetBSD: if_ipwvar.h,v 1.12 2007/12/09 20:28:09 jmcneill Exp $ */ /*- * Copyright (c) 2004 @@ -109,9 +109,6 @@ struct ipw_softc { pcitag_t sc_pcitag; bus_size_t sc_sz; - void *sc_sdhook; /* shutdown hook */ - void *sc_powerhook; /* power management hook */ - int sc_tx_timer; bus_dma_tag_t sc_dmat; diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index 9c7365af277..906360e800b 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwi.c,v 1.67 2007/10/22 15:31:46 joerg Exp $ */ +/* $NetBSD: if_iwi.c,v 1.68 2007/12/09 20:28:09 jmcneill Exp $ */ /*- * Copyright (c) 2004, 2005 @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.67 2007/10/22 15:31:46 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.68 2007/12/09 20:28:09 jmcneill Exp $"); /*- * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver @@ -94,11 +94,6 @@ static int iwi_match(device_t, struct cfdata *, void *); static void iwi_attach(device_t, device_t, void *); static int iwi_detach(device_t, int); -static void iwi_shutdown(void *); -static int iwi_suspend(struct iwi_softc *); -static int iwi_resume(struct iwi_softc *); -static void iwi_powerhook(int, void *); - static int iwi_alloc_cmd_ring(struct iwi_softc *, struct iwi_cmd_ring *, int); static void iwi_reset_cmd_ring(struct iwi_softc *, struct iwi_cmd_ring *); @@ -206,6 +201,16 @@ iwi_match(device_t parent, struct cfdata *match, void *aux) return 0; } +static bool +iwi_pci_resume(device_t dv) +{ + struct iwi_softc *sc = device_private(dv); + + pci_disable_retry(sc->sc_pct, sc->sc_pcitag); + + return true; +} + /* Base Address Register */ #define IWI_PCI_BAR0 0x10 @@ -233,10 +238,7 @@ iwi_attach(device_t parent, device_t self, void *aux) revision = PCI_REVISION(pa->pa_class); aprint_normal(": %s (rev. 0x%02x)\n", devinfo, revision); - /* clear device specific PCI configuration register 0x41 */ - data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); - data &= ~0x0000ff00; - pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); + pci_disable_retry(sc->sc_pct, sc->sc_pcitag); /* clear unit numbers allocated to IBSS */ sc->sc_unr = 0; @@ -435,18 +437,10 @@ iwi_attach(device_t parent, device_t self, void *aux) iwi_sysctlattach(sc); - /* - * Make sure the interface is shutdown during reboot. - */ - sc->sc_sdhook = shutdownhook_establish(iwi_shutdown, sc); - if (sc->sc_sdhook == NULL) - aprint_error_dev(self, - "WARNING: unable to establish shutdown hook\n"); - sc->sc_powerhook = powerhook_establish(device_xname(self), - iwi_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error_dev(self, - "WARNING: unable to establish power hook\n"); + if (!pmf_device_register(self, NULL, iwi_pci_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, ifp); ieee80211_announce(ic); @@ -461,6 +455,8 @@ iwi_detach(device_t self, int flags) struct iwi_softc *sc = device_private(self); struct ifnet *ifp = &sc->sc_if; + pmf_device_deregister(self); + if (ifp != NULL) iwi_stop(ifp, 1); @@ -484,9 +480,6 @@ iwi_detach(device_t self, int flags) bus_space_unmap(sc->sc_st, sc->sc_sh, sc->sc_sz); - powerhook_disestablish(sc->sc_powerhook); - shutdownhook_disestablish(sc->sc_sdhook); - return 0; } @@ -784,73 +777,6 @@ iwi_free_rx_ring(struct iwi_softc *sc, struct iwi_rx_ring *ring) } } -static void -iwi_shutdown(void *arg) -{ - struct iwi_softc *sc = (struct iwi_softc *)arg; - struct ifnet *ifp = sc->sc_ic.ic_ifp; - - iwi_stop(ifp, 1); -} - -static int -iwi_suspend(struct iwi_softc *sc) -{ - struct ifnet *ifp = sc->sc_ic.ic_ifp; - - iwi_stop(ifp, 1); - - return 0; -} - -static int -iwi_resume(struct iwi_softc *sc) -{ - struct ifnet *ifp = sc->sc_ic.ic_ifp; - pcireg_t data; - - /* clear device specific PCI configuration register 0x41 */ - data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); - data &= ~0x0000ff00; - pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); - - if (ifp->if_flags & IFF_UP) { - iwi_init(ifp); - if (ifp->if_flags & IFF_RUNNING) - iwi_start(ifp); - } - - return 0; -} - -static void -iwi_powerhook(int why, void *arg) -{ - struct iwi_softc *sc = arg; - pci_chipset_tag_t pc = sc->sc_pct; - pcitag_t tag = sc->sc_pcitag; - int s; - - s = splnet(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - pci_conf_capture(pc, tag, &sc->sc_pciconf); - break; - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->sc_pciconf); - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - iwi_suspend(sc); - break; - case PWR_SOFTRESUME: - iwi_resume(sc); - break; - } - splx(s); -} - static struct ieee80211_node * iwi_node_alloc(struct ieee80211_node_table *nt) { diff --git a/sys/dev/pci/if_iwivar.h b/sys/dev/pci/if_iwivar.h index 0ada21412d8..ea55920d05d 100644 --- a/sys/dev/pci/if_iwivar.h +++ b/sys/dev/pci/if_iwivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwivar.h,v 1.14 2007/10/22 15:28:48 joerg Exp $ */ +/* $NetBSD: if_iwivar.h,v 1.15 2007/12/09 20:28:09 jmcneill Exp $ */ /*- * Copyright (c) 2004, 2005 @@ -144,10 +144,6 @@ struct iwi_softc { pcitag_t sc_pcitag; bus_size_t sc_sz; - void *sc_sdhook; /* shutdown hook */ - void *sc_powerhook; /* power management hook */ - struct pci_conf_state sc_pciconf; - struct sysctllog *sc_sysctllog; int antenna; diff --git a/sys/dev/pci/if_nfe.c b/sys/dev/pci/if_nfe.c index 8a003b97c6f..f58201e3e5d 100644 --- a/sys/dev/pci/if_nfe.c +++ b/sys/dev/pci/if_nfe.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_nfe.c,v 1.23 2007/11/14 14:59:50 xtraeme Exp $ */ +/* $NetBSD: if_nfe.c,v 1.24 2007/12/09 20:28:09 jmcneill Exp $ */ /* $OpenBSD: if_nfe.c,v 1.52 2006/03/02 09:04:00 jsg Exp $ */ /*- @@ -21,7 +21,7 @@ /* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.23 2007/11/14 14:59:50 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.24 2007/12/09 20:28:09 jmcneill Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -323,6 +323,7 @@ nfe_attach(struct device *parent, struct device *self, void *aux) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = nfe_ioctl; ifp->if_start = nfe_start; + ifp->if_stop = nfe_stop; ifp->if_watchdog = nfe_watchdog; ifp->if_init = nfe_init; ifp->if_baudrate = IF_Gbps(1); @@ -365,25 +366,10 @@ nfe_attach(struct device *parent, struct device *self, void *aux) callout_init(&sc->sc_tick_ch, 0); callout_setfunc(&sc->sc_tick_ch, nfe_tick, sc); - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - nfe_power, sc); -} - -void -nfe_power(int why, void *arg) -{ - struct nfe_softc *sc = arg; - struct ifnet *ifp; - - if (why == PWR_RESUME) { - ifp = &sc->sc_ethercom.ec_if; - if (ifp->if_flags & IFF_UP) { - ifp->if_flags &= ~IFF_RUNNING; - nfe_init(ifp); - if (ifp->if_flags & IFF_RUNNING) - nfe_start(ifp); - } - } + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, ifp); } void diff --git a/sys/dev/pci/if_nfevar.h b/sys/dev/pci/if_nfevar.h index 368cedf5964..f4c2137e03b 100644 --- a/sys/dev/pci/if_nfevar.h +++ b/sys/dev/pci/if_nfevar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_nfevar.h,v 1.3 2007/09/24 13:17:54 cube Exp $ */ +/* $NetBSD: if_nfevar.h,v 1.4 2007/12/09 20:28:09 jmcneill Exp $ */ /* $OpenBSD: if_nfevar.h,v 1.11 2006/02/19 13:57:02 damien Exp $ */ /*- @@ -76,7 +76,6 @@ struct nfe_softc { bus_dma_tag_t sc_dmat; struct mii_data sc_mii; struct callout sc_tick_ch; - void *sc_powerhook; int sc_if_flags; u_int sc_flags; diff --git a/sys/dev/pci/if_re_pci.c b/sys/dev/pci/if_re_pci.c index 3d1c610432b..10100ab8d83 100644 --- a/sys/dev/pci/if_re_pci.c +++ b/sys/dev/pci/if_re_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_re_pci.c,v 1.30 2007/10/19 12:00:47 ad Exp $ */ +/* $NetBSD: if_re_pci.c,v 1.31 2007/12/09 20:28:09 jmcneill Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -183,43 +183,13 @@ re_pci_attach(struct device *parent, struct device *self, void *aux) const struct rtk_type *t; uint32_t hwrev; int error = 0; - pcireg_t pmreg, memtype; + pcireg_t memtype; bool ioh_valid, memh_valid; pcireg_t command; bus_space_tag_t iot, memt; bus_space_handle_t ioh, memh; bus_size_t iosize, memsize, bsize; - - /* - * Handle power management nonsense. - */ - if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) { - command = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR); - if (command & PCI_PMCSR_STATE_MASK) { - u_int32_t iobase, membase, irq; - - /* Save important PCI config data. */ - iobase = pci_conf_read(pc, pa->pa_tag, RTK_PCI_LOIO); - membase = pci_conf_read(pc, pa->pa_tag, RTK_PCI_LOMEM); - irq = pci_conf_read(pc, pa->pa_tag, PCI_INTERRUPT_REG); - - /* Reset the power state. */ - aprint_normal("%s: chip is is in D%d power mode " - "-- setting to D0\n", sc->sc_dev.dv_xname, - command & PCI_PMCSR_STATE_MASK); - - command &= ~PCI_PMCSR_STATE_MASK; - pci_conf_write(pc, pa->pa_tag, - pmreg + PCI_PMCSR, command); - - /* Restore PCI config data. */ - pci_conf_write(pc, pa->pa_tag, RTK_PCI_LOIO, iobase); - pci_conf_write(pc, pa->pa_tag, RTK_PCI_LOMEM, membase); - pci_conf_write(pc, pa->pa_tag, PCI_INTERRUPT_REG, irq); - } - } - /* * Map control/status registers. */ @@ -329,4 +299,9 @@ re_pci_attach(struct device *parent, struct device *self, void *aux) bus_space_unmap(memt, memh, memsize); } } + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->ethercom.ec_if); } diff --git a/sys/dev/pci/if_rtk_pci.c b/sys/dev/pci/if_rtk_pci.c index c9422141883..de7fa68de56 100644 --- a/sys/dev/pci/if_rtk_pci.c +++ b/sys/dev/pci/if_rtk_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_rtk_pci.c,v 1.34 2007/11/06 02:29:19 uwe Exp $ */ +/* $NetBSD: if_rtk_pci.c,v 1.35 2007/12/09 20:28:10 jmcneill Exp $ */ /* * Copyright (c) 1997, 1998 @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_rtk_pci.c,v 1.34 2007/11/06 02:29:19 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_rtk_pci.c,v 1.35 2007/12/09 20:28:10 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -82,11 +82,6 @@ struct rtk_pci_softc { /* PCI-specific goo.*/ void *sc_ih; - pci_chipset_tag_t sc_pc; /* PCI chipset */ - pcitag_t sc_pcitag; /* PCI tag */ - - void *sc_powerhook; /* powerhook ctxt. */ - struct pci_conf_state sc_pciconf; }; static const struct rtk_type rtk_pci_devs[] = { @@ -111,7 +106,6 @@ static const struct rtk_type rtk_pci_devs[] = { static int rtk_pci_match(device_t, struct cfdata *, void *); static void rtk_pci_attach(device_t, device_t, void *); -static void rtk_pci_powerhook(int, void *); CFATTACH_DECL(rtk_pci, sizeof(struct rtk_pci_softc), rtk_pci_match, rtk_pci_attach, NULL, NULL); @@ -151,7 +145,6 @@ rtk_pci_attach(device_t parent, device_t self, void *aux) { struct rtk_pci_softc *psc = device_private(self); struct rtk_softc *sc = &psc->sc_rtk; - pcireg_t command; struct pci_attach_args *pa = aux; pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; @@ -159,12 +152,8 @@ rtk_pci_attach(device_t parent, device_t self, void *aux) bus_space_handle_t ioh, memh; const char *intrstr = NULL; const struct rtk_type *t; - int pmreg; int ioh_valid, memh_valid; - psc->sc_pc = pa->pa_pc; - psc->sc_pcitag = pa->pa_tag; - t = rtk_pci_lookup(pa); if (t == NULL) { printf("\n"); @@ -176,35 +165,6 @@ rtk_pci_attach(device_t parent, device_t self, void *aux) t->rtk_name, PCI_REVISION(pa->pa_class)); /* - * Handle power management nonsense. - */ - - if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) { - command = pci_conf_read(pc, pa->pa_tag, pmreg + PCI_PMCSR); - if (command & PCI_PMCSR_STATE_MASK) { - pcireg_t iobase, membase, irq; - - /* Save important PCI config data. */ - iobase = pci_conf_read(pc, pa->pa_tag, RTK_PCI_LOIO); - membase = pci_conf_read(pc, pa->pa_tag, RTK_PCI_LOMEM); - irq = pci_conf_read(pc, pa->pa_tag, PCI_INTERRUPT_REG); - - /* Reset the power state. */ - aprint_normal_dev(self, - "chip is in D%d power mode -- setting to D0\n", - command & PCI_PMCSR_STATE_MASK); - command &= ~PCI_PMCSR_STATE_MASK; - pci_conf_write(pc, pa->pa_tag, - pmreg + PCI_PMCSR, command); - - /* Restore PCI config data. */ - pci_conf_write(pc, pa->pa_tag, RTK_PCI_LOIO, iobase); - pci_conf_write(pc, pa->pa_tag, RTK_PCI_LOMEM, membase); - pci_conf_write(pc, pa->pa_tag, PCI_INTERRUPT_REG, irq); - } - } - - /* * Map control/status registers. * * The original FreeBSD's driver has the following comment: @@ -258,34 +218,10 @@ rtk_pci_attach(device_t parent, device_t self, void *aux) sc->sc_dmat = pa->pa_dmat; sc->sc_flags |= RTK_ENABLED; - psc->sc_powerhook = powerhook_establish(device_xname(self), - rtk_pci_powerhook, psc); - if (psc->sc_powerhook == NULL) - aprint_error_dev(self, - "WARNING: unable to establish pci power hook\n"); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->ethercom.ec_if); rtk_attach(sc); } - -static void -rtk_pci_powerhook(int why, void *arg) -{ - struct rtk_pci_softc *sc = (struct rtk_pci_softc *)arg; - int s; - - s = splnet(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - pci_conf_capture(sc->sc_pc, sc->sc_pcitag, &sc->sc_pciconf); - break; - case PWR_RESUME: - pci_conf_restore(sc->sc_pc, sc->sc_pcitag, &sc->sc_pciconf); - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } - splx(s); -} diff --git a/sys/dev/pci/if_wi_pci.c b/sys/dev/pci/if_wi_pci.c index d113cda1900..78e7db292ae 100644 --- a/sys/dev/pci/if_wi_pci.c +++ b/sys/dev/pci/if_wi_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wi_pci.c,v 1.42 2007/10/19 12:00:49 ad Exp $ */ +/* $NetBSD: if_wi_pci.c,v 1.43 2007/12/09 20:28:10 jmcneill Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wi_pci.c,v 1.42 2007/10/19 12:00:49 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wi_pci.c,v 1.43 2007/12/09 20:28:10 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -92,8 +92,7 @@ struct wi_pci_softc { /* PCI-specific goo */ pci_intr_handle_t psc_ih; pci_chipset_tag_t psc_pc; - - void *sc_powerhook; /* power hook descriptor */ + pcitag_t psc_pcitag; }; static int wi_pci_match(struct device *, struct cfdata *, void *); @@ -101,7 +100,6 @@ static void wi_pci_attach(struct device *, struct device *, void *); static int wi_pci_enable(struct wi_softc *); static void wi_pci_disable(struct wi_softc *); static void wi_pci_reset(struct wi_softc *); -static void wi_pci_powerhook(int, void *); static const struct wi_pci_product *wi_pci_lookup(struct pci_attach_args *); @@ -236,6 +234,7 @@ wi_pci_attach(struct device *parent, struct device *self, void *aux) bus_space_handle_t memh, ioh, plxh, tmdh; psc->psc_pc = pc; + psc->psc_pcitag = pa->pa_tag; wpp = wi_pci_lookup(pa); #ifdef DIAGNOSTIC @@ -383,19 +382,8 @@ wi_pci_attach(struct device *parent, struct device *self, void *aux) if (!wpp->wpp_chip) sc->sc_reset = wi_pci_reset; - /* Add a suspend hook to restore PCI config state */ - psc->sc_powerhook = powerhook_establish(self->dv_xname, - wi_pci_powerhook, psc); - if (psc->sc_powerhook == NULL) - printf("%s: WARNING: unable to establish pci power hook\n", - self->dv_xname); -} - -static void -wi_pci_powerhook(int why, void *arg) -{ - struct wi_pci_softc *psc = arg; - struct wi_softc *sc = &psc->psc_wi; - - wi_power(sc, why); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->sc_if); } diff --git a/sys/dev/pci/if_wm.c b/sys/dev/pci/if_wm.c index 40722b613f2..9819385cf28 100644 --- a/sys/dev/pci/if_wm.c +++ b/sys/dev/pci/if_wm.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.148 2007/10/30 07:49:40 simonb Exp $ */ +/* $NetBSD: if_wm.c,v 1.149 2007/12/09 20:28:10 jmcneill Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.148 2007/10/30 07:49:40 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.149 2007/12/09 20:28:10 jmcneill Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -268,11 +268,8 @@ struct wm_softc { bus_space_handle_t sc_flashh; /* flash registers space handle */ bus_dma_tag_t sc_dmat; /* bus DMA tag */ struct ethercom sc_ethercom; /* ethernet common data */ - void *sc_sdhook; /* shutdown hook */ - void *sc_powerhook; /* power hook */ pci_chipset_tag_t sc_pc; pcitag_t sc_pcitag; - struct pci_conf_state sc_pciconf; wm_chip_type sc_type; /* chip type */ int sc_flags; /* flags; see below */ @@ -523,9 +520,6 @@ static int wm_ioctl(struct ifnet *, u_long, void *); static int wm_init(struct ifnet *); static void wm_stop(struct ifnet *, int); -static void wm_shutdown(void *); -static void wm_powerhook(int, void *); - static void wm_reset(struct wm_softc *); static void wm_rxdrain(struct wm_softc *); static int wm_add_rxbuf(struct wm_softc *, int); @@ -1617,19 +1611,11 @@ wm_attach(struct device *parent, struct device *self, void *aux) NULL, sc->sc_dev.dv_xname, "rx_macctl"); #endif /* WM_EVENT_COUNTERS */ - /* - * Make sure the interface is shutdown during reboot. - */ - sc->sc_sdhook = shutdownhook_establish(wm_shutdown, sc); - if (sc->sc_sdhook == NULL) - aprint_error("%s: WARNING: unable to establish shutdown hook\n", - sc->sc_dev.dv_xname); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, ifp); - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - wm_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: can't establish powerhook\n", - sc->sc_dev.dv_xname); return; /* @@ -1661,48 +1647,6 @@ wm_attach(struct device *parent, struct device *self, void *aux) } /* - * wm_shutdown: - * - * Make sure the interface is stopped at reboot time. - */ -static void -wm_shutdown(void *arg) -{ - struct wm_softc *sc = arg; - - wm_stop(&sc->sc_ethercom.ec_if, 1); -} - -static void -wm_powerhook(int why, void *arg) -{ - struct wm_softc *sc = arg; - struct ifnet *ifp = &sc->sc_ethercom.ec_if; - pci_chipset_tag_t pc = sc->sc_pc; - pcitag_t tag = sc->sc_pcitag; - - switch (why) { - case PWR_SOFTSUSPEND: - wm_shutdown(sc); - break; - case PWR_SOFTRESUME: - ifp->if_flags &= ~IFF_RUNNING; - wm_init(ifp); - if (ifp->if_flags & IFF_RUNNING) - wm_start(ifp); - break; - case PWR_SUSPEND: - pci_conf_capture(pc, tag, &sc->sc_pciconf); - break; - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->sc_pciconf); - break; - } - - return; -} - -/* * wm_tx_offload: * * Set up TCP/IP checksumming parameters for the diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index 7b945dcdd09..f92a32791b8 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wpi.c,v 1.32 2007/12/01 18:02:42 jmcneill Exp $ */ +/* $NetBSD: if_wpi.c,v 1.33 2007/12/09 20:28:10 jmcneill Exp $ */ /*- * Copyright (c) 2006, 2007 @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.32 2007/12/01 18:02:42 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.33 2007/12/09 20:28:10 jmcneill Exp $"); /* * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters. @@ -94,7 +94,6 @@ static const struct ieee80211_rateset wpi_rateset_11g = static int wpi_match(device_t, struct cfdata *, void *); static void wpi_attach(device_t, device_t, void *); static int wpi_detach(device_t , int); -static void wpi_power(int, void *); static int wpi_dma_contig_alloc(bus_dma_tag_t, struct wpi_dma_info *, void **, bus_size_t, bus_size_t, int); static void wpi_dma_contig_free(struct wpi_dma_info *); @@ -164,6 +163,7 @@ static int wpi_reset(struct wpi_softc *); static void wpi_hw_config(struct wpi_softc *); static int wpi_init(struct ifnet *); static void wpi_stop(struct ifnet *, int); +static bool wpi_resume(device_t); CFATTACH_DECL_NEW(wpi, sizeof (struct wpi_softc), wpi_match, wpi_attach, wpi_detach, NULL); @@ -212,10 +212,7 @@ wpi_attach(device_t parent __unused, device_t self, void *aux) revision = PCI_REVISION(pa->pa_class); aprint_normal(": %s (rev. 0x%02x)\n", devinfo, revision); - /* clear device specific PCI configuration register 0x41 */ - data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); - data &= ~0x0000ff00; - pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); + pci_disable_retry(pa->pa_pc, pa->pa_tag); /* enable bus-mastering */ data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, PCI_COMMAND_STATUS_REG); @@ -343,8 +340,10 @@ wpi_attach(device_t parent __unused, device_t self, void *aux) sc->amrr.amrr_min_success_threshold = 1; sc->amrr.amrr_max_success_threshold = 15; - /* set powerhook */ - sc->powerhook = powerhook_establish(device_xname(self), wpi_power, sc); + if (!pmf_device_register(self, NULL, wpi_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, ifp); #if NBPFILTER > 0 bpfattach2(ifp, DLT_IEEE802_11_RADIO, @@ -406,32 +405,6 @@ wpi_detach(device_t self, int flags __unused) return 0; } -static void -wpi_power(int why, void *arg) -{ - struct wpi_softc *sc = arg; - struct ifnet *ifp; - pcireg_t data; - int s; - - if (why != PWR_RESUME) - return; - - /* clear device specific PCI configuration register 0x41 */ - data = pci_conf_read(sc->sc_pct, sc->sc_pcitag, 0x40); - data &= ~0x0000ff00; - pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); - - s = splnet(); - ifp = sc->sc_ic.ic_ifp; - if (ifp->if_flags & IFF_UP) { - ifp->if_init(ifp); - if (ifp->if_flags & IFF_RUNNING) - ifp->if_start(ifp); - } - splx(s); -} - static int wpi_dma_contig_alloc(bus_dma_tag_t tag, struct wpi_dma_info *dma, void **kvap, bus_size_t size, bus_size_t alignment, int flags) @@ -3153,3 +3126,14 @@ wpi_stop(struct ifnet *ifp, int disable) tmp = WPI_READ(sc, WPI_RESET); WPI_WRITE(sc, WPI_RESET, tmp | WPI_SW_RESET); } + +static bool +wpi_resume(device_t dv) +{ + struct wpi_softc *sc = device_private(dv); + + pci_disable_retry(sc->sc_pct, sc->sc_pcitag); + (void)wpi_reset(sc); + + return true; +} diff --git a/sys/dev/pci/if_wpivar.h b/sys/dev/pci/if_wpivar.h index 84657505c9f..b8e34fdff79 100644 --- a/sys/dev/pci/if_wpivar.h +++ b/sys/dev/pci/if_wpivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_wpivar.h,v 1.9 2007/11/16 00:13:32 degroote Exp $ */ +/* $NetBSD: if_wpivar.h,v 1.10 2007/12/09 20:28:11 jmcneill Exp $ */ /*- * Copyright (c) 2006 @@ -166,7 +166,6 @@ struct wpi_softc { int8_t maxpwr[IEEE80211_CHAN_MAX]; int sc_tx_timer; - void *powerhook; #if NBPFILTER > 0 void * sc_drvbpf; diff --git a/sys/dev/pci/neo.c b/sys/dev/pci/neo.c index 7b02a93e142..c4b2a84ecc8 100644 --- a/sys/dev/pci/neo.c +++ b/sys/dev/pci/neo.c @@ -1,4 +1,4 @@ -/* $NetBSD: neo.c,v 1.36 2007/10/19 12:00:52 ad Exp $ */ +/* $NetBSD: neo.c,v 1.37 2007/12/09 20:28:11 jmcneill Exp $ */ /* * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: neo.c,v 1.36 2007/10/19 12:00:52 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: neo.c,v 1.37 2007/12/09 20:28:11 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -162,8 +162,6 @@ struct neo_softc { struct ac97_codec_if *codec_if; struct ac97_host_if host_if; - - void *powerhook; }; /* -------------------------------------------------------------------- */ @@ -207,7 +205,6 @@ static void neo_free(void *, void *, struct malloc_type *); static size_t neo_round_buffersize(void *, int, size_t); static paddr_t neo_mappage(void *, void *, off_t, int); static int neo_get_props(void *); -static void neo_power(int, void *); CFATTACH_DECL(neo, sizeof(struct neo_softc), neo_match, neo_attach, NULL, NULL); @@ -552,16 +549,15 @@ neo_match(struct device *parent, struct cfdata *match, return 0; } -static void -neo_power(int why, void *addr) +static bool +neo_resume(device_t dv) { - struct neo_softc *sc; + struct neo_softc *sc = device_private(dv); - sc = (struct neo_softc *)addr; - if (why == PWR_RESUME) { - nm_init(sc); - sc->codec_if->vtbl->restore_ports(sc->codec_if); - } + nm_init(sc); + sc->codec_if->vtbl->restore_ports(sc->codec_if); + + return true; } static void @@ -634,7 +630,8 @@ neo_attach(struct device *parent, struct device *self, void *aux) if (ac97_attach(&sc->host_if, self) != 0) return; - sc->powerhook = powerhook_establish(sc->dev.dv_xname, neo_power, sc); + if (!pmf_device_register(self, NULL, neo_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); audio_attach_mi(&neo_hw_if, sc, &sc->dev); } diff --git a/sys/dev/pci/ohci_pci.c b/sys/dev/pci/ohci_pci.c index e96804ae48d..2468a6daa55 100644 --- a/sys/dev/pci/ohci_pci.c +++ b/sys/dev/pci/ohci_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ohci_pci.c,v 1.32 2007/10/19 12:00:53 ad Exp $ */ +/* $NetBSD: ohci_pci.c,v 1.33 2007/12/09 20:28:11 jmcneill Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ohci_pci.c,v 1.32 2007/10/19 12:00:53 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci_pci.c,v 1.33 2007/12/09 20:28:11 jmcneill Exp $"); #include "ehci.h" @@ -68,6 +68,7 @@ struct ohci_pci_softc { struct usb_pci sc_pci; #endif pci_chipset_tag_t sc_pc; + pcitag_t sc_tag; void *sc_ih; /* interrupt vectoring */ }; @@ -115,6 +116,7 @@ ohci_pci_attach(struct device *parent, struct device *self, void *aux) OHCI_ALL_INTRS); sc->sc_pc = pc; + sc->sc_tag = tag; sc->sc.sc_bus.dmatag = pa->pa_dmat; /* Enable the device. */ @@ -157,6 +159,9 @@ ohci_pci_attach(struct device *parent, struct device *self, void *aux) usb_pci_add(&sc->sc_pci, pa, &sc->sc.sc_bus); #endif + if (!pmf_device_register(self, ohci_suspend, ohci_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + /* Attach usb device. */ sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, usbctlprint); diff --git a/sys/dev/pci/pccbb.c b/sys/dev/pci/pccbb.c index d9c08f22f7d..e9e34d43dc2 100644 --- a/sys/dev/pci/pccbb.c +++ b/sys/dev/pci/pccbb.c @@ -1,4 +1,4 @@ -/* $NetBSD: pccbb.c,v 1.155 2007/12/01 05:41:53 jmcneill Exp $ */ +/* $NetBSD: pccbb.c,v 1.156 2007/12/09 20:28:11 jmcneill Exp $ */ /* * Copyright (c) 1998, 1999 and 2000 @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pccbb.c,v 1.155 2007/12/01 05:41:53 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pccbb.c,v 1.156 2007/12/09 20:28:11 jmcneill Exp $"); /* #define CBB_DEBUG @@ -185,7 +185,6 @@ static void pccbb_pcmcia_delay(struct pcic_handle *, int, const char *); static void pccbb_pcmcia_do_io_map(struct pcic_handle *, int); static void pccbb_pcmcia_do_mem_map(struct pcic_handle *, int); -static void pccbb_powerhook(int, void *); /* bus-space allocation and deallocation functions */ #if rbus @@ -217,6 +216,9 @@ void pccbb_winlist_show(struct pccbb_win_chain *); /* for config_defer */ static void pccbb_pci_callback(struct device *); +static bool pccbb_suspend(device_t); +static bool pccbb_resume(device_t); + #if defined SHOW_REGS static void cb_show_regs(pci_chipset_tag_t pc, pcitag_t tag, bus_space_tag_t memt, bus_space_handle_t memh); @@ -378,36 +380,6 @@ cb_chipset(u_int32_t pci_id, int *flagp) return (yc->yc_chiptype); } -static void -pccbb_shutdown(void *arg) -{ - struct pccbb_softc *sc = arg; - pcireg_t command; - - DPRINTF(("%s: shutdown\n", sc->sc_dev.dv_xname)); - - /* - * turn off power - * - * XXX - do not turn off power if chipset is TI 113X because - * only TI 1130 with PowerMac 2400 hangs in pccbb_power(). - */ - if (sc->sc_chipset != CB_TI113X) { - pccbb_power((cardbus_chipset_tag_t)sc, - CARDBUS_VCC_0V | CARDBUS_VPP_0V); - } - - bus_space_write_4(sc->sc_base_memt, sc->sc_base_memh, CB_SOCKET_MASK, - 0); - - command = pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_COMMAND_STATUS_REG); - - command &= ~(PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | - PCI_COMMAND_MASTER_ENABLE); - pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_COMMAND_STATUS_REG, command); - -} - void pccbbattach(struct device *parent, struct device *self, void *aux) { @@ -418,7 +390,6 @@ pccbbattach(struct device *parent, struct device *self, void *aux) bus_addr_t sockbase; char devinfo[256]; int flags; - int pwrmgt_offs; #ifdef __HAVE_PCCBB_ATTACH_HOOK pccbb_attach_hook(parent, self, pa); @@ -452,23 +423,6 @@ pccbbattach(struct device *parent, struct device *self, void *aux) sc->sc_flags &= ~CBB_MEMHMAPPED; - /* power management: set D0 state */ - sc->sc_pwrmgt_offs = 0; - if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, - &pwrmgt_offs, 0)) { - reg = pci_conf_read(pc, pa->pa_tag, pwrmgt_offs + PCI_PMCSR); - if ((reg & PCI_PMCSR_STATE_MASK) != PCI_PMCSR_STATE_D0 || - reg & 0x100 /* PCI_PMCSR_PME_EN */) { - reg &= ~PCI_PMCSR_STATE_MASK; - reg |= PCI_PMCSR_STATE_D0; - reg &= ~(0x100 /* PCI_PMCSR_PME_EN */); - pci_conf_write(pc, pa->pa_tag, - pwrmgt_offs + PCI_PMCSR, reg); - } - - sc->sc_pwrmgt_offs = pwrmgt_offs; - } - /* * MAP socket registers and ExCA registers on memory-space * When no valid address is set on socket base registers (on pci @@ -526,15 +480,11 @@ pccbbattach(struct device *parent, struct device *self, void *aux) sc->sc_dmat = pa->pa_dmat; sc->sc_tag = pa->pa_tag; sc->sc_function = pa->pa_function; - sc->sc_sockbase = sock_base; - sc->sc_busnum = busreg; memcpy(&sc->sc_pa, pa, sizeof(*pa)); sc->sc_pcmcia_flags = flags; /* set PCMCIA facility */ - shutdownhook_establish(pccbb_shutdown, sc); - /* Disable legacy register mapping. */ switch (sc->sc_chipset) { case CB_RX5C46X: /* fallthrough */ @@ -559,6 +509,9 @@ pccbbattach(struct device *parent, struct device *self, void *aux) break; } + if (!pmf_device_register(self, pccbb_suspend, pccbb_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + config_defer(self, pccbb_pci_callback); } @@ -618,7 +571,6 @@ pccbb_pci_callback(struct device *self) sc->sc_dev.dv_xname, (unsigned long)sock_base, (unsigned long)pci_conf_read(pc, sc->sc_tag, PCI_SOCKBASE))); - sc->sc_sockbase = sockbase; #endif sc->sc_flags |= CBB_MEMHMAPPED; } @@ -655,7 +607,6 @@ pccbb_pci_callback(struct device *self) } aprint_normal("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr); - powerhook_establish(sc->sc_dev.dv_xname, pccbb_powerhook, sc); { u_int32_t sockstat; @@ -3274,97 +3225,64 @@ pccbb_winset(bus_addr_t align, struct pccbb_softc *sc, bus_space_tag_t bst) #endif /* rbus */ -static void -pccbb_powerhook(int why, void *arg) +static bool +pccbb_suspend(device_t dv) { - struct pccbb_softc *sc = arg; - pcireg_t reg; + struct pccbb_softc *sc = device_private(dv); bus_space_tag_t base_memt = sc->sc_base_memt; /* socket regs memory */ bus_space_handle_t base_memh = sc->sc_base_memh; + pcireg_t reg; - DPRINTF(("%s: power: why %d\n", sc->sc_dev.dv_xname, why)); - - if (why == PWR_SUSPEND || why == PWR_STANDBY) { - DPRINTF(("%s: power: why %d stopping intr\n", - sc->sc_dev.dv_xname, why)); - if (sc->sc_pil_intr_enable) { - (void)pccbbintr_function(sc); - } - sc->sc_pil_intr_enable = 0; - - pci_conf_capture(sc->sc_pc, sc->sc_tag, &sc->sc_pciconf); - - if (sc->sc_chipset == CB_RX5C47X) - sc->sc_ricoh_misc_ctrl = pci_conf_read(sc->sc_pc, - sc->sc_tag, - RICOH_PCI_MISC_CTRL); + if (sc->sc_pil_intr_enable) + (void)pccbbintr_function(sc); + sc->sc_pil_intr_enable = 0; - /* ToDo: deactivate or suspend child devices */ - } + reg = bus_space_read_4(base_memt, base_memh, CB_SOCKET_MASK); + /* Disable interrupts. */ + reg &= ~(CB_SOCKET_MASK_CSTS | CB_SOCKET_MASK_CD | CB_SOCKET_MASK_POWER); + bus_space_write_4(base_memt, base_memh, CB_SOCKET_MASK, reg); + /* XXX joerg Disable power to the socket? */ - if (why == PWR_RESUME) { - if (sc->sc_pwrmgt_offs != 0) { - reg = pci_conf_read(sc->sc_pc, sc->sc_tag, - sc->sc_pwrmgt_offs + PCI_PMCSR); - if ((reg & PCI_PMCSR_STATE_MASK) != PCI_PMCSR_STATE_D0 || - reg & PCI_PMCSR_PME_EN) { - /* powrstate != D0 */ + if (sc->sc_chipset == CB_RX5C47X) + sc->sc_ricoh_misc_ctrl = pci_conf_read(sc->sc_pc, + sc->sc_tag, RICOH_PCI_MISC_CTRL); - printf("%s going back to D0 mode\n", - sc->sc_dev.dv_xname); - reg &= ~PCI_PMCSR_STATE_MASK; - reg |= PCI_PMCSR_STATE_D0; - reg &= ~PCI_PMCSR_PME_EN; - pci_conf_write(sc->sc_pc, sc->sc_tag, - sc->sc_pwrmgt_offs + PCI_PMCSR, reg); - - pci_conf_write(sc->sc_pc, sc->sc_tag, - PCI_SOCKBASE, sc->sc_sockbase); - pci_conf_write(sc->sc_pc, sc->sc_tag, - PCI_BUSNUM, sc->sc_busnum); - pccbb_chipinit(sc); - /* setup memory and io space window for CB */ - pccbb_winset(0x1000, sc, sc->sc_memt); - pccbb_winset(0x04, sc, sc->sc_iot); - goto norestore; - } - } + return true; +} -norestore: - pci_conf_restore(sc->sc_pc, sc->sc_tag, &sc->sc_pciconf); - if (sc->sc_chipset == CB_RX5C47X) { - pci_conf_write(sc->sc_pc, sc->sc_tag, - RICOH_PCI_MISC_CTRL, sc->sc_ricoh_misc_ctrl); - } +static bool +pccbb_resume(device_t dv) +{ + struct pccbb_softc *sc = device_private(dv); + bus_space_tag_t base_memt = sc->sc_base_memt; /* socket regs memory */ + bus_space_handle_t base_memh = sc->sc_base_memh; + pcireg_t reg; - if (pci_conf_read (sc->sc_pc, sc->sc_tag, PCI_SOCKBASE) == 0) - /* BIOS did not recover this register */ - pci_conf_write (sc->sc_pc, sc->sc_tag, - PCI_SOCKBASE, sc->sc_sockbase); - if (pci_conf_read (sc->sc_pc, sc->sc_tag, PCI_BUSNUM) == 0) - /* BIOS did not recover this register */ - pci_conf_write (sc->sc_pc, sc->sc_tag, - PCI_BUSNUM, sc->sc_busnum); - /* CSC Interrupt: Card detect interrupt on */ - reg = bus_space_read_4(base_memt, base_memh, CB_SOCKET_MASK); - /* Card detect intr is turned on. */ - reg |= CB_SOCKET_MASK_CD | CB_SOCKET_MASK_POWER; - bus_space_write_4(base_memt, base_memh, CB_SOCKET_MASK, reg); - /* reset interrupt */ - reg = bus_space_read_4(base_memt, base_memh, CB_SOCKET_EVENT); - bus_space_write_4(base_memt, base_memh, CB_SOCKET_EVENT, reg); + pccbb_chipinit(sc); + /* setup memory and io space window for CB */ + pccbb_winset(0x1000, sc, sc->sc_memt); + pccbb_winset(0x04, sc, sc->sc_iot); + if (sc->sc_chipset == CB_RX5C47X) + pci_conf_write(sc->sc_pc, sc->sc_tag, + RICOH_PCI_MISC_CTRL, sc->sc_ricoh_misc_ctrl); + + /* CSC Interrupt: Card detect interrupt on */ + reg = bus_space_read_4(base_memt, base_memh, CB_SOCKET_MASK); + /* Card detect intr is turned on. */ + reg |= CB_SOCKET_MASK_CD | CB_SOCKET_MASK_POWER; + bus_space_write_4(base_memt, base_memh, CB_SOCKET_MASK, reg); + /* reset interrupt */ + reg = bus_space_read_4(base_memt, base_memh, CB_SOCKET_EVENT); + bus_space_write_4(base_memt, base_memh, CB_SOCKET_EVENT, reg); - /* - * check for card insertion or removal during suspend period. - * XXX: the code can't cope with card swap (remove then - * insert). how can we detect such situation? - */ - (void)pccbbintr(sc); + /* + * check for card insertion or removal during suspend period. + * XXX: the code can't cope with card swap (remove then + * insert). how can we detect such situation? + */ + (void)pccbbintr(sc); - sc->sc_pil_intr_enable = 1; - DPRINTF(("%s: power: RESUME enabling intr\n", - sc->sc_dev.dv_xname)); + sc->sc_pil_intr_enable = 1; - /* ToDo: activate or wakeup child devices */ - } + return true; } diff --git a/sys/dev/pci/pccbbvar.h b/sys/dev/pci/pccbbvar.h index 5dcfe285a89..2a26c932293 100644 --- a/sys/dev/pci/pccbbvar.h +++ b/sys/dev/pci/pccbbvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: pccbbvar.h,v 1.29 2007/08/10 22:57:54 dyoung Exp $ */ +/* $NetBSD: pccbbvar.h,v 1.30 2007/12/09 20:28:11 jmcneill Exp $ */ /* * Copyright (c) 1999 HAYAKAWA Koichi. All rights reserved. * @@ -132,9 +132,6 @@ struct pccbb_softc { bus_addr_t sc_io_start; /* CardBus/PCMCIA io start */ bus_addr_t sc_io_end; /* CardBus/PCMCIA io end */ - pcireg_t sc_sockbase; /* Socket base register */ - pcireg_t sc_busnum; /* bus number */ - /* CardBus stuff */ struct cardslot_softc *sc_csc; @@ -156,8 +153,6 @@ struct pccbb_softc { LIST_HEAD(, pccbb_intrhand_list) sc_pil; int sc_pil_intr_enable; /* can i call intr handler for child device? */ - int sc_pwrmgt_offs; /* Offset for power management capability */ - struct pci_conf_state sc_pciconf; pcireg_t sc_ricoh_misc_ctrl; }; diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 7b06067b205..87211c3708d 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci.c,v 1.106 2007/12/01 16:46:18 ad Exp $ */ +/* $NetBSD: pci.c,v 1.107 2007/12/09 20:28:11 jmcneill Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 @@ -36,11 +36,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.106 2007/12/01 16:46:18 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.107 2007/12/09 20:28:11 jmcneill Exp $"); #include "opt_pci.h" #include <sys/param.h> +#include <sys/malloc.h> #include <sys/systm.h> #include <sys/device.h> @@ -50,8 +51,12 @@ __KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.106 2007/12/01 16:46:18 ad Exp $"); #include <uvm/uvm_extern.h> +#include <net/if.h> + #include "locators.h" +static bool pci_child_register(device_t); + #ifdef PCI_CONFIG_DUMP int pci_config_dump = 1; #else @@ -126,86 +131,6 @@ pcimatch(struct device *parent, struct cfdata *cf, void *aux) } static void -pci_power_devices(struct pci_softc *sc, int why) -{ - pci_chipset_tag_t pc; - int device, function, nfunctions; - pcitag_t tag; - pcireg_t bhlcr, id; - pcireg_t state; -#ifdef __PCI_BUS_DEVORDER - char devs[32]; - int i; -#endif - - pc = sc->sc_pc; - switch (why) { - case PWR_STANDBY: - state = PCI_PMCSR_STATE_D1; - break; - case PWR_SUSPEND: - state = PCI_PMCSR_STATE_D3; - break; - case PWR_RESUME: - state = PCI_PMCSR_STATE_D0; - break; - default: - /* we should never be called here */ -#ifdef DIAGNOSTIC - panic("pci_power_devices called with invalid reason %d\n", - why); - /* NOTREACHED */ -#endif - return; - } - -#ifdef __PCI_BUS_DEVORDER - pci_bus_devorder(sc->sc_pc, sc->sc_bus, devs); - for (i = 0; (device = devs[i]) < 32 && device >= 0; i++) -#else - for (device = 0; device < sc->sc_maxndevs; device++) -#endif - { - tag = pci_make_tag(pc, sc->sc_bus, device, 0); - bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG); - if (PCI_HDRTYPE_TYPE(bhlcr) > 2) - continue; - id = pci_conf_read(pc, tag, PCI_ID_REG); - if (PCI_VENDOR(id) == PCI_VENDOR_INVALID || - PCI_VENDOR(id) == 0x0000) - continue; - nfunctions = PCI_HDRTYPE_MULTIFN(bhlcr) ? 8 : 1; - - for (function = 0; function < nfunctions; function++) { - tag = pci_make_tag(pc, sc->sc_bus, device, function); - if (sc->PCI_SC_DEVICESC(device, function) != NULL) - continue; - (void)pci_set_powerstate(pc, tag, state); - } - } - - return; -} - -static void -pci_powerhook(int why, void *aux) -{ - struct pci_softc *sc; - - sc = (struct pci_softc *)aux; - - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - case PWR_RESUME: - pci_power_devices(sc, why); - break; - } - - return; -} - -static void pciattach(struct device *parent, struct device *self, void *aux) { struct pcibus_attach_args *pba = aux; @@ -229,7 +154,7 @@ pciattach(struct device *parent, struct device *self, void *aux) if (io_enabled == 0 && mem_enabled == 0) { aprint_error("%s: no spaces enabled!\n", self->dv_xname); - return; + goto fail; } #define PRINT(str) \ @@ -272,13 +197,20 @@ do { \ sc->sc_intrtag = pba->pba_intrtag; sc->sc_flags = pba->pba_flags; - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - pci_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: can't establish powerhook\n", - sc->sc_dev.dv_xname); + device_pmf_driver_set_child_register(&sc->sc_dev, pci_child_register); pcirescan(&sc->sc_dev, "pci", wildcard); + +fail: + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); +} + +static int +pcidetach(struct device *self, int flags) +{ + pmf_device_deregister(self); + return 0; } int @@ -447,6 +379,9 @@ pcidevdetached(struct device *sc, struct device *dev) psc->PCI_SC_DEVICESC(d, f) = 0; } +CFATTACH_DECL2(pci, sizeof(struct pci_softc), + pcimatch, pciattach, pcidetach, NULL, pcirescan, pcidevdetached); + int pci_get_capability(pci_chipset_tag_t pc, pcitag_t tag, int capid, int *offset, pcireg_t *value) @@ -694,9 +629,13 @@ pci_conf_restore(pci_chipset_tag_t pc, pcitag_t tag, struct pci_conf_state *pcs) { int off; + pcireg_t val; - for (off = 0; off < 16; off++) - pci_conf_write(pc, tag, (off * 4), pcs->reg[off]); + for (off = 15; off >= 0; off--) { + val = pci_conf_read(pc, tag, (off * 4)); + if (val != pcs->reg[off]) + pci_conf_write(pc, tag, (off * 4), pcs->reg[off]); + } return; } @@ -704,16 +643,12 @@ pci_conf_restore(pci_chipset_tag_t pc, pcitag_t tag, /* * Power Management Capability (Rev 2.2) */ -int -pci_get_powerstate(pci_chipset_tag_t pc, pcitag_t tag , pcireg_t *state) +static int +pci_get_powerstate_int(pci_chipset_tag_t pc, pcitag_t tag , pcireg_t *state, + int offset) { - int offset; - pcireg_t value, cap, now; + pcireg_t value, now; - if (!pci_get_capability(pc, tag, PCI_CAP_PWRMGMT, &offset, &value)) - return EOPNOTSUPP; - - cap = value >> PCI_PMCR_SHIFT; value = pci_conf_read(pc, tag, offset + PCI_PMCSR); now = value & PCI_PMCSR_STATE_MASK; switch (now) { @@ -729,15 +664,24 @@ pci_get_powerstate(pci_chipset_tag_t pc, pcitag_t tag , pcireg_t *state) } int -pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, pcireg_t state) +pci_get_powerstate(pci_chipset_tag_t pc, pcitag_t tag , pcireg_t *state) { int offset; - pcireg_t value, cap, now; + pcireg_t value; if (!pci_get_capability(pc, tag, PCI_CAP_PWRMGMT, &offset, &value)) return EOPNOTSUPP; - cap = value >> PCI_PMCR_SHIFT; + return pci_get_powerstate_int(pc, tag, state, offset); +} + +static int +pci_set_powerstate_int(pci_chipset_tag_t pc, pcitag_t tag, pcireg_t state, + int offset, pcireg_t cap_reg) +{ + pcireg_t value, cap, now; + + cap = cap_reg >> PCI_PMCR_SHIFT; value = pci_conf_read(pc, tag, offset + PCI_PMCSR); now = value & PCI_PMCSR_STATE_MASK; value &= ~PCI_PMCSR_STATE_MASK; @@ -749,22 +693,28 @@ pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, pcireg_t state) value |= PCI_PMCSR_STATE_D0; break; case PCI_PMCSR_STATE_D1: - if (now == PCI_PMCSR_STATE_D2 || now == PCI_PMCSR_STATE_D3) + if (now == PCI_PMCSR_STATE_D2 || now == PCI_PMCSR_STATE_D3) { + printf("invalid transition from %d to D1\n", (int)now); return EINVAL; - if (!(cap & PCI_PMCR_D1SUPP)) + } + if (!(cap & PCI_PMCR_D1SUPP)) { + printf("D1 not supported\n"); return EOPNOTSUPP; + } value |= PCI_PMCSR_STATE_D1; break; case PCI_PMCSR_STATE_D2: - if (now == PCI_PMCSR_STATE_D3) + if (now == PCI_PMCSR_STATE_D3) { + printf("invalid transition from %d to D2\n", (int)now); return EINVAL; - if (!(cap & PCI_PMCR_D2SUPP)) + } + if (!(cap & PCI_PMCR_D2SUPP)) { + printf("D2 not supported\n"); return EOPNOTSUPP; + } value |= PCI_PMCSR_STATE_D2; break; case PCI_PMCSR_STATE_D3: - if (now == PCI_PMCSR_STATE_D3) - return 0; value |= PCI_PMCSR_STATE_D3; break; default: @@ -776,6 +726,20 @@ pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, pcireg_t state) } int +pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, pcireg_t state) +{ + int offset; + pcireg_t value; + + if (!pci_get_capability(pc, tag, PCI_CAP_PWRMGMT, &offset, &value)) { + printf("pci_set_powerstate not supported\n"); + return EOPNOTSUPP; + } + + return pci_set_powerstate_int(pc, tag, state, offset, value); +} + +int pci_activate(pci_chipset_tag_t pc, pcitag_t tag, void *sc, int (*wakefun)(pci_chipset_tag_t, pcitag_t, void *, pcireg_t)) { @@ -822,9 +786,6 @@ pci_activate_null(pci_chipset_tag_t pc, pcitag_t tag, return 0; } -CFATTACH_DECL2(pci, sizeof(struct pci_softc), - pcimatch, pciattach, NULL, NULL, pcirescan, pcidevdetached); - void pci_disable_retry(pci_chipset_tag_t pc, pcitag_t tag) { @@ -838,3 +799,90 @@ pci_disable_retry(pci_chipset_tag_t pc, pcitag_t tag) retry &= ~PCI_RETRY_TIMEOUT_REG_MASK; pci_conf_write(pc, tag, PCI_RETRY_TIMEOUT_REG, retry); } + +struct pci_child_power { + struct pci_conf_state p_pciconf; + pci_chipset_tag_t p_pc; + pcitag_t p_tag; + bool p_has_pm; + int p_pm_offset; + pcireg_t p_pm_cap; + pcireg_t p_class; +}; + +static bool +pci_child_suspend(device_t dv) +{ + struct pci_child_power *priv = device_pmf_bus_private(dv); + + pci_conf_capture(priv->p_pc, priv->p_tag, &priv->p_pciconf); + + if (priv->p_has_pm && + PCI_CLASS(priv->p_class) != PCI_CLASS_DISPLAY && + pci_set_powerstate_int(priv->p_pc, priv->p_tag, + PCI_PMCSR_STATE_D3, priv->p_pm_offset, priv->p_pm_cap)) { + aprint_error_dev(dv, "unsupported state, continuing.\n"); + return false; + } + return true; +} + +static bool +pci_child_resume(device_t dv) +{ + struct pci_child_power *priv = device_pmf_bus_private(dv); + + if (priv->p_has_pm && + pci_set_powerstate_int(priv->p_pc, priv->p_tag, + PCI_PMCSR_STATE_D0, priv->p_pm_offset, priv->p_pm_cap)) { + aprint_error_dev(dv, "unsupported state, continuing.\n"); + return false; + } + + pci_conf_restore(priv->p_pc, priv->p_tag, &priv->p_pciconf); + + return true; +} + +static void +pci_child_deregister(device_t dv) +{ + struct pci_child_power *priv = device_pmf_bus_private(dv); + + free(priv, M_DEVBUF); +} + +static bool +pci_child_register(device_t child) +{ + device_t self = device_parent(child); + struct pci_softc *sc = device_private(self); + struct pci_child_power *priv; + int device, function, off; + pcireg_t reg; + + priv = malloc(sizeof(*priv), M_DEVBUF, M_WAITOK); + + device = device_locator(child, PCICF_DEV); + function = device_locator(child, PCICF_FUNCTION); + + priv->p_pc = sc->sc_pc; + priv->p_tag = pci_make_tag(priv->p_pc, sc->sc_bus, device, + function); + priv->p_class = pci_conf_read(priv->p_pc, priv->p_tag, PCI_CLASS_REG); + + if (pci_get_capability(priv->p_pc, priv->p_tag, + PCI_CAP_PWRMGMT, &off, ®)) { + priv->p_has_pm = true; + priv->p_pm_offset = off; + priv->p_pm_cap = reg; + } else { + priv->p_has_pm = false; + priv->p_pm_offset = -1; + } + + device_pmf_bus_register(child, priv, pci_child_suspend, + pci_child_resume, pci_child_deregister); + + return true; +} diff --git a/sys/dev/pci/pcidevs.h b/sys/dev/pci/pcidevs.h index 723ada15ef0..a32e0d507e5 100644 --- a/sys/dev/pci/pcidevs.h +++ b/sys/dev/pci/pcidevs.h @@ -1,10 +1,10 @@ -/* $NetBSD: pcidevs.h,v 1.920 2007/11/26 09:36:29 bjs Exp $ */ +/* $NetBSD: pcidevs.h,v 1.921 2007/12/09 20:28:12 jmcneill Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: pcidevs,v 1.919 2007/11/24 01:44:55 markd Exp + * NetBSD: pcidevs,v 1.885.6.10 2007/10/31 23:14:07 joerg Exp */ /* diff --git a/sys/dev/pci/pcidevs_data.h b/sys/dev/pci/pcidevs_data.h index 1268e2692f0..3e4a873da5a 100644 --- a/sys/dev/pci/pcidevs_data.h +++ b/sys/dev/pci/pcidevs_data.h @@ -1,10 +1,10 @@ -/* $NetBSD: pcidevs_data.h,v 1.919 2007/11/26 09:36:29 bjs Exp $ */ +/* $NetBSD: pcidevs_data.h,v 1.920 2007/12/09 20:28:12 jmcneill Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: pcidevs,v 1.919 2007/11/24 01:44:55 markd Exp + * NetBSD: pcidevs,v 1.885.6.10 2007/10/31 23:14:07 joerg Exp */ /* diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 27b39cfd334..69900d1601f 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: pcivar.h,v 1.76 2007/11/12 19:54:36 joerg Exp $ */ +/* $NetBSD: pcivar.h,v 1.77 2007/12/09 20:28:12 jmcneill Exp $ */ /* * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. @@ -42,6 +42,7 @@ */ #include <sys/device.h> +#include <sys/pmf.h> #include <sys/bus.h> #include <dev/pci/pcireg.h> @@ -169,7 +170,6 @@ struct pci_softc { /* accounting of child devices */ struct device *sc_devices[32*8]; #define PCI_SC_DEVICESC(d, f) sc_devices[(d) * 8 + (f)] - void *sc_powerhook; }; struct pci_conf_state { diff --git a/sys/dev/pci/piixide.c b/sys/dev/pci/piixide.c index edb236ad8fe..3c449b8185c 100644 --- a/sys/dev/pci/piixide.c +++ b/sys/dev/pci/piixide.c @@ -1,4 +1,4 @@ -/* $NetBSD: piixide.c,v 1.41 2007/09/09 01:09:02 xtraeme Exp $ */ +/* $NetBSD: piixide.c,v 1.42 2007/12/09 20:28:12 jmcneill Exp $ */ /* * Copyright (c) 1999, 2000, 2001 Manuel Bouyer. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: piixide.c,v 1.41 2007/09/09 01:09:02 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: piixide.c,v 1.42 2007/12/09 20:28:12 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -50,7 +50,8 @@ static u_int32_t piix_setup_sidetim_timings(u_int8_t, u_int8_t, u_int8_t); static void piixsata_chip_map(struct pciide_softc*, struct pci_attach_args *); static int piix_dma_init(void *, int, int, void *, size_t, int); -static void piixide_powerhook(int, void *); +static bool piixide_resume(device_t); +static bool piixide_suspend(device_t); static int piixide_match(struct device *, struct cfdata *, void *); static void piixide_attach(struct device *, struct device *, void *); @@ -277,42 +278,34 @@ piixide_attach(struct device *parent, struct device *self, void *aux) pciide_common_attach(sc, pa, pciide_lookup_product(pa->pa_id, pciide_intel_products)); - /* Setup our powerhook */ - sc->sc_powerhook = powerhook_establish( - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname, piixide_powerhook, sc); - if (sc->sc_powerhook == NULL) - printf("%s: WARNING: unable to establish PCI power hook\n", - sc->sc_wdcdev.sc_atac.atac_dev.dv_xname); + if (!pmf_device_register(self, piixide_suspend, piixide_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } -static void -piixide_powerhook(int why, void *hdl) +static bool +piixide_resume(device_t dv) { - struct pciide_softc *sc = (struct pciide_softc *)hdl; - - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - pci_conf_capture(sc->sc_pc, sc->sc_tag, &sc->sc_pciconf); - sc->sc_idetim = pci_conf_read(sc->sc_pc, sc->sc_tag, - PIIX_IDETIM); - sc->sc_udmatim = pci_conf_read(sc->sc_pc, sc->sc_tag, - PIIX_UDMATIM); - break; - case PWR_RESUME: - pci_conf_restore(sc->sc_pc, sc->sc_tag, &sc->sc_pciconf); - pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_IDETIM, - sc->sc_idetim); - pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_UDMATIM, - sc->sc_udmatim); - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } + struct pciide_softc *sc = device_private(dv); + + pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_IDETIM, + sc->sc_idetim); + pci_conf_write(sc->sc_pc, sc->sc_tag, PIIX_UDMATIM, + sc->sc_udmatim); + + return true; +} + +static bool +piixide_suspend(device_t dv) +{ + struct pciide_softc *sc = device_private(dv); + + sc->sc_idetim = pci_conf_read(sc->sc_pc, sc->sc_tag, + PIIX_IDETIM); + sc->sc_udmatim = pci_conf_read(sc->sc_pc, sc->sc_tag, + PIIX_UDMATIM); - return; + return true; } static void diff --git a/sys/dev/pci/piixpm.c b/sys/dev/pci/piixpm.c index 01e316c7cc9..019a997c733 100644 --- a/sys/dev/pci/piixpm.c +++ b/sys/dev/pci/piixpm.c @@ -1,4 +1,4 @@ -/* $NetBSD: piixpm.c,v 1.17 2007/10/19 12:00:54 ad Exp $ */ +/* $NetBSD: piixpm.c,v 1.18 2007/12/09 20:28:13 jmcneill Exp $ */ /* $OpenBSD: piixpm.c,v 1.20 2006/02/27 08:25:02 grange Exp $ */ /* @@ -73,15 +73,14 @@ struct piixpm_softc { volatile int error; } sc_i2c_xfer; - void * sc_powerhook; - struct pci_conf_state sc_pciconf; pcireg_t sc_devact[2]; }; int piixpm_match(struct device *, struct cfdata *, void *); void piixpm_attach(struct device *, struct device *, void *); -void piixpm_powerhook(int, void *); +static bool piixpm_suspend(device_t); +static bool piixpm_resume(device_t); int piixpm_i2c_acquire_bus(void *, int); void piixpm_i2c_release_bus(void *, int); @@ -150,11 +149,8 @@ piixpm_attach(struct device *parent, struct device *self, void *aux) aprint_normal("\n%s: %s (rev. 0x%02x)\n", device_xname(self), devinfo, PCI_REVISION(pa->pa_class)); - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - piixpm_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: can't establish powerhook\n", - sc->sc_dev.dv_xname); + if (!pmf_device_register(self, piixpm_suspend, piixpm_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); /* Read configuration */ conf = pci_conf_read(pa->pa_pc, pa->pa_tag, PIIX_SMB_HOSTC); @@ -240,27 +236,30 @@ nopowermanagement: return; } -void -piixpm_powerhook(int why, void *cookie) +static bool +piixpm_suspend(device_t dv) { - struct piixpm_softc *sc = cookie; - pci_chipset_tag_t pc = sc->sc_pc; - pcitag_t tag = sc->sc_pcitag; - - switch (why) { - case PWR_SUSPEND: - pci_conf_capture(pc, tag, &sc->sc_pciconf); - sc->sc_devact[0] = pci_conf_read(pc, tag, PIIX_DEVACTA); - sc->sc_devact[1] = pci_conf_read(pc, tag, PIIX_DEVACTB); - break; - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->sc_pciconf); - pci_conf_write(pc, tag, PIIX_DEVACTA, sc->sc_devact[0]); - pci_conf_write(pc, tag, PIIX_DEVACTB, sc->sc_devact[1]); - break; - } + struct piixpm_softc *sc = device_private(dv); - return; + sc->sc_devact[0] = pci_conf_read(sc->sc_pc, sc->sc_pcitag, + PIIX_DEVACTA); + sc->sc_devact[1] = pci_conf_read(sc->sc_pc, sc->sc_pcitag, + PIIX_DEVACTB); + + return true; +} + +static bool +piixpm_resume(device_t dv) +{ + struct piixpm_softc *sc = device_private(dv); + + pci_conf_write(sc->sc_pc, sc->sc_pcitag, PIIX_DEVACTA, + sc->sc_devact[0]); + pci_conf_write(sc->sc_pc, sc->sc_pcitag, PIIX_DEVACTB, + sc->sc_devact[1]); + + return true; } int diff --git a/sys/dev/pci/ppb.c b/sys/dev/pci/ppb.c index be881da2510..ce4e4e5bbe6 100644 --- a/sys/dev/pci/ppb.c +++ b/sys/dev/pci/ppb.c @@ -1,4 +1,4 @@ -/* $NetBSD: ppb.c,v 1.35 2007/10/16 18:27:00 joerg Exp $ */ +/* $NetBSD: ppb.c,v 1.36 2007/12/09 20:28:13 jmcneill Exp $ */ /* * Copyright (c) 1996, 1998 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ppb.c,v 1.35 2007/10/16 18:27:00 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ppb.c,v 1.36 2007/12/09 20:28:13 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -41,13 +41,19 @@ __KERNEL_RCSID(0, "$NetBSD: ppb.c,v 1.35 2007/10/16 18:27:00 joerg Exp $"); #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> #include <dev/pci/ppbreg.h> +#include <dev/pci/pcidevs.h> struct ppb_softc { struct device sc_dev; /* generic device glue */ pci_chipset_tag_t sc_pc; /* our PCI chipset... */ pcitag_t sc_tag; /* ...and tag. */ + + pcireg_t sc_pciconfext[48]; }; +static bool ppb_resume(device_t); +static bool ppb_suspend(device_t); + static int ppbmatch(struct device *parent, struct cfdata *match, void *aux) @@ -67,12 +73,13 @@ ppbmatch(struct device *parent, struct cfdata *match, } static void -ppb_fix_pcix(device_t self, struct pci_attach_args *pa) +ppb_fix_pcix(device_t self) { + struct ppb_softc *sc = device_private(self); pcireg_t reg; int off; - if (!pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_PCIEXPRESS, + if (!pci_get_capability(sc->sc_pc, sc->sc_tag, PCI_CAP_PCIEXPRESS, &off, ®)) return; /* Not a PCIe device */ @@ -80,11 +87,11 @@ ppb_fix_pcix(device_t self, struct pci_attach_args *pa) aprint_normal_dev(self, "unuspported PCI Express version\n"); return; } - reg = pci_conf_read(pa->pa_pc, pa->pa_tag, off + 0x18); + reg = pci_conf_read(sc->sc_pc, sc->sc_tag, off + 0x18); if (reg & 0x003f) { aprint_normal_dev(self, "disabling notification events\n"); reg &= ~0x003f; - pci_conf_write(pa->pa_pc, pa->pa_tag, off + 0x18, reg); + pci_conf_write(sc->sc_pc, sc->sc_tag, off + 0x18, reg); } } @@ -114,7 +121,7 @@ ppbattach(struct device *parent, struct device *self, void *aux) return; } - ppb_fix_pcix(self, pa); + ppb_fix_pcix(self); #if 0 /* @@ -128,6 +135,9 @@ ppbattach(struct device *parent, struct device *self, void *aux) pa->pa_bus, PPB_BUSINFO_PRIMARY(busdata)); #endif + if (!pmf_device_register(self, ppb_suspend, ppb_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + /* * Attach the PCI bus than hangs off of it. * @@ -148,5 +158,37 @@ ppbattach(struct device *parent, struct device *self, void *aux) config_found_ia(self, "pcibus", &pba, pcibusprint); } +static bool +ppb_resume(device_t dv) +{ + struct ppb_softc *sc = device_private(dv); + int off; + pcireg_t val; + + for (off = 0x40; off <= 0xff; off += 4) { + val = pci_conf_read(sc->sc_pc, sc->sc_tag, off); + if (val != sc->sc_pciconfext[(off - 0x40) / 4]) + pci_conf_write(sc->sc_pc, sc->sc_tag, off, + sc->sc_pciconfext[(off - 0x40)/4]); + } + + ppb_fix_pcix(dv); + + return true; +} + +static bool +ppb_suspend(device_t dv) +{ + struct ppb_softc *sc = device_private(dv); + int off; + + for (off = 0x40; off <= 0xff; off += 4) + sc->sc_pciconfext[(off - 0x40) / 4] = + pci_conf_read(sc->sc_pc, sc->sc_tag, off); + + return true; +} + CFATTACH_DECL(ppb, sizeof(struct ppb_softc), ppbmatch, ppbattach, NULL, NULL); diff --git a/sys/dev/pci/uhci_pci.c b/sys/dev/pci/uhci_pci.c index 5487e82e980..da4b535d296 100644 --- a/sys/dev/pci/uhci_pci.c +++ b/sys/dev/pci/uhci_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: uhci_pci.c,v 1.39 2007/11/25 02:46:54 dsainty Exp $ */ +/* $NetBSD: uhci_pci.c,v 1.40 2007/12/09 20:28:13 jmcneill Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.39 2007/11/25 02:46:54 dsainty Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.40 2007/12/09 20:28:13 jmcneill Exp $"); #include "ehci.h" @@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.39 2007/11/25 02:46:54 dsainty Exp $" #include <dev/usb/uhcireg.h> #include <dev/usb/uhcivar.h> -static void uhci_pci_powerhook(int, void *); +static bool uhci_pci_resume(device_t); struct uhci_pci_softc { uhci_softc_t sc; @@ -72,9 +72,6 @@ struct uhci_pci_softc { pci_chipset_tag_t sc_pc; pcitag_t sc_tag; void *sc_ih; /* interrupt vectoring */ - - void *sc_powerhook; - struct pci_conf_state sc_pciconf; }; static int @@ -189,15 +186,6 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux) snprintf(sc->sc.sc_vendor, sizeof(sc->sc.sc_vendor), "vendor 0x%04x", PCI_VENDOR(pa->pa_id)); - /* - * Establish our powerhook before uhci_init() does its powerhook. - */ - sc->sc_powerhook = powerhook_establish(USBDEVNAME(sc->sc.sc_bus.bdev), - uhci_pci_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: couldn't establish powerhook\n", - devname); - r = uhci_init(&sc->sc); if (r != USBD_NORMAL_COMPLETION) { aprint_error("%s: init failed, error=%d\n", devname, r); @@ -208,6 +196,9 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux) usb_pci_add(&sc->sc_pci, pa, &sc->sc.sc_bus); #endif + if (!pmf_device_register(self, uhci_suspend, uhci_pci_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); + /* Attach usb device. */ sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, usbctlprint); @@ -219,8 +210,7 @@ uhci_pci_detach(device_ptr_t self, int flags) struct uhci_pci_softc *sc = (struct uhci_pci_softc *)self; int rv; - if (sc->sc_powerhook != NULL) - powerhook_disestablish(sc->sc_powerhook); + pmf_device_deregister(self); rv = uhci_detach(&sc->sc, flags); if (rv) @@ -239,34 +229,16 @@ uhci_pci_detach(device_ptr_t self, int flags) return (0); } -static void -uhci_pci_powerhook(int why, void *opaque) +static bool +uhci_pci_resume(device_t dv) { - struct uhci_pci_softc *sc; - pci_chipset_tag_t pc; - pcitag_t tag; - pcireg_t reg; - - sc = (struct uhci_pci_softc *)opaque; - pc = sc->sc_pc; - tag = sc->sc_tag; - - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - pci_conf_capture(pc, tag, &sc->sc_pciconf); - break; - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->sc_pciconf); - /* the BIOS might change this on us */ - reg = pci_conf_read(pc, tag, PCI_LEGSUP); - reg |= PCI_LEGSUP_USBPIRQDEN; - reg &= ~PCI_LEGSUP_USBSMIEN; - pci_conf_write(pc, tag, PCI_LEGSUP, reg); - break; - } + struct uhci_pci_softc *sc = device_private(dv); + + /* Set LEGSUP register to its default value. */ + pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_LEGSUP, + PCI_LEGSUP_USBPIRQDEN); - return; + return uhci_resume(dv); } CFATTACH_DECL(uhci_pci, sizeof(struct uhci_pci_softc), diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c index 17f9714dfdb..f45ddf9274a 100644 --- a/sys/dev/pci/vga_pci.c +++ b/sys/dev/pci/vga_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: vga_pci.c,v 1.36 2007/12/01 17:00:41 ad Exp $ */ +/* $NetBSD: vga_pci.c,v 1.37 2007/12/09 20:28:13 jmcneill Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vga_pci.c,v 1.36 2007/12/01 17:00:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vga_pci.c,v 1.37 2007/12/09 20:28:13 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -69,11 +69,14 @@ struct vga_pci_softc { struct vga_bar sc_bars[NBARS]; struct vga_bar sc_rom; + + struct pci_conf_state sc_pciconf; }; static int vga_pci_match(struct device *, struct cfdata *, void *); static void vga_pci_attach(struct device *, struct device *, void *); static int vga_pci_lookup_quirks(struct pci_attach_args *); +static bool vga_pci_resume(device_t dv); CFATTACH_DECL(vga_pci, sizeof(struct vga_pci_softc), vga_pci_match, vga_pci_attach, NULL, NULL); @@ -218,9 +221,26 @@ vga_pci_attach(struct device *parent, struct device *self, void *aux) vga_common_attach(sc, pa->pa_iot, pa->pa_memt, WSDISPLAY_TYPE_PCIVGA, vga_pci_lookup_quirks(pa), &vga_pci_funcs); + /* + * XXX Do not use the generic PCI framework for now as + * XXX it would power down the device when the console + * XXX is still using it. + */ + if (!pmf_device_register(self, NULL, vga_pci_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); config_found_ia(self, "drm", aux, vga_drm_print); } +static bool +vga_pci_resume(device_t dv) +{ + struct vga_pci_softc *sc = device_private(dv); + + vga_resume(&sc->sc_vga); + + return true; +} + int vga_pci_cnattach(bus_space_tag_t iot, bus_space_tag_t memt, pci_chipset_tag_t pc, int bus, int device, diff --git a/sys/dev/pci/yds.c b/sys/dev/pci/yds.c index 08cb974906e..cac1c10ffa4 100644 --- a/sys/dev/pci/yds.c +++ b/sys/dev/pci/yds.c @@ -1,4 +1,4 @@ -/* $NetBSD: yds.c,v 1.38 2007/10/19 12:00:56 ad Exp $ */ +/* $NetBSD: yds.c,v 1.39 2007/12/09 20:28:13 jmcneill Exp $ */ /* * Copyright (c) 2000, 2001 Kazuki Sakamoto and Minoura Makoto. @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: yds.c,v 1.38 2007/10/19 12:00:56 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: yds.c,v 1.39 2007/12/09 20:28:13 jmcneill Exp $"); #include "mpu.h" @@ -192,7 +192,6 @@ static uint32_t yds_get_lpfk(u_int); static struct yds_dma *yds_find_dma(struct yds_softc *, void *); static int yds_init(struct yds_softc *); -static void yds_powerhook(int, void *); #ifdef AUDIO_DEBUG static void yds_dump_play_slot(struct yds_softc *, int); @@ -679,64 +678,48 @@ yds_init(struct yds_softc *sc) return 0; } -static void -yds_powerhook(int why, void *addr) +static bool +yds_suspend(device_t dv) { - struct yds_softc *sc; - pci_chipset_tag_t pc; - pcitag_t tag; - pcireg_t reg; - int s; + struct yds_softc *sc = device_private(dv); + pci_chipset_tag_t pc = sc->sc_pc; + pcitag_t tag = sc->sc_pcitag; - sc = (struct yds_softc *)addr; - pc = sc->sc_pc; - tag = sc->sc_pcitag; + sc->sc_dsctrl = pci_conf_read(pc, tag, YDS_PCI_DSCTRL); + sc->sc_legacy = pci_conf_read(pc, tag, YDS_PCI_LEGACY); + sc->sc_ba[0] = pci_conf_read(pc, tag, YDS_PCI_FM_BA); + sc->sc_ba[1] = pci_conf_read(pc, tag, YDS_PCI_MPU_BA); - s = splaudio(); - switch (why) { - case PWR_SUSPEND: - pci_conf_capture(pc, tag, &sc->sc_pciconf); + return true; +} - sc->sc_dsctrl = pci_conf_read(pc, tag, YDS_PCI_DSCTRL); - sc->sc_legacy = pci_conf_read(pc, tag, YDS_PCI_LEGACY); - sc->sc_ba[0] = pci_conf_read(pc, tag, YDS_PCI_FM_BA); - sc->sc_ba[1] = pci_conf_read(pc, tag, YDS_PCI_MPU_BA); - break; - case PWR_RESUME: - pci_conf_restore(pc, tag, &sc->sc_pciconf); - - /* Disable legacy mode */ - reg = pci_conf_read(pc, tag, YDS_PCI_LEGACY); - pci_conf_write(pc, tag, YDS_PCI_LEGACY, - reg & YDS_PCI_LEGACY_LAD); - - /* Enable the device. */ - reg = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); - reg |= (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | - PCI_COMMAND_MASTER_ENABLE); - pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, reg); - reg = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); - if (yds_init(sc)) { - printf("%s: reinitialize failed\n", - sc->sc_dev.dv_xname); - splx(s); - return; - } - pci_conf_write(pc, tag, YDS_PCI_DSCTRL, sc->sc_dsctrl); - sc->sc_codec[0].codec_if->vtbl->restore_ports(sc->sc_codec[0].codec_if); - break; - case PWR_SOFTRESUME: - pci_conf_write(pc, tag, YDS_PCI_LEGACY, sc->sc_legacy); - pci_conf_write(pc, tag, YDS_PCI_FM_BA, sc->sc_ba[0]); - pci_conf_write(pc, tag, YDS_PCI_MPU_BA, sc->sc_ba[1]); -#if notyet - yds_configure_legacy(addr); -#endif - break; +static bool +yds_resume(device_t dv) +{ + struct yds_softc *sc = device_private(dv); + pci_chipset_tag_t pc = sc->sc_pc; + pcitag_t tag = sc->sc_pcitag; + pcireg_t reg; + + /* Disable legacy mode */ + reg = pci_conf_read(pc, tag, YDS_PCI_LEGACY); + pci_conf_write(pc, tag, YDS_PCI_LEGACY, reg & YDS_PCI_LEGACY_LAD); + + /* Enable the device. */ + reg = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); + reg |= (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | + PCI_COMMAND_MASTER_ENABLE); + pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, reg); + reg = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); + if (yds_init(sc)) { + aprint_error_dev(dv, "reinitialize failed\n"); + return false; } - splx(s); - return; + pci_conf_write(pc, tag, YDS_PCI_DSCTRL, sc->sc_dsctrl); + sc->sc_codec[0].codec_if->vtbl->restore_ports(sc->sc_codec[0].codec_if); + + return true; } static void @@ -929,7 +912,8 @@ detected: sc->sc_legacy_iot = pa->pa_iot; config_defer((struct device*) sc, yds_configure_legacy); - powerhook_establish(sc->sc_dev.dv_xname, yds_powerhook, sc); + if (!pmf_device_register(self, yds_suspend, yds_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int diff --git a/sys/dev/pckbport/pckbd.c b/sys/dev/pckbport/pckbd.c index 46ab38c12d4..5ccccc32739 100644 --- a/sys/dev/pckbport/pckbd.c +++ b/sys/dev/pckbport/pckbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: pckbd.c,v 1.17 2007/12/01 14:36:15 jmcneill Exp $ */ +/* $NetBSD: pckbd.c,v 1.18 2007/12/09 20:28:13 jmcneill Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pckbd.c,v 1.17 2007/12/01 14:36:15 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pckbd.c,v 1.18 2007/12/09 20:28:13 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -126,12 +126,9 @@ struct pckbd_softc { #ifdef WSDISPLAY_COMPAT_RAWKBD int rawkbd; #endif - - void *sc_powerhook; }; static int pckbd_is_console(pckbport_tag_t, pckbport_slot_t); -static void pckbd_powerhook(int, void *); int pckbdprobe(struct device *, struct cfdata *, void *); void pckbdattach(struct device *, struct device *, void *); @@ -249,55 +246,55 @@ pckbd_is_console(pckbport_tag_t tag, pckbport_slot_t slot) tag == pckbd_consdata.t_kbctag && slot == pckbd_consdata.t_kbcslot; } -static void -pckbd_powerhook(int why, void *opaque) +static bool +pckbd_suspend(device_t dv) { - struct pckbd_softc *sc; + struct pckbd_softc *sc = device_private(dv); + u_char cmd[1]; int res; - u_char cmd[1], resp[1]; - sc = (struct pckbd_softc *)opaque; + /* XXX duped from pckbd_enable, but we want to disable + * it even if it's the console kbd + */ + cmd[0] = KBC_DISABLE; + res = pckbport_enqueue_cmd(sc->id->t_kbctag, + sc->id->t_kbcslot, cmd, 1, 0, 1, 0); + if (res) + return false; - switch (why) { - case PWR_STANDBY: - case PWR_SUSPEND: - printf("%s: suspending...\n", sc->sc_dev.dv_xname); - /* XXX duped from pckbd_enable, but we want to disable it - * even if it's the console kbd - */ - cmd[0] = KBC_DISABLE; - res = pckbport_enqueue_cmd(sc->id->t_kbctag, sc->id->t_kbcslot, - cmd, 1, 0, 1, 0); - if (res) - printf("pckbd_disable: command error\n"); + pckbport_slot_enable(sc->id->t_kbctag, + sc->id->t_kbcslot, 0); - pckbport_slot_enable(sc->id->t_kbctag, sc->id->t_kbcslot, 0); + sc->sc_enabled = 0; + return true; +} - sc->sc_enabled = 0; - break; - case PWR_RESUME: - printf("%s: resuming...\n", sc->sc_dev.dv_xname); +static bool +pckbd_resume(device_t dv) +{ + struct pckbd_softc *sc = device_private(dv); + u_char cmd[1], resp[1]; + int res; - /* XXX jmcneill reset the keyboard */ - cmd[0] = KBC_RESET; - res = pckbport_poll_cmd(sc->id->t_kbctag, sc->id->t_kbcslot, - cmd, 1, 1, resp, 1); + /* XXX jmcneill reset the keyboard */ + pckbport_flush(sc->id->t_kbctag, sc->id->t_kbcslot); + + cmd[0] = KBC_RESET; + res = pckbport_poll_cmd(sc->id->t_kbctag, + sc->id->t_kbcslot, cmd, 1, 1, resp, 1); #ifdef DEBUG - if (res) - printf("pckbdprobe: reset error %d\n", res); + if (res) + printf("pckbdprobe: reset error %d\n", res); #endif - if (resp[0] != KBR_RSTDONE) - printf("pckbdprobe: reset response 0x%x\n", resp[0]); - - pckbport_flush(sc->id->t_kbctag, sc->id->t_kbcslot); + if (resp[0] != KBR_RSTDONE) + printf("pckbdprobe: reset response 0x%x\n", + resp[0]); - pckbd_set_xtscancode(sc->id->t_kbctag, sc->id->t_kbcslot); + pckbport_flush(sc->id->t_kbctag, sc->id->t_kbcslot); - pckbd_enable(sc, 1); - break; - } + pckbd_enable(sc, 1); - return; + return true; } /* @@ -404,11 +401,8 @@ pckbdattach(struct device *parent, struct device *self, void *aux) a.accessops = &pckbd_accessops; a.accesscookie = sc; - sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname, - pckbd_powerhook, sc); - if (sc->sc_powerhook == NULL) - aprint_error("%s: unable to install powerhook\n", - sc->sc_dev.dv_xname); + if (!pmf_device_register(self, pckbd_suspend, pckbd_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); /* * Attach the wskbd, saving a handle to it. diff --git a/sys/dev/pckbport/pms.c b/sys/dev/pckbport/pms.c index 12b25da6e58..8dfaeb952b8 100644 --- a/sys/dev/pckbport/pms.c +++ b/sys/dev/pckbport/pms.c @@ -1,4 +1,4 @@ -/* $NetBSD: pms.c,v 1.21 2007/12/01 14:36:15 jmcneill Exp $ */ +/* $NetBSD: pms.c,v 1.22 2007/12/09 20:28:13 jmcneill Exp $ */ /*- * Copyright (c) 2004 Kentaro Kurahone. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.21 2007/12/01 14:36:15 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.22 2007/12/09 20:28:13 jmcneill Exp $"); #include "opt_pms.h" @@ -85,9 +85,9 @@ static void pms_reset_thread(void*); int pms_enable(void *); int pms_ioctl(void *, u_long, void *, int, struct lwp *); void pms_disable(void *); -#ifndef PMS_DISABLE_POWERHOOK -void pms_power(int, void *); -#endif /* !PMS_DISABLE_POWERHOOK */ + +static bool pms_suspend(device_t); +static bool pms_resume(device_t); const struct wsmouse_accessops pms_accessops = { pms_enable, @@ -230,9 +230,10 @@ pmsattach(struct device *parent, struct device *self, void *aux) &sc->sc_event_thread, sc->sc_dev.dv_xname); #ifndef PMS_DISABLE_POWERHOOK - sc->sc_powerhook = powerhook_establish(self->dv_xname, pms_power, sc); sc->sc_suspended = 0; -#endif /* !PMS_DISABLE_POWERHOOK */ +#endif + if (!pmf_device_register(self, pms_suspend, pms_resume)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static void @@ -334,43 +335,36 @@ pms_disable(void *v) splx(s); } -#ifndef PMS_DISABLE_POWERHOOK -void -pms_power(int why, void *v) +static bool +pms_suspend(device_t dv) { - struct pms_softc *sc = v; + struct pms_softc *sc = device_private(dv); + + if (sc->sc_enabled) + do_disable(sc); + + return true; +} + +static bool +pms_resume(device_t dv) +{ + struct pms_softc *sc = device_private(dv); - switch (why) { - case PWR_STANDBY: - break; - case PWR_SUSPEND: - if (sc->sc_enabled) { - do_disable(sc); - sc->sc_suspended = 1; - } - break; - case PWR_RESUME: #ifdef PMS_SYNAPTICS_TOUCHPAD - if (sc->protocol == PMS_SYNAPTICS) { - pms_synaptics_resume(sc); - sc->sc_suspended = 0; - do_enable(sc); - } + if (sc->protocol == PMS_SYNAPTICS) { + pms_synaptics_resume(sc); + do_enable(sc); + } else #endif - if (sc->sc_enabled && sc->sc_suspended) { - /* recheck protocol & init mouse */ - sc->protocol = PMS_UNKNOWN; - sc->sc_suspended = 0; - do_enable(sc); /* only if we were suspended */ - } - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; + if (sc->sc_enabled) { + /* recheck protocol & init mouse */ + sc->protocol = PMS_UNKNOWN; + do_enable(sc); /* only if we were suspended */ } + + return true; } -#endif /* !PMS_DISABLE_POWERHOOK */ int pms_ioctl(void *v, u_long cmd, void *data, int flag, diff --git a/sys/dev/pckbport/wskbdmap_mfii.c b/sys/dev/pckbport/wskbdmap_mfii.c index 8a7bcdbfeac..527d797c461 100644 --- a/sys/dev/pckbport/wskbdmap_mfii.c +++ b/sys/dev/pckbport/wskbdmap_mfii.c @@ -1,4 +1,4 @@ -/* $NetBSD: wskbdmap_mfii.c,v 1.11 2006/04/01 23:02:32 christos Exp $ */ +/* $NetBSD: wskbdmap_mfii.c,v 1.12 2007/12/09 20:28:13 jmcneill Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wskbdmap_mfii.c,v 1.11 2006/04/01 23:02:32 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wskbdmap_mfii.c,v 1.12 2007/12/09 20:28:13 jmcneill Exp $"); #include <sys/types.h> #include <dev/wscons/wsksymdef.h> @@ -136,7 +136,10 @@ static const keysym_t pckbd_keydesc_us[] = { KC(127), KS_Pause, /* Break */ KC(156), KS_KP_Enter, KC(157), KS_Control_R, + KC(160), KS_Cmd_VolumeToggle, KC(170), KS_Print_Screen, + KC(174), KS_Cmd_VolumeDown, + KC(176), KS_Cmd_VolumeUp, KC(181), KS_KP_Divide, KC(183), KS_Print_Screen, KC(184), KS_Alt_R, KS_Multi_key, diff --git a/sys/dev/pcmcia/if_an_pcmcia.c b/sys/dev/pcmcia/if_an_pcmcia.c index 2762f9c247c..6ebb53be71e 100644 --- a/sys/dev/pcmcia/if_an_pcmcia.c +++ b/sys/dev/pcmcia/if_an_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_an_pcmcia.c,v 1.32 2007/10/19 12:01:04 ad Exp $ */ +/* $NetBSD: if_an_pcmcia.c,v 1.33 2007/12/09 20:28:14 jmcneill Exp $ */ /*- * Copyright (c) 2000, 2004 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_an_pcmcia.c,v 1.32 2007/10/19 12:01:04 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_an_pcmcia.c,v 1.33 2007/12/09 20:28:14 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -84,7 +84,6 @@ struct an_pcmcia_softc { int sc_io_window; /* our i/o window */ struct pcmcia_function *sc_pf; /* our PCMCIA function */ void *sc_ih; /* interrupt handle */ - void *sc_powerhook; /* power hook descriptor */ int sc_state; #define AN_PCMCIA_ATTACHED 3 @@ -164,7 +163,10 @@ an_pcmcia_attach(struct device *parent, struct device *self, goto fail2; } - psc->sc_powerhook = powerhook_establish(self->dv_xname, an_power, sc); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->sc_if); an_pcmcia_disable(sc); sc->sc_enabled = 0; @@ -188,8 +190,7 @@ an_pcmcia_detach(struct device *self, int flags) if (psc->sc_state != AN_PCMCIA_ATTACHED) return (0); - if (psc->sc_powerhook) - powerhook_disestablish(psc->sc_powerhook); + pmf_device_deregister(self); error = an_detach(&psc->sc_an); if (error) diff --git a/sys/dev/pcmcia/if_ray.c b/sys/dev/pcmcia/if_ray.c index db6213f6387..4a04394654f 100644 --- a/sys/dev/pcmcia/if_ray.c +++ b/sys/dev/pcmcia/if_ray.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ray.c,v 1.67 2007/10/19 12:01:05 ad Exp $ */ +/* $NetBSD: if_ray.c,v 1.68 2007/12/09 20:28:14 jmcneill Exp $ */ /* * Copyright (c) 2000 Christian E. Hopps @@ -57,7 +57,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.67 2007/10/19 12:01:05 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.68 2007/12/09 20:28:14 jmcneill Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -158,12 +158,8 @@ struct ray_softc { struct pcmcia_function *sc_pf; void *sc_ih; - void *sc_sdhook; - void *sc_pwrhook; int sc_attached; - int sc_flags; /*. misc flags */ -#define RAY_FLAGS_RESUMEINIT 0x0001 int sc_resetloop; struct callout sc_check_ccs_ch; @@ -302,6 +298,7 @@ static u_int ray_find_free_tx_ccs(struct ray_softc *, u_int); static u_int8_t ray_free_ccs(struct ray_softc *, bus_size_t); static void ray_free_ccs_chain(struct ray_softc *, u_int); static void ray_if_start(struct ifnet *); +static void ray_if_stop(struct ifnet *, int); static int ray_init(struct ray_softc *); static int ray_intr(void *); static void ray_intr_start(struct ray_softc *); @@ -310,7 +307,6 @@ static int ray_issue_cmd(struct ray_softc *, bus_size_t, u_int); static int ray_match(struct device *, struct cfdata *, void *); static int ray_media_change(struct ifnet *); static void ray_media_status(struct ifnet *, struct ifmediareq *); -void ray_power(int, void *); static ray_cmd_func_t ray_rccs_intr(struct ray_softc *, bus_size_t); static void ray_read_region(struct ray_softc *, bus_size_t,void *,size_t); static void ray_recv(struct ray_softc *, bus_size_t); @@ -320,7 +316,6 @@ static void ray_reset(struct ray_softc *); static void ray_reset_resetloop(void *); static int ray_send_auth(struct ray_softc *, u_int8_t *, u_int8_t); static void ray_set_pending(struct ray_softc *, u_int); -static void ray_shutdown(void *); static int ray_simple_cmd(struct ray_softc *, u_int, u_int); static void ray_start_assoc(struct ray_softc *); static void ray_start_join_net(struct ray_softc *); @@ -571,7 +566,6 @@ ray_attach(struct device *parent, struct device *self, void *aux) sc->sc_omode = sc->sc_mode = RAY_MODE_DEFAULT; sc->sc_countrycode = sc->sc_dcountrycode = RAY_PID_COUNTRY_CODE_DEFAULT; - sc->sc_flags &= ~RAY_FLAGS_RESUMEINIT; /* * attach the interface @@ -590,6 +584,7 @@ ray_attach(struct device *parent, struct device *self, void *aux) memcpy(ifp->if_xname, self->dv_xname, IFNAMSIZ); ifp->if_softc = sc; ifp->if_start = ray_if_start; + ifp->if_stop = ray_if_stop; ifp->if_ioctl = ray_ioctl; ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST; @@ -609,8 +604,10 @@ ray_attach(struct device *parent, struct device *self, void *aux) else ifmedia_set(&sc->sc_media, IFM_INFRA); - sc->sc_sdhook = shutdownhook_establish(ray_shutdown, sc); - sc->sc_pwrhook = powerhook_establish(self->dv_xname, ray_power, sc); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, ifp); /* The attach is successful. */ sc->sc_attached = 1; @@ -655,17 +652,14 @@ ray_detach(struct device *self, int flags) struct ray_softc *sc; struct ifnet *ifp; - sc = (struct ray_softc *)self; + sc = device_private(self); ifp = &sc->sc_if; RAY_DPRINTF(("%s: detach\n", sc->sc_xname)); if (!sc->sc_attached) return (0); - if (sc->sc_pwrhook) - powerhook_disestablish(sc->sc_pwrhook); - if (sc->sc_sdhook) - shutdownhook_disestablish(sc->sc_sdhook); + pmf_device_deregister(self); if (sc->sc_if.if_flags & IFF_UP) ray_disable(sc); @@ -760,7 +754,6 @@ ray_init(sc) sc->sc_running = 0; sc->sc_txfree = RAY_CCS_NTX; sc->sc_checkcounters = 0; - sc->sc_flags &= ~RAY_FLAGS_RESUMEINIT; sc->sc_authstate = RAY_AUTH_UNAUTH; /* get startup results */ @@ -878,42 +871,6 @@ ray_reset_resetloop(arg) sc->sc_resetloop = 0; } -void -ray_power(int why, void *arg) -{ -#if 0 - struct ray_softc *sc; - - /* can't do this until power hooks are called from thread */ - sc = arg; - switch (why) { - case PWR_RESUME: - if ((sc->sc_flags & RAY_FLAGS_RESUMEINIT)) - ray_init(sc); - break; - case PWR_SUSPEND: - if ((sc->sc_if.if_flags & IFF_RUNNING)) { - ray_stop(sc); - sc->sc_flags |= RAY_FLAGS_RESUMEINIT; - } - break; - case PWR_STANDBY: - default: - break; - } -#endif -} - -static void -ray_shutdown(arg) - void *arg; -{ - struct ray_softc *sc; - - sc = arg; - ray_disable(sc); -} - static int ray_ioctl(ifp, cmd, data) struct ifnet *ifp; @@ -1070,6 +1027,14 @@ ray_if_start(ifp) ray_intr_start(sc); } +static void +ray_if_stop(struct ifnet *ifp, int disable) +{ + struct ray_softc *sc = ifp->if_softc; + + ray_stop(sc); +} + static int ray_media_change(ifp) struct ifnet *ifp; diff --git a/sys/dev/pcmcia/if_wi_pcmcia.c b/sys/dev/pcmcia/if_wi_pcmcia.c index 769621aa38f..609c02df62d 100644 --- a/sys/dev/pcmcia/if_wi_pcmcia.c +++ b/sys/dev/pcmcia/if_wi_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wi_pcmcia.c,v 1.76 2007/10/19 12:01:05 ad Exp $ */ +/* $NetBSD: if_wi_pcmcia.c,v 1.77 2007/12/09 20:28:14 jmcneill Exp $ */ /*- * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wi_pcmcia.c,v 1.76 2007/10/19 12:01:05 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wi_pcmcia.c,v 1.77 2007/12/09 20:28:14 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -87,8 +87,6 @@ static void wi_pcmcia_attach(struct device *, struct device *, void *); static int wi_pcmcia_detach(struct device *, int); static int wi_pcmcia_enable(struct wi_softc *); static void wi_pcmcia_disable(struct wi_softc *); -static void wi_pcmcia_powerhook(int, void *); -static void wi_pcmcia_shutdown(void *); #if WI_PCMCIA_SPECTRUM24T_FW /* support to download firmware for symbol CF card */ @@ -100,8 +98,6 @@ static int wi_pcmcia_set_hcr(struct wi_softc *, int); struct wi_pcmcia_softc { struct wi_softc sc_wi; - void *sc_powerhook; /* power hook descriptor */ - void *sc_sdhook; /* shutdown hook */ int sc_symbol_cf; /* Spectrum24t CF card */ struct pcmcia_function *sc_pf; /* PCMCIA function */ @@ -392,9 +388,10 @@ wi_pcmcia_attach(struct device *parent, struct device *self, goto fail2; } - psc->sc_sdhook = shutdownhook_establish(wi_pcmcia_shutdown, psc); - psc->sc_powerhook = powerhook_establish(self->dv_xname, - wi_pcmcia_powerhook, psc); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else + pmf_class_network_register(self, &sc->sc_if); wi_pcmcia_disable(sc); psc->sc_state = WI_PCMCIA_ATTACHED; @@ -415,11 +412,6 @@ wi_pcmcia_detach(struct device *self, int flags) if (psc->sc_state != WI_PCMCIA_ATTACHED) return (0); - if (psc->sc_powerhook) - powerhook_disestablish(psc->sc_powerhook); - if (psc->sc_sdhook) - shutdownhook_disestablish(psc->sc_sdhook); - error = wi_detach(&psc->sc_wi); if (error != 0) return (error); @@ -429,27 +421,6 @@ wi_pcmcia_detach(struct device *self, int flags) return (0); } -static void -wi_pcmcia_powerhook(why, arg) - int why; - void *arg; -{ - struct wi_pcmcia_softc *psc = arg; - struct wi_softc *sc = &psc->sc_wi; - - wi_power(sc, why); -} - -static void -wi_pcmcia_shutdown(arg) - void *arg; -{ - struct wi_pcmcia_softc *psc = arg; - struct wi_softc *sc = &psc->sc_wi; - - wi_shutdown(sc); -} - /* * Special routines to download firmware for Symbol CF card. * XXX: This should be modified generic into any PRISM-2 based card. diff --git a/sys/dev/pcmcia/pcmcia.c b/sys/dev/pcmcia/pcmcia.c index 67d579624d5..059fe6f69d2 100644 --- a/sys/dev/pcmcia/pcmcia.c +++ b/sys/dev/pcmcia/pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcmcia.c,v 1.83 2007/12/01 14:36:57 jmcneill Exp $ */ +/* $NetBSD: pcmcia.c,v 1.84 2007/12/09 20:28:14 jmcneill Exp $ */ /* * Copyright (c) 2004 Charles M. Hannum. All rights reserved. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pcmcia.c,v 1.83 2007/12/01 14:36:57 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcmcia.c,v 1.84 2007/12/09 20:28:14 jmcneill Exp $"); #include "opt_pcmciaverbose.h" @@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: pcmcia.c,v 1.83 2007/12/01 14:36:57 jmcneill Exp $") #include <sys/systm.h> #include <sys/device.h> +#include <net/if.h> + #include <dev/pcmcia/pcmciareg.h> #include <dev/pcmcia/pcmciachip.h> #include <dev/pcmcia/pcmciavar.h> @@ -138,6 +140,9 @@ pcmcia_attach(struct device *parent, struct device *self, void *aux) sc->iosize = paa->iosize; sc->ih = NULL; + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } int diff --git a/sys/dev/rasops/rasops.c b/sys/dev/rasops/rasops.c index 5008b4beb37..1cd1961927b 100644 --- a/sys/dev/rasops/rasops.c +++ b/sys/dev/rasops/rasops.c @@ -1,4 +1,4 @@ -/* $NetBSD: rasops.c,v 1.56 2007/07/28 20:28:57 mjf Exp $ */ +/* $NetBSD: rasops.c,v 1.57 2007/12/09 20:28:14 jmcneill Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.56 2007/07/28 20:28:57 mjf Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.57 2007/12/09 20:28:14 jmcneill Exp $"); #include "opt_rasops.h" #include "rasops_glue.h" @@ -945,8 +945,10 @@ rasops_do_cursor(ri) *(int32_t *)dp ^= ~0; dp += 4; if (ri->ri_hwbits) { - *(int32_t *)hp ^= ~0; + dp -= 4; + *(int32_t *)hp = *(int32_t *)dp; hp += 4; + dp += 4; } } } @@ -962,16 +964,19 @@ rasops_do_cursor(ri) if (slop1 & 1) { *dp++ ^= ~0; - if (ri->ri_hwbits) - *hp++ ^= ~0; + if (ri->ri_hwbits) { + *hp++ = *(dp - 1); + } } if (slop1 & 2) { *(int16_t *)dp ^= ~0; dp += 2; if (ri->ri_hwbits) { - *(int16_t *)hp ^= ~0; + dp -= 2; + *(int16_t *)hp = *(int16_t *)dp; hp += 2; + dp += 2; } } @@ -979,21 +984,23 @@ rasops_do_cursor(ri) *(int32_t *)dp ^= ~0; dp += 4; if (ri->ri_hwbits) { - *(int32_t *)hp ^= ~0; + dp -= 4; + *(int32_t *)hp = *(int32_t *)dp; hp += 4; + dp += 4; } } if (slop2 & 1) { *dp++ ^= ~0; if (ri->ri_hwbits) - *hp++ ^= ~0; + *hp++ = *(dp - 1); } if (slop2 & 2) { *(int16_t *)dp ^= ~0; if (ri->ri_hwbits) - *(int16_t *)hp ^= ~0; + *(int16_t *)hp = *(int16_t *)(dp - 2); } } } diff --git a/sys/dev/rasops/rasops8.c b/sys/dev/rasops/rasops8.c index 1fe5f08d4ec..f5d01a1e375 100644 --- a/sys/dev/rasops/rasops8.c +++ b/sys/dev/rasops/rasops8.c @@ -1,4 +1,4 @@ -/* $NetBSD: rasops8.c,v 1.22 2007/03/04 06:02:39 christos Exp $ */ +/* $NetBSD: rasops8.c,v 1.23 2007/12/09 20:28:14 jmcneill Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.22 2007/03/04 06:02:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.23 2007/12/09 20:28:14 jmcneill Exp $"); #include "opt_rasops.h" @@ -289,7 +289,8 @@ rasops8_putchar8(cookie, row, col, uc, attr) rp[0] = rp[1] = stamp[0]; DELTA(rp, ri->ri_stride, int32_t *); if (ri->ri_hwbits) { - hp[0] = hp[1] = stamp[0]; + hp[0] = stamp[0]; + hp[1] = stamp[0]; DELTA(hp, ri->ri_stride, int32_t *); } } @@ -321,7 +322,8 @@ rasops8_putchar8(cookie, row, col, uc, attr) rp[0] = rp[1] = stamp[15]; if (ri->ri_hwbits) { DELTA(hp, -(ri->ri_stride << 1), int32_t *); - hp[0] = hp[1] = stamp[15]; + hp[0] = stamp[15]; + hp[1] = stamp[15]; } } @@ -385,7 +387,9 @@ rasops8_putchar12(cookie, row, col, uc, attr) rp[0] = rp[1] = rp[2] = c; DELTA(rp, ri->ri_stride, int32_t *); if (ri->ri_hwbits) { - hrp[0] = hrp[1] = hrp[2] = c; + hrp[0] = c; + hrp[1] = c; + hrp[2] = c; DELTA(hrp, ri->ri_stride, int32_t *); } } @@ -417,7 +421,9 @@ rasops8_putchar12(cookie, row, col, uc, attr) rp[0] = rp[1] = rp[2] = stamp[15]; if (ri->ri_hwbits) { DELTA(hrp, -(ri->ri_stride << 1), int32_t *); - hrp[0] = hrp[1] = hrp[2] = stamp[15]; + hrp[0] = stamp[15]; + hrp[1] = stamp[15]; + hrp[2] = stamp[15]; } } @@ -478,8 +484,12 @@ rasops8_putchar16(cookie, row, col, uc, attr) if (uc == ' ') { while (height--) { rp[0] = rp[1] = rp[2] = rp[3] = stamp[0]; - if (ri->ri_hwbits) - hrp[0] = hrp[1] = hrp[2] = hrp[3] = stamp[0]; + if (ri->ri_hwbits) { + hrp[0] = stamp[0]; + hrp[1] = stamp[0]; + hrp[2] = stamp[0]; + hrp[3] = stamp[0]; + } } } else { uc -= ri->ri_font->firstchar; @@ -511,7 +521,10 @@ rasops8_putchar16(cookie, row, col, uc, attr) rp[0] = rp[1] = rp[2] = rp[3] = stamp[15]; if (ri->ri_hwbits) { DELTA(hrp, -(ri->ri_stride << 1), int32_t *); - hrp[0] = hrp[1] = hrp[2] = hrp[3] = stamp[15]; + hrp[0] = stamp[15]; + hrp[1] = stamp[15]; + hrp[2] = stamp[15]; + hrp[3] = stamp[15]; } } diff --git a/sys/dev/scsipi/atapiconf.c b/sys/dev/scsipi/atapiconf.c index 8e85012215f..21bbd59d3bf 100644 --- a/sys/dev/scsipi/atapiconf.c +++ b/sys/dev/scsipi/atapiconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: atapiconf.c,v 1.73 2007/12/01 14:46:04 jmcneill Exp $ */ +/* $NetBSD: atapiconf.c,v 1.74 2007/12/09 20:28:22 jmcneill Exp $ */ /* * Copyright (c) 1996, 2001 Manuel Bouyer. All rights reserved. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.73 2007/12/01 14:46:04 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.74 2007/12/09 20:28:22 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -162,6 +162,9 @@ atapibusattach(struct device *parent, struct device *self, void *aux) chan->chan_init_cb_arg = NULL; scsipi_channel_init(chan); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + /* Probe the bus for devices. */ atapi_probe_bus(sc, -1); } diff --git a/sys/dev/scsipi/cd.c b/sys/dev/scsipi/cd.c index dc5dfa379f7..7f0f12731df 100644 --- a/sys/dev/scsipi/cd.c +++ b/sys/dev/scsipi/cd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.270 2007/11/27 18:06:37 reinoud Exp $ */ +/* $NetBSD: cd.c,v 1.271 2007/12/09 20:28:22 jmcneill Exp $ */ /*- * Copyright (c) 1998, 2001, 2003, 2004, 2005 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.270 2007/11/27 18:06:37 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.271 2007/12/09 20:28:22 jmcneill Exp $"); #include "rnd.h" @@ -289,6 +289,9 @@ cdattach(struct device *parent, struct device *self, void *aux) rnd_attach_source(&cd->rnd_source, cd->sc_dev.dv_xname, RND_TYPE_DISK, 0); #endif + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } static int @@ -3485,4 +3488,3 @@ mmc_gettrackinfo(struct scsipi_periph *periph, return 0; } - diff --git a/sys/dev/scsipi/scsiconf.c b/sys/dev/scsipi/scsiconf.c index 21057d8d322..4b36b440f6a 100644 --- a/sys/dev/scsipi/scsiconf.c +++ b/sys/dev/scsipi/scsiconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsiconf.c,v 1.243 2007/03/04 06:02:42 christos Exp $ */ +/* $NetBSD: scsiconf.c,v 1.244 2007/12/09 20:28:22 jmcneill Exp $ */ /*- * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. @@ -55,7 +55,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.243 2007/03/04 06:02:42 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.244 2007/12/09 20:28:22 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -166,6 +166,9 @@ scsibusattach(struct device *parent, struct device *self, void *aux) struct scsipi_channel *chan = aux; struct scsi_initq *scsi_initq; + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + sc->sc_channel = chan; chan->chan_name = sc->sc_dev.dv_xname; @@ -285,6 +288,7 @@ scsibusdetach(struct device *self, int flags) struct scsipi_xfer *xs; int error; + pmf_device_deregister(self); /* * Process outstanding commands (which will never complete as the diff --git a/sys/dev/scsipi/sd.c b/sys/dev/scsipi/sd.c index 252f1c42c45..31ca48e508d 100644 --- a/sys/dev/scsipi/sd.c +++ b/sys/dev/scsipi/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.267 2007/10/08 16:41:14 ad Exp $ */ +/* $NetBSD: sd.c,v 1.268 2007/12/09 20:28:23 jmcneill Exp $ */ /*- * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc. @@ -54,7 +54,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.267 2007/10/08 16:41:14 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.268 2007/12/09 20:28:23 jmcneill Exp $"); #include "opt_scsi.h" #include "rnd.h" @@ -107,7 +107,7 @@ static int sdgetdisklabel(struct sd_softc *); static void sdstart(struct scsipi_periph *); static void sdrestart(void *); static void sddone(struct scsipi_xfer *, int); -static void sd_shutdown(void *); +static bool sd_suspend(device_t); static int sd_interpret_sense(struct scsipi_xfer *); static int sd_mode_sense(struct sd_softc *, u_int8_t, void *, size_t, int, @@ -306,18 +306,8 @@ sdattach(struct device *parent, struct device *self, void *aux) } aprint_normal("\n"); - /* - * Establish a shutdown hook so that we can ensure that - * our data has actually made it onto the platter at - * shutdown time. Note that this relies on the fact - * that the shutdown hook code puts us at the head of - * the list (thus guaranteeing that our hook runs before - * our ancestors'). - */ - if ((sd->sc_sdhook = - shutdownhook_establish(sd_shutdown, sd)) == NULL) - aprint_error("%s: WARNING: unable to establish shutdown hook\n", - sd->sc_dev.dv_xname); + if (!pmf_device_register(self, sd_suspend, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); #if NRND > 0 /* @@ -391,8 +381,7 @@ sddetach(struct device *self, int flags) disk_detach(&sd->sc_dk); disk_destroy(&sd->sc_dk); - /* Get rid of the shutdown hook. */ - shutdownhook_disestablish(sd->sc_sdhook); + pmf_device_deregister(self); #if NRND > 0 /* Unhook the entropy source. */ @@ -1324,10 +1313,10 @@ sdgetdisklabel(struct sd_softc *sd) return 0; } -static void -sd_shutdown(void *arg) +static bool +sd_suspend(device_t dv) { - struct sd_softc *sd = arg; + struct sd_softc *sd = device_private(dv); /* * If the disk cache needs to be flushed, and the disk supports @@ -1342,6 +1331,8 @@ sd_shutdown(void *arg) } else sd->flags &= ~(SDF_FLUSHING|SDF_DIRTY); } + + return true; } /* diff --git a/sys/dev/sysmon/sysmon_power.c b/sys/dev/sysmon/sysmon_power.c index e975082a0a7..d75539bc6dc 100644 --- a/sys/dev/sysmon/sysmon_power.c +++ b/sys/dev/sysmon/sysmon_power.c @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_power.c,v 1.32 2007/12/05 17:19:54 pooka Exp $ */ +/* $NetBSD: sysmon_power.c,v 1.33 2007/12/09 20:28:23 jmcneill Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -69,7 +69,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.32 2007/12/05 17:19:54 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.33 2007/12/09 20:28:23 jmcneill Exp $"); #include "opt_compat_netbsd.h" #include <sys/param.h> @@ -896,6 +896,23 @@ sysmon_pswitch_event(struct sysmon_pswitch *smpsw, int event) KASSERT(smpsw != NULL); + /* + * For pnp specific events, we don't care if the power daemon + * is running or not + */ + if (smpsw->smpsw_type == PSWITCH_TYPE_LID) { + switch (event) { + case PSWITCH_EVENT_PRESSED: + pmf_event_inject(NULL, PMFE_CHASSIS_LID_CLOSE); + break; + case PSWITCH_EVENT_RELEASED: + pmf_event_inject(NULL, PMFE_CHASSIS_LID_OPEN); + break; + default: + break; + } + } + if (sysmon_power_daemon != NULL) { /* * Create a new dictionary for the event. diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index 48b248bc268..5fd95361483 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.126 2007/12/05 07:15:53 ad Exp $ */ +/* $NetBSD: ehci.c,v 1.127 2007/12/09 20:28:23 jmcneill Exp $ */ /* * Copyright (c) 2004,2005 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.126 2007/12/05 07:15:53 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.127 2007/12/09 20:28:23 jmcneill Exp $"); #include "ohci.h" #include "uhci.h" @@ -129,7 +129,6 @@ struct ehci_pipe { }; Static void ehci_shutdown(void *); -Static void ehci_power(int, void *); Static usbd_status ehci_open(usbd_pipe_handle); Static void ehci_poll(struct usbd_bus *); @@ -416,8 +415,6 @@ ehci_init(ehci_softc_t *sc) sc->sc_bus.methods = &ehci_bus_methods; sc->sc_bus.pipe_size = sizeof(struct ehci_pipe); - sc->sc_powerhook = powerhook_establish(USBDEVNAME(sc->sc_bus.bdev), - ehci_power, sc); sc->sc_shutdownhook = shutdownhook_establish(ehci_shutdown, sc); sc->sc_eintrs = EHCI_NORMAL_INTRS; @@ -539,7 +536,7 @@ ehci_intr(void *v) { ehci_softc_t *sc = v; - if (sc == NULL || sc->sc_dying) + if (sc == NULL || sc->sc_dying || !device_has_power(&sc->sc_bus.bdev)) return (0); /* If we get an interrupt while polling, then just ignore it. */ @@ -925,8 +922,6 @@ ehci_detach(struct ehci_softc *sc, int flags) usb_uncallout(sc->sc_tmo_intrlist, ehci_intrlist_timeout, sc); - if (sc->sc_powerhook != NULL) - powerhook_disestablish(sc->sc_powerhook); if (sc->sc_shutdownhook != NULL) shutdownhook_disestablish(sc->sc_shutdownhook); @@ -964,102 +959,122 @@ ehci_activate(device_ptr_t self, enum devact act) * We need to switch to polling mode here, because this routine is * called from an interrupt context. This is all right since we * are almost suspended anyway. + * + * Note that this power handler isn't to be registered directly; the + * bus glue needs to call out to it. */ -void -ehci_power(int why, void *v) +bool +ehci_suspend(device_t dv) { - ehci_softc_t *sc = v; - u_int32_t cmd, hcr; - int s, i; - -#ifdef EHCI_DEBUG - DPRINTF(("ehci_power: sc=%p, why=%d\n", sc, why)); - if (ehcidebug > 0) - ehci_dump_regs(sc); -#endif + ehci_softc_t *sc = (ehci_softc_t *)dv; + int i, s; + uint32_t cmd, hcr; s = splhardusb(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - sc->sc_bus.use_polling++; - sc->sc_cmd = EOREAD4(sc, EHCI_USBCMD); + sc->sc_bus.use_polling++; - cmd = sc->sc_cmd & ~(EHCI_CMD_ASE | EHCI_CMD_PSE); - EOWRITE4(sc, EHCI_USBCMD, cmd); + for (i = 1; i <= sc->sc_noport; i++) { + cmd = EOREAD4(sc, EHCI_PORTSC(i)); + if ((cmd & EHCI_PS_PO) == 0 && (cmd & EHCI_PS_PE) == EHCI_PS_PE) + EOWRITE4(sc, EHCI_PORTSC(i), cmd | EHCI_PS_SUSP); + } - for (i = 0; i < 100; i++) { - hcr = EOREAD4(sc, EHCI_USBSTS) & - (EHCI_STS_ASS | EHCI_STS_PSS); - if (hcr == 0) - break; + sc->sc_cmd = EOREAD4(sc, EHCI_USBCMD); - usb_delay_ms(&sc->sc_bus, 1); - } - if (hcr != 0) { - printf("%s: reset timeout\n", - USBDEVNAME(sc->sc_bus.bdev)); - } + cmd = sc->sc_cmd & ~(EHCI_CMD_ASE | EHCI_CMD_PSE); + EOWRITE4(sc, EHCI_USBCMD, cmd); - cmd &= ~EHCI_CMD_RS; - EOWRITE4(sc, EHCI_USBCMD, cmd); + for (i = 0; i < 100; i++) { + hcr = EOREAD4(sc, EHCI_USBSTS) & (EHCI_STS_ASS | EHCI_STS_PSS); + if (hcr == 0) + break; - for (i = 0; i < 100; i++) { - hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH; - if (hcr == EHCI_STS_HCH) - break; + usb_delay_ms(&sc->sc_bus, 1); + } + if (hcr != 0) + printf("%s: reset timeout\n", USBDEVNAME(sc->sc_bus.bdev)); - usb_delay_ms(&sc->sc_bus, 1); - } - if (hcr != EHCI_STS_HCH) { - printf("%s: config timeout\n", - USBDEVNAME(sc->sc_bus.bdev)); - } + cmd &= ~EHCI_CMD_RS; + EOWRITE4(sc, EHCI_USBCMD, cmd); - sc->sc_bus.use_polling--; - break; + for (i = 0; i < 100; i++) { + hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH; + if (hcr == EHCI_STS_HCH) + break; - case PWR_RESUME: - sc->sc_bus.use_polling++; + usb_delay_ms(&sc->sc_bus, 1); + } + if (hcr != EHCI_STS_HCH) + printf("%s: config timeout\n", USBDEVNAME(sc->sc_bus.bdev)); - /* restore things in case the bios sucks */ - EOWRITE4(sc, EHCI_CTRLDSSEGMENT, 0); - EOWRITE4(sc, EHCI_PERIODICLISTBASE, DMAADDR(&sc->sc_fldma, 0)); - EOWRITE4(sc, EHCI_ASYNCLISTADDR, - sc->sc_async_head->physaddr | EHCI_LINK_QH); - EOWRITE4(sc, EHCI_USBINTR, sc->sc_eintrs); + sc->sc_bus.use_polling--; + splx(s); - EOWRITE4(sc, EHCI_USBCMD, sc->sc_cmd); + return true; +} - for (i = 0; i < 100; i++) { - hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH; - if (hcr != EHCI_STS_HCH) - break; +bool +ehci_resume(device_t dv) +{ + ehci_softc_t *sc = (ehci_softc_t *)dv; + int i, s; + uint32_t cmd, hcr; - usb_delay_ms(&sc->sc_bus, 1); - } - if (hcr == EHCI_STS_HCH) { - printf("%s: config timeout\n", - USBDEVNAME(sc->sc_bus.bdev)); + s = splhardusb(); + + sc->sc_bus.use_polling++; + + /* restore things in case the bios sucks */ + EOWRITE4(sc, EHCI_CTRLDSSEGMENT, 0); + EOWRITE4(sc, EHCI_PERIODICLISTBASE, DMAADDR(&sc->sc_fldma, 0)); + EOWRITE4(sc, EHCI_ASYNCLISTADDR, + sc->sc_async_head->physaddr | EHCI_LINK_QH); + EOWRITE4(sc, EHCI_USBINTR, sc->sc_eintrs); + + EOWRITE4(sc, EHCI_USBCMD, sc->sc_cmd); + + hcr = 0; + for (i = 1; i <= sc->sc_noport; i++) { + cmd = EOREAD4(sc, EHCI_PORTSC(i)); + if ((cmd & EHCI_PS_PO) == 0 && + (cmd & EHCI_PS_SUSP) == EHCI_PS_SUSP) { + EOWRITE4(sc, EHCI_PORTSC(i), cmd | EHCI_PS_FPR); + hcr = 1; } + } + if (hcr) { usb_delay_ms(&sc->sc_bus, USB_RESUME_WAIT); - sc->sc_bus.use_polling--; - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; + for (i = 1; i <= sc->sc_noport; i++) { + cmd = EOREAD4(sc, EHCI_PORTSC(i)); + if ((cmd & EHCI_PS_PO) == 0 && + (cmd & EHCI_PS_SUSP) == EHCI_PS_SUSP) + EOWRITE4(sc, EHCI_PORTSC(i), + cmd & ~EHCI_PS_FPR); + } } + + EOWRITE4(sc, EHCI_USBCMD, sc->sc_cmd); + + for (i = 0; i < 100; i++) { + hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH; + if (hcr != EHCI_STS_HCH) + break; + + usb_delay_ms(&sc->sc_bus, 1); + } + if (hcr == EHCI_STS_HCH) + printf("%s: config timeout\n", USBDEVNAME(sc->sc_bus.bdev)); + + usb_delay_ms(&sc->sc_bus, USB_RESUME_WAIT); + + sc->sc_bus.use_polling--; + splx(s); -#ifdef EHCI_DEBUG - DPRINTF(("ehci_power: sc=%p\n", sc)); - if (ehcidebug > 0) - ehci_dump_regs(sc); -#endif + return true; } /* diff --git a/sys/dev/usb/ehcivar.h b/sys/dev/usb/ehcivar.h index fc80e45bb4e..a88beafbebb 100644 --- a/sys/dev/usb/ehcivar.h +++ b/sys/dev/usb/ehcivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ehcivar.h,v 1.25 2007/12/05 07:15:54 ad Exp $ */ +/* $NetBSD: ehcivar.h,v 1.26 2007/12/09 20:28:23 jmcneill Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -97,7 +97,6 @@ typedef struct ehci_softc { int sc_id_vendor; /* vendor ID for root hub */ u_int32_t sc_cmd; /* shadow of cmd reg during suspend */ - void *sc_powerhook; /* cookie from power hook */ void *sc_shutdownhook; /* cookie from shutdown hook */ u_int sc_ncomp; @@ -161,3 +160,5 @@ usbd_status ehci_init(ehci_softc_t *); int ehci_intr(void *); int ehci_detach(ehci_softc_t *, int); int ehci_activate(device_ptr_t, enum devact); +bool ehci_suspend(device_t dv); +bool ehci_resume(device_t dv); diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c index 5cff532ab84..8e46a81f096 100644 --- a/sys/dev/usb/if_rum.c +++ b/sys/dev/usb/if_rum.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_rum.c,v 1.65 2007/09/07 19:05:05 damien Exp $ */ -/* $NetBSD: if_rum.c,v 1.18 2007/11/25 09:30:10 kiyohara Exp $ */ +/* $OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $ */ +/* $NetBSD: if_rum.c,v 1.19 2007/12/09 20:28:23 jmcneill Exp $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr> @@ -24,7 +24,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.18 2007/11/25 09:30:10 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.19 2007/12/09 20:28:23 jmcneill Exp $"); #include "bpfilter.h" diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index ffed3e114a0..dcc9fc1bad8 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.184 2007/10/19 12:01:21 ad Exp $ */ +/* $NetBSD: ohci.c,v 1.185 2007/12/09 20:28:23 jmcneill Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ /* @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.184 2007/10/19 12:01:21 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.185 2007/12/09 20:28:23 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -137,7 +137,6 @@ Static usbd_status ohci_alloc_std_chain(struct ohci_pipe *, ohci_soft_td_t *, ohci_soft_td_t **); Static void ohci_shutdown(void *v); -Static void ohci_power(int, void *); Static usbd_status ohci_open(usbd_pipe_handle); Static void ohci_poll(struct usbd_bus *); Static void ohci_softintr(void *); @@ -396,7 +395,6 @@ ohci_detach(struct ohci_softc *sc, int flags) usb_uncallout(sc->sc_tmo_rhsc, ohci_rhsc_enable, sc); #if defined(__NetBSD__) || defined(__OpenBSD__) - powerhook_disestablish(sc->sc_powerhook); shutdownhook_disestablish(sc->sc_shutdownhook); #endif @@ -904,8 +902,6 @@ ohci_init(ohci_softc_t *sc) #if defined(__NetBSD__) || defined(__OpenBSD__) sc->sc_control = sc->sc_intre = 0; - sc->sc_powerhook = powerhook_establish(USBDEVNAME(sc->sc_bus.bdev), - ohci_power, sc); sc->sc_shutdownhook = shutdownhook_establish(ohci_shutdown, sc); #endif @@ -1017,72 +1013,66 @@ ohci_shutdown(void *v) OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET); } -/* - * Handle suspend/resume. - * - * We need to switch to polling mode here, because this routine is - * called from an interupt context. This is all right since we - * are almost suspended anyway. - */ -void -ohci_power(int why, void *v) +bool +ohci_resume(device_t dv) { - ohci_softc_t *sc = v; - u_int32_t ctl; + ohci_softc_t *sc = device_private(dv); + uint32_t ctl; int s; -#ifdef OHCI_DEBUG - DPRINTF(("ohci_power: sc=%p, why=%d\n", sc, why)); - ohci_dumpregs(sc); -#endif + s = splhardusb(); + sc->sc_bus.use_polling++; + /* Some broken BIOSes do not recover these values */ + OWRITE4(sc, OHCI_HCCA, DMAADDR(&sc->sc_hccadma, 0)); + OWRITE4(sc, OHCI_CONTROL_HEAD_ED, + sc->sc_ctrl_head->physaddr); + OWRITE4(sc, OHCI_BULK_HEAD_ED, + sc->sc_bulk_head->physaddr); + if (sc->sc_intre) + OWRITE4(sc, OHCI_INTERRUPT_ENABLE, sc->sc_intre & + (OHCI_ALL_INTRS | OHCI_MIE)); + if (sc->sc_control) + ctl = sc->sc_control; + else + ctl = OREAD4(sc, OHCI_CONTROL); + ctl |= OHCI_HCFS_RESUME; + OWRITE4(sc, OHCI_CONTROL, ctl); + usb_delay_ms(&sc->sc_bus, USB_RESUME_DELAY); + ctl = (ctl & ~OHCI_HCFS_MASK) | OHCI_HCFS_OPERATIONAL; + OWRITE4(sc, OHCI_CONTROL, ctl); + usb_delay_ms(&sc->sc_bus, USB_RESUME_RECOVERY); + sc->sc_control = sc->sc_intre = 0; + sc->sc_bus.use_polling--; + + return true; +} + +bool +ohci_suspend(device_t dv) +{ + ohci_softc_t *sc = device_private(dv); + uint32_t ctl; + int s; s = splhardusb(); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: - sc->sc_bus.use_polling++; - ctl = OREAD4(sc, OHCI_CONTROL) & ~OHCI_HCFS_MASK; - if (sc->sc_control == 0) { - /* - * Preserve register values, in case that APM BIOS - * does not recover them. - */ - sc->sc_control = ctl; - sc->sc_intre = OREAD4(sc, OHCI_INTERRUPT_ENABLE); - } - ctl |= OHCI_HCFS_SUSPEND; - OWRITE4(sc, OHCI_CONTROL, ctl); - usb_delay_ms(&sc->sc_bus, USB_RESUME_WAIT); - sc->sc_bus.use_polling--; - break; - case PWR_RESUME: - sc->sc_bus.use_polling++; - /* Some broken BIOSes do not recover these values */ - OWRITE4(sc, OHCI_HCCA, DMAADDR(&sc->sc_hccadma, 0)); - OWRITE4(sc, OHCI_CONTROL_HEAD_ED, sc->sc_ctrl_head->physaddr); - OWRITE4(sc, OHCI_BULK_HEAD_ED, sc->sc_bulk_head->physaddr); - if (sc->sc_intre) - OWRITE4(sc, OHCI_INTERRUPT_ENABLE, - sc->sc_intre & (OHCI_ALL_INTRS | OHCI_MIE)); - if (sc->sc_control) - ctl = sc->sc_control; - else - ctl = OREAD4(sc, OHCI_CONTROL); - ctl |= OHCI_HCFS_RESUME; - OWRITE4(sc, OHCI_CONTROL, ctl); - usb_delay_ms(&sc->sc_bus, USB_RESUME_DELAY); - ctl = (ctl & ~OHCI_HCFS_MASK) | OHCI_HCFS_OPERATIONAL; - OWRITE4(sc, OHCI_CONTROL, ctl); - usb_delay_ms(&sc->sc_bus, USB_RESUME_RECOVERY); - sc->sc_control = sc->sc_intre = 0; - sc->sc_bus.use_polling--; - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; + sc->sc_bus.use_polling++; + ctl = OREAD4(sc, OHCI_CONTROL) & ~OHCI_HCFS_MASK; + if (sc->sc_control == 0) { + /* + * Preserve register values, in case that BIOS + * does not recover them. + */ + sc->sc_control = ctl; + sc->sc_intre = OREAD4(sc, + OHCI_INTERRUPT_ENABLE); } + ctl |= OHCI_HCFS_SUSPEND; + OWRITE4(sc, OHCI_CONTROL, ctl); + usb_delay_ms(&sc->sc_bus, USB_RESUME_WAIT); + sc->sc_bus.use_polling--; splx(s); + + return true; } #ifdef OHCI_DEBUG @@ -1133,7 +1123,7 @@ ohci_intr(void *p) { ohci_softc_t *sc = p; - if (sc == NULL || sc->sc_dying) + if (sc == NULL || sc->sc_dying || !device_has_power(&sc->sc_bus.bdev)) return (0); /* If we get an interrupt while polling, then just ignore it. */ diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h index 7130e24f186..269482fd16b 100644 --- a/sys/dev/usb/ohcivar.h +++ b/sys/dev/usb/ohcivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: ohcivar.h,v 1.39 2005/12/27 04:06:45 chs Exp $ */ +/* $NetBSD: ohcivar.h,v 1.40 2007/12/09 20:28:24 jmcneill Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohcivar.h,v 1.13 1999/11/17 22:33:41 n_hibma Exp $ */ /* @@ -155,3 +155,5 @@ int ohci_intr(void *); int ohci_detach(ohci_softc_t *, int); int ohci_activate(device_ptr_t, enum devact); #endif +bool ohci_resume(device_t); +bool ohci_suspend(device_t); diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 7e9ccb07dc6..6994dae5eae 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -1,4 +1,4 @@ -/* $NetBSD: ugen.c,v 1.94 2007/12/05 17:19:55 pooka Exp $ */ +/* $NetBSD: ugen.c,v 1.95 2007/12/09 20:28:24 jmcneill Exp $ */ /* * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. @@ -44,7 +44,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.94 2007/12/05 17:19:55 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.95 2007/12/09 20:28:24 jmcneill Exp $"); #include "opt_ugen_bulk_ra_wb.h" #include "opt_compat_netbsd.h" @@ -271,6 +271,9 @@ USB_ATTACH(ugen) usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, USBDEV(sc->sc_dev)); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + USB_ATTACH_SUCCESS_RETURN; } diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index 5827659be8c..7c039bcd10a 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $NetBSD: uhci.c,v 1.211 2007/10/19 12:01:22 ad Exp $ */ +/* $NetBSD: uhci.c,v 1.212 2007/12/09 20:28:24 jmcneill Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ /* @@ -49,7 +49,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.211 2007/10/19 12:01:22 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.212 2007/12/09 20:28:24 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -165,8 +165,6 @@ struct uhci_pipe { Static void uhci_globalreset(uhci_softc_t *); Static usbd_status uhci_portreset(uhci_softc_t*, int); Static void uhci_reset(uhci_softc_t *); -Static void uhci_shutdown(void *v); -Static void uhci_power(int, void *); Static usbd_status uhci_run(uhci_softc_t *, int run); Static uhci_soft_td_t *uhci_alloc_std(uhci_softc_t *); Static void uhci_free_std(uhci_softc_t *, uhci_soft_td_t *); @@ -545,13 +543,6 @@ uhci_init(uhci_softc_t *sc) sc->sc_bus.methods = &uhci_bus_methods; sc->sc_bus.pipe_size = sizeof(struct uhci_pipe); -#if defined(__NetBSD__) || defined(__OpenBSD__) - sc->sc_suspend = PWR_RESUME; - sc->sc_powerhook = powerhook_establish(USBDEVNAME(sc->sc_bus.bdev), - uhci_power, sc); - sc->sc_shutdownhook = shutdownhook_establish(uhci_shutdown, sc); -#endif - UHCICMD(sc, UHCI_CMD_MAXP); /* Assume 64 byte packets at frame end */ DPRINTFN(1,("uhci_init: enabling\n")); @@ -593,11 +584,6 @@ uhci_detach(struct uhci_softc *sc, int flags) if (rv != 0) return (rv); -#if defined(__NetBSD__) || defined(__OpenBSD__) - powerhook_disestablish(sc->sc_powerhook); - shutdownhook_disestablish(sc->sc_shutdownhook); -#endif - /* Free all xfers associated with this HC. */ for (;;) { xfer = SIMPLEQ_FIRST(&sc->sc_free_xfers); @@ -712,111 +698,88 @@ uhci_freex(struct usbd_bus *bus, usbd_xfer_handle xfer) } /* - * Shut down the controller when the system is going down. + * Handle suspend/resume. + * + * We need to switch to polling mode here, because this routine is + * called from an interrupt context. This is all right since we + * are almost suspended anyway. */ -void -uhci_shutdown(void *v) +bool +uhci_resume(device_t dv) { - uhci_softc_t *sc = v; + uhci_softc_t *sc = device_private(dv); + int cmd; int s; - DPRINTF(("uhci_shutdown: stopping the HC\n")); - - /* - * Use polling mode to prevent the interrupts shutting - * us down before we shut them down. - */ s = splhardusb(); + + cmd = UREAD2(sc, UHCI_CMD); sc->sc_bus.use_polling++; - uhci_run(sc, 0); /* stop the controller */ + if (cmd & UHCI_CMD_RS) + uhci_run(sc, 0); + + /* restore saved state */ + UWRITE4(sc, UHCI_FLBASEADDR, DMAADDR(&sc->sc_dma, 0)); + UWRITE2(sc, UHCI_FRNUM, sc->sc_saved_frnum); + UWRITE1(sc, UHCI_SOF, sc->sc_saved_sof); + + UHCICMD(sc, cmd | UHCI_CMD_FGR); /* force resume */ + usb_delay_ms(&sc->sc_bus, USB_RESUME_DELAY); + UHCICMD(sc, cmd & ~UHCI_CMD_EGSM); /* back to normal */ + UHCICMD(sc, UHCI_CMD_MAXP); + UWRITE2(sc, UHCI_INTR, UHCI_INTR_TOCRCIE | + UHCI_INTR_RIE | UHCI_INTR_IOCE | UHCI_INTR_SPIE); + uhci_run(sc, 1); /* and start traffic again */ + usb_delay_ms(&sc->sc_bus, USB_RESUME_RECOVERY); sc->sc_bus.use_polling--; + if (sc->sc_intr_xfer != NULL) + usb_callout(sc->sc_poll_handle, sc->sc_ival, uhci_poll_hub, + sc->sc_intr_xfer); +#ifdef UHCI_DEBUG + if (uhcidebug > 2) + uhci_dumpregs(sc); +#endif + splx(s); + + return true; } -/* - * Handle suspend/resume. - * - * We need to switch to polling mode here, because this routine is - * called from an interrupt context. This is all right since we - * are almost suspended anyway. - */ -void -uhci_power(int why, void *v) +bool +uhci_suspend(device_t dv) { - uhci_softc_t *sc = v; + uhci_softc_t *sc = device_private(dv); int cmd; int s; s = splhardusb(); - cmd = UREAD2(sc, UHCI_CMD); - DPRINTF(("uhci_power: sc=%p, why=%d (was %d), cmd=0x%x\n", - sc, why, sc->sc_suspend, cmd)); + cmd = UREAD2(sc, UHCI_CMD); - switch (why) { - case PWR_SUSPEND: - case PWR_STANDBY: #ifdef UHCI_DEBUG - if (uhcidebug > 2) - uhci_dumpregs(sc); -#endif - if (sc->sc_intr_xfer != NULL) - usb_uncallout(sc->sc_poll_handle, uhci_poll_hub, - sc->sc_intr_xfer); - sc->sc_bus.use_polling++; - uhci_run(sc, 0); /* stop the controller */ - cmd &= ~UHCI_CMD_RS; + if (uhcidebug > 2) + uhci_dumpregs(sc); +#endif + if (sc->sc_intr_xfer != NULL) + usb_uncallout(sc->sc_poll_handle, uhci_poll_hub, + sc->sc_intr_xfer); + sc->sc_bus.use_polling++; + uhci_run(sc, 0); /* stop the controller */ + cmd &= ~UHCI_CMD_RS; - /* save some state if BIOS doesn't */ - sc->sc_saved_frnum = UREAD2(sc, UHCI_FRNUM); - sc->sc_saved_sof = UREAD1(sc, UHCI_SOF); + /* save some state if BIOS doesn't */ + sc->sc_saved_frnum = UREAD2(sc, UHCI_FRNUM); + sc->sc_saved_sof = UREAD1(sc, UHCI_SOF); - UWRITE2(sc, UHCI_INTR, 0); /* disable intrs */ + UWRITE2(sc, UHCI_INTR, 0); /* disable intrs */ + + UHCICMD(sc, cmd | UHCI_CMD_EGSM); /* enter suspend */ + usb_delay_ms(&sc->sc_bus, USB_RESUME_WAIT); + sc->sc_bus.use_polling--; - UHCICMD(sc, cmd | UHCI_CMD_EGSM); /* enter global suspend */ - usb_delay_ms(&sc->sc_bus, USB_RESUME_WAIT); - sc->sc_suspend = why; - sc->sc_bus.use_polling--; - DPRINTF(("uhci_power: cmd=0x%x\n", UREAD2(sc, UHCI_CMD))); - break; - case PWR_RESUME: -#ifdef DIAGNOSTIC - if (sc->sc_suspend == PWR_RESUME) - printf("uhci_power: weird, resume without suspend.\n"); -#endif - sc->sc_bus.use_polling++; - sc->sc_suspend = why; - if (cmd & UHCI_CMD_RS) - uhci_run(sc, 0); /* in case BIOS has started it */ - - /* restore saved state */ - UWRITE4(sc, UHCI_FLBASEADDR, DMAADDR(&sc->sc_dma, 0)); - UWRITE2(sc, UHCI_FRNUM, sc->sc_saved_frnum); - UWRITE1(sc, UHCI_SOF, sc->sc_saved_sof); - - UHCICMD(sc, cmd | UHCI_CMD_FGR); /* force global resume */ - usb_delay_ms(&sc->sc_bus, USB_RESUME_DELAY); - UHCICMD(sc, cmd & ~UHCI_CMD_EGSM); /* back to normal */ - UHCICMD(sc, UHCI_CMD_MAXP); - UWRITE2(sc, UHCI_INTR, UHCI_INTR_TOCRCIE | UHCI_INTR_RIE | - UHCI_INTR_IOCE | UHCI_INTR_SPIE); /* re-enable intrs */ - uhci_run(sc, 1); /* and start traffic again */ - usb_delay_ms(&sc->sc_bus, USB_RESUME_RECOVERY); - sc->sc_bus.use_polling--; - if (sc->sc_intr_xfer != NULL) - usb_callout(sc->sc_poll_handle, sc->sc_ival, - uhci_poll_hub, sc->sc_intr_xfer); -#ifdef UHCI_DEBUG - if (uhcidebug > 2) - uhci_dumpregs(sc); -#endif - break; - case PWR_SOFTSUSPEND: - case PWR_SOFTSTANDBY: - case PWR_SOFTRESUME: - break; - } splx(s); + + return true; } #ifdef UHCI_DEBUG @@ -1226,7 +1189,7 @@ uhci_intr(void *arg) { uhci_softc_t *sc = arg; - if (sc->sc_dying) + if (sc->sc_dying || !device_has_power(&sc->sc_bus.bdev)) return (0); if (sc->sc_bus.use_polling) { diff --git a/sys/dev/usb/uhcivar.h b/sys/dev/usb/uhcivar.h index b0ddd3c45fa..436ff437d02 100644 --- a/sys/dev/usb/uhcivar.h +++ b/sys/dev/usb/uhcivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: uhcivar.h,v 1.40 2005/12/27 04:06:45 chs Exp $ */ +/* $NetBSD: uhcivar.h,v 1.41 2007/12/09 20:28:24 jmcneill Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhcivar.h,v 1.14 1999/11/17 22:33:42 n_hibma Exp $ */ /* @@ -177,9 +177,6 @@ typedef struct uhci_softc { char sc_vendor[32]; /* vendor string for root hub */ int sc_id_vendor; /* vendor ID for root hub */ - void *sc_powerhook; /* cookie from power hook */ - void *sc_shutdownhook; /* cookie from shutdown hook */ - #if defined(__NetBSD__) || defined(__OpenBSD__) device_ptr_t sc_child; /* /dev/usb# device */ #endif @@ -193,5 +190,7 @@ int uhci_intr(void *); #if defined(__NetBSD__) || defined(__OpenBSD__) int uhci_detach(uhci_softc_t *, int); int uhci_activate(device_ptr_t, enum devact); +bool uhci_resume(device_t); +bool uhci_suspend(device_t); #endif diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c index ee93d521354..d4a2f04b955 100644 --- a/sys/dev/usb/uhub.c +++ b/sys/dev/usb/uhub.c @@ -1,4 +1,4 @@ -/* $NetBSD: uhub.c,v 1.91 2007/12/01 04:50:50 jmcneill Exp $ */ +/* $NetBSD: uhub.c,v 1.92 2007/12/09 20:28:24 jmcneill Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */ /* @@ -43,7 +43,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.91 2007/12/01 04:50:50 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.92 2007/12/09 20:28:24 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -358,6 +358,9 @@ USB_ATTACH(uhub) sc->sc_running = 1; + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + USB_ATTACH_SUCCESS_RETURN; bad: diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c index 507c3f75445..e2fc01bc9cf 100644 --- a/sys/dev/usb/umass.c +++ b/sys/dev/usb/umass.c @@ -1,4 +1,4 @@ -/* $NetBSD: umass.c,v 1.124 2007/03/13 13:51:56 drochner Exp $ */ +/* $NetBSD: umass.c,v 1.125 2007/12/09 20:28:24 jmcneill Exp $ */ /* * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -131,7 +131,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.124 2007/03/13 13:51:56 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.125 2007/12/09 20:28:24 jmcneill Exp $"); #include "atapibus.h" #include "scsibus.h" @@ -636,6 +636,9 @@ USB_ATTACH(umass) usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, USBDEV(sc->sc_dev)); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + DPRINTF(UDMASS_GEN, ("%s: Attach finished\n", USBDEVNAME(sc->sc_dev))); USB_ATTACH_SUCCESS_RETURN; @@ -649,6 +652,8 @@ USB_DETACH(umass) DPRINTF(UDMASS_USB, ("%s: detached\n", USBDEVNAME(sc->sc_dev))); + pmf_device_deregister(self); + /* Abort the pipes to wake up any waiting processes. */ for (i = 0 ; i < UMASS_NEP ; i++) { if (sc->sc_pipe[i] != NULL) diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 7e714fd663a..f665ea7345a 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $NetBSD: usb.c,v 1.103 2007/12/05 17:19:56 pooka Exp $ */ +/* $NetBSD: usb.c,v 1.104 2007/12/09 20:28:25 jmcneill Exp $ */ /* * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc. @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.103 2007/12/05 17:19:56 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.104 2007/12/09 20:28:25 jmcneill Exp $"); #include "opt_compat_netbsd.h" @@ -248,6 +248,9 @@ USB_ATTACH(usb) config_pending_incr(); usb_kthread_create(usb_create_event_thread, sc); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + USB_ATTACH_SUCCESS_RETURN; } diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c index 3e46ba7af52..a1715d68a13 100644 --- a/sys/dev/wscons/wsdisplay.c +++ b/sys/dev/wscons/wsdisplay.c @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay.c,v 1.112 2007/11/19 18:51:51 ad Exp $ */ +/* $NetBSD: wsdisplay.c,v 1.113 2007/12/09 20:28:25 jmcneill Exp $ */ /* * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.112 2007/11/19 18:51:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.113 2007/12/09 20:28:25 jmcneill Exp $"); #include "opt_wsdisplay_compat.h" #include "opt_wsmsgattrs.h" @@ -108,6 +108,7 @@ static void wsdisplay_shutdownhook(void *); static void wsdisplay_addscreen_print(struct wsdisplay_softc *, int, int); static void wsdisplay_closescreen(struct wsdisplay_softc *, struct wsscreen *); int wsdisplay_delscreen(struct wsdisplay_softc *, int, int); +static void wsdisplay_switchto(int); #define WSDISPLAY_MAXSCREEN 8 @@ -158,10 +159,12 @@ static int wsdisplay_emul_match(device_t , struct cfdata *, void *); static void wsdisplay_emul_attach(device_t, device_t, void *); static int wsdisplay_noemul_match(device_t, struct cfdata *, void *); static void wsdisplay_noemul_attach(device_t, device_t, void *); +static bool wsdisplay_resume(device_t dv); +static bool wsdisplay_suspend(device_t dv); CFATTACH_DECL_NEW(wsdisplay_emul, sizeof (struct wsdisplay_softc), wsdisplay_emul_match, wsdisplay_emul_attach, NULL, NULL); - + CFATTACH_DECL_NEW(wsdisplay_noemul, sizeof (struct wsdisplay_softc), wsdisplay_noemul_match, wsdisplay_noemul_attach, NULL, NULL); @@ -598,6 +601,21 @@ wsdisplay_noemul_attach(device_t parent, device_t self, void *aux) ap->accessops, ap->accesscookie); } +static bool +wsdisplay_suspend(device_t dv) +{ + wsdisplay_switchtoconsole(); + + return true; +} + +static bool +wsdisplay_resume(device_t dv) +{ + + return true; +} + /* Print function (for parent devices). */ int wsdisplaydevprint(void *aux, const char *pnp) @@ -696,6 +714,9 @@ wsdisplay_common_attach(struct wsdisplay_softc *sc, int console, int kbdmux, if (i > start) wsdisplay_addscreen_print(sc, start, i-start); + if (!pmf_device_register(sc->sc_dev, wsdisplay_suspend, wsdisplay_resume)) + aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n"); + if (hookset == 0) shutdownhook_establish(wsdisplay_shutdownhook, NULL); hookset = 1; @@ -2057,18 +2078,15 @@ wsdisplay_unset_cons_kbd(void) wsdisplay_cons_kbd_pollc = 0; } -/* - * Switch the console display to it's first screen. - */ -void -wsdisplay_switchtoconsole(void) +static void +wsdisplay_switchto(int no) { struct wsdisplay_softc *sc; struct wsscreen *scr; if (wsdisplay_console_device != NULL) { sc = wsdisplay_console_device; - if ((scr = sc->sc_scr[0]) == NULL) + if ((scr = sc->sc_scr[no]) == NULL) return; (*sc->sc_accessops->show_screen)(sc->sc_accesscookie, scr->scr_dconf->emulcookie, @@ -2077,6 +2095,15 @@ wsdisplay_switchtoconsole(void) } /* + * Switch the console display to it's first screen. + */ +void +wsdisplay_switchtoconsole(void) +{ + wsdisplay_switchto(0); +} + +/* * Switch the console at shutdown. */ static void diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c index cc154617c6d..42abfce3b8a 100644 --- a/sys/dev/wscons/wskbd.c +++ b/sys/dev/wscons/wskbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: wskbd.c,v 1.108 2007/12/01 05:22:02 jmcneill Exp $ */ +/* $NetBSD: wskbd.c,v 1.109 2007/12/09 20:28:25 jmcneill Exp $ */ /* * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.108 2007/12/01 05:22:02 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.109 2007/12/09 20:28:25 jmcneill Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -464,6 +464,11 @@ wskbd_attach(struct device *parent, struct device *self, void *aux) sc->sc_base.me_dv.dv_xname, error); } #endif + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + else if (!pmf_class_input_register(self)) + aprint_error_dev(self, "couldn't register as input device\n"); } void @@ -620,6 +625,8 @@ wskbd_input(struct device *dev, u_int type, int value) callout_stop(&sc->sc_repeat_ch); } + device_active(dev, DVA_HARDWARE); + #if NWSDISPLAY > 0 /* * If /dev/wskbdN is not connected in event mode translate and @@ -689,7 +696,7 @@ wskbd_deliver_event(struct wskbd_softc *sc, u_int type, int value) return; } #endif - + event.type = type; event.value = value; if (wsevent_inject(evar, &event, 1) != 0) @@ -1453,6 +1460,18 @@ internal_command(struct wskbd_softc *sc, u_int *type, keysym_t ksym, u_int state = 0; #endif switch (ksym) { + case KS_Cmd_VolumeToggle: + if (*type == WSCONS_EVENT_KEY_DOWN) + pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_TOGGLE); + break; + case KS_Cmd_VolumeUp: + if (*type == WSCONS_EVENT_KEY_DOWN) + pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_UP); + break; + case KS_Cmd_VolumeDown: + if (*type == WSCONS_EVENT_KEY_DOWN) + pmf_event_inject(NULL, PMFE_AUDIO_VOLUME_DOWN); + break; #ifdef WSDISPLAY_SCROLLSUPPORT case KS_Cmd_ScrollFastUp: case KS_Cmd_ScrollFastDown: diff --git a/sys/dev/wscons/wsksymdef.h b/sys/dev/wscons/wsksymdef.h index 8bc48f04924..1d082521a87 100644 --- a/sys/dev/wscons/wsksymdef.h +++ b/sys/dev/wscons/wsksymdef.h @@ -1,4 +1,4 @@ -/* $NetBSD: wsksymdef.h,v 1.58 2007/04/04 14:50:21 mishka Exp $ */ +/* $NetBSD: wsksymdef.h,v 1.59 2007/12/09 20:28:25 jmcneill Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -524,6 +524,9 @@ #define KS_Cmd_ScrollFastDown 0xf42d #define KS_Cmd_ScrollSlowUp 0xf42e #define KS_Cmd_ScrollSlowDown 0xf42f +#define KS_Cmd_VolumeUp 0xf430 +#define KS_Cmd_VolumeDown 0xf431 +#define KS_Cmd_VolumeToggle 0xf432 /* * Group 5 (internal) diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c index 05bab1a2ebe..4b8cd0616fa 100644 --- a/sys/dev/wscons/wsmouse.c +++ b/sys/dev/wscons/wsmouse.c @@ -1,4 +1,4 @@ -/* $NetBSD: wsmouse.c,v 1.54 2007/12/01 05:40:44 jmcneill Exp $ */ +/* $NetBSD: wsmouse.c,v 1.55 2007/12/09 20:28:25 jmcneill Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -111,7 +111,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.54 2007/12/01 05:40:44 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wsmouse.c,v 1.55 2007/12/09 20:28:25 jmcneill Exp $"); #include "wsmouse.h" #include "wsdisplay.h" @@ -275,6 +275,9 @@ wsmouse_attach(struct device *parent, struct device *self, void *aux) aprint_naive("\n"); aprint_normal("\n"); + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); } int diff --git a/sys/dist/acpica/CHANGES.txt b/sys/dist/acpica/CHANGES.txt new file mode 100644 index 00000000000..f26ed47d97f --- /dev/null +++ b/sys/dist/acpica/CHANGES.txt @@ -0,0 +1,8448 @@ +---------------------------------------- +20 March 2007. Summary of changes for version 20070320: + +1) ACPI CA Core Subsystem: + +Implemented a change to the order of interpretation and +evaluation of AML operand objects within the AML interpreter. The +interpreter now evaluates operands in the order that they appear +in the AML stream (and the corresponding ASL code), instead of in +the reverse order (after the entire operand list has been +parsed). The previous behavior caused several subtle +incompatibilities with the Microsoft AML interpreter as well as +being somewhat non-intuitive. BZ 7871, local BZ 263. Valery +Podrezov. + +Implemented a change to the ACPI Global Lock support. All +interfaces to the global lock now allow the same thread to +acquire the lock multiple times. This affects the +AcpiAcquireGlobalLock external interface to the global lock as +well as the internal use of the global lock to support AML fields +-- a control method that is holding the global lock can now +simultaneously access AML fields that require global lock +protection. Previously, in both cases, this would have resulted +in an AE_ALREADY_ACQUIRED exception. The change to +AcpiAcquireGlobalLock is of special interest to drivers for the +Embedded Controller. There is no change to the behavior of the +AML Acquire operator, as this can already be used to acquire a +mutex multiple times by the same thread. BZ 8066. With assistance +from Alexey Starikovskiy. + +Fixed a problem where invalid objects could be referenced in the +AML Interpreter after error conditions. During operand +evaluation, ensure that the internal "Return Object" field is +cleared on error and only valid pointers are stored there. Caused +occasional access to deleted objects that resulted in "large +reference count" warning messages. Valery Podrezov. + +Fixed a problem where an AE_STACK_OVERFLOW internal exception +could occur on deeply nested control method invocations. BZ 7873, +local BZ 487. Valery Podrezov. + +Fixed an internal problem with the handling of result objects on +the interpreter result stack. BZ 7872. Valery Podrezov. + +Removed obsolete code that handled the case where AML_NAME_OP is +the target of a reference (Reference.Opcode). This code was no +longer necessary. BZ 7874. Valery Podrezov. + +Removed obsolete ACPI_NO_INTEGER64_SUPPORT from two header files. +This was a remnant from the previously discontinued 16-bit +support. + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 78.0K Code, 17.1K Data, 95.1K Total + Debug Version: 155.8K Code, 63.3K Data, 219.1K Total + Current Release: + Non-Debug Version: 78.0K Code, 17.1K Data, 95.1K Total + Debug Version: 155.9K Code, 63.1K Data, 219.0K Total + +---------------------------------------- +26 January 2007. Summary of changes for version 20070126: + +1) ACPI CA Core Subsystem: + +Added the 2007 copyright to all module headers and signons. This +affects virtually every file in the ACPICA core subsystem, the +iASL compiler, and the utilities. + +Implemented a fix for an incorrect parameter passed to +AcpiTbDeleteTable during a table load. A bad pointer was passed +in the case where the DSDT is overridden, causing a fault in this +case. + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 78.0K Code, 17.1K Data, 95.1K Total + Debug Version: 155.8K Code, 63.3K Data, 219.1K Total + Current Release: + Non-Debug Version: 78.0K Code, 17.1K Data, 95.1K Total + Debug Version: 155.8K Code, 63.3K Data, 219.1K Total + +---------------------------------------- +15 December 2006. Summary of changes for version 20061215: + +1) ACPI CA Core Subsystem: + +Support for 16-bit ACPICA has been completely removed since it is +no longer necessary and it clutters the code. All 16-bit macros, +types, and conditional compiles have been removed, cleaning up +and simplifying the code across the entire subsystem. DOS support +is no longer needed since the bootable Linux firmware kit is now +available. + +The handler for the Global Lock is now removed during +AcpiTerminate to enable a clean subsystem restart, via the +implementation of the AcpiEvRemoveGlobalLockHandler function. +(With assistance from Joel Bretz, HP) + +Implemented enhancements to the multithreading support within the +debugger to enable improved multithreading debugging and +evaluation of the subsystem. (Valery Podrezov) + +Debugger: Enhanced the Statistics/Memory command to emit the +total (maximum) memory used during the execution, as well as the +maximum memory consumed by each of the various object types. +(Valery Podrezov) + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 77.9K Code, 17.0K Data, 94.9K Total + Debug Version: 155.2K Code, 63.1K Data, 218.3K Total + Current Release: + Non-Debug Version: 78.0K Code, 17.1K Data, 95.1K Total + Debug Version: 155.8K Code, 63.3K Data, 219.1K Total + + +2) iASL Compiler/Disassembler and Tools: + +AcpiExec: Implemented a new option (-m) to display full memory +use statistics upon subsystem/program termination. (Valery +Podrezov) + +---------------------------------------- +09 November 2006. Summary of changes for version 20061109: + +1) ACPI CA Core Subsystem: + +Optimized the Load ASL operator in the case where the source +operand is an operation region. Simply map the operation region +memory, instead of performing a bytewise read. (Region must be of +type SystemMemory, see below.) + +Fixed the Load ASL operator for the case where the source operand +is a region field. A buffer object is also allowed as the source +operand. BZ 480 + +Fixed a problem where the Load ASL operator allowed the source +operand to be an operation region of any type. It is now +restricted to regions of type SystemMemory, as per the ACPI +specification. BZ 481 + +Additional cleanup and optimizations for the new Table Manager +code. + +AcpiEnable will now fail if all of the required ACPI tables are +not loaded (FADT, FACS, DSDT). BZ 477 + +Added #pragma pack(8/4) to acobject.h to ensure that the +structures in this header are always compiled as aligned. The +ACPI_OPERAND_OBJECT has been manually optimized to be aligned and +will not work if it is byte-packed. + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 78.1K Code, 17.1K Data, 95.2K Total + Debug Version: 155.4K Code, 63.1K Data, 218.5K Total + Current Release: + Non-Debug Version: 77.9K Code, 17.0K Data, 94.9K Total + Debug Version: 155.2K Code, 63.1K Data, 218.3K Total + + +2) iASL Compiler/Disassembler and Tools: + +Fixed a problem where the presence of the _OSI predefined control +method within complex expressions could cause an internal +compiler error. + +AcpiExec: Implemented full region support for multiple address +spaces. SpaceId is now part of the REGION object. BZ 429 + +---------------------------------------- +11 October 2006. Summary of changes for version 20061011: + +1) ACPI CA Core Subsystem: + +Completed an AML interpreter performance enhancement for control +method execution. Previously a 2-pass parse/execution, control +methods are now completely parsed and executed in a single pass. +This improves overall interpreter performance by ~25%, reduces +code size, and reduces CPU stack use. (Valery Podrezov + +interpreter changes in version 20051202 that eliminated namespace +loading during the pass one parse.) + +Implemented _CID support for PCI Root Bridge detection. If the +_HID does not match the predefined PCI Root Bridge IDs, the _CID +list (if present) is now obtained and also checked for an ID +match. + +Implemented additional support for the PCI _ADR execution: +upsearch until a device scope is found before executing _ADR. +This allows PCI_Config operation regions to be declared locally +within control methods underneath PCI device objects. + +Fixed a problem with a possible race condition between threads +executing AcpiWalkNamespace and the AML interpreter. This +condition was removed by modifying AcpiWalkNamespace to (by +default) ignore all temporary namespace entries created during +any concurrent control method execution. An additional namespace +race condition is known to exist between AcpiWalkNamespace and +the Load/Unload ASL operators and is still under investigation. + +Restructured the AML ParseLoop function, breaking it into several +subfunctions in order to reduce CPU stack use and improve +maintainability. (Mikhail Kouzmich) + +AcpiGetHandle: Fix for parameter validation to detect invalid +combinations of prefix handle and pathname. BZ 478 + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 77.9K Code, 17.1K Data, 95.0K Total + Debug Version: 154.6K Code, 63.0K Data, 217.6K Total + Current Release: + Non-Debug Version: 78.1K Code, 17.1K Data, 95.2K Total + Debug Version: 155.4K Code, 63.1K Data, 218.5K Total + +2) iASL Compiler/Disassembler and Tools: + +Ported the -g option (get local ACPI tables) to the new ACPICA +Table Manager to restore original behavior. + +---------------------------------------- +27 September 2006. Summary of changes for version 20060927: + +1) ACPI CA Core Subsystem: + +Removed the "Flags" parameter from AcpiGetRegister and +AcpiSetRegister. These functions now use a spinlock for mutual +exclusion and the interrupt level indication flag is not needed. + +Fixed a problem with the Global Lock where the lock could appear +to be obtained before it is actually obtained. The global lock +semaphore was inadvertently created with one unit instead of zero +units. (BZ 464) Fiodor Suietov. + +Fixed a possible memory leak and fault in +AcpiExResolveObjectToValue during a read from a buffer or region +field. (BZ 458) Fiodor Suietov. + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 77.9K Code, 17.1K Data, 95.0K Total + Debug Version: 154.7K Code, 63.0K Data, 217.7K Total + Current Release: + Non-Debug Version: 77.9K Code, 17.1K Data, 95.0K Total + Debug Version: 154.6K Code, 63.0K Data, 217.6K Total + + +2) iASL Compiler/Disassembler and Tools: + +Fixed a compilation problem with the pre-defined Resource +Descriptor field names where an "object does not exist" error +could be incorrectly generated if the parent ResourceTemplate +pathname places the template within a different namespace scope +than the current scope. (BZ 7212) + +Fixed a problem where the compiler could hang after syntax errors +detected in an ElseIf construct. (BZ 453) + +Fixed a problem with the AmlFilename parameter to the +DefinitionBlock() operator. An incorrect output filename was +produced when this parameter was a null string (""). Now, the +original input filename is used as the AML output filename, with +an ".aml" extension. + +Implemented a generic batch command mode for the AcpiExec utility +(execute any AML debugger command) (Valery Podrezov). + +---------------------------------------- +12 September 2006. Summary of changes for version 20060912: + +1) ACPI CA Core Subsystem: + +Enhanced the implementation of the "serialized mode" of the +interpreter (enabled via the AcpiGbl_AllMethodsSerialized flag.) +When this mode is specified, instead of creating a serialization +semaphore per control method, the interpreter lock is simply no +longer released before a blocking operation during control method +execution. This effectively makes the AML Interpreter single- +threaded. The overhead of a semaphore per-method is eliminated. + +Fixed a regression where an error was no longer emitted if a +control method attempts to create 2 objects of the same name. +This once again returns AE_ALREADY_EXISTS. When this exception +occurs, it invokes the mechanism that will dynamically serialize +the control method to possible prevent future errors. (BZ 440) + +Integrated a fix for a problem with PCI Express HID detection in +the PCI Config Space setup procedure. (BZ 7145) + +Moved all FADT-related functions to a new file, tbfadt.c. +Eliminated the AcpiHwInitialize function - the FADT registers are +now validated when the table is loaded. + +Added two new warnings during FADT verification - 1) if the FADT +is larger than the largest known FADT version, and 2) if there is +a mismatch between a 32-bit block address and the 64-bit X +counterpart (when both are non-zero.) + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 77.9K Code, 16.7K Data, 94.6K Total + Debug Version: 154.9K Code, 62.6K Data, 217.5K Total + Current Release: + Non-Debug Version: 77.9K Code, 17.1K Data, 95.0K Total + Debug Version: 154.7K Code, 63.0K Data, 217.7K Total + + +2) iASL Compiler/Disassembler and Tools: + +Fixed a problem with the implementation of the Switch() operator +where the temporary variable was declared too close to the actual +Switch, instead of at method level. This could cause a problem if +the Switch() operator is within a while loop, causing an error on +the second iteration. (BZ 460) + +Disassembler - fix for error emitted for unknown type for target +of scope operator. Now, ignore it and continue. + +Disassembly of an FADT now verifies the input FADT and reports +any errors found. Fix for proper disassembly of full-sized (ACPI +2.0) FADTs. + +Disassembly of raw data buffers with byte initialization data now +prefixes each output line with the current buffer offset. + +Disassembly of ASF! table now includes all variable-length data +fields at the end of some of the subtables. + +The disassembler now emits a comment if a buffer appears to be a +ResourceTemplate, but cannot be disassembled as such because the +EndTag does not appear at the very end of the buffer. + +AcpiExec - Added the "-t" command line option to enable the +serialized mode of the AML interpreter. + +---------------------------------------- +31 August 2006. Summary of changes for version 20060831: + +1) ACPI CA Core Subsystem: + +Miscellaneous fixes for the Table Manager: +- Correctly initialize internal common FADT for all 64-bit "X" +fields +- Fixed a couple table mapping issues during table load +- Fixed a couple alignment issues for IA64 +- Initialize input array to zero in AcpiInitializeTables +- Additional parameter validation for AcpiGetTable, +AcpiGetTableHeader, AcpiGetTableByIndex + +Change for GPE support: when a "wake" GPE is received, all wake +GPEs are now immediately disabled to prevent the waking GPE from +firing again and to prevent other wake GPEs from interrupting the +wake process. + +Added the AcpiGpeCount global that tracks the number of processed +GPEs, to be used for debugging systems with a large number of +ACPI interrupts. + +Implemented support for the "DMAR" ACPI table (DMA Redirection +Table) in both the ACPICA headers and the disassembler. + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 77.8K Code, 16.5K Data, 94.3K Total + Debug Version: 154.6K Code, 62.3K Data, 216.9K Total + Current Release: + Non-Debug Version: 77.9K Code, 16.7K Data, 94.6K Total + Debug Version: 154.9K Code, 62.6K Data, 217.5K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler support for the DMAR ACPI table. + +---------------------------------------- +23 August 2006. Summary of changes for version 20060823: + +1) ACPI CA Core Subsystem: + +The Table Manager component has been completely redesigned and +reimplemented. The new design is much simpler, and reduces the +overall code and data size of the kernel-resident ACPICA by +approximately 5%. Also, it is now possible to obtain the ACPI +tables very early during kernel initialization, even before +dynamic memory management is initialized. (Alexey Starikovskiy, +Fiodor Suietov, Bob Moore) + +Obsolete ACPICA interfaces: + +- AcpiGetFirmwareTable: Use AcpiGetTable instead (works at early +kernel init time). +- AcpiLoadTable: Not needed. +- AcpiUnloadTable: Not needed. + +New ACPICA interfaces: + +- AcpiInitializeTables: Must be called before the table manager +can be used. +- AcpiReallocateRootTable: Used to transfer the root table to +dynamically allocated memory after it becomes available. +- AcpiGetTableByIndex: Allows the host to easily enumerate all +ACPI tables in the RSDT/XSDT. + +Other ACPICA changes: + +- AcpiGetTableHeader returns the actual mapped table header, not +a copy. Use AcpiOsUnmapMemory to free this mapping. +- AcpiGetTable returns the actual mapped table. The mapping is +managed internally and must not be deleted by the caller. Use of +this interface causes no additional dynamic memory allocation. +- AcpiFindRootPointer: Support for physical addressing has been +eliminated, it appeared to be unused. +- The interface to AcpiOsMapMemory has changed to be consistent +with the other allocation interfaces. +- The interface to AcpiOsGetRootPointer has changed to eliminate +unnecessary parameters. +- ACPI_PHYSICAL_ADDRESS is now 32 bits on 32-bit platforms, 64 +bits on 64-bit platforms. Was previously 64 bits on all +platforms. +- The interface to the ACPI Global Lock acquire/release macros +have changed slightly since ACPICA no longer keeps a local copy +of the FACS with a constructed pointer to the actual global lock. + +Porting to the new table manager: + +- AcpiInitializeTables: Must be called once, and can be called +anytime during the OS initialization process. It allows the host +to specify an area of memory to be used to store the internal +version of the RSDT/XSDT (root table). This allows the host to +access ACPI tables before memory management is initialized and +running. +- AcpiReallocateRootTable: Can be called after memory management +is running to copy the root table to a dynamically allocated +array, freeing up the scratch memory specified in the call to +AcpiInitializeTables. +- AcpiSubsystemInitialize: This existing interface is independent +of the Table Manager, and does not have to be called before the +Table Manager can be used, it only must be called before the rest +of ACPICA can be used. +- ACPI Tables: Some changes have been made to the names and +structure of the actbl.h and actbl1.h header files and may +require changes to existing code. For example, bitfields have +been completely removed because of their lack of portability +across C compilers. +- Update interfaces to the Global Lock acquire/release macros if +local versions are used. (see acwin.h) + +Obsolete files: tbconvrt.c, tbget.c, tbgetall.c, tbrsdt.c + +New files: tbfind.c + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 80.7K Code, 17.9K Data, 98.6K Total + Debug Version: 161.0K Code, 65.1K Data, 226.1K Total + Current Release: + Non-Debug Version: 77.8K Code, 16.5K Data, 94.3K Total + Debug Version: 154.6K Code, 62.3K Data, 216.9K Total + + +2) iASL Compiler/Disassembler and Tools: + +No changes for this release. + +---------------------------------------- +21 July 2006. Summary of changes for version 20060721: + +1) ACPI CA Core Subsystem: + +The full source code for the ASL test suite used to validate the +iASL compiler and the ACPICA core subsystem is being released +with the ACPICA source for the first time. The source is +contained in a separate package and consists of over 1100 files +that exercise all ASL/AML operators. The package should appear on +the Intel/ACPI web site shortly. (Valery Podrezov, Fiodor +Suietov) + +Completed a new design and implementation for support of the ACPI +Global Lock. On the OS side, the global lock is now treated as a +standard AML mutex. Previously, multiple OS threads could +"acquire" the global lock simultaneously. However, this could +cause the BIOS to be starved out of the lock - especially in +cases such as the Embedded Controller driver where there is a +tight coupling between the OS and the BIOS. + +Implemented an optimization for the ACPI Global Lock interrupt +mechanism. The Global Lock interrupt handler no longer queues the +execution of a separate thread to signal the global lock +semaphore. Instead, the semaphore is signaled directly from the +interrupt handler. + +Implemented support within the AML interpreter for package +objects that contain a larger AML length (package list length) +than the package element count. In this case, the length of the +package is truncated to match the package element count. Some +BIOS code apparently modifies the package length on the fly, and +this change supports this behavior. Provides compatibility with +the MS AML interpreter. (With assistance from Fiodor Suietov) + +Implemented a temporary fix for the BankValue parameter of a Bank +Field to support all constant values, now including the Zero and +One opcodes. Evaluation of this parameter must eventually be +converted to a full TermArg evaluation. A not-implemented error +is now returned (temporarily) for non-constant values for this +parameter. + +Fixed problem reports (Fiodor Suietov) integrated: +- Fix for premature object deletion after CopyObject on Operation +Region (BZ 350) + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 80.7K Code, 18.0K Data, 98.7K Total + Debug Version: 160.9K Code, 65.1K Data, 226.0K Total + Current Release: + Non-Debug Version: 80.7K Code, 17.9K Data, 98.6K Total + Debug Version: 161.0K Code, 65.1K Data, 226.1K Total + + +2) iASL Compiler/Disassembler and Tools: + +No changes for this release. + +---------------------------------------- +07 July 2006. Summary of changes for version 20060707: + +1) ACPI CA Core Subsystem: + +Added the ACPI_PACKED_POINTERS_NOT_SUPPORTED macro to support C +compilers that do not allow the initialization of address +pointers within packed structures - even though the hardware +itself may support misaligned transfers. Some of the debug data +structures are packed by default to minimize size. + +Added an error message for the case where AcpiOsGetThreadId() +returns zero. A non-zero value is required by the core ACPICA +code to ensure the proper operation of AML mutexes and recursive +control methods. + +The DSDT is now the only ACPI table that determines whether the +AML interpreter is in 32-bit or 64-bit mode. Not really a +functional change, but the hooks for per-table 32/64 switching +have been removed from the code. A clarification to the ACPI +specification is forthcoming in ACPI 3.0B. + +Fixed a possible leak of an OwnerID in the error path of +AcpiTbInitTableDescriptor (tbinstal.c), and migrated all table +OwnerID deletion to a single place in AcpiTbUninstallTable to +correct possible leaks when using the AcpiTbDeleteTablesByType +interface (with assistance from Lance Ortiz.) + +Fixed a problem with Serialized control methods where the +semaphore associated with the method could be over-signaled after +multiple method invocations. + +Fixed two issues with the locking of the internal namespace data +structure. Both the Unload() operator and AcpiUnloadTable +interface now lock the namespace during the namespace deletion +associated with the table unload (with assistance from Linn +Crosetto.) + +Fixed problem reports (Valery Podrezov) integrated: +- Eliminate unnecessary memory allocation for CreateXxxxField (BZ +5426) + +Fixed problem reports (Fiodor Suietov) integrated: +- Incomplete cleanup branches in AcpiTbGetTableRsdt (BZ 369) +- On Address Space handler deletion, needless deactivation call +(BZ 374) +- AcpiRemoveAddressSpaceHandler: validate Device handle parameter +(BZ 375) +- Possible memory leak, Notify sub-objects of Processor, Power, +ThermalZone (BZ 376) +- AcpiRemoveAddressSpaceHandler: validate Handler parameter (BZ +378) +- Minimum Length of RSDT should be validated (BZ 379) +- AcpiRemoveNotifyHandler: return AE_NOT_EXIST if Processor Obj +has no Handler (BZ (380) +- AcpiUnloadTable: return AE_NOT_EXIST if no table of specified +type loaded (BZ 381) + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 80.5K Code, 17.8K Data, 98.3K Total + Debug Version: 160.8K Code, 64.8K Data, 225.6K Total + Current Release: + Non-Debug Version: 80.7K Code, 17.9K Data, 98.6K Total + Debug Version: 161.0K Code, 65.1K Data, 226.1K Total + + +2) iASL Compiler/Disassembler and Tools: + +Fixed problem reports: +Compiler segfault when ASL contains a long (>1024) String +declaration (BZ 436) + +---------------------------------------- +23 June 2006. Summary of changes for version 20060623: + +1) ACPI CA Core Subsystem: + +Implemented a new ACPI_SPINLOCK type for the OSL lock interfaces. +This allows the type to be customized to the host OS for improved +efficiency (since a spinlock is usually a very small object.) + +Implemented support for "ignored" bits in the ACPI registers. +According to the ACPI specification, these bits should be +preserved when writing the registers via a read/modify/write +cycle. There are 3 bits preserved in this manner: PM1_CONTROL[0] +(SCI_EN), PM1_CONTROL[9], and PM1_STATUS[11]. + +Implemented the initial deployment of new OSL mutex interfaces. +Since some host operating systems have separate mutex and +semaphore objects, this feature was requested. The base code now +uses mutexes (and the new mutex interfaces) wherever a binary +semaphore was used previously. However, for the current release, +the mutex interfaces are defined as macros to map them to the +existing semaphore interfaces. Therefore, no OSL changes are +required at this time. (See acpiosxf.h) + +Fixed several problems with the support for the control method +SyncLevel parameter. The SyncLevel now works according to the +ACPI specification and in concert with the Mutex SyncLevel +parameter, since the current SyncLevel is a property of the +executing thread. Mutual exclusion for control methods is now +implemented with a mutex instead of a semaphore. + +Fixed three instances of the use of the C shift operator in the +bitfield support code (exfldio.c) to avoid the use of a shift +value larger than the target data width. The behavior of C +compilers is undefined in this case and can cause unpredictable +results, and therefore the case must be detected and avoided. +(Fiodor Suietov) + +Added an info message whenever an SSDT or OEM table is loaded +dynamically via the Load() or LoadTable() ASL operators. This +should improve debugging capability since it will show exactly +what tables have been loaded (beyond the tables present in the +RSDT/XSDT.) + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 80.0K Code, 17.6K Data, 97.6K Total + Debug Version: 160.2K Code, 64.7K Data, 224.9K Total + Current Release: + Non-Debug Version: 80.5K Code, 17.8K Data, 98.3K Total + Debug Version: 160.8K Code, 64.8K Data, 225.6K Total + + +2) iASL Compiler/Disassembler and Tools: + +No changes for this release. + +---------------------------------------- +08 June 2006. Summary of changes for version 20060608: + +1) ACPI CA Core Subsystem: + +Converted the locking mutex used for the ACPI hardware to a +spinlock. This change should eliminate all problems caused by +attempting to acquire a semaphore at interrupt level, and it +means that all ACPICA external interfaces that directly access +the ACPI hardware can be safely called from interrupt level. OSL +code that implements the semaphore interfaces should be able to +eliminate any workarounds for being called at interrupt level. + +Fixed a regression introduced in 20060526 where the ACPI device +initialization could be prematurely aborted with an AE_NOT_FOUND +if a device did not have an optional _INI method. + +Fixed an IndexField issue where a write to the Data Register +should be limited in size to the AccessSize (width) of the +IndexField itself. (BZ 433, Fiodor Suietov) + +Fixed problem reports (Valery Podrezov) integrated: +- Allow store of ThermalZone objects to Debug object (BZ +5369/5370) + +Fixed problem reports (Fiodor Suietov) integrated: +- AcpiGetTableHeader doesn't handle multiple instances correctly +(BZ 364) + +Removed four global mutexes that were obsolete and were no longer +being used. + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 80.0K Code, 17.7K Data, 97.7K Total + Debug Version: 160.3K Code, 64.9K Data, 225.2K Total + Current Release: + Non-Debug Version: 80.0K Code, 17.6K Data, 97.6K Total + Debug Version: 160.2K Code, 64.7K Data, 224.9K Total + + +2) iASL Compiler/Disassembler and Tools: + +Fixed a fault when using -g option (get tables from registry) on +Windows machines. + +Fixed problem reports integrated: +- Generate error if CreateField NumBits parameter is zero. (BZ +405) +- Fault if Offset/Length in Field unit is very large (BZ 432, +Fiodor Suietov) +- Global table revision override (-r) is ignored (BZ 413) + +---------------------------------------- +26 May 2006. Summary of changes for version 20060526: + +1) ACPI CA Core Subsystem: + +Restructured, flattened, and simplified the internal interfaces +for namespace object evaluation - resulting in smaller code, less +CPU stack use, and fewer interfaces. (With assistance from +Mikhail Kouzmich) + +Fixed a problem with the CopyObject operator where the first +parameter was not typed correctly for the parser, interpreter, +compiler, and disassembler. Caused various errors and unexpected +behavior. + +Fixed a problem where a ShiftLeft or ShiftRight of more than 64 +bits produced incorrect results with some C compilers. Since the +behavior of C compilers when the shift value is larger than the +datatype width is apparently not well defined, the interpreter +now detects this condition and simply returns zero as expected in +all such cases. (BZ 395) + +Fixed problem reports (Valery Podrezov) integrated: +- Update String-to-Integer conversion to match ACPI 3.0A spec (BZ +5329) +- Allow interpreter to handle nested method declarations (BZ +5361) + +Fixed problem reports (Fiodor Suietov) integrated: +- AcpiTerminate doesn't free debug memory allocation list objects +(BZ 355) +- After Core Subsystem shutdown, AcpiSubsystemStatus returns +AE_OK (BZ 356) +- AcpiOsUnmapMemory for RSDP can be invoked inconsistently (BZ +357) +- Resource Manager should return AE_TYPE for non-device objects +(BZ 358) +- Incomplete cleanup branch in AcpiNsEvaluateRelative (BZ 359) +- Use AcpiOsFree instead of ACPI_FREE in AcpiRsSetSrsMethodData +(BZ 360) +- Incomplete cleanup branch in AcpiPsParseAml (BZ 361) +- Incomplete cleanup branch in AcpiDsDeleteWalkState (BZ 362) +- AcpiGetTableHeader returns AE_NO_ACPI_TABLES until DSDT is +loaded (BZ 365) +- Status of the Global Initialization Handler call not used (BZ +366) +- Incorrect object parameter to Global Initialization Handler (BZ +367) + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 79.8K Code, 17.7K Data, 97.5K Total + Debug Version: 160.5K Code, 65.1K Data, 225.6K Total + Current Release: + Non-Debug Version: 80.0K Code, 17.7K Data, 97.7K Total + Debug Version: 160.3K Code, 64.9K Data, 225.2K Total + + +2) iASL Compiler/Disassembler and Tools: + +Modified the parser to allow the names IO, DMA, and IRQ to be +used as namespace identifiers with no collision with existing +resource descriptor macro names. This provides compatibility with +other ASL compilers and is most useful for +disassembly/recompilation of existing tables without parse +errors. (With assistance from Thomas Renninger) + +Disassembler: fixed an incorrect disassembly problem with the +DataTableRegion and CopyObject operators. Fixed a possible fault +during disassembly of some Alias operators. + +---------------------------------------- +12 May 2006. Summary of changes for version 20060512: + +1) ACPI CA Core Subsystem: + +Replaced the AcpiOsQueueForExecution interface with a new +interface named AcpiOsExecute. The major difference is that the +new interface does not have a Priority parameter, this appeared +to be useless and has been replaced by a Type parameter. The Type +tells the host what type of execution is being requested, such as +global lock handler, notify handler, GPE handler, etc. This +allows the host to queue and execute the request as appropriate +for the request type, possibly using different work queues and +different priorities for the various request types. This enables +fixes for multithreading deadlock problems such as BZ #5534, and +will require changes to all existing OS interface layers. (Alexey +Starikovskiy and Bob Moore) + +Fixed a possible memory leak associated with the support for the +so-called "implicit return" ACPI extension. Reported by FreeBSD, +BZ #6514. (Fiodor Suietov) + +Fixed a problem with the Load() operator where a table load from +an operation region could overwrite an internal table buffer by +up to 7 bytes and cause alignment faults on IPF systems. (With +assistance from Luming Yu) + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 79.7K Code, 17.7K Data, 97.4K Total + Debug Version: 160.1K Code, 65.2K Data, 225.3K Total + Current Release: + Non-Debug Version: 79.8K Code, 17.7K Data, 97.5K Total + Debug Version: 160.5K Code, 65.1K Data, 225.6K Total + + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Implemented support to cross reference the internal +namespace and automatically generate ASL External() statements +for symbols not defined within the current table being +disassembled. This will simplify the disassembly and +recompilation of interdependent tables such as SSDTs since these +statements will no longer have to be added manually. + +Disassembler: Implemented experimental support to automatically +detect invocations of external control methods and generate +appropriate External() statements. This is problematic because +the AML cannot be correctly parsed until the number of arguments +for each control method is known. Currently, standalone method +invocations and invocations as the source operand of a Store() +statement are supported. + +Disassembler: Implemented support for the ASL pseudo-operators +LNotEqual, LLessEqual, and LGreaterEqual. Previously disassembled +as LNot(LEqual()), LNot(LGreater()), and LNot(LLess()), this +makes the disassembled ASL code more readable and likely closer +to the original ASL source. + +---------------------------------------- +21 April 2006. Summary of changes for version 20060421: + +1) ACPI CA Core Subsystem: + +Removed a device initialization optimization introduced in +20051216 where the _STA method was not run unless an _INI was +also present for the same device. This optimization could cause +problems because it could allow _INI methods to be run within a +not-present device subtree. (If a not-present device had no _INI, +_STA would not be run, the not-present status would not be +discovered, and the children of the device would be incorrectly +traversed.) + +Implemented a new _STA optimization where namespace subtrees that +do not contain _INI are identified and ignored during device +initialization. Selectively running _STA can significantly +improve boot time on large machines (with assistance from Len +Brown.) + +Implemented support for the device initialization case where the +returned _STA flags indicate a device not-present but +functioning. In this case, _INI is not run, but the device +children are examined for presence, as per the ACPI +specification. + +Implemented an additional change to the IndexField support in +order to conform to MS behavior. The value written to the Index +Register is not simply a byte offset, it is a byte offset in +units of the access width of the parent Index Field. (Fiodor +Suietov) + +Defined and deployed a new OSL interface, AcpiOsValidateAddress. +This interface is called during the creation of all AML operation +regions, and allows the host OS to exert control over what +addresses it will allow the AML code to access. Operation Regions +whose addresses are disallowed will cause a runtime exception +when they are actually accessed (will not affect or abort table +loading.) See oswinxf or osunixxf for an example implementation. + +Defined and deployed a new OSL interface, +AcpiOsValidateInterface. This interface allows the host OS to +match the various "optional" interface/behavior strings for the +_OSI predefined control method as appropriate (with assistance +from Bjorn Helgaas.) See oswinxf or osunixxf for an example +implementation. + +Restructured and corrected various problems in the exception +handling code paths within DsCallControlMethod and +DsTerminateControlMethod in dsmethod (with assistance from +Takayoshi Kochi.) + +Modified the Linux source converter to ignore quoted string +literals while converting identifiers from mixed to lower case. +This will correct problems with the disassembler and other areas +where such strings must not be modified. + +The ACPI_FUNCTION_* macros no longer require quotes around the +function name. This allows the Linux source converter to convert +the names, now that the converter ignores quoted strings. + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + + Non-Debug Version: 81.1K Code, 17.7K Data, 98.8K Total + Debug Version: 158.9K Code, 64.9K Data, 223.8K Total + Current Release: + Non-Debug Version: 79.7K Code, 17.7K Data, 97.4K Total + Debug Version: 160.1K Code, 65.2K Data, 225.3K Total + + +2) iASL Compiler/Disassembler and Tools: + +Implemented 3 new warnings for iASL, and implemented multiple +warning levels (w2 flag). + +1) Ignored timeouts: If the TimeoutValue parameter to Wait or +Acquire is not WAIT_FOREVER (0xFFFF) and the code does not +examine the return value to check for the possible timeout, a +warning is issued. + +2) Useless operators: If an ASL operator does not specify an +optional target operand and it also does not use the function +return value from the operator, a warning is issued since the +operator effectively does nothing. + +3) Unreferenced objects: If a namespace object is created, but +never referenced, a warning is issued. This is a warning level 2 +since there are cases where this is ok, such as when a secondary +table is loaded that uses the unreferenced objects. Even so, care +is taken to only flag objects that don't look like they will ever +be used. For example, the reserved methods (starting with an +underscore) are usually not referenced because it is expected +that the OS will invoke them. + +---------------------------------------- +31 March 2006. Summary of changes for version 20060331: + +1) ACPI CA Core Subsystem: + +Implemented header file support for the following additional ACPI +tables: ASF!, BOOT, CPEP, DBGP, MCFG, SPCR, SPMI, TCPA, and WDRT. +With this support, all current and known ACPI tables are now +defined in the ACPICA headers and are available for use by device +drivers and other software. + +Implemented support to allow tables that contain ACPI names with +invalid characters to be loaded. Previously, this would cause the +table load to fail, but since there are several known cases of +such tables on existing machines, this change was made to enable +ACPI support for them. Also, this matches the behavior of the +Microsoft ACPI implementation. + +Fixed a couple regressions introduced during the memory +optimization in the 20060317 release. The namespace node +definition required additional reorganization and an internal +datatype that had been changed to 8-bit was restored to 32-bit. +(Valery Podrezov) + +Fixed a problem where a null pointer passed to +AcpiUtDeleteGenericState could be passed through to +AcpiOsReleaseObject which is unexpected. Such null pointers are +now trapped and ignored, matching the behavior of the previous +implementation before the deployment of AcpiOsReleaseObject. +(Valery Podrezov, Fiodor Suietov) + +Fixed a memory mapping leak during the deletion of a SystemMemory +operation region where a cached memory mapping was not deleted. +This became a noticeable problem for operation regions that are +defined within frequently used control methods. (Dana Meyers) + +Reorganized the ACPI table header files into two main files: one +for the ACPI tables consumed by the ACPICA core, and another for +the miscellaneous ACPI tables that are consumed by the drivers +and other software. The various FADT definitions were merged into +one common section and three different tables (ACPI 1.0, 1.0+, +and 2.0) + +Example Code and Data Size: These are the sizes for the OS- +independent acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. + + Previous Release: + Non-Debug Version: 80.9K Code, 17.7K Data, 98.6K Total + Debug Version: 158.7K Code, 64.8K Data, 223.5K Total + Current Release: + Non-Debug Version: 81.1K Code, 17.7K Data, 98.8K Total + Debug Version: 158.9K Code, 64.9K Data, 223.8K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Implemented support to decode and format all non- +AML ACPI tables (tables other than DSDTs and SSDTs.) This +includes the new tables added to the ACPICA headers, therefore +all current and known ACPI tables are supported. + +Disassembler: The change to allow ACPI names with invalid +characters also enables the disassembly of such tables. Invalid +characters within names are changed to '*' to make the name +printable; the iASL compiler will still generate an error for +such names, however, since this is an invalid ACPI character. + +Implemented an option for AcpiXtract (-a) to extract all tables +found in the input file. The default invocation extracts only the +DSDTs and SSDTs. + +Fixed a couple of gcc generation issues for iASL and AcpiExec and +added a makefile for the AcpiXtract utility. + +---------------------------------------- +17 March 2006. Summary of changes for version 20060317: + +1) ACPI CA Core Subsystem: + +Implemented the use of a cache object for all internal namespace +nodes. Since there are about 1000 static nodes in a typical +system, this will decrease memory use for cache implementations +that minimize per-allocation overhead (such as a slab allocator.) + +Removed the reference count mechanism for internal namespace +nodes, since it was deemed unnecessary. This reduces the size of +each namespace node by about 5%-10% on all platforms. Nodes are +now 20 bytes for the 32-bit case, and 32 bytes for the 64-bit +case. + +Optimized several internal data structures to reduce object size +on 64-bit platforms by packing data within the 64-bit alignment. +This includes the frequently used ACPI_OPERAND_OBJECT, of which +there can be ~1000 static instances corresponding to the +namespace objects. + +Added two new strings for the predefined _OSI method: "Windows +2001.1 SP1" and "Windows 2006". + +Split the allocation tracking mechanism out to a separate file, +from utalloc.c to uttrack.c. This mechanism appears to be only +useful for application-level code. Kernels may wish to not +include uttrack.c in distributions. + +Removed all remnants of the obsolete ACPI_REPORT_* macros and the +associated code. (These macros have been replaced by the +ACPI_ERROR and ACPI_WARNING macros.) + +Code and Data Size: These are the sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release: + Non-Debug Version: 81.1K Code, 17.8K Data, 98.9K Total + Debug Version: 161.6K Code, 65.7K Data, 227.3K Total + Current Release: + Non-Debug Version: 80.9K Code, 17.7K Data, 98.6K Total + Debug Version: 158.7K Code, 64.8K Data, 223.5K Total + + +2) iASL Compiler/Disassembler and Tools: + +Implemented an ANSI C version of the acpixtract utility. This +version will automatically extract the DSDT and all SSDTs from +the input acpidump text file and dump the binary output to +separate files. It can also display a summary of the input file +including the headers for each table found and will extract any +single ACPI table, with any signature. (See +source/tools/acpixtract) + +---------------------------------------- +10 March 2006. Summary of changes for version 20060310: + +1) ACPI CA Core Subsystem: + +Tagged all external interfaces to the subsystem with the new +ACPI_EXPORT_SYMBOL macro. This macro can be defined as necessary +to assist kernel integration. For Linux, the macro resolves to +the EXPORT_SYMBOL macro. The default definition is NULL. + +Added the ACPI_THREAD_ID type for the return value from +AcpiOsGetThreadId. This allows the host to define this as +necessary to simplify kernel integration. The default definition +is ACPI_NATIVE_UINT. + +Fixed two interpreter problems related to error processing, the +deletion of objects, and placing invalid pointers onto the +internal operator result stack. BZ 6028, 6151 (Valery Podrezov) + +Increased the reference count threshold where a warning is +emitted for large reference counts in order to eliminate +unnecessary warnings on systems with large namespaces (especially +64-bit.) Increased the value from 0x400 to 0x800. + +Due to universal disagreement as to the meaning of the 'c' in the +calloc() function, the ACPI_MEM_CALLOCATE macro has been renamed +to ACPI_ALLOCATE_ZEROED so that the purpose of the interface is +'clear'. ACPI_MEM_ALLOCATE and ACPI_MEM_FREE are renamed to +ACPI_ALLOCATE and ACPI_FREE. + +Code and Data Size: These are the sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release: + Non-Debug Version: 81.0K Code, 17.8K Data, 98.8K Total + Debug Version: 161.4K Code, 65.7K Data, 227.1K Total + Current Release: + Non-Debug Version: 81.1K Code, 17.8K Data, 98.9K Total + Debug Version: 161.6K Code, 65.7K Data, 227.3K Total + + +2) iASL Compiler/Disassembler: + +Disassembler: implemented support for symbolic resource +descriptor references. If a CreateXxxxField operator references a +fixed offset within a resource descriptor, a name is assigned to +the descriptor and the offset is translated to the appropriate +resource tag and pathname. The addition of this support brings +the disassembled code very close to the original ASL source code +and helps eliminate run-time errors when the disassembled code is +modified (and recompiled) in such a way as to invalidate the +original fixed offsets. + +Implemented support for a Descriptor Name as the last parameter +to the ASL Register() macro. This parameter was inadvertently +left out of the ACPI specification, and will be added for ACPI +3.0b. + +Fixed a problem where the use of the "_OSI" string (versus the +full path "\_OSI") caused an internal compiler error. ("No back +ptr to op") + +Fixed a problem with the error message that occurs when an +invalid string is used for a _HID object (such as one with an +embedded asterisk: "*PNP010A".) The correct message is now +displayed. + +---------------------------------------- +17 February 2006. Summary of changes for version 20060217: + +1) ACPI CA Core Subsystem: + +Implemented a change to the IndexField support to match the +behavior of the Microsoft AML interpreter. The value written to +the Index register is now a byte offset, no longer an index based +upon the width of the Data register. This should fix IndexField +problems seen on some machines where the Data register is not +exactly one byte wide. The ACPI specification will be clarified +on this point. + +Fixed a problem where several resource descriptor types could +overrun the internal descriptor buffer due to size +miscalculation: VendorShort, VendorLong, and Interrupt. This was +noticed on IA64 machines, but could affect all platforms. + +Fixed a problem where individual resource descriptors were +misaligned within the internal buffer, causing alignment faults +on IA64 platforms. + +Code and Data Size: These are the sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release: + Non-Debug Version: 81.1K Code, 17.8K Data, 98.9K Total + Debug Version: 161.3K Code, 65.6K Data, 226.9K Total + Current Release: + Non-Debug Version: 81.0K Code, 17.8K Data, 98.8K Total + Debug Version: 161.4K Code, 65.7K Data, 227.1K Total + + +2) iASL Compiler/Disassembler: + +Implemented support for new reserved names: _WDG and _WED are +Microsoft extensions for Windows Instrumentation Management, _TDL +is a new ACPI-defined method (Throttling Depth Limit.) + +Fixed a problem where a zero-length VendorShort or VendorLong +resource descriptor was incorrectly emitted as a descriptor of +length one. + +---------------------------------------- +10 February 2006. Summary of changes for version 20060210: + +1) ACPI CA Core Subsystem: + +Removed a couple of extraneous ACPI_ERROR messages that appeared +during normal execution. These became apparent after the +conversion from ACPI_DEBUG_PRINT. + +Fixed a problem where the CreateField operator could hang if the +BitIndex or NumBits parameter referred to a named object. (Valery +Podrezov, BZ 5359) + +Fixed a problem where a DeRefOf operation on a buffer object +incorrectly failed with an exception. This also fixes a couple of +related RefOf and DeRefOf issues. (Valery Podrezov, BZ +5360/5392/5387) + +Fixed a problem where the AE_BUFFER_LIMIT exception was returned +instead of AE_STRING_LIMIT on an out-of-bounds Index() operation. +(Valery Podrezov, BZ 5480) + +Implemented a memory cleanup at the end of the execution of each +iteration of an AML While() loop, preventing the accumulation of +outstanding objects. (Valery Podrezov, BZ 5427) + +Eliminated a chunk of duplicate code in the object resolution +code. (Valery Podrezov, BZ 5336) + +Fixed several warnings during the 64-bit code generation. + +The AcpiSrc source code conversion tool now inserts one line of +whitespace after an if() statement that is followed immediately +by a comment, improving readability of the Linux code. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 81.0K Code, 17.9K Data, 98.9K Total + Debug Version: 161.3K Code, 65.7K Data, 227.0K Total + Current Release: + Non-Debug Version: 81.1K Code, 17.8K Data, 98.9K Total + Debug Version: 161.3K Code, 65.6K Data, 226.9K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem with the disassembly of a BankField operator with +a complex expression for the BankValue parameter. + +---------------------------------------- +27 January 2006. Summary of changes for version 20060127: + +1) ACPI CA Core Subsystem: + +Implemented support in the Resource Manager to allow unresolved +namestring references within resource package objects for the +_PRT method. This support is in addition to the previously +implemented unresolved reference support within the AML parser. +If the interpreter slack mode is enabled, these unresolved +references will be passed through to the caller as a NULL package +entry. + +Implemented and deployed new macros and functions for error and +warning messages across the subsystem. These macros are simpler +and generate less code than their predecessors. The new macros +ACPI_ERROR, ACPI_EXCEPTION, ACPI_WARNING, and ACPI_INFO replace +the ACPI_REPORT_* macros. The older macros remain defined to +allow ACPI drivers time to migrate to the new macros. + +Implemented the ACPI_CPU_FLAGS type to simplify host OS +integration of the Acquire/Release Lock OSL interfaces. + +Fixed a problem where Alias ASL operators are sometimes not +correctly resolved, in both the interpreter and the iASL +compiler. + +Fixed several problems with the implementation of the +ConcatenateResTemplate ASL operator. As per the ACPI +specification, zero length buffers are now treated as a single +EndTag. One-length buffers always cause a fatal exception. Non- +zero length buffers that do not end with a full 2-byte EndTag +cause a fatal exception. + +Fixed a possible structure overwrite in the AcpiGetObjectInfo +external interface. (With assistance from Thomas Renninger) + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 83.1K Code, 18.4K Data, 101.5K Total + Debug Version: 163.2K Code, 66.2K Data, 229.4K Total + Current Release: + Non-Debug Version: 81.0K Code, 17.9K Data, 98.9K Total + Debug Version: 161.3K Code, 65.7K Data, 227.0K Total + + +2) iASL Compiler/Disassembler: + +Fixed an internal error that was generated for any forward +references to ASL Alias objects. + +---------------------------------------- +13 January 2006. Summary of changes for version 20060113: + +1) ACPI CA Core Subsystem: + +Added 2006 copyright to all module headers and signons. This +affects virtually every file in the ACPICA core subsystem, iASL +compiler, and the utilities. + +Enhanced the ACPICA error reporting in order to simplify user +migration to the non-debug version of ACPICA. Replaced all +instances of the ACPI_DEBUG_PRINT macro invoked at the +ACPI_DB_ERROR and ACPI_DB_WARN debug levels with the +ACPI_REPORT_ERROR and ACPI_REPORT_WARNING macros, respectively. +This preserves all error and warning messages in the non-debug +version of the ACPICA code (this has been referred to as the +"debug lite" option.) Over 200 cases were converted to create a +total of over 380 error/warning messages across the ACPICA code. +This increases the code and data size of the default non-debug +version of the code somewhat (about 13K), but all error/warning +reporting may be disabled if desired (and code eliminated) by +specifying the ACPI_NO_ERROR_MESSAGES compile-time configuration +option. The size of the debug version of ACPICA remains about the +same. + +Fixed a memory leak within the AML Debugger "Set" command. One +object was not properly deleted for every successful invocation +of the command. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 76.6K Code, 12.3K Data, 88.9K Total + Debug Version: 163.7K Code, 67.5K Data, 231.2K Total + Current Release: + Non-Debug Version: 83.1K Code, 18.4K Data, 101.5K Total + Debug Version: 163.2K Code, 66.2K Data, 229.4K Total + + +2) iASL Compiler/Disassembler: + +The compiler now officially supports the ACPI 3.0a specification +that was released on December 30, 2005. (Specification is +available at www.acpi.info) + +---------------------------------------- +16 December 2005. Summary of changes for version 20051216: + +1) ACPI CA Core Subsystem: + +Implemented optional support to allow unresolved names within ASL +Package objects. A null object is inserted in the package when a +named reference cannot be located in the current namespace. +Enabled via the interpreter slack flag, this should eliminate +AE_NOT_FOUND exceptions seen on machines that contain such code. + +Implemented an optimization to the initialization sequence that +can improve boot time. During ACPI device initialization, the +_STA method is now run if and only if the _INI method exists. The +_STA method is used to determine if the device is present; An +_INI can only be run if _STA returns present, but it is a waste +of time to run the _STA method if the _INI does not exist. +(Prototype and assistance from Dong Wei) + +Implemented use of the C99 uintptr_t for the pointer casting +macros if it is available in the current compiler. Otherwise, the +default (void *) cast is used as before. + +Fixed some possible memory leaks found within the execution path +of the Break, Continue, If, and CreateField operators. (Valery +Podrezov) + +Fixed a problem introduced in the 20051202 release where an +exception is generated during method execution if a control +method attempts to declare another method. + +Moved resource descriptor string constants that are used by both +the AML disassembler and AML debugger to the common utilities +directory so that these components are independent. + +Implemented support in the AcpiExec utility (-e switch) to +globally ignore exceptions during control method execution +(method is not aborted.) + +Added the rsinfo.c source file to the AcpiExec makefile for +Linux/Unix generation. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 76.3K Code, 12.3K Data, 88.6K Total + Debug Version: 163.2K Code, 67.4K Data, 230.6K Total + Current Release: + Non-Debug Version: 76.6K Code, 12.3K Data, 88.9K Total + Debug Version: 163.7K Code, 67.5K Data, 231.2K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem where a CPU stack overflow fault could occur if a +recursive method call was made from within a Return statement. + +---------------------------------------- +02 December 2005. Summary of changes for version 20051202: + +1) ACPI CA Core Subsystem: + +Modified the parsing of control methods to no longer create +namespace objects during the first pass of the parse. Objects are +now created only during the execute phase, at the moment the +namespace creation operator is encountered in the AML (Name, +OperationRegion, CreateByteField, etc.) This should eliminate +ALREADY_EXISTS exceptions seen on some machines where reentrant +control methods are protected by an AML mutex. The mutex will now +correctly block multiple threads from attempting to create the +same object more than once. + +Increased the number of available Owner Ids for namespace object +tracking from 32 to 255. This should eliminate the OWNER_ID_LIMIT +exceptions seen on some machines with a large number of ACPI +tables (either static or dynamic). + +Fixed a problem with the AcpiExec utility where a fault could +occur when the -b switch (batch mode) is used. + +Enhanced the namespace dump routine to output the owner ID for +each namespace object. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 76.3K Code, 12.3K Data, 88.6K Total + Debug Version: 163.0K Code, 67.4K Data, 230.4K Total + Current Release: + Non-Debug Version: 76.3K Code, 12.3K Data, 88.6K Total + Debug Version: 163.2K Code, 67.4K Data, 230.6K Total + + +2) iASL Compiler/Disassembler: + +Fixed a parse error during compilation of certain Switch/Case +constructs. To simplify the parse, the grammar now allows for +multiple Default statements and this error is now detected and +flagged during the analysis phase. + +Disassembler: The disassembly now includes the contents of the +original table header within a comment at the start of the file. +This includes the name and version of the original ASL compiler. + +---------------------------------------- +17 November 2005. Summary of changes for version 20051117: + +1) ACPI CA Core Subsystem: + +Fixed a problem in the AML parser where the method thread count +could be decremented below zero if any errors occurred during the +method parse phase. This should eliminate AE_AML_METHOD_LIMIT +exceptions seen on some machines. This also fixed a related +regression with the mechanism that detects and corrects methods +that cannot properly handle reentrancy (related to the deployment +of the new OwnerId mechanism.) + +Eliminated the pre-parsing of control methods (to detect errors) +during table load. Related to the problem above, this was causing +unwind issues if any errors occurred during the parse, and it +seemed to be overkill. A table load should not be aborted if +there are problems with any single control method, thus rendering +this feature rather pointless. + +Fixed a problem with the new table-driven resource manager where +an internal buffer overflow could occur for small resource +templates. + +Implemented a new external interface, AcpiGetVendorResource. This +interface will find and return a vendor-defined resource +descriptor within a _CRS or _PRS method via an ACPI 3.0 UUID +match. With assistance from Bjorn Helgaas. + +Removed the length limit (200) on string objects as per the +upcoming ACPI 3.0A specification. This affects the following +areas of the interpreter: 1) any implicit conversion of a Buffer +to a String, 2) a String object result of the ASL Concatentate +operator, 3) the String object result of the ASL ToString +operator. + +Fixed a problem in the Windows OS interface layer (OSL) where a +WAIT_FOREVER on a semaphore object would incorrectly timeout. +This allows the multithreading features of the AcpiExec utility +to work properly under Windows. + +Updated the Linux makefiles for the iASL compiler and AcpiExec to +include the recently added file named "utresrc.c". + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 76.2K Code, 12.3K Data, 88.5K Total + Debug Version: 163.0K Code, 67.4K Data, 230.4K Total + Current Release: + Non-Debug Version: 76.3K Code, 12.3K Data, 88.6K Total + Debug Version: 163.0K Code, 67.4K Data, 230.4K Total + + +2) iASL Compiler/Disassembler: + +Removed the limit (200) on string objects as per the upcoming +ACPI 3.0A specification. For the iASL compiler, this means that +string literals within the source ASL can be of any length. + +Enhanced the listing output to dump the AML code for resource +descriptors immediately after the ASL code for each descriptor, +instead of in a block at the end of the entire resource template. + +Enhanced the compiler debug output to dump the entire original +parse tree constructed during the parse phase, before any +transforms are applied to the tree. The transformed tree is +dumped also. + +---------------------------------------- +02 November 2005. Summary of changes for version 20051102: + +1) ACPI CA Core Subsystem: + +Modified the subsystem initialization sequence to improve GPE +support. The GPE initialization has been split into two parts in +order to defer execution of the _PRW methods (Power Resources for +Wake) until after the hardware is fully initialized and the SCI +handler is installed. This allows the _PRW methods to access +fields protected by the Global Lock. This will fix systems where +a NO_GLOBAL_LOCK exception has been seen during initialization. + +Converted the ACPI internal object disassemble and display code +within the AML debugger to fully table-driven operation, reducing +code size and increasing maintainability. + +Fixed a regression with the ConcatenateResTemplate() ASL operator +introduced in the 20051021 release. + +Implemented support for "local" internal ACPI object types within +the debugger "Object" command and the AcpiWalkNamespace external +interfaces. These local types include RegionFields, BankFields, +IndexFields, Alias, and reference objects. + +Moved common AML resource handling code into a new file, +"utresrc.c". This code is shared by both the Resource Manager and +the AML Debugger. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 76.1K Code, 12.2K Data, 88.3K Total + Debug Version: 163.5K Code, 67.0K Data, 230.5K Total + Current Release: + Non-Debug Version: 76.2K Code, 12.3K Data, 88.5K Total + Debug Version: 163.0K Code, 67.4K Data, 230.4K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem with very large initializer lists (more than 4000 +elements) for both Buffer and Package objects where the parse +stack could overflow. + +Enhanced the pre-compile source code scan for non-ASCII +characters to ignore characters within comment fields. The scan +is now always performed and is no longer optional, detecting +invalid characters within a source file immediately rather than +during the parse phase or later. + +Enhanced the ASL grammar definition to force early reductions on +all list-style grammar elements so that the overall parse stack +usage is greatly reduced. This should improve performance and +reduce the possibility of parse stack overflow. + +Eliminated all reduce/reduce conflicts in the iASL parser +generation. Also, with the addition of a %expected statement, the +compiler generates from source with no warnings. + +Fixed a possible segment fault in the disassembler if the input +filename does not contain a "dot" extension (Thomas Renninger). + +---------------------------------------- +21 October 2005. Summary of changes for version 20051021: + +1) ACPI CA Core Subsystem: + +Implemented support for the EM64T and other x86-64 processors. +This essentially entails recognizing that these processors +support non-aligned memory transfers. Previously, all 64-bit +processors were assumed to lack hardware support for non-aligned +transfers. + +Completed conversion of the Resource Manager to nearly full table- +driven operation. Specifically, the resource conversion code +(convert AML to internal format and the reverse) and the debug +code to dump internal resource descriptors are fully table- +driven, reducing code and data size and improving +maintainability. + +The OSL interfaces for Acquire and Release Lock now use a 64-bit +flag word on 64-bit processors instead of a fixed 32-bit word. +(With assistance from Alexey Starikovskiy) + +Implemented support within the resource conversion code for the +Type-Specific byte within the various ACPI 3.0 *WordSpace macros. + +Fixed some issues within the resource conversion code for the +type-specific flags for both Memory and I/O address resource +descriptors. For Memory, implemented support for the MTP and TTP +flags. For I/O, split the TRS and TTP flags into two separate +fields. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.1K Code, 12.1K Data, 89.2K Total + Debug Version: 168.0K Code, 68.3K Data, 236.3K Total + Current Release: + Non-Debug Version: 76.1K Code, 12.2K Data, 88.3K Total + Debug Version: 163.5K Code, 67.0K Data, 230.5K Total + + + +2) iASL Compiler/Disassembler: + +Relaxed a compiler restriction that disallowed a ResourceIndex +byte if the corresponding ResourceSource string was not also +present in a resource descriptor declaration. This restriction +caused problems with existing AML/ASL code that includes the +Index byte without the string. When such AML was disassembled, it +could not be compiled without modification. Further, the modified +code created a resource template with a different size than the +original, breaking code that used fixed offsets into the resource +template buffer. + +Removed a recent feature of the disassembler to ignore a lone +ResourceIndex byte. This byte is now emitted if present so that +the exact AML can be reproduced when the disassembled code is +recompiled. + +Improved comments and text alignment for the resource descriptor +code emitted by the disassembler. + +Implemented disassembler support for the ACPI 3.0 AccessSize +field within a Register() resource descriptor. + +---------------------------------------- +30 September 2005. Summary of changes for version 20050930: + +1) ACPI CA Core Subsystem: + +Completed a major overhaul of the Resource Manager code - +specifically, optimizations in the area of the AML/internal +resource conversion code. The code has been optimized to simplify +and eliminate duplicated code, CPU stack use has been decreased +by optimizing function parameters and local variables, and naming +conventions across the manager have been standardized for clarity +and ease of maintenance (this includes function, parameter, +variable, and struct/typedef names.) The update may force changes +in some driver code, depending on how resources are handled by +the host OS. + +All Resource Manager dispatch and information tables have been +moved to a single location for clarity and ease of maintenance. +One new file was created, named "rsinfo.c". + +The ACPI return macros (return_ACPI_STATUS, etc.) have been +modified to guarantee that the argument is not evaluated twice, +making them less prone to macro side-effects. However, since +there exists the possibility of additional stack use if a +particular compiler cannot optimize them (such as in the debug +generation case), the original macros are optionally available. +Note that some invocations of the return_VALUE macro may now +cause size mismatch warnings; the return_UINT8 and return_UINT32 +macros are provided to eliminate these. (From Randy Dunlap) + +Implemented a new mechanism to enable debug tracing for +individual control methods. A new external interface, +AcpiDebugTrace, is provided to enable this mechanism. The intent +is to allow the host OS to easily enable and disable tracing for +problematic control methods. This interface can be easily exposed +to a user or debugger interface if desired. See the file +psxface.c for details. + +AcpiUtCallocate will now return a valid pointer if a length of +zero is specified - a length of one is used and a warning is +issued. This matches the behavior of AcpiUtAllocate. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.5K Code, 12.0K Data, 89.5K Total + Debug Version: 168.1K Code, 68.4K Data, 236.5K Total + Current Release: + Non-Debug Version: 77.1K Code, 12.1K Data, 89.2K Total + Debug Version: 168.0K Code, 68.3K Data, 236.3K Total + + +2) iASL Compiler/Disassembler: + +A remark is issued if the effective compile-time length of a +package or buffer is zero. Previously, this was a warning. + +---------------------------------------- +16 September 2005. Summary of changes for version 20050916: + +1) ACPI CA Core Subsystem: + +Fixed a problem within the Resource Manager where support for the +Generic Register descriptor was not fully implemented. This +descriptor is now fully recognized, parsed, disassembled, and +displayed. + +Completely restructured the Resource Manager code to utilize +table-driven dispatch and lookup, eliminating many of the large +switch() statements. This reduces overall subsystem code size and +code complexity. Affects the resource parsing and construction, +disassembly, and debug dump output. + +Cleaned up and restructured the debug dump output for all +resource descriptors. Improved readability of the output and +reduced code size. + +Fixed a problem where changes to internal data structures caused +the optional ACPI_MUTEX_DEBUG code to fail compilation if +specified. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. These values do not include any ACPI driver or +OSPM code. The debug version of the code includes the debug +output trace mechanism and has a much larger code and data size. +Note that these values will vary depending on the efficiency of +the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.4K Code, 11.8K Data, 90.2K Total + Debug Version: 169.6K Code, 69.9K Data, 239.5K Total + Current Release: + Non-Debug Version: 77.5K Code, 12.0K Data, 89.5K Total + Debug Version: 168.1K Code, 68.4K Data, 236.5K Total + + +2) iASL Compiler/Disassembler: + +Updated the disassembler to automatically insert an +EndDependentFn() macro into the ASL stream if this macro is +missing in the original AML code, simplifying compilation of the +resulting ASL module. + +Fixed a problem in the disassembler where a disassembled +ResourceSource string (within a large resource descriptor) was +not surrounded by quotes and not followed by a comma, causing +errors when the resulting ASL module was compiled. Also, escape +sequences within a ResourceSource string are now handled +correctly (especially "\\") + +---------------------------------------- +02 September 2005. Summary of changes for version 20050902: + +1) ACPI CA Core Subsystem: + +Fixed a problem with the internal Owner ID allocation and +deallocation mechanisms for control method execution and +recursive method invocation. This should eliminate the +OWNER_ID_LIMIT exceptions and "Invalid OwnerId" messages seen on +some systems. Recursive method invocation depth is currently +limited to 255. (Alexey Starikovskiy) + +Completely eliminated all vestiges of support for the "module- +level executable code" until this support is fully implemented +and debugged. This should eliminate the NO_RETURN_VALUE +exceptions seen during table load on some systems that invoke +this support. + +Fixed a problem within the resource manager code where the +transaction flags for a 64-bit address descriptor were handled +incorrectly in the type-specific flag byte. + +Consolidated duplicate code within the address descriptor +resource manager code, reducing overall subsystem code size. + +Fixed a fault when using the AML debugger "disassemble" command +to disassemble individual control methods. + +Removed references to the "release_current" directory within the +Unix release package. + +Code and Data Size: The current and previous core subsystem +library sizes are shown below. These are the code and data sizes +for the acpica.lib produced by the Microsoft Visual C++ 6.0 +compiler. These values do not include any ACPI driver or OSPM +code. The debug version of the code includes the debug output +trace mechanism and has a much larger code and data size. Note +that these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.6K Code, 11.7K Data, 90.3K Total + Debug Version: 170.0K Code, 69.9K Data, 239.9K Total + Current Release: + Non-Debug Version: 78.4K Code, 11.8K Data, 90.2K Total + Debug Version: 169.6K Code, 69.9K Data, 239.5K Total + + +2) iASL Compiler/Disassembler: + +Implemented an error check for illegal duplicate values in the +interrupt and dma lists for the following ASL macros: Dma(), +Irq(), IrqNoFlags(), and Interrupt(). + +Implemented error checking for the Irq() and IrqNoFlags() macros +to detect too many values in the interrupt list (16 max) and +invalid values in the list (range 0 - 15) + +The maximum length string literal within an ASL file is now +restricted to 200 characters as per the ACPI specification. + +Fixed a fault when using the -ln option (generate namespace +listing). + +Implemented an error check to determine if a DescriptorName +within a resource descriptor has already been used within the +current scope. + +---------------------------------------- +15 August 2005. Summary of changes for version 20050815: + +1) ACPI CA Core Subsystem: + +Implemented a full bytewise compare to determine if a table load +request is attempting to load a duplicate table. The compare is +performed if the table signatures and table lengths match. This +will allow different tables with the same OEM Table ID and +revision to be loaded - probably against the ACPI specification, +but discovered in the field nonetheless. + +Added the changes.txt logfile to each of the zipped release +packages. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.6K Code, 11.7K Data, 90.3K Total + Debug Version: 167.0K Code, 69.9K Data, 236.9K Total + Current Release: + Non-Debug Version: 78.6K Code, 11.7K Data, 90.3K Total + Debug Version: 170.0K Code, 69.9K Data, 239.9K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem where incorrect AML code could be generated for +Package objects if optimization is disabled (via the -oa switch). + +Fixed a problem with where incorrect AML code is generated for +variable-length packages when the package length is not specified +and the number of initializer values is greater than 255. + + +---------------------------------------- +29 July 2005. Summary of changes for version 20050729: + +1) ACPI CA Core Subsystem: + +Implemented support to ignore an attempt to install/load a +particular ACPI table more than once. Apparently there exists +BIOS code that repeatedly attempts to load the same SSDT upon +certain events. With assistance from Venkatesh Pallipadi. + +Restructured the main interface to the AML parser in order to +correctly handle all exceptional conditions. This will prevent +leakage of the OwnerId resource and should eliminate the +AE_OWNER_ID_LIMIT exceptions seen on some machines. With +assistance from Alexey Starikovskiy. + +Support for "module level code" has been disabled in this version +due to a number of issues that have appeared on various machines. +The support can be enabled by defining +ACPI_ENABLE_MODULE_LEVEL_CODE during subsystem compilation. When +the issues are fully resolved, the code will be enabled by +default again. + +Modified the internal functions for debug print support to define +the FunctionName parameter as a (const char *) for compatibility +with compiler built-in macros such as __FUNCTION__, etc. + +Linted the entire ACPICA source tree for both 32-bit and 64-bit. + +Implemented support to display an object count summary for the +AML Debugger commands Object and Methods. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.6K Code, 11.6K Data, 90.2K Total + Debug Version: 170.0K Code, 69.7K Data, 239.7K Total + Current Release: + Non-Debug Version: 78.6K Code, 11.7K Data, 90.3K Total + Debug Version: 167.0K Code, 69.9K Data, 236.9K Total + + +2) iASL Compiler/Disassembler: + +Fixed a regression that appeared in the 20050708 version of the +compiler where an error message was inadvertently emitted for +invocations of the _OSI reserved control method. + +---------------------------------------- +08 July 2005. Summary of changes for version 20050708: + +1) ACPI CA Core Subsystem: + +The use of the CPU stack in the debug version of the subsystem +has been considerably reduced. Previously, a debug structure was +declared in every function that used the debug macros. This +structure has been removed in favor of declaring the individual +elements as parameters to the debug functions. This reduces the +cumulative stack use during nested execution of ACPI function +calls at the cost of a small increase in the code size of the +debug version of the subsystem. With assistance from Alexey +Starikovskiy and Len Brown. + +Added the ACPI_GET_FUNCTION_NAME macro to enable the compiler- +dependent headers to define a macro that will return the current +function name at runtime (such as __FUNCTION__ or _func_, etc.) +The function name is used by the debug trace output. If +ACPI_GET_FUNCTION_NAME is not defined in the compiler-dependent +header, the function name is saved on the CPU stack (one pointer +per function.) This mechanism is used because apparently there +exists no standard ANSI-C defined macro that that returns the +function name. + +Redesigned and reimplemented the "Owner ID" mechanism used to +track namespace objects created/deleted by ACPI tables and +control method execution. A bitmap is now used to allocate and +free the IDs, thus solving the wraparound problem present in the +previous implementation. The size of the namespace node +descriptor was reduced by 2 bytes as a result (Alexey +Starikovskiy). + +Removed the UINT32_BIT and UINT16_BIT types that were used for +the bitfield flag definitions within the headers for the +predefined ACPI tables. These have been replaced by UINT8_BIT in +order to increase the code portability of the subsystem. If the +use of UINT8 remains a problem, we may be forced to eliminate +bitfields entirely because of a lack of portability. + +Enhanced the performance of the AcpiUtUpdateObjectReference +procedure. This is a frequently used function and this +improvement increases the performance of the entire subsystem +(Alexey Starikovskiy). + +Fixed several possible memory leaks and the inverse - premature +object deletion (Alexey Starikovskiy). + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.6K Code, 11.5K Data, 90.1K Total + Debug Version: 165.2K Code, 69.6K Data, 234.8K Total + Current Release: + Non-Debug Version: 78.6K Code, 11.6K Data, 90.2K Total + Debug Version: 170.0K Code, 69.7K Data, 239.7K Total + +---------------------------------------- +24 June 2005. Summary of changes for version 20050624: + +1) ACPI CA Core Subsystem: + +Modified the new OSL cache interfaces to use ACPI_CACHE_T as the +type for the host-defined cache object. This allows the OSL +implementation to define and type this object in any manner +desired, simplifying the OSL implementation. For example, +ACPI_CACHE_T is defined as kmem_cache_t for Linux, and should be +defined in the OS-specific header file for other operating +systems as required. + +Changed the interface to AcpiOsAcquireObject to directly return +the requested object as the function return (instead of +ACPI_STATUS.) This change was made for performance reasons, since +this is the purpose of the interface in the first place. +AcpiOsAcquireObject is now similar to the AcpiOsAllocate +interface. + +Implemented a new AML debugger command named Businfo. This +command displays information about all devices that have an +associate _PRT object. The _ADR, _HID, _UID, and _CID are +displayed for these devices. + +Modified the initialization sequence in AcpiInitializeSubsystem +to call the OSL interface AcpiOslInitialize first, before any +local initialization. This change was required because the global +initialization now calls OSL interfaces. + +Enhanced the Dump command to display the entire contents of +Package objects (including all sub-objects and their values.) + +Restructured the code base to split some files because of size +and/or because the code logically belonged in a separate file. +New files are listed below. All makefiles and project files +included in the ACPI CA release have been updated. + utilities/utcache.c /* Local cache interfaces */ + utilities/utmutex.c /* Local mutex support */ + utilities/utstate.c /* State object support */ + interpreter/parser/psloop.c /* Main AML parse loop */ + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.3K Code, 11.6K Data, 89.9K Total + Debug Version: 164.0K Code, 69.1K Data, 233.1K Total + Current Release: + Non-Debug Version: 78.6K Code, 11.5K Data, 90.1K Total + Debug Version: 165.2K Code, 69.6K Data, 234.8K Total + + +2) iASL Compiler/Disassembler: + +Fixed a regression introduced in version 20050513 where the use +of a Package object within a Case() statement caused a compile +time exception. The original behavior has been restored (a +Match() operator is emitted.) + +---------------------------------------- +17 June 2005. Summary of changes for version 20050617: + +1) ACPI CA Core Subsystem: + +Moved the object cache operations into the OS interface layer +(OSL) to allow the host OS to handle these operations if desired +(for example, the Linux OSL will invoke the slab allocator). This +support is optional; the compile time define ACPI_USE_LOCAL_CACHE +may be used to utilize the original cache code in the ACPI CA +core. The new OSL interfaces are shown below. See utalloc.c for +an example implementation, and acpiosxf.h for the exact interface +definitions. With assistance from Alexey Starikovskiy. + AcpiOsCreateCache + AcpiOsDeleteCache + AcpiOsPurgeCache + AcpiOsAcquireObject + AcpiOsReleaseObject + +Modified the interfaces to AcpiOsAcquireLock and +AcpiOsReleaseLock to return and restore a flags parameter. This +fits better with many OS lock models. Note: the current execution +state (interrupt handler or not) is no longer passed to these +interfaces. If necessary, the OSL must determine this state by +itself, a simple and fast operation. With assistance from Alexey +Starikovskiy. + +Fixed a problem in the ACPI table handling where a valid XSDT was +assumed present if the revision of the RSDP was 2 or greater. +According to the ACPI specification, the XSDT is optional in all +cases, and the table manager therefore now checks for both an +RSDP >=2 and a valid XSDT pointer. Otherwise, the RSDT pointer is +used. Some ACPI 2.0 compliant BIOSs contain only the RSDT. + +Fixed an interpreter problem with the Mid() operator in the case +of an input string where the resulting output string is of zero +length. It now correctly returns a valid, null terminated string +object instead of a string object with a null pointer. + +Fixed a problem with the control method argument handling to +allow a store to an Arg object that already contains an object of +type Device. The Device object is now correctly overwritten. +Previously, an error was returned. + + +Enhanced the debugger Find command to emit object values in +addition to the found object pathnames. The output format is the +same as the dump namespace command. + +Enhanced the debugger Set command. It now has the ability to set +the value of any Named integer object in the namespace +(Previously, only method locals and args could be set.) + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.1K Code, 11.6K Data, 89.7K Total + Debug Version: 164.0K Code, 69.3K Data, 233.3K Total + Current Release: + Non-Debug Version: 78.3K Code, 11.6K Data, 89.9K Total + Debug Version: 164.0K Code, 69.1K Data, 233.1K Total + + +2) iASL Compiler/Disassembler: + +Fixed a regression in the disassembler where if/else/while +constructs were output incorrectly. This problem was introduced +in the previous release (20050526). This problem also affected +the single-step disassembly in the debugger. + +Fixed a problem where compiling the reserved _OSI method would +randomly (but rarely) produce compile errors. + +Enhanced the disassembler to emit compilable code in the face of +incorrect AML resource descriptors. If the optional +ResourceSourceIndex is present, but the ResourceSource is not, do +not emit the ResourceSourceIndex in the disassembly. Otherwise, +the resulting code cannot be compiled without errors. + +---------------------------------------- +26 May 2005. Summary of changes for version 20050526: + +1) ACPI CA Core Subsystem: + +Implemented support to execute Type 1 and Type 2 AML opcodes +appearing at the module level (not within a control method.) +These opcodes are executed exactly once at the time the table is +loaded. This type of code was legal up until the release of ACPI +2.0B (2002) and is now supported within ACPI CA in order to +provide backwards compatibility with earlier BIOS +implementations. This eliminates the "Encountered executable code +at module level" warning that was previously generated upon +detection of such code. + +Fixed a problem in the interpreter where an AE_NOT_FOUND +exception could inadvertently be generated during the lookup of +namespace objects in the second pass parse of ACPI tables and +control methods. It appears that this problem could occur during +the resolution of forward references to namespace objects. + +Added the ACPI_MUTEX_DEBUG #ifdef to the AcpiUtReleaseMutex +function, corresponding to the same #ifdef in the +AcpiUtAcquireMutex function. This allows the deadlock detection +debug code to be compiled out in the normal case, improving mutex +performance (and overall subsystem performance) considerably. + +Implemented a handful of miscellaneous fixes for possible memory +leaks on error conditions and error handling control paths. These +fixes were suggested by FreeBSD and the Coverity Prevent source +code analysis tool. + +Added a check for a null RSDT pointer in AcpiGetFirmwareTable +(tbxfroot.c) to prevent a fault in this error case. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.2K Code, 11.6K Data, 89.8K Total + Debug Version: 163.7K Code, 69.3K Data, 233.0K Total + Current Release: + Non-Debug Version: 78.1K Code, 11.6K Data, 89.7K Total + Debug Version: 164.0K Code, 69.3K Data, 233.3K Total + + +2) iASL Compiler/Disassembler: + +Implemented support to allow Type 1 and Type 2 ASL operators to +appear at the module level (not within a control method.) These +operators will be executed once at the time the table is loaded. +This type of code was legal up until the release of ACPI 2.0B +(2002) and is now supported by the iASL compiler in order to +provide backwards compatibility with earlier BIOS ASL code. + +The ACPI integer width (specified via the table revision ID or +the -r override, 32 or 64 bits) is now used internally during +compile-time constant folding to ensure that constants are +truncated to 32 bits if necessary. Previously, the revision ID +value was only emitted in the AML table header. + +An error message is now generated for the Mutex and Method +operators if the SyncLevel parameter is outside the legal range +of 0 through 15. + +Fixed a problem with the Method operator ParameterTypes list +handling (ACPI 3.0). Previously, more than 2 types or 2 arguments +generated a syntax error. The actual underlying implementation +of method argument typechecking is still under development, +however. + +---------------------------------------- +13 May 2005. Summary of changes for version 20050513: + +1) ACPI CA Core Subsystem: + +Implemented support for PCI Express root bridges -- added support +for device PNP0A08 in the root bridge search within +AcpiEvPciConfigRegionSetup. + +The interpreter now automatically truncates incoming 64-bit +constants to 32 bits if currently executing out of a 32-bit ACPI +table (Revision < 2). This also affects the iASL compiler +constant folding. (Note: as per below, the iASL compiler no +longer allows 64-bit constants within 32-bit tables.) + +Fixed a problem where string and buffer objects with "static" +pointers (pointers to initialization data within an ACPI table) +were not handled consistently. The internal object copy operation +now always copies the data to a newly allocated buffer, +regardless of whether the source object is static or not. + +Fixed a problem with the FromBCD operator where an implicit +result conversion was improperly performed while storing the +result to the target operand. Since this is an "explicit +conversion" operator, the implicit conversion should never be +performed on the output. + +Fixed a problem with the CopyObject operator where a copy to an +existing named object did not always completely overwrite the +existing object stored at name. Specifically, a buffer-to-buffer +copy did not delete the existing buffer. + +Replaced "InterruptLevel" with "InterruptNumber" in all GPE +interfaces and structs for consistency. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.2K Code, 11.6K Data, 89.8K Total + Debug Version: 163.7K Code, 69.3K Data, 233.0K Total + Current Release: (Same sizes) + Non-Debug Version: 78.2K Code, 11.6K Data, 89.8K Total + Debug Version: 163.7K Code, 69.3K Data, 233.0K Total + + +2) iASL Compiler/Disassembler: + +The compiler now emits a warning if an attempt is made to +generate a 64-bit integer constant from within a 32-bit ACPI +table (Revision < 2). The integer is truncated to 32 bits. + +Fixed a problem with large package objects: if the static length +of the package is greater than 255, the "variable length package" +opcode is emitted. Previously, this caused an error. This +requires an update to the ACPI spec, since it currently +(incorrectly) states that packages larger than 255 elements are +not allowed. + +The disassembler now correctly handles variable length packages +and packages larger than 255 elements. + +---------------------------------------- +08 April 2005. Summary of changes for version 20050408: + +1) ACPI CA Core Subsystem: + +Fixed three cases in the interpreter where an "index" argument to +an ASL function was still (internally) 32 bits instead of the +required 64 bits. This was the Index argument to the Index, Mid, +and Match operators. + +The "strupr" function is now permanently local (AcpiUtStrupr), +since this is not a POSIX-defined function and not present in +most kernel-level C libraries. All references to the C library +strupr function have been removed from the headers. + +Completed the deployment of static functions/prototypes. All +prototypes with the static attribute have been moved from the +headers to the owning C file. + +Implemented an extract option (-e) for the AcpiBin utility (AML +binary utility). This option allows the utility to extract +individual ACPI tables from the output of AcpiDmp. It provides +the same functionality of the acpixtract.pl perl script without +the worry of setting the correct perl options. AcpiBin runs on +Windows and has not yet been generated/validated in the +Linux/Unix environment (but should be soon). + +Updated and fixed the table dump option for AcpiBin (-d). This +option converts a single ACPI table to a hex/ascii file, similar +to the output of AcpiDmp. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.0K Code, 11.6K Data, 89.6K Total + Debug Version: 163.5K Code, 69.3K Data, 232.8K Total + Current Release: + Non-Debug Version: 78.2K Code, 11.6K Data, 89.8K Total + Debug Version: 163.7K Code, 69.3K Data, 233.0K Total + + +2) iASL Compiler/Disassembler: + +Disassembler fix: Added a check to ensure that the table length +found in the ACPI table header within the input file is not +longer than the actual input file size. This indicates some kind +of file or table corruption. + +---------------------------------------- +29 March 2005. Summary of changes for version 20050329: + +1) ACPI CA Core Subsystem: + +An error is now generated if an attempt is made to create a +Buffer Field of length zero (A CreateField with a length operand +of zero.) + +The interpreter now issues a warning whenever executable code at +the module level is detected during ACPI table load. This will +give some idea of the prevalence of this type of code. + +Implemented support for references to named objects (other than +control methods) within package objects. + +Enhanced package object output for the debug object. Package +objects are now completely dumped, showing all elements. + +Enhanced miscellaneous object output for the debug object. Any +object can now be written to the debug object (for example, a +device object can be written, and the type of the object will be +displayed.) + +The "static" qualifier has been added to all local functions +across both the core subsystem and the iASL compiler. + +The number of "long" lines (> 80 chars) within the source has +been significantly reduced, by about 1/3. + +Cleaned up all header files to ensure that all CA/iASL functions +are prototyped (even static functions) and the formatting is +consistent. + +Two new header files have been added, acopcode.h and acnames.h. + +Removed several obsolete functions that were no longer used. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.4K Code, 69.7K Data, 236.1K Total + Current Release: + Non-Debug Version: 78.0K Code, 11.6K Data, 89.6K Total + Debug Version: 163.5K Code, 69.3K Data, 232.8K Total + + + +2) iASL Compiler/Disassembler: + +Fixed a problem with the resource descriptor generation/support. +For the ResourceSourceIndex and the ResourceSource fields, both +must be present, or both must be not present - can't have one +without the other. + +The compiler now returns non-zero from the main procedure if any +errors have occurred during the compilation. + + +---------------------------------------- +09 March 2005. Summary of changes for version 20050309: + +1) ACPI CA Core Subsystem: + +The string-to-buffer implicit conversion code has been modified +again after a change to the ACPI specification. In order to +match the behavior of the other major ACPI implementation, the +target buffer is no longer truncated if the source string is +smaller than an existing target buffer. This change requires an +update to the ACPI spec, and should eliminate the recent +AE_AML_BUFFER_LIMIT issues. + +The "implicit return" support was rewritten to a new algorithm +that solves the general case. Rather than attempt to determine +when a method is about to exit, the result of every ASL operator +is saved momentarily until the very next ASL operator is +executed. Therefore, no matter how the method exits, there will +always be a saved implicit return value. This feature is only +enabled with the AcpiGbl_EnableInterpreterSlack flag, and should +eliminate AE_AML_NO_RETURN_VALUE errors when enabled. + +Implemented implicit conversion support for the predicate +(operand) of the If, Else, and While operators. String and Buffer +arguments are automatically converted to Integers. + +Changed the string-to-integer conversion behavior to match the +new ACPI errata: "If no integer object exists, a new integer is +created. The ASCII string is interpreted as a hexadecimal +constant. Each string character is interpreted as a hexadecimal +value (`0'-`9', `A'-`F', `a', `f'), starting with the first +character as the most significant digit, and ending with the +first non-hexadecimal character or end-of-string." This means +that the first non-hex character terminates the conversion and +this is the code that was changed. + +Fixed a problem where the ObjectType operator would fail (fault) +when used on an Index of a Package which pointed to a null +package element. The operator now properly returns zero +(Uninitialized) in this case. + +Fixed a problem where the While operator used excessive memory by +not properly popping the result stack during execution. There was +no memory leak after execution, however. (Code provided by Valery +Podrezov.) + +Fixed a problem where references to control methods within +Package objects caused the method to be invoked, instead of +producing a reference object pointing to the method. + +Restructured and simplified the pswalk.c module +(AcpiPsDeleteParseTree) to improve performance and reduce code +size. (Code provided by Alexey Starikovskiy.) + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.4K Code, 69.6K Data, 236.0K Total + Current Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.4K Code, 69.7K Data, 236.1K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem with the Return operator with no arguments. Since +the AML grammar for the byte encoding requires an operand for the +Return opcode, the compiler now emits a Return(Zero) for this +case. An ACPI specification update has been written for this +case. + +For tables other than the DSDT, namepath optimization is +automatically disabled. This is because SSDTs can be loaded +anywhere in the namespace, the compiler has no knowledge of +where, and thus cannot optimize namepaths. + +Added "ProcessorObj" to the ObjectTypeKeyword list. This object +type was inadvertently omitted from the ACPI specification, and +will require an update to the spec. + +The source file scan for ASCII characters is now optional (-a). +This change was made because some vendors place non-ascii +characters within comments. However, the scan is simply a brute- +force byte compare to ensure all characters in the file are in +the range 0x00 to 0x7F. + +Fixed a problem with the CondRefOf operator where the compiler +was inappropriately checking for the existence of the target. +Since the point of the operator is to check for the existence of +the target at run-time, the compiler no longer checks for the +target existence. + +Fixed a problem where errors generated from the internal AML +interpreter during constant folding were not handled properly, +causing a fault. + +Fixed a problem with overly aggressive range checking for the +Stall operator. The valid range (max 255) is now only checked if +the operand is of type Integer. All other operand types cannot be +statically checked. + +Fixed a problem where control method references within the RefOf, +DeRefOf, and ObjectType operators were not treated properly. They +are now treated as actual references, not method invocations. + +Fixed and enhanced the "list namespace" option (-ln). This option +was broken a number of releases ago. + +Improved error handling for the Field, IndexField, and BankField +operators. The compiler now cleanly reports and recovers from +errors in the field component (FieldUnit) list. + +Fixed a disassembler problem where the optional +ResourceDescriptor fields TRS and TTP were not always handled +correctly. + +Disassembler - Comments in output now use "//" instead of "/*" + +---------------------------------------- +28 February 2005. Summary of changes for version 20050228: + +1) ACPI CA Core Subsystem: + +Fixed a problem where the result of an Index() operator (an +object reference) must increment the reference count on the +target object for the life of the object reference. + +Implemented AML Interpreter and Debugger support for the new ACPI +3.0 Extended Address (IO, Memory, Space), QwordSpace, DwordSpace, +and WordSpace resource descriptors. + +Implemented support in the _OSI method for the ACPI 3.0 "Extended +Address Space Descriptor" string, indicating interpreter support +for the descriptors above. + +Implemented header support for the new ACPI 3.0 FADT flag bits. + +Implemented header support for the new ACPI 3.0 PCI Express bits +for the PM1 status/enable registers. + +Updated header support for the MADT processor local Apic struct +and MADT platform interrupt source struct for new ACPI 3.0 +fields. + +Implemented header support for the SRAT and SLIT ACPI tables. + +Implemented the -s switch in AcpiExec to enable the +"InterpreterSlack" flag at runtime. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.2K Code, 11.5K Data, 89.7K Total + Debug Version: 164.9K Code, 69.2K Data, 234.1K Total + Current Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.4K Code, 69.6K Data, 236.0K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem with the internal 64-bit String-to-integer +conversion with strings less than two characters long. + +Fixed a problem with constant folding where the result of the +Index() operator can not be considered a constant. This means +that Index() cannot be a type3 opcode and this will require an +update to the ACPI specification. + +Disassembler: Implemented support for the TTP, MTP, and TRS +resource descriptor fields. These fields were inadvertently +ignored and not output in the disassembly of the resource +descriptor. + + + ---------------------------------------- +11 February 2005. Summary of changes for version 20050211: + +1) ACPI CA Core Subsystem: + +Implemented ACPI 3.0 support for implicit conversion within the +Match() operator. MatchObjects can now be of type integer, +buffer, or string instead of just type integer. Package elements +are implicitly converted to the type of the MatchObject. This +change aligns the behavior of Match() with the behavior of the +other logical operators (LLess(), etc.) It also requires an +errata change to the ACPI specification as this support was +intended for ACPI 3.0, but was inadvertently omitted. + +Fixed a problem with the internal implicit "to buffer" +conversion. Strings that are converted to buffers will cause +buffer truncation if the string is smaller than the target +buffer. Integers that are converted to buffers will not cause +buffer truncation, only zero extension (both as per the ACPI +spec.) The problem was introduced when code was added to truncate +the buffer, but this should not be performed in all cases, only +the string case. + +Fixed a problem with the Buffer and Package operators where the +interpreter would get confused if two such operators were used as +operands to an ASL operator (such as +LLess(Buffer(1){0},Buffer(1){1}). The internal result stack was +not being popped after the execution of these operators, +resulting in an AE_NO_RETURN_VALUE exception. + +Fixed a problem with constructs of the form +Store(Index(...),...). The reference object returned from Index +was inadvertently resolved to an actual value. This problem was +introduced in version 20050114 when the behavior of Store() was +modified to restrict the object types that can be used as the +source operand (to match the ACPI specification.) + +Reduced excessive stack use within the AcpiGetObjectInfo +procedure. + +Added a fix to aclinux.h to allow generation of AcpiExec on +Linux. + +Updated the AcpiSrc utility to add the FADT_DESCRIPTOR_REV2_MINUS +struct. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.1K Code, 11.5K Data, 89.6K Total + Debug Version: 164.8K Code, 69.2K Data, 234.0K Total + Current Release: + Non-Debug Version: 78.2K Code, 11.5K Data, 89.7K Total + Debug Version: 164.9K Code, 69.2K Data, 234.1K Total + + +2) iASL Compiler/Disassembler: + +Fixed a code generation problem in the constant folding +optimization code where incorrect code was generated if a +constant was reduced to a buffer object (i.e., a reduced type 5 +opcode.) + +Fixed a typechecking problem for the ToBuffer operator. Caused by +an incorrect return type in the internal opcode information +table. + +---------------------------------------- +25 January 2005. Summary of changes for version 20050125: + +1) ACPI CA Core Subsystem: + +Fixed a recently introduced problem with the Global Lock where +the underlying semaphore was not created. This problem was +introduced in version 20050114, and caused an AE_AML_NO_OPERAND +exception during an Acquire() operation on _GL. + +The local object cache is now optional, and is disabled by +default. Both AcpiExec and the iASL compiler enable the cache +because they run in user mode and this enhances their +performance. #define ACPI_ENABLE_OBJECT_CACHE to enable the local +cache. + +Fixed an issue in the internal function AcpiUtEvaluateObject +concerning the optional "implicit return" support where an error +was returned if no return object was expected, but one was +implicitly returned. AE_OK is now returned in this case and the +implicitly returned object is deleted. AcpiUtEvaluateObject is +only occasionally used, and only to execute reserved methods such +as _STA and _INI where the return type is known up front. + +Fixed a few issues with the internal convert-to-integer code. It +now returns an error if an attempt is made to convert a null +string, a string of only blanks/tabs, or a zero-length buffer. +This affects both implicit conversion and explicit conversion via +the ToInteger() operator. + +The internal debug code in AcpiUtAcquireMutex has been commented +out. It is not needed for normal operation and should increase +the performance of the entire subsystem. The code remains in case +it is needed for debug purposes again. + +The AcpiExec source and makefile are included in the Unix/Linux +package for the first time. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.4K Code, 11.5K Data, 89.9K Total + Debug Version: 165.4K Code, 69.4K Data, 234.8K Total + Current Release: + Non-Debug Version: 78.1K Code, 11.5K Data, 89.6K Total + Debug Version: 164.8K Code, 69.2K Data, 234.0K Total + +2) iASL Compiler/Disassembler: + +Switch/Case support: A warning is now issued if the type of the +Switch value cannot be determined at compile time. For example, +Switch(Arg0) will generate the warning, and the type is assumed +to be an integer. As per the ACPI spec, use a construct such as +Switch(ToInteger(Arg0)) to eliminate the warning. + +Switch/Case support: Implemented support for buffer and string +objects as the switch value. This is an ACPI 3.0 feature, now +that LEqual supports buffers and strings. + +Switch/Case support: The emitted code for the LEqual() +comparisons now uses the switch value as the first operand, not +the second. The case value is now the second operand, and this +allows the case value to be implicitly converted to the type of +the switch value, not the other way around. + +Switch/Case support: Temporary variables are now emitted +immediately within the control method, not at the global level. +This means that there are now 36 temps available per-method, not +36 temps per-module as was the case with the earlier +implementation (_T_0 through _T_9 and _T_A through _T_Z.) + +---------------------------------------- +14 January 2005. Summary of changes for version 20050114: + +Added 2005 copyright to all module headers. This affects every +module in the core subsystem, iASL compiler, and the utilities. + +1) ACPI CA Core Subsystem: + +Fixed an issue with the String-to-Buffer conversion code where +the string null terminator was not included in the buffer after +conversion, but there is existing ASL that assumes the string +null terminator is included. This is the root of the +ACPI_AML_BUFFER_LIMIT regression. This problem was introduced in +the previous version when the code was updated to correctly set +the converted buffer size as per the ACPI specification. The ACPI +spec is ambiguous and will be updated to specify that the null +terminator must be included in the converted buffer. This also +affects the ToBuffer() ASL operator. + +Fixed a problem with the Mid() ASL/AML operator where it did not +work correctly on Buffer objects. Newly created sub-buffers were +not being marked as initialized. + + +Fixed a problem in AcpiTbFindTable where incorrect string +compares were performed on the OemId and OemTableId table header +fields. These fields are not null terminated, so strncmp is now +used instead of strcmp. + +Implemented a restriction on the Store() ASL/AML operator to +align the behavior with the ACPI specification. Previously, any +object could be used as the source operand. Now, the only +objects that may be used are Integers, Buffers, Strings, +Packages, Object References, and DDB Handles. If necessary, the +original behavior can be restored by enabling the +EnableInterpreterSlack flag. + +Enhanced the optional "implicit return" support to allow an +implicit return value from methods that are invoked externally +via the AcpiEvaluateObject interface. This enables implicit +returns from the _STA and _INI methods, for example. + +Changed the Revision() ASL/AML operator to return the current +version of the AML interpreter, in the YYYYMMDD format. +Previously, it incorrectly returned the supported ACPI version +(This is the function of the _REV method). + +Updated the _REV predefined method to return the currently +supported version of ACPI, now 3. + +Implemented batch mode option for the AcpiExec utility (-b). + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.3K Code, 69.4K Data, 234.7K Total + Current Release: + Non-Debug Version: 78.4K Code, 11.5K Data, 89.9K Total + Debug Version: 165.4K Code, 69.4K Data, 234.8K Total + +---------------------------------------- +10 December 2004. Summary of changes for version 20041210: + +ACPI 3.0 support is nearing completion in both the iASL compiler +and the ACPI CA core subsystem. + +1) ACPI CA Core Subsystem: + +Fixed a problem in the ToDecimalString operator where the +resulting string length was incorrectly calculated. The length is +now calculated exactly, eliminating incorrect AE_STRING_LIMIT +exceptions. + +Fixed a problem in the ToHexString operator to allow a maximum +200 character string to be produced. + +Fixed a problem in the internal string-to-buffer and buffer-to- +buffer copy routine where the length of the resulting buffer was +not truncated to the new size (if the target buffer already +existed). + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 164.7K Code, 68.5K Data, 233.2K Total + Current Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.3K Code, 69.4K Data, 234.7K Total + + +2) iASL Compiler/Disassembler: + +Implemented the new ACPI 3.0 resource template macros - +DWordSpace, ExtendedIO, ExtendedMemory, ExtendedSpace, +QWordSpace, and WordSpace. Includes support in the disassembler. + +Implemented support for the new (ACPI 3.0) parameter to the +Register macro, AccessSize. + +Fixed a problem where the _HE resource name for the Interrupt +macro was referencing bit 0 instead of bit 1. + +Implemented check for maximum 255 interrupts in the Interrupt +macro. + +Fixed a problem with the predefined resource descriptor names +where incorrect AML code was generated if the offset within the +resource buffer was 0 or 1. The optimizer shortened the AML code +to a single byte opcode but did not update the surrounding +package lengths. + +Changes to the Dma macro: All channels within the channel list +must be in the range 0-7. Maximum 8 channels can be specified. +BusMaster operand is optional (default is BusMaster). + +Implemented check for maximum 7 data bytes for the VendorShort +macro. + +The ReadWrite parameter is now optional for the Memory32 and +similar macros. + +---------------------------------------- +03 December 2004. Summary of changes for version 20041203: + +1) ACPI CA Core Subsystem: + +The low-level field insertion/extraction code (exfldio) has been +completely rewritten to eliminate unnecessary complexity, bugs, +and boundary conditions. + +Fixed a problem in the ToInteger, ToBuffer, ToHexString, and +ToDecimalString operators where the input operand could be +inadvertently deleted if no conversion was necessary (e.g., if +the input to ToInteger was an Integer object.) + +Fixed a problem with the ToDecimalString and ToHexString where an +incorrect exception code was returned if the resulting string +would be > 200 chars. AE_STRING_LIMIT is now returned. + +Fixed a problem with the Concatenate operator where AE_OK was +always returned, even if the operation failed. + +Fixed a problem in oswinxf (used by AcpiExec and iASL) to allow > +128 semaphores to be allocated. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.5K Code, 11.5K Data, 90.0K Total + Debug Version: 165.2K Code, 68.6K Data, 233.8K Total + Current Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 164.7K Code, 68.5K Data, 233.2K Total + + +2) iASL Compiler/Disassembler: + +Fixed typechecking for the ObjectType and SizeOf operators. +Problem was recently introduced in 20041119. + +Fixed a problem with the ToUUID macro where the upper nybble of +each buffer byte was inadvertently set to zero. + +---------------------------------------- +19 November 2004. Summary of changes for version 20041119: + +1) ACPI CA Core Subsystem: + +Fixed a problem in the internal ConvertToInteger routine where +new integers were not truncated to 32 bits for 32-bit ACPI +tables. This routine converts buffers and strings to integers. + +Implemented support to store a value to an Index() on a String +object. This is an ACPI 2.0 feature that had not yet been +implemented. + +Implemented new behavior for storing objects to individual +package elements (via the Index() operator). The previous +behavior was to invoke the implicit conversion rules if an object +was already present at the index. The new behavior is to simply +delete any existing object and directly store the new object. +Although the ACPI specification seems unclear on this subject, +other ACPI implementations behave in this manner. (This is the +root of the AE_BAD_HEX_CONSTANT issue.) + +Modified the RSDP memory scan mechanism to support the extended +checksum for ACPI 2.0 (and above) RSDPs. Note that the search +continues until a valid RSDP signature is found with a valid +checksum. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.5K Code, 11.5K Data, 90.0K Total + Debug Version: 165.2K Code, 68.6K Data, 233.8K Total + Current Release: + Non-Debug Version: 78.5K Code, 11.5K Data, 90.0K Total + Debug Version: 165.2K Code, 68.6K Data, 233.8K Total + + +2) iASL Compiler/Disassembler: + +Fixed a missing semicolon in the aslcompiler.y file. + +---------------------------------------- +05 November 2004. Summary of changes for version 20041105: + +1) ACPI CA Core Subsystem: + +Implemented support for FADT revision 2. This was an interim +table (between ACPI 1.0 and ACPI 2.0) that adds support for the +FADT reset register. + +Implemented optional support to allow uninitialized LocalX and +ArgX variables in a control method. The variables are +initialized to an Integer object with a value of zero. This +support is enabled by setting the AcpiGbl_EnableInterpreterSlack +flag to TRUE. + +Implemented support for Integer objects for the SizeOf operator. +Either 4 or 8 is returned, depending on the current integer size +(32-bit or 64-bit, depending on the parent table revision). + +Fixed a problem in the implementation of the SizeOf and +ObjectType operators where the operand was resolved to a value +too early, causing incorrect return values for some objects. + +Fixed some possible memory leaks during exceptional conditions. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.0K Code, 11.5K Data, 89.5K Total + Debug Version: 164.8K Code, 68.6K Data, 233.4K Total + Current Release: + Non-Debug Version: 78.5K Code, 11.5K Data, 90.0K Total + Debug Version: 165.2K Code, 68.6K Data, 233.8K Total + + +2) iASL Compiler/Disassembler: + +Implemented support for all ACPI 3.0 reserved names and methods. + +Implemented all ACPI 3.0 grammar elements in the front-end, +including support for semicolons. + +Implemented the ACPI 3.0 Function() and ToUUID() macros + +Fixed a problem in the disassembler where a Scope() operator +would not be emitted properly if the target of the scope was in +another table. + +---------------------------------------- +15 October 2004. Summary of changes for version 20041015: + +Note: ACPI CA is currently undergoing an in-depth and complete +formal evaluation to test/verify the following areas. Other +suggestions are welcome. This will result in an increase in the +frequency of releases and the number of bug fixes in the next few +months. + - Functional tests for all ASL/AML operators + - All implicit/explicit type conversions + - Bit fields and operation regions + - 64-bit math support and 32-bit-only "truncated" math support + - Exceptional conditions, both compiler and interpreter + - Dynamic object deletion and memory leaks + - ACPI 3.0 support when implemented + - External interfaces to the ACPI subsystem + + +1) ACPI CA Core Subsystem: + +Fixed two alignment issues on 64-bit platforms - within debug +statements in AcpiEvGpeDetect and AcpiEvCreateGpeBlock. Removed +references to the Address field within the non-aligned ACPI +generic address structure. + +Fixed a problem in the Increment and Decrement operators where +incorrect operand resolution could result in the inadvertent +modification of the original integer when the integer is passed +into another method as an argument and the arg is then +incremented/decremented. + +Fixed a problem in the FromBCD operator where the upper 32-bits +of a 64-bit BCD number were truncated during conversion. + +Fixed a problem in the ToDecimal operator where the length of the +resulting string could be set incorrectly too long if the input +operand was a Buffer object. + +Fixed a problem in the Logical operators (LLess, etc.) where a +NULL byte (0) within a buffer would prematurely terminate a +compare between buffer objects. + +Added a check for string overflow (>200 characters as per the +ACPI specification) during the Concatenate operator with two +string operands. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.8K Code, 11.5K Data, 89.3K Total + Debug Version: 164.6K Code, 68.5K Data, 233.1K Total + Current Release: + Non-Debug Version: 78.0K Code, 11.5K Data, 89.5K Total + Debug Version: 164.8K Code, 68.6K Data, 233.4K Total + + + +2) iASL Compiler/Disassembler: + +Allow the use of the ObjectType operator on uninitialized Locals +and Args (returns 0 as per the ACPI specification). + +Fixed a problem where the compiler would fault if there was a +syntax error in the FieldName of all of the various +CreateXXXField operators. + +Disallow the use of lower case letters within the EISAID macro, +as per the ACPI specification. All EISAID strings must be of the +form "UUUNNNN" Where U is an uppercase letter and N is a hex +digit. + + +---------------------------------------- +06 October 2004. Summary of changes for version 20041006: + +1) ACPI CA Core Subsystem: + +Implemented support for the ACPI 3.0 Timer operator. This ASL +function implements a 64-bit timer with 100 nanosecond +granularity. + +Defined a new OSL interface, AcpiOsGetTimer. This interface is +used to implement the ACPI 3.0 Timer operator. This allows the +host OS to implement the timer with the best clock available. +Also, it keeps the core subsystem out of the clock handling +business, since the host OS (usually) performs this function. + +Fixed an alignment issue on 64-bit platforms. The +HwLowLevelRead(Write) functions use a 64-bit address which is +part of the packed ACPI Generic Address Structure. Since the +structure is non-aligned, the alignment macros are now used to +extract the address to a local variable before use. + +Fixed a problem where the ToInteger operator assumed all input +strings were hexadecimal. The operator now handles both decimal +strings and hex strings (prefixed with "0x"). + +Fixed a problem where the string length in the string object +created as a result of the internal ConvertToString procedure +could be incorrect. This potentially affected all implicit +conversions and also the ToDecimalString and ToHexString +operators. + +Fixed two problems in the ToString operator. If the length +parameter was zero, an incorrect string object was created and +the value of the input length parameter was inadvertently changed +from zero to Ones. + +Fixed a problem where the optional ResourceSource string in the +ExtendedIRQ resource macro was ignored. + +Simplified the interfaces to the internal division functions, +reducing code size and complexity. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.9K Code, 11.4K Data, 89.3K Total + Debug Version: 164.5K Code, 68.3K Data, 232.8K Total + Current Release: + Non-Debug Version: 77.8K Code, 11.5K Data, 89.3K Total + Debug Version: 164.6K Code, 68.5K Data, 233.1K Total + + +2) iASL Compiler/Disassembler: + +Implemented support for the ACPI 3.0 Timer operator. + +Fixed a problem where the Default() operator was inadvertently +ignored in a Switch/Case block. This was a problem in the +translation of the Switch statement to If...Else pairs. + +Added support to allow a standalone Return operator, with no +parentheses (or operands). + +Fixed a problem with code generation for the ElseIf operator +where the translated Else...If parse tree was improperly +constructed leading to the loss of some code. + +---------------------------------------- +22 September 2004. Summary of changes for version 20040922: + +1) ACPI CA Core Subsystem: + +Fixed a problem with the implementation of the LNot() operator +where "Ones" was not returned for the TRUE case. Changed the code +to return Ones instead of (!Arg) which was usually 1. This change +affects iASL constant folding for this operator also. + +Fixed a problem in AcpiUtInitializeBuffer where an existing +buffer was not initialized properly -- Now zero the entire buffer +in this case where the buffer already exists. + +Changed the interface to AcpiOsSleep from (UINT32 Seconds, UINT32 +Milliseconds) to simply (ACPI_INTEGER Milliseconds). This +simplifies all related code considerably. This will require +changes/updates to all OS interface layers (OSLs.) + +Implemented a new external interface, +AcpiInstallExceptionHandler, to allow a system exception handler +to be installed. This handler is invoked upon any run-time +exception that occurs during control method execution. + +Added support for the DSDT in AcpiTbFindTable. This allows the +DataTableRegion() operator to access the local copy of the DSDT. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.8K Code, 11.4K Data, 89.2K Total + Debug Version: 164.2K Code, 68.2K Data, 232.4K Total + Current Release: + Non-Debug Version: 77.9K Code, 11.4K Data, 89.3K Total + Debug Version: 164.5K Code, 68.3K Data, 232.8K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem with constant folding and the LNot operator. LNot +was returning 1 in the TRUE case, not Ones as per the ACPI +specification. This could result in the generation of an +incorrect folded/reduced constant. + +End-Of-File is now allowed within a "//"-style comment. A parse +error no longer occurs if such a comment is at the very end of +the input ASL source file. + +Implemented the "-r" option to override the Revision in the table +header. The initial use of this option will be to simplify the +evaluation of the AML interpreter by allowing a single ASL source +module to be compiled for either 32-bit or 64-bit integers. + + +---------------------------------------- +27 August 2004. Summary of changes for version 20040827: + +1) ACPI CA Core Subsystem: + +- Implemented support for implicit object conversion in the non- +numeric logical operators (LEqual, LGreater, LGreaterEqual, +LLess, LLessEqual, and LNotEqual.) Any combination of +Integers/Strings/Buffers may now be used; the second operand is +implicitly converted on the fly to match the type of the first +operand. For example: + + LEqual (Source1, Source2) + +Source1 and Source2 must each evaluate to an integer, a string, +or a buffer. The data type of Source1 dictates the required type +of Source2. Source2 is implicitly converted if necessary to match +the type of Source1. + +- Updated and corrected the behavior of the string conversion +support. The rules concerning conversion of buffers to strings +(according to the ACPI specification) are as follows: + +ToDecimalString - explicit byte-wise conversion of buffer to +string of decimal values (0-255) separated by commas. ToHexString +- explicit byte-wise conversion of buffer to string of hex values +(0-FF) separated by commas. ToString - explicit byte-wise +conversion of buffer to string. Byte-by-byte copy with no +transform except NULL terminated. Any other implicit buffer-to- +string conversion - byte-wise conversion of buffer to string of +hex values (0-FF) separated by spaces. + +- Fixed typo in definition of AcpiGbl_EnableInterpreterSlack. + +- Fixed a problem in AcpiNsGetPathnameLength where the returned +length was one byte too short in the case of a node in the root +scope. This could cause a fault during debug output. + +- Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.9K Code, 11.5K Data, 89.4K Total + Debug Version: 164.1K Code, 68.3K Data, 232.4K Total + Current Release: + Non-Debug Version: 77.8K Code, 11.4K Data, 89.2K Total + Debug Version: 164.2K Code, 68.2K Data, 232.4K Total + + +2) iASL Compiler/Disassembler: + +- Fixed a Linux generation error. + + +---------------------------------------- +16 August 2004. Summary of changes for version 20040816: + +1) ACPI CA Core Subsystem: + +Designed and implemented support within the AML interpreter for +the so-called "implicit return". This support returns the result +of the last ASL operation within a control method, in the absence +of an explicit Return() operator. A few machines depend on this +behavior, even though it is not explicitly supported by the ASL +language. It is optional support that can be enabled at runtime +via the AcpiGbl_EnableInterpreterSlack flag. + +Removed support for the PCI_Config address space from the +internal low level hardware interfaces (AcpiHwLowLevelRead and +AcpiHwLowLevelWrite). This support was not used internally, and +would not work correctly anyway because the PCI bus number and +segment number were not supported. There are separate interfaces +for PCI configuration space access because of the unique +interface. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.0K Code, 11.5K Data, 89.5K Total + Debug Version: 164.1K Code, 68.2K Data, 232.3K Total + Current Release: + Non-Debug Version: 77.9K Code, 11.5K Data, 89.4K Total + Debug Version: 164.1K Code, 68.3K Data, 232.4K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem where constants in ASL expressions at the root +level (not within a control method) could be inadvertently +truncated during code generation. This problem was introduced in +the 20040715 release. + + +---------------------------------------- +15 July 2004. Summary of changes for version 20040715: + +1) ACPI CA Core Subsystem: + +Restructured the internal HW GPE interfaces to pass/track the +current state of interrupts (enabled/disabled) in order to avoid +possible deadlock and increase flexibility of the interfaces. + +Implemented a "lexicographical compare" for String and Buffer +objects within the logical operators -- LGreater, LLess, +LGreaterEqual, and LLessEqual -- as per further clarification to +the ACPI specification. Behavior is similar to C library +"strcmp". + +Completed a major reduction in CPU stack use for the +AcpiGetFirmwareTable external function. In the 32-bit non-debug +case, the stack use has been reduced from 168 bytes to 32 bytes. + +Deployed a new run-time configuration flag, +AcpiGbl_EnableInterpreterSlack, whose purpose is to allow the AML +interpreter to forgive certain bad AML constructs. Default +setting is FALSE. + +Implemented the first use of AcpiGbl_EnableInterpreterSlack in +the Field IO support code. If enabled, it allows field access to +go beyond the end of a region definition if the field is within +the region length rounded up to the next access width boundary (a +common coding error.) + +Renamed OSD_HANDLER to ACPI_OSD_HANDLER, and +OSD_EXECUTION_CALLBACK to ACPI_OSD_EXEC_CALLBACK for consistency +with other ACPI symbols. Also, these symbols are lowercased by +the latest version of the AcpiSrc tool. + +The prototypes for the PCI interfaces in acpiosxf.h have been +updated to rename "Register" to simply "Reg" to prevent certain +compilers from complaining. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.8K Code, 11.5K Data, 89.3K Total + Debug Version: 163.8K Code, 68.2K Data, 232.0K Total + Current Release: + Non-Debug Version: 78.0K Code, 11.5K Data, 89.5K Total + Debug Version: 164.1K Code, 68.2K Data, 232.3K Total + + +2) iASL Compiler/Disassembler: + +Implemented full support for Package objects within the Case() +operator. Note: The Break() operator is currently not supported +within Case blocks (TermLists) as there is some question about +backward compatibility with ACPI 1.0 interpreters. + + +Fixed a problem where complex terms were not supported properly +within the Switch() operator. + +Eliminated extraneous warning for compiler-emitted reserved names +of the form "_T_x". (Used in Switch/Case operators.) + +Eliminated optimization messages for "_T_x" objects and small +constants within the DefinitionBlock operator. + + +---------------------------------------- +15 June 2004. Summary of changes for version 20040615: + +1) ACPI CA Core Subsystem: + +Implemented support for Buffer and String objects (as per ACPI +2.0) for the following ASL operators: LEqual, LGreater, LLess, +LGreaterEqual, and LLessEqual. + +All directory names in the entire source package are lower case, +as they were in earlier releases. + +Implemented "Disassemble" command in the AML debugger that will +disassemble a single control method. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.7K Code, 11.5K Data, 89.2K Total + Debug Version: 163.3K Code, 67.2K Data, 230.5K Total + + Current Release: + Non-Debug Version: 77.8K Code, 11.5K Data, 89.3K Total + Debug Version: 163.8K Code, 68.2K Data, 232.0K Total + + +2) iASL Compiler/Disassembler: + +Implemented support for Buffer and String objects (as per ACPI +2.0) for the following ASL operators: LEqual, LGreater, LLess, +LGreaterEqual, and LLessEqual. + +All directory names in the entire source package are lower case, +as they were in earlier releases. + +Fixed a fault when using the -g or -d<nofilename> options if the +FADT was not found. + +Fixed an issue with the Windows version of the compiler where +later versions of Windows place the FADT in the registry under +the name "FADT" and not "FACP" as earlier versions did. This +applies when using the -g or -d<nofilename> options. The +compiler now looks for both strings as necessary. + +Fixed a problem with compiler namepath optimization where a +namepath within the Scope() operator could not be optimized if +the namepath was a subpath of the current scope path. + +---------------------------------------- +27 May 2004. Summary of changes for version 20040527: + +1) ACPI CA Core Subsystem: + +Completed a new design and implementation for EBDA (Extended BIOS +Data Area) support in the RSDP scan code. The original code +improperly scanned for the EBDA by simply scanning from memory +location 0 to 0x400. The correct method is to first obtain the +EBDA pointer from within the BIOS data area, then scan 1K of +memory starting at the EBDA pointer. There appear to be few if +any machines that place the RSDP in the EBDA, however. + +Integrated a fix for a possible fault during evaluation of +BufferField arguments. Obsolete code that was causing the +problem was removed. + +Found and fixed a problem in the Field Support Code where data +could be corrupted on a bit field read that starts on an aligned +boundary but does not end on an aligned boundary. Merged the +read/write "datum length" calculation code into a common +procedure. + +Rolled in a couple of changes to the FreeBSD-specific header. + + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.6K Code, 11.5K Data, 89.1K Total + Debug Version: 163.2K Code, 67.2K Data, 230.4K Total + Current Release: + Non-Debug Version: 77.7K Code, 11.5K Data, 89.2K Total + Debug Version: 163.3K Code, 67.2K Data, 230.5K Total + + +2) iASL Compiler/Disassembler: + +Fixed a generation warning produced by some overly-verbose +compilers for a 64-bit constant. + +---------------------------------------- +14 May 2004. Summary of changes for version 20040514: + +1) ACPI CA Core Subsystem: + +Fixed a problem where hardware GPE enable bits sometimes not set +properly during and after GPE method execution. Result of 04/27 +changes. + +Removed extra "clear all GPEs" when sleeping/waking. + +Removed AcpiHwEnableGpe and AcpiHwDisableGpe, replaced by the +single AcpiHwWriteGpeEnableReg. Changed a couple of calls to the +functions above to the new AcpiEv* calls as appropriate. + +ACPI_OS_NAME was removed from the OS-specific headers. The +default name is now "Microsoft Windows NT" for maximum +compatibility. However this can be changed by modifying the +acconfig.h file. + +Allow a single invocation of AcpiInstallNotifyHandler for a +handler that traps both types of notifies (System, Device). Use +ACPI_ALL_NOTIFY flag. + +Run _INI methods on ThermalZone objects. This is against the +ACPI specification, but there is apparently ASL code in the field +that has these _INI methods, and apparently "other" AML +interpreters execute them. + +Performed a full 16/32/64 bit lint that resulted in some small +changes. + +Added a sleep simulation command to the AML debugger to test +sleep code. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.6K Code, 11.5K Data, 89.1K Total + Debug Version: 162.9K Code, 67.0K Data, 229.9K Total + Current Release: + Non-Debug Version: 77.6K Code, 11.5K Data, 89.1K Total + Debug Version: 163.2K Code, 67.2K Data, 230.4K Total + +---------------------------------------- +27 April 2004. Summary of changes for version 20040427: + +1) ACPI CA Core Subsystem: + +Completed a major overhaul of the GPE handling within ACPI CA. +There are now three types of GPEs: wake-only, runtime-only, and +combination wake/run. The only GPEs allowed to be combination +wake/run are for button-style devices such as a control-method +power button, control-method sleep button, or a notebook lid +switch. GPEs that have an _Lxx or _Exx method and are not +referenced by any _PRW methods are marked for "runtime" and +hardware enabled. Any GPE that is referenced by a _PRW method is +marked for "wake" (and disabled at runtime). However, at sleep +time, only those GPEs that have been specifically enabled for +wake via the AcpiEnableGpe interface will actually be hardware +enabled. + +A new external interface has been added, AcpiSetGpeType(), that +is meant to be used by device drivers to force a GPE to a +particular type. It will be especially useful for the drivers +for the button devices mentioned above. + +Completed restructuring of the ACPI CA initialization sequence so +that default operation region handlers are installed before GPEs +are initialized and the _PRW methods are executed. This will +prevent errors when the _PRW methods attempt to access system +memory or I/O space. + +GPE enable/disable no longer reads the GPE enable register. We +now keep the enable info for runtime and wake separate and in the +GPE_EVENT_INFO. We thus no longer depend on the hardware to +maintain these bits. + +Always clear the wake status and fixed/GPE status bits before +sleep, even for state S5. + +Improved the AML debugger output for displaying the GPE blocks +and their current status. + +Added new strings for the _OSI method, of the form "Windows 2001 +SPx" where x = 0,1,2,3,4. + +Fixed a problem where the physical address was incorrectly +calculated when the Load() operator was used to directly load +from an Operation Region (vs. loading from a Field object.) Also +added check for minimum table length for this case. + +Fix for multiple mutex acquisition. Restore original thread +SyncLevel on mutex release. + +Added ACPI_VALID_SXDS flag to the AcpiGetObjectInfo interface for +consistency with the other fields returned. + +Shrunk the ACPI_GPE_EVENT_INFO structure by 40%. There is one +such structure for each GPE in the system, so the size of this +structure is important. + +CPU stack requirement reduction: Cleaned up the method execution +and object evaluation paths so that now a parameter structure is +passed, instead of copying the various method parameters over and +over again. + +In evregion.c: Correctly exit and reenter the interpreter region +if and only if dispatching an operation region request to a user- +installed handler. Do not exit/reenter when dispatching to a +default handler (e.g., default system memory or I/O handlers) + + +Notes for updating drivers for the new GPE support. The +following changes must be made to ACPI-related device drivers +that are attached to one or more GPEs: (This information will be +added to the ACPI CA Programmer Reference.) + +1) AcpiInstallGpeHandler no longer automatically enables the GPE, +you must explicitly call AcpiEnableGpe. +2) There is a new interface called AcpiSetGpeType. This should be +called before enabling the GPE. Also, this interface will +automatically disable the GPE if it is currently enabled. +3) AcpiEnableGpe no longer supports a GPE type flag. + +Specific drivers that must be changed: +1) EC driver: + AcpiInstallGpeHandler (NULL, GpeNum, ACPI_GPE_EDGE_TRIGGERED, +AeGpeHandler, NULL); + AcpiSetGpeType (NULL, GpeNum, ACPI_GPE_TYPE_RUNTIME); + AcpiEnableGpe (NULL, GpeNum, ACPI_NOT_ISR); + +2) Button Drivers (Power, Lid, Sleep): +Run _PRW method under parent device +If _PRW exists: /* This is a control-method button */ + Extract GPE number and possibly GpeDevice + AcpiSetGpeType (GpeDevice, GpeNum, ACPI_GPE_TYPE_WAKE_RUN); + AcpiEnableGpe (GpeDevice, GpeNum, ACPI_NOT_ISR); + +For all other devices that have _PRWs, we automatically set the +GPE type to ACPI_GPE_TYPE_WAKE, but the GPE is NOT automatically +(wake) enabled. This must be done on a selective basis, usually +requiring some kind of user app to allow the user to pick the +wake devices. + + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.0K Code, 11.4K Data, 88.4K Total + Debug Version: 161.0K Code, 66.3K Data, 227.3K Total + Current Release: + + Non-Debug Version: 77.6K Code, 11.5K Data, 89.1K Total + Debug Version: 162.9K Code, 67.0K Data, 229.9K Total + + + +---------------------------------------- +02 April 2004. Summary of changes for version 20040402: + +1) ACPI CA Core Subsystem: + +Fixed an interpreter problem where an indirect store through an +ArgX parameter was incorrectly applying the "implicit conversion +rules" during the store. From the ACPI specification: "If the +target is a method local or argument (LocalX or ArgX), no +conversion is performed and the result is stored directly to the +target". The new behavior is to disable implicit conversion +during ALL stores to an ArgX. + +Changed the behavior of the _PRW method scan to ignore any and +all errors returned by a given _PRW. This prevents the scan from +aborting from the failure of any single _PRW. + +Moved the runtime configuration parameters from the global init +procedure to static variables in acglobal.h. This will allow the +host to override the default values easily. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 76.9K Code, 11.4K Data, 88.3K Total + Debug Version: 160.8K Code, 66.1K Data, 226.9K Total + Current Release: + Non-Debug Version: 77.0K Code, 11.4K Data, 88.4K Total + Debug Version: 161.0K Code, 66.3K Data, 227.3K Total + + +2) iASL Compiler/Disassembler: + +iASL now fully disassembles SSDTs. However, External() +statements are not generated automatically for unresolved symbols +at this time. This is a planned feature for future +implementation. + +Fixed a scoping problem in the disassembler that occurs when the +type of the target of a Scope() operator is overridden. This +problem caused an incorrectly nested internal namespace to be +constructed. + +Any warnings or errors that are emitted during disassembly are +now commented out automatically so that the resulting file can be +recompiled without any hand editing. + +---------------------------------------- +26 March 2004. Summary of changes for version 20040326: + +1) ACPI CA Core Subsystem: + +Implemented support for "wake" GPEs via interaction between GPEs +and the _PRW methods. Every GPE that is pointed to by one or +more _PRWs is identified as a WAKE GPE and by default will no +longer be enabled at runtime. Previously, we were blindly +enabling all GPEs with a corresponding _Lxx or _Exx method - but +most of these turn out to be WAKE GPEs anyway. We believe this +has been the cause of thousands of "spurious" GPEs on some +systems. + +This new GPE behavior is can be reverted to the original behavior +(enable ALL GPEs at runtime) via a runtime flag. + +Fixed a problem where aliased control methods could not access +objects properly. The proper scope within the namespace was not +initialized (transferred to the target of the aliased method) +before executing the target method. + +Fixed a potential race condition on internal object deletion on +the return object in AcpiEvaluateObject. + +Integrated a fix for resource descriptors where both _MEM and +_MTP were being extracted instead of just _MEM. (i.e. bitmask +was incorrectly too wide, 0x0F instead of 0x03.) + +Added a special case for ACPI_ROOT_OBJECT in AcpiUtGetNodeName, +preventing a fault in some cases. + +Updated Notify() values for debug statements in evmisc.c + +Return proper status from AcpiUtMutexInitialize, not just simply +AE_OK. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + + Non-Debug Version: 76.5K Code, 11.3K Data, 87.8K Total + Debug Version: 160.3K Code, 66.0K Data, 226.3K Total + Current Release: + Non-Debug Version: 76.9K Code, 11.4K Data, 88.3K Total + Debug Version: 160.8K Code, 66.1K Data, 226.9K Total + +---------------------------------------- +11 March 2004. Summary of changes for version 20040311: + +1) ACPI CA Core Subsystem: + +Fixed a problem where errors occurring during the parse phase of +control method execution did not abort cleanly. For example, +objects created and installed in the namespace were not deleted. +This caused all subsequent invocations of the method to return +the AE_ALREADY_EXISTS exception. + +Implemented a mechanism to force a control method to "Serialized" +execution if the method attempts to create namespace objects. +(The root of the AE_ALREADY_EXISTS problem.) + +Implemented support for the predefined _OSI "internal" control +method. Initial supported strings are "Linux", "Windows 2000", +"Windows 2001", and "Windows 2001.1", and can be easily upgraded +for new strings as necessary. This feature will allow "other" +operating systems to execute the fully tested, "Windows" code +path through the ASL code + +Global Lock Support: Now allows multiple acquires and releases +with any internal thread. Removed concept of "owning thread" for +this special mutex. + +Fixed two functions that were inappropriately declaring large +objects on the CPU stack: PsParseLoop, NsEvaluateRelative. +Reduces the stack usage during method execution considerably. + +Fixed a problem in the ACPI 2.0 FACS descriptor (actbl2.h) where +the S4Bios_f field was incorrectly defined as UINT32 instead of +UINT32_BIT. + +Fixed a problem where AcpiEvGpeDetect would fault if there were +no GPEs defined on the machine. + +Implemented two runtime options: One to force all control method +execution to "Serialized" to mimic Windows behavior, another to +disable _OSI support if it causes problems on a given machine. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 74.8K Code, 10.1K Data, 84.9K Total + Debug Version: 158.7K Code, 65.1K Data, 223.8K Total + Current Release: + Non-Debug Version: 76.5K Code, 11.3K Data, 87.8K Total + Debug Version: 160.3K Code, 66.0K Data, 226.3K Total + +2) iASL Compiler/Disassembler: + +Fixed an array size problem for FreeBSD that would cause the +compiler to fault. + +---------------------------------------- +20 February 2004. Summary of changes for version 20040220: + + +1) ACPI CA Core Subsystem: + +Implemented execution of _SxD methods for Device objects in the +GetObjectInfo interface. + +Fixed calls to _SST method to pass the correct arguments. + +Added a call to _SST on wake to restore to "working" state. + +Check for End-Of-Buffer failure case in the WalkResources +interface. + +Integrated fix for 64-bit alignment issue in acglobal.h by moving +two structures to the beginning of the file. + +After wake, clear GPE status register(s) before enabling GPEs. + +After wake, clear/enable power button. (Perhaps we should +clear/enable all fixed events upon wake.) + +Fixed a couple of possible memory leaks in the Namespace manager. + +Integrated latest acnetbsd.h file. + +---------------------------------------- +11 February 2004. Summary of changes for version 20040211: + + +1) ACPI CA Core Subsystem: + +Completed investigation and implementation of the call-by- +reference mechanism for control method arguments. + +Fixed a problem where a store of an object into an indexed +package could fail if the store occurs within a different method +than the method that created the package. + +Fixed a problem where the ToDecimal operator could return +incorrect results. + +Fixed a problem where the CopyObject operator could fail on some +of the more obscure objects (e.g., Reference objects.) + +Improved the output of the Debug object to display buffer, +package, and index objects. + +Fixed a problem where constructs of the form "RefOf (ArgX)" did +not return the expected result. + +Added permanent ACPI_REPORT_ERROR macros for all instances of the +ACPI_AML_INTERNAL exception. + +Integrated latest version of acfreebsd.h + +---------------------------------------- +16 January 2004. Summary of changes for version 20040116: + +The purpose of this release is primarily to update the copyright +years in each module, thus causing a huge number of diffs. There +are a few small functional changes, however. + +1) ACPI CA Core Subsystem: + +Improved error messages when there is a problem finding one or +more of the required base ACPI tables + +Reintroduced the definition of APIC_HEADER in actbl.h + +Changed definition of MADT_ADDRESS_OVERRIDE to 64 bits (actbl.h) + +Removed extraneous reference to NewObj in dsmthdat.c + +2) iASL compiler + +Fixed a problem introduced in December that disabled the correct +disassembly of Resource Templates + + +---------------------------------------- +03 December 2003. Summary of changes for version 20031203: + +1) ACPI CA Core Subsystem: + +Changed the initialization of Operation Regions during subsystem +init to perform two entire walks of the ACPI namespace; The first +to initialize the regions themselves, the second to execute the +_REG methods. This fixed some interdependencies across _REG +methods found on some machines. + +Fixed a problem where a Store(Local0, Local1) could simply update +the object reference count, and not create a new copy of the +object if the Local1 is uninitialized. + +Implemented support for the _SST reserved method during sleep +transitions. + +Implemented support to clear the SLP_TYP and SLP_EN bits when +waking up, this is apparently required by some machines. + +When sleeping, clear the wake status only if SleepState is not +S5. + +Fixed a problem in AcpiRsExtendedIrqResource() where an incorrect +pointer arithmetic advanced a string pointer too far. + +Fixed a problem in AcpiTbGetTablePtr() where a garbage pointer +could be returned if the requested table has not been loaded. + +Within the support for IRQ resources, restructured the handling +of +the active and edge/level bits. + +Fixed a few problems in AcpiPsxExecute() where memory could be +leaked under certain error conditions. + +Improved error messages for the cases where the ACPI mode could +not be entered. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler +and the compiler options used during generation. + + Previous Release (20031029): + Non-Debug Version: 74.4K Code, 10.1K Data, 84.5K Total + Debug Version: 158.3K Code, 65.0K Data, 223.3K Total + Current Release: + Non-Debug Version: 74.8K Code, 10.1K Data, 84.9K Total + Debug Version: 158.7K Code, 65.1K Data, 223.8K Total + +2) iASL Compiler/Disassembler: + +Implemented a fix for the iASL disassembler where a bad index was +generated. This was most noticeable on 64-bit platforms + + +---------------------------------------- +29 October 2003. Summary of changes for version 20031029: + +1) ACPI CA Core Subsystem: + + +Fixed a problem where a level-triggered GPE with an associated +_Lxx control method was incorrectly cleared twice. + +Fixed a problem with the Field support code where an access can +occur beyond the end-of-region if the field is non-aligned but +extends to the very end of the parent region (resulted in an +AE_AML_REGION_LIMIT exception.) + +Fixed a problem with ACPI Fixed Events where an RT Clock handler +would not get invoked on an RTC event. The RTC event bitmasks +for +the PM1 registers were not being initialized properly. + +Implemented support for executing _STA and _INI methods for +Processor objects. Although this is currently not part of the +ACPI specification, there is existing ASL code that depends on +the +init-time execution of these methods. + +Implemented and deployed a GetDescriptorName function to decode +the various types of internal descriptors. Guards against null +descriptors during debug output also. + +Implemented and deployed a GetNodeName function to extract the 4- +character namespace node name. This function simplifies the +debug +and error output, as well as guarding against null pointers +during +output. + +Implemented and deployed the ACPI_FORMAT_UINT64 helper macro to +simplify the debug and error output of 64-bit integers. This +macro replaces the HIDWORD and LODWORD macros for dumping these +integers. + +Updated the implementation of the Stall() operator to only call +AcpiOsStall(), and also return an error if the operand is larger +than 255. This preserves the required behavior of not +relinquishing the processor, as would happen if AcpiOsSleep() was +called for "long stalls". + +Constructs of the form "Store(LocalX,LocalX)" where LocalX is not +initialized are now treated as NOOPs. + +Cleaned up a handful of warnings during 64-bit generation. + +Fixed a reported error where and incorrect GPE number was passed +to the GPE dispatch handler. This value is only used for error +output, however. Used this opportunity to clean up and +streamline +the GPE dispatch code. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The + +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler +and the compiler options used during generation. + + Previous Release (20031002): + Non-Debug Version: 74.1K Code, 9.7K Data, 83.8K Total + Debug Version: 157.9K Code, 64.8K Data, 222.7K Total + Current Release: + Non-Debug Version: 74.4K Code, 10.1K Data, 84.5K Total + Debug Version: 158.3K Code, 65.0K Data, 223.3K Total + + +2) iASL Compiler/Disassembler: + +Updated the iASL compiler to return an error if the operand to +the +Stall() operator is larger than 255. + + +---------------------------------------- +02 October 2003. Summary of changes for version 20031002: + + +1) ACPI CA Core Subsystem: + +Fixed a problem with Index Fields where the index was not +incremented for fields that require multiple writes to the +index/data registers (Fields that are wider than the data +register.) + +Fixed a problem with all Field objects where a write could go +beyond the end-of-field if the field was larger than the access +granularity and therefore required multiple writes to complete +the +request. An extra write beyond the end of the field could happen +inadvertently. + +Fixed a problem with Index Fields where a BUFFER_OVERFLOW error +would incorrectly be returned if the width of the Data Register +was larger than the specified field access width. + +Completed fixes for LoadTable() and Unload() and verified their +operation. Implemented full support for the "DdbHandle" object +throughout the ACPI CA subsystem. + +Implemented full support for the MADT and ECDT tables in the ACPI +CA header files. Even though these tables are not directly +consumed by ACPI CA, the header definitions are useful for ACPI +device drivers. + +Integrated resource descriptor fixes posted to the Linux ACPI +list. This included checks for minimum descriptor length, and +support for trailing NULL strings within descriptors that have +optional string elements. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler +and the compiler options used during generation. + + Previous Release (20030918): + Non-Debug Version: 73.9K Code, 9.7K Data, 83.6K Total + Debug Version: 157.3K Code, 64.5K Data, 221.8K Total + Current Release: + Non-Debug Version: 74.1K Code, 9.7K Data, 83.8K Total + Debug Version: 157.9K Code, 64.8K Data, 222.7K Total + + +2) iASL Compiler: + +Implemented detection of non-ASCII characters within the input +source ASL file. This catches attempts to compile binary (AML) +files early in the compile, with an informative error message. + +Fixed a problem where the disassembler would fault if the output +filename could not be generated or if the output file could not +be +opened. + +---------------------------------------- +18 September 2003. Summary of changes for version 20030918: + + +1) ACPI CA Core Subsystem: + +Found and fixed a longstanding problem with the late execution of +the various deferred AML opcodes (such as Operation Regions, +Buffer Fields, Buffers, and Packages). If the name string +specified for the name of the new object placed the object in a +scope other than the current scope, the initialization/execution +of the opcode failed. The solution to this problem was to +implement a mechanism where the late execution of such opcodes +does not attempt to lookup/create the name a second time in an +incorrect scope. This fixes the "region size computed +incorrectly" problem. + +Fixed a call to AcpiHwRegisterWrite in hwregs.c that was causing +a +Global Lock AE_BAD_PARAMETER error. + +Fixed several 64-bit issues with prototypes, casting and data +types. + +Removed duplicate prototype from acdisasm.h + +Fixed an issue involving EC Operation Region Detach (Shaohua Li) + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler +and the compiler options used during generation. + + Previous Release: + + Non-Debug Version: 73.7K Code, 9.7K Data, 83.4K Total + Debug Version: 156.9K Code, 64.2K Data, 221.1K Total + Current Release: + Non-Debug Version: 73.9K Code, 9.7K Data, 83.6K Total + Debug Version: 157.3K Code, 64.5K Data, 221.8K Total + + +2) Linux: + +Fixed the AcpiOsSleep implementation in osunixxf.c to pass the +correct sleep time in seconds. + +---------------------------------------- +14 July 2003. Summary of changes for version 20030619: + +1) ACPI CA Core Subsystem: + +Parse SSDTs in order discovered, as opposed to reverse order +(Hrvoje Habjanic) + +Fixes from FreeBSD and NetBSD. (Frank van der Linden, Thomas +Klausner, + Nate Lawson) + + +2) Linux: + +Dynamically allocate SDT list (suggested by Andi Kleen) + +proc function return value cleanups (Andi Kleen) + +Correctly handle NMI watchdog during long stalls (Andrew Morton) + +Make it so acpismp=force works (reported by Andrew Morton) + + +---------------------------------------- +19 June 2003. Summary of changes for version 20030619: + +1) ACPI CA Core Subsystem: + +Fix To/FromBCD, eliminating the need for an arch-specific +#define. + +Do not acquire a semaphore in the S5 shutdown path. + +Fix ex_digits_needed for 0. (Takayoshi Kochi) + +Fix sleep/stall code reversal. (Andi Kleen) + +Revert a change having to do with control method calling +semantics. + +2) Linux: + +acpiphp update (Takayoshi Kochi) + +Export acpi_disabled for sonypi (Stelian Pop) + +Mention acpismp=force in config help + +Re-add acpitable.c and acpismp=force. This improves backwards + +compatibility and also cleans up the code to a significant +degree. + +Add ASUS Value-add driver (Karol Kozimor and Julien Lerouge) + +---------------------------------------- +22 May 2003. Summary of changes for version 20030522: + +1) ACPI CA Core Subsystem: + +Found and fixed a reported problem where an AE_NOT_FOUND error +occurred occasionally during _BST evaluation. This turned out to +be an Owner ID allocation issue where a called method did not get +a new ID assigned to it. Eventually, (after 64k calls), the +Owner +ID UINT16 would wraparound so that the ID would be the same as +the +caller's and the called method would delete the caller's +namespace. + +Implemented extended error reporting for control methods that are +aborted due to a run-time exception. Output includes the exact +AML instruction that caused the method abort, a dump of the +method +locals and arguments at the time of the abort, and a trace of all +nested control method calls. + +Modified the interpreter to allow the creation of buffers of zero +length from the AML code. Implemented new code to ensure that no +attempt is made to actually allocate a memory buffer (of length +zero) - instead, a simple buffer object with a NULL buffer +pointer +and length zero is created. A warning is no longer issued when +the AML attempts to create a zero-length buffer. + +Implemented a workaround for the "leading asterisk issue" in +_HIDs, _UIDs, and _CIDs in the AML interpreter. One leading +asterisk is automatically removed if present in any HID, UID, or +CID strings. The iASL compiler will still flag this asterisk as +an error, however. + +Implemented full support for _CID methods that return a package +of +multiple CIDs (Compatible IDs). The AcpiGetObjectInfo() +interface +now additionally returns a device _CID list if present. This +required a change to the external interface in order to pass an +ACPI_BUFFER object as a parameter since the _CID list is of +variable length. + +Fixed a problem with the new AE_SAME_HANDLER exception where +handler initialization code did not know about this exception. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler +and the compiler options used during generation. + + Previous Release (20030509): + Non-Debug Version: 73.4K Code, 9.7K Data, 83.1K Total + Debug Version: 156.1K Code, 63.9K Data, 220.0K Total + Current Release: + Non-Debug Version: 73.7K Code, 9.7K Data, 83.4K Total + Debug Version: 156.9K Code, 64.2K Data, 221.1K Total + + +2) Linux: + +Fixed a bug in which we would reinitialize the ACPI interrupt +after it was already working, thus disabling all ACPI and the +IRQs +for any other device sharing the interrupt. (Thanks to Stian +Jordet) + +Toshiba driver update (John Belmonte) + +Return only 0 or 1 for our interrupt handler status (Andrew +Morton) + + +3) iASL Compiler: + +Fixed a reported problem where multiple (nested) ElseIf() +statements were not handled correctly by the compiler, resulting +in incorrect warnings and incorrect AML code. This was a problem +in both the ASL parser and the code generator. + + +4) Documentation: + +Added changes to existing interfaces, new exception codes, and +new +text concerning reference count object management versus garbage +collection. + +---------------------------------------- +09 May 2003. Summary of changes for version 20030509. + + +1) ACPI CA Core Subsystem: + +Changed the subsystem initialization sequence to hold off +installation of address space handlers until the hardware has +been +initialized and the system has entered ACPI mode. This is +because +the installation of space handlers can cause _REG methods to be +run. Previously, the _REG methods could potentially be run +before +ACPI mode was enabled. + +Fixed some memory leak issues related to address space handler +and +notify handler installation. There were some problems with the +reference count mechanism caused by the fact that the handler +objects are shared across several namespace objects. + +Fixed a reported problem where reference counts within the +namespace were not properly updated when named objects created by +method execution were deleted. + +Fixed a reported problem where multiple SSDTs caused a deletion +issue during subsystem termination. Restructured the table data +structures to simplify the linked lists and the related code. + +Fixed a problem where the table ID associated with secondary +tables (SSDTs) was not being propagated into the namespace +objects +created by those tables. This would only present a problem for +tables that are unloaded at run-time, however. + +Updated AcpiOsReadable and AcpiOsWritable to use the ACPI_SIZE +type as the length parameter (instead of UINT32). + +Solved a long-standing problem where an ALREADY_EXISTS error +appears on various systems. This problem could happen when there +are multiple PCI_Config operation regions under a single PCI root +bus. This doesn't happen very frequently, but there are some +systems that do this in the ASL. + +Fixed a reported problem where the internal DeleteNode function +was incorrectly handling the case where a namespace node was the +first in the parent's child list, and had additional peers (not +the only child, but first in the list of children.) + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 73.7K Code, 9.5K Data, 83.2K Total + Debug Version: 156.1K Code, 63.6K Data, 219.7K Total + Current Release: + Non-Debug Version: 73.4K Code, 9.7K Data, 83.1K Total + Debug Version: 156.1K Code, 63.9K Data, 220.0K Total + + +2) Linux: + +Allow ":" in OS override string (Ducrot Bruno) + +Kobject fix (Greg KH) + + +3 iASL Compiler/Disassembler: + +Fixed a problem in the generation of the C source code files (AML +is emitted in C source statements for BIOS inclusion) where the +Ascii dump that appears within a C comment at the end of each +line +could cause a compile time error if the AML sequence happens to +have an open comment or close comment sequence embedded. + + +---------------------------------------- +24 April 2003. Summary of changes for version 20030424. + + +1) ACPI CA Core Subsystem: + +Support for big-endian systems has been implemented. Most of the +support has been invisibly added behind big-endian versions of +the +ACPI_MOVE_* macros. + +Fixed a problem in AcpiHwDisableGpeBlock() and +AcpiHwClearGpeBlock() where an incorrect offset was passed to the +low level hardware write routine. The offset parameter was +actually eliminated from the low level read/write routines +because +they had become obsolete. + +Fixed a problem where a handler object was deleted twice during +the removal of a fixed event handler. + + +2) Linux: + +A fix for SMP systems with link devices was contributed by + +Compaq's Dan Zink. + +(2.5) Return whether we handled the interrupt in our IRQ handler. +(Linux ISRs no longer return void, so we can propagate the +handler +return value from the ACPI CA core back to the OS.) + + + +3) Documentation: + +The ACPI CA Programmer Reference has been updated to reflect new +interfaces and changes to existing interfaces. + +---------------------------------------- +28 March 2003. Summary of changes for version 20030328. + +1) ACPI CA Core Subsystem: + +The GPE Block Device support has been completed. New interfaces +are AcpiInstallGpeBlock and AcpiRemoveGpeBlock. The Event +interfaces (enable, disable, clear, getstatus) have been split +into separate interfaces for Fixed Events and General Purpose +Events (GPEs) in order to support GPE Block Devices properly. + +Fixed a problem where the error message "Failed to acquire +semaphore" would appear during operations on the embedded +controller (EC). + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 72.3K Code, 9.5K Data, 81.8K Total + Debug Version: 154.0K Code, 63.4K Data, 217.4K Total + Current Release: + Non-Debug Version: 73.7K Code, 9.5K Data, 83.2K Total + Debug Version: 156.1K Code, 63.6K Data, 219.7K Total + + +---------------------------------------- +28 February 2003. Summary of changes for version 20030228. + + +1) ACPI CA Core Subsystem: + +The GPE handling and dispatch code has been completely overhauled +in preparation for support of GPE Block Devices (ID ACPI0006). +This affects internal data structures and code only; there should +be no differences visible externally. One new file has been +added, evgpeblk.c + +The FADT fields GPE0_BLK_LEN and GPE1_BLK_LEN are now the only +fields that are used to determine the GPE block lengths. The +REGISTER_BIT_WIDTH field of the X_GPEx_BLK extended address +structures are ignored. This is per the ACPI specification but +it +isn't very clear. The full 256 Block 0/1 GPEs are now supported +(the use of REGISTER_BIT_WIDTH limited the number of GPEs to +128). + +In the SCI interrupt handler, removed the read of the PM1_CONTROL +register to look at the SCI_EN bit. On some machines, this read +causes an SMI event and greatly slows down SCI events. (This may +in fact be the cause of slow battery status response on some +systems.) + +Fixed a problem where a store of a NULL string to a package +object +could cause the premature deletion of the object. This was seen +during execution of the battery _BIF method on some systems, +resulting in no battery data being returned. + +Added AcpiWalkResources interface to simplify parsing of resource +lists. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 72.0K Code, 9.5K Data, 81.5K Total + Debug Version: 153.0K Code, 62.9K Data, 215.9K Total + Current Release: + Non-Debug Version: 72.3K Code, 9.5K Data, 81.8K Total + Debug Version: 154.0K Code, 63.4K Data, 217.4K Total + + +2) Linux + +S3 fixes (Ole Rohne) + +Update ACPI PHP driver with to use new acpi_walk_resource API +(Bjorn Helgaas) + +Add S4BIOS support (Pavel Machek) + +Map in entire table before performing checksum (John Stultz) + +Expand the mem= cmdline to allow the specification of reserved +and +ACPI DATA blocks (Pavel Machek) + +Never use ACPI on VISWS + +Fix derive_pci_id (Ducrot Bruno, Alvaro Lopez) + +Revert a change that allowed P_BLK lengths to be 4 or 5. This is +causing us to think that some systems support C2 when they really +don't. + +Do not count processor objects for non-present CPUs (Thanks to +Dominik Brodowski) + + +3) iASL Compiler: + +Fixed a problem where ASL include files could not be found and +opened. + +Added support for the _PDC reserved name. + + +---------------------------------------- +22 January 2003. Summary of changes for version 20030122. + + +1) ACPI CA Core Subsystem: + +Added a check for constructs of the form: Store (Local0, Local0) +where Local0 is not initialized. Apparently, some BIOS +programmers believe that this is a NOOP. Since this store +doesn't +do anything anyway, the new prototype behavior will ignore this +error. This is a case where we can relax the strict checking in +the interpreter in the name of compatibility. + + +2) Linux + +The AcpiSrc Source Conversion Utility has been released with the +Linux package for the first time. This is the utility that is +used to convert the ACPI CA base source code to the Linux +version. + +(Both) Handle P_BLK lengths shorter than 6 more gracefully + +(Both) Move more headers to include/acpi, and delete an unused +header. + +(Both) Move drivers/acpi/include directory to include/acpi + +(Both) Boot functions don't use cmdline, so don't pass it around + +(Both) Remove include of unused header (Adrian Bunk) + +(Both) acpiphp.h includes both linux/acpi.h and acpi_bus.h. Since +the +former now also includes the latter, acpiphp.h only needs the +one, +now. + +(2.5) Make it possible to select method of bios restoring after +S3 +resume. [=> no more ugly ifdefs] (Pavel Machek) + +(2.5) Make proc write interfaces work (Pavel Machek) + +(2.5) Properly init/clean up in cpufreq/acpi (Dominik Brodowski) + +(2.5) Break out ACPI Perf code into its own module, under cpufreq +(Dominik Brodowski) + +(2.4) S4BIOS support (Ducrot Bruno) + +(2.4) Fix acpiphp_glue.c for latest ACPI struct changes (Sergio +Visinoni) + + +3) iASL Compiler: + +Added support to disassemble SSDT and PSDTs. + +Implemented support to obtain SSDTs from the Windows registry if +available. + + +---------------------------------------- +09 January 2003. Summary of changes for version 20030109. + +1) ACPI CA Core Subsystem: + +Changed the behavior of the internal Buffer-to-String conversion +function. The current ACPI specification states that the +contents +of the buffer are "converted to a string of two-character +hexadecimal numbers, each separated by a space". Unfortunately, +this definition is not backwards compatible with existing ACPI +1.0 +implementations (although the behavior was not defined in the +ACPI +1.0 specification). The new behavior simply copies data from the +buffer to the string until a null character is found or the end +of +the buffer is reached. The new String object is always null +terminated. This problem was seen during the generation of _BIF +battery data where incorrect strings were returned for battery +type, etc. This will also require an errata to the ACPI +specification. + +Renamed all instances of NATIVE_UINT and NATIVE_INT to +ACPI_NATIVE_UINT and ACPI_NATIVE_INT, respectively. + +Copyright in all module headers (both Linux and non-Linux) has be +updated to 2003. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 72.0K Code, 9.5K Data, 81.5K Total + Debug Version: 153.0K Code, 62.9K Data, 215.9K Total + Current Release: + Non-Debug Version: 72.0K Code, 9.5K Data, 81.5K Total + Debug Version: 153.0K Code, 62.9K Data, 215.9K Total + + +2) Linux + +Fixed an oops on module insertion/removal (Matthew Tippett) + +(2.4) Fix to handle dynamic size of mp_irqs (Joerg Prante) + +(2.5) Replace pr_debug (Randy Dunlap) + +(2.5) Remove usage of CPUFREQ_ALL_CPUS (Dominik Brodowski) + +(Both) Eliminate spawning of thread from timer callback, in favor +of schedule_work() + +(Both) Show Lid status in /proc (Zdenek OGAR Skalak) + +(Both) Added define for Fixed Function HW region (Matthew Wilcox) + +(Both) Add missing statics to button.c (Pavel Machek) + +Several changes have been made to the source code translation +utility that generates the Linux Code in order to make the code +more "Linux-like": + +All typedefs on structs and unions have been removed in keeping +with the Linux coding style. + +Removed the non-Linux SourceSafe module revision number from each +module header. + +Completed major overhaul of symbols to be lowercased for linux. +Doubled the number of symbols that are lowercased. + +Fixed a problem where identifiers within procedure headers and +within quotes were not fully lower cased (they were left with a +starting capital.) + +Some C macros whose only purpose is to allow the generation of 16- +bit code are now completely removed in the Linux code, increasing +readability and maintainability. + +---------------------------------------- + +12 December 2002. Summary of changes for version 20021212. + + +1) ACPI CA Core Subsystem: + +Fixed a problem where the creation of a zero-length AML Buffer +would cause a fault. + +Fixed a problem where a Buffer object that pointed to a static +AML +buffer (in an ACPI table) could inadvertently be deleted, causing +memory corruption. + +Fixed a problem where a user buffer (passed in to the external +ACPI CA interfaces) could be overwritten if the buffer was too +small to complete the operation, causing memory corruption. + +Fixed a problem in the Buffer-to-String conversion code where a +string of length one was always returned, regardless of the size +of the input Buffer object. + +Removed the NATIVE_CHAR data type across the entire source due to +lack of need and lack of consistent use. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 72.1K Code, 9.5K Data, 81.6K Total + Debug Version: 152.7K Code, 62.7K Data, 215.4K Total + Current Release: + Non-Debug Version: 72.0K Code, 9.5K Data, 81.5K Total + Debug Version: 153.0K Code, 62.9K Data, 215.9K Total + + +---------------------------------------- +05 December 2002. Summary of changes for version 20021205. + +1) ACPI CA Core Subsystem: + +Fixed a problem where a store to a String or Buffer object could +cause corruption of the DSDT if the object type being stored was +the same as the target object type and the length of the object +being stored was equal to or smaller than the original (existing) +target object. This was seen to cause corruption of battery _BIF +buffers if the _BIF method modified the buffer on the fly. + +Fixed a problem where an internal error was generated if a +control +method invocation was used in an OperationRegion, Buffer, or +Package declaration. This was caused by the deferred parsing of +the control method and thus the deferred creation of the internal +method object. The solution to this problem was to create the +internal method object at the moment the method is encountered in +the first pass - so that subsequent references to the method will +able to obtain the required parameter count and thus properly +parse the method invocation. This problem presented itself as an +AE_AML_INTERNAL during the pass 1 parse phase during table load. + +Fixed a problem where the internal String object copy routine did +not always allocate sufficient memory for the target String +object +and caused memory corruption. This problem was seen to cause +"Allocation already present in list!" errors as memory allocation +became corrupted. + +Implemented a new function for the evaluation of namespace +objects +that allows the specification of the allowable return object +types. This simplifies a lot of code that checks for a return +object of one or more specific objects returned from the +evaluation (such as _STA, etc.) This may become and external +function if it would be useful to ACPI-related drivers. + +Completed another round of prefixing #defines with "ACPI_" for +clarity. + +Completed additional code restructuring to allow more modular +linking for iASL compiler and AcpiExec. Several files were split +creating new files. New files: nsparse.c dsinit.c evgpe.c + +Implemented an abort mechanism to terminate an executing control +method via the AML debugger. This feature is useful for +debugging +control methods that depend (wait) for specific hardware +responses. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 71.4K Code, 9.0K Data, 80.4K Total + Debug Version: 152.9K Code, 63.3K Data, 216.2K Total + Current Release: + Non-Debug Version: 72.1K Code, 9.5K Data, 81.6K Total + Debug Version: 152.7K Code, 62.7K Data, 215.4K Total + + +2) iASL Compiler/Disassembler + +Fixed a compiler code generation problem for "Interrupt" Resource +Descriptors. If specified in the ASL, the optional "Resource +Source Index" and "Resource Source" fields were not inserted into +the correct location within the AML resource descriptor, creating +an invalid descriptor. + +Fixed a disassembler problem for "Interrupt" resource +descriptors. +The optional "Resource Source Index" and "Resource Source" fields +were ignored. + + +---------------------------------------- +22 November 2002. Summary of changes for version 20021122. + + +1) ACPI CA Core Subsystem: + +Fixed a reported problem where an object stored to a Method Local +or Arg was not copied to a new object during the store - the +object pointer was simply copied to the Local/Arg. This caused +all subsequent operations on the Local/Arg to also affect the +original source of the store operation. + +Fixed a problem where a store operation to a Method Local or Arg +was not completed properly if the Local/Arg contained a reference +(from RefOf) to a named field. The general-purpose store-to- +namespace-node code is now used so that this case is handled +automatically. + +Fixed a problem where the internal object copy routine would +cause +a protection fault if the object being copied was a Package and +contained either 1) a NULL package element or 2) a nested sub- +package. + +Fixed a problem with the GPE initialization that resulted from an +ambiguity in the ACPI specification. One section of the +specification states that both the address and length of the GPE +block must be zero if the block is not supported. Another +section +implies that only the address need be zero if the block is not +supported. The code has been changed so that both the address +and +the length must be non-zero to indicate a valid GPE block (i.e., +if either the address or the length is zero, the GPE block is +invalid.) + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 71.3K Code, 9.0K Data, 80.3K Total + Debug Version: 152.7K Code, 63.2K Data, 215.5K Total + Current Release: + Non-Debug Version: 71.4K Code, 9.0K Data, 80.4K Total + Debug Version: 152.9K Code, 63.3K Data, 216.2K Total + + +2) Linux + +Cleaned up EC driver. Exported an external EC read/write +interface. By going through this, other drivers (most notably +sonypi) will be able to serialize access to the EC. + + +3) iASL Compiler/Disassembler + +Implemented support to optionally generate include files for both +ASM and C (the -i switch). This simplifies BIOS development by +automatically creating include files that contain external +declarations for the symbols that are created within the + +(optionally generated) ASM and C AML source files. + + +---------------------------------------- +15 November 2002. Summary of changes for version 20021115. + +1) ACPI CA Core Subsystem: + +Fixed a memory leak problem where an error during resolution of + +method arguments during a method invocation from another method +failed to cleanup properly by deleting all successfully resolved +argument objects. + +Fixed a problem where the target of the Index() operator was not +correctly constructed if the source object was a package. This +problem has not been detected because the use of a target operand +with Index() is very rare. + +Fixed a problem with the Index() operator where an attempt was +made to delete the operand objects twice. + +Fixed a problem where an attempt was made to delete an operand +twice during execution of the CondRefOf() operator if the target +did not exist. + +Implemented the first of perhaps several internal create object +functions that create and initialize a specific object type. +This +consolidates duplicated code wherever the object is created, thus +shrinking the size of the subsystem. + +Implemented improved debug/error messages for errors that occur +during nested method invocations. All executing method pathnames +are displayed (with the error) as the call stack is unwound - +thus +simplifying debug. + +Fixed a problem introduced in the 10/02 release that caused +premature deletion of a buffer object if a buffer was used as an +ASL operand where an integer operand is required (Thus causing an +implicit object conversion from Buffer to Integer.) The change +in +the 10/02 release was attempting to fix a memory leak (albeit +incorrectly.) + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 71.9K Code, 9.1K Data, 81.0K Total + Debug Version: 153.1K Code, 63.3K Data, 216.4K Total + Current Release: + Non-Debug Version: 71.3K Code, 9.0K Data, 80.3K Total + Debug Version: 152.7K Code, 63.2K Data, 215.5K Total + + +2) Linux + +Changed the implementation of the ACPI semaphores to use down() +instead of down_interruptable(). It is important that the +execution of ACPI control methods not be interrupted by signals. +Methods must run to completion, or the system may be left in an +unknown/unstable state. + +Fixed a compilation error when CONFIG_SOFTWARE_SUSPEND is not +set. +(Shawn Starr) + + +3) iASL Compiler/Disassembler + + +Changed the default location of output files. All output files +are now placed in the current directory by default instead of in +the directory of the source file. This change may affect some +existing makefiles, but it brings the behavior of the compiler in +line with other similar tools. The location of the output files +can be overridden with the -p command line switch. + + +---------------------------------------- +11 November 2002. Summary of changes for version 20021111. + + +0) ACPI Specification 2.0B is released and is now available at: +http://www.acpi.info/index.html + + +1) ACPI CA Core Subsystem: + +Implemented support for the ACPI 2.0 SMBus Operation Regions. +This includes the early detection and handoff of the request to +the SMBus region handler (avoiding all of the complex field +support code), and support for the bidirectional return packet +from an SMBus write operation. This paves the way for the +development of SMBus drivers in each host operating system. + +Fixed a problem where the semaphore WAIT_FOREVER constant was +defined as 32 bits, but must be 16 bits according to the ACPI +specification. This had the side effect of causing ASL +Mutex/Event timeouts even though the ASL code requested a wait +forever. Changed all internal references to the ACPI timeout +parameter to 16 bits to prevent future problems. Changed the +name +of WAIT_FOREVER to ACPI_WAIT_FOREVER. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 71.4K Code, 9.0K Data, 80.4K Total + Debug Version: 152.3K Code, 63.0K Data, 215.3K Total + Current Release: + Non-Debug Version: 71.9K Code, 9.1K Data, 81.0K Total + Debug Version: 153.1K Code, 63.3K Data, 216.4K Total + + +2) Linux + +Module loading/unloading fixes (John Cagle) + + +3) iASL Compiler/Disassembler + +Added support for the SMBBlockProcessCall keyword (ACPI 2.0) + +Implemented support for the disassembly of all SMBus protocol +keywords (SMBQuick, SMBWord, etc.) + +---------------------------------------- +01 November 2002. Summary of changes for version 20021101. + + +1) ACPI CA Core Subsystem: + +Fixed a problem where platforms that have a GPE1 block but no +GPE0 +block were not handled correctly. This resulted in a "GPE +overlap" error message. GPE0 is no longer required. + +Removed code added in the previous release that inserted nodes +into the namespace in alphabetical order. This caused some side- +effects on various machines. The root cause of the problem is +still under investigation since in theory, the internal ordering +of the namespace nodes should not matter. + + +Enhanced error reporting for the case where a named object is not +found during control method execution. The full ACPI namepath +(name reference) of the object that was not found is displayed in +this case. + +Note: as a result of the overhaul of the namespace object types +in +the previous release, the namespace nodes for the predefined +scopes (_TZ, _PR, etc.) are now of the type ACPI_TYPE_LOCAL_SCOPE +instead of ACPI_TYPE_ANY. This simplifies the namespace +management code but may affect code that walks the namespace tree +looking for specific object types. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a much larger code and data size. Note that these values +will +vary depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 70.7K Code, 8.6K Data, 79.3K Total + Debug Version: 151.7K Code, 62.4K Data, 214.1K Total + Current Release: + Non-Debug Version: 71.4K Code, 9.0K Data, 80.4K Total + Debug Version: 152.3K Code, 63.0K Data, 215.3K Total + + +2) Linux + +Fixed a problem introduced in the previous release where the +Processor and Thermal objects were not recognized and installed +in +/proc. This was related to the scope type change described +above. + + +3) iASL Compiler/Disassembler + +Implemented the -g option to get all of the required ACPI tables +from the registry and save them to files (Windows version of the +compiler only.) The required tables are the FADT, FACS, and +DSDT. + +Added ACPI table checksum validation during table disassembly in +order to catch corrupted tables. + + +---------------------------------------- +22 October 2002. Summary of changes for version 20021022. + +1) ACPI CA Core Subsystem: + +Implemented a restriction on the Scope operator that the target +must already exist in the namespace at the time the operator is +encountered (during table load or method execution). In other +words, forward references are not allowed and Scope() cannot +create a new object. This changes the previous behavior where the +interpreter would create the name if not found. This new +behavior +correctly enables the search-to-root algorithm during namespace +lookup of the target name. Because of this upsearch, this fixes +the known Compaq _SB_.OKEC problem and makes both the AML +interpreter and iASL compiler compatible with other ACPI +implementations. + +Completed a major overhaul of the internal ACPI object types for +the ACPI Namespace and the associated operand objects. Many of +these types had become obsolete with the introduction of the two- +pass namespace load. This cleanup simplifies the code and makes +the entire namespace load mechanism much clearer and easier to +understand. + +Improved debug output for tracking scope opening/closing to help +diagnose scoping issues. The old scope name as well as the new +scope name are displayed. Also improved error messages for +problems with ASL Mutex objects and error messages for GPE +problems. + +Cleaned up the namespace dump code, removed obsolete code. + +All string output (for all namespace/object dumps) now uses the +common ACPI string output procedure which handles escapes +properly +and does not emit non-printable characters. + +Fixed some issues with constants in the 64-bit version of the +local C library (utclib.c) + + +2) Linux + +EC Driver: No longer attempts to acquire the Global Lock at +interrupt level. + + +3) iASL Compiler/Disassembler + +Implemented ACPI 2.0B grammar change that disallows all Type 1 +and +2 opcodes outside of a control method. This means that the +"executable" operators (versus the "namespace" operators) cannot +be used at the table level; they can only be used within a +control +method. + +Implemented the restriction on the Scope() operator where the +target must already exist in the namespace at the time the +operator is encountered (during ASL compilation). In other words, +forward references are not allowed and Scope() cannot create a +new +object. This makes the iASL compiler compatible with other ACPI +implementations and makes the Scope() implementation adhere to +the +ACPI specification. + +Fixed a problem where namepath optimization for the Alias +operator +was optimizing the wrong path (of the two namepaths.) This +caused +a "Missing alias link" error message. + +Fixed a problem where an "unknown reserved name" warning could be +incorrectly generated for names like "_SB" when the trailing +underscore is not used in the original ASL. + +Fixed a problem where the reserved name check did not handle +NamePaths with multiple NameSegs correctly. The first nameseg of +the NamePath was examined instead of the last NameSeg. + + +---------------------------------------- + +02 October 2002. Summary of changes for this release. + + +1) ACPI CA Core Subsystem version 20021002: + +Fixed a problem where a store/copy of a string to an existing +string did not always set the string length properly in the +String +object. + +Fixed a reported problem with the ToString operator where the +behavior was identical to the ToHexString operator instead of +just +simply converting a raw buffer to a string data type. + +Fixed a problem where CopyObject and the other "explicit" +conversion operators were not updating the internal namespace +node +type as part of the store operation. + +Fixed a memory leak during implicit source operand conversion +where the original object was not deleted if it was converted to +a +new object of a different type. + +Enhanced error messages for all problems associated with +namespace +lookups. Common procedure generates and prints the lookup name +as +well as the formatted status. + +Completed implementation of a new design for the Alias support +within the namespace. The existing design did not handle the +case +where a new object was assigned to one of the two names due to +the +use of an explicit conversion operator, resulting in the two +names +pointing to two different objects. The new design simply points +the Alias name to the original name node - not to the object. +This results in a level of indirection that must be handled in +the +name resolution mechanism. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 69.6K Code, 8.3K Data, 77.9K Total + Debug Version: 150.0K Code, 61.7K Data, 211.7K Total + Current Release: + Non-Debug Version: 70.7K Code, 8.6K Data, 79.3K Total + Debug Version: 151.7K Code, 62.4K Data, 214.1K Total + + +2) Linux + +Initialize thermal driver's timer before it is used. (Knut +Neumann) + +Allow handling negative celsius values. (Kochi Takayoshi) + +Fix thermal management and make trip points. R/W (Pavel Machek) + +Fix /proc/acpi/sleep. (P. Christeas) + +IA64 fixes. (David Mosberger) + +Fix reversed logic in blacklist code. (Sergio Monteiro Basto) + +Replace ACPI_DEBUG define with ACPI_DEBUG_OUTPUT. (Dominik +Brodowski) + + +3) iASL Compiler/Disassembler + +Clarified some warning/error messages. + + +---------------------------------------- +18 September 2002. Summary of changes for this release. + + +1) ACPI CA Core Subsystem version 20020918: + +Fixed a reported problem with reference chaining (via the Index() +and RefOf() operators) in the ObjectType() and SizeOf() +operators. +The definition of these operators includes the dereferencing of +all chained references to return information on the base object. + +Fixed a problem with stores to indexed package elements - the +existing code would not complete the store if an "implicit +conversion" was not performed. In other words, if the existing +object (package element) was to be replaced completely, the code +didn't handle this case. + +Relaxed typechecking on the ASL "Scope" operator to allow the +target name to refer to an object of type Integer, String, or +Buffer, in addition to the scoping object types (Device, +predefined Scopes, Processor, PowerResource, and ThermalZone.) +This allows existing AML code that has workarounds for a bug in +Windows to function properly. A warning is issued, however. +This +affects both the AML interpreter and the iASL compiler. Below is +an example of this type of ASL code: + + Name(DEB,0x00) + Scope(DEB) + { + +Fixed some reported problems with 64-bit integer support in the +local implementation of C library functions (clib.c) + + +2) Linux + +Use ACPI fix map region instead of IOAPIC region, since it is +undefined in non-SMP. + +Ensure that the SCI has the proper polarity and trigger, even on +systems that do not have an interrupt override entry in the MADT. + +2.5 big driver reorganization (Pat Mochel) + +Use early table mapping code from acpitable.c (Andi Kleen) + +New blacklist entries (Andi Kleen) + +Blacklist improvements. Split blacklist code out into a separate +file. Move checking the blacklist to very early. Previously, we +would use ACPI tables, and then halfway through init, check the +blacklist -- too late. Now, it's early enough to completely fall- +back to non-ACPI. + + +3) iASL Compiler/Disassembler version 20020918: + +Fixed a problem where the typechecking code didn't know that an +alias could point to a method. In other words, aliases were not +being dereferenced during typechecking. + + +---------------------------------------- +29 August 2002. Summary of changes for this release. + +1) ACPI CA Core Subsystem Version 20020829: + +If the target of a Scope() operator already exists, it must be an +object type that actually opens a scope -- such as a Device, +Method, Scope, etc. This is a fatal runtime error. Similar +error +check has been added to the iASL compiler also. + +Tightened up the namespace load to disallow multiple names in the +same scope. This previously was allowed if both objects were of +the same type. (i.e., a lookup was the same as entering a new +name). + + +2) Linux + +Ensure that the ACPI interrupt has the proper trigger and +polarity. + +local_irq_disable is extraneous. (Matthew Wilcox) + +Make "acpi=off" actually do what it says, and not use the ACPI +interpreter *or* the tables. + +Added arch-neutral support for parsing SLIT and SRAT tables +(Kochi +Takayoshi) + + +3) iASL Compiler/Disassembler Version 20020829: + +Implemented namepath optimization for name declarations. For +example, a declaration like "Method (\_SB_.ABCD)" would get +optimized to "Method (ABCD)" if the declaration is within the +\_SB_ scope. This optimization is in addition to the named +reference path optimization first released in the previous +version. This would seem to complete all possible optimizations +for namepaths within the ASL/AML. + +If the target of a Scope() operator already exists, it must be an +object type that actually opens a scope -- such as a Device, +Method, Scope, etc. + +Implemented a check and warning for unreachable code in the same +block below a Return() statement. + +Fixed a problem where the listing file was not generated if the +compiler aborted if the maximum error count was exceeded (200). + +Fixed a problem where the typechecking of method return values +was +broken. This includes the check for a return value when the +method is invoked as a TermArg (a return value is expected.) + +Fixed a reported problem where EOF conditions during a quoted +string or comment caused a fault. + + +---------------------------------------- +15 August 2002. Summary of changes for this release. + +1) ACPI CA Core Subsystem Version 20020815: + +Fixed a reported problem where a Store to a method argument that +contains a reference did not perform the indirect store +correctly. +This problem was created during the conversion to the new +reference object model - the indirect store to a method argument +code was not updated to reflect the new model. + +Reworked the ACPI mode change code to better conform to ACPI 2.0, +handle corner cases, and improve code legibility (Kochi +Takayoshi) + +Fixed a problem with the pathname parsing for the carat (^) +prefix. The heavy use of the carat operator by the new namepath +optimization in the iASL compiler uncovered a problem with the +AML +interpreter handling of this prefix. In the case where one or +more carats precede a single nameseg, the nameseg was treated as +standalone and the search rule (to root) was inadvertently +applied. This could cause both the iASL compiler and the +interpreter to find the wrong object or to miss the error that +should occur if the object does not exist at that exact pathname. + +Found and fixed the problem where the HP Pavilion DSDT would not +load. This was a relatively minor tweak to the table loading +code +(a problem caused by the unexpected encounter with a method +invocation not within a control method), but it does not solve +the +overall issue of the execution of AML code at the table level. +This investigation is still ongoing. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 69.1K Code, 8.2K Data, 77.3K Total + Debug Version: 149.4K Code, 61.6K Data, 211.0K Total + Current Release: + Non-Debug Version: 69.6K Code, 8.3K Data, 77.9K Total + Debug Version: 150.0K Code, 61.7K Data, 211.7K Total + + +2) Linux + +Remove redundant slab.h include (Brad Hards) + +Fix several bugs in thermal.c (Herbert Nachtnebel) + +Make CONFIG_ACPI_BOOT work properly (Pavel Machek) + +Change acpi_system_suspend to use updated irq functions (Pavel +Machek) + +Export acpi_get_firmware_table (Matthew Wilcox) + +Use proper root proc entry for ACPI (Kochi Takayoshi) + +Fix early-boot table parsing (Bjorn Helgaas) + + +3) iASL Compiler/Disassembler + +Reworked the compiler options to make them more consistent and to +use two-letter options where appropriate. We were running out of +sensible letters. This may break some makefiles, so check the +current options list by invoking the compiler with no parameters. + +Completed the design and implementation of the ASL namepath +optimization option for the compiler. This option optimizes all +references to named objects to the shortest possible path. The +first attempt tries to utilize a single nameseg (4 characters) +and +the "search-to-root" algorithm used by the interpreter. If that +cannot be used (because either the name is not in the search path +or there is a conflict with another object with the same name), +the pathname is optimized using the carat prefix (usually a +shorter string than specifying the entire path from the root.) + +Implemented support to obtain the DSDT from the Windows registry +(when the disassembly option is specified with no input file). +Added this code as the implementation for AcpiOsTableOverride in +the Windows OSL. Migrated the 16-bit code (used in the AcpiDump +utility) to scan memory for the DSDT to the AcpiOsTableOverride +function in the DOS OSL to make the disassembler truly OS +independent. + +Implemented a new option to disassemble and compile in one step. +When used without an input filename, this option will grab the +DSDT from the local machine, disassemble it, and compile it in +one +step. + +Added a warning message for invalid escapes (a backslash followed +by any character other than the allowable escapes). This catches +the quoted string error "\_SB_" (which should be "\\_SB_" ). + +Also, there are numerous instances in the ACPI specification +where +this error occurs. + +Added a compiler option to disable all optimizations. This is +basically the "compatibility mode" because by using this option, +the AML code will come out exactly the same as other ASL +compilers. + +Added error messages for incorrectly ordered dependent resource +functions. This includes: missing EndDependentFn macro at end of +dependent resource list, nested dependent function macros (both +start and end), and missing StartDependentFn macro. These are +common errors that should be caught at compile time. + +Implemented _OSI support for the disassembler and compiler. _OSI +must be included in the namespace for proper disassembly (because +the disassembler must know the number of arguments.) + +Added an "optimization" message type that is optional (off by +default). This message is used for all optimizations - including +constant folding, integer optimization, and namepath +optimization. + +---------------------------------------- +25 July 2002. Summary of changes for this release. + + +1) ACPI CA Core Subsystem Version 20020725: + +The AML Disassembler has been enhanced to produce compilable ASL +code and has been integrated into the iASL compiler (see below) +as +well as the single-step disassembly for the AML debugger and the +disassembler for the AcpiDump utility. All ACPI 2.0A opcodes, +resource templates and macros are fully supported. The +disassembler has been tested on over 30 different AML files, +producing identical AML when the resulting disassembled ASL file +is recompiled with the same ASL compiler. + +Modified the Resource Manager to allow zero interrupts and zero +dma channels during the GetCurrentResources call. This was +causing problems on some platforms. + +Added the AcpiOsRedirectOutput interface to the OSL to simplify +output redirection for the AcpiOsPrintf and AcpiOsVprintf +interfaces. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 68.7K Code, 7.4K Data, 76.1K Total + Debug Version: 142.9K Code, 58.7K Data, 201.6K Total + Current Release: + Non-Debug Version: 69.1K Code, 8.2K Data, 77.3K Total + Debug Version: 149.4K Code, 61.6K Data, 211.0K Total + + +2) Linux + +Fixed a panic in the EC driver (Dominik Brodowski) + +Implemented checksum of the R/XSDT itself during Linux table scan +(Richard Schaal) + + +3) iASL compiler + +The AML disassembler is integrated into the compiler. The "-d" +option invokes the disassembler to completely disassemble an +input AML file, producing as output a text ASL file with the +extension ".dsl" (to avoid name collisions with existing .asl +source files.) A future enhancement will allow the disassembler +to obtain the BIOS DSDT from the registry under Windows. + +Fixed a problem with the VendorShort and VendorLong resource +descriptors where an invalid AML sequence was created. + +Implemented a fix for BufferData term in the ASL parser. It was +inadvertently defined twice, allowing invalid syntax to pass and +causing reduction conflicts. + +Fixed a problem where the Ones opcode could get converted to a +value of zero if "Ones" was used where a byte, word or dword +value +was expected. The 64-bit value is now truncated to the correct +size with the correct value. + + + +---------------------------------------- +02 July 2002. Summary of changes for this release. + + +1) ACPI CA Core Subsystem Version 20020702: + +The Table Manager code has been restructured to add several new +features. Tables that are not required by the core subsystem +(other than the FADT, DSDT, FACS, PSDTs, etc.) are no longer +validated in any way and are returned from AcpiGetFirmwareTable +if +requested. The AcpiOsTableOverride interface is now called for +each table that is loaded by the subsystem in order to allow the +host to override any table it chooses. Previously, only the DSDT +could be overridden. Added one new files, tbrsdt.c and +tbgetall.c. + +Fixed a problem with the conversion of internal package objects +to +external objects (when a package is returned from a control +method.) The return buffer length was set to zero instead of the +proper length of the package object. + +Fixed a reported problem with the use of the RefOf and DeRefOf +operators when passing reference arguments to control methods. A +new type of Reference object is used internally for references +produced by the RefOf operator. + +Added additional error messages in the Resource Manager to +explain +AE_BAD_DATA errors when they occur during resource parsing. + +Split the AcpiEnableSubsystem into two primitives to enable a +finer granularity initialization sequence. These two calls +should +be called in this order: AcpiEnableSubsystem (flags), +AcpiInitializeObjects (flags). The flags parameter remains the +same. + + +2) Linux + +Updated the ACPI utilities module to understand the new style of +fully resolved package objects that are now returned from the +core +subsystem. This eliminates errors of the form: + + ACPI: PCI Interrupt Routing Table [\_SB_.PCI0.PPB_._PRT] + acpi_utils-0430 [145] acpi_evaluate_reference: + Invalid element in package (not a device reference) + +The method evaluation utility uses the new buffer allocation +scheme instead of calling AcpiEvaluate Object twice. + +Added support for ECDT. This allows the use of the Embedded + +Controller before the namespace has been fully initialized, which +is necessary for ACPI 2.0 support, and for some laptops to +initialize properly. (Laptops using ECDT are still rare, so only +limited testing was performed of the added functionality.) + +Fixed memory leaks in the EC driver. + +Eliminated a brittle code structure in acpi_bus_init(). + +Eliminated the acpi_evaluate() helper function in utils.c. It is +no longer needed since acpi_evaluate_object can optionally +allocate memory for the return object. + +Implemented fix for keyboard hang when getting battery readings +on +some systems (Stephen White) + +PCI IRQ routing update (Dominik Brodowski) + +Fix an ifdef to allow compilation on UP with LAPIC but no IOAPIC +support + +---------------------------------------- +11 June 2002. Summary of changes for this release. + + +1) ACPI CA Core Subsystem Version 20020611: + +Fixed a reported problem where constants such as Zero and One +appearing within _PRT packages were not handled correctly within +the resource manager code. Originally reported against the ASL +compiler because the code generator now optimizes integers to +their minimal AML representation (i.e. AML constants if +possible.) +The _PRT code now handles all AML constant opcodes correctly +(Zero, One, Ones, Revision). + +Fixed a problem with the Concatenate operator in the AML +interpreter where a buffer result object was incorrectly marked +as +not fully evaluated, causing a run-time error of AE_AML_INTERNAL. + +All package sub-objects are now fully resolved before they are +returned from the external ACPI interfaces. This means that name +strings are resolved to object handles, and constant operators +(Zero, One, Ones, Revision) are resolved to Integers. + +Implemented immediate resolution of the AML Constant opcodes +(Zero, One, Ones, Revision) to Integer objects upon detection +within the AML stream. This has simplified and reduced the +generated code size of the subsystem by eliminating about 10 +switch statements for these constants (which previously were +contained in Reference objects.) The complicating issues are +that +the Zero opcode is used as a "placeholder" for unspecified +optional target operands and stores to constants are defined to +be +no-ops. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 69.3K Code, 7.4K Data, 76.7K Total + Debug Version: 143.8K Code, 58.8K Data, 202.6K Total + Current Release: + Non-Debug Version: 68.7K Code, 7.4K Data, 76.1K Total + Debug Version: 142.9K Code, 58.7K Data, 201.6K Total + + +2) Linux + + +Added preliminary support for obtaining _TRA data for PCI root +bridges (Bjorn Helgaas). + + +3) iASL Compiler Version X2046: + +Fixed a problem where the "_DDN" reserved name was defined to be +a +control method with one argument. There are no arguments, and +_DDN does not have to be a control method. + +Fixed a problem with the Linux version of the compiler where the +source lines printed with error messages were the wrong lines. +This turned out to be the "LF versus CR/LF" difference between +Windows and Unix. This appears to be the longstanding issue +concerning listing output and error messages. + +Fixed a problem with the Linux version of compiler where opcode +names within error messages were wrong. This was caused by a +slight difference in the output of the Flex tool on Linux versus +Windows. + +Fixed a problem with the Linux compiler where the hex output +files +contained some garbage data caused by an internal buffer overrun. + + +---------------------------------------- +17 May 2002. Summary of changes for this release. + + +1) ACPI CA Core Subsystem Version 20020517: + +Implemented a workaround to an BIOS bug discovered on the HP +OmniBook where the FADT revision number and the table size are +inconsistent (ACPI 2.0 revision vs. ACPI 1.0 table size). The +new +behavior is to fallback to using only the ACPI 1.0 fields of the +FADT if the table is too small to be a ACPI 2.0 table as claimed +by the revision number. Although this is a BIOS bug, this is a +case where the workaround is simple enough and with no side +effects, so it seemed prudent to add it. A warning message is +issued, however. + +Implemented minimum size checks for the fixed-length ACPI tables +- +- the FADT and FACS, as well as consistency checks between the +revision number and the table size. + +Fixed a reported problem in the table override support where the +new table pointer was incorrectly treated as a physical address +instead of a logical address. + +Eliminated the use of the AE_AML_ERROR exception and replaced it +with more descriptive codes. + +Fixed a problem where an exception would occur if an ASL Field +was +defined with no named Field Units underneath it (used by some +index fields). + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 68.8K Code, 7.1K Data, 75.9K Total + Debug Version: 142.9K Code, 58.4K Data, 201.3K Total + Current Release: + Non-Debug Version: 69.3K Code, 7.4K Data, 76.7K Total + Debug Version: 143.8K Code, 58.8K Data, 202.6K Total + + + +2) Linux + +Much work done on ACPI init (MADT and PCI IRQ routing support). +(Paul D. and Dominik Brodowski) + +Fix PCI IRQ-related panic on boot (Sam Revitch) + +Set BM_ARB_DIS when entering a sleep state (Ducrot Bruno) + +Fix "MHz" typo (Dominik Brodowski) + +Fix RTC year 2000 issue (Dominik Brodowski) + +Preclude multiple button proc entries (Eric Brunet) + +Moved arch-specific code out of include/platform/aclinux.h + +3) iASL Compiler Version X2044: + +Implemented error checking for the string used in the EISAID +macro +(Usually used in the definition of the _HID object.) The code +now +strictly enforces the PnP format - exactly 7 characters, 3 +uppercase letters and 4 hex digits. + +If a raw string is used in the definition of the _HID object +(instead of the EISAID macro), the string must contain all +alphanumeric characters (e.g., "*PNP0011" is not allowed because +of the asterisk.) + +Implemented checking for invalid use of ACPI reserved names for +most of the name creation operators (Name, Device, Event, Mutex, +OperationRegion, PowerResource, Processor, and ThermalZone.) +Previously, this check was only performed for control methods. + +Implemented an additional check on the Name operator to emit an +error if a reserved name that must be implemented in ASL as a +control method is used. We know that a reserved name must be a +method if it is defined with input arguments. + +The warning emitted when a namespace object reference is not +found +during the cross reference phase has been changed into an error. +The "External" directive should be used for names defined in +other +modules. + + +4) Tools and Utilities + +The 16-bit tools (adump16 and aexec16) have been regenerated and +tested. + +Fixed a problem with the output of both acpidump and adump16 +where +the indentation of closing parentheses and brackets was not + +aligned properly with the parent block. + + +---------------------------------------- +03 May 2002. Summary of changes for this release. + + +1) ACPI CA Core Subsystem Version 20020503: + +Added support a new OSL interface that allows the host operating + +system software to override the DSDT found in the firmware - +AcpiOsTableOverride. With this interface, the OSL can examine +the +version of the firmware DSDT and replace it with a different one +if desired. + +Added new external interfaces for accessing ACPI registers from +device drivers and other system software - AcpiGetRegister and +AcpiSetRegister. This was simply an externalization of the +existing AcpiHwBitRegister interfaces. + +Fixed a regression introduced in the previous build where the +ASL/AML CreateField operator always returned an error, +"destination must be a NS Node". + +Extended the maximum time (before failure) to successfully enable +ACPI mode to 3 seconds. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 68.5K Code, 7.0K Data, 75.5K Total + Debug Version: 142.4K Code, 58.3K Data, 200.7K Total + Current Release: + Non-Debug Version: 68.8K Code, 7.1K Data, 75.9K Total + Debug Version: 142.9K Code, 58.4K Data, 201.3K Total + + +2) Linux + +Enhanced ACPI init code for SMP. We are now fully MPS and $PIR- +free. While 3 out of 4 of our in-house systems work fine, the +last +one still hangs when testing the LAPIC timer. + +Renamed many files in 2.5 kernel release to omit "acpi_" from the +name. + +Added warning on boot for Presario 711FR. + +Sleep improvements (Pavel Machek) + +ACPI can now be built without CONFIG_PCI enabled. + +IA64: Fixed memory map functions (JI Lee) + + +3) iASL Compiler Version X2043: + +Added support to allow the compiler to be integrated into the MS +VC++ development environment for one-button compilation of single +files or entire projects -- with error-to-source-line mapping. + +Implemented support for compile-time constant folding for the +Type3, Type4, and Type5 opcodes first defined in the ACPI 2.0 +specification. This allows the ASL writer to use expressions +instead of Integer/Buffer/String constants in terms that must +evaluate to constants at compile time and will also simplify the +emitted AML in any such sub-expressions that can be folded +(evaluated at compile-time.) This increases the size of the +compiler significantly because a portion of the ACPI CA AML +interpreter is included within the compiler in order to pre- +evaluate constant expressions. + + +Fixed a problem with the "Unicode" ASL macro that caused the +compiler to fault. (This macro is used in conjunction with the +_STR reserved name.) + +Implemented an AML opcode optimization to use the Zero, One, and +Ones opcodes where possible to further reduce the size of integer +constants and thus reduce the overall size of the generated AML +code. + +Implemented error checking for new reserved terms for ACPI +version +2.0A. + +Implemented the -qr option to display the current list of ACPI +reserved names known to the compiler. + +Implemented the -qc option to display the current list of ASL +operators that are allowed within constant expressions and can +therefore be folded at compile time if the operands are +constants. + + +4) Documentation + +Updated the Programmer's Reference for new interfaces, data +types, +and memory allocation model options. + +Updated the iASL Compiler User Reference to apply new format and +add information about new features and options. + +---------------------------------------- +19 April 2002. Summary of changes for this release. + +1) ACPI CA Core Subsystem Version 20020419: + +The source code base for the Core Subsystem has been completely +cleaned with PC-lint (FlexLint) for both 32-bit and 64-bit +versions. The Lint option files used are included in the +/acpi/generate/lint directory. + +Implemented enhanced status/error checking across the entire +Hardware manager subsystem. Any hardware errors (reported from +the OSL) are now bubbled up and will abort a running control +method. + + +Fixed a problem where the per-ACPI-table integer width (32 or 64) +was stored only with control method nodes, causing a fault when +non-control method code was executed during table loading. The +solution implemented uses a global variable to indicate table +width across the entire ACPI subsystem. Therefore, ACPI CA does +not support mixed integer widths across different ACPI tables +(DSDT, SSDT). + +Fixed a problem where NULL extended fields (X fields) in an ACPI +2.0 ACPI FADT caused the table load to fail. Although the +existing ACPI specification is a bit fuzzy on this topic, the new +behavior is to fall back on a ACPI 1.0 field if the corresponding +ACPI 2.0 X field is zero (even though the table revision +indicates +a full ACPI 2.0 table.) The ACPI specification will be updated +to +clarify this issue. + +Fixed a problem with the SystemMemory operation region handler +where memory was always accessed byte-wise even if the AML- +specified access width was larger than a byte. This caused +problems on systems with memory-mapped I/O. Memory is now +accessed with the width specified. On systems that do not +support +non-aligned transfers, a check is made to guarantee proper +address +alignment before proceeding in order to avoid an AML-caused +alignment fault within the kernel. + + +Fixed a problem with the ExtendedIrq resource where only one byte +of the 4-byte Irq field was extracted. + +Fixed the AcpiExDigitsNeeded() procedure to support _UID. This +function was out of date and required a rewrite. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 66.6K Code, 6.5K Data, 73.1K Total + Debug Version: 139.8K Code, 57.4K Data, 197.2K Total + Current Release: + Non-Debug Version: 68.5K Code, 7.0K Data, 75.5K Total + Debug Version: 142.4K Code, 58.3K Data, 200.7K Total + + +2) Linux + +PCI IRQ routing fixes (Dominik Brodowski) + + +3) iASL Compiler Version X2042: + +Implemented an additional compile-time error check for a field +unit whose size + minimum access width would cause a run-time +access beyond the end-of-region. Previously, only the field size +itself was checked. + +The Core subsystem and iASL compiler now share a common parse +object in preparation for compile-time evaluation of the type +3/4/5 ASL operators. + + +---------------------------------------- +Summary of changes for this release: 03_29_02 + +1) ACPI CA Core Subsystem Version 20020329: + +Implemented support for late evaluation of TermArg operands to +Buffer and Package objects. This allows complex expressions to +be +used in the declarations of these object types. + +Fixed an ACPI 1.0 compatibility issue when reading Fields. In +ACPI +1.0, if the field was larger than 32 bits, it was returned as a +buffer - otherwise it was returned as an integer. In ACPI 2.0, +the field is returned as a buffer only if the field is larger +than +64 bits. The TableRevision is now considered when making this +conversion to avoid incompatibility with existing ASL code. + +Implemented logical addressing for AcpiOsGetRootPointer. This +allows an RSDP with either a logical or physical address. With +this support, the host OS can now override all ACPI tables with +one logical RSDP. Includes implementation of "typed" pointer +support to allow a common data type for both physical and logical +pointers internally. This required a change to the +AcpiOsGetRootPointer interface. + +Implemented the use of ACPI 2.0 Generic Address Structures for +all +GPE, Fixed Event, and PM Timer I/O. This allows the use of +memory +mapped I/O for these ACPI features. + +Initialization now ignores not only non-required tables (All +tables other than the FADT, FACS, DSDT, and SSDTs), but also does +not validate the table headers of unrecognized tables. + +Fixed a problem where a notify handler could only be +installed/removed on an object of type Device. All "notify" + +objects are now supported -- Devices, Processor, Power, and +Thermal. + +Removed most verbosity from the ACPI_DB_INFO debug level. Only +critical information is returned when this debug level is +enabled. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release + Non-Debug Version: 65.4K Code, 6.2K Data, 71.6K Total + Debug Version: 138.0K Code, 56.6K Data, 194.6K Total + Current Release: + Non-Debug Version: 66.6K Code, 6.5K Data, 73.1K Total + Debug Version: 139.8K Code, 57.4K Data, 197.2K Total + + +2) Linux: + +The processor driver (acpi_processor.c) now fully supports ACPI +2.0-based processor performance control (e.g. Intel(R) +SpeedStep(TM) technology) Note that older laptops that only have +the Intel "applet" interface are not supported through this. The +'limit' and 'performance' interface (/proc) are fully functional. +[Note that basic policy for controlling performance state +transitions will be included in the next version of ospmd.] The +idle handler was modified to more aggressively use C2, and PIIX4 +errata handling underwent a complete overhaul (big thanks to +Dominik Brodowski). + +Added support for ACPI-PCI device binding (acpi_pci_root.c). _ADR- +based devices in the ACPI namespace are now dynamically bound +(associated) with their PCI counterparts (e.g. PCI1->01:00.0). +This allows, among other things, ACPI to resolve bus numbers for +subordinate PCI bridges. + +Enhanced PCI IRQ routing to get the proper bus number for _PRT +entries defined underneath PCI bridges. + +Added IBM 600E to bad bios list due to invalid _ADR value for +PIIX4 PCI-ISA bridge, resulting in improper PCI IRQ routing. + +In the process of adding full MADT support (e.g. IOAPIC) for IA32 +(acpi.c, mpparse.c) -- stay tuned. + +Added back visual differentiation between fixed-feature and +control-method buttons in dmesg. Buttons are also subtyped (e.g. +button/power/PWRF) to simplify button identification. + +We no longer use -Wno-unused when compiling debug. Please ignore +any "_THIS_MODULE defined but not used" messages. + +Can now shut down the system using "magic sysrq" key. + + +3) iASL Compiler version 2041: + +Fixed a problem where conversion errors for hex/octal/decimal +constants were not reported. + +Implemented a fix for the General Register template Address +field. +This field was 8 bits when it should be 64. + +Fixed a problem where errors/warnings were no longer being +emitted +within the listing output file. + +Implemented the ACPI 2.0A restriction on ACPI Table Signatures to +exactly 4 characters, alphanumeric only. + + + + +---------------------------------------- +Summary of changes for this release: 03_08_02 + + +1) ACPI CA Core Subsystem Version 20020308: + +Fixed a problem with AML Fields where the use of the "AccessAny" +keyword could cause an interpreter error due to attempting to +read +or write beyond the end of the parent Operation Region. + +Fixed a problem in the SystemMemory Operation Region handler +where +an attempt was made to map memory beyond the end of the region. +This was the root cause of the "AE_ERROR" and "AE_NO_MEMORY" +errors on some Linux systems. + +Fixed a problem where the interpreter/namespace "search to root" +algorithm was not functioning for some object types. Relaxed the +internal restriction on the search to allow upsearches for all +external object types as well as most internal types. + + +2) Linux: + +We now use safe_halt() macro versus individual calls to sti | +hlt. + +Writing to the processor limit interface should now work. "echo +1" +will increase the limit, 2 will decrease, and 0 will reset to the + +default. + + +3) ASL compiler: + +Fixed segfault on Linux version. + + +---------------------------------------- +Summary of changes for this release: 02_25_02 + +1) ACPI CA Core Subsystem: + + +Fixed a problem where the GPE bit masks were not initialized +properly, causing erratic GPE behavior. + +Implemented limited support for multiple calling conventions. +The +code can be generated with either the VPL (variable parameter +list, or "C") convention, or the FPL (fixed parameter list, or +"Pascal") convention. The core subsystem is about 3.4% smaller +when generated with FPL. + + +2) Linux + +Re-add some /proc/acpi/event functionality that was lost during +the rewrite + +Resolved issue with /proc events for fixed-feature buttons +showing +up as the system device. + +Fixed checks on C2/C3 latencies to be inclusive of maximum +values. + +Replaced AE_ERRORs in acpi_osl.c with more specific error codes. + +Changed ACPI PRT option from "pci=noacpi-routing" to "pci=noacpi" + +Fixed limit interface & usage to fix bugs with passive cooling +hysterisis. + +Restructured PRT support. + + +---------------------------------------- +Summary of changes for this label: 02_14_02 + + +1) ACPI CA Core Subsystem: + +Implemented support in AcpiLoadTable to allow loading of FACS and +FADT tables. + +Suport for the now-obsolete interim 0.71 64-bit ACPI tables has +been removed. All 64-bit platforms should be migrated to the +ACPI +2.0 tables. The actbl71.h header has been removed from the +source +tree. + +All C macros defined within the subsystem have been prefixed with +"ACPI_" to avoid collision with other system include files. + +Removed the return value for the two AcpiOsPrint interfaces, +since +it is never used and causes lint warnings for ignoring the return +value. + +Added error checking to all internal mutex acquire and release +calls. Although a failure from one of these interfaces is +probably a fatal system error, these checks will cause the +immediate abort of the currently executing method or interface. + +Fixed a problem where the AcpiSetCurrentResources interface could +fault. This was a side effect of the deployment of the new +memory +allocation model. + +Fixed a couple of problems with the Global Lock support +introduced +in the last major build. The "common" (1.0/2.0) internal FACS +was +being overwritten with the FACS signature and clobbering the +Global Lock pointer. Also, the actual firmware FACS was being +unmapped after construction of the "common" FACS, preventing +access to the actual Global Lock field within it. The "common" +internal FACS is no longer installed as an actual ACPI table; it +is used simply as a global. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release (02_07_01) + Non-Debug Version: 65.2K Code, 6.2K Data, 71.4K Total + Debug Version: 136.9K Code, 56.4K Data, 193.3K Total + Current Release: + Non-Debug Version: 65.4K Code, 6.2K Data, 71.6K Total + Debug Version: 138.0K Code, 56.6K Data, 194.6K Total + + +2) Linux + +Updated Linux-specific code for core macro and OSL interface +changes described above. + +Improved /proc/acpi/event. It now can be opened only once and has +proper poll functionality. + +Fixed and restructured power management (acpi_bus). + +Only create /proc "view by type" when devices of that class +exist. + +Fixed "charging/discharging" bug (and others) in acpi_battery. + +Improved thermal zone code. + + +3) ASL Compiler, version X2039: + + +Implemented the new compiler restriction on ASL String hex/octal +escapes to non-null, ASCII values. An error results if an +invalid +value is used. (This will require an ACPI 2.0 specification +change.) + +AML object labels that are output to the optional C and ASM +source +are now prefixed with both the ACPI table signature and table ID +to help guarantee uniqueness within a large BIOS project. + + +---------------------------------------- +Summary of changes for this label: 02_01_02 + +1) ACPI CA Core Subsystem: + +ACPI 2.0 support is complete in the entire Core Subsystem and the +ASL compiler. All new ACPI 2.0 operators are implemented and all +other changes for ACPI 2.0 support are complete. With +simultaneous code and data optimizations throughout the +subsystem, +ACPI 2.0 support has been implemented with almost no additional +cost in terms of code and data size. + +Implemented a new mechanism for allocation of return buffers. If +the buffer length is set to ACPI_ALLOCATE_BUFFER, the buffer will +be allocated on behalf of the caller. Consolidated all return +buffer validation and allocation to a common procedure. Return +buffers will be allocated via the primary OSL allocation +interface +since it appears that a separate pool is not needed by most +users. +If a separate pool is required for these buffers, the caller can +still use the original mechanism and pre-allocate the buffer(s). + +Implemented support for string operands within the DerefOf +operator. + +Restructured the Hardware and Event managers to be table driven, +simplifying the source code and reducing the amount of generated +code. + +Split the common read/write low-level ACPI register bitfield +procedure into a separate read and write, simplifying the code +considerably. + +Obsoleted the AcpiOsCallocate OSL interface. This interface was +used only a handful of times and didn't have enough critical mass +for a separate interface. Replaced with a common calloc +procedure +in the core. + +Fixed a reported problem with the GPE number mapping mechanism +that allows GPE1 numbers to be non-contiguous with GPE0. +Reorganized the GPE information and shrunk a large array that was +originally large enough to hold info for all possible GPEs (256) +to simply large enough to hold all GPEs up to the largest GPE +number on the machine. + +Fixed a reported problem with resource structure alignment on 64- +bit platforms. + +Changed the AcpiEnableEvent and AcpiDisableEvent external +interfaces to not require any flags for the common case of +enabling/disabling a GPE. + +Implemented support to allow a "Notify" on a Processor object. + +Most TBDs in comments within the source code have been resolved +and eliminated. + + +Fixed a problem in the interpreter where a standalone parent +prefix (^) was not handled correctly in the interpreter and +debugger. + +Removed obsolete and unnecessary GPE save/restore code. + +Implemented Field support in the ASL Load operator. This allows +a +table to be loaded from a named field, in addition to loading a +table directly from an Operation Region. + +Implemented timeout and handle support in the external Global +Lock +interfaces. + +Fixed a problem in the AcpiDump utility where pathnames were no +longer being generated correctly during the dump of named +objects. + +Modified the AML debugger to give a full display of if/while +predicates instead of just one AML opcode at a time. (The +predicate can have several nested ASL statements.) The old +method +was confusing during single stepping. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release (12_18_01) + Non-Debug Version: 66.1K Code, 5.5K Data, 71.6K Total + Debug Version: 138.3K Code, 55.9K Data, 194.2K Total + Current Release: + Non-Debug Version: 65.2K Code, 6.2K Data, 71.4K Total + Debug Version: 136.9K Code, 56.4K Data, 193.3K Total + +2) Linux + + Implemented fix for PIIX reverse throttling errata (Processor +driver) + +Added new Limit interface (Processor and Thermal drivers) + +New thermal policy (Thermal driver) + +Many updates to /proc + +Battery "low" event support (Battery driver) + +Supports ACPI PCI IRQ routing (PCI Link and PCI root drivers) + +IA32 - IA64 initialization unification, no longer experimental + +Menuconfig options redesigned + +3) ASL Compiler, version X2037: + +Implemented several new output features to simplify integration +of +AML code into firmware: 1) Output the AML in C source code with +labels for each named ASL object. The original ASL source +code +is interleaved as C comments. 2) Output the AML in ASM source +code +with labels and interleaved ASL source. 3) Output the AML in +raw hex table form, in either C or ASM. + +Implemented support for optional string parameters to the +LoadTable operator. + +Completed support for embedded escape sequences within string +literals. The compiler now supports all single character escapes +as well as the Octal and Hex escapes. Note: the insertion of a +null byte into a string literal (via the hex/octal escape) causes +the string to be immediately terminated. A warning is issued. + +Fixed a problem where incorrect AML was generated for the case +where an ASL namepath consists of a single parent prefix ( + +) with no trailing name segments. + +The compiler has been successfully generated with a 64-bit C +compiler. + + + + +---------------------------------------- +Summary of changes for this label: 12_18_01 + +1) Linux + +Enhanced blacklist with reason and severity fields. Any table's +signature may now be used to identify a blacklisted system. + +Call _PIC control method to inform the firmware which interrupt +model the OS is using. Turn on any disabled link devices. + +Cleaned up busmgr /proc error handling (Andreas Dilger) + + 2) ACPI CA Core Subsystem: + +Implemented ACPI 2.0 semantics for the "Break" operator (Exit +from +while loop) + +Completed implementation of the ACPI 2.0 "Continue", +"ConcatenateResTemplate", "DataTableRegion", and "LoadTable" +operators. All new ACPI 2.0 operators are now implemented in +both +the ASL compiler and the AML interpreter. The only remaining +ACPI +2.0 task is support for the String data type in the DerefOf +operator. Fixed a problem with AcquireMutex where the status +code +was lost if the caller had to actually wait for the mutex. + +Increased the maximum ASL Field size from 64K bits to 4G bits. + +Completed implementation of the external Global Lock interfaces - +- +AcpiAcquireGlobalLock and AcpiReleaseGlobalLock. The Timeout and +Handler parameters were added. + +Completed another pass at removing warnings and issues when +compiling with 64-bit compilers. The code now compiles cleanly +with the Intel 64-bit C/C++ compiler. Most notably, the pointer +add and subtract (diff) macros have changed considerably. + + +Created and deployed a new ACPI_SIZE type that is 64-bits wide on +64-bit platforms, 32-bits on all others. This type is used +wherever memory allocation and/or the C sizeof() operator is +used, +and affects the OSL memory allocation interfaces AcpiOsAllocate +and AcpiOsCallocate. + +Implemented sticky user breakpoints in the AML debugger. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release (12_05_01) + Non-Debug Version: 64.7K Code, 5.3K Data, 70.0K Total + Debug Version: 136.2K Code, 55.6K Data, 191.8K Total + Current Release: + Non-Debug Version: 66.1K Code, 5.5K Data, 71.6K Total + Debug Version: 138.3K Code, 55.9K Data, 194.2K Total + + 3) ASL Compiler, version X2034: + +Now checks for (and generates an error if detected) the use of a +Break or Continue statement without an enclosing While statement. + + +Successfully generated the compiler with the Intel 64-bit C +compiler. + + ---------------------------------------- +Summary of changes for this label: 12_05_01 + + 1) ACPI CA Core Subsystem: + +The ACPI 2.0 CopyObject operator is fully implemented. This +operator creates a new copy of an object (and is also used to +bypass the "implicit conversion" mechanism of the Store +operator.) + +The ACPI 2.0 semantics for the SizeOf operator are fully +implemented. The change is that performing a SizeOf on a +reference object causes an automatic dereference of the object to +tha actual value before the size is evaluated. This behavior was +undefined in ACPI 1.0. + +The ACPI 2.0 semantics for the Extended IRQ resource descriptor +have been implemented. The interrupt polarity and mode are now +independently set. + +Fixed a problem where ASL Constants (Zero, One, Ones, Revision) +appearing in Package objects were not properly converted to +integers when the internal Package was converted to an external +object (via the AcpiEvaluateObject interface.) + +Fixed a problem with the namespace object deletion mechanism for +objects created by control methods. There were two parts to this +problem: 1) Objects created during the initialization phase +method +parse were not being deleted, and 2) The object owner ID +mechanism +to track objects was broken. + +Fixed a problem where the use of the ASL Scope operator within a +control method would result in an invalid opcode exception. + +Fixed a problem introduced in the previous label where the buffer +length required for the _PRT structure was not being returned +correctly. + +Code and Data Size: Current core subsystem library sizes are +shown +below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these +values do not include any ACPI driver or OSPM code. The debug +version of the code includes the debug output trace mechanism and +has a larger code and data size. Note that these values will +vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Release (11_20_01) + Non-Debug Version: 64.1K Code, 5.3K Data, 69.4K Total + Debug Version: 135.1K Code, 55.4K Data, 190.5K Total + + Current Release: + Non-Debug Version: 64.7K Code, 5.3K Data, 70.0K Total + Debug Version: 136.2K Code, 55.6K Data, 191.8K Total + + 2) Linux: + +Updated all files to apply cleanly against 2.4.16. + +Added basic PCI Interrupt Routing Table (PRT) support for IA32 +(acpi_pci.c), and unified the PRT code for IA32 and IA64. This +version supports both static and dyanmic PRT entries, but dynamic +entries are treated as if they were static (not yet +reconfigurable). Architecture- specific code to use this data is +absent on IA32 but should be available shortly. + +Changed the initialization sequence to start the ACPI interpreter +(acpi_init) prior to initialization of the PCI driver (pci_init) +in init/main.c. This ordering is required to support PRT and +facilitate other (future) enhancement. A side effect is that the +ACPI bus driver and certain device drivers can no longer be +loaded +as modules. + +Modified the 'make menuconfig' options to allow PCI Interrupt +Routing support to be included without the ACPI Bus and other +device drivers. + + 3) ASL Compiler, version X2033: + +Fixed some issues with the use of the new CopyObject and +DataTableRegion operators. Both are fully functional. + + ---------------------------------------- +Summary of changes for this label: 11_20_01 + + 20 November 2001. Summary of changes for this release. + + 1) ACPI CA Core Subsystem: + +Updated Index support to match ACPI 2.0 semantics. Storing a +Integer, String, or Buffer to an Index of a Buffer will store +only +the least-significant byte of the source to the Indexed buffer +byte. Multiple writes are not performed. + +Fixed a problem where the access type used in an AccessAs ASL +operator was not recorded correctly into the field object. + +Fixed a problem where ASL Event objects were created in a +signalled state. Events are now created in an unsignalled state. + +The internal object cache is now purged after table loading and +initialization to reduce the use of dynamic kernel memory -- on +the assumption that object use is greatest during the parse phase +of the entire table (versus the run-time use of individual +control +methods.) + +ACPI 2.0 variable-length packages are now fully operational. + +Code and Data Size: Code and Data optimizations have permitted +new +feature development with an actual reduction in the library size. +Current core subsystem library sizes are shown below. These are +the code and data sizes for the acpica.lib produced by the +Microsoft Visual C++ 6.0 compiler, and these values do not +include +any ACPI driver or OSPM code. The debug version of the code +includes the debug output trace mechanism and has a larger code +and data size. Note that these values will vary depending on the +efficiency of the compiler and the compiler options used during +generation. + + Previous Release (11_09_01): + Non-Debug Version: 63.7K Code, 5.2K Data, 68.9K Total + Debug Version: 134.5K Code, 55.4K Data, 189.9K Total + + Current Release: + Non-Debug Version: 64.1K Code, 5.3K Data, 69.4K Total + Debug Version: 135.1K Code, 55.4K Data, 190.5K Total + + 2) Linux: + +Enhanced the ACPI boot-time initialization code to allow the use +of Local APIC tables for processor enumeration on IA-32, and to +pave the way for a fully MPS-free boot (on SMP systems) in the +near future. This functionality replaces +arch/i386/kernel/acpitables.c, which was introduced in an earlier +2.4.15-preX release. To enable this feature you must add +"acpi_boot=on" to the kernel command line -- see the help entry +for CONFIG_ACPI_BOOT for more information. An IA-64 release is +in +the works... + +Restructured the configuration options to allow boot-time table +parsing support without inclusion of the ACPI Interpreter (and +other) code. + +NOTE: This release does not include fixes for the reported +events, +power-down, and thermal passive cooling issues (coming soon). + + 3) ASL Compiler: + +Added additional typechecking for Fields within restricted access +Operation Regions. All fields within EC and CMOS regions must be +declared with ByteAcc. All fields withing SMBus regions must be +declared with the BufferAcc access type. + +Fixed a problem where the listing file output of control methods +no longer interleaved the actual AML code with the ASL source +code. + + + + +---------------------------------------- +Summary of changes for this label: 11_09_01 + +1) ACPI CA Core Subsystem: + +Implemented ACPI 2.0-defined support for writes to fields with a +Buffer, String, or Integer source operand that is smaller than +the +target field. In these cases, the source operand is zero-extended +to fill the target field. + +Fixed a problem where a Field starting bit offset (within the +parent operation region) was calculated incorrectly if the + +alignment of the field differed from the access width. This +affected CreateWordField, CreateDwordField, CreateQwordField, and +possibly other fields that use the "AccessAny" keyword. + +Fixed a problem introduced in the 11_02_01 release where indirect +stores through method arguments did not operate correctly. + +2) Linux: + +Implemented boot-time ACPI table parsing support +(CONFIG_ACPI_BOOT) for IA32 and IA64 UP/SMP systems. This code +facilitates the use of ACPI tables (e.g. MADT, SRAT) rather than +legacy BIOS interfaces (e.g. MPS) for the configuration of system +processors, memory, and interrupts during setup_arch(). Note +that +this patch does not include the required architecture-specific +changes required to apply this information -- subsequent patches +will be posted for both IA32 and IA64 to achieve this. + +Added low-level sleep support for IA32 platforms, courtesy of Pat +Mochel. This allows IA32 systems to transition to/from various +sleeping states (e.g. S1, S3), although the lack of a centralized +driver model and power-manageable drivers will prevent its +(successful) use on most systems. + +Revamped the ACPI 'menuconfig' layout: created new "ACPI Support" +submenu, unified IA32 and IA64 options, added new "Boot using +ACPI +tables" option, etc. + +Increased the default timeout for the EC driver from 1ms to 10ms +(1000 cycles of 10us) to try to address AE_TIME errors during EC +transactions. + + ---------------------------------------- +Summary of changes for this label: 11_02_01 + +1) ACPI CA Core Subsystem: + +ACPI 2.0 Support: Implemented ACPI 2.0 64-bit Field access +(QWordAcc keyword). All ACPI 2.0 64-bit support is now +implemented. + +OSL Interfaces: Several of the OSL (AcpiOs*) interfaces required +changes to support ACPI 2.0 Qword field access. Read/Write +PciConfiguration(), Read/Write Memory(), and Read/Write Port() +now +accept an ACPI_INTEGER (64 bits) as the value parameter. Also, +the value parameter for the address space handler interface is +now +an ACPI_INTEGER. OSL implementations of these interfaces must +now +handle the case where the Width parameter is 64. + +Index Fields: Fixed a problem where unaligned bit assembly and +disassembly for IndexFields was not supported correctly. + +Index and Bank Fields: Nested Index and Bank Fields are now +supported. During field access, a check is performed to ensure +that the value written to an Index or Bank register is not out of +the range of the register. The Index (or Bank) register is +written before each access to the field data. Future support will +include allowing individual IndexFields to be wider than the +DataRegister width. + +Fields: Fixed a problem where the AML interpreter was incorrectly +attempting to write beyond the end of a Field/OpRegion. This was +a boundary case that occurred when a DWORD field was written to a +BYTE access OpRegion, forcing multiple writes and causing the +interpreter to write one datum too many. + +Fields: Fixed a problem with Field/OpRegion access where the +starting bit address of a field was incorrectly calculated if the +current access type was wider than a byte (WordAcc, DwordAcc, or +QwordAcc). + +Fields: Fixed a problem where forward references to individual +FieldUnits (individual Field names within a Field definition) +were +not resolved during the AML table load. + +Fields: Fixed a problem where forward references from a Field +definition to the parent Operation Region definition were not +resolved during the AML table load. + +Fields: Duplicate FieldUnit names within a scope are now detected +during AML table load. + +Acpi Interfaces: Fixed a problem where the AcpiGetName() +interface +returned an incorrect name for the root node. + +Code and Data Size: Code and Data optimizations have permitted +new +feature development with an actual reduction in the library size. +Current core subsystem library sizes are shown below. These are +the code and data sizes for the acpica.lib produced by the +Microsoft Visual C++ 6.0 compiler, and these values do not +include +any ACPI driver or OSPM code. The debug version of the code +includes the debug output trace mechanism and has a larger code +and data size. Note that these values will vary depending on the +efficiency of the compiler and the compiler options used during +generation. + + Previous Release (10_18_01): + Non-Debug Version: 63.9K Code, 5.1K Data, 69.0K Total + Debug Version: 136.7K Code, 57.4K Data, 194.2K Total + + Current Release: + Non-Debug Version: 63.7K Code, 5.2K Data, 68.9K Total + Debug Version: 134.5K Code, 55.4K Data, 189.9K Total + + 2) Linux: + +Improved /proc processor output (Pavel Machek) Re-added +MODULE_LICENSE("GPL") to all modules. + + 3) ASL Compiler version X2030: + +Duplicate FieldUnit names within a scope are now detected and +flagged as errors. + + 4) Documentation: + +Programmer Reference updated to reflect OSL and address space +handler interface changes described above. + +---------------------------------------- +Summary of changes for this label: 10_18_01 + +ACPI CA Core Subsystem: + +Fixed a problem with the internal object reference count +mechanism +that occasionally caused premature object deletion. This resolves +all of the outstanding problem reports where an object is deleted +in the middle of an interpreter evaluation. Although this +problem +only showed up in rather obscure cases, the solution to the +problem involved an adjustment of all reference counts involving +objects attached to namespace nodes. + +Fixed a problem with Field support in the interpreter where +writing to an aligned field whose length is an exact multiple (2 +or greater) of the field access granularity would cause an +attempt +to write beyond the end of the field. + +The top level AML opcode execution functions within the +interpreter have been renamed with a more meaningful and +consistent naming convention. The modules exmonad.c and +exdyadic.c were eliminated. New modules are exoparg1.c, +exoparg2.c, exoparg3.c, and exoparg6.c. + +Support for the ACPI 2.0 "Mid" ASL operator has been implemented. + +Fixed a problem where the AML debugger was causing some internal +objects to not be deleted during subsystem termination. + +Fixed a problem with the external AcpiEvaluateObject interface +where the subsystem would fault if the named object to be +evaluated refered to a constant such as Zero, Ones, etc. + +Fixed a problem with IndexFields and BankFields where the +subsystem would fault if the index, data, or bank registers were +not defined in the same scope as the field itself. + +Added printf format string checking for compilers that support +this feature. Corrected more than 50 instances of issues with +format specifiers within invocations of ACPI_DEBUG_PRINT +throughout the core subsystem code. + +The ASL "Revision" operator now returns the ACPI support level +implemented in the core - the value "2" since the ACPI 2.0 +support +is more than 50% implemented. + +Enhanced the output of the AML debugger "dump namespace" command +to output in a more human-readable form. + +Current core subsystem library code sizes are shown below. These + +are the code and data sizes for the acpica.lib produced by the +Microsoft Visual C++ 6.0 compiler, and these values do not +include +any ACPI driver or OSPM code. The debug version of the code +includes the full debug trace mechanism -- leading to a much + +larger code and data size. Note that these values will vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Previous Label (09_20_01): + Non-Debug Version: 65K Code, 5K Data, 70K Total + Debug Version: 138K Code, 58K Data, 196K Total + + This Label: + + Non-Debug Version: 63.9K Code, 5.1K Data, 69.0K Total + Debug Version: 136.7K Code, 57.4K Data, 194.2K Total + +Linux: + +Implemented a "Bad BIOS Blacklist" to track machines that have +known ASL/AML problems. + +Enhanced the /proc interface for the thermal zone driver and +added +support for _HOT (the critical suspend trip point). The 'info' +file now includes threshold/policy information, and allows +setting +of _SCP (cooling preference) and _TZP (polling frequency) values +to the 'info' file. Examples: "echo tzp=5 > info" sets the +polling +frequency to 5 seconds, and "echo scp=1 > info" sets the cooling +preference to the passive/quiet mode (if supported by the ASL). + +Implemented a workaround for a gcc bug that resuted in an OOPs +when loading the control method battery driver. + + ---------------------------------------- +Summary of changes for this label: 09_20_01 + + ACPI CA Core Subsystem: + +The AcpiEnableEvent and AcpiDisableEvent interfaces have been +modified to allow individual GPE levels to be flagged as wake- +enabled (i.e., these GPEs are to remain enabled when the platform +sleeps.) + +The AcpiEnterSleepState and AcpiLeaveSleepState interfaces now +support wake-enabled GPEs. This means that upon entering the +sleep state, all GPEs that are not wake-enabled are disabled. +When leaving the sleep state, these GPEs are reenabled. + +A local double-precision divide/modulo module has been added to +enhance portability to OS kernels where a 64-bit math library is +not available. The new module is "utmath.c". + +Several optimizations have been made to reduce the use of CPU +stack. Originally over 2K, the maximum stack usage is now below +2K at 1860 bytes (1.82k) + +Fixed a problem with the AcpiGetFirmwareTable interface where the +root table pointer was not mapped into a logical address +properly. + +Fixed a problem where a NULL pointer was being dereferenced in +the +interpreter code for the ASL Notify operator. + +Fixed a problem where the use of the ASL Revision operator +returned an error. This operator now returns the current version +of the ACPI CA core subsystem. + +Fixed a problem where objects passed as control method parameters +to AcpiEvaluateObject were always deleted at method termination. +However, these objects may end up being stored into the namespace +by the called method. The object reference count mechanism was +applied to these objects instead of a force delete. + +Fixed a problem where static strings or buffers (contained in the +AML code) that are declared as package elements within the ASL +code could cause a fault because the interpreter would attempt to +delete them. These objects are now marked with the "static +object" flag to prevent any attempt to delete them. + +Implemented an interpreter optimization to use operands directly +from the state object instead of extracting the operands to local +variables. This reduces stack use and code size, and improves +performance. + +The module exxface.c was eliminated as it was an unnecessary +extra +layer of code. + +Current core subsystem library code sizes are shown below. These +are the code and data sizes for the acpica.lib produced by the +Microsoft Visual C++ 6.0 compiler, and these values do not +include +any ACPI driver or OSPM code. The debug version of the code +includes the full debug trace mechanism -- leading to a much +larger code and data size. Note that these values will vary +depending on the efficiency of the compiler and the compiler +options used during generation. + + Non-Debug Version: 65K Code, 5K Data, 70K Total +(Previously 69K) Debug Version: 138K Code, 58K Data, 196K +Total (Previously 195K) + +Linux: + +Support for ACPI 2.0 64-bit integers has been added. All ACPI +Integer objects are now 64 bits wide + +All Acpi data types and structures are now in lower case. Only +Acpi macros are upper case for differentiation. + + Documentation: + +Changes to the external interfaces as described above. + + ---------------------------------------- +Summary of changes for this label: 08_31_01 + + ACPI CA Core Subsystem: + +A bug with interpreter implementation of the ASL Divide operator +was found and fixed. The implicit function return value (not the +explicit store operands) was returning the remainder instead of +the quotient. This was a longstanding bug and it fixes several +known outstanding issues on various platforms. + +The ACPI_DEBUG_PRINT and function trace entry/exit macros have +been further optimized for size. There are 700 invocations of +the +DEBUG_PRINT macro alone, so each optimization reduces the size of +the debug version of the subsystem significantly. + +A stack trace mechanism has been implemented. The maximum stack +usage is about 2K on 32-bit platforms. The debugger command +"stat +stack" will display the current maximum stack usage. + +All public symbols and global variables within the subsystem are +now prefixed with the string "Acpi". This keeps all of the +symbols grouped together in a kernel map, and avoids conflicts +with other kernel subsystems. + +Most of the internal fixed lookup tables have been moved into the +code segment via the const operator. + +Several enhancements have been made to the interpreter to both +reduce the code size and improve performance. + +Current core subsystem library code sizes are shown below. These +are the code and data sizes for the acpica.lib produced by the +Microsoft Visual C++ 6.0 compiler, and these values do not +include +any ACPI driver or OSPM code. The debug version of the code +includes the full debug trace mechanism which contains over 700 +invocations of the DEBUG_PRINT macro, 500 function entry macro +invocations, and over 900 function exit macro invocations -- +leading to a much larger code and data size. Note that these +values will vary depending on the efficiency of the compiler and +the compiler options used during generation. + + Non-Debug Version: 64K Code, 5K Data, 69K Total +Debug Version: 137K Code, 58K Data, 195K Total + + Linux: + +Implemented wbinvd() macro, pending a kernel-wide definition. + +Fixed /proc/acpi/event to handle poll() and short reads. + + ASL Compiler, version X2026: + +Fixed a problem introduced in the previous label where the AML + +code emitted for package objects produced packages with zero +length. + + ---------------------------------------- +Summary of changes for this label: 08_16_01 + +ACPI CA Core Subsystem: + +The following ACPI 2.0 ASL operators have been implemented in the +AML interpreter (These are already supported by the Intel ASL +compiler): ToDecimalString, ToHexString, ToString, ToInteger, +and +ToBuffer. Support for 64-bit AML constants is implemented in the +AML parser, debugger, and disassembler. + +The internal memory tracking mechanism (leak detection code) has +been upgraded to reduce the memory overhead (a separate tracking +block is no longer allocated for each memory allocation), and now +supports all of the internal object caches. + +The data structures and code for the internal object caches have +been coelesced and optimized so that there is a single cache and +memory list data structure and a single group of functions that +implement generic cache management. This has reduced the code +size in both the debug and release versions of the subsystem. + +The DEBUG_PRINT macro(s) have been optimized for size and +replaced +by ACPI_DEBUG_PRINT. The syntax for this macro is slightly +different, because it generates a single call to an internal +function. This results in a savings of about 90 bytes per +invocation, resulting in an overall code and data savings of +about +16% in the debug version of the subsystem. + + Linux: + +Fixed C3 disk corruption problems and re-enabled C3 on supporting +machines. + +Integrated low-level sleep code by Patrick Mochel. + +Further tweaked source code Linuxization. + +Other minor fixes. + + ASL Compiler: + +Support for ACPI 2.0 variable length packages is fixed/completed. + +Fixed a problem where the optional length parameter for the ACPI +2.0 ToString operator. + +Fixed multiple extraneous error messages when a syntax error is +detected within the declaration line of a control method. + + ---------------------------------------- +Summary of changes for this label: 07_17_01 + +ACPI CA Core Subsystem: + +Added a new interface named AcpiGetFirmwareTable to obtain any +ACPI table via the ACPI signature. The interface can be called +at +any time during kernel initialization, even before the kernel +virtual memory manager is initialized and paging is enabled. +This +allows kernel subsystems to obtain ACPI tables very early, even +before the ACPI CA subsystem is initialized. + +Fixed a problem where Fields defined with the AnyAcc attribute +could be resolved to the incorrect address under the following +conditions: 1) the field width is larger than 8 bits and 2) the +parent operation region is not defined on a DWORD boundary. + +Fixed a problem where the interpreter is not being locked during +namespace initialization (during execution of the _INI control +methods), causing an error when an attempt is made to release it +later. + +ACPI 2.0 support in the AML Interpreter has begun and will be +ongoing throughout the rest of this year. In this label, The Mod +operator is implemented. + +Added a new data type to contain full PCI addresses named +ACPI_PCI_ID. This structure contains the PCI Segment, Bus, +Device, +and Function values. + + Linux: + +Enhanced the Linux version of the source code to change most +capitalized ACPI type names to lowercase. For example, all +instances of ACPI_STATUS are changed to acpi_status. This will +result in a large diff, but the change is strictly cosmetic and +aligns the CA code closer to the Linux coding standard. + +OSL Interfaces: + +The interfaces to the PCI configuration space have been changed +to +add the PCI Segment number and to split the single 32-bit +combined +DeviceFunction field into two 16-bit fields. This was +accomplished by moving the four values that define an address in +PCI configuration space (segment, bus, device, and function) to +the new ACPI_PCI_ID structure. + +The changes to the PCI configuration space interfaces led to a +reexamination of the complete set of address space access +interfaces for PCI, I/O, and Memory. The previously existing 18 +interfaces have proven difficult to maintain (any small change +must be propagated across at least 6 interfaces) and do not +easily +allow for future expansion to 64 bits if necessary. Also, on +some +systems, it would not be appropriate to demultiplex the access +width (8, 16, 32,or 64) before calling the OSL if the +corresponding native OS interfaces contain a similar access width +parameter. For these reasons, the 18 address space interfaces +have been replaced by these 6 new ones: + +AcpiOsReadPciConfiguration +AcpiOsWritePciConfiguration +AcpiOsReadMemory +AcpiOsWriteMemory +AcpiOsReadPort +AcpiOsWritePort + +Added a new interface named AcpiOsGetRootPointer to allow the OSL +to perform the platform and/or OS-specific actions necessary to +obtain the ACPI RSDP table pointer. On IA-32 platforms, this +interface will simply call down to the CA core to perform the low- +memory search for the table. On IA-64, the RSDP is obtained from +EFI. Migrating this interface to the OSL allows the CA core to + +remain OS and platform independent. + +Added a new interface named AcpiOsSignal to provide a generic +"function code and pointer" interface for various miscellaneous +signals and notifications that must be made to the host OS. The +first such signals are intended to support the ASL Fatal and +Breakpoint operators. In the latter case, the AcpiOsBreakpoint +interface has been obsoleted. + +The definition of the AcpiFormatException interface has been +changed to simplify its use. The caller no longer must supply a +buffer to the call; A pointer to a const string is now returned +directly. This allows the call to be easily used in printf +statements, etc. since the caller does not have to manage a local +buffer. + + + ASL Compiler, Version X2025: + +The ACPI 2.0 Switch/Case/Default operators have been implemented +and are fully functional. They will work with all ACPI 1.0 +interpreters, since the operators are simply translated to +If/Else +pairs. + +The ACPI 2.0 ElseIf operator is implemented and will also work +with 1.0 interpreters, for the same reason. + +Implemented support for ACPI 2.0 variable-length packages. These +packages have a separate opcode, and their size is determined by +the interpreter at run-time. + +Documentation The ACPI CA Programmer Reference has been updated +to +reflect the new interfaces and changes to existing interfaces. + + ------------------------------------------ +Summary of changes for this label: 06_15_01 + + ACPI CA Core Subsystem: + +Fixed a problem where a DWORD-accessed field within a Buffer +object would get its byte address inadvertently rounded down to +the nearest DWORD. Buffers are always Byte-accessible. + + ASL Compiler, version X2024: + +Fixed a problem where the Switch() operator would either fault or +hang the compiler. Note however, that the AML code for this ACPI +2.0 operator is not yet implemented. + +Compiler uses the new AcpiOsGetTimer interface to obtain compile +timings. + +Implementation of the CreateField operator automatically converts +a reference to a named field within a resource descriptor from a +byte offset to a bit offset if required. + +Added some missing named fields from the resource descriptor +support. These are the names that are automatically created by +the +compiler to reference fields within a descriptor. They are only +valid at compile time and are not passed through to the AML +interpreter. + +Resource descriptor named fields are now typed as Integers and +subject to compile-time typechecking when used in expressions. + + ------------------------------------------ +Summary of changes for this label: 05_18_01 + + ACPI CA Core Subsystem: + +Fixed a couple of problems in the Field support code where bits +from adjacent fields could be returned along with the proper +field +bits. Restructured the field support code to improve performance, +readability and maintainability. + +New DEBUG_PRINTP macro automatically inserts the procedure name +into the output, saving hundreds of copies of procedure name +strings within the source, shrinking the memory footprint of the +debug version of the core subsystem. + + Source Code Structure: + +The source code directory tree was restructured to reflect the +current organization of the component architecture. Some files +and directories have been moved and/or renamed. + + Linux: + +Fixed leaking kacpidpc processes. + +Fixed queueing event data even when /proc/acpi/event is not +opened. + + ASL Compiler, version X2020: + +Memory allocation performance enhancement - over 24X compile time +improvement on large ASL files. Parse nodes and namestring +buffers are now allocated from a large internal compiler buffer. + +The temporary .SRC file is deleted unless the "-s" option is +specified + +The "-d" debug output option now sends all output to the .DBG +file +instead of the console. + +"External" second parameter is now optional + +"ElseIf" syntax now properly allows the predicate + +Last operand to "Load" now recognized as a Target operand + +Debug object can now be used anywhere as a normal object. + +ResourceTemplate now returns an object of type BUFFER + +EISAID now returns an object of type INTEGER + +"Index" now works with a STRING operand + +"LoadTable" now accepts optional parameters + +"ToString" length parameter is now optional + +"Interrupt (ResourceType," parse error fixed. + +"Register" with a user-defined region space parse error fixed + +Escaped backslash at the end of a string ("\\") scan/parse error +fixed + +"Revision" is now an object of type INTEGER. + + + +------------------------------------------ +Summary of changes for this label: 05_02_01 + +Linux: + +/proc/acpi/event now blocks properly. + +Removed /proc/sys/acpi. You can still dump your DSDT from +/proc/acpi/dsdt. + + ACPI CA Core Subsystem: + +Fixed a problem introduced in the previous label where some of +the +"small" resource descriptor types were not recognized. + +Improved error messages for the case where an ASL Field is +outside +the range of the parent operation region. + + ASL Compiler, version X2018: + + +Added error detection for ASL Fields that extend beyond the +length +of the parent operation region (only if the length of the region +is known at compile time.) This includes fields that have a +minimum access width that is smaller than the parent region, and +individual field units that are partially or entirely beyond the +extent of the parent. + + + +------------------------------------------ +Summary of changes for this label: 04_27_01 + + ACPI CA Core Subsystem: + +Fixed a problem where the namespace mutex could be released at +the +wrong time during execution of AcpiRemoveAddressSpaceHandler. + +Added optional thread ID output for debug traces, to simplify +debugging of multiple threads. Added context switch notification +when the debug code realizes that a different thread is now +executing ACPI code. + +Some additional external data types have been prefixed with the +string "ACPI_" for consistency. This may effect existing code. +The data types affected are the external callback typedefs - +e.g., + +WALK_CALLBACK becomes ACPI_WALK_CALLBACK. + + Linux: + +Fixed an issue with the OSL semaphore implementation where a +thread was waking up with an error from receiving a SIGCHLD +signal. + +Linux version of ACPI CA now uses the system C library for string +manipulation routines instead of a local implementation. + +Cleaned up comments and removed TBDs. + + ASL Compiler, version X2017: + +Enhanced error detection and reporting for all file I/O +operations. + + Documentation: + +Programmer Reference updated to version 1.06. + + + +------------------------------------------ +Summary of changes for this label: 04_13_01 + + ACPI CA Core Subsystem: + +Restructured support for BufferFields and RegionFields. +BankFields support is now fully operational. All known 32-bit +limitations on field sizes have been removed. Both BufferFields +and (Operation) RegionFields are now supported by the same field +management code. + +Resource support now supports QWORD address and IO resources. The +16/32/64 bit address structures and the Extended IRQ structure +have been changed to properly handle Source Resource strings. + +A ThreadId of -1 is now used to indicate a "mutex not acquired" +condition internally and must never be returned by +AcpiOsThreadId. +This reserved value was changed from 0 since Unix systems allow a +thread ID of 0. + +Linux: + +Driver code reorganized to enhance portability + +Added a kernel configuration option to control ACPI_DEBUG + +Fixed the EC driver to honor _GLK. + +ASL Compiler, version X2016: + +Fixed support for the "FixedHw" keyword. Previously, the FixedHw +address space was set to 0, not 0x7f as it should be. + + ------------------------------------------ +Summary of changes for this label: 03_13_01 + + ACPI CA Core Subsystem: + +During ACPI initialization, the _SB_._INI method is now run if +present. + +Notify handler fix - notifies are deferred until the parent +method +completes execution. This fixes the "mutex already acquired" +issue seen occasionally. + +Part of the "implicit conversion" rules in ACPI 2.0 have been +found to cause compatibility problems with existing ASL/AML. The +convert "result-to-target-type" implementation has been removed +for stores to method Args and Locals. Source operand conversion +is still fully implemented. Possible changes to ACPI 2.0 +specification pending. + +Fix to AcpiRsCalculatePciRoutingTableLength to return correct +length. + +Fix for compiler warnings for 64-bit compiles. + + Linux: + +/proc output aligned for easier parsing. + +Release-version compile problem fixed. + +New kernel configuration options documented in Configure.help. + +IBM 600E - Fixed Sleep button may generate "Invalid <NULL> +context" message. + + OSPM: + +Power resource driver integrated with bus manager. + +Fixed kernel fault during active cooling for thermal zones. + +Source Code: + +The source code tree has been restructured. + + + +------------------------------------------ +Summary of changes for this label: 03_02_01 + + Linux OS Services Layer (OSL): + +Major revision of all Linux-specific code. + +Modularized all ACPI-specific drivers. + +Added new thermal zone and power resource drivers. + +Revamped /proc interface (new functionality is under /proc/acpi). + +New kernel configuration options. + + Linux known issues: + +New kernel configuration options not documented in Configure.help +yet. + + +Module dependencies not currently implemented. If used, they +should be loaded in this order: busmgr, power, ec, system, +processor, battery, ac_adapter, button, thermal. + +Modules will not load if CONFIG_MODVERSION is set. + +IBM 600E - entering S5 may reboot instead of shutting down. + +IBM 600E - Sleep button may generate "Invalid <NULL> context" +message. + +Some systems may fail with "execution mutex already acquired" +message. + + ACPI CA Core Subsystem: + +Added a new OSL Interface, AcpiOsGetThreadId. This was required +for the deadlock detection code. Defined to return a non-zero, +32- +bit thread ID for the currently executing thread. May be a non- +zero constant integer on single-thread systems. + +Implemented deadlock detection for internal subsystem mutexes. +We +may add conditional compilation for this code (debug only) later. + +ASL/AML Mutex object semantics are now fully supported. This +includes multiple acquires/releases by owner and support for the + +Mutex SyncLevel parameter. + +A new "Force Release" mechanism automatically frees all ASL +Mutexes that have been acquired but not released when a thread +exits the interpreter. This forces conformance to the ACPI spec +("All mutexes must be released when an invocation exits") and +prevents deadlocked ASL threads. This mechanism can be expanded +(later) to monitor other resource acquisitions if OEM ASL code +continues to misbehave (which it will). + +Several new ACPI exception codes have been added for the Mutex +support. + +Recursive method calls are now allowed and supported (the ACPI +spec does in fact allow recursive method calls.) The number of +recursive calls is subject to the restrictions imposed by the +SERIALIZED method keyword and SyncLevel (ACPI 2.0) method +parameter. + +Implemented support for the SyncLevel parameter for control +methods (ACPI 2.0 feature) + +Fixed a deadlock problem when multiple threads attempted to use +the interpreter. + +Fixed a problem where the string length of a String package +element was not always set in a package returned from +AcpiEvaluateObject. + +Fixed a problem where the length of a String package element was +not always included in the length of the overall package returned +from AcpiEvaluateObject. + +Added external interfaces (Acpi*) to the ACPI debug memory +manager. This manager keeps a list of all outstanding +allocations, and can therefore detect memory leaks and attempts +to +free memory blocks more than once. Useful for code such as the +power manager, etc. May not be appropriate for device drivers. +Performance with the debug code enabled is slow. + +The ACPI Global Lock is now an optional hardware element. + + ASL Compiler Version X2015: + +Integrated changes to allow the compiler to be generated on +multiple platforms. + +Linux makefile added to generate the compiler on Linux + + Source Code: + +All platform-specific headers have been moved to their own +subdirectory, Include/Platform. + +New source file added, Interpreter/ammutex.c + +New header file, Include/acstruct.h + + Documentation: + +The programmer reference has been updated for the following new +interfaces: AcpiOsGetThreadId AcpiAllocate AcpiCallocate AcpiFree + + ------------------------------------------ +Summary of changes for this label: 02_08_01 + +Core ACPI CA Subsystem: Fixed a problem where an error was +incorrectly returned if the return resource buffer was larger +than +the actual data (in the resource interfaces). + +References to named objects within packages are resolved to the + +full pathname string before packages are returned directly (via +the AcpiEvaluateObject interface) or indirectly via the resource +interfaces. + +Linux OS Services Layer (OSL): + +Improved /proc battery interface. + + +Added C-state debugging output and other miscellaneous fixes. + +ASL Compiler Version X2014: + +All defined method arguments can now be used as local variables, +including the ones that are not actually passed in as parameters. +The compiler tracks initialization of the arguments and issues an +exception if they are used without prior assignment (just like +locals). + +The -o option now specifies a filename prefix that is used for +all +output files, including the AML output file. Otherwise, the +default behavior is as follows: 1) the AML goes to the file +specified in the DSDT. 2) all other output files use the input +source filename as the base. + + ------------------------------------------ +Summary of changes for this label: 01_25_01 + +Core ACPI CA Subsystem: Restructured the implementation of object +store support within the interpreter. This includes support for +the Store operator as well as any ASL operators that include a +target operand. + +Partially implemented support for Implicit Result-to-Target +conversion. This is when a result object is converted on the fly +to the type of an existing target object. Completion of this +support is pending further analysis of the ACPI specification +concerning this matter. + +CPU-specific code has been removed from the subsystem (hardware +directory). + +New Power Management Timer functions added + +Linux OS Services Layer (OSL): Moved system state transition code +to the core, fixed it, and modified Linux OSL accordingly. + +Fixed C2 and C3 latency calculations. + + +We no longer use the compilation date for the version message on +initialization, but retrieve the version from +AcpiGetSystemInfo(). + +Incorporated for fix Sony VAIO machines. + +Documentation: The Programmer Reference has been updated and +reformatted. + + +ASL Compiler: Version X2013: Fixed a problem where the line +numbering and error reporting could get out of sync in the +presence of multiple include files. + + ------------------------------------------ +Summary of changes for this label: 01_15_01 + +Core ACPI CA Subsystem: + +Implemented support for type conversions in the execution of the +ASL Concatenate operator (The second operand is converted to +match the type of the first operand before concatenation.) + +Support for implicit source operand conversion is partially +implemented. The ASL source operand types Integer, Buffer, and +String are freely interchangeable for most ASL operators and are +converted by the interpreter on the fly as required. Implicit +Target operand conversion (where the result is converted to the +target type before storing) is not yet implemented. + +Support for 32-bit and 64-bit BCD integers is implemented. + +Problem fixed where a field read on an aligned field could cause +a +read past the end of the field. + +New exception, AE_AML_NO_RETURN_VALUE, is returned when a method +does not return a value, but the caller expects one. (The ASL +compiler flags this as a warning.) + +ASL Compiler: + +Version X2011: +1. Static typechecking of all operands is implemented. This +prevents the use of invalid objects (such as using a Package +where +an Integer is required) at compile time instead of at interpreter +run-time. +2. The ASL source line is printed with ALL errors and warnings. +3. Bug fix for source EOF without final linefeed. +4. Debug option is split into a parse trace and a namespace +trace. +5. Namespace output option (-n) includes initial values for +integers and strings. +6. Parse-only option added for quick syntax checking. +7. Compiler checks for duplicate ACPI name declarations + +Version X2012: +1. Relaxed typechecking to allow interchangeability between +strings, integers, and buffers. These types are now converted by +the interpreter at runtime. +2. Compiler reports time taken by each internal subsystem in the +debug output file. + + + ------------------------------------------ +Summary of changes for this label: 12_14_00 + +ASL Compiler: + +This is the first official release of the compiler. Since the +compiler requires elements of the Core Subsystem, this label +synchronizes everything. + +------------------------------------------ +Summary of changes for this label: 12_08_00 + + +Fixed a problem where named references within the ASL definition +of both OperationRegions and CreateXXXFields did not work +properly. The symptom was an AE_AML_OPERAND_TYPE during +initialization of the region/field. This is similar (but not +related internally) to the problem that was fixed in the last +label. + +Implemented both 32-bit and 64-bit support for the BCD ASL +functions ToBCD and FromBCD. + +Updated all legal headers to include "2000" in the copyright +years. + + ------------------------------------------ +Summary of changes for this label: 12_01_00 + +Fixed a problem where method invocations within the ASL +definition +of both OperationRegions and CreateXXXFields did not work +properly. The symptom was an AE_AML_OPERAND_TYPE during +initialization of the region/field: + + nsinit-0209: AE_AML_OPERAND_TYPE while getting region arguments +[DEBG] ammonad-0284: Exec_monadic2_r/Not: bad operand(s) +(0x3005) + +Fixed a problem where operators with more than one nested +subexpression would fail. The symptoms were varied, by mostly +AE_AML_OPERAND_TYPE errors. This was actually a rather serious +problem that has gone unnoticed until now. + + Subtract (Add (1,2), Multiply (3,4)) + +Fixed a problem where AcpiGetHandle didn't quite get fixed in the +previous build (The prefix part of a relative path was handled +incorrectly). + +Fixed a problem where Operation Region initialization failed if +the operation region name was a "namepath" instead of a simple +"nameseg". Symptom was an AE_NO_OPERAND error. + +Fixed a problem where an assignment to a local variable via the +indirect RefOf mechanism only worked for the first such +assignment. Subsequent assignments were ignored. + + ------------------------------------------ +Summary of changes for this label: 11_15_00 + +ACPI 2.0 table support with backwards support for ACPI 1.0 and +the +0.71 extensions. Note: although we can read ACPI 2.0 BIOS +tables, +the AML interpreter does NOT have support for the new 2.0 ASL +grammar terms at this time. + +All ACPI hardware access is via the GAS structures in the ACPI +2.0 +FADT. + +All physical memory addresses across all platforms are now 64 +bits +wide. Logical address width remains dependent on the platform +(i.e., "void *"). + +AcpiOsMapMemory interface changed to a 64-bit physical address. + +The AML interpreter integer size is now 64 bits, as per the ACPI +2.0 specification. + +For backwards compatibility with ACPI 1.0, ACPI tables with a +revision number less than 2 use 32-bit integers only. + +Fixed a problem where the evaluation of OpRegion operands did not +always resolve them to numbers properly. + +------------------------------------------ +Summary of changes for this label: 10_20_00 + +Fix for CBN_._STA issue. This fix will allow correct access to +CBN_ OpRegions when the _STA returns 0x8. + +Support to convert ACPI constants (Ones, Zeros, One) to actual +values before a package object is returned + +Fix for method call as predicate to if/while construct causing +incorrect if/while behavior + +Fix for Else block package lengths sometimes calculated wrong (if +block > 63 bytes) + +Fix for Processor object length field, was always zero + +Table load abort if FACP sanity check fails + +Fix for problem with Scope(name) if name already exists + +Warning emitted if a named object referenced cannot be found +(resolved) during method execution. + + + + + +------------------------------------------ +Summary of changes for this label: 9_29_00 + +New table initialization interfaces: AcpiInitializeSubsystem no +longer has any parameters AcpiFindRootPointer - Find the RSDP (if +necessary) AcpiLoadTables (RSDP) - load all tables found at RSDP- +>RSDT Obsolete Interfaces AcpiLoadFirmwareTables - replaced by +AcpiLoadTables + +Note: These interface changes require changes to all existing +OSDs + +The PCI_Config default address space handler is always installed +at the root namespace object. + +------------------------------------------- +Summary of changes for this label: 09_15_00 + +The new initialization architecture is implemented. New +interfaces are: AcpiInitializeSubsystem (replaces AcpiInitialize) +AcpiEnableSubsystem Obsolete Interfaces: AcpiLoadNamespace + +(Namespace is automatically loaded when a table is loaded) + +The ACPI_OPERAND_OBJECT has been optimized to shrink its size +from +52 bytes to 32 bytes. There is usually one of these for every +namespace object, so the memory savings is significant. + +Implemented just-in-time evaluation of the CreateField operators. + +Bug fixes for IA-64 support have been integrated. + +Additional code review comments have been implemented + +The so-called "third pass parse" has been replaced by a final +walk +through the namespace to initialize all operation regions +(address +spaces) and fields that have not yet been initialized during the +execution of the various _INI and REG methods. + +New file - namespace/nsinit.c + +------------------------------------------- +Summary of changes for this label: 09_01_00 + +Namespace manager data structures have been reworked to change +the +primary object from a table to a single object. This has +resulted in dynamic memory savings of 3X within the namespace +and +2X overall in the ACPI CA subsystem. + +Fixed problem where the call to AcpiEvFindPciRootBuses was +inadvertently left commented out. + +Reduced the warning count when generating the source with the GCC +compiler. + +Revision numbers added to each module header showing the +SourceSafe version of the file. Please refer to this version +number when giving us feedback or comments on individual modules. + +The main object types within the subsystem have been renamed to +clarify their purpose: + +ACPI_INTERNAL_OBJECT -> ACPI_OPERAND_OBJECT +ACPI_GENERIC_OP -> ACPI_PARSE_OBJECT +ACPI_NAME_TABLE_ENTRY -> ACPI_NAMESPACE_NODE + +NOTE: no changes to the initialization sequence are included in +this label. + +------------------------------------------- +Summary of changes for this label: 08_23_00 + +Fixed problem where TerminateControlMethod was being called +multiple times per method + +Fixed debugger problem where single stepping caused a semaphore +to +be oversignalled + +Improved performance through additional parse object caching - +added ACPI_EXTENDED_OP type + +------------------------------------------- +Summary of changes for this label: 08_10_00 + +Parser/Interpreter integration: Eliminated the creation of +complete parse trees for ACPI tables and control methods. +Instead, parse subtrees are created and then deleted as soon as +they are processed (Either entered into the namespace or +executed +by the interpreter). This reduces the use of dynamic kernel +memory significantly. (about 10X) + +Exception codes broken into classes and renumbered. Be sure to +recompile all code that includes acexcep.h. Hopefully we won't +have to renumber the codes again now that they are split into +classes (environment, programmer, AML code, ACPI table, and +internal). + +Fixed some additional alignment issues in the Resource Manager +subcomponent + +Implemented semaphore tracking in the AcpiExec utility, and fixed +several places where mutexes/semaphores were being unlocked +without a corresponding lock operation. There are no known +semaphore or mutex "leaks" at this time. + +Fixed the case where an ASL Return operator is used to return an +unnamed package. + +------------------------------------------- +Summary of changes for this label: 07_28_00 + +Fixed a problem with the way addresses were calculated in +AcpiAmlReadFieldData() and AcpiAmlWriteFieldData(). This problem +manifested itself when a Field was created with WordAccess or +DwordAccess, but the field unit defined within the Field was +less + +than a Word or Dword. + +Fixed a problem in AmlDumpOperands() module's loop to pull +operands off of the operand stack to display information. The +problem manifested itself as a TLB error on 64-bit systems when +accessing an operand stack with two or more operands. + +Fixed a problem with the PCI configuration space handlers where +context was getting confused between accesses. This required a +change to the generic address space handler and address space +setup definitions. Handlers now get both a global handler +context +(this is the one passed in by the user when executing +AcpiInstallAddressSpaceHandler() and a specific region context +that is unique to each region (For example, the _ADR, _SEG and +_BBN values associated with a specific region). The generic +function definitions have changed to the following: + +typedef ACPI_STATUS (*ADDRESS_SPACE_HANDLER) ( UINT32 Function, +UINT32 Address, UINT32 BitWidth, UINT32 *Value, void +*HandlerContext, // This used to be void *Context void +*RegionContext); // This is an additional parameter + +typedef ACPI_STATUS (*ADDRESS_SPACE_SETUP) ( ACPI_HANDLE +RegionHandle, UINT32 Function, void *HandlerContext, void +**RegionContext); // This used to be **ReturnContext + +------------------------------------------- +Summary of changes for this label: 07_21_00 + +Major file consolidation and rename. All files within the +interpreter have been renamed as well as most header files. +This +was done to prevent collisions with existing files in the host +OSs -- filenames such as "config.h" and "global.h" seem to be +quite common. The VC project files have been updated. All +makefiles will require modification. + +The parser/interpreter integration continues in Phase 5 with the +implementation of a complete 2-pass parse (the AML is parsed +twice) for each table; This avoids the construction of a huge +parse tree and therefore reduces the amount of dynamic memory +required by the subsystem. Greater use of the parse object cache +means that performance is unaffected. + +Many comments from the two code reviews have been rolled in. + +The 64-bit alignment support is complete. + +------------------------------------------- +Summary of changes for this label: 06_30_00 + +With a nod and a tip of the hat to the technology of yesteryear, +we've added support in the source code for 80 column output +devices. The code is now mostly constrained to 80 columns or +less to support environments and editors that 1) cannot display +or print more than 80 characters on a single line, and 2) cannot +disable line wrapping. + +A major restructuring of the namespace data structure has been +completed. The result is 1) cleaner and more +understandable/maintainable code, and 2) a significant reduction +in the dynamic memory requirement for each named ACPI object +(almost half). + +------------------------------------------- +Summary of changes for this label: 06_23_00 + +Linux support has been added. In order to obtain approval to get +the ACPI CA subsystem into the Linux kernel, we've had to make +quite a few changes to the base subsystem that will affect all +users (all the changes are generic and OS- independent). The +effects of these global changes have been somewhat far reaching. +Files have been merged and/or renamed and interfaces have been +renamed. The major changes are described below. + +Osd* interfaces renamed to AcpiOs* to eliminate namespace +pollution/confusion within our target kernels. All OSD +interfaces must be modified to match the new naming convention. + +Files merged across the subsystem. A number of the smaller +source +and header files have been merged to reduce the file count and +increase the density of the existing files. There are too many +to list here. In general, makefiles that call out individual +files will require rebuilding. + +Interpreter files renamed. All interpreter files now have the +prefix am* instead of ie* and is*. + +Header files renamed: The acapi.h file is now acpixf.h. The +acpiosd.h file is now acpiosxf.h. We are removing references to +the acronym "API" since it is somewhat windowsy. The new name is +"external interface" or xface or xf in the filenames.j + + +All manifest constants have been forced to upper case (some were +mixed case.) Also, the string "ACPI_" has been prepended to +many +(not all) of the constants, typedefs, and structs. + +The globals "DebugLevel" and "DebugLayer" have been renamed +"AcpiDbgLevel" and "AcpiDbgLayer" respectively. + +All other globals within the subsystem are now prefixed with +"AcpiGbl_" Internal procedures within the subsystem are now +prefixed with "Acpi" (with only a few exceptions). The original +two-letter abbreviation for the subcomponent remains after +"Acpi" +- for example, CmCallocate became AcpiCmCallocate. + +Added a source code translation/conversion utility. Used to +generate the Linux source code, it can be modified to generate +other types of source as well. Can also be used to cleanup +existing source by removing extraneous spaces and blank lines. +Found in tools/acpisrc/* + +OsdUnMapMemory was renamed to OsdUnmapMemory and then +AcpiOsUnmapMemory. (UnMap became Unmap). + +A "MaxUnits" parameter has been added to AcpiOsCreateSemaphore. +When set to one, this indicates that the caller wants to use the + +semaphore as a mutex, not a counting semaphore. ACPI CA uses +both types. However, implementers of this call may want to use +different OS primitives depending on the type of semaphore +requested. For example, some operating systems provide separate + +"mutex" and "semaphore" interfaces - where the mutex interface +is +much faster because it doesn't have all the overhead of a full +semaphore implementation. + +Fixed a deadlock problem where a method that accesses the PCI +address space can block forever if it is the first access to the +space. + +------------------------------------------- +Summary of changes for this label: 06_02_00 + +Support for environments that cannot handle unaligned data +accesses (e.g. firmware and OS environments devoid of alignment +handler technology namely SAL/EFI and the IA-64 Linux kernel) +has +been added (via configurable macros) in these three areas: - +Transfer of data from the raw AML byte stream is done via byte +moves instead of word/dword/qword moves. - External objects +are +aligned within the user buffer, including package elements (sub- +objects). - Conversion of name strings to UINT32 Acpi Names is +now +done byte-wise. + +The Store operator was modified to mimic Microsoft's +implementation when storing to a Buffer Field. + +Added a check of the BM_STS bit before entering C3. + +The methods subdirectory has been obsoleted and removed. A new +file, cmeval.c subsumes the functionality. + +A 16-bit (DOS) version of AcpiExec has been developed. The +makefile is under the acpiexec directory. diff --git a/sys/dist/acpica/acapps.h b/sys/dist/acpica/acapps.h new file mode 100644 index 00000000000..e2d20b2b5aa --- /dev/null +++ b/sys/dist/acpica/acapps.h @@ -0,0 +1,243 @@ +/****************************************************************************** + * + * Module Name: acapps - common include for ACPI applications/tools + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _ACAPPS +#define _ACAPPS + + +#ifdef _MSC_VER /* disable some level-4 warnings */ +#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ +#endif + +#define FILE_SUFFIX_DISASSEMBLY "dsl" +#define ACPI_TABLE_FILE_SUFFIX ".dat" + +extern UINT8 *DsdtPtr; +extern UINT32 AcpiDsdtLength; +extern UINT8 *AmlStart; +extern UINT32 AmlLength; + + +extern int AcpiGbl_Optind; +extern char *AcpiGbl_Optarg; + +int +AcpiGetopt( + int argc, + char **argv, + char *opts); + +/* + * adisasm + */ +ACPI_STATUS +AdAmlDisassemble ( + BOOLEAN OutToFile, + char *Filename, + char *Prefix, + char **OutFilename, + BOOLEAN GetAllTables); + +void +AdPrintStatistics (void); + +ACPI_STATUS +AdFindDsdt( + UINT8 **DsdtPtr, + UINT32 *DsdtLength); + +void +AdDumpTables (void); + +ACPI_STATUS +AdGetLocalTables ( + char *Filename, + BOOLEAN GetAllTables); + +ACPI_STATUS +AdParseTable ( + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AdDisplayTables ( + char *Filename, + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AdDisplayStatistics (void); + +/* + * adwalk + */ +void +AcpiDmCrossReferenceNamespace ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot); + +void +AcpiDmDumpTree ( + ACPI_PARSE_OBJECT *Origin); + +void +AcpiDmFindOrphanMethods ( + ACPI_PARSE_OBJECT *Origin); + +void +AcpiDmFinishNamespaceLoad ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot); + +void +AcpiDmConvertResourceIndexes ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot); + +/* + * adfile + */ +ACPI_STATUS +AdInitialize ( + void); + +char * +FlGenerateFilename ( + char *InputFilename, + char *Suffix); + +ACPI_STATUS +FlSplitInputPathname ( + char *InputPath, + char **OutDirectoryPath, + char **OutFilename); + +char * +FlGenerateFilename ( + char *InputFilename, + char *Suffix); + +char * +AdGenerateFilename ( + char *Prefix, + char *TableId); + +void +AdWriteTable ( + ACPI_TABLE_HEADER *Table, + UINT32 Length, + char *TableName, + char *OemTableId); + +#endif /* _ACAPPS */ + diff --git a/sys/dist/acpica/acconfig.h b/sys/dist/acpica/acconfig.h index 42e4517b2e4..27f442c2ee7 100644 --- a/sys/dist/acpica/acconfig.h +++ b/sys/dist/acpica/acconfig.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acconfig.h - Global configuration constants - * xRevision: 1.207 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -137,7 +137,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20060217 +#define ACPI_CA_VERSION 0x20070320 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, @@ -155,6 +155,7 @@ #define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ #define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */ #define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ +#define ACPI_MAX_NAMESPACE_CACHE_DEPTH 96 /* Namespace objects */ /* * Should the subsystem abort the loading of an ACPI table if the @@ -177,9 +178,9 @@ #define ACPI_MAX_SEMAPHORE_COUNT 256 -/* Max reference count (for debug only) */ +/* Maximum object reference count (detects object deletion issues) */ -#define ACPI_MAX_REFERENCE_COUNT 0x400 +#define ACPI_MAX_REFERENCE_COUNT 0x800 /* Size of cached memory mapping for system memory operation region */ @@ -189,6 +190,10 @@ #define ACPI_NUM_OWNERID_MASKS 8 +/* Size of the root table array is increased by this increment */ + +#define ACPI_ROOT_TABLE_SIZE_INCREMENT 4 + /****************************************************************************** * @@ -221,12 +226,28 @@ #define ACPI_OBJ_NUM_OPERANDS 8 #define ACPI_OBJ_MAX_OPERAND 7 +/* Number of elements in the Result Stack frame, can be an arbitrary value */ + +#define ACPI_RESULTS_FRAME_OBJ_NUM 8 + +/* + * Maximal number of elements the Result Stack can contain, + * it may be an arbitray value not exceeding the types of + * ResultSize and ResultCount (now UINT8). + */ +#define ACPI_RESULTS_OBJ_NUM_MAX 255 + /* Names within the namespace are 4 bytes long */ #define ACPI_NAME_SIZE 4 #define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ #define ACPI_PATH_SEPARATOR '.' +/* Sizes for ACPI table headers */ + +#define ACPI_OEM_ID_SIZE 6 +#define ACPI_OEM_TABLE_ID_SIZE 8 + /* Constants used in searching for the RSDP in low memory */ #define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ @@ -247,12 +268,7 @@ /* Array sizes. Used for range checking also */ -#define ACPI_NUM_ACCESS_TYPES 6 -#define ACPI_NUM_UPDATE_RULES 3 -#define ACPI_NUM_LOCK_RULES 2 -#define ACPI_NUM_MATCH_OPS 6 -#define ACPI_NUM_OPCODES 256 -#define ACPI_NUM_FIELD_NAMES 2 +#define ACPI_MAX_MATCH_OPCODE 5 /* RSDP checksums */ @@ -265,7 +281,7 @@ /* Number of strings associated with the _OSI reserved method */ -#define ACPI_NUM_OSI_STRINGS 10 +#define ACPI_NUM_OSI_STRINGS 12 /****************************************************************************** diff --git a/sys/dist/acpica/acdebug.h b/sys/dist/acpica/acdebug.h index c4fa312e473..67b9c3e0046 100644 --- a/sys/dist/acpica/acdebug.h +++ b/sys/dist/acpica/acdebug.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdebug.h - ACPI/AML debugger - * xRevision: 1.81 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -323,6 +323,12 @@ AcpiDbCreateExecutionThreads ( char *NumLoopsArg, char *MethodNameArg); +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +UINT32 +AcpiDbGetCacheInfo ( + ACPI_MEMORY_LIST *Cache); +#endif + /* * dbfileio - Debugger file I/O commands @@ -423,4 +429,9 @@ ACPI_NAMESPACE_NODE * AcpiDbLocalNsLookup ( char *Name); +void +AcpiDbUInt32ToHexString ( + UINT32 Value, + char *Buffer); + #endif /* __ACDEBUG_H__ */ diff --git a/sys/dist/acpica/acdisasm.h b/sys/dist/acpica/acdisasm.h index c685b5a6275..692094c7033 100644 --- a/sys/dist/acpica/acdisasm.h +++ b/sys/dist/acpica/acdisasm.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdisasm.h - AML disassembler - * xRevision: 1.28 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -117,36 +117,88 @@ #ifndef __ACDISASM_H__ #define __ACDISASM_H__ -#include "amlresrc.h" +#include <dist/acpica/amlresrc.h> #define BLOCK_NONE 0 #define BLOCK_PAREN 1 #define BLOCK_BRACE 2 #define BLOCK_COMMA_LIST 4 +#define ACPI_DEFAULT_RESNAME *(const UINT32 *) "__RD" typedef struct acpi_external_list { char *Path; + char *InternalPath; struct acpi_external_list *Next; + UINT32 Value; + UINT16 Length; + UINT8 Type; } ACPI_EXTERNAL_LIST; extern ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList; -/* Strings used for decoding flags to ASL keywords */ +typedef const struct acpi_dmtable_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + +} ACPI_DMTABLE_INFO; -extern const char *AcpiGbl_WordDecode[4]; -extern const char *AcpiGbl_IrqDecode[2]; -extern const char *AcpiGbl_LockRule[ACPI_NUM_LOCK_RULES]; -extern const char *AcpiGbl_AccessTypes[ACPI_NUM_ACCESS_TYPES]; -extern const char *AcpiGbl_UpdateRules[ACPI_NUM_UPDATE_RULES]; -extern const char *AcpiGbl_MatchOps[ACPI_NUM_MATCH_OPS]; +/* + * Values for Opcode above. + * Note: 0-7 must not change, used as a flag shift value + */ +#define ACPI_DMT_FLAG0 0 +#define ACPI_DMT_FLAG1 1 +#define ACPI_DMT_FLAG2 2 +#define ACPI_DMT_FLAG3 3 +#define ACPI_DMT_FLAG4 4 +#define ACPI_DMT_FLAG5 5 +#define ACPI_DMT_FLAG6 6 +#define ACPI_DMT_FLAG7 7 +#define ACPI_DMT_FLAGS0 8 +#define ACPI_DMT_FLAGS2 9 +#define ACPI_DMT_UINT8 10 +#define ACPI_DMT_UINT16 11 +#define ACPI_DMT_UINT24 12 +#define ACPI_DMT_UINT32 13 +#define ACPI_DMT_UINT56 14 +#define ACPI_DMT_UINT64 15 +#define ACPI_DMT_STRING 16 +#define ACPI_DMT_NAME4 17 +#define ACPI_DMT_NAME6 18 +#define ACPI_DMT_NAME8 19 +#define ACPI_DMT_CHKSUM 20 +#define ACPI_DMT_SPACEID 21 +#define ACPI_DMT_GAS 22 +#define ACPI_DMT_DMAR 23 +#define ACPI_DMT_MADT 24 +#define ACPI_DMT_SRAT 25 +#define ACPI_DMT_EXIT 26 +#define ACPI_DMT_SIG 27 + +typedef +void (*ACPI_TABLE_HANDLER) ( + ACPI_TABLE_HEADER *Table); + +typedef struct acpi_dmtable_data +{ + char *Signature; + ACPI_DMTABLE_INFO *TableInfo; + ACPI_TABLE_HANDLER TableHandler; + char *Name; + +} ACPI_DMTABLE_DATA; typedef struct acpi_op_walk_info { UINT32 Level; + UINT32 LastLevel; + UINT32 Count; UINT32 BitOffset; UINT32 Flags; ACPI_WALK_STATE *WalkState; @@ -159,6 +211,148 @@ ACPI_STATUS (*ASL_WALK_CALLBACK) ( UINT32 Level, void *Context); +typedef struct acpi_resource_tag +{ + UINT32 BitIndex; + char *Tag; + +} ACPI_RESOURCE_TAG; + +/* Strings used for decoding flags to ASL keywords */ + +extern const char *AcpiGbl_WordDecode[]; +extern const char *AcpiGbl_IrqDecode[]; +extern const char *AcpiGbl_LockRule[]; +extern const char *AcpiGbl_AccessTypes[]; +extern const char *AcpiGbl_UpdateRules[]; +extern const char *AcpiGbl_MatchOps[]; + +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsfHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoBoot[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCpep[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCpep0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbgp[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarScope[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGas[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt5[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt6[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt7[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt8[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSbst[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlit[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[]; + + +/* + * dmtable + */ +void +AcpiDmDumpDataTable ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpTable ( + UINT32 TableLength, + UINT32 TableOffset, + void *Table, + UINT32 SubTableLength, + ACPI_DMTABLE_INFO *Info); + +void +AcpiDmLineHeader ( + UINT32 Offset, + UINT32 ByteLength, + char *Name); + +void +AcpiDmLineHeader2 ( + UINT32 Offset, + UINT32 ByteLength, + char *Name, + UINT32 Value); + + +/* + * dmtbdump + */ +void +AcpiDmDumpAsf ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpCpep ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpDmar ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpFadt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpSrat ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMcfg ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMadt ( + ACPI_TABLE_HEADER *Table); + +UINT32 +AcpiDmDumpRsdp ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpRsdt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpSlit ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpXsdt ( + ACPI_TABLE_HEADER *Table); + /* * dmwalk @@ -169,6 +363,13 @@ AcpiDmDisassemble ( ACPI_PARSE_OBJECT *Origin, UINT32 NumOpcodes); +void +AcpiDmWalkParseTree ( + ACPI_PARSE_OBJECT *Op, + ASL_WALK_CALLBACK DescendingCallback, + ASL_WALK_CALLBACK AscendingCallback, + void *Context); + /* * dmopcode @@ -313,10 +514,11 @@ AcpiDmDumpInteger64 ( void AcpiDmResourceTemplate ( ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op, UINT8 *ByteData, UINT32 ByteCount); -BOOLEAN +ACPI_STATUS AcpiDmIsResourceTemplate ( ACPI_PARSE_OBJECT *Op); @@ -332,6 +534,10 @@ void AcpiDmDecodeAttribute ( UINT8 Attribute); +void +AcpiDmDescriptorName ( + void); + /* * dmresrcl @@ -455,6 +661,20 @@ AcpiDmVendorSmallDescriptor ( */ void AcpiDmAddToExternalList ( - char *Path); + char *Path, + UINT8 Type, + UINT32 Value); + +/* + * dmrestag + */ +void +AcpiDmFindResources ( + ACPI_PARSE_OBJECT *Root); + +void +AcpiDmCheckResourceReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); #endif /* __ACDISASM_H__ */ diff --git a/sys/dist/acpica/acdispat.h b/sys/dist/acpica/acdispat.h index 0d1e2837ebd..a6dfbaa0a1e 100644 --- a/sys/dist/acpica/acdispat.h +++ b/sys/dist/acpica/acdispat.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdispat.h - dispatcher (parser to interpreter interface) - * xRevision: 1.69 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -324,13 +324,14 @@ AcpiDsRestartControlMethod ( void AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsBeginMethodExecution ( ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_NAMESPACE_NODE *CallingMethodNode); + ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsMethodError ( @@ -342,7 +343,7 @@ AcpiDsMethodError ( */ ACPI_STATUS AcpiDsInitializeObjects ( - ACPI_TABLE_DESC *TableDesc, + ACPI_NATIVE_UINT TableIndex, ACPI_NAMESPACE_NODE *StartNode); @@ -420,6 +421,10 @@ void AcpiDsClearOperands ( ACPI_WALK_STATE *WalkState); +ACPI_STATUS +AcpiDsEvaluateNamePath ( + ACPI_WALK_STATE *WalkState); + /* * dswscope - Scope Stack manipulation @@ -467,10 +472,10 @@ AcpiDsInitAmlWalk ( ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, - ACPI_PARAMETER_INFO *Info, + ACPI_EVALUATE_INFO *Info, UINT8 PassNumber); -ACPI_STATUS +void AcpiDsObjStackPopAndDelete ( UINT32 PopCount, ACPI_WALK_STATE *WalkState); @@ -489,14 +494,6 @@ AcpiDsPushWalkState ( ACPI_THREAD_STATE *Thread); ACPI_STATUS -AcpiDsResultStackPop ( - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiDsResultStackPush ( - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS AcpiDsResultStackClear ( ACPI_WALK_STATE *WalkState); @@ -505,12 +502,6 @@ AcpiDsGetCurrentWalkState ( ACPI_THREAD_STATE *Thread); ACPI_STATUS -AcpiDsResultRemove ( - ACPI_OPERAND_OBJECT **Object, - UINT32 Index, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS AcpiDsResultPop ( ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState); @@ -520,9 +511,4 @@ AcpiDsResultPush ( ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState); -ACPI_STATUS -AcpiDsResultPopFromBottom ( - ACPI_OPERAND_OBJECT **Object, - ACPI_WALK_STATE *WalkState); - #endif /* _ACDISPAT_H_ */ diff --git a/sys/dist/acpica/acefi.h b/sys/dist/acpica/acefi.h new file mode 100644 index 00000000000..664ed584153 --- /dev/null +++ b/sys/dist/acpica/acefi.h @@ -0,0 +1,148 @@ +/****************************************************************************** + * + * Name: acefi.h - OS specific defines, etc. + * $Revision: 1.2 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACEFI_H__ +#define __ACEFI_H__ + +#include <efi.h> +#include <efistdarg.h> +#include <efilib.h> + + +/* _int64 works for both IA32 and IA64 */ + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +/* warn C4142: redefinition of type */ + +#pragma warning(disable:4142) + + +#endif /* __ACEFI_H__ */ diff --git a/sys/dist/acpica/acenv.h b/sys/dist/acpica/acenv.h index a55999efce6..a5888666bbc 100644 --- a/sys/dist/acpica/acenv.h +++ b/sys/dist/acpica/acenv.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acenv.h - Generation environment specific items - * xRevision: 1.122 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -123,33 +123,41 @@ */ #ifdef ACPI_LIBRARY +/* + * Note: The non-debug version of the AcpiLibrary does not contain any + * debug support, for minimimal size. The debug version uses ACPI_FULL_DEBUG + */ #define ACPI_USE_LOCAL_CACHE #endif -#ifdef ACPI_DUMP_APP -#ifndef MSDOS +#ifdef ACPI_ASL_COMPILER #define ACPI_DEBUG_OUTPUT -#endif #define ACPI_APPLICATION #define ACPI_DISASSEMBLER -#define ACPI_NO_METHOD_EXECUTION +#define ACPI_CONSTANT_EVAL_ONLY +#define ACPI_LARGE_NAMESPACE_NODE +#define ACPI_DATA_TABLE_DISASSEMBLY #endif #ifdef ACPI_EXEC_APP #undef DEBUGGER_THREADING #define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED -#define ACPI_DEBUG_OUTPUT +#define ACPI_FULL_DEBUG #define ACPI_APPLICATION #define ACPI_DEBUGGER -#define ACPI_DISASSEMBLER #define ACPI_MUTEX_DEBUG +#define ACPI_DBG_TRACK_ALLOCATIONS #endif -#ifdef ACPI_ASL_COMPILER +#ifdef ACPI_DASM_APP +#ifndef MSDOS #define ACPI_DEBUG_OUTPUT +#endif #define ACPI_APPLICATION #define ACPI_DISASSEMBLER -#define ACPI_CONSTANT_EVAL_ONLY +#define ACPI_NO_METHOD_EXECUTION +#define ACPI_LARGE_NAMESPACE_NODE +#define ACPI_DATA_TABLE_DISASSEMBLY #endif #ifdef ACPI_APPLICATION @@ -157,6 +165,13 @@ #define ACPI_USE_LOCAL_CACHE #endif +#ifdef ACPI_FULL_DEBUG +#define ACPI_DEBUGGER +#define ACPI_DEBUG_OUTPUT +#define ACPI_DISASSEMBLER +#endif + + /* * Environment configuration. The purpose of this file is to interface to the * local generation environment. @@ -211,8 +226,8 @@ #elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */ #include "acdos16.h" -#elif defined(__FreeBSD__) -#include "acfreebsd.h" +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include <dist/acpica/acfreebsd.h> #elif defined(__NetBSD__) #include "acnetbsd.h" @@ -237,17 +252,6 @@ #endif -/* - * Memory allocation tracking. Used only if - * 1) This is the debug version - * 2) This is NOT a 16-bit version of the code (not enough real-mode memory) - */ -#ifdef ACPI_DEBUG_OUTPUT -#if ACPI_MACHINE_WIDTH != 16 -#define ACPI_DBG_TRACK_ALLOCATIONS -#endif -#endif - /*! [End] no source code translation !*/ diff --git a/sys/dist/acpica/acevents.h b/sys/dist/acpica/acevents.h index 518a952d3ed..a78b248af6b 100644 --- a/sys/dist/acpica/acevents.h +++ b/sys/dist/acpica/acevents.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acevents.h - Event subcomponent prototypes and defines - * xRevision: 1.105 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -264,7 +264,7 @@ AcpiEvAddressSpaceDispatch ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - void *Value); + ACPI_INTEGER *Value); ACPI_STATUS AcpiEvAttachRegion ( diff --git a/sys/dist/acpica/acexcep.h b/sys/dist/acpica/acexcep.h index 01fcdb6e93e..06f28ee9f42 100644 --- a/sys/dist/acpica/acexcep.h +++ b/sys/dist/acpica/acexcep.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acexcep.h - Exception codes returned by the ACPI subsystem - * xRevision: 1.76 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -239,8 +239,9 @@ #define AE_AML_BAD_RESOURCE_VALUE (ACPI_STATUS) (0x001F | AE_CODE_AML) #define AE_AML_CIRCULAR_REFERENCE (ACPI_STATUS) (0x0020 | AE_CODE_AML) #define AE_AML_BAD_RESOURCE_LENGTH (ACPI_STATUS) (0x0021 | AE_CODE_AML) +#define AE_AML_ILLEGAL_ADDRESS (ACPI_STATUS) (0x0022 | AE_CODE_AML) -#define AE_CODE_AML_MAX 0x0021 +#define AE_CODE_AML_MAX 0x0022 /* @@ -257,8 +258,10 @@ #define AE_CTRL_BREAK (ACPI_STATUS) (0x0009 | AE_CODE_CONTROL) #define AE_CTRL_CONTINUE (ACPI_STATUS) (0x000A | AE_CODE_CONTROL) #define AE_CTRL_SKIP (ACPI_STATUS) (0x000B | AE_CODE_CONTROL) +#define AE_CTRL_PARSE_CONTINUE (ACPI_STATUS) (0x000C | AE_CODE_CONTROL) +#define AE_CTRL_PARSE_PENDING (ACPI_STATUS) (0x000D | AE_CODE_CONTROL) -#define AE_CODE_CTRL_MAX 0x000B +#define AE_CODE_CTRL_MAX 0x000D #ifdef DEFINE_ACPI_GLOBALS @@ -361,7 +364,8 @@ char const *AcpiGbl_ExceptionNames_Aml[] = "AE_AML_NO_RESOURCE_END_TAG", "AE_AML_BAD_RESOURCE_VALUE", "AE_AML_CIRCULAR_REFERENCE", - "AE_AML_BAD_RESOURCE_LENGTH" + "AE_AML_BAD_RESOURCE_LENGTH", + "AE_AML_ILLEGAL_ADDRESS" }; char const *AcpiGbl_ExceptionNames_Ctrl[] = @@ -376,7 +380,9 @@ char const *AcpiGbl_ExceptionNames_Ctrl[] = "AE_CTRL_TRANSFER", "AE_CTRL_BREAK", "AE_CTRL_CONTINUE", - "AE_CTRL_SKIP" + "AE_CTRL_SKIP", + "AE_CTRL_PARSE_CONTINUE", + "AE_CTRL_PARSE_PENDING" }; #endif /* ACPI GLOBALS */ diff --git a/sys/dist/acpica/acgcc.h b/sys/dist/acpica/acgcc.h index ebb1e16276e..48c528a7c18 100644 --- a/sys/dist/acpica/acgcc.h +++ b/sys/dist/acpica/acgcc.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acgcc.h - GCC specific defines, etc. - * xRevision: 1.31 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/dist/acpica/acglobal.h b/sys/dist/acpica/acglobal.h index 05d20013961..076256bf12c 100644 --- a/sys/dist/acpica/acglobal.h +++ b/sys/dist/acpica/acglobal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acglobal.h - Declarations for global variables - * xRevision: 1.175 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -132,37 +132,6 @@ #define ACPI_INIT_GLOBAL(a,b) a #endif -/* - * Keep local copies of these FADT-based registers. NOTE: These globals - * are first in this file for alignment reasons on 64-bit systems. - */ -ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; -ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; - - -/***************************************************************************** - * - * Debug support - * - ****************************************************************************/ - -/* Runtime configuration of debug print levels */ - -extern UINT32 AcpiDbgLevel; -extern UINT32 AcpiDbgLayer; - -/* Procedure nesting level for debug output */ - -extern UINT32 AcpiGbl_NestingLevel; - -/* Support for dynamic control method tracing mechanism */ - -ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLevel; -ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLayer; -ACPI_EXTERN ACPI_NAME AcpiGbl_TraceMethodName; -ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLevel; -ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; -ACPI_EXTERN UINT32 AcpiGbl_TraceFlags; /***************************************************************************** * @@ -182,13 +151,9 @@ ACPI_EXTERN UINT32 AcpiGbl_TraceFlags; * 3) Allow access to uninitialized locals/args (auto-init to integer 0) * 4) Allow ANY object type to be a source operand for the Store() operator * 5) Allow unresolved references (invalid target name) in package objects + * 6) Enable warning messages for behavior that is not ACPI spec compliant */ -#ifdef ACPICA_PEDANTIC ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); -#else -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, TRUE); -#endif - /* * Automatically serialize ALL control methods? Default is FALSE, meaning @@ -220,55 +185,58 @@ ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE); ****************************************************************************/ /* - * Table pointers. - * Although these pointers are somewhat redundant with the global AcpiTable, - * they are convenient because they are typed pointers. + * AcpiGbl_RootTableList is the master list of ACPI tables found in the + * RSDT/XSDT. * - * These tables are single-table only; meaning that there can be at most one - * of each in the system. Each global points to the actual table. - */ -ACPI_EXTERN UINT32 AcpiGbl_TableFlags; -ACPI_EXTERN UINT32 AcpiGbl_RsdtTableCount; -ACPI_EXTERN RSDP_DESCRIPTOR *AcpiGbl_RSDP; -ACPI_EXTERN XSDT_DESCRIPTOR *AcpiGbl_XSDT; -ACPI_EXTERN FADT_DESCRIPTOR *AcpiGbl_FADT; -ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DSDT; -ACPI_EXTERN FACS_DESCRIPTOR *AcpiGbl_FACS; -ACPI_EXTERN ACPI_COMMON_FACS AcpiGbl_CommonFACS; -/* - * Since there may be multiple SSDTs and PSDTs, a single pointer is not - * sufficient; Therefore, there isn't one! + * AcpiGbl_FADT is a local copy of the FADT, converted to a common format. */ +ACPI_EXTERN ACPI_INTERNAL_RSDT AcpiGbl_RootTableList; +ACPI_EXTERN ACPI_TABLE_FADT AcpiGbl_FADT; +/* These addresses are calculated from FADT address values */ -/* The root table can be either an RSDT or an XSDT */ - -ACPI_EXTERN UINT8 AcpiGbl_RootTableType; -#define ACPI_TABLE_TYPE_RSDT 'R' -#define ACPI_TABLE_TYPE_XSDT 'X' - +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; /* - * Handle both ACPI 1.0 and ACPI 2.0 Integer widths: - * If we are executing a method that exists in a 32-bit ACPI table, - * use only the lower 32 bits of the (internal) 64-bit Integer. + * Handle both ACPI 1.0 and ACPI 2.0 Integer widths. The integer width is + * determined by the revision of the DSDT: If the DSDT revision is less than + * 2, use only the lower 32 bits of the internal 64-bit Integer. */ ACPI_EXTERN UINT8 AcpiGbl_IntegerBitWidth; ACPI_EXTERN UINT8 AcpiGbl_IntegerByteWidth; ACPI_EXTERN UINT8 AcpiGbl_IntegerNybbleWidth; -/* - * ACPI Table info arrays - */ -extern ACPI_TABLE_LIST AcpiGbl_TableLists[NUM_ACPI_TABLE_TYPES]; -extern ACPI_TABLE_SUPPORT AcpiGbl_TableData[NUM_ACPI_TABLE_TYPES]; + +/***************************************************************************** + * + * Mutual exlusion within ACPICA subsystem + * + ****************************************************************************/ /* - * Predefined mutex objects. This array contains the + * Predefined mutex objects. This array contains the * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. * (The table maps local handles to the real OS handles) */ -ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[NUM_MUTEX]; +ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[ACPI_NUM_MUTEX]; + +/* + * Global lock mutex is an actual AML mutex object + * Global lock semaphore works in conjunction with the HW global lock + */ +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_GlobalLockMutex; +ACPI_EXTERN ACPI_SEMAPHORE AcpiGbl_GlobalLockSemaphore; +ACPI_EXTERN UINT16 AcpiGbl_GlobalLockHandle; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockAcquired; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; + +/* + * Spinlocks are used for interfaces that can be possibly called at + * interrupt level + */ +ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_GpeLock; /* For GPE data structs and registers */ +ACPI_EXTERN ACPI_SPINLOCK AcpiGbl_HardwareLock; /* For ACPI H/W except GPE registers */ /***************************************************************************** @@ -277,16 +245,9 @@ ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[NUM_MUTEX]; * ****************************************************************************/ -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - -/* Lists for tracking memory allocations */ - -ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_GlobalList; -ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_NsNodeList; -#endif - /* Object caches */ +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_NamespaceCache; ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_StateCache; ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeCache; ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeExtCache; @@ -299,36 +260,56 @@ ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_SystemNotify; ACPI_EXTERN ACPI_EXCEPTION_HANDLER AcpiGbl_ExceptionHandler; ACPI_EXTERN ACPI_INIT_HANDLER AcpiGbl_InitHandler; ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; -ACPI_EXTERN ACPI_HANDLE AcpiGbl_GlobalLockSemaphore; + +/* Owner ID support */ + +ACPI_EXTERN UINT32 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS]; +ACPI_EXTERN UINT8 AcpiGbl_LastOwnerIdIndex; +ACPI_EXTERN UINT8 AcpiGbl_NextOwnerIdOffset; /* Misc */ -ACPI_EXTERN UINT32 AcpiGbl_GlobalLockThreadCount; ACPI_EXTERN UINT32 AcpiGbl_OriginalMode; ACPI_EXTERN UINT32 AcpiGbl_RsdpOriginalLocation; ACPI_EXTERN UINT32 AcpiGbl_NsLookupCount; ACPI_EXTERN UINT32 AcpiGbl_PsFindCount; -ACPI_EXTERN UINT32 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS]; ACPI_EXTERN UINT16 AcpiGbl_Pm1EnableRegisterSave; -ACPI_EXTERN UINT16 AcpiGbl_GlobalLockHandle; -ACPI_EXTERN UINT8 AcpiGbl_LastOwnerIdIndex; -ACPI_EXTERN UINT8 AcpiGbl_NextOwnerIdOffset; ACPI_EXTERN UINT8 AcpiGbl_DebuggerConfiguration; -ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockAcquired; ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; -ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; ACPI_EXTERN BOOLEAN AcpiGbl_EventsInitialized; ACPI_EXTERN BOOLEAN AcpiGbl_SystemAwakeAndRunning; + +#ifndef DEFINE_ACPI_GLOBALS + +/* Exception codes */ + +extern char const *AcpiGbl_ExceptionNames_Env[]; +extern char const *AcpiGbl_ExceptionNames_Pgm[]; +extern char const *AcpiGbl_ExceptionNames_Tbl[]; +extern char const *AcpiGbl_ExceptionNames_Aml[]; +extern char const *AcpiGbl_ExceptionNames_Ctrl[]; + +/* Other miscellaneous */ + extern BOOLEAN AcpiGbl_Shutdown; extern UINT32 AcpiGbl_StartupFlags; -extern const UINT8 AcpiGbl_DecodeTo8bit[8]; extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]; extern const char *AcpiGbl_HighestDstateNames[4]; extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; -extern const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS]; +#endif + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +/* Lists for tracking memory allocations */ + +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_GlobalList; +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_NsNodeList; +ACPI_EXTERN BOOLEAN AcpiGbl_DisplayFinalMemStats; +#endif /***************************************************************************** @@ -378,15 +359,6 @@ ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; /***************************************************************************** * - * Parser globals - * - ****************************************************************************/ - -ACPI_EXTERN ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot; - - -/***************************************************************************** - * * Hardware globals * ****************************************************************************/ @@ -406,7 +378,35 @@ extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EV ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]; ACPI_EXTERN ACPI_GPE_XRUPT_INFO *AcpiGbl_GpeXruptListHead; ACPI_EXTERN ACPI_GPE_BLOCK_INFO *AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCKS]; -ACPI_EXTERN ACPI_HANDLE AcpiGbl_GpeLock; + + +/***************************************************************************** + * + * Debug support + * + ****************************************************************************/ + +/* Runtime configuration of debug print levels */ + +extern UINT32 AcpiDbgLevel; +extern UINT32 AcpiDbgLayer; + +/* Procedure nesting level for debug output */ + +extern UINT32 AcpiGbl_NestingLevel; + +/* Event counters */ + +ACPI_EXTERN UINT32 AcpiGpeCount; + +/* Support for dynamic control method tracing mechanism */ + +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLayer; +ACPI_EXTERN ACPI_NAME AcpiGbl_TraceMethodName; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; +ACPI_EXTERN UINT32 AcpiGbl_TraceFlags; /***************************************************************************** diff --git a/sys/dist/acpica/achware.h b/sys/dist/acpica/achware.h index d37cff264af..446ab559d27 100644 --- a/sys/dist/acpica/achware.h +++ b/sys/dist/acpica/achware.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: achware.h -- hardware specific interfaces - * xRevision: 1.80 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -138,10 +138,6 @@ * hwacpi - high level functions */ ACPI_STATUS -AcpiHwInitialize ( - void); - -ACPI_STATUS AcpiHwSetMode ( UINT32 Mode); @@ -183,7 +179,7 @@ AcpiHwLowLevelWrite ( ACPI_STATUS AcpiHwClearAcpiStatus ( - UINT32 Flags); + void); /* diff --git a/sys/dist/acpica/acinterp.h b/sys/dist/acpica/acinterp.h index 2e611c8e879..0132f78dfa3 100644 --- a/sys/dist/acpica/acinterp.h +++ b/sys/dist/acpica/acinterp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acinterp.h - Interpreter subcomponent prototypes and defines - * xRevision: 1.164 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -127,10 +127,14 @@ #define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_EXDUMP_INFO)) /* - * If possible, pack the following structure to byte alignment, since we - * don't care about performance for debug output + * If possible, pack the following structures to byte alignment, since we + * don't care about performance for debug output. Two cases where we cannot + * pack the structures: + * + * 1) Hardware does not support misaligned memory transfers + * 2) Compiler does not support pointers within packed structures */ -#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) #pragma pack(1) #endif @@ -377,10 +381,20 @@ AcpiExAcquireMutex ( ACPI_WALK_STATE *WalkState); ACPI_STATUS +AcpiExAcquireMutexObject ( + UINT16 Timeout, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_ID ThreadId); + +ACPI_STATUS AcpiExReleaseMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState); +ACPI_STATUS +AcpiExReleaseMutexObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + void AcpiExReleaseAllMutexes ( ACPI_THREAD_STATE *Thread); @@ -423,15 +437,6 @@ AcpiExSystemDoStall ( UINT32 Time); ACPI_STATUS -AcpiExSystemAcquireMutex( - ACPI_OPERAND_OBJECT *Time, - ACPI_OPERAND_OBJECT *ObjDesc); - -ACPI_STATUS -AcpiExSystemReleaseMutex( - ACPI_OPERAND_OBJECT *ObjDesc); - -ACPI_STATUS AcpiExSystemSignalEvent( ACPI_OPERAND_OBJECT *ObjDesc); @@ -446,9 +451,13 @@ AcpiExSystemResetEvent( ACPI_STATUS AcpiExSystemWaitSemaphore ( - ACPI_HANDLE Semaphore, + ACPI_SEMAPHORE Semaphore, UINT16 Timeout); +ACPI_STATUS +AcpiExSystemWaitMutex ( + ACPI_MUTEX Mutex, + UINT16 Timeout); /* * exoparg1 - ACPI AML execution, 1 operand @@ -666,7 +675,7 @@ AcpiExCopyIntegerToBufferField ( /* * exutils - interpreter/scanner utilities */ -ACPI_STATUS +void AcpiExEnterInterpreter ( void); @@ -675,16 +684,24 @@ AcpiExExitInterpreter ( void); void +AcpiExReacquireInterpreter ( + void); + +void +AcpiExRelinquishInterpreter ( + void); + +void AcpiExTruncateFor32bitTable ( ACPI_OPERAND_OBJECT *ObjDesc); -BOOLEAN +void AcpiExAcquireGlobalLock ( UINT32 Rule); void AcpiExReleaseGlobalLock ( - BOOLEAN Locked); + UINT32 Rule); void AcpiExEisaIdToString ( diff --git a/sys/dist/acpica/aclocal.h b/sys/dist/acpica/aclocal.h index a35baaf5376..c695f738bb6 100644 --- a/sys/dist/acpica/aclocal.h +++ b/sys/dist/acpica/aclocal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: aclocal.h - Internal data types used across the ACPI subsystem - * xRevision: 1.220 $ + * $Revision: 1.3 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -117,12 +117,14 @@ #ifndef __ACLOCAL_H__ #define __ACLOCAL_H__ +/* acpisrc:StructDefs -- for acpisrc conversion */ #define ACPI_WAIT_FOREVER 0xFFFF /* UINT16, as per ACPI spec */ +#define ACPI_DO_NOT_WAIT 0 +#define ACPI_SERIALIZED 0xFF -typedef void * ACPI_MUTEX; typedef UINT32 ACPI_MUTEX_HANDLE; - +#define ACPI_GLOBAL_LOCK (ACPI_SEMAPHORE) (-1) /* Total number of aml opcodes defined */ @@ -147,55 +149,56 @@ union acpi_parse_object; * Predefined handles for the mutex objects used within the subsystem * All mutex objects are automatically created by AcpiUtMutexInitialize. * - * The acquire/release ordering protocol is implied via this list. Mutexes + * The acquire/release ordering protocol is implied via this list. Mutexes * with a lower value must be acquired before mutexes with a higher value. * - * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames table also! + * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames + * table below also! */ -#define ACPI_MTX_EXECUTE 0 -#define ACPI_MTX_INTERPRETER 1 -#define ACPI_MTX_PARSER 2 -#define ACPI_MTX_DISPATCHER 3 -#define ACPI_MTX_TABLES 4 -#define ACPI_MTX_OP_REGIONS 5 -#define ACPI_MTX_NAMESPACE 6 -#define ACPI_MTX_EVENTS 7 -#define ACPI_MTX_HARDWARE 8 -#define ACPI_MTX_CACHES 9 -#define ACPI_MTX_MEMORY 10 -#define ACPI_MTX_DEBUG_CMD_COMPLETE 11 -#define ACPI_MTX_DEBUG_CMD_READY 12 - -#define MAX_MUTEX 12 -#define NUM_MUTEX MAX_MUTEX+1 - +#define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */ +#define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */ +#define ACPI_MTX_TABLES 2 /* Data for ACPI tables */ +#define ACPI_MTX_EVENTS 3 /* Data for ACPI events */ +#define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */ +#define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */ +#define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */ +#define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */ + +#define ACPI_MAX_MUTEX 7 +#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) #ifdef DEFINE_ACPI_GLOBALS -/* Names for the mutexes used in the subsystem */ +/* Debug names for the mutexes above */ -static const char *AcpiGbl_MutexNames[] = +static const char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = { - "ACPI_MTX_Execute", "ACPI_MTX_Interpreter", - "ACPI_MTX_Parser", - "ACPI_MTX_Dispatcher", "ACPI_MTX_Tables", - "ACPI_MTX_OpRegions", "ACPI_MTX_Namespace", "ACPI_MTX_Events", - "ACPI_MTX_Hardware", "ACPI_MTX_Caches", "ACPI_MTX_Memory", - "ACPI_MTX_DebugCmdComplete", - "ACPI_MTX_DebugCmdReady", + "ACPI_MTX_CommandComplete", + "ACPI_MTX_CommandReady" }; #endif #endif +/* + * Predefined handles for spinlocks used within the subsystem. + * These spinlocks are created by AcpiUtMutexInitialize + */ +#define ACPI_LOCK_GPES 0 +#define ACPI_LOCK_HARDWARE 1 + +#define ACPI_MAX_LOCK 1 +#define ACPI_NUM_LOCK ACPI_MAX_LOCK+1 + + /* Owner IDs are used to track namespace nodes for selective deletion */ typedef UINT8 ACPI_OWNER_ID; @@ -209,9 +212,9 @@ typedef UINT8 ACPI_OWNER_ID; typedef struct acpi_mutex_info { - ACPI_MUTEX Mutex; - UINT32 UseCount; - UINT32 ThreadId; + ACPI_MUTEX Mutex; + UINT32 UseCount; + ACPI_THREAD_ID ThreadId; } ACPI_MUTEX_INFO; @@ -230,6 +233,9 @@ typedef struct acpi_mutex_info #define ACPI_FIELD_QWORD_GRANULARITY 8 +#define ACPI_ENTRY_NOT_FOUND NULL + + /***************************************************************************** * * Namespace typedefs and structs @@ -240,103 +246,126 @@ typedef struct acpi_mutex_info typedef enum { - ACPI_IMODE_LOAD_PASS1 = 0x01, - ACPI_IMODE_LOAD_PASS2 = 0x02, - ACPI_IMODE_EXECUTE = 0x0E + ACPI_IMODE_LOAD_PASS1 = 0x01, + ACPI_IMODE_LOAD_PASS2 = 0x02, + ACPI_IMODE_EXECUTE = 0x03 } ACPI_INTERPRETER_MODE; - -/* - * The Node describes a named object that appears in the AML - * An AcpiNode is used to store Nodes. - * - * DataType is used to differentiate between internal descriptors, and MUST - * be the first byte in this structure. - */ typedef union acpi_name_union { - UINT32 Integer; - char Ascii[4]; + UINT32 Integer; + char Ascii[4]; } ACPI_NAME_UNION; + +/* + * The Namespace Node describes a named object that appears in the AML. + * DescriptorType is used to differentiate between internal descriptors. + * + * The node is optimized for both 32-bit and 64-bit platforms: + * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case. + * + * Note: The DescriptorType and Type fields must appear in the identical + * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT + * structures. + */ typedef struct acpi_namespace_node { - UINT8 Descriptor; /* Used to differentiate object descriptor types */ - UINT8 Type; /* Type associated with this name */ - UINT16 ReferenceCount; /* Current count of references and children */ - ACPI_NAME_UNION Name; /* ACPI Name, always 4 chars per ACPI spec */ - union acpi_operand_object *Object; /* Pointer to attached ACPI object (optional) */ - struct acpi_namespace_node *Child; /* First child */ - struct acpi_namespace_node *Peer; /* Next peer*/ - UINT8 OwnerId; /* Who created this node */ - UINT8 Flags; - - /* Fields used by the ASL compiler only */ - -#ifdef ACPI_ASL_COMPILER - UINT32 Value; - union acpi_parse_object *Op; + union acpi_operand_object *Object; /* Interpreter object */ + UINT8 DescriptorType; /* Differentiate object descriptor types */ + UINT8 Type; /* ACPI Type associated with this name */ + UINT8 Flags; /* Miscellaneous flags */ + ACPI_OWNER_ID OwnerId; /* Node creator */ + ACPI_NAME_UNION Name; /* ACPI Name, always 4 chars per ACPI spec */ + struct acpi_namespace_node *Child; /* First child */ + struct acpi_namespace_node *Peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */ + + /* + * The following fields are used by the ASL compiler and disassembler only + */ +#ifdef ACPI_LARGE_NAMESPACE_NODE + union acpi_parse_object *Op; + UINT32 Value; + UINT32 Length; #endif } ACPI_NAMESPACE_NODE; -#define ACPI_ENTRY_NOT_FOUND NULL +/* Namespace Node flags */ +#define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */ +#define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */ +#define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */ +#define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */ +#define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */ -/* Node flags */ - -#define ANOBJ_RESERVED 0x01 -#define ANOBJ_END_OF_PEER_LIST 0x02 -#define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */ -#define ANOBJ_METHOD_ARG 0x08 -#define ANOBJ_METHOD_LOCAL 0x10 -#define ANOBJ_METHOD_NO_RETVAL 0x20 -#define ANOBJ_METHOD_SOME_NO_RETVAL 0x40 -#define ANOBJ_IS_BIT_OFFSET 0x80 +#define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */ +#define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */ +#define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* iASL only: Method has at least one return value */ +#define ANOBJ_IS_BIT_OFFSET 0x40 /* iASL only: Reference is a bit offset */ +#define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */ /* * ACPI Table Descriptor. One per ACPI table */ typedef struct acpi_table_desc { - struct acpi_table_desc *Prev; - struct acpi_table_desc *Next; - struct acpi_table_desc *InstalledDesc; - ACPI_TABLE_HEADER *Pointer; - UINT8 *AmlStart; - UINT64 PhysicalAddress; - UINT32 AmlLength; - ACPI_SIZE Length; - ACPI_OWNER_ID OwnerId; - UINT8 Type; - UINT8 Allocation; - BOOLEAN LoadedIntoNamespace; + ACPI_PHYSICAL_ADDRESS Address; + ACPI_TABLE_HEADER *Pointer; + UINT32 Length; /* Length fixed at 32 bits */ + ACPI_NAME_UNION Signature; + ACPI_OWNER_ID OwnerId; + UINT8 Flags; } ACPI_TABLE_DESC; -typedef struct acpi_table_list +/* Flags for above */ + +#define ACPI_TABLE_ORIGIN_UNKNOWN (0) +#define ACPI_TABLE_ORIGIN_MAPPED (1) +#define ACPI_TABLE_ORIGIN_ALLOCATED (2) +#define ACPI_TABLE_ORIGIN_MASK (3) +#define ACPI_TABLE_IS_LOADED (4) + +/* One internal RSDT for table management */ + +typedef struct acpi_internal_rsdt { - struct acpi_table_desc *Next; - UINT32 Count; + ACPI_TABLE_DESC *Tables; + UINT32 Count; + UINT32 Size; + UINT8 Flags; + +} ACPI_INTERNAL_RSDT; + +/* Flags for above */ + +#define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */ +#define ACPI_ROOT_ORIGIN_ALLOCATED (1) +#define ACPI_ROOT_ALLOW_RESIZE (2) + -} ACPI_TABLE_LIST; +/* Predefined (fixed) table indexes */ + +#define ACPI_TABLE_INDEX_DSDT (0) +#define ACPI_TABLE_INDEX_FACS (1) typedef struct acpi_find_context { - char *SearchFor; - ACPI_HANDLE *List; - UINT32 *Count; + char *SearchFor; + ACPI_HANDLE *List; + UINT32 *Count; } ACPI_FIND_CONTEXT; typedef struct acpi_ns_search_data { - ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *Node; } ACPI_NS_SEARCH_DATA; @@ -346,30 +375,30 @@ typedef struct acpi_ns_search_data */ typedef struct acpi_predefined_names { - const char *Name; - UINT8 Type; - const char *Val; + const char *Name; + UINT8 Type; + const char *Val; } ACPI_PREDEFINED_NAMES; /* Object types used during package copies */ - #define ACPI_COPY_TYPE_SIMPLE 0 #define ACPI_COPY_TYPE_PACKAGE 1 + /* Info structure used to convert external<->internal namestrings */ typedef struct acpi_namestring_info { - const char *ExternalName; - const char *NextExternalChar; - char *InternalName; - UINT32 Length; - UINT32 NumSegments; - UINT32 NumCarats; - BOOLEAN FullyQualified; + const char *ExternalName; + const char *NextExternalChar; + char *InternalName; + UINT32 Length; + UINT32 NumSegments; + UINT32 NumCarats; + BOOLEAN FullyQualified; } ACPI_NAMESTRING_INFO; @@ -378,20 +407,25 @@ typedef struct acpi_namestring_info typedef struct acpi_create_field_info { - ACPI_NAMESPACE_NODE *RegionNode; - ACPI_NAMESPACE_NODE *FieldNode; - ACPI_NAMESPACE_NODE *RegisterNode; - ACPI_NAMESPACE_NODE *DataRegisterNode; - UINT32 BankValue; - UINT32 FieldBitPosition; - UINT32 FieldBitLength; - UINT8 FieldFlags; - UINT8 Attribute; - UINT8 FieldType; + ACPI_NAMESPACE_NODE *RegionNode; + ACPI_NAMESPACE_NODE *FieldNode; + ACPI_NAMESPACE_NODE *RegisterNode; + ACPI_NAMESPACE_NODE *DataRegisterNode; + UINT32 BankValue; + UINT32 FieldBitPosition; + UINT32 FieldBitLength; + UINT8 FieldFlags; + UINT8 Attribute; + UINT8 FieldType; } ACPI_CREATE_FIELD_INFO; +typedef +ACPI_STATUS (*ACPI_INTERNAL_METHOD) ( + struct acpi_walk_state *WalkState); + + /* * Bitmapped ACPI types. Used internally only */ @@ -456,7 +490,7 @@ typedef struct acpi_gpe_event_info union acpi_gpe_dispatch_info Dispatch; /* Either Method or Handler */ struct acpi_gpe_register_info *RegisterInfo; /* Backpointer to register info */ UINT8 Flags; /* Misc info about this GPE */ - UINT8 RegisterBit; /* This GPE bit within the register */ + UINT8 GpeNumber; /* This GPE */ } ACPI_GPE_EVENT_INFO; @@ -511,25 +545,25 @@ typedef struct acpi_gpe_walk_info typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock); + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock); /* Information about each particular fixed event */ typedef struct acpi_fixed_event_handler { - ACPI_EVENT_HANDLER Handler; /* Address of handler. */ - void *Context; /* Context to be passed to handler */ + ACPI_EVENT_HANDLER Handler; /* Address of handler. */ + void *Context; /* Context to be passed to handler */ } ACPI_FIXED_EVENT_HANDLER; typedef struct acpi_fixed_event_info { - UINT8 StatusRegisterId; - UINT8 EnableRegisterId; - UINT16 StatusBitMask; - UINT16 EnableBitMask; + UINT8 StatusRegisterId; + UINT8 EnableRegisterId; + UINT16 StatusBitMask; + UINT16 EnableBitMask; } ACPI_FIXED_EVENT_INFO; @@ -537,9 +571,9 @@ typedef struct acpi_fixed_event_info typedef struct acpi_field_info { - UINT8 SkipField; - UINT8 FieldFlag; - UINT32 PkgLength; + UINT8 SkipField; + UINT8 FieldFlag; + UINT32 PkgLength; } ACPI_FIELD_INFO; @@ -557,13 +591,14 @@ typedef struct acpi_field_info #define ACPI_CONTROL_PREDICATE_TRUE 0xC4 -#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ - UINT8 DataType; /* To differentiate various internal objs */\ - UINT8 Flags; \ - UINT16 Value; \ - UINT16 State; \ - UINT16 Reserved; \ - void *Next; +#define ACPI_STATE_COMMON \ + void *Next; \ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Flags; \ + UINT16 Value; \ + UINT16 State; + + /* There are 2 bytes available here until the next natural alignment boundary */ typedef struct acpi_common_state { @@ -577,7 +612,7 @@ typedef struct acpi_common_state typedef struct acpi_update_state { ACPI_STATE_COMMON - union acpi_operand_object *Object; + union acpi_operand_object *Object; } ACPI_UPDATE_STATE; @@ -588,12 +623,12 @@ typedef struct acpi_update_state typedef struct acpi_pkg_state { ACPI_STATE_COMMON - union acpi_operand_object *SourceObject; - union acpi_operand_object *DestObject; - struct acpi_walk_state *WalkState; - void *ThisTargetObj; - UINT32 NumPackages; - UINT16 Index; + UINT16 Index; + union acpi_operand_object *SourceObject; + union acpi_operand_object *DestObject; + struct acpi_walk_state *WalkState; + void *ThisTargetObj; + UINT32 NumPackages; } ACPI_PKG_STATE; @@ -605,10 +640,10 @@ typedef struct acpi_pkg_state typedef struct acpi_control_state { ACPI_STATE_COMMON - union acpi_parse_object *PredicateOp; - UINT8 *AmlPredicateStart; /* Start of if/while predicate */ - UINT8 *PackageEnd; /* End of if/while block */ - UINT16 Opcode; + UINT16 Opcode; + union acpi_parse_object *PredicateOp; + UINT8 *AmlPredicateStart; /* Start of if/while predicate */ + UINT8 *PackageEnd; /* End of if/while block */ } ACPI_CONTROL_STATE; @@ -619,7 +654,7 @@ typedef struct acpi_control_state typedef struct acpi_scope_state { ACPI_STATE_COMMON - ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *Node; } ACPI_SCOPE_STATE; @@ -627,11 +662,11 @@ typedef struct acpi_scope_state typedef struct acpi_pscope_state { ACPI_STATE_COMMON - union acpi_parse_object *Op; /* Current op being parsed */ - UINT8 *ArgEnd; /* Current argument end */ - UINT8 *PkgEnd; /* Current package end */ - UINT32 ArgList; /* Next argument to parse */ - UINT32 ArgCount; /* Number of fixed arguments */ + UINT32 ArgCount; /* Number of fixed arguments */ + union acpi_parse_object *Op; /* Current op being parsed */ + UINT8 *ArgEnd; /* Current argument end */ + UINT8 *PkgEnd; /* Current package end */ + UINT32 ArgList; /* Next argument to parse */ } ACPI_PSCOPE_STATE; @@ -643,10 +678,10 @@ typedef struct acpi_pscope_state typedef struct acpi_thread_state { ACPI_STATE_COMMON - struct acpi_walk_state *WalkStateList; /* Head of list of WalkStates for this thread */ - union acpi_operand_object *AcquiredMutexList; /* List of all currently acquired mutexes */ - UINT32 ThreadId; /* Running thread ID */ - UINT8 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ + UINT8 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ + struct acpi_walk_state *WalkStateList; /* Head of list of WalkStates for this thread */ + union acpi_operand_object *AcquiredMutexList; /* List of all currently acquired mutexes */ + ACPI_THREAD_ID ThreadId; /* Running thread ID */ } ACPI_THREAD_STATE; @@ -658,21 +693,19 @@ typedef struct acpi_thread_state typedef struct acpi_result_values { ACPI_STATE_COMMON - union acpi_operand_object *ObjDesc [ACPI_OBJ_NUM_OPERANDS]; - UINT8 NumResults; - UINT8 LastInsert; + union acpi_operand_object *ObjDesc [ACPI_RESULTS_FRAME_OBJ_NUM]; } ACPI_RESULT_VALUES; typedef ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) ( - struct acpi_walk_state *WalkState, - union acpi_parse_object **OutOp); + struct acpi_walk_state *WalkState, + union acpi_parse_object **OutOp); typedef ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( - struct acpi_walk_state *WalkState); + struct acpi_walk_state *WalkState); /* @@ -682,8 +715,8 @@ ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( typedef struct acpi_notify_info { ACPI_STATE_COMMON - ACPI_NAMESPACE_NODE *Node; - union acpi_operand_object *HandlerObj; + ACPI_NAMESPACE_NODE *Node; + union acpi_operand_object *HandlerObj; } ACPI_NOTIFY_INFO; @@ -692,15 +725,15 @@ typedef struct acpi_notify_info typedef union acpi_generic_state { - ACPI_COMMON_STATE Common; - ACPI_CONTROL_STATE Control; - ACPI_UPDATE_STATE Update; - ACPI_SCOPE_STATE Scope; - ACPI_PSCOPE_STATE ParseScope; - ACPI_PKG_STATE Pkg; - ACPI_THREAD_STATE Thread; - ACPI_RESULT_VALUES Results; - ACPI_NOTIFY_INFO Notify; + ACPI_COMMON_STATE Common; + ACPI_CONTROL_STATE Control; + ACPI_UPDATE_STATE Update; + ACPI_SCOPE_STATE Scope; + ACPI_PSCOPE_STATE ParseScope; + ACPI_PKG_STATE Pkg; + ACPI_THREAD_STATE Thread; + ACPI_RESULT_VALUES Results; + ACPI_NOTIFY_INFO Notify; } ACPI_GENERIC_STATE; @@ -713,7 +746,7 @@ typedef union acpi_generic_state typedef ACPI_STATUS (*ACPI_EXECUTE_OP) ( - struct acpi_walk_state *WalkState); + struct acpi_walk_state *WalkState); /***************************************************************************** @@ -728,54 +761,57 @@ ACPI_STATUS (*ACPI_EXECUTE_OP) ( typedef struct acpi_opcode_info { #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) - const char *Name; /* Opcode name (disassembler/debug only) */ + const char *Name; /* Opcode name (disassembler/debug only) */ #endif - UINT32 ParseArgs; /* Grammar/Parse time arguments */ - UINT32 RuntimeArgs; /* Interpret time arguments */ - UINT32 Flags; /* Misc flags */ - UINT8 ObjectType; /* Corresponding internal object type */ - UINT8 Class; /* Opcode class */ - UINT8 Type; /* Opcode type */ + UINT32 ParseArgs; /* Grammar/Parse time arguments */ + UINT32 RuntimeArgs; /* Interpret time arguments */ + UINT16 Flags; /* Misc flags */ + UINT8 ObjectType; /* Corresponding internal object type */ + UINT8 Class; /* Opcode class */ + UINT8 Type; /* Opcode type */ } ACPI_OPCODE_INFO; typedef union acpi_parse_value { - ACPI_INTEGER Integer; /* Integer constant (Up to 64 bits) */ - UINT64_STRUCT Integer64; /* Structure overlay for 2 32-bit Dwords */ - UINT32 Size; /* bytelist or field size */ - char *String; /* NULL terminated string */ - UINT8 *Buffer; /* buffer or string */ - char *Name; /* NULL terminated string */ - union acpi_parse_object *Arg; /* arguments and contained ops */ + ACPI_INTEGER Integer; /* Integer constant (Up to 64 bits) */ + UINT64_STRUCT Integer64; /* Structure overlay for 2 32-bit Dwords */ + UINT32 Size; /* bytelist or field size */ + char *String; /* NULL terminated string */ + UINT8 *Buffer; /* buffer or string */ + char *Name; /* NULL terminated string */ + union acpi_parse_object *Arg; /* arguments and contained ops */ } ACPI_PARSE_VALUE; #define ACPI_PARSE_COMMON \ - UINT8 DataType; /* To differentiate various internal objs */\ - UINT8 Flags; /* Type of Op */\ - UINT16 AmlOpcode; /* AML opcode */\ - UINT32 AmlOffset; /* Offset of declaration in AML */\ - union acpi_parse_object *Parent; /* Parent op */\ - union acpi_parse_object *Next; /* Next op */\ + union acpi_parse_object *Parent; /* Parent op */\ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Flags; /* Type of Op */\ + UINT16 AmlOpcode; /* AML opcode */\ + UINT32 AmlOffset; /* Offset of declaration in AML */\ + union acpi_parse_object *Next; /* Next op */\ + ACPI_NAMESPACE_NODE *Node; /* For use by interpreter */\ + ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ + UINT8 ArgListLength; /* Number of elements in the arg list */\ ACPI_DISASM_ONLY_MEMBERS (\ - UINT8 DisasmFlags; /* Used during AML disassembly */\ - UINT8 DisasmOpcode; /* Subtype used for disassembly */\ - char AmlOpName[16]) /* Op name (debug only) */\ - /* NON-DEBUG members below: */\ - ACPI_NAMESPACE_NODE *Node; /* For use by interpreter */\ - ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */ + UINT8 DisasmFlags; /* Used during AML disassembly */\ + UINT8 DisasmOpcode; /* Subtype used for disassembly */\ + char AmlOpName[16]) /* Op name (debug only) */ -#define ACPI_DASM_BUFFER 0x00 -#define ACPI_DASM_RESOURCE 0x01 -#define ACPI_DASM_STRING 0x02 -#define ACPI_DASM_UNICODE 0x03 -#define ACPI_DASM_EISAID 0x04 -#define ACPI_DASM_MATCHOP 0x05 +#define ACPI_DASM_BUFFER 0x00 +#define ACPI_DASM_RESOURCE 0x01 +#define ACPI_DASM_STRING 0x02 +#define ACPI_DASM_UNICODE 0x03 +#define ACPI_DASM_EISAID 0x04 +#define ACPI_DASM_MATCHOP 0x05 +#define ACPI_DASM_LNOT_PREFIX 0x06 +#define ACPI_DASM_LNOT_SUFFIX 0x07 +#define ACPI_DASM_IGNORE 0x08 /* - * generic operation (for example: If, While, Store) + * Generic operation (for example: If, While, Store) */ typedef struct acpi_parse_obj_common { @@ -790,53 +826,53 @@ typedef struct acpi_parse_obj_common typedef struct acpi_parse_obj_named { ACPI_PARSE_COMMON - UINT8 *Path; - UINT8 *Data; /* AML body or bytelist data */ - UINT32 Length; /* AML length */ - UINT32 Name; /* 4-byte name or zero if no name */ + UINT8 *Path; + UINT8 *Data; /* AML body or bytelist data */ + UINT32 Length; /* AML length */ + UINT32 Name; /* 4-byte name or zero if no name */ } ACPI_PARSE_OBJ_NAMED; -/* The parse node is the fundamental element of the parse tree */ +/* This version is used by the iASL compiler only */ #define ACPI_MAX_PARSEOP_NAME 20 typedef struct acpi_parse_obj_asl { ACPI_PARSE_COMMON - union acpi_parse_object *Child; - union acpi_parse_object *ParentMethod; - char *Filename; - char *ExternalName; - char *Namepath; - char NameSeg[4]; - UINT32 ExtraValue; - UINT32 Column; - UINT32 LineNumber; - UINT32 LogicalLineNumber; - UINT32 LogicalByteOffset; - UINT32 EndLine; - UINT32 EndLogicalLine; - UINT32 AcpiBtype; - UINT32 AmlLength; - UINT32 AmlSubtreeLength; - UINT32 FinalAmlLength; - UINT32 FinalAmlOffset; - UINT32 CompileFlags; - UINT16 ParseOpcode; - UINT8 AmlOpcodeLength; - UINT8 AmlPkgLenBytes; - UINT8 Extra; - char ParseOpName[ACPI_MAX_PARSEOP_NAME]; + union acpi_parse_object *Child; + union acpi_parse_object *ParentMethod; + char *Filename; + char *ExternalName; + char *Namepath; + char NameSeg[4]; + UINT32 ExtraValue; + UINT32 Column; + UINT32 LineNumber; + UINT32 LogicalLineNumber; + UINT32 LogicalByteOffset; + UINT32 EndLine; + UINT32 EndLogicalLine; + UINT32 AcpiBtype; + UINT32 AmlLength; + UINT32 AmlSubtreeLength; + UINT32 FinalAmlLength; + UINT32 FinalAmlOffset; + UINT32 CompileFlags; + UINT16 ParseOpcode; + UINT8 AmlOpcodeLength; + UINT8 AmlPkgLenBytes; + UINT8 Extra; + char ParseOpName[ACPI_MAX_PARSEOP_NAME]; } ACPI_PARSE_OBJ_ASL; typedef union acpi_parse_object { - ACPI_PARSE_OBJ_COMMON Common; - ACPI_PARSE_OBJ_NAMED Named; - ACPI_PARSE_OBJ_ASL Asl; + ACPI_PARSE_OBJ_COMMON Common; + ACPI_PARSE_OBJ_NAMED Named; + ACPI_PARSE_OBJ_ASL Asl; } ACPI_PARSE_OBJECT; @@ -847,34 +883,36 @@ typedef union acpi_parse_object */ typedef struct acpi_parse_state { - UINT32 AmlSize; - UINT8 *AmlStart; /* First AML byte */ - UINT8 *Aml; /* Next AML byte */ - UINT8 *AmlEnd; /* (last + 1) AML byte */ - UINT8 *PkgStart; /* Current package begin */ - UINT8 *PkgEnd; /* Current package end */ - union acpi_parse_object *StartOp; /* Root of parse tree */ - struct acpi_namespace_node *StartNode; - union acpi_generic_state *Scope; /* Current scope */ - union acpi_parse_object *StartScope; + UINT8 *AmlStart; /* First AML byte */ + UINT8 *Aml; /* Next AML byte */ + UINT8 *AmlEnd; /* (last + 1) AML byte */ + UINT8 *PkgStart; /* Current package begin */ + UINT8 *PkgEnd; /* Current package end */ + union acpi_parse_object *StartOp; /* Root of parse tree */ + struct acpi_namespace_node *StartNode; + union acpi_generic_state *Scope; /* Current scope */ + union acpi_parse_object *StartScope; + UINT32 AmlSize; } ACPI_PARSE_STATE; /* Parse object flags */ -#define ACPI_PARSEOP_GENERIC 0x01 -#define ACPI_PARSEOP_NAMED 0x02 -#define ACPI_PARSEOP_DEFERRED 0x04 -#define ACPI_PARSEOP_BYTELIST 0x08 -#define ACPI_PARSEOP_IN_CACHE 0x80 +#define ACPI_PARSEOP_GENERIC 0x01 +#define ACPI_PARSEOP_NAMED 0x02 +#define ACPI_PARSEOP_DEFERRED 0x04 +#define ACPI_PARSEOP_BYTELIST 0x08 +#define ACPI_PARSEOP_IN_STACK 0x10 +#define ACPI_PARSEOP_TARGET 0x20 +#define ACPI_PARSEOP_IN_CACHE 0x80 /* Parse object DisasmFlags */ -#define ACPI_PARSEOP_IGNORE 0x01 -#define ACPI_PARSEOP_PARAMLIST 0x02 -#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 -#define ACPI_PARSEOP_SPECIAL 0x10 +#define ACPI_PARSEOP_IGNORE 0x01 +#define ACPI_PARSEOP_PARAMLIST 0x02 +#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 +#define ACPI_PARSEOP_SPECIAL 0x10 /***************************************************************************** @@ -883,19 +921,27 @@ typedef struct acpi_parse_state * ****************************************************************************/ -#define PCI_ROOT_HID_STRING "PNP0A03" -#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" +#define PCI_ROOT_HID_STRING "PNP0A03" +#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" typedef struct acpi_bit_register_info { - UINT8 ParentRegister; - UINT8 BitPosition; - UINT16 AccessBitMask; + UINT8 ParentRegister; + UINT8 BitPosition; + UINT16 AccessBitMask; } ACPI_BIT_REGISTER_INFO; /* + * Some ACPI registers have bits that must be ignored -- meaning that they + * must be preserved. + */ +#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ +#define ACPI_PM1_CONTROL_PRESERVED_BITS 0x0201 /* Bit 9, Bit 0 (SCI_EN) */ + + +/* * Register IDs * These are the full ACPI registers */ @@ -921,13 +967,14 @@ typedef struct acpi_bit_register_info #define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ #define ACPI_BITMASK_WAKE_STATUS 0x8000 -#define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \ - ACPI_BITMASK_BUS_MASTER_STATUS | \ - ACPI_BITMASK_GLOBAL_LOCK_STATUS | \ - ACPI_BITMASK_POWER_BUTTON_STATUS | \ - ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ - ACPI_BITMASK_RT_CLOCK_STATUS | \ - ACPI_BITMASK_WAKE_STATUS) +#define ACPI_BITMASK_ALL_FIXED_STATUS (\ + ACPI_BITMASK_TIMER_STATUS | \ + ACPI_BITMASK_BUS_MASTER_STATUS | \ + ACPI_BITMASK_GLOBAL_LOCK_STATUS | \ + ACPI_BITMASK_POWER_BUTTON_STATUS | \ + ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ + ACPI_BITMASK_RT_CLOCK_STATUS | \ + ACPI_BITMASK_WAKE_STATUS) #define ACPI_BITMASK_TIMER_ENABLE 0x0001 #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020 @@ -1035,7 +1082,7 @@ typedef struct acpi_bit_register_info * ****************************************************************************/ -#define ACPI_ASCII_ZERO 0x30 +#define ACPI_ASCII_ZERO 0x30 /***************************************************************************** @@ -1046,26 +1093,44 @@ typedef struct acpi_bit_register_info typedef struct acpi_db_method_info { - ACPI_HANDLE ThreadGate; - char *Name; - char **Args; - UINT32 Flags; - UINT32 NumLoops; - char Pathname[128]; + ACPI_HANDLE MainThreadGate; + ACPI_HANDLE ThreadCompleteGate; + UINT32 *Threads; + UINT32 NumThreads; + UINT32 NumCreated; + UINT32 NumCompleted; + + char *Name; + UINT32 Flags; + UINT32 NumLoops; + char Pathname[128]; + char **Args; + + /* + * Arguments to be passed to method for the command + * Threads - + * the Number of threads, ID of current thread and + * Index of current thread inside all them created. + */ + char InitArgs; + char *Arguments[4]; + char NumThreadsStr[11]; + char IdOfThreadStr[11]; + char IndexOfThreadStr[11]; } ACPI_DB_METHOD_INFO; typedef struct acpi_integrity_info { - UINT32 Nodes; - UINT32 Objects; + UINT32 Nodes; + UINT32 Objects; } ACPI_INTEGRITY_INFO; -#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 -#define ACPI_DB_CONSOLE_OUTPUT 0x02 -#define ACPI_DB_DUPLICATE_OUTPUT 0x03 +#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 +#define ACPI_DB_CONSOLE_OUTPUT 0x02 +#define ACPI_DB_DUPLICATE_OUTPUT 0x03 /***************************************************************************** @@ -1076,18 +1141,18 @@ typedef struct acpi_integrity_info /* Entry for a memory allocation (debug only) */ -#define ACPI_MEM_MALLOC 0 -#define ACPI_MEM_CALLOC 1 -#define ACPI_MAX_MODULE_NAME 16 +#define ACPI_MEM_MALLOC 0 +#define ACPI_MEM_CALLOC 1 +#define ACPI_MAX_MODULE_NAME 16 #define ACPI_COMMON_DEBUG_MEM_HEADER \ - struct acpi_debug_mem_block *Previous; \ - struct acpi_debug_mem_block *Next; \ - UINT32 Size; \ - UINT32 Component; \ - UINT32 Line; \ - char Module[ACPI_MAX_MODULE_NAME]; \ - UINT8 AllocType; + struct acpi_debug_mem_block *Previous; \ + struct acpi_debug_mem_block *Next; \ + UINT32 Size; \ + UINT32 Component; \ + UINT32 Line; \ + char Module[ACPI_MAX_MODULE_NAME]; \ + UINT8 AllocType; typedef struct acpi_debug_mem_header { @@ -1098,7 +1163,7 @@ typedef struct acpi_debug_mem_header typedef struct acpi_debug_mem_block { ACPI_COMMON_DEBUG_MEM_HEADER - UINT64 UserSpace; + UINT64 UserSpace; } ACPI_DEBUG_MEM_BLOCK; @@ -1111,22 +1176,24 @@ typedef struct acpi_debug_mem_block typedef struct acpi_memory_list { - const char *ListName; - void *ListHead; - UINT16 ObjectSize; - UINT16 MaxDepth; - UINT16 CurrentDepth; - UINT16 LinkOffset; + const char *ListName; + void *ListHead; + UINT16 ObjectSize; + UINT16 MaxDepth; + UINT16 CurrentDepth; + UINT16 LinkOffset; #ifdef ACPI_DBG_TRACK_ALLOCATIONS /* Statistics for debug memory tracking only */ - UINT32 TotalAllocated; - UINT32 TotalFreed; - UINT32 CurrentTotalSize; - UINT32 Requests; - UINT32 Hits; + UINT32 TotalAllocated; + UINT32 TotalFreed; + UINT32 MaxOccupied; + UINT32 TotalSize; + UINT32 CurrentTotalSize; + UINT32 Requests; + UINT32 Hits; #endif } ACPI_MEMORY_LIST; diff --git a/sys/dist/acpica/acmacros.h b/sys/dist/acpica/acmacros.h index d7a62b6a3a8..49306ed2836 100644 --- a/sys/dist/acpica/acmacros.h +++ b/sys/dist/acpica/acmacros.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acmacros.h - C macros for the entire subsystem. - * xRevision: 1.180 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -129,46 +129,19 @@ #define ACPI_SET_BIT(target,bit) ((target) |= (bit)) #define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) #define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) +#define ACPI_MAX(a,b) (((a)>(b))?(a):(b)) +/* Size calculation */ -#if ACPI_MACHINE_WIDTH == 16 +#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) -/* - * For 16-bit addresses, we have to assume that the upper 32 bits - * (out of 64) are zero. - */ -#define ACPI_LODWORD(l) ((UINT32)(l)) -#define ACPI_HIDWORD(l) ((UINT32)(0)) - -#define ACPI_GET_ADDRESS(a) ((a).Lo) -#define ACPI_STORE_ADDRESS(a,b) {(a).Hi=0;(a).Lo=(UINT32)(b);} -#define ACPI_VALID_ADDRESS(a) ((a).Hi | (a).Lo) - -#else -#ifdef ACPI_NO_INTEGER64_SUPPORT -/* - * ACPI_INTEGER is 32-bits, no 64-bit support on this platform - */ -#define ACPI_LODWORD(l) ((UINT32)(l)) -#define ACPI_HIDWORD(l) ((UINT32)(0)) - -#define ACPI_GET_ADDRESS(a) (a) -#define ACPI_STORE_ADDRESS(a,b) ((a)=(b)) -#define ACPI_VALID_ADDRESS(a) (a) - -#else /* - * Full 64-bit address/integer on both 32-bit and 64-bit platforms + * Full 64-bit integer must be available on both 32-bit and 64-bit platforms */ #define ACPI_LODWORD(l) ((UINT32)(UINT64)(l)) #define ACPI_HIDWORD(l) ((UINT32)(((*(UINT64_STRUCT *)(void *)(&l))).Hi)) -#define ACPI_GET_ADDRESS(a) (a) -#define ACPI_STORE_ADDRESS(a,b) ((a)=(ACPI_PHYSICAL_ADDRESS)(b)) -#define ACPI_VALID_ADDRESS(a) (a) -#endif -#endif /* * printf() format helpers @@ -197,7 +170,7 @@ */ #define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (p)) #define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (ACPI_UINTPTR_T) (p)) -#define ACPI_CAST_CONST_PTR(t, p) ((const t *)(const void *)(p)) +#define ACPI_CAST_CONST_PTR(t, p) ((const t *)(const void *)(p)) #define ACPI_CAST_CONST_INDIRECT_PTR(t, p) ((const t **)(const void *)(p)) #define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8,(a)) + (ACPI_NATIVE_UINT)(b))) #define ACPI_PTR_DIFF(a,b) (ACPI_NATIVE_UINT) (ACPI_CAST_PTR (UINT8,(a)) - ACPI_CAST_PTR (UINT8,(b))) @@ -207,15 +180,13 @@ #define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void,(void *) NULL,(ACPI_NATIVE_UINT) i) #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) #define ACPI_OFFSET(d,f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) -#define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f) - -#if ACPI_MACHINE_WIDTH == 16 -#define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) -#define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) -#define ACPI_PTR_TO_PHYSADDR(i) (UINT32) ACPI_CAST_PTR (UINT8,(i)) -#else #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) + +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (UINT32,(a)) == *ACPI_CAST_PTR (UINT32,(b))) +#else +#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char,(a)), ACPI_CAST_PTR (char,(b)), ACPI_NAME_SIZE)) #endif /* @@ -238,16 +209,16 @@ /* Hi...Lo Lo...Hi */ /* 16-bit source, 16/32/64 destination */ -#define ACPI_MOVE_16_TO_16(d,s) {(( UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[1];\ - (( UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[0];} +#define ACPI_MOVE_16_TO_16(d,s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[0];} #define ACPI_MOVE_16_TO_32(d,s) {(*(UINT32 *)(void *)(d))=0;\ - ((UINT8 *)(void *)(d))[2] = ((const UINT8 *)(const void *)(s))[1];\ - ((UINT8 *)(void *)(d))[3] = ((const UINT8 *)(const void *)(s))[0];} + ((UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[0];} #define ACPI_MOVE_16_TO_64(d,s) {(*(UINT64 *)(void *)(d))=0;\ - ((UINT8 *)(void *)(d))[6] = ((const UINT8 *)(const void *)(s))[1];\ - ((UINT8 *)(void *)(d))[7] = ((const UINT8 *)(const void *)(s))[0];} + ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} /* 32-bit source, 16/32/64 destination */ @@ -270,14 +241,14 @@ #define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ -#define ACPI_MOVE_64_TO_64(d,s) {(( UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[7];\ - (( UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[6];\ - (( UINT8 *)(void *)(d))[2] = ((const UINT8 *)(const void *)(s))[5];\ - (( UINT8 *)(void *)(d))[3] = ((const UINT8 *)(const void *)(s))[4];\ - (( UINT8 *)(void *)(d))[4] = ((const UINT8 *)(const void *)(s))[3];\ - (( UINT8 *)(void *)(d))[5] = ((const UINT8 *)(const void *)(s))[2];\ - (( UINT8 *)(void *)(d))[6] = ((const UINT8 *)(const void *)(s))[1];\ - (( UINT8 *)(void *)(d))[7] = ((const UINT8 *)(const void *)(s))[0];} +#define ACPI_MOVE_64_TO_64(d,s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[5];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[4];\ + (( UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} #else /* * Macros for little-endian machines @@ -291,33 +262,11 @@ /* The hardware supports unaligned transfers, just do the little-endian move */ -#if ACPI_MACHINE_WIDTH == 16 - -/* No 64-bit integers */ /* 16-bit source, 16/32/64 destination */ -#define ACPI_MOVE_16_TO_16(d,s) *(UINT16 *)(void *)(d) = *(const UINT16 *)(const void *)(s) -#define ACPI_MOVE_16_TO_32(d,s) *(UINT32 *)(void *)(d) = *(const UINT16 *)(const void *)(s) -#define ACPI_MOVE_16_TO_64(d,s) ACPI_MOVE_16_TO_32(d,s) - -/* 32-bit source, 16/32/64 destination */ - -#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ -#define ACPI_MOVE_32_TO_32(d,s) *(UINT32 *)(void *)(d) = *(const UINT32 *)(const void *)(s) -#define ACPI_MOVE_32_TO_64(d,s) ACPI_MOVE_32_TO_32(d,s) - -/* 64-bit source, 16/32/64 destination */ - -#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ -#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ -#define ACPI_MOVE_64_TO_64(d,s) ACPI_MOVE_32_TO_32(d,s) - -#else -/* 16-bit source, 16/32/64 destination */ - -#define ACPI_MOVE_16_TO_16(d,s) *(UINT16 *)(void *)(d) = *(const UINT16 *)(const void *)(s) -#define ACPI_MOVE_16_TO_32(d,s) *(UINT32 *)(void *)(d) = *(const UINT16 *)(const void *)(s) -#define ACPI_MOVE_16_TO_64(d,s) *(UINT64 *)(void *)(d) = *(const UINT16 *)(const void *)(s) +#define ACPI_MOVE_16_TO_16(d,s) *(UINT16 *)(void *)(d) = *(UINT16 *)(void *)(s) +#define ACPI_MOVE_16_TO_32(d,s) *(UINT32 *)(void *)(d) = *(UINT16 *)(void *)(s) +#define ACPI_MOVE_16_TO_64(d,s) *(UINT64 *)(void *)(d) = *(UINT16 *)(void *)(s) /* 32-bit source, 16/32/64 destination */ @@ -330,7 +279,6 @@ #define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ #define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ #define ACPI_MOVE_64_TO_64(d,s) *(UINT64 *)(void *)(d) = *(const UINT64 *)(const void *)(s) -#endif #else /* @@ -341,8 +289,8 @@ /* 16-bit source, 16/32/64 destination */ -#define ACPI_MOVE_16_TO_16(d,s) {(( UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[0];\ - (( UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[1];} +#define ACPI_MOVE_16_TO_16(d,s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];} #define ACPI_MOVE_16_TO_32(d,s) {(*(UINT32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d,s);} #define ACPI_MOVE_16_TO_64(d,s) {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d,s);} @@ -351,10 +299,10 @@ #define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ -#define ACPI_MOVE_32_TO_32(d,s) {(( UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[0];\ - (( UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[1];\ - (( UINT8 *)(void *)(d))[2] = ((const UINT8 *)(const void *)(s))[2];\ - (( UINT8 *)(void *)(d))[3] = ((const UINT8 *)(const void *)(s))[3];} +#define ACPI_MOVE_32_TO_32(d,s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];} #define ACPI_MOVE_32_TO_64(d,s) {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d,s);} @@ -362,23 +310,20 @@ #define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ #define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ -#define ACPI_MOVE_64_TO_64(d,s) {(( UINT8 *)(void *)(d))[0] = ((const UINT8 *)(const void *)(s))[0];\ - (( UINT8 *)(void *)(d))[1] = ((const UINT8 *)(const void *)(s))[1];\ - (( UINT8 *)(void *)(d))[2] = ((const UINT8 *)(const void *)(s))[2];\ - (( UINT8 *)(void *)(d))[3] = ((const UINT8 *)(const void *)(s))[3];\ - (( UINT8 *)(void *)(d))[4] = ((const UINT8 *)(const void *)(s))[4];\ - (( UINT8 *)(void *)(d))[5] = ((const UINT8 *)(const void *)(s))[5];\ - (( UINT8 *)(void *)(d))[6] = ((const UINT8 *)(const void *)(s))[6];\ - (( UINT8 *)(void *)(d))[7] = ((const UINT8 *)(const void *)(s))[7];} +#define ACPI_MOVE_64_TO_64(d,s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[4];\ + (( UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[5];\ + (( UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[6];\ + (( UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[7];} #endif #endif /* Macros based on machine integer width */ -#if ACPI_MACHINE_WIDTH == 16 -#define ACPI_MOVE_SIZE_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) - -#elif ACPI_MACHINE_WIDTH == 32 +#if ACPI_MACHINE_WIDTH == 32 #define ACPI_MOVE_SIZE_TO_16(d,s) ACPI_MOVE_32_TO_16(d,s) #elif ACPI_MACHINE_WIDTH == 64 @@ -464,6 +409,8 @@ #define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) ((Val << Pos) & Mask) #define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val) Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) +#define ACPI_INSERT_BITS(Target, Mask, Source) Target = ((Target & (~(Mask))) | (Source & Mask)) + /* Generate a UUID */ #define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ @@ -479,8 +426,8 @@ * * The "Descriptor" field is the first field in both structures. */ -#define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_DESCRIPTOR *)(void *)(d))->DescriptorId) -#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((ACPI_DESCRIPTOR *)(void *)(d))->DescriptorId = t) +#define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType) +#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType = t) /* Macro to test the object type */ @@ -561,14 +508,6 @@ #define ACPI_ERROR_NAMESPACE(s,e) AcpiNsReportError (AE_INFO, s, e); #define ACPI_ERROR_METHOD(s,n,p,e) AcpiNsReportMethodError (AE_INFO, s, n, p, e); -/* Legacy interfaces. Remove when migration is complete */ - -#define ACPI_REPORT_INFO(fp) {AcpiUtReportInfo (AE_INFO); \ - AcpiOsPrintf fp;} -#define ACPI_REPORT_ERROR(fp) {AcpiUtReportError (AE_INFO); \ - AcpiOsPrintf fp;} -#define ACPI_REPORT_WARNING(fp) {AcpiUtReportWarning (AE_INFO); \ - AcpiOsPrintf fp;} #else /* No error messages */ @@ -579,10 +518,6 @@ #define ACPI_ERROR(plist) #define ACPI_ERROR_NAMESPACE(s,e) #define ACPI_ERROR_METHOD(s,n,p,e) - -#define ACPI_REPORT_INFO(fp) -#define ACPI_REPORT_ERROR(fp) -#define ACPI_REPORT_WARNING(fp) #endif /* @@ -615,7 +550,7 @@ * Note: (const char) is used to be compatible with the debug interfaces * and macros such as __FUNCTION__. */ -#define ACPI_FUNCTION_NAME(Name) const char *_AcpiFunctionName = Name; +#define ACPI_FUNCTION_NAME(Name) const char *_AcpiFunctionName = #Name; #else /* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ @@ -626,11 +561,11 @@ #define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ AcpiUtTrace(ACPI_DEBUG_PARAMETERS) #define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTracePtr(ACPI_DEBUG_PARAMETERS, b) + AcpiUtTracePtr(ACPI_DEBUG_PARAMETERS,b) #define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ AcpiUtTraceU32(ACPI_DEBUG_PARAMETERS,(UINT32)b) #define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTraceStr(ACPI_DEBUG_PARAMETERS, b) + AcpiUtTraceStr(ACPI_DEBUG_PARAMETERS,b) #define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr() @@ -782,17 +717,6 @@ #endif -/* - * For 16-bit code, we want to shrink some things even though - * we are using ACPI_DEBUG_OUTPUT to get the debug output - */ -#if ACPI_MACHINE_WIDTH == 16 -#undef ACPI_DEBUG_ONLY_MEMBERS -#undef _VERBOSE_STRUCTURES -#define ACPI_DEBUG_ONLY_MEMBERS(a) -#endif - - #ifdef ACPI_DEBUG_OUTPUT /* * 1) Set name to blanks @@ -813,19 +737,19 @@ /* Memory allocation */ -#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) -#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocate((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) -#define ACPI_MEM_FREE(a) AcpiOsFree(a) +#define ACPI_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) +#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroed((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) +#define ACPI_FREE(a) AcpiOsFree(a) #define ACPI_MEM_TRACKING(a) #else /* Memory allocation */ -#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) -#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocateAndTrack((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) -#define ACPI_MEM_FREE(a) AcpiUtFreeAndTrack(a,_COMPONENT,_AcpiModuleName,__LINE__) -#define ACPI_MEM_TRACKING(a) a +#define ACPI_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) +#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroedAndTrack((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) +#define ACPI_FREE(a) AcpiUtFreeAndTrack(a,_COMPONENT,_AcpiModuleName,__LINE__) +#define ACPI_MEM_TRACKING(a) a #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ diff --git a/sys/dist/acpica/acnames.h b/sys/dist/acpica/acnames.h index 31e3992e9a0..4b1a2fd8d1c 100644 --- a/sys/dist/acpica/acnames.h +++ b/sys/dist/acpica/acnames.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acnames.h - Global names and strings - * xRevision: 1.6 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/dist/acpica/acnamesp.h b/sys/dist/acpica/acnamesp.h index b3b561e1c70..7ac904e864b 100644 --- a/sys/dist/acpica/acnamesp.h +++ b/sys/dist/acpica/acnamesp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acnamesp.h - Namespace subcomponent prototypes and defines - * xRevision: 1.144 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -137,9 +137,15 @@ #define ACPI_NS_DONT_OPEN_SCOPE 0x02 #define ACPI_NS_NO_PEER_SEARCH 0x04 #define ACPI_NS_ERROR_IF_FOUND 0x08 +#define ACPI_NS_PREFIX_IS_SCOPE 0x10 +#define ACPI_NS_EXTERNAL 0x20 +#define ACPI_NS_TEMPORARY 0x40 -#define ACPI_NS_WALK_UNLOCK TRUE -#define ACPI_NS_WALK_NO_UNLOCK FALSE +/* Flags for AcpiNsWalkNamespace */ + +#define ACPI_NS_WALK_NO_UNLOCK 0 +#define ACPI_NS_WALK_UNLOCK 0x01 +#define ACPI_NS_WALK_TEMP_NODES 0x02 /* @@ -163,7 +169,7 @@ AcpiNsLoadNamespace ( ACPI_STATUS AcpiNsLoadTable ( - ACPI_TABLE_DESC *TableDesc, + ACPI_NATIVE_UINT TableIndex, ACPI_NAMESPACE_NODE *Node); @@ -175,7 +181,7 @@ AcpiNsWalkNamespace ( ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, - BOOLEAN UnlockBeforeCallback, + UINT32 Flags, ACPI_WALK_CALLBACK UserFunction, void *Context, void **ReturnValue); @@ -192,13 +198,13 @@ AcpiNsGetNextNode ( */ ACPI_STATUS AcpiNsParseTable ( - ACPI_TABLE_DESC *TableDesc, - ACPI_NAMESPACE_NODE *Scope); + ACPI_NATIVE_UINT TableIndex, + ACPI_NAMESPACE_NODE *StartNode); ACPI_STATUS AcpiNsOneCompleteParse ( - UINT8 PassNumber, - ACPI_TABLE_DESC *TableDesc); + ACPI_NATIVE_UINT PassNumber, + ACPI_NATIVE_UINT TableIndex); /* @@ -297,18 +303,8 @@ AcpiNsDumpObjects ( * nseval - Namespace evaluation functions */ ACPI_STATUS -AcpiNsEvaluateByHandle ( - ACPI_PARAMETER_INFO *Info); - -ACPI_STATUS -AcpiNsEvaluateByName ( - const char *Pathname, - ACPI_PARAMETER_INFO *Info); - -ACPI_STATUS -AcpiNsEvaluateRelative ( - const char *Pathname, - ACPI_PARAMETER_INFO *Info); +AcpiNsEvaluate ( + ACPI_EVALUATE_INFO *Info); /* @@ -318,6 +314,12 @@ UINT32 AcpiNsOpensScope ( ACPI_OBJECT_TYPE Type); +void +AcpiNsBuildExternalPath ( + ACPI_NAMESPACE_NODE *Node, + ACPI_SIZE Size, + char *NameBuffer); + char * AcpiNsGetExternalPathname ( ACPI_NAMESPACE_NODE *Node); @@ -334,12 +336,12 @@ AcpiNsHandleToPathname ( BOOLEAN AcpiNsPatternMatch ( ACPI_NAMESPACE_NODE *ObjNode, - const char *SearchFor); + char *SearchFor); ACPI_STATUS -AcpiNsGetNodeByPath ( +AcpiNsGetNode ( + ACPI_NAMESPACE_NODE *PrefixNode, const char *ExternalPathname, - ACPI_NAMESPACE_NODE *InPrefixNode, UINT32 Flags, ACPI_NAMESPACE_NODE **OutNode); @@ -397,7 +399,7 @@ AcpiNsSearchAndEnter ( ACPI_NAMESPACE_NODE **RetNode); ACPI_STATUS -AcpiNsSearchNode ( +AcpiNsSearchOneScope ( UINT32 EntryName, ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, @@ -430,7 +432,7 @@ void AcpiNsReportError ( const char *ModuleName, UINT32 LineNumber, - const char *InternalName, + char *InternalName, ACPI_STATUS LookupStatus); void @@ -463,7 +465,7 @@ AcpiNsInternalizeName ( ACPI_STATUS AcpiNsExternalizeName ( UINT32 InternalNameLength, - const char *InternalName, + char *InternalName, UINT32 *ConvertedNameLength, char **ConvertedName); diff --git a/sys/dist/acpica/acobject.h b/sys/dist/acpica/acobject.h index 6865c5398db..3bbec9131e0 100644 --- a/sys/dist/acpica/acobject.h +++ b/sys/dist/acpica/acobject.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) - * xRevision: 1.133 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -118,13 +118,23 @@ #ifndef _ACOBJECT_H #define _ACOBJECT_H +/* acpisrc:StructDefs -- for acpisrc conversion */ + /* - * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher + * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher * to the interpreter, and to keep track of the various handlers such as - * address space handlers and notify handlers. The object is a constant + * address space handlers and notify handlers. The object is a constant * size in order to allow it to be cached and reused. + * + * Note: The object is optimized to be aligned and will not work if it is + * byte-packed. */ +#if ACPI_MACHINE_WIDTH == 64 +#pragma pack(8) +#else +#pragma pack(4) +#endif /******************************************************************************* * @@ -135,17 +145,25 @@ /* * Common area for all objects. * - * DataType is used to differentiate between internal descriptors, and MUST - * be the first byte in this structure. + * DescriptorType is used to differentiate between internal descriptors, and + * must be in the same place across all descriptors + * + * Note: The DescriptorType and Type fields must appear in the identical + * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT + * structures. */ -#define ACPI_OBJECT_COMMON_HEADER /* SIZE/ALIGNMENT: 32 bits, one ptr plus trailing 8-bit flag */\ - UINT8 Descriptor; /* To differentiate various internal objs */\ +#define ACPI_OBJECT_COMMON_HEADER \ + union acpi_operand_object *NextObject; /* Objects linked to parent NS node */\ + UINT8 DescriptorType; /* To differentiate various internal objs */\ UINT8 Type; /* ACPI_OBJECT_TYPE */\ UINT16 ReferenceCount; /* For object deletion management */\ - union acpi_operand_object *NextObject; /* Objects linked to parent NS node */\ UINT8 Flags; + /* + * Note: There are 3 bytes available here before the + * next natural alignment boundary (for both 32/64 cases) + */ -/* Values for flag byte above */ +/* Values for Flag byte above */ #define AOPOBJ_AML_CONSTANT 0x01 #define AOPOBJ_STATIC_POINTER 0x02 @@ -153,39 +171,7 @@ #define AOPOBJ_OBJECT_INITIALIZED 0x08 #define AOPOBJ_SETUP_COMPLETE 0x10 #define AOPOBJ_SINGLE_DATUM 0x20 - - -/* - * Common bitfield for the field objects - * "Field Datum" -- a datum from the actual field object - * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field - */ -#define ACPI_COMMON_FIELD_INFO /* SIZE/ALIGNMENT: 24 bits + three 32-bit values */\ - UINT8 FieldFlags; /* Access, update, and lock bits */\ - UINT8 Attribute; /* From AccessAs keyword */\ - UINT8 AccessByteWidth; /* Read/Write size in bytes */\ - UINT32 BitLength; /* Length of field in bits */\ - UINT32 BaseByteOffset; /* Byte offset within containing object */\ - UINT8 StartFieldBitOffset;/* Bit offset within first field datum (0-63) */\ - UINT8 AccessBitWidth; /* Read/Write size in bits (8-64) */\ - UINT32 Value; /* Value to store into the Bank or Index register */\ - ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ - - -/* - * Fields common to both Strings and Buffers - */ -#define ACPI_COMMON_BUFFER_INFO \ - UINT32 Length; - - -/* - * Common fields for objects that support ASL notifications - */ -#define ACPI_COMMON_NOTIFY_INFO \ - union acpi_operand_object *SystemNotify; /* Handler for system notifies */\ - union acpi_operand_object *DeviceNotify; /* Handler for driver notifies */\ - union acpi_operand_object *Handler; /* Handler for Address space */ +#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an OpRegion address */ /****************************************************************************** @@ -204,6 +190,7 @@ typedef struct acpi_object_common typedef struct acpi_object_integer { ACPI_OBJECT_COMMON_HEADER + UINT8 Fill[3]; /* Prevent warning on some compilers */ ACPI_INTEGER Value; } ACPI_OBJECT_INTEGER; @@ -211,13 +198,19 @@ typedef struct acpi_object_integer /* * Note: The String and Buffer object must be identical through the Pointer - * element. There is code that depends on this. + * and length elements. There is code that depends on this. + * + * Fields common to both Strings and Buffers */ +#define ACPI_COMMON_BUFFER_INFO(_Type) \ + _Type *Pointer; \ + UINT32 Length; + + typedef struct acpi_object_string /* Null terminated, ASCII characters only */ { ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_BUFFER_INFO - char *Pointer; /* String in AML stream or allocated string */ + ACPI_COMMON_BUFFER_INFO (char) /* String in AML stream or allocated string */ } ACPI_OBJECT_STRING; @@ -225,11 +218,10 @@ typedef struct acpi_object_string /* Null terminated, ASCII characters only */ typedef struct acpi_object_buffer { ACPI_OBJECT_COMMON_HEADER - ACPI_COMMON_BUFFER_INFO - UINT8 *Pointer; /* Buffer in AML stream or allocated buffer */ - ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ - UINT8 *AmlStart; + ACPI_COMMON_BUFFER_INFO (UINT8) /* Buffer in AML stream or allocated buffer */ UINT32 AmlLength; + UINT8 *AmlStart; + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ } ACPI_OBJECT_BUFFER; @@ -237,12 +229,11 @@ typedef struct acpi_object_buffer typedef struct acpi_object_package { ACPI_OBJECT_COMMON_HEADER - - UINT32 Count; /* # of elements in package */ - UINT32 AmlLength; - UINT8 *AmlStart; ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ union acpi_operand_object **Elements; /* Array of pointers to AcpiObjects */ + UINT8 *AmlStart; + UINT32 AmlLength; + UINT32 Count; /* # of elements in package */ } ACPI_OBJECT_PACKAGE; @@ -256,40 +247,19 @@ typedef struct acpi_object_package typedef struct acpi_object_event { ACPI_OBJECT_COMMON_HEADER - void *Semaphore; + ACPI_SEMAPHORE OsSemaphore; /* Actual OS synchronization object */ } ACPI_OBJECT_EVENT; -#define ACPI_INFINITE_CONCURRENCY 0xFF - -typedef -ACPI_STATUS (*ACPI_INTERNAL_METHOD) ( - struct acpi_walk_state *WalkState); - -typedef struct acpi_object_method -{ - ACPI_OBJECT_COMMON_HEADER - UINT8 MethodFlags; - UINT8 ParamCount; - UINT32 AmlLength; - void *Semaphore; - UINT8 *AmlStart; - ACPI_INTERNAL_METHOD Implementation; - UINT8 Concurrency; - UINT8 ThreadCount; - ACPI_OWNER_ID OwnerId; - -} ACPI_OBJECT_METHOD; - - typedef struct acpi_object_mutex { ACPI_OBJECT_COMMON_HEADER UINT8 SyncLevel; /* 0-15, specified in Mutex() call */ UINT16 AcquisitionDepth; /* Allow multiple Acquires, same thread */ + ACPI_MUTEX OsMutex; /* Actual OS synchronization object */ + ACPI_THREAD_ID ThreadId; /* Current owner of the mutex */ struct acpi_thread_state *OwnerThread; /* Current owner of the mutex */ - void *Semaphore; /* Actual OS synchronization object */ union acpi_operand_object *Prev; /* Link for list of acquired mutexes */ union acpi_operand_object *Next; /* Link for list of acquired mutexes */ ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ @@ -301,23 +271,47 @@ typedef struct acpi_object_mutex typedef struct acpi_object_region { ACPI_OBJECT_COMMON_HEADER - UINT8 SpaceId; - union acpi_operand_object *Handler; /* Handler for region access */ ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ + union acpi_operand_object *Handler; /* Handler for region access */ union acpi_operand_object *Next; - UINT32 Length; ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; } ACPI_OBJECT_REGION; +typedef struct acpi_object_method +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 MethodFlags; + UINT8 ParamCount; + UINT8 SyncLevel; + union acpi_operand_object *Mutex; + UINT8 *AmlStart; + ACPI_INTERNAL_METHOD Implementation; + UINT32 AmlLength; + UINT8 ThreadCount; + ACPI_OWNER_ID OwnerId; + +} ACPI_OBJECT_METHOD; + + /****************************************************************************** * * Objects that can be notified. All share a common NotifyInfo area. * *****************************************************************************/ +/* + * Common fields for objects that support ASL notifications + */ +#define ACPI_COMMON_NOTIFY_INFO \ + union acpi_operand_object *SystemNotify; /* Handler for system notifies */\ + union acpi_operand_object *DeviceNotify; /* Handler for driver notifies */\ + union acpi_operand_object *Handler; /* Handler for Address space */ + + typedef struct acpi_object_notify_common /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ { ACPI_OBJECT_COMMON_HEADER @@ -348,9 +342,12 @@ typedef struct acpi_object_power_resource typedef struct acpi_object_processor { ACPI_OBJECT_COMMON_HEADER + + /* The next two fields take advantage of the 3-byte space before NOTIFY_INFO */ + + UINT8 ProcId; + UINT8 Length; ACPI_COMMON_NOTIFY_INFO - UINT32 ProcId; - UINT32 Length; ACPI_IO_ADDRESS Address; } ACPI_OBJECT_PROCESSOR; @@ -370,12 +367,29 @@ typedef struct acpi_object_thermal_zone * *****************************************************************************/ +/* + * Common bitfield for the field objects + * "Field Datum" -- a datum from the actual field object + * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field + */ +#define ACPI_COMMON_FIELD_INFO \ + UINT8 FieldFlags; /* Access, update, and lock bits */\ + UINT8 Attribute; /* From AccessAs keyword */\ + UINT8 AccessByteWidth; /* Read/Write size in bytes */\ + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */\ + UINT32 BitLength; /* Length of field in bits */\ + UINT32 BaseByteOffset; /* Byte offset within containing object */\ + UINT32 Value; /* Value to store into the Bank or Index register */\ + UINT8 StartFieldBitOffset;/* Bit offset within first field datum (0-63) */\ + UINT8 AccessBitWidth; /* Read/Write size in bits (8-64) */ + + typedef struct acpi_object_field_common /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO - union acpi_operand_object *RegionObj; /* Containing Operation Region object */ - /* (REGION/BANK fields only) */ + union acpi_operand_object *RegionObj; /* Parent Operation Region object (REGION/BANK fields only) */ + } ACPI_OBJECT_FIELD_COMMON; @@ -440,16 +454,11 @@ typedef struct acpi_object_notify_handler } ACPI_OBJECT_NOTIFY_HANDLER; -/* Flags for address handler */ - -#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x1 - - typedef struct acpi_object_addr_handler { ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId; - UINT16 Hflags; + UINT8 HandlerFlags; ACPI_ADR_SPACE_HANDLER Handler; ACPI_NAMESPACE_NODE *Node; /* Parent device */ void *Context; @@ -459,6 +468,10 @@ typedef struct acpi_object_addr_handler } ACPI_OBJECT_ADDR_HANDLER; +/* Flags for address handler (HandlerFlags) */ + +#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x01 + /****************************************************************************** * @@ -475,10 +488,10 @@ typedef struct acpi_object_reference ACPI_OBJECT_COMMON_HEADER UINT8 TargetType; /* Used for IndexOp */ UINT16 Opcode; - UINT32 Offset; /* Used for ArgOp, LocalOp, and IndexOp */ void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ ACPI_NAMESPACE_NODE *Node; union acpi_operand_object **Where; + UINT32 Offset; /* Used for ArgOp, LocalOp, and IndexOp */ } ACPI_OBJECT_REFERENCE; @@ -493,12 +506,10 @@ typedef struct acpi_object_reference typedef struct acpi_object_extra { ACPI_OBJECT_COMMON_HEADER - UINT8 ByteFill1; - UINT16 WordFill1; - UINT32 AmlLength; - UINT8 *AmlStart; ACPI_NAMESPACE_NODE *Method_REG; /* _REG method for this region (if any) */ void *RegionContext; /* Region-specific data */ + UINT8 *AmlStart; + UINT32 AmlLength; } ACPI_OBJECT_EXTRA; @@ -532,31 +543,31 @@ typedef struct acpi_object_cache_list typedef union acpi_operand_object { - ACPI_OBJECT_COMMON Common; - ACPI_OBJECT_INTEGER Integer; - ACPI_OBJECT_STRING String; - ACPI_OBJECT_BUFFER Buffer; - ACPI_OBJECT_PACKAGE Package; - ACPI_OBJECT_EVENT Event; - ACPI_OBJECT_METHOD Method; - ACPI_OBJECT_MUTEX Mutex; - ACPI_OBJECT_REGION Region; - ACPI_OBJECT_NOTIFY_COMMON CommonNotify; - ACPI_OBJECT_DEVICE Device; - ACPI_OBJECT_POWER_RESOURCE PowerResource; - ACPI_OBJECT_PROCESSOR Processor; - ACPI_OBJECT_THERMAL_ZONE ThermalZone; - ACPI_OBJECT_FIELD_COMMON CommonField; - ACPI_OBJECT_REGION_FIELD Field; - ACPI_OBJECT_BUFFER_FIELD BufferField; - ACPI_OBJECT_BANK_FIELD BankField; - ACPI_OBJECT_INDEX_FIELD IndexField; - ACPI_OBJECT_NOTIFY_HANDLER Notify; - ACPI_OBJECT_ADDR_HANDLER AddressSpace; - ACPI_OBJECT_REFERENCE Reference; - ACPI_OBJECT_EXTRA Extra; - ACPI_OBJECT_DATA Data; - ACPI_OBJECT_CACHE_LIST Cache; + ACPI_OBJECT_COMMON Common; + ACPI_OBJECT_INTEGER Integer; + ACPI_OBJECT_STRING String; + ACPI_OBJECT_BUFFER Buffer; + ACPI_OBJECT_PACKAGE Package; + ACPI_OBJECT_EVENT Event; + ACPI_OBJECT_METHOD Method; + ACPI_OBJECT_MUTEX Mutex; + ACPI_OBJECT_REGION Region; + ACPI_OBJECT_NOTIFY_COMMON CommonNotify; + ACPI_OBJECT_DEVICE Device; + ACPI_OBJECT_POWER_RESOURCE PowerResource; + ACPI_OBJECT_PROCESSOR Processor; + ACPI_OBJECT_THERMAL_ZONE ThermalZone; + ACPI_OBJECT_FIELD_COMMON CommonField; + ACPI_OBJECT_REGION_FIELD Field; + ACPI_OBJECT_BUFFER_FIELD BufferField; + ACPI_OBJECT_BANK_FIELD BankField; + ACPI_OBJECT_INDEX_FIELD IndexField; + ACPI_OBJECT_NOTIFY_HANDLER Notify; + ACPI_OBJECT_ADDR_HANDLER AddressSpace; + ACPI_OBJECT_REFERENCE Reference; + ACPI_OBJECT_EXTRA Extra; + ACPI_OBJECT_DATA Data; + ACPI_OBJECT_CACHE_LIST Cache; } ACPI_OPERAND_OBJECT; @@ -587,14 +598,22 @@ typedef union acpi_operand_object #define ACPI_DESC_TYPE_MAX 0x0F +typedef struct acpi_common_descriptor +{ + void *CommonPointer; + UINT8 DescriptorType; /* To differentiate various internal objs */ + +} ACPI_COMMON_DESCRIPTOR; + typedef union acpi_descriptor { - UINT8 DescriptorId; /* To differentiate various internal objs */ + ACPI_COMMON_DESCRIPTOR Common; ACPI_OPERAND_OBJECT Object; ACPI_NAMESPACE_NODE Node; ACPI_PARSE_OBJECT Op; } ACPI_DESCRIPTOR; +#pragma pack() #endif /* _ACOBJECT_H */ diff --git a/sys/dist/acpica/acopcode.h b/sys/dist/acpica/acopcode.h index 1aec2499720..87a6b3af853 100644 --- a/sys/dist/acpica/acopcode.h +++ b/sys/dist/acpica/acopcode.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acopcode.h - AML opcode information for the AML parser and interpreter - * xRevision: 1.4 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -168,7 +168,7 @@ #define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) #define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) #define ARGP_CONTINUE_OP ARG_NONE -#define ARGP_COPY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SIMPLENAME) +#define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME) #define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) #define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) #define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) @@ -332,7 +332,7 @@ #define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE #define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE -#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_FIELD,ARGI_TARGETREF) +#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_BUFFER,ARGI_TARGETREF) #define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE) #define ARGI_LOCAL0 ARG_NONE #define ARGI_LOCAL1 ARG_NONE diff --git a/sys/dist/acpica/acoutput.h b/sys/dist/acpica/acoutput.h index b2e294459cc..a12efb87d3d 100644 --- a/sys/dist/acpica/acoutput.h +++ b/sys/dist/acpica/acoutput.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acoutput.h -- debug output - * xRevision: 1.99 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -220,7 +220,7 @@ /* * These two levels are essentially obsolete, all instances in the - * ACPICA core code have been replaced by REPORT_ERROR and REPORT_WARNING + * ACPICA core code have been replaced by ACPI_ERROR and ACPI_WARNING * (Kept here because some drivers may still use them) */ #define ACPI_DB_ERROR ACPI_DEBUG_LEVEL (ACPI_LV_ERROR) diff --git a/sys/dist/acpica/acparser.h b/sys/dist/acpica/acparser.h index cefbc3a6e19..fdd8919fa8f 100644 --- a/sys/dist/acpica/acparser.h +++ b/sys/dist/acpica/acparser.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: acparser.h - AML Parser subcomponent prototypes and defines - * xRevision: 1.78 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -121,7 +121,7 @@ #define OP_HAS_RETURN_VALUE 1 -/* variable # arguments */ +/* Variable number of arguments. This field must be 32 bits */ #define ACPI_VAR_ARGS ACPI_UINT32_MAX @@ -151,7 +151,7 @@ */ ACPI_STATUS AcpiPsExecuteMethod ( - ACPI_PARAMETER_INFO *Info); + ACPI_EVALUATE_INFO *Info); /* @@ -211,6 +211,10 @@ const char * AcpiPsGetOpcodeName ( UINT16 Opcode); +UINT8 +AcpiPsGetArgumentCount ( + UINT32 OpType); + /* * psparse - top level parsing routines diff --git a/sys/dist/acpica/acpi.h b/sys/dist/acpica/acpi.h index 3a451ea0520..8290b11c0ca 100644 --- a/sys/dist/acpica/acpi.h +++ b/sys/dist/acpica/acpi.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acpi.h - Master include file, Publics and external data. - * xRevision: 1.60 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -122,22 +122,22 @@ * We put them here because we don't want to duplicate them * in the rest of the source code again and again. */ -#include "acnames.h" /* Global ACPI names and strings */ -#include "acconfig.h" /* Configuration constants */ -#include "acenv.h" /* Target environment specific items */ -#include "actypes.h" /* Fundamental common data types */ -#include "acexcep.h" /* ACPI exception codes */ -#include "acmacros.h" /* C macros */ -#include "actbl.h" /* ACPI table definitions */ -#include "aclocal.h" /* Internal data types */ -#include "acoutput.h" /* Error output and Debug macros */ -#include "acpiosxf.h" /* Interfaces to the ACPI-to-OS layer*/ -#include "acpixf.h" /* ACPI core subsystem external interfaces */ -#include "acobject.h" /* ACPI internal object */ -#include "acstruct.h" /* Common structures */ -#include "acglobal.h" /* All global variables */ -#include "achware.h" /* Hardware defines and interfaces */ -#include "acutils.h" /* Utility interfaces */ +#include <dist/acpica/acnames.h> /* Global ACPI names and strings */ +#include <dist/acpica/acconfig.h> /* Configuration constants */ +#include <dist/acpica/acenv.h> /* Target environment specific items */ +#include <dist/acpica/actypes.h> /* Fundamental common data types */ +#include <dist/acpica/acexcep.h> /* ACPI exception codes */ +#include <dist/acpica/acmacros.h> /* C macros */ +#include <dist/acpica/actbl.h> /* ACPI table definitions */ +#include <dist/acpica/aclocal.h> /* Internal data types */ +#include <dist/acpica/acoutput.h> /* Error output and Debug macros */ +#include <dist/acpica/acpiosxf.h> /* Interfaces to the ACPI-to-OS layer*/ +#include <dist/acpica/acpixf.h> /* ACPI core subsystem external interfaces */ +#include <dist/acpica/acobject.h> /* ACPI internal object */ +#include <dist/acpica/acstruct.h> /* Common structures */ +#include <dist/acpica/acglobal.h> /* All global variables */ +#include <dist/acpica/achware.h> /* Hardware defines and interfaces */ +#include <dist/acpica/acutils.h> /* Utility interfaces */ #endif /* __ACPI_H__ */ diff --git a/sys/dist/acpica/acpiosxf.h b/sys/dist/acpica/acpiosxf.h index bcab3259751..4abe14686f2 100644 --- a/sys/dist/acpica/acpiosxf.h +++ b/sys/dist/acpica/acpiosxf.h @@ -12,7 +12,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -121,16 +121,22 @@ #ifndef __ACPIOSXF_H__ #define __ACPIOSXF_H__ -#include "acenv.h" -#include "actypes.h" +#include <dist/acpica/acenv.h> +#include <dist/acpica/actypes.h> -/* Priorities for AcpiOsQueueForExecution */ +/* Types for AcpiOsExecute */ -#define OSD_PRIORITY_GPE 1 -#define OSD_PRIORITY_HIGH 2 -#define OSD_PRIORITY_MED 3 -#define OSD_PRIORITY_LO 4 +typedef enum +{ + OSL_GLOBAL_LOCK_HANDLER, + OSL_NOTIFY_HANDLER, + OSL_GPE_HANDLER, + OSL_DEBUGGER_THREAD, + OSL_EC_POLL_HANDLER, + OSL_EC_BURST_HANDLER + +} ACPI_EXECUTE_TYPE; #define ACPI_NO_UNIT_LIMIT ((UINT32) -1) #define ACPI_MUTEX_SEM 1 @@ -165,10 +171,9 @@ AcpiOsTerminate ( /* * ACPI Table interfaces */ -ACPI_STATUS +ACPI_PHYSICAL_ADDRESS AcpiOsGetRootPointer ( - UINT32 Flags, - ACPI_POINTER *Address); + void); ACPI_STATUS AcpiOsPredefinedOverride ( @@ -182,45 +187,77 @@ AcpiOsTableOverride ( /* - * Synchronization primitives + * Spinlock primitives + */ +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle); + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle); + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_SPINLOCK Handle); + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags); + + +/* + * Semaphore primitives */ ACPI_STATUS AcpiOsCreateSemaphore ( UINT32 MaxUnits, UINT32 InitialUnits, - ACPI_HANDLE *OutHandle); + ACPI_SEMAPHORE *OutHandle); ACPI_STATUS AcpiOsDeleteSemaphore ( - ACPI_HANDLE Handle); + ACPI_SEMAPHORE Handle); ACPI_STATUS AcpiOsWaitSemaphore ( - ACPI_HANDLE Handle, + ACPI_SEMAPHORE Handle, UINT32 Units, UINT16 Timeout); ACPI_STATUS AcpiOsSignalSemaphore ( - ACPI_HANDLE Handle, + ACPI_SEMAPHORE Handle, UINT32 Units); + +/* + * Mutex primitives + */ ACPI_STATUS -AcpiOsCreateLock ( - ACPI_HANDLE *OutHandle); +AcpiOsCreateMutex ( + ACPI_MUTEX *OutHandle); void -AcpiOsDeleteLock ( - ACPI_HANDLE Handle); +AcpiOsDeleteMutex ( + ACPI_MUTEX Handle); -ACPI_CPU_FLAGS -AcpiOsAcquireLock ( - ACPI_HANDLE Handle); +ACPI_STATUS +AcpiOsAcquireMutex ( + ACPI_MUTEX Handle, + UINT16 Timeout); void -AcpiOsReleaseLock ( - ACPI_HANDLE Handle, - ACPI_CPU_FLAGS Flags); +AcpiOsReleaseMutex ( + ACPI_MUTEX Handle); + +/* Temporary macros for Mutex* interfaces, map to existing semaphore xfaces */ + +#define AcpiOsCreateMutex(OutHandle) AcpiOsCreateSemaphore (1, 1, OutHandle) +#define AcpiOsDeleteMutex(Handle) (void) AcpiOsDeleteSemaphore (Handle) +#define AcpiOsAcquireMutex(Handle,Time) AcpiOsWaitSemaphore (Handle, 1, Time) +#define AcpiOsReleaseMutex(Handle) (void) AcpiOsSignalSemaphore (Handle, 1) /* @@ -232,13 +269,12 @@ AcpiOsAllocate ( void AcpiOsFree ( - void * Memory); + void * Memory); -ACPI_STATUS +void * AcpiOsMapMemory ( - ACPI_PHYSICAL_ADDRESS PhysicalAddress, - ACPI_SIZE Size, - void **LogicalAddress); + ACPI_PHYSICAL_ADDRESS Where, + ACPI_NATIVE_UINT Length); void AcpiOsUnmapMemory ( @@ -297,13 +333,13 @@ AcpiOsRemoveInterruptHandler ( /* * Threads and Scheduling */ -UINT32 +ACPI_THREAD_ID AcpiOsGetThreadId ( void); ACPI_STATUS -AcpiOsQueueForExecution ( - UINT32 Priority, +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function, void *Context); @@ -371,6 +407,7 @@ AcpiOsWritePciConfiguration ( ACPI_INTEGER Value, UINT32 Width); + /* * Interim function needed for PCI IRQ routing */ @@ -380,9 +417,20 @@ AcpiOsDerivePciId( ACPI_HANDLE Chandle, ACPI_PCI_ID **PciId); + /* * Miscellaneous */ +ACPI_STATUS +AcpiOsValidateInterface ( + char *Interface); + +ACPI_STATUS +AcpiOsValidateAddress ( + UINT8 SpaceId, + ACPI_PHYSICAL_ADDRESS Address, + ACPI_SIZE Length); + BOOLEAN AcpiOsReadable ( void *Pointer, @@ -402,6 +450,7 @@ AcpiOsSignal ( UINT32 Function, const void *Info); + /* * Debug print routines */ @@ -451,14 +500,5 @@ void AcpiOsCloseDirectory ( void *DirHandle); -/* - * Debug - */ -void -AcpiOsDbgAssert( - void *FailedAssertion, - void *FileName, - UINT32 LineNumber, - char *Message); #endif /* __ACPIOSXF_H__ */ diff --git a/sys/dist/acpica/acpixf.h b/sys/dist/acpica/acpixf.h index 7e2fb4c514c..c178d3df833 100644 --- a/sys/dist/acpica/acpixf.h +++ b/sys/dist/acpica/acpixf.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -118,14 +118,20 @@ #ifndef __ACXFACE_H__ #define __ACXFACE_H__ -#include "actypes.h" -#include "actbl.h" +#include <dist/acpica/actypes.h> +#include <dist/acpica/actbl.h> /* * Global interfaces */ ACPI_STATUS +AcpiInitializeTables ( + ACPI_TABLE_DESC *InitialStorage, + UINT32 InitialTableCount, + BOOLEAN AllowResize); + +ACPI_STATUS AcpiInitializeSubsystem ( void); @@ -190,40 +196,33 @@ AcpiFree ( * ACPI table manipulation interfaces */ ACPI_STATUS -AcpiFindRootPointer ( - UINT32 Flags, - ACPI_POINTER *RsdpAddress); - -ACPI_STATUS -AcpiLoadTables ( +AcpiReallocateRootTable ( void); ACPI_STATUS -AcpiLoadTable ( - ACPI_TABLE_HEADER *TablePtr); +AcpiFindRootPointer ( + ACPI_NATIVE_UINT *RsdpAddress); ACPI_STATUS -AcpiUnloadTable ( - ACPI_TABLE_TYPE TableType); +AcpiLoadTables ( + void); ACPI_STATUS AcpiGetTableHeader ( - ACPI_TABLE_TYPE TableType, - UINT32 Instance, + ACPI_CONST_STRING Signature, + ACPI_NATIVE_UINT Instance, ACPI_TABLE_HEADER *OutTableHeader); ACPI_STATUS AcpiGetTable ( - ACPI_TABLE_TYPE TableType, - UINT32 Instance, - ACPI_BUFFER *RetBuffer); + ACPI_CONST_STRING Signature, + ACPI_NATIVE_UINT Instance, + ACPI_TABLE_HEADER **OutTable); ACPI_STATUS -AcpiGetFirmwareTable ( - ACPI_CONST_STRING Signature, - UINT32 Instance, - UINT32 Flags, - ACPI_TABLE_HEADER **TablePointer); +AcpiGetTableByIndex ( + ACPI_NATIVE_UINT TableIndex, + ACPI_TABLE_HEADER **OutTable); /* @@ -510,14 +509,12 @@ AcpiResourceToAddress64 ( ACPI_STATUS AcpiGetRegister ( UINT32 RegisterId, - UINT32 *ReturnValue, - UINT32 Flags); + UINT32 *ReturnValue); ACPI_STATUS AcpiSetRegister ( UINT32 RegisterId, - UINT32 Value, - UINT32 Flags); + UINT32 Value); ACPI_STATUS AcpiSetFirmwareWakingVector ( diff --git a/sys/dist/acpica/acresrc.h b/sys/dist/acpica/acresrc.h index aba87b30eae..14f6df8adaa 100644 --- a/sys/dist/acpica/acresrc.h +++ b/sys/dist/acpica/acresrc.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acresrc.h - Resource Manager function prototypes - * xRevision: 1.56 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -120,14 +120,18 @@ /* Need the AML resource descriptor structs */ -#include "amlresrc.h" +#include <dist/acpica/amlresrc.h> /* * If possible, pack the following structures to byte alignment, since we - * don't care about performance for debug output + * don't care about performance for debug output. Two cases where we cannot + * pack the structures: + * + * 1) Hardware does not support misaligned memory transfers + * 2) Compiler does not support pointers within packed structures */ -#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) #pragma pack(1) #endif @@ -253,17 +257,17 @@ AcpiRsCreatePciRoutingTable ( */ ACPI_STATUS AcpiRsGetPrtMethodData ( - ACPI_HANDLE Handle, + ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer); ACPI_STATUS AcpiRsGetCrsMethodData ( - ACPI_HANDLE Handle, + ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer); ACPI_STATUS AcpiRsGetPrsMethodData ( - ACPI_HANDLE Handle, + ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer); ACPI_STATUS @@ -274,7 +278,7 @@ AcpiRsGetMethodData ( ACPI_STATUS AcpiRsSetSrsMethodData ( - ACPI_HANDLE Handle, + ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer); @@ -299,9 +303,11 @@ AcpiRsGetPciRoutingTableLength ( ACPI_STATUS AcpiRsConvertAmlToResources ( - UINT8 *AmlBuffer, - UINT32 AmlBufferLength, - UINT8 *OutputBuffer); + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context); ACPI_STATUS AcpiRsConvertResourcesToAml ( diff --git a/sys/dist/acpica/acstruct.h b/sys/dist/acpica/acstruct.h index 626bdf41a38..ba1532a401f 100644 --- a/sys/dist/acpica/acstruct.h +++ b/sys/dist/acpica/acstruct.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acstruct.h - Internal structs - * xRevision: 1.39 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +117,7 @@ #ifndef __ACSTRUCT_H__ #define __ACSTRUCT_H__ +/* acpisrc:StructDefs -- for acpisrc conversion */ /***************************************************************************** * @@ -126,68 +127,81 @@ /* - * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through - * the tree (for whatever reason), and for control method execution. + * Walk state - current state of a parse tree walk. Used for both a leisurely + * stroll through the tree (for whatever reason), and for control method + * execution. */ #define ACPI_NEXT_OP_DOWNWARD 1 #define ACPI_NEXT_OP_UPWARD 2 +/* + * Groups of definitions for WalkType used for different implementations of + * walkers (never simultaneously) - flags for interpreter: + */ #define ACPI_WALK_NON_METHOD 0 -#define ACPI_WALK_METHOD 1 -#define ACPI_WALK_METHOD_RESTART 2 -#define ACPI_WALK_CONST_REQUIRED 3 -#define ACPI_WALK_CONST_OPTIONAL 4 +#define ACPI_WALK_METHOD 0x01 +#define ACPI_WALK_METHOD_RESTART 0x02 + +/* Flags for iASL compiler only */ + +#define ACPI_WALK_CONST_REQUIRED 0x10 +#define ACPI_WALK_CONST_OPTIONAL 0x20 + typedef struct acpi_walk_state { - UINT8 DataType; /* To differentiate various internal objs MUST BE FIRST!*/ - UINT8 WalkType; - ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ - BOOLEAN LastPredicate; /* Result of last predicate */ - UINT8 CurrentResult; /* */ - UINT8 NextOpInfo; /* Info about NextOp */ - UINT8 NumOperands; /* Stack pointer for Operands[] array */ - UINT8 ReturnUsed; - UINT16 Opcode; /* Current AML opcode */ - UINT8 ScopeDepth; - UINT8 PassNumber; /* Parse pass during table load */ - UINT32 ArgCount; /* push for fixed or var args */ - UINT32 AmlOffset; - UINT32 ArgTypes; - UINT32 MethodBreakpoint; /* For single stepping */ - UINT32 UserBreakpoint; /* User AML breakpoint */ - UINT32 ParseFlags; - UINT32 PrevArgTypes; - - UINT8 *AmlLastWhile; - struct acpi_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ - union acpi_operand_object **CallerReturnDesc; - ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ - struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ - struct acpi_gpe_event_info *GpeEventInfo; /* Info for GPE (_Lxx/_Exx methods only */ - union acpi_operand_object *ImplicitReturnObj; - struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ - struct acpi_namespace_node *MethodCallNode; /* Called method Node*/ - ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ - union acpi_operand_object *MethodDesc; /* Method descriptor if running a method */ - struct acpi_namespace_node *MethodNode; /* Method node if running a method. */ - ACPI_PARSE_OBJECT *Op; /* Current parser op */ - union acpi_operand_object *Operands[ACPI_OBJ_NUM_OPERANDS+1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ - const ACPI_OPCODE_INFO *OpInfo; /* Info on current opcode */ - ACPI_PARSE_OBJECT *Origin; /* Start of walk [Obsolete] */ - union acpi_operand_object **Params; - ACPI_PARSE_STATE ParserState; /* Current state of parser */ - union acpi_operand_object *ResultObj; - ACPI_GENERIC_STATE *Results; /* Stack of accumulated results */ - union acpi_operand_object *ReturnDesc; /* Return object, if any */ - ACPI_GENERIC_STATE *ScopeInfo; /* Stack of nested scopes */ - - ACPI_PARSE_OBJECT *PrevOp; /* Last op that was processed */ - ACPI_PARSE_OBJECT *NextOp; /* next op to be processed */ - ACPI_PARSE_DOWNWARDS DescendingCallback; - ACPI_PARSE_UPWARDS AscendingCallback; - ACPI_THREAD_STATE *Thread; - struct acpi_walk_state *Next; /* Next WalkState in list */ + struct acpi_walk_state *Next; /* Next WalkState in list */ + UINT8 DescriptorType; /* To differentiate various internal objs */ + UINT8 WalkType; + UINT16 Opcode; /* Current AML opcode */ + UINT8 NextOpInfo; /* Info about NextOp */ + UINT8 NumOperands; /* Stack pointer for Operands[] array */ + UINT8 OperandIndex; /* Index into operand stack, to be used by AcpiDsObjStackPush */ + ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ + BOOLEAN LastPredicate; /* Result of last predicate */ + UINT8 CurrentResult; + UINT8 ReturnUsed; + UINT8 ScopeDepth; + UINT8 PassNumber; /* Parse pass during table load */ + UINT8 ResultSize; /* Total elements for the result stack */ + UINT8 ResultCount; /* Current number of occupied elements of result stack */ + UINT32 AmlOffset; + UINT32 ArgTypes; + UINT32 MethodBreakpoint; /* For single stepping */ + UINT32 UserBreakpoint; /* User AML breakpoint */ + UINT32 ParseFlags; + + ACPI_PARSE_STATE ParserState; /* Current state of parser */ + UINT32 PrevArgTypes; + UINT32 ArgCount; /* push for fixed or var args */ + + struct acpi_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ + struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ + union acpi_operand_object *Operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ + union acpi_operand_object **Params; + + UINT8 *AmlLastWhile; + union acpi_operand_object **CallerReturnDesc; + ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ + struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ + struct acpi_gpe_event_info *GpeEventInfo; /* Info for GPE (_Lxx/_Exx methods only */ + union acpi_operand_object *ImplicitReturnObj; + struct acpi_namespace_node *MethodCallNode; /* Called method Node*/ + ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ + union acpi_operand_object *MethodDesc; /* Method descriptor if running a method */ + struct acpi_namespace_node *MethodNode; /* Method node if running a method. */ + ACPI_PARSE_OBJECT *Op; /* Current parser op */ + const ACPI_OPCODE_INFO *OpInfo; /* Info on current opcode */ + ACPI_PARSE_OBJECT *Origin; /* Start of walk [Obsolete] */ + union acpi_operand_object *ResultObj; + ACPI_GENERIC_STATE *Results; /* Stack of accumulated results */ + union acpi_operand_object *ReturnDesc; /* Return object, if any */ + ACPI_GENERIC_STATE *ScopeInfo; /* Stack of nested scopes */ + ACPI_PARSE_OBJECT *PrevOp; /* Last op that was processed */ + ACPI_PARSE_OBJECT *NextOp; /* next op to be processed */ + ACPI_THREAD_STATE *Thread; + ACPI_PARSE_DOWNWARDS DescendingCallback; + ACPI_PARSE_UPWARDS AscendingCallback; } ACPI_WALK_STATE; @@ -196,112 +210,124 @@ typedef struct acpi_walk_state typedef struct acpi_init_walk_info { - UINT16 MethodCount; - UINT16 DeviceCount; - UINT16 OpRegionCount; - UINT16 FieldCount; - UINT16 BufferCount; - UINT16 PackageCount; - UINT16 OpRegionInit; - UINT16 FieldInit; - UINT16 BufferInit; - UINT16 PackageInit; - UINT16 ObjectCount; - ACPI_TABLE_DESC *TableDesc; + UINT16 MethodCount; + UINT16 DeviceCount; + UINT16 OpRegionCount; + UINT16 FieldCount; + UINT16 BufferCount; + UINT16 PackageCount; + UINT16 OpRegionInit; + UINT16 FieldInit; + UINT16 BufferInit; + UINT16 PackageInit; + UINT16 ObjectCount; + ACPI_OWNER_ID OwnerId; + ACPI_NATIVE_UINT TableIndex; } ACPI_INIT_WALK_INFO; -/* Info used by AcpiNsInitializeDevices */ - -typedef struct acpi_device_walk_info -{ - UINT16 DeviceCount; - UINT16 Num_STA; - UINT16 Num_INI; - ACPI_TABLE_DESC *TableDesc; - -} ACPI_DEVICE_WALK_INFO; - - -/* TBD: [Restructure] Merge with struct above */ - -typedef struct acpi_walk_info -{ - UINT32 DebugLevel; - UINT32 Count; - ACPI_OWNER_ID OwnerId; - UINT8 DisplayType; - -} ACPI_WALK_INFO; - -/* Display Types */ - -#define ACPI_DISPLAY_SUMMARY (UINT8) 0 -#define ACPI_DISPLAY_OBJECTS (UINT8) 1 -#define ACPI_DISPLAY_MASK (UINT8) 1 - -#define ACPI_DISPLAY_SHORT (UINT8) 2 - typedef struct acpi_get_devices_info { - ACPI_WALK_CALLBACK UserFunction; - void *Context; - char *Hid; + ACPI_WALK_CALLBACK UserFunction; + void *Context; + char *Hid; } ACPI_GET_DEVICES_INFO; typedef union acpi_aml_operands { - ACPI_OPERAND_OBJECT *Operands[7]; + ACPI_OPERAND_OBJECT *Operands[7]; struct { - ACPI_OBJECT_INTEGER *Type; - ACPI_OBJECT_INTEGER *Code; - ACPI_OBJECT_INTEGER *Argument; + ACPI_OBJECT_INTEGER *Type; + ACPI_OBJECT_INTEGER *Code; + ACPI_OBJECT_INTEGER *Argument; } Fatal; struct { - ACPI_OPERAND_OBJECT *Source; - ACPI_OBJECT_INTEGER *Index; - ACPI_OPERAND_OBJECT *Target; + ACPI_OPERAND_OBJECT *Source; + ACPI_OBJECT_INTEGER *Index; + ACPI_OPERAND_OBJECT *Target; } Index; struct { - ACPI_OPERAND_OBJECT *Source; - ACPI_OBJECT_INTEGER *Index; - ACPI_OBJECT_INTEGER *Length; - ACPI_OPERAND_OBJECT *Target; + ACPI_OPERAND_OBJECT *Source; + ACPI_OBJECT_INTEGER *Index; + ACPI_OBJECT_INTEGER *Length; + ACPI_OPERAND_OBJECT *Target; } Mid; } ACPI_AML_OPERANDS; -/* Internal method parameter list */ - -typedef struct acpi_parameter_info +/* + * Structure used to pass object evaluation parameters. + * Purpose is to reduce CPU stack use. + */ +typedef struct acpi_evaluate_info { - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT **Parameters; - ACPI_OPERAND_OBJECT *ReturnObject; - UINT8 PassNumber; - UINT8 ParameterType; - UINT8 ReturnObjectType; - -} ACPI_PARAMETER_INFO; + ACPI_NAMESPACE_NODE *PrefixNode; + const char *Pathname; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **Parameters; + ACPI_NAMESPACE_NODE *ResolvedNode; + ACPI_OPERAND_OBJECT *ReturnObject; + UINT8 PassNumber; + UINT8 ParameterType; + UINT8 ReturnObjectType; + UINT8 Flags; + +} ACPI_EVALUATE_INFO; /* Types for ParameterType above */ #define ACPI_PARAM_ARGS 0 #define ACPI_PARAM_GPE 1 +/* Values for Flags above */ + +#define ACPI_IGNORE_RETURN_VALUE 1 + + +/* Info used by AcpiNsInitializeDevices */ + +typedef struct acpi_device_walk_info +{ + UINT16 DeviceCount; + UINT16 Num_STA; + UINT16 Num_INI; + ACPI_TABLE_DESC *TableDesc; + ACPI_EVALUATE_INFO *EvaluateInfo; + +} ACPI_DEVICE_WALK_INFO; + + +/* TBD: [Restructure] Merge with struct above */ + +typedef struct acpi_walk_info +{ + UINT32 DebugLevel; + UINT32 Count; + ACPI_OWNER_ID OwnerId; + UINT8 DisplayType; + +} ACPI_WALK_INFO; + +/* Display Types */ + +#define ACPI_DISPLAY_SUMMARY (UINT8) 0 +#define ACPI_DISPLAY_OBJECTS (UINT8) 1 +#define ACPI_DISPLAY_MASK (UINT8) 1 + +#define ACPI_DISPLAY_SHORT (UINT8) 2 + #endif diff --git a/sys/dist/acpica/actables.h b/sys/dist/acpica/actables.h index c79a4abbb50..75c34e2ab8b 100644 --- a/sys/dist/acpica/actables.h +++ b/sys/dist/acpica/actables.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actables.h - ACPI table management - * xRevision: 1.54 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -118,153 +118,126 @@ #define __ACTABLES_H__ -/* Used in AcpiTbMapAcpiTable for size parameter if table header is to be used */ - -#define SIZE_IN_HEADER 0 - - -/* - * tbconvrt - Table conversion routines - */ -ACPI_STATUS -AcpiTbConvertToXsdt ( - ACPI_TABLE_DESC *TableInfo); - -ACPI_STATUS -AcpiTbConvertTableFadt ( - void); - ACPI_STATUS -AcpiTbBuildCommonFacs ( - ACPI_TABLE_DESC *TableInfo); - -UINT32 -AcpiTbGetTableCount ( - RSDP_DESCRIPTOR *RSDP, - ACPI_TABLE_HEADER *RSDT); - +AcpiAllocateRootTable ( + UINT32 InitialTableCount); /* - * tbget - Table "get" routines + * tbfadt - FADT parse/convert/validate */ -ACPI_STATUS -AcpiTbGetTable ( - ACPI_POINTER *Address, - ACPI_TABLE_DESC *TableInfo); - -ACPI_STATUS -AcpiTbGetTableHeader ( - ACPI_POINTER *Address, - ACPI_TABLE_HEADER *ReturnHeader); - -ACPI_STATUS -AcpiTbGetTableBody ( - ACPI_POINTER *Address, - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo); - -ACPI_STATUS -AcpiTbGetTablePtr ( - ACPI_TABLE_TYPE TableType, - UINT32 Instance, - ACPI_TABLE_HEADER **TablePtrLoc); - -ACPI_STATUS -AcpiTbVerifyRsdp ( - ACPI_POINTER *Address); - void -AcpiTbGetRsdtAddress ( - ACPI_POINTER *OutAddress); +AcpiTbParseFadt ( + ACPI_NATIVE_UINT TableIndex, + UINT8 Flags); -ACPI_STATUS -AcpiTbValidateRsdt ( - ACPI_TABLE_HEADER *TablePtr); +void +AcpiTbCreateLocalFadt ( + ACPI_TABLE_HEADER *Table, + UINT32 Length); /* - * tbgetall - get multiple required tables + * tbfind - find ACPI table */ ACPI_STATUS -AcpiTbGetRequiredTables ( - void); +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + ACPI_NATIVE_UINT *TableIndex); /* - * tbinstall - Table installation + * tbinstal - Table removal and deletion */ ACPI_STATUS -AcpiTbInstallTable ( - ACPI_TABLE_DESC *TableInfo); +AcpiTbResizeRootTableList ( + void); ACPI_STATUS -AcpiTbRecognizeTable ( - ACPI_TABLE_DESC *TableInfo, - UINT8 SearchType); +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc); ACPI_STATUS -AcpiTbInitTableDescriptor ( - ACPI_TABLE_TYPE TableType, - ACPI_TABLE_DESC *TableInfo); +AcpiTbAddTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NATIVE_UINT *TableIndex); +ACPI_STATUS +AcpiTbStoreTable ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Table, + UINT32 Length, + UINT8 Flags, + ACPI_NATIVE_UINT *TableIndex); -/* - * tbremove - Table removal and deletion - */ void -AcpiTbDeleteAllTables ( - void); +AcpiTbDeleteTable ( + ACPI_TABLE_DESC *TableDesc); void -AcpiTbDeleteTablesByType ( - ACPI_TABLE_TYPE Type); +AcpiTbTerminate ( + void); void -AcpiTbDeleteSingleTable ( - ACPI_TABLE_DESC *TableDesc); +AcpiTbDeleteNamespaceByOwner ( + ACPI_NATIVE_UINT TableIndex); -ACPI_TABLE_DESC * -AcpiTbUninstallTable ( - ACPI_TABLE_DESC *TableDesc); - - -/* - * tbxfroot - RSDP, RSDT utilities - */ ACPI_STATUS -AcpiTbFindTable ( - char *Signature, - char *OemId, - char *OemTableId, - ACPI_TABLE_HEADER **TablePtr); +AcpiTbAllocateOwnerId ( + ACPI_NATIVE_UINT TableIndex); ACPI_STATUS -AcpiTbGetTableRsdt ( - void); +AcpiTbReleaseOwnerId ( + ACPI_NATIVE_UINT TableIndex); ACPI_STATUS -AcpiTbValidateRsdp ( - RSDP_DESCRIPTOR *Rsdp); +AcpiTbGetOwnerId ( + ACPI_NATIVE_UINT TableIndex, + ACPI_OWNER_ID *OwnerId); + +BOOLEAN +AcpiTbIsTableLoaded ( + ACPI_NATIVE_UINT TableIndex); + +void +AcpiTbSetTableLoadedFlag ( + ACPI_NATIVE_UINT TableIndex, + BOOLEAN IsLoaded); /* - * tbutils - common table utilities + * tbutils - table manager utilities */ -ACPI_STATUS -AcpiTbIsTableInstalled ( - ACPI_TABLE_DESC *NewTableDesc); +BOOLEAN +AcpiTbTablesLoaded ( + void); -ACPI_STATUS -AcpiTbVerifyTableChecksum ( - ACPI_TABLE_HEADER *TableHeader); +void +AcpiTbPrintTableHeader( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Header); UINT8 -AcpiTbGenerateChecksum ( - void *Buffer, +AcpiTbChecksum ( + UINT8 *Buffer, + ACPI_NATIVE_UINT Length); + +ACPI_STATUS +AcpiTbVerifyChecksum ( + ACPI_TABLE_HEADER *Table, UINT32 Length); +void +AcpiTbInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + const char *Signature, + ACPI_NATIVE_UINT TableIndex); + ACPI_STATUS -AcpiTbValidateTableHeader ( - ACPI_TABLE_HEADER *TableHeader); +AcpiTbParseRootTable ( + ACPI_PHYSICAL_ADDRESS RsdpAddress, + UINT8 Flags); #endif /* __ACTABLES_H__ */ diff --git a/sys/dist/acpica/actbl.h b/sys/dist/acpica/actbl.h index ec02af119c1..73f871cc580 100644 --- a/sys/dist/acpica/actbl.h +++ b/sys/dist/acpica/actbl.h @@ -1,7 +1,7 @@ /****************************************************************************** * - * Name: actbl.h - Table data structures defined in ACPI specification - * xRevision: 1.74 $ + * Name: actbl.h - Basic ACPI Table Definitions + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -117,336 +117,279 @@ #ifndef __ACTBL_H__ #define __ACTBL_H__ - /* - * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. - * This is the only type that is even remotely portable. Anything else is not - * portable, so do not use any other bitfield types. + * Values for description table header signatures. Useful because they make + * it more difficult to inadvertently type in the wrong signature. */ +#define ACPI_SIG_DSDT "DSDT" /* Differentiated System Description Table */ +#define ACPI_SIG_FADT "FACP" /* Fixed ACPI Description Table */ +#define ACPI_SIG_FACS "FACS" /* Firmware ACPI Control Structure */ +#define ACPI_SIG_PSDT "PSDT" /* Persistent System Description Table */ +#define ACPI_SIG_RSDP "RSD PTR " /* Root System Description Pointer */ +#define ACPI_SIG_RSDT "RSDT" /* Root System Description Table */ +#define ACPI_SIG_XSDT "XSDT" /* Extended System Description Table */ +#define ACPI_SIG_SSDT "SSDT" /* Secondary System Description Table */ +#define ACPI_RSDP_NAME "RSDP" /* Short name for RSDP, not signature */ /* - * Values for description table header signatures - */ -#define RSDP_NAME "RSDP" -#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ -#define APIC_SIG "APIC" /* Multiple APIC Description Table */ -#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ -#define FADT_SIG "FACP" /* Fixed ACPI Description Table */ -#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ -#define PSDT_SIG "PSDT" /* Persistent System Description Table */ -#define RSDT_SIG "RSDT" /* Root System Description Table */ -#define XSDT_SIG "XSDT" /* Extended System Description Table */ -#define SSDT_SIG "SSDT" /* Secondary System Description Table */ -#define SBST_SIG "SBST" /* Smart Battery Specification Table */ -#define SPIC_SIG "SPIC" /* IOSAPIC table */ -#define BOOT_SIG "BOOT" /* Boot table */ - - -#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */ - - -/* - * Common table types. The base code can remain - * constant if the underlying tables are changed + * All tables and structures must be byte-packed to match the ACPI + * specification, since the tables are provided by the system BIOS */ -#define RSDT_DESCRIPTOR RSDT_DESCRIPTOR_REV2 -#define XSDT_DESCRIPTOR XSDT_DESCRIPTOR_REV2 -#define FACS_DESCRIPTOR FACS_DESCRIPTOR_REV2 -#define FADT_DESCRIPTOR FADT_DESCRIPTOR_REV2 - - #pragma pack(1) + /* - * ACPI Version-independent tables + * These are the ACPI tables that are directly consumed by the subsystem. + * + * The RSDP and FACS do not use the common ACPI table header. All other ACPI + * tables use the header. * - * NOTE: The tables that are specific to ACPI versions (1.0, 2.0, etc.) - * are in separate files. + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. */ -typedef struct rsdp_descriptor /* Root System Descriptor Pointer */ -{ - char Signature[8]; /* ACPI signature, contains "RSD PTR " */ - UINT8 Checksum; /* ACPI 1.0 checksum */ - char OemId[6]; /* OEM identification */ - UINT8 Revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */ - UINT32 RsdtPhysicalAddress; /* 32-bit physical address of the RSDT */ - UINT32 Length; /* XSDT Length in bytes, including header */ - UINT64 XsdtPhysicalAddress; /* 64-bit physical address of the XSDT */ - UINT8 ExtendedChecksum; /* Checksum of entire table (ACPI 2.0) */ - char Reserved[3]; /* Reserved, must be zero */ - -} RSDP_DESCRIPTOR; - - -typedef struct acpi_common_facs /* Common FACS for internal use */ -{ - UINT32 *GlobalLock; - UINT64 *FirmwareWakingVector; - UINT8 VectorWidth; - -} ACPI_COMMON_FACS; - - -#define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ - char Signature[4]; /* ASCII table signature */\ - UINT32 Length; /* Length of table in bytes, including this header */\ - UINT8 Revision; /* ACPI Specification minor version # */\ - UINT8 Checksum; /* To make sum of entire table == 0 */\ - char OemId[6]; /* ASCII OEM identification */\ - char OemTableId[8]; /* ASCII OEM table identification */\ - UINT32 OemRevision; /* OEM revision number */\ - char AslCompilerId [4]; /* ASCII ASL compiler vendor ID */\ - UINT32 AslCompilerRevision; /* ASL compiler version */ +/******************************************************************************* + * + * ACPI Table Header. This common header is used by all tables except the + * RSDP and FACS. The define is used for direct inclusion of header into + * other ACPI tables + * + ******************************************************************************/ -typedef struct acpi_table_header /* ACPI common table header */ +typedef struct acpi_table_header { - ACPI_TABLE_HEADER_DEF + char Signature[ACPI_NAME_SIZE]; /* ASCII table signature */ + UINT32 Length; /* Length of table in bytes, including this header */ + UINT8 Revision; /* ACPI Specification minor version # */ + UINT8 Checksum; /* To make sum of entire table == 0 */ + char OemId[ACPI_OEM_ID_SIZE]; /* ASCII OEM identification */ + char OemTableId[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */ + UINT32 OemRevision; /* OEM revision number */ + char AslCompilerId[ACPI_NAME_SIZE]; /* ASCII ASL compiler vendor ID */ + UINT32 AslCompilerRevision; /* ASL compiler version */ } ACPI_TABLE_HEADER; /* - * MADT values and structures + * GAS - Generic Address Structure (ACPI 2.0+) + * + * Note: Since this structure is used in the ACPI tables, it is byte aligned. + * If misalignment is not supported, access to the Address field must be + * performed with care. */ - -/* Values for MADT PCATCompat */ - -#define DUAL_PIC 0 -#define MULTIPLE_APIC 1 - -/* Master MADT */ - -typedef struct multiple_apic_table +typedef struct acpi_generic_address { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT32 LocalApicAddress; /* Physical address of local APIC */ + UINT8 SpaceId; /* Address space where struct or register exists */ + UINT8 BitWidth; /* Size in bits of given register */ + UINT8 BitOffset; /* Bit offset within the register */ + UINT8 AccessWidth; /* Minimum Access size (ACPI 3.0) */ + UINT64 Address; /* 64-bit address of struct or register */ - /* Flags (32 bits) */ +} ACPI_GENERIC_ADDRESS; - UINT8 PCATCompat : 1; /* 00: System also has dual 8259s */ - UINT8 : 7; /* 01-07: Reserved, must be zero */ - UINT8 Reserved1[3]; /* 08-31: Reserved, must be zero */ -} MULTIPLE_APIC_TABLE; - -/* Values for Type in APIC_HEADER_DEF */ - -#define APIC_PROCESSOR 0 -#define APIC_IO 1 -#define APIC_XRUPT_OVERRIDE 2 -#define APIC_NMI 3 -#define APIC_LOCAL_NMI 4 -#define APIC_ADDRESS_OVERRIDE 5 -#define APIC_IO_SAPIC 6 -#define APIC_LOCAL_SAPIC 7 -#define APIC_XRUPT_SOURCE 8 -#define APIC_RESERVED 9 /* 9 and greater are reserved */ - -/* - * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) - */ -#define APIC_HEADER_DEF /* Common APIC sub-structure header */\ - UINT8 Type; \ - UINT8 Length; +/******************************************************************************* + * + * RSDP - Root System Description Pointer (Signature is "RSD PTR ") + * + ******************************************************************************/ -typedef struct apic_header +typedef struct acpi_table_rsdp { - APIC_HEADER_DEF - -} APIC_HEADER; - -/* Values for MPS INTI flags */ + char Signature[8]; /* ACPI signature, contains "RSD PTR " */ + UINT8 Checksum; /* ACPI 1.0 checksum */ + char OemId[ACPI_OEM_ID_SIZE]; /* OEM identification */ + UINT8 Revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */ + UINT32 RsdtPhysicalAddress; /* 32-bit physical address of the RSDT */ + UINT32 Length; /* Table length in bytes, including header (ACPI 2.0+) */ + UINT64 XsdtPhysicalAddress; /* 64-bit physical address of the XSDT (ACPI 2.0+) */ + UINT8 ExtendedChecksum; /* Checksum of entire table (ACPI 2.0+) */ + UINT8 Reserved[3]; /* Reserved, must be zero */ -#define POLARITY_CONFORMS 0 -#define POLARITY_ACTIVE_HIGH 1 -#define POLARITY_RESERVED 2 -#define POLARITY_ACTIVE_LOW 3 +} ACPI_TABLE_RSDP; -#define TRIGGER_CONFORMS 0 -#define TRIGGER_EDGE 1 -#define TRIGGER_RESERVED 2 -#define TRIGGER_LEVEL 3 +#define ACPI_RSDP_REV0_SIZE 20 /* Size of original ACPI 1.0 RSDP */ -/* Common flag definitions (16 bits each) */ -#define MPS_INTI_FLAGS \ - UINT8 Polarity : 2; /* 00-01: Polarity of APIC I/O input signals */\ - UINT8 TriggerMode : 2; /* 02-03: Trigger mode of APIC input signals */\ - UINT8 : 4; /* 04-07: Reserved, must be zero */\ - UINT8 Reserved1; /* 08-15: Reserved, must be zero */ - -#define LOCAL_APIC_FLAGS \ - UINT8 ProcessorEnabled: 1; /* 00: Processor is usable if set */\ - UINT8 : 7; /* 01-07: Reserved, must be zero */\ - UINT8 Reserved2; /* 08-15: Reserved, must be zero */ - -/* Sub-structures for MADT */ +/******************************************************************************* + * + * RSDT/XSDT - Root System Description Tables + * + ******************************************************************************/ -typedef struct madt_processor_apic +typedef struct acpi_table_rsdt { - APIC_HEADER_DEF - UINT8 ProcessorId; /* ACPI processor id */ - UINT8 LocalApicId; /* Processor's local APIC id */ - LOCAL_APIC_FLAGS + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ -} MADT_PROCESSOR_APIC; +} ACPI_TABLE_RSDT; -typedef struct madt_io_apic +typedef struct acpi_table_xsdt { - APIC_HEADER_DEF - UINT8 IoApicId; /* I/O APIC ID */ - UINT8 Reserved; /* Reserved - must be zero */ - UINT32 Address; /* APIC physical address */ - UINT32 Interrupt; /* Global system interrupt where INTI - * lines start */ -} MADT_IO_APIC; - -typedef struct madt_interrupt_override -{ - APIC_HEADER_DEF - UINT8 Bus; /* 0 - ISA */ - UINT8 Source; /* Interrupt source (IRQ) */ - UINT32 Interrupt; /* Global system interrupt */ - MPS_INTI_FLAGS + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ -} MADT_INTERRUPT_OVERRIDE; +} ACPI_TABLE_XSDT; -typedef struct madt_nmi_source -{ - APIC_HEADER_DEF - MPS_INTI_FLAGS - UINT32 Interrupt; /* Global system interrupt */ -} MADT_NMI_SOURCE; +/******************************************************************************* + * + * FACS - Firmware ACPI Control Structure (FACS) + * + ******************************************************************************/ -typedef struct madt_local_apic_nmi +typedef struct acpi_table_facs { - APIC_HEADER_DEF - UINT8 ProcessorId; /* ACPI processor id */ - MPS_INTI_FLAGS - UINT8 Lint; /* LINTn to which NMI is connected */ + char Signature[4]; /* ASCII table signature */ + UINT32 Length; /* Length of structure, in bytes */ + UINT32 HardwareSignature; /* Hardware configuration signature */ + UINT32 FirmwareWakingVector; /* 32-bit physical address of the Firmware Waking Vector */ + UINT32 GlobalLock; /* Global Lock for shared hardware resources */ + UINT32 Flags; + UINT64 XFirmwareWakingVector; /* 64-bit version of the Firmware Waking Vector (ACPI 2.0+) */ + UINT8 Version; /* Version of this table (ACPI 2.0+) */ + UINT8 Reserved[31]; /* Reserved, must be zero */ -} MADT_LOCAL_APIC_NMI; +} ACPI_TABLE_FACS; -typedef struct madt_address_override -{ - APIC_HEADER_DEF - UINT16 Reserved; /* Reserved, must be zero */ - UINT64 Address; /* APIC physical address */ +/* Flag macros */ -} MADT_ADDRESS_OVERRIDE; +#define ACPI_FACS_S4_BIOS_PRESENT (1) /* 00: S4BIOS support is present */ -typedef struct madt_io_sapic -{ - APIC_HEADER_DEF - UINT8 IoSapicId; /* I/O SAPIC ID */ - UINT8 Reserved; /* Reserved, must be zero */ - UINT32 InterruptBase; /* Glocal interrupt for SAPIC start */ - UINT64 Address; /* SAPIC physical address */ +/* Global lock flags */ -} MADT_IO_SAPIC; +#define ACPI_GLOCK_PENDING 0x01 /* 00: Pending global lock ownership */ +#define ACPI_GLOCK_OWNED 0x02 /* 01: Global lock is owned */ -typedef struct madt_local_sapic -{ - APIC_HEADER_DEF - UINT8 ProcessorId; /* ACPI processor id */ - UINT8 LocalSapicId; /* SAPIC ID */ - UINT8 LocalSapicEid; /* SAPIC EID */ - UINT8 Reserved[3]; /* Reserved, must be zero */ - LOCAL_APIC_FLAGS - UINT32 ProcessorUID; /* Numeric UID - ACPI 3.0 */ - char ProcessorUIDString[1]; /* String UID - ACPI 3.0 */ - -} MADT_LOCAL_SAPIC; - -typedef struct madt_interrupt_source -{ - APIC_HEADER_DEF - MPS_INTI_FLAGS - UINT8 InterruptType; /* 1=PMI, 2=INIT, 3=corrected */ - UINT8 ProcessorId; /* Processor ID */ - UINT8 ProcessorEid; /* Processor EID */ - UINT8 IoSapicVector; /* Vector value for PMI interrupts */ - UINT32 Interrupt; /* Global system interrupt */ - UINT32 Flags; /* Interrupt Source Flags */ -} MADT_INTERRUPT_SOURCE; +/******************************************************************************* + * + * FADT - Fixed ACPI Description Table (Signature "FACP") + * + ******************************************************************************/ +/* Fields common to all versions of the FADT */ -/* - * Smart Battery - */ -typedef struct smart_battery_table +typedef struct acpi_table_fadt { - ACPI_TABLE_HEADER_DEF - UINT32 WarningLevel; - UINT32 LowLevel; - UINT32 CriticalLevel; - -} SMART_BATTERY_TABLE; - - -#pragma pack() + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Facs; /* 32-bit physical address of FACS */ + UINT32 Dsdt; /* 32-bit physical address of DSDT */ + UINT8 Model; /* System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ + UINT8 PreferredProfile; /* Conveys preferred power management profile to OSPM. */ + UINT16 SciInterrupt; /* System vector of SCI interrupt */ + UINT32 SmiCommand; /* 32-bit Port address of SMI command port */ + UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */ + UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */ + UINT8 S4BiosRequest; /* Value to write to SMI CMD to enter S4BIOS state */ + UINT8 PstateControl; /* Processor performance state control*/ + UINT32 Pm1aEventBlock; /* 32-bit Port address of Power Mgt 1a Event Reg Blk */ + UINT32 Pm1bEventBlock; /* 32-bit Port address of Power Mgt 1b Event Reg Blk */ + UINT32 Pm1aControlBlock; /* 32-bit Port address of Power Mgt 1a Control Reg Blk */ + UINT32 Pm1bControlBlock; /* 32-bit Port address of Power Mgt 1b Control Reg Blk */ + UINT32 Pm2ControlBlock; /* 32-bit Port address of Power Mgt 2 Control Reg Blk */ + UINT32 PmTimerBlock; /* 32-bit Port address of Power Mgt Timer Ctrl Reg Blk */ + UINT32 Gpe0Block; /* 32-bit Port address of General Purpose Event 0 Reg Blk */ + UINT32 Gpe1Block; /* 32-bit Port address of General Purpose Event 1 Reg Blk */ + UINT8 Pm1EventLength; /* Byte Length of ports at Pm1xEventBlock */ + UINT8 Pm1ControlLength; /* Byte Length of ports at Pm1xControlBlock */ + UINT8 Pm2ControlLength; /* Byte Length of ports at Pm2ControlBlock */ + UINT8 PmTimerLength; /* Byte Length of ports at PmTimerBlock */ + UINT8 Gpe0BlockLength; /* Byte Length of ports at Gpe0Block */ + UINT8 Gpe1BlockLength; /* Byte Length of ports at Gpe1Block */ + UINT8 Gpe1Base; /* Offset in GPE number space where GPE1 events start */ + UINT8 CstControl; /* Support for the _CST object and C States change notification */ + UINT16 C2Latency; /* Worst case HW latency to enter/exit C2 state */ + UINT16 C3Latency; /* Worst case HW latency to enter/exit C3 state */ + UINT16 FlushSize; /* Processor's memory cache line width, in bytes */ + UINT16 FlushStride; /* Number of flush strides that need to be read */ + UINT8 DutyOffset; /* Processor duty cycle index in processor's P_CNT reg*/ + UINT8 DutyWidth; /* Processor duty cycle value bit width in P_CNT register.*/ + UINT8 DayAlarm; /* Index to day-of-month alarm in RTC CMOS RAM */ + UINT8 MonthAlarm; /* Index to month-of-year alarm in RTC CMOS RAM */ + UINT8 Century; /* Index to century in RTC CMOS RAM */ + UINT16 BootFlags; /* IA-PC Boot Architecture Flags. See Table 5-10 for description */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ + ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ + UINT8 Reserved4[3]; /* Reserved, must be zero */ + UINT64 XFacs; /* 64-bit physical address of FACS */ + UINT64 XDsdt; /* 64-bit physical address of DSDT */ + ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPmTimerBlock; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe0Block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe1Block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */ + +} ACPI_TABLE_FADT; + + +/* FADT flags */ + +#define ACPI_FADT_WBINVD (1) /* 00: The wbinvd instruction works properly */ +#define ACPI_FADT_WBINVD_FLUSH (1<<1) /* 01: The wbinvd flushes but does not invalidate */ +#define ACPI_FADT_C1_SUPPORTED (1<<2) /* 02: All processors support C1 state */ +#define ACPI_FADT_C2_MP_SUPPORTED (1<<3) /* 03: C2 state works on MP system */ +#define ACPI_FADT_POWER_BUTTON (1<<4) /* 04: Power button is handled as a generic feature */ +#define ACPI_FADT_SLEEP_BUTTON (1<<5) /* 05: Sleep button is handled as a generic feature, or not present */ +#define ACPI_FADT_FIXED_RTC (1<<6) /* 06: RTC wakeup stat not in fixed register space */ +#define ACPI_FADT_S4_RTC_WAKE (1<<7) /* 07: RTC wakeup stat not possible from S4 */ +#define ACPI_FADT_32BIT_TIMER (1<<8) /* 08: tmr_val is 32 bits 0=24-bits */ +#define ACPI_FADT_DOCKING_SUPPORTED (1<<9) /* 09: Docking supported */ +#define ACPI_FADT_RESET_REGISTER (1<<10) /* 10: System reset via the FADT RESET_REG supported */ +#define ACPI_FADT_SEALED_CASE (1<<11) /* 11: No internal expansion capabilities and case is sealed */ +#define ACPI_FADT_HEADLESS (1<<12) /* 12: No local video capabilities or local input devices */ +#define ACPI_FADT_SLEEP_TYPE (1<<13) /* 13: Must execute native instruction after writing SLP_TYPx register */ +#define ACPI_FADT_PCI_EXPRESS_WAKE (1<<14) /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ +#define ACPI_FADT_PLATFORM_CLOCK (1<<15) /* 15: OSPM should use platform-provided timer (ACPI 3.0) */ +#define ACPI_FADT_S4_RTC_VALID (1<<16) /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ +#define ACPI_FADT_REMOTE_POWER_ON (1<<17) /* 17: System is compatible with remote power on (ACPI 3.0) */ +#define ACPI_FADT_APIC_CLUSTER (1<<18) /* 18: All local APICs must use cluster model (ACPI 3.0) */ +#define ACPI_FADT_APIC_PHYSICAL (1<<19) /* 19: All local xAPICs must use physical dest mode (ACPI 3.0) */ /* - * ACPI Table information. We save the table address, length, - * and type of memory allocation (mapped or allocated) for each - * table for 1) when we exit, and 2) if a new table is installed + * FADT Prefered Power Management Profiles */ -#define ACPI_MEM_NOT_ALLOCATED 0 -#define ACPI_MEM_ALLOCATED 1 -#define ACPI_MEM_MAPPED 2 - -/* Definitions for the Flags bitfield member of ACPI_TABLE_SUPPORT */ - -#define ACPI_TABLE_SINGLE 0x00 -#define ACPI_TABLE_MULTIPLE 0x01 -#define ACPI_TABLE_EXECUTABLE 0x02 +enum AcpiPreferedPmProfiles +{ + PM_UNSPECIFIED = 0, + PM_DESKTOP = 1, + PM_MOBILE = 2, + PM_WORKSTATION = 3, + PM_ENTERPRISE_SERVER = 4, + PM_SOHO_SERVER = 5, + PM_APPLIANCE_PC = 6 +}; -#define ACPI_TABLE_ROOT 0x00 -#define ACPI_TABLE_PRIMARY 0x10 -#define ACPI_TABLE_SECONDARY 0x20 -#define ACPI_TABLE_ALL 0x30 -#define ACPI_TABLE_TYPE_MASK 0x30 -/* Data about each known table type */ +/* FADT Boot Arch Flags */ -typedef struct acpi_table_support -{ - const char *Name; - const char *Signature; - void **GlobalPtr; - UINT8 SigLength; - UINT8 Flags; +#define BAF_LEGACY_DEVICES 0x0001 +#define BAF_8042_KEYBOARD_CONTROLLER 0x0002 -} ACPI_TABLE_SUPPORT; +#define FADT2_REVISION_ID 3 +#define FADT2_MINUS_REVISION_ID 2 -/* - * Get the ACPI version-specific tables - */ -#include "actbl1.h" /* Acpi 1.0 table definitions */ -#include "actbl2.h" /* Acpi 2.0 table definitions */ +/* Reset to default packing */ +#pragma pack() -#pragma pack(1) /* - * High performance timer + * Get the remaining ACPI tables */ -typedef struct hpet_table -{ - ACPI_TABLE_HEADER_DEF - UINT32 HardwareId; - ACPI_GENERIC_ADDRESS BaseAddress; - UINT8 HpetNumber; - UINT16 ClockTick; - UINT8 Attributes; +#include <dist/acpica/actbl1.h> -} HPET_TABLE; +/* Macros used to generate offsets to specific table fields */ -#pragma pack() +#define ACPI_FADT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_TABLE_FADT, f) #endif /* __ACTBL_H__ */ diff --git a/sys/dist/acpica/actbl1.h b/sys/dist/acpica/actbl1.h index 84a7df59eba..7b676ed4eca 100644 --- a/sys/dist/acpica/actbl1.h +++ b/sys/dist/acpica/actbl1.h @@ -1,7 +1,7 @@ /****************************************************************************** * - * Name: actbl1.h - ACPI 1.0 tables - * xRevision: 1.34 $ + * Name: actbl1.h - Additional ACPI table definitions + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -117,102 +117,801 @@ #ifndef __ACTBL1_H__ #define __ACTBL1_H__ + +/******************************************************************************* + * + * Additional ACPI Tables + * + * These tables are not consumed directly by the ACPICA subsystem, but are + * included here to support device drivers and the AML disassembler. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures. Useful because they make + * it more difficult to inadvertently type in the wrong signature. + */ +#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ +#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */ +#define ACPI_SIG_CPEP "CPEP" /* Corrected Platform Error Polling table */ +#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ +#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ +#define ACPI_SIG_ECDT "ECDT" /* Embedded Controller Boot Resources Table */ +#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ +#define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */ +#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ +#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */ +#define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */ +#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ +#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ +#define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */ +#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ +#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */ + + +/* + * All tables must be byte-packed to match the ACPI specification, since + * the tables are provided by the system BIOS. + */ #pragma pack(1) /* - * ACPI 1.0 Root System Description Table (RSDT) + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. */ -typedef struct rsdt_descriptor_rev1 + + +/* Common Sub-table header (used in MADT, SRAT, etc.) */ + +typedef struct acpi_subtable_header { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT32 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + UINT8 Type; + UINT8 Length; -} RSDT_DESCRIPTOR_REV1; +} ACPI_SUBTABLE_HEADER; +/******************************************************************************* + * + * ASF - Alert Standard Format table (Signature "ASF!") + * + * Conforms to the Alert Standard Format Specification V2.0, 23 April 2003 + * + ******************************************************************************/ + +typedef struct acpi_table_asf +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + +} ACPI_TABLE_ASF; + + +/* ASF subtable header */ + +typedef struct acpi_asf_header +{ + UINT8 Type; + UINT8 Reserved; + UINT16 Length; + +} ACPI_ASF_HEADER; + + +/* Values for Type field above */ + +enum AcpiAsfType +{ + ACPI_ASF_TYPE_INFO = 0, + ACPI_ASF_TYPE_ALERT = 1, + ACPI_ASF_TYPE_CONTROL = 2, + ACPI_ASF_TYPE_BOOT = 3, + ACPI_ASF_TYPE_ADDRESS = 4, + ACPI_ASF_TYPE_RESERVED = 5 +}; + /* - * ACPI 1.0 Firmware ACPI Control Structure (FACS) + * ASF subtables */ -typedef struct facs_descriptor_rev1 + +/* 0: ASF Information */ + +typedef struct acpi_asf_info +{ + ACPI_ASF_HEADER Header; + UINT8 MinResetValue; + UINT8 MinPollInterval; + UINT16 SystemId; + UINT32 MfgId; + UINT8 Flags; + UINT8 Reserved2[3]; + +} ACPI_ASF_INFO; + +/* 1: ASF Alerts */ + +typedef struct acpi_asf_alert +{ + ACPI_ASF_HEADER Header; + UINT8 AssertMask; + UINT8 DeassertMask; + UINT8 Alerts; + UINT8 DataLength; + +} ACPI_ASF_ALERT; + +typedef struct acpi_asf_alert_data +{ + UINT8 Address; + UINT8 Command; + UINT8 Mask; + UINT8 Value; + UINT8 SensorType; + UINT8 Type; + UINT8 Offset; + UINT8 SourceType; + UINT8 Severity; + UINT8 SensorNumber; + UINT8 Entity; + UINT8 Instance; + +} ACPI_ASF_ALERT_DATA; + +/* 2: ASF Remote Control */ + +typedef struct acpi_asf_remote +{ + ACPI_ASF_HEADER Header; + UINT8 Controls; + UINT8 DataLength; + UINT16 Reserved2; + +} ACPI_ASF_REMOTE; + +typedef struct acpi_asf_control_data +{ + UINT8 Function; + UINT8 Address; + UINT8 Command; + UINT8 Value; + +} ACPI_ASF_CONTROL_DATA; + +/* 3: ASF RMCP Boot Options */ + +typedef struct acpi_asf_rmcp +{ + ACPI_ASF_HEADER Header; + UINT8 Capabilities[7]; + UINT8 CompletionCode; + UINT32 EnterpriseId; + UINT8 Command; + UINT16 Parameter; + UINT16 BootOptions; + UINT16 OemParameters; + +} ACPI_ASF_RMCP; + +/* 4: ASF Address */ + +typedef struct acpi_asf_address +{ + ACPI_ASF_HEADER Header; + UINT8 EpromAddress; + UINT8 Devices; + +} ACPI_ASF_ADDRESS; + + +/******************************************************************************* + * + * BOOT - Simple Boot Flag Table + * + ******************************************************************************/ + +typedef struct acpi_table_boot +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 CmosIndex; /* Index in CMOS RAM for the boot register */ + UINT8 Reserved[3]; + +} ACPI_TABLE_BOOT; + + +/******************************************************************************* + * + * CPEP - Corrected Platform Error Polling table + * + ******************************************************************************/ + +typedef struct acpi_table_cpep +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 Reserved; + +} ACPI_TABLE_CPEP; + + +/* Subtable */ + +typedef struct acpi_cpep_polling +{ + UINT8 Type; + UINT8 Length; + UINT8 Id; /* Processor ID */ + UINT8 Eid; /* Processor EID */ + UINT32 Interval; /* Polling interval (msec) */ + +} ACPI_CPEP_POLLING; + + +/******************************************************************************* + * + * DBGP - Debug Port table + * + ******************************************************************************/ + +typedef struct acpi_table_dbgp { - char Signature[4]; /* ASCII table signature */ - UINT32 Length; /* Length of structure in bytes */ - UINT32 HardwareSignature; /* Hardware configuration signature */ - UINT32 FirmwareWakingVector; /* ACPI OS waking vector */ - UINT32 GlobalLock; /* Global Lock */ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Type; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS DebugPort; - /* Flags (32 bits) */ +} ACPI_TABLE_DBGP; - UINT8 S4Bios_f : 1; /* 00: S4BIOS support is present */ - UINT8 : 7; /* 01-07: Reserved, must be zero */ - UINT8 Reserved1[3]; /* 08-31: Reserved, must be zero */ - UINT8 Reserved2[40]; /* Reserved, must be zero */ +/******************************************************************************* + * + * DMAR - DMA Remapping table + * + ******************************************************************************/ -} FACS_DESCRIPTOR_REV1; +typedef struct acpi_table_dmar +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Width; /* Host Address Width */ + UINT8 Reserved[11]; + +} ACPI_TABLE_DMAR; + +/* DMAR subtable header */ + +typedef struct acpi_dmar_header +{ + UINT16 Type; + UINT16 Length; + UINT8 Flags; + UINT8 Reserved[3]; + +} ACPI_DMAR_HEADER; + +/* Values for subtable type in ACPI_DMAR_HEADER */ + +enum AcpiDmarType +{ + ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, + ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, + ACPI_DMAR_TYPE_RESERVED = 2 /* 2 and greater are reserved */ +}; + +typedef struct acpi_dmar_device_scope +{ + UINT8 EntryType; + UINT8 Length; + UINT8 Segment; + UINT8 Bus; + +} ACPI_DMAR_DEVICE_SCOPE; + +/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */ + +enum AcpiDmarScopeType +{ + ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, + ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, + ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, + ACPI_DMAR_SCOPE_TYPE_RESERVED = 3 /* 3 and greater are reserved */ +}; /* - * ACPI 1.0 Fixed ACPI Description Table (FADT) + * DMAR Sub-tables, correspond to Type in ACPI_DMAR_HEADER */ -typedef struct fadt_descriptor_rev1 -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT32 FirmwareCtrl; /* Physical address of FACS */ - UINT32 Dsdt; /* Physical address of DSDT */ - UINT8 Model; /* System Interrupt Model */ - UINT8 Reserved1; /* Reserved, must be zero */ - UINT16 SciInt; /* System vector of SCI interrupt */ - UINT32 SmiCmd; /* Port address of SMI command port */ - UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */ - UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */ - UINT8 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */ - UINT8 Reserved2; /* Reserved, must be zero */ - UINT32 Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */ - UINT32 Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */ - UINT32 Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */ - UINT32 Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */ - UINT32 Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */ - UINT32 PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ - UINT32 Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */ - UINT32 Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */ - UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */ - UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */ - UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */ - UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */ - UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */ - UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */ - UINT8 Gpe1Base; /* Offset in gpe model where gpe1 events start */ - UINT8 Reserved3; /* Reserved, must be zero */ - UINT16 Plvl2Lat; /* Worst case HW latency to enter/exit C2 state */ - UINT16 Plvl3Lat; /* Worst case HW latency to enter/exit C3 state */ - UINT16 FlushSize; /* Size of area read to flush caches */ - UINT16 FlushStride; /* Stride used in flushing caches */ - UINT8 DutyOffset; /* Bit location of duty cycle field in p_cnt reg */ - UINT8 DutyWidth; /* Bit width of duty cycle field in p_cnt reg */ - UINT8 DayAlrm; /* Index to day-of-month alarm in RTC CMOS RAM */ - UINT8 MonAlrm; /* Index to month-of-year alarm in RTC CMOS RAM */ - UINT8 Century; /* Index to century in RTC CMOS RAM */ - UINT8 Reserved4[3]; /* Reserved, must be zero */ - - /* Flags (32 bits) */ - - UINT8 WbInvd : 1; /* 00: The wbinvd instruction works properly */ - UINT8 WbInvdFlush : 1; /* 01: The wbinvd flushes but does not invalidate */ - UINT8 ProcC1 : 1; /* 02: All processors support C1 state */ - UINT8 Plvl2Up : 1; /* 03: C2 state works on MP system */ - UINT8 PwrButton : 1; /* 04: Power button is handled as a generic feature */ - UINT8 SleepButton : 1; /* 05: Sleep button is handled as a generic feature, or not present */ - UINT8 FixedRTC : 1; /* 06: RTC wakeup stat not in fixed register space */ - UINT8 Rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ - UINT8 TmrValExt : 1; /* 08: tmr_val width is 32 bits (0 = 24 bits) */ - UINT8 : 7; /* 09-15: Reserved, must be zero */ - UINT8 Reserved5[2]; /* 16-31: Reserved, must be zero */ - -} FADT_DESCRIPTOR_REV1; -#pragma pack() +/* 0: Hardware Unit Definition */ -#endif /* __ACTBL1_H__ */ +typedef struct acpi_dmar_hardware_unit +{ + ACPI_DMAR_HEADER Header; + UINT64 Address; /* Register Base Address */ + +} ACPI_DMAR_HARDWARE_UNIT; + +/* Flags */ + +#define ACPI_DMAR_INCLUDE_ALL (1) + +/* 1: Reserved Memory Defininition */ + +typedef struct acpi_dmar_reserved_memory +{ + ACPI_DMAR_HEADER Header; + UINT64 Address; /* 4K aligned base address */ + UINT64 EndAddress; /* 4K aligned limit address */ + +} ACPI_DMAR_RESERVED_MEMORY; + +/* Flags */ + +#define ACPI_DMAR_ALLOW_ALL (1) + + +/******************************************************************************* + * + * ECDT - Embedded Controller Boot Resources Table + * + ******************************************************************************/ + +typedef struct acpi_table_ecdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + ACPI_GENERIC_ADDRESS Control; /* Address of EC command/status register */ + ACPI_GENERIC_ADDRESS Data; /* Address of EC data register */ + UINT32 Uid; /* Unique ID - must be same as the EC _UID method */ + UINT8 Gpe; /* The GPE for the EC */ + UINT8 Id[1]; /* Full namepath of the EC in the ACPI namespace */ + +} ACPI_TABLE_ECDT; + + +/******************************************************************************* + * + * HPET - High Precision Event Timer table + * + ******************************************************************************/ + +typedef struct acpi_table_hpet +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Id; /* Hardware ID of event timer block */ + ACPI_GENERIC_ADDRESS Address; /* Address of event timer block */ + UINT8 Sequence; /* HPET sequence number */ + UINT16 MinimumTick; /* Main counter min tick, periodic mode */ + UINT8 Flags; + +} ACPI_TABLE_HPET; + +/*! Flags */ + +#define ACPI_HPET_PAGE_PROTECT (1) /* 00: No page protection */ +#define ACPI_HPET_PAGE_PROTECT_4 (1<<1) /* 01: 4KB page protected */ +#define ACPI_HPET_PAGE_PROTECT_64 (1<<2) /* 02: 64KB page protected */ + +/*! [End] no source code translation !*/ + + +/******************************************************************************* + * + * MADT - Multiple APIC Description Table + * + ******************************************************************************/ + +typedef struct acpi_table_madt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Address; /* Physical address of local APIC */ + UINT32 Flags; + +} ACPI_TABLE_MADT; + +/* Flags */ + +#define ACPI_MADT_PCAT_COMPAT (1) /* 00: System also has dual 8259s */ + +/* Values for PCATCompat flag */ + +#define ACPI_MADT_DUAL_PIC 0 +#define ACPI_MADT_MULTIPLE_APIC 1 + + +/* Values for subtable type in ACPI_SUBTABLE_HEADER */ +enum AcpiMadtType +{ + ACPI_MADT_TYPE_LOCAL_APIC = 0, + ACPI_MADT_TYPE_IO_APIC = 1, + ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, + ACPI_MADT_TYPE_NMI_SOURCE = 3, + ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, + ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, + ACPI_MADT_TYPE_IO_SAPIC = 6, + ACPI_MADT_TYPE_LOCAL_SAPIC = 7, + ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, + ACPI_MADT_TYPE_RESERVED = 9 /* 9 and greater are reserved */ +}; + + +/* + * MADT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + */ + +/* 0: Processor Local APIC */ + +typedef struct acpi_madt_local_apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT8 Id; /* Processor's local APIC id */ + UINT32 LapicFlags; + +} ACPI_MADT_LOCAL_APIC; + +/* 1: IO APIC */ + +typedef struct acpi_madt_io_apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* I/O APIC ID */ + UINT8 Reserved; /* Reserved - must be zero */ + UINT32 Address; /* APIC physical address */ + UINT32 GlobalIrqBase; /* Global system interrupt where INTI lines start */ + +} ACPI_MADT_IO_APIC; + +/* 2: Interrupt Override */ + +typedef struct acpi_madt_interrupt_override +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Bus; /* 0 - ISA */ + UINT8 SourceIrq; /* Interrupt source (IRQ) */ + UINT32 GlobalIrq; /* Global system interrupt */ + UINT16 IntiFlags; + +} ACPI_MADT_INTERRUPT_OVERRIDE; + +/* 3: NMI Source */ + +typedef struct acpi_madt_nmi_source +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT32 GlobalIrq; /* Global system interrupt */ + +} ACPI_MADT_NMI_SOURCE; + +/* 4: Local APIC NMI */ + +typedef struct acpi_madt_local_apic_nmi +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT16 IntiFlags; + UINT8 Lint; /* LINTn to which NMI is connected */ + +} ACPI_MADT_LOCAL_APIC_NMI; + +/* 5: Address Override */ + +typedef struct acpi_madt_local_apic_override +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved, must be zero */ + UINT64 Address; /* APIC physical address */ + +} ACPI_MADT_LOCAL_APIC_OVERRIDE; + +/* 6: I/O Sapic */ + +typedef struct acpi_madt_io_sapic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* I/O SAPIC ID */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 GlobalIrqBase; /* Global interrupt for SAPIC start */ + UINT64 Address; /* SAPIC physical address */ + +} ACPI_MADT_IO_SAPIC; + +/* 7: Local Sapic */ + +typedef struct acpi_madt_local_sapic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT8 Id; /* SAPIC ID */ + UINT8 Eid; /* SAPIC EID */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + UINT32 LapicFlags; + UINT32 Uid; /* Numeric UID - ACPI 3.0 */ + char UidString[1]; /* String UID - ACPI 3.0 */ + +} ACPI_MADT_LOCAL_SAPIC; + +/* 8: Platform Interrupt Source */ + +typedef struct acpi_madt_interrupt_source +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT8 Type; /* 1=PMI, 2=INIT, 3=corrected */ + UINT8 Id; /* Processor ID */ + UINT8 Eid; /* Processor EID */ + UINT8 IoSapicVector; /* Vector value for PMI interrupts */ + UINT32 GlobalIrq; /* Global system interrupt */ + UINT32 Flags; /* Interrupt Source Flags */ + +} ACPI_MADT_INTERRUPT_SOURCE; + +/* Flags field above */ + +#define ACPI_MADT_CPEI_OVERRIDE (1) + + +/* + * Common flags fields for MADT subtables + */ + +/* MADT Local APIC flags (LapicFlags) */ + +#define ACPI_MADT_ENABLED (1) /* 00: Processor is usable if set */ + +/* MADT MPS INTI flags (IntiFlags) */ + +#define ACPI_MADT_POLARITY_MASK (3) /* 00-01: Polarity of APIC I/O input signals */ +#define ACPI_MADT_TRIGGER_MASK (3<<2) /* 02-03: Trigger mode of APIC input signals */ + +/* Values for MPS INTI flags */ + +#define ACPI_MADT_POLARITY_CONFORMS 0 +#define ACPI_MADT_POLARITY_ACTIVE_HIGH 1 +#define ACPI_MADT_POLARITY_RESERVED 2 +#define ACPI_MADT_POLARITY_ACTIVE_LOW 3 + +#define ACPI_MADT_TRIGGER_CONFORMS (0) +#define ACPI_MADT_TRIGGER_EDGE (1<<2) +#define ACPI_MADT_TRIGGER_RESERVED (2<<2) +#define ACPI_MADT_TRIGGER_LEVEL (3<<2) + + +/******************************************************************************* + * + * MCFG - PCI Memory Mapped Configuration table and sub-table + * + ******************************************************************************/ + +typedef struct acpi_table_mcfg +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved[8]; + +} ACPI_TABLE_MCFG; + + +/* Subtable */ + +typedef struct acpi_mcfg_allocation +{ + UINT64 Address; /* Base address, processor-relative */ + UINT16 PciSegment; /* PCI segment group number */ + UINT8 StartBusNumber; /* Starting PCI Bus number */ + UINT8 EndBusNumber; /* Final PCI Bus number */ + UINT32 Reserved; + +} ACPI_MCFG_ALLOCATION; + + +/******************************************************************************* + * + * SBST - Smart Battery Specification Table + * + ******************************************************************************/ +typedef struct acpi_table_sbst +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 WarningLevel; + UINT32 LowLevel; + UINT32 CriticalLevel; + +} ACPI_TABLE_SBST; + + +/******************************************************************************* + * + * SLIT - System Locality Distance Information Table + * + ******************************************************************************/ + +typedef struct acpi_table_slit +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 LocalityCount; + UINT8 Entry[1]; /* Real size = localities^2 */ + +} ACPI_TABLE_SLIT; + + +/******************************************************************************* + * + * SPCR - Serial Port Console Redirection table + * + ******************************************************************************/ + +typedef struct acpi_table_spcr +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 InterfaceType; /* 0=full 16550, 1=subset of 16550 */ + UINT8 Reserved[3]; + ACPI_GENERIC_ADDRESS SerialPort; + UINT8 InterruptType; + UINT8 PcInterrupt; + UINT32 Interrupt; + UINT8 BaudRate; + UINT8 Parity; + UINT8 StopBits; + UINT8 FlowControl; + UINT8 TerminalType; + UINT8 Reserved1; + UINT16 PciDeviceId; + UINT16 PciVendorId; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + UINT32 PciFlags; + UINT8 PciSegment; + UINT32 Reserved2; + +} ACPI_TABLE_SPCR; + + +/******************************************************************************* + * + * SPMI - Server Platform Management Interface table + * + ******************************************************************************/ + +typedef struct acpi_table_spmi +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 Reserved; + UINT8 InterfaceType; + UINT16 SpecRevision; /* Version of IPMI */ + UINT8 InterruptType; + UINT8 GpeNumber; /* GPE assigned */ + UINT8 Reserved1; + UINT8 PciDeviceFlag; + UINT32 Interrupt; + ACPI_GENERIC_ADDRESS IpmiRegister; + UINT8 PciSegment; + UINT8 PciBus; + UINT8 PciDevice; + UINT8 PciFunction; + +} ACPI_TABLE_SPMI; + + +/******************************************************************************* + * + * SRAT - System Resource Affinity Table + * + ******************************************************************************/ + +typedef struct acpi_table_srat +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 TableRevision; /* Must be value '1' */ + UINT64 Reserved; /* Reserved, must be zero */ + +} ACPI_TABLE_SRAT; + +/* Values for subtable type in ACPI_SUBTABLE_HEADER */ + +enum AcpiSratType +{ + ACPI_SRAT_TYPE_CPU_AFFINITY = 0, + ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, + ACPI_SRAT_TYPE_RESERVED = 2 +}; + +/* SRAT sub-tables */ + +typedef struct acpi_srat_cpu_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProximityDomainLo; + UINT8 ApicId; + UINT32 Flags; + UINT8 LocalSapicEid; + UINT8 ProximityDomainHi[3]; + UINT32 Reserved; /* Reserved, must be zero */ + +} ACPI_SRAT_CPU_AFFINITY; + +/* Flags */ + +#define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ + + +typedef struct acpi_srat_mem_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 ProximityDomain; + UINT16 Reserved; /* Reserved, must be zero */ + UINT64 BaseAddress; + UINT64 Length; + UINT32 MemoryType; /* See acpi_address_range_id */ + UINT32 Flags; + UINT64 Reserved1; /* Reserved, must be zero */ + +} ACPI_SRAT_MEM_AFFINITY; + +/* Flags */ + +#define ACPI_SRAT_MEM_ENABLED (1) /* 00: Use affinity structure */ +#define ACPI_SRAT_MEM_HOT_PLUGGABLE (1<<1) /* 01: Memory region is hot pluggable */ +#define ACPI_SRAT_MEM_NON_VOLATILE (1<<2) /* 02: Memory region is non-volatile */ + +/* Memory types */ + +enum acpi_address_range_id +{ + ACPI_ADDRESS_RANGE_MEMORY = 1, + ACPI_ADDRESS_RANGE_RESERVED = 2, + ACPI_ADDRESS_RANGE_ACPI = 3, + ACPI_ADDRESS_RANGE_NVS = 4, + ACPI_ADDRESS_RANGE_COUNT = 5 +}; + + +/******************************************************************************* + * + * TCPA - Trusted Computing Platform Alliance table + * + ******************************************************************************/ + +typedef struct acpi_table_tcpa +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT16 Reserved; + UINT32 MaxLogLength; /* Maximum length for the event log area */ + UINT64 LogAddress; /* Address of the event log area */ + +} ACPI_TABLE_TCPA; + + +/******************************************************************************* + * + * WDRT - Watchdog Resource Table + * + ******************************************************************************/ + +typedef struct acpi_table_wdrt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; /* Watchdog Header Length */ + UINT8 PciSegment; /* PCI Segment number */ + UINT8 PciBus; /* PCI Bus number */ + UINT8 PciDevice; /* PCI Device number */ + UINT8 PciFunction; /* PCI Function number */ + UINT32 TimerPeriod; /* Period of one timer count (msec) */ + UINT32 MaxCount; /* Maximum counter value supported */ + UINT32 MinCount; /* Minimum counter value */ + UINT8 Flags; + UINT8 Reserved[3]; + UINT32 Entries; /* Number of watchdog entries that follow */ + +} ACPI_TABLE_WDRT; + +/* Flags */ + +#define ACPI_WDRT_TIMER_ENABLED (1) /* 00: Timer enabled */ + + +/* Reset to default packing */ + +#pragma pack() + +#endif /* __ACTBL1_H__ */ diff --git a/sys/dist/acpica/actbl2.h b/sys/dist/acpica/actbl2.h index 97f099f0b3e..c71095f8e87 100644 --- a/sys/dist/acpica/actbl2.h +++ b/sys/dist/acpica/actbl2.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actbl2.h - ACPI Specification Revision 2.0 Tables - * xRevision: 1.47 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -117,272 +117,7 @@ #ifndef __ACTBL2_H__ #define __ACTBL2_H__ -/* - * Prefered Power Management Profiles - */ -#define PM_UNSPECIFIED 0 -#define PM_DESKTOP 1 -#define PM_MOBILE 2 -#define PM_WORKSTATION 3 -#define PM_ENTERPRISE_SERVER 4 -#define PM_SOHO_SERVER 5 -#define PM_APPLIANCE_PC 6 - -/* - * ACPI Boot Arch Flags - */ -#define BAF_LEGACY_DEVICES 0x0001 -#define BAF_8042_KEYBOARD_CONTROLLER 0x0002 - -#define FADT2_REVISION_ID 3 -#define FADT2_MINUS_REVISION_ID 2 - - -#pragma pack(1) - -/* - * ACPI 2.0 Root System Description Table (RSDT) - */ -typedef struct rsdt_descriptor_rev2 -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT32 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ - -} RSDT_DESCRIPTOR_REV2; - - -/* - * ACPI 2.0 Extended System Description Table (XSDT) - */ -typedef struct xsdt_descriptor_rev2 -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT64 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ - -} XSDT_DESCRIPTOR_REV2; - - -/* - * ACPI 2.0 Firmware ACPI Control Structure (FACS) - */ -typedef struct facs_descriptor_rev2 -{ - char Signature[4]; /* ASCII table signature */ - UINT32 Length; /* Length of structure, in bytes */ - UINT32 HardwareSignature; /* Hardware configuration signature */ - UINT32 FirmwareWakingVector; /* 32-bit physical address of the Firmware Waking Vector. */ - UINT32 GlobalLock; /* Global Lock used to synchronize access to shared hardware resources */ - - /* Flags (32 bits) */ - - UINT8 S4Bios_f : 1; /* 00: S4BIOS support is present */ - UINT8 : 7; /* 01-07: Reserved, must be zero */ - UINT8 Reserved1[3]; /* 08-31: Reserved, must be zero */ - - UINT64 XFirmwareWakingVector; /* 64-bit physical address of the Firmware Waking Vector. */ - UINT8 Version; /* Version of this table */ - UINT8 Reserved3[31]; /* Reserved, must be zero */ - -} FACS_DESCRIPTOR_REV2; - - -/* - * ACPI 2.0+ Generic Address Structure (GAS) - */ -typedef struct acpi_generic_address -{ - UINT8 AddressSpaceId; /* Address space where struct or register exists. */ - UINT8 RegisterBitWidth; /* Size in bits of given register */ - UINT8 RegisterBitOffset; /* Bit offset within the register */ - UINT8 AccessWidth; /* Minimum Access size (ACPI 3.0) */ - UINT64 Address; /* 64-bit address of struct or register */ - -} ACPI_GENERIC_ADDRESS; - - -#define FADT_REV2_COMMON \ - UINT32 V1_FirmwareCtrl; /* 32-bit physical address of FACS */ \ - UINT32 V1_Dsdt; /* 32-bit physical address of DSDT */ \ - UINT8 Reserved1; /* System Interrupt Model isn't used in ACPI 2.0*/ \ - UINT8 Prefer_PM_Profile; /* Conveys preferred power management profile to OSPM. */ \ - UINT16 SciInt; /* System vector of SCI interrupt */ \ - UINT32 SmiCmd; /* Port address of SMI command port */ \ - UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */ \ - UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */ \ - UINT8 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */ \ - UINT8 PstateCnt; /* Processor performance state control*/ \ - UINT32 V1_Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */ \ - UINT32 V1_Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */ \ - UINT32 V1_Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */ \ - UINT32 V1_Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */ \ - UINT32 V1_Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */ \ - UINT32 V1_PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ \ - UINT32 V1_Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */ \ - UINT32 V1_Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */ \ - UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */ \ - UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */ \ - UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */ \ - UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */ \ - UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */ \ - UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */ \ - UINT8 Gpe1Base; /* Offset in gpe model where gpe1 events start */ \ - UINT8 CstCnt; /* Support for the _CST object and C States change notification.*/ \ - UINT16 Plvl2Lat; /* Worst case HW latency to enter/exit C2 state */ \ - UINT16 Plvl3Lat; /* Worst case HW latency to enter/exit C3 state */ \ - UINT16 FlushSize; /* Number of flush strides that need to be read */ \ - UINT16 FlushStride; /* Processor's memory cache line width, in bytes */ \ - UINT8 DutyOffset; /* Processor's duty cycle index in processor's P_CNT reg*/ \ - UINT8 DutyWidth; /* Processor's duty cycle value bit width in P_CNT register.*/ \ - UINT8 DayAlrm; /* Index to day-of-month alarm in RTC CMOS RAM */ \ - UINT8 MonAlrm; /* Index to month-of-year alarm in RTC CMOS RAM */ \ - UINT8 Century; /* Index to century in RTC CMOS RAM */ \ - UINT16 IapcBootArch; /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/ - -/* - * ACPI 2.0+ Fixed ACPI Description Table (FADT) - */ -typedef struct fadt_descriptor_rev2 -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - FADT_REV2_COMMON - UINT8 Reserved2; /* Reserved, must be zero */ - - /* Flags (32 bits) */ - - UINT8 WbInvd : 1; /* 00: The wbinvd instruction works properly */ - UINT8 WbInvdFlush : 1; /* 01: The wbinvd flushes but does not invalidate */ - UINT8 ProcC1 : 1; /* 02: All processors support C1 state */ - UINT8 Plvl2Up : 1; /* 03: C2 state works on MP system */ - UINT8 PwrButton : 1; /* 04: Power button is handled as a generic feature */ - UINT8 SleepButton : 1; /* 05: Sleep button is handled as a generic feature, or not present */ - UINT8 FixedRTC : 1; /* 06: RTC wakeup stat not in fixed register space */ - UINT8 Rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ - UINT8 TmrValExt : 1; /* 08: tmr_val is 32 bits 0=24-bits */ - UINT8 DockCap : 1; /* 09: Docking supported */ - UINT8 ResetRegSup : 1; /* 10: System reset via the FADT RESET_REG supported */ - UINT8 SealedCase : 1; /* 11: No internal expansion capabilities and case is sealed */ - UINT8 Headless : 1; /* 12: No local video capabilities or local input devices */ - UINT8 CpuSwSleep : 1; /* 13: Must execute native instruction after writing SLP_TYPx register */ - - UINT8 PciExpWak : 1; /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ - UINT8 UsePlatformClock : 1; /* 15: OSPM should use platform-provided timer (ACPI 3.0) */ - UINT8 S4RtcStsValid : 1; /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ - UINT8 RemotePowerOnCapable : 1; /* 17: System is compatible with remote power on (ACPI 3.0) */ - UINT8 ForceApicClusterModel : 1; /* 18: All local APICs must use cluster model (ACPI 3.0) */ - UINT8 ForceApicPhysicalDestinationMode : 1; /* 19: All local xAPICs must use physical dest mode (ACPI 3.0) */ - UINT8 : 4; /* 20-23: Reserved, must be zero */ - UINT8 Reserved3; /* 24-31: Reserved, must be zero */ - - ACPI_GENERIC_ADDRESS ResetRegister; /* Reset register address in GAS format */ - UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ - UINT8 Reserved4[3]; /* These three bytes must be zero */ - UINT64 XFirmwareCtrl; /* 64-bit physical address of FACS */ - UINT64 XDsdt; /* 64-bit physical address of DSDT */ - ACPI_GENERIC_ADDRESS XPm1aEvtBlk; /* Extended Power Mgt 1a AcpiEvent Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1bEvtBlk; /* Extended Power Mgt 1b AcpiEvent Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1aCntBlk; /* Extended Power Mgt 1a Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1bCntBlk; /* Extended Power Mgt 1b Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm2CntBlk; /* Extended Power Mgt 2 Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPmTmrBlk; /* Extended Power Mgt Timer Ctrl Reg Blk address */ - ACPI_GENERIC_ADDRESS XGpe0Blk; /* Extended General Purpose AcpiEvent 0 Reg Blk address */ - ACPI_GENERIC_ADDRESS XGpe1Blk; /* Extended General Purpose AcpiEvent 1 Reg Blk address */ - -} FADT_DESCRIPTOR_REV2; - - -/* "Down-revved" ACPI 2.0 FADT descriptor */ - -typedef struct fadt_descriptor_rev2_minus -{ - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - FADT_REV2_COMMON - UINT8 Reserved2; /* Reserved, must be zero */ - UINT32 Flags; - ACPI_GENERIC_ADDRESS ResetRegister; /* Reset register address in GAS format */ - UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system. */ - UINT8 Reserved7[3]; /* Reserved, must be zero */ - -} FADT_DESCRIPTOR_REV2_MINUS; - - -/* ECDT - Embedded Controller Boot Resources Table */ - -typedef struct ec_boot_resources -{ - ACPI_TABLE_HEADER_DEF - ACPI_GENERIC_ADDRESS EcControl; /* Address of EC command/status register */ - ACPI_GENERIC_ADDRESS EcData; /* Address of EC data register */ - UINT32 Uid; /* Unique ID - must be same as the EC _UID method */ - UINT8 GpeBit; /* The GPE for the EC */ - UINT8 EcId[1]; /* Full namepath of the EC in the ACPI namespace */ - -} EC_BOOT_RESOURCES; - - -/* SRAT - System Resource Affinity Table */ - -typedef struct static_resource_alloc -{ - UINT8 Type; - UINT8 Length; - UINT8 ProximityDomainLo; - UINT8 ApicId; - - /* Flags (32 bits) */ - - UINT8 Enabled :1; /* 00: Use affinity structure */ - UINT8 :7; /* 01-07: Reserved, must be zero */ - UINT8 Reserved3[3]; /* 08-31: Reserved, must be zero */ - - UINT8 LocalSapicEid; - UINT8 ProximityDomainHi[3]; - UINT32 Reserved4; /* Reserved, must be zero */ - -} STATIC_RESOURCE_ALLOC; - -typedef struct memory_affinity -{ - UINT8 Type; - UINT8 Length; - UINT32 ProximityDomain; - UINT16 Reserved3; - UINT64 BaseAddress; - UINT64 AddressLength; - UINT32 Reserved4; - - /* Flags (32 bits) */ - - UINT8 Enabled :1; /* 00: Use affinity structure */ - UINT8 HotPluggable :1; /* 01: Memory region is hot pluggable */ - UINT8 NonVolatile :1; /* 02: Memory is non-volatile */ - UINT8 :5; /* 03-07: Reserved, must be zero */ - UINT8 Reserved5[3]; /* 08-31: Reserved, must be zero */ - - UINT64 Reserved6; /* Reserved, must be zero */ - -} MEMORY_AFFINITY; - -typedef struct system_resource_affinity -{ - ACPI_TABLE_HEADER_DEF - UINT32 Reserved1; /* Must be value '1' */ - UINT64 Reserved2; /* Reserved, must be zero */ - -} SYSTEM_RESOURCE_AFFINITY; - - -/* SLIT - System Locality Distance Information Table */ - -typedef struct system_locality_info -{ - ACPI_TABLE_HEADER_DEF - UINT64 LocalityCount; - UINT8 Entry[1][1]; - -} SYSTEM_LOCALITY_INFO; - - -#pragma pack() +/* Code moved to both actbl.h and actbl1.h */ #endif /* __ACTBL2_H__ */ diff --git a/sys/dist/acpica/actypes.h b/sys/dist/acpica/actypes.h index 9d5d15821a9..42335490288 100644 --- a/sys/dist/acpica/actypes.h +++ b/sys/dist/acpica/actypes.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem - * xRevision: 1.301 $ + * $Revision: 1.3 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -117,15 +117,17 @@ #ifndef __ACTYPES_H__ #define __ACTYPES_H__ +/* acpisrc:StructDefs -- for acpisrc conversion */ + /* * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent header - * and must be either 16, 32, or 64 + * and must be either 32 or 64. 16-bit ACPICA is no longer supported, as of + * 12/2006. */ #ifndef ACPI_MACHINE_WIDTH #error ACPI_MACHINE_WIDTH not defined #endif - /*! [Begin] no source code translation */ /* @@ -224,7 +226,6 @@ typedef int INT32; typedef UINT64 ACPI_NATIVE_UINT; typedef INT64 ACPI_NATIVE_INT; -typedef UINT64 ACPI_TABLE_PTR; typedef UINT64 ACPI_IO_ADDRESS; typedef UINT64 ACPI_PHYSICAL_ADDRESS; @@ -266,51 +267,15 @@ typedef int INT32; typedef UINT32 ACPI_NATIVE_UINT; typedef INT32 ACPI_NATIVE_INT; -typedef UINT64 ACPI_TABLE_PTR; typedef UINT32 ACPI_IO_ADDRESS; -typedef UINT64 ACPI_PHYSICAL_ADDRESS; +typedef UINT32 ACPI_PHYSICAL_ADDRESS; #define ACPI_MAX_PTR ACPI_UINT32_MAX #define ACPI_SIZE_MAX ACPI_UINT32_MAX - -/******************************************************************************* - * - * Types specific to 16-bit targets - * - ******************************************************************************/ - -#elif ACPI_MACHINE_WIDTH == 16 - -/*! [Begin] no source code translation (keep the typedefs as-is) */ - -typedef unsigned long UINT32; -typedef short INT16; -typedef long INT32; - -/*! [End] no source code translation !*/ - - -typedef UINT16 ACPI_NATIVE_UINT; -typedef INT16 ACPI_NATIVE_INT; - -typedef UINT32 ACPI_TABLE_PTR; -typedef UINT32 ACPI_IO_ADDRESS; -typedef char *ACPI_PHYSICAL_ADDRESS; - -#define ACPI_MAX_PTR ACPI_UINT16_MAX -#define ACPI_SIZE_MAX ACPI_UINT16_MAX - -#define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */ - -/* 64-bit integers cannot be supported */ - -#define ACPI_NO_INTEGER64_SUPPORT - - #else -/* ACPI_MACHINE_WIDTH must be either 64, 32, or 16 */ +/* ACPI_MACHINE_WIDTH must be either 64 or 32 */ #error unknown ACPI_MACHINE_WIDTH #endif @@ -323,37 +288,45 @@ typedef ACPI_NATIVE_UINT ACPI_SIZE; /******************************************************************************* * - * OS- or compiler-dependent types + * OS-dependent and compiler-dependent types * - * If the defaults below are not appropriate for the host system, they can + * If the defaults below are not appropriate for the host system, they can * be defined in the compiler-specific or OS-specific header, and this will * take precedence. * ******************************************************************************/ -/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ -#ifndef ACPI_UINTPTR_T -#define ACPI_UINTPTR_T void * +/* Value returned by AcpiOsGetThreadId */ + +#ifndef ACPI_THREAD_ID +#define ACPI_THREAD_ID ACPI_NATIVE_UINT #endif -/* - * If ACPI_CACHE_T was not defined in the OS-dependent header, - * define it now. This is typically the case where the local cache - * manager implementation is to be used (ACPI_USE_LOCAL_CACHE) - */ -#ifndef ACPI_CACHE_T -#define ACPI_CACHE_T ACPI_MEMORY_LIST +/* Object returned from AcpiOsCreateLock */ + +#ifndef ACPI_SPINLOCK +#define ACPI_SPINLOCK void * #endif -/* - * Allow the CPU flags word to be defined per-OS to simplify the use of the - * lock and unlock OSL interfaces. - */ +/* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */ + #ifndef ACPI_CPU_FLAGS #define ACPI_CPU_FLAGS ACPI_NATIVE_UINT #endif +/* Object returned from AcpiOsCreateCache */ + +#ifndef ACPI_CACHE_T +#define ACPI_CACHE_T ACPI_MEMORY_LIST +#endif + +/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ + +#ifndef ACPI_UINTPTR_T +#define ACPI_UINTPTR_T void * +#endif + /* * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because * some compilers can catch printf format string problems @@ -372,6 +345,14 @@ typedef ACPI_NATIVE_UINT ACPI_SIZE; #define ACPI_UNUSED_VAR #endif +/* + * All ACPICA functions that are available to the rest of the kernel are + * tagged with this macro which can be defined as appropriate for the host. + */ +#ifndef ACPI_EXPORT_SYMBOL +#define ACPI_EXPORT_SYMBOL(Symbol) +#endif + /******************************************************************************* * @@ -379,41 +360,6 @@ typedef ACPI_NATIVE_UINT ACPI_SIZE; * ******************************************************************************/ -/* - * Pointer overlays to avoid lots of typecasting for - * code that accepts both physical and logical pointers. - */ -typedef union acpi_pointers -{ - ACPI_PHYSICAL_ADDRESS Physical; - void *Logical; - ACPI_TABLE_PTR Value; - -} ACPI_POINTERS; - -typedef struct acpi_pointer -{ - UINT32 PointerType; - union acpi_pointers Pointer; - -} ACPI_POINTER; - -/* PointerTypes for above */ - -#define ACPI_PHYSICAL_POINTER 0x01 -#define ACPI_LOGICAL_POINTER 0x02 - -/* Processor mode */ - -#define ACPI_PHYSICAL_ADDRESSING 0x04 -#define ACPI_LOGICAL_ADDRESSING 0x08 -#define ACPI_MEMORY_MODE 0x0C - -#define ACPI_PHYSMODE_PHYSPTR ACPI_PHYSICAL_ADDRESSING | ACPI_PHYSICAL_POINTER -#define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER -#define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER - - /* Logical defines and NULL */ #ifdef FALSE @@ -437,54 +383,43 @@ typedef struct acpi_pointer typedef UINT32 ACPI_STATUS; /* All ACPI Exceptions */ typedef UINT32 ACPI_NAME; /* 4-byte ACPI name */ typedef char * ACPI_STRING; /* Null terminated ASCII string */ -typedef const char * ACPI_CONST_STRING; /* Null terminated ASCII string */ -typedef void * ACPI_HANDLE; /* Actually a ptr to a NS Node */ +typedef const char * ACPI_CONST_STRING; /* Null terminated ASCII string */ +typedef void * ACPI_HANDLE; /* Actually a ptr to a NS Node */ typedef struct uint64_struct { - UINT32 Lo; - UINT32 Hi; + UINT32 Lo; + UINT32 Hi; } UINT64_STRUCT; typedef union uint64_overlay { - UINT64 Full; - UINT64_STRUCT Part; + UINT64 Full; + UINT64_STRUCT Part; } UINT64_OVERLAY; typedef struct uint32_struct { - UINT32 Lo; - UINT32 Hi; + UINT32 Lo; + UINT32 Hi; } UINT32_STRUCT; -/* - * Acpi integer width. In ACPI version 1, integers are - * 32 bits. In ACPI version 2, integers are 64 bits. - * Note that this pertains to the ACPI integer type only, not - * other integers used in the implementation of the ACPI CA - * subsystem. - */ -#ifdef ACPI_NO_INTEGER64_SUPPORT - -/* 32-bit integers only, no 64-bit support */ - -typedef UINT32 ACPI_INTEGER; -#define ACPI_INTEGER_MAX ACPI_UINT32_MAX -#define ACPI_INTEGER_BIT_SIZE 32 -#define ACPI_MAX_DECIMAL_DIGITS 10 /* 2^32 = 4,294,967,296 */ +/* Synchronization objects */ -#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */ +#define ACPI_MUTEX void * +#define ACPI_SEMAPHORE void * -#else - -/* 64-bit integers */ - +/* + * Acpi integer width. In ACPI version 1, integers are 32 bits. In ACPI + * version 2, integers are 64 bits. Note that this pertains to the ACPI integer + * type only, not other integers used in the implementation of the ACPI CA + * subsystem. + */ typedef UINT64 ACPI_INTEGER; #define ACPI_INTEGER_MAX ACPI_UINT64_MAX #define ACPI_INTEGER_BIT_SIZE 64 @@ -494,7 +429,6 @@ typedef UINT64 ACPI_INTEGER; #if ACPI_MACHINE_WIDTH == 64 #define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ #endif -#endif #define ACPI_MAX64_DECIMAL_DIGITS 20 #define ACPI_MAX32_DECIMAL_DIGITS 10 @@ -522,7 +456,8 @@ typedef UINT64 ACPI_INTEGER; /* * Initialization state */ -#define ACPI_INITIALIZED_OK 0x01 +#define ACPI_SUBSYSTEM_INITIALIZE 0x01 +#define ACPI_INITIALIZED_OK 0x02 /* * Power state values @@ -571,21 +506,6 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NOTIFY_POWER_FAULT (UINT8) 7 /* - * Table types. These values are passed to the table related APIs - */ -typedef UINT32 ACPI_TABLE_TYPE; - -#define ACPI_TABLE_RSDP (ACPI_TABLE_TYPE) 0 -#define ACPI_TABLE_DSDT (ACPI_TABLE_TYPE) 1 -#define ACPI_TABLE_FADT (ACPI_TABLE_TYPE) 2 -#define ACPI_TABLE_FACS (ACPI_TABLE_TYPE) 3 -#define ACPI_TABLE_PSDT (ACPI_TABLE_TYPE) 4 -#define ACPI_TABLE_SSDT (ACPI_TABLE_TYPE) 5 -#define ACPI_TABLE_XSDT (ACPI_TABLE_TYPE) 6 -#define ACPI_TABLE_MAX 6 -#define NUM_ACPI_TABLE_TYPES (ACPI_TABLE_MAX+1) - -/* * Types associated with ACPI names and objects. The first group of * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore, @@ -718,7 +638,7 @@ typedef UINT32 ACPI_EVENT_STATUS; * | | | +--- Type of dispatch -- to method, handler, or none * | | +--- Enabled for runtime? * | +--- Enabled for wake? - * +--- System state when GPE ocurred (running/waking) + * +--- Unused */ #define ACPI_GPE_XRUPT_TYPE_MASK (UINT8) 0x01 #define ACPI_GPE_LEVEL_TRIGGERED (UINT8) 0x01 @@ -744,10 +664,6 @@ typedef UINT32 ACPI_EVENT_STATUS; #define ACPI_GPE_ENABLE_MASK (UINT8) 0x60 /* Both run/wake */ -#define ACPI_GPE_SYSTEM_MASK (UINT8) 0x80 -#define ACPI_GPE_SYSTEM_RUNNING (UINT8) 0x80 -#define ACPI_GPE_SYSTEM_WAKING (UINT8) 0x00 - /* * Flags for GPE and Lock interfaces */ @@ -822,54 +738,54 @@ typedef UINT8 ACPI_ADR_SPACE_TYPE; */ typedef union acpi_object { - ACPI_OBJECT_TYPE Type; /* See definition of AcpiNsType for values */ + ACPI_OBJECT_TYPE Type; /* See definition of AcpiNsType for values */ struct { - ACPI_OBJECT_TYPE Type; - ACPI_INTEGER Value; /* The actual number */ + ACPI_OBJECT_TYPE Type; + ACPI_INTEGER Value; /* The actual number */ } Integer; struct { - ACPI_OBJECT_TYPE Type; - UINT32 Length; /* # of bytes in string, excluding trailing null */ - const char *Pointer; /* points to the string value */ + ACPI_OBJECT_TYPE Type; + UINT32 Length; /* # of bytes in string, excluding trailing null */ + char *Pointer; /* points to the string value */ } String; struct { - ACPI_OBJECT_TYPE Type; - UINT32 Length; /* # of bytes in buffer */ - UINT8 *Pointer; /* points to the buffer */ + ACPI_OBJECT_TYPE Type; + UINT32 Length; /* # of bytes in buffer */ + UINT8 *Pointer; /* points to the buffer */ } Buffer; struct { - ACPI_OBJECT_TYPE Type; - UINT32 Fill1; - ACPI_HANDLE Handle; /* object reference */ + ACPI_OBJECT_TYPE Type; + UINT32 Fill1; + ACPI_HANDLE Handle; /* object reference */ } Reference; struct { - ACPI_OBJECT_TYPE Type; - UINT32 Count; /* # of elements in package */ - union acpi_object *Elements; /* Pointer to an array of ACPI_OBJECTs */ + ACPI_OBJECT_TYPE Type; + UINT32 Count; /* # of elements in package */ + union acpi_object *Elements; /* Pointer to an array of ACPI_OBJECTs */ } Package; struct { - ACPI_OBJECT_TYPE Type; - UINT32 ProcId; - ACPI_IO_ADDRESS PblkAddress; - UINT32 PblkLength; + ACPI_OBJECT_TYPE Type; + UINT32 ProcId; + ACPI_IO_ADDRESS PblkAddress; + UINT32 PblkLength; } Processor; struct { - ACPI_OBJECT_TYPE Type; - UINT32 SystemLevel; - UINT32 ResourceOrder; + ACPI_OBJECT_TYPE Type; + UINT32 SystemLevel; + UINT32 ResourceOrder; } PowerResource; } ACPI_OBJECT; @@ -880,8 +796,8 @@ typedef union acpi_object */ typedef struct acpi_object_list { - UINT32 Count; - ACPI_OBJECT *Pointer; + UINT32 Count; + ACPI_OBJECT *Pointer; } ACPI_OBJECT_LIST; @@ -895,8 +811,8 @@ typedef struct acpi_object_list typedef struct acpi_buffer { - ACPI_SIZE Length; /* Length in bytes of the buffer */ - void *Pointer; /* pointer to buffer */ + ACPI_SIZE Length; /* Length in bytes of the buffer */ + void *Pointer; /* pointer to buffer */ } ACPI_BUFFER; @@ -919,29 +835,17 @@ typedef struct acpi_buffer /* - * ACPI Table Info. One per ACPI table _type_ - */ -typedef struct acpi_table_info -{ - UINT32 Count; - -} ACPI_TABLE_INFO; - - -/* * System info returned by AcpiGetSystemInfo() */ typedef struct acpi_system_info { - UINT32 AcpiCaVersion; - UINT32 Flags; - UINT32 TimerResolution; - UINT32 Reserved1; - UINT32 Reserved2; - UINT32 DebugLevel; - UINT32 DebugLayer; - UINT32 NumTableTypes; - ACPI_TABLE_INFO TableInfo [NUM_ACPI_TABLE_TYPES]; + UINT32 AcpiCaVersion; + UINT32 Flags; + UINT32 TimerResolution; + UINT32 Reserved1; + UINT32 Reserved2; + UINT32 DebugLevel; + UINT32 DebugLayer; } ACPI_SYSTEM_INFO; @@ -951,77 +855,77 @@ typedef struct acpi_system_info */ typedef UINT32 (ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) ( - void *Context); + void *Context); typedef void (ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) ( - void *Context); + void *Context); /* * Various handlers and callback procedures */ typedef UINT32 (*ACPI_EVENT_HANDLER) ( - void *Context); + void *Context); typedef void (*ACPI_NOTIFY_HANDLER) ( - ACPI_HANDLE Device, - UINT32 Value, - void *Context); + ACPI_HANDLE Device, + UINT32 Value, + void *Context); typedef void (*ACPI_OBJECT_HANDLER) ( - ACPI_HANDLE Object, - UINT32 Function, - void *Data); + ACPI_HANDLE Object, + UINT32 Function, + void *Data); typedef ACPI_STATUS (*ACPI_INIT_HANDLER) ( - ACPI_HANDLE Object, - UINT32 Function); + ACPI_HANDLE Object, + UINT32 Function); #define ACPI_INIT_DEVICE_INI 1 typedef ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) ( - ACPI_STATUS AmlStatus, - ACPI_NAME Name, - UINT16 Opcode, - UINT32 AmlOffset, - void *Context); + ACPI_STATUS AmlStatus, + ACPI_NAME Name, + UINT16 Opcode, + UINT32 AmlOffset, + void *Context); /* Address Spaces (For Operation Regions) */ typedef ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) ( - UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, - UINT32 BitWidth, - ACPI_INTEGER *Value, - void *HandlerContext, - void *RegionContext); + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); -#define ACPI_DEFAULT_HANDLER NULL +#define ACPI_DEFAULT_HANDLER NULL typedef ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) ( - ACPI_HANDLE RegionHandle, - UINT32 Function, - void *HandlerContext, - void **RegionContext); + ACPI_HANDLE RegionHandle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); #define ACPI_REGION_ACTIVATE 0 #define ACPI_REGION_DEACTIVATE 1 typedef ACPI_STATUS (*ACPI_WALK_CALLBACK) ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); /* Interrupt handler return values */ @@ -1034,7 +938,7 @@ ACPI_STATUS (*ACPI_WALK_CALLBACK) ( typedef struct acpi_device_id { - char Value[ACPI_DEVICE_ID_LENGTH]; + char Value[ACPI_DEVICE_ID_LENGTH]; } ACPI_DEVICE_ID; @@ -1042,15 +946,15 @@ typedef struct acpi_device_id typedef struct acpi_compatible_id { - char Value[ACPI_MAX_CID_LENGTH]; + char Value[ACPI_MAX_CID_LENGTH]; } ACPI_COMPATIBLE_ID; typedef struct acpi_compatible_id_list { - UINT32 Count; - UINT32 Size; - ACPI_COMPATIBLE_ID Id[1]; + UINT32 Count; + UINT32 Size; + ACPI_COMPATIBLE_ID Id[1]; } ACPI_COMPATIBLE_ID_LIST; @@ -1069,13 +973,14 @@ typedef struct acpi_compatible_id_list #define ACPI_STA_DEVICE_PRESENT 0x01 #define ACPI_STA_DEVICE_ENABLED 0x02 #define ACPI_STA_DEVICE_UI 0x04 -#define ACPI_STA_DEVICE_OK 0x08 +#define ACPI_STA_DEVICE_FUNCTIONING 0x08 +#define ACPI_STA_DEVICE_OK 0x08 /* Synonym */ #define ACPI_STA_BATTERY_PRESENT 0x10 #define ACPI_COMMON_OBJ_INFO \ - ACPI_OBJECT_TYPE Type; /* ACPI object type */ \ - ACPI_NAME Name /* ACPI object Name */ + ACPI_OBJECT_TYPE Type; /* ACPI object type */ \ + ACPI_NAME Name /* ACPI object Name */ typedef struct acpi_obj_info_header @@ -1091,13 +996,13 @@ typedef struct acpi_device_info { ACPI_COMMON_OBJ_INFO; - UINT32 Valid; /* Indicates which fields below are valid */ - UINT32 CurrentStatus; /* _STA value */ - ACPI_INTEGER Address; /* _ADR value if any */ - ACPI_DEVICE_ID HardwareId; /* _HID value if any */ - ACPI_DEVICE_ID UniqueId; /* _UID value if any */ - UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ - ACPI_COMPATIBLE_ID_LIST CompatibilityId; /* List of _CIDs if any */ + UINT32 Valid; /* Indicates which fields below are valid */ + UINT32 CurrentStatus; /* _STA value */ + ACPI_INTEGER Address; /* _ADR value if any */ + ACPI_DEVICE_ID HardwareId; /* _HID value if any */ + ACPI_DEVICE_ID UniqueId; /* _UID value if any */ + UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ + ACPI_COMPATIBLE_ID_LIST CompatibilityId; /* List of _CIDs if any */ } ACPI_DEVICE_INFO; @@ -1106,21 +1011,21 @@ typedef struct acpi_device_info typedef struct acpi_pci_id { - UINT16 Segment; - UINT16 Bus; - UINT16 Device; - UINT16 Function; + UINT16 Segment; + UINT16 Bus; + UINT16 Device; + UINT16 Function; } ACPI_PCI_ID; typedef struct acpi_mem_space_context { - UINT32 Length; - ACPI_PHYSICAL_ADDRESS Address; - ACPI_PHYSICAL_ADDRESS MappedPhysicalAddress; - UINT8 *MappedLogicalAddress; - ACPI_SIZE MappedLength; + UINT32 Length; + ACPI_PHYSICAL_ADDRESS Address; + ACPI_PHYSICAL_ADDRESS MappedPhysicalAddress; + UINT8 *MappedLogicalAddress; + ACPI_SIZE MappedLength; } ACPI_MEM_SPACE_CONTEXT; @@ -1223,13 +1128,13 @@ typedef UINT32 ACPI_RSDESC_SIZE; /* Max Resource Descr typedef struct acpi_uuid { - UINT8 Data[ACPI_UUID_LENGTH]; + UINT8 Data[ACPI_UUID_LENGTH]; } ACPI_UUID; typedef struct acpi_vendor_uuid { - UINT8 Subtype; - UINT8 Data[ACPI_UUID_LENGTH]; + UINT8 Subtype; + UINT8 Data[ACPI_UUID_LENGTH]; } ACPI_VENDOR_UUID; @@ -1238,30 +1143,30 @@ typedef struct acpi_vendor_uuid */ typedef struct acpi_resource_irq { - UINT8 Triggering; - UINT8 Polarity; - UINT8 Sharable; - UINT8 InterruptCount; - UINT8 Interrupts[1]; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + UINT8 Interrupts[1]; } ACPI_RESOURCE_IRQ; typedef struct ACPI_RESOURCE_DMA { - UINT8 Type; - UINT8 BusMaster; - UINT8 Transfer; - UINT8 ChannelCount; - UINT8 Channels[1]; + UINT8 Type; + UINT8 BusMaster; + UINT8 Transfer; + UINT8 ChannelCount; + UINT8 Channels[1]; } ACPI_RESOURCE_DMA; typedef struct acpi_resource_start_dependent { - UINT8 CompatibilityPriority; - UINT8 PerformanceRobustness; + UINT8 CompatibilityPriority; + UINT8 PerformanceRobustness; } ACPI_RESOURCE_START_DEPENDENT; @@ -1274,25 +1179,25 @@ typedef struct acpi_resource_start_dependent typedef struct acpi_resource_io { - UINT8 IoDecode; - UINT8 Alignment; - UINT8 AddressLength; - UINT16 Minimum; - UINT16 Maximum; + UINT8 IoDecode; + UINT8 Alignment; + UINT8 AddressLength; + UINT16 Minimum; + UINT16 Maximum; } ACPI_RESOURCE_IO; typedef struct acpi_resource_fixed_io { - UINT16 Address; - UINT8 AddressLength; + UINT16 Address; + UINT8 AddressLength; } ACPI_RESOURCE_FIXED_IO; typedef struct acpi_resource_vendor { - UINT16 ByteLength; - UINT8 ByteData[1]; + UINT16 ByteLength; + UINT8 ByteData[1]; } ACPI_RESOURCE_VENDOR; @@ -1300,93 +1205,93 @@ typedef struct acpi_resource_vendor typedef struct acpi_resource_vendor_typed { - UINT16 ByteLength; - UINT8 UuidSubtype; - UINT8 Uuid[ACPI_UUID_LENGTH]; - UINT8 ByteData[1]; + UINT16 ByteLength; + UINT8 UuidSubtype; + UINT8 Uuid[ACPI_UUID_LENGTH]; + UINT8 ByteData[1]; } ACPI_RESOURCE_VENDOR_TYPED; typedef struct acpi_resource_end_tag { - UINT8 Checksum; + UINT8 Checksum; } ACPI_RESOURCE_END_TAG; typedef struct acpi_resource_memory24 { - UINT8 WriteProtect; - UINT16 Minimum; - UINT16 Maximum; - UINT16 Alignment; - UINT16 AddressLength; + UINT8 WriteProtect; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; } ACPI_RESOURCE_MEMORY24; typedef struct acpi_resource_memory32 { - UINT8 WriteProtect; - UINT32 Minimum; - UINT32 Maximum; - UINT32 Alignment; - UINT32 AddressLength; + UINT8 WriteProtect; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; } ACPI_RESOURCE_MEMORY32; typedef struct acpi_resource_fixed_memory32 { - UINT8 WriteProtect; - UINT32 Address; - UINT32 AddressLength; + UINT8 WriteProtect; + UINT32 Address; + UINT32 AddressLength; } ACPI_RESOURCE_FIXED_MEMORY32; typedef struct acpi_memory_attribute { - UINT8 WriteProtect; - UINT8 Caching; - UINT8 RangeType; - UINT8 Translation; + UINT8 WriteProtect; + UINT8 Caching; + UINT8 RangeType; + UINT8 Translation; } ACPI_MEMORY_ATTRIBUTE; typedef struct acpi_io_attribute { - UINT8 RangeType; - UINT8 Translation; - UINT8 TranslationType; - UINT8 Reserved1; + UINT8 RangeType; + UINT8 Translation; + UINT8 TranslationType; + UINT8 Reserved1; } ACPI_IO_ATTRIBUTE; typedef union acpi_resource_attribute { - ACPI_MEMORY_ATTRIBUTE Mem; - ACPI_IO_ATTRIBUTE Io; + ACPI_MEMORY_ATTRIBUTE Mem; + ACPI_IO_ATTRIBUTE Io; /* Used for the *WordSpace macros */ - UINT8 TypeSpecific; + UINT8 TypeSpecific; } ACPI_RESOURCE_ATTRIBUTE; typedef struct acpi_resource_source { - UINT8 Index; - UINT16 StringLength; - char *StringPtr; + UINT8 Index; + UINT16 StringLength; + char *StringPtr; } ACPI_RESOURCE_SOURCE; /* Fields common to all address descriptors, 16/32/64 bit */ #define ACPI_RESOURCE_ADDRESS_COMMON \ - UINT8 ResourceType; \ - UINT8 ProducerConsumer; \ - UINT8 Decode; \ - UINT8 MinAddressFixed; \ - UINT8 MaxAddressFixed; \ - ACPI_RESOURCE_ATTRIBUTE Info; + UINT8 ResourceType; \ + UINT8 ProducerConsumer; \ + UINT8 Decode; \ + UINT8 MinAddressFixed; \ + UINT8 MaxAddressFixed; \ + ACPI_RESOURCE_ATTRIBUTE Info; typedef struct acpi_resource_address { @@ -1397,71 +1302,71 @@ typedef struct acpi_resource_address typedef struct acpi_resource_address16 { ACPI_RESOURCE_ADDRESS_COMMON - UINT16 Granularity; - UINT16 Minimum; - UINT16 Maximum; - UINT16 TranslationOffset; - UINT16 AddressLength; - ACPI_RESOURCE_SOURCE ResourceSource; + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; } ACPI_RESOURCE_ADDRESS16; typedef struct acpi_resource_address32 { ACPI_RESOURCE_ADDRESS_COMMON - UINT32 Granularity; - UINT32 Minimum; - UINT32 Maximum; - UINT32 TranslationOffset; - UINT32 AddressLength; - ACPI_RESOURCE_SOURCE ResourceSource; + UINT32 Granularity; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; + UINT32 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; } ACPI_RESOURCE_ADDRESS32; typedef struct acpi_resource_address64 { ACPI_RESOURCE_ADDRESS_COMMON - UINT64 Granularity; - UINT64 Minimum; - UINT64 Maximum; - UINT64 TranslationOffset; - UINT64 AddressLength; - ACPI_RESOURCE_SOURCE ResourceSource; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; } ACPI_RESOURCE_ADDRESS64; typedef struct acpi_resource_extended_address64 { ACPI_RESOURCE_ADDRESS_COMMON - UINT8 RevisionID; - UINT64 Granularity; - UINT64 Minimum; - UINT64 Maximum; - UINT64 TranslationOffset; - UINT64 AddressLength; - UINT64 TypeSpecific; + UINT8 RevisionID; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; } ACPI_RESOURCE_EXTENDED_ADDRESS64; typedef struct acpi_resource_extended_irq { - UINT8 ProducerConsumer; - UINT8 Triggering; - UINT8 Polarity; - UINT8 Sharable; - UINT8 InterruptCount; - ACPI_RESOURCE_SOURCE ResourceSource; - UINT32 Interrupts[1]; + UINT8 ProducerConsumer; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + ACPI_RESOURCE_SOURCE ResourceSource; + UINT32 Interrupts[1]; } ACPI_RESOURCE_EXTENDED_IRQ; typedef struct acpi_resource_generic_register { - UINT8 SpaceId; - UINT8 BitWidth; - UINT8 BitOffset; - UINT8 AccessSize; - UINT64 Address; + UINT8 SpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; + UINT64 Address; } ACPI_RESOURCE_GENERIC_REGISTER; @@ -1490,36 +1395,36 @@ typedef struct acpi_resource_generic_register typedef union acpi_resource_data { - ACPI_RESOURCE_IRQ Irq; - ACPI_RESOURCE_DMA Dma; - ACPI_RESOURCE_START_DEPENDENT StartDpf; - ACPI_RESOURCE_IO Io; - ACPI_RESOURCE_FIXED_IO FixedIo; - ACPI_RESOURCE_VENDOR Vendor; - ACPI_RESOURCE_VENDOR_TYPED VendorTyped; - ACPI_RESOURCE_END_TAG EndTag; - ACPI_RESOURCE_MEMORY24 Memory24; - ACPI_RESOURCE_MEMORY32 Memory32; - ACPI_RESOURCE_FIXED_MEMORY32 FixedMemory32; - ACPI_RESOURCE_ADDRESS16 Address16; - ACPI_RESOURCE_ADDRESS32 Address32; - ACPI_RESOURCE_ADDRESS64 Address64; - ACPI_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; - ACPI_RESOURCE_EXTENDED_IRQ ExtendedIrq; - ACPI_RESOURCE_GENERIC_REGISTER GenericReg; + ACPI_RESOURCE_IRQ Irq; + ACPI_RESOURCE_DMA Dma; + ACPI_RESOURCE_START_DEPENDENT StartDpf; + ACPI_RESOURCE_IO Io; + ACPI_RESOURCE_FIXED_IO FixedIo; + ACPI_RESOURCE_VENDOR Vendor; + ACPI_RESOURCE_VENDOR_TYPED VendorTyped; + ACPI_RESOURCE_END_TAG EndTag; + ACPI_RESOURCE_MEMORY24 Memory24; + ACPI_RESOURCE_MEMORY32 Memory32; + ACPI_RESOURCE_FIXED_MEMORY32 FixedMemory32; + ACPI_RESOURCE_ADDRESS16 Address16; + ACPI_RESOURCE_ADDRESS32 Address32; + ACPI_RESOURCE_ADDRESS64 Address64; + ACPI_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + ACPI_RESOURCE_EXTENDED_IRQ ExtendedIrq; + ACPI_RESOURCE_GENERIC_REGISTER GenericReg; /* Common fields */ - ACPI_RESOURCE_ADDRESS Address; /* Common 16/32/64 address fields */ + ACPI_RESOURCE_ADDRESS Address; /* Common 16/32/64 address fields */ } ACPI_RESOURCE_DATA; typedef struct acpi_resource { - UINT32 Type; - UINT32 Length; - ACPI_RESOURCE_DATA Data; + UINT32 Type; + UINT32 Length; + ACPI_RESOURCE_DATA Data; } ACPI_RESOURCE; @@ -1534,24 +1439,16 @@ typedef struct acpi_resource #define ACPI_NEXT_RESOURCE(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length) -/* - * END: of definitions for Resource Attributes - */ - typedef struct acpi_pci_routing_table { - UINT32 Length; - UINT32 Pin; - ACPI_INTEGER Address; /* here for 64-bit alignment */ - UINT32 SourceIndex; - char Source[4]; /* pad to 64 bits so sizeof() works in all cases */ + UINT32 Length; + UINT32 Pin; + ACPI_INTEGER Address; /* here for 64-bit alignment */ + UINT32 SourceIndex; + char Source[4]; /* pad to 64 bits so sizeof() works in all cases */ } ACPI_PCI_ROUTING_TABLE; -/* - * END: of definitions for PCI Routing tables - */ - #endif /* __ACTYPES_H__ */ diff --git a/sys/dist/acpica/acutils.h b/sys/dist/acpica/acutils.h index 91acee44256..aba1bfcb022 100644 --- a/sys/dist/acpica/acutils.h +++ b/sys/dist/acpica/acutils.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures - * xRevision: 1.189 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -124,24 +124,24 @@ extern const UINT8 AcpiGbl_ResourceAmlSizes[]; #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) -extern const char *AcpiGbl_BMDecode[2]; -extern const char *AcpiGbl_ConfigDecode[4]; -extern const char *AcpiGbl_ConsumeDecode[2]; -extern const char *AcpiGbl_DECDecode[2]; -extern const char *AcpiGbl_HEDecode[2]; -extern const char *AcpiGbl_IoDecode[2]; -extern const char *AcpiGbl_LLDecode[2]; -extern const char *AcpiGbl_MaxDecode[2]; -extern const char *AcpiGbl_MEMDecode[4]; -extern const char *AcpiGbl_MinDecode[2]; -extern const char *AcpiGbl_MTPDecode[4]; -extern const char *AcpiGbl_RNGDecode[4]; -extern const char *AcpiGbl_RWDecode[2]; -extern const char *AcpiGbl_SHRDecode[2]; -extern const char *AcpiGbl_SIZDecode[4]; -extern const char *AcpiGbl_TRSDecode[2]; -extern const char *AcpiGbl_TTPDecode[2]; -extern const char *AcpiGbl_TYPDecode[4]; +extern const char *AcpiGbl_BmDecode[]; +extern const char *AcpiGbl_ConfigDecode[]; +extern const char *AcpiGbl_ConsumeDecode[]; +extern const char *AcpiGbl_DecDecode[]; +extern const char *AcpiGbl_HeDecode[]; +extern const char *AcpiGbl_IoDecode[]; +extern const char *AcpiGbl_LlDecode[]; +extern const char *AcpiGbl_MaxDecode[]; +extern const char *AcpiGbl_MemDecode[]; +extern const char *AcpiGbl_MinDecode[]; +extern const char *AcpiGbl_MtpDecode[]; +extern const char *AcpiGbl_RngDecode[]; +extern const char *AcpiGbl_RwDecode[]; +extern const char *AcpiGbl_ShrDecode[]; +extern const char *AcpiGbl_SizDecode[]; +extern const char *AcpiGbl_TrsDecode[]; +extern const char *AcpiGbl_TtpDecode[]; +extern const char *AcpiGbl_TypDecode[]; #endif /* Types for Resource descriptor entries */ @@ -152,6 +152,14 @@ extern const char *AcpiGbl_TYPDecode[4]; #define ACPI_SMALL_VARIABLE_LENGTH 3 typedef +ACPI_STATUS (*ACPI_WALK_AML_CALLBACK) ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context); + +typedef ACPI_STATUS (*ACPI_PKG_CALLBACK) ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, @@ -239,10 +247,6 @@ void AcpiUtSubsystemShutdown ( void); -ACPI_STATUS -AcpiUtValidateFadt ( - void); - /* * utclib - Local implementations of C library functions @@ -475,6 +479,12 @@ AcpiUtDumpBuffer ( UINT32 componentId); void +AcpiUtDumpBuffer2 ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display); + +void AcpiUtReportError ( const char *ModuleName, UINT32 LineNumber); @@ -726,6 +736,14 @@ AcpiUtShortDivide ( /* * utmisc */ +const char * +AcpiUtValidateException ( + ACPI_STATUS Status); + +BOOLEAN +AcpiUtIsAmlTable ( + ACPI_TABLE_HEADER *Table); + ACPI_STATUS AcpiUtAllocateOwnerId ( ACPI_OWNER_ID *OwnerId); @@ -754,9 +772,14 @@ BOOLEAN AcpiUtValidAcpiName ( UINT32 Name); +ACPI_NAME +AcpiUtRepairName ( + char *Name); + BOOLEAN -AcpiUtValidAcpiCharacter ( - char Character); +AcpiUtValidAcpiChar ( + char Character, + ACPI_NATIVE_UINT Position); ACPI_STATUS AcpiUtStrtoul64 ( @@ -768,6 +791,33 @@ AcpiUtStrtoul64 ( #define ACPI_ANY_BASE 0 +UINT32 +AcpiUtDwordByteSwap ( + UINT32 Value); + +void +AcpiUtSetIntegerWidth ( + UINT8 Revision); + +#ifdef ACPI_DEBUG_OUTPUT +void +AcpiUtDisplayInitPathname ( + UINT8 Type, + ACPI_NAMESPACE_NODE *ObjHandle, + const char *Path); +#endif + + +/* + * utresrc + */ +ACPI_STATUS +AcpiUtWalkAmlResources ( + UINT8 *Aml, + ACPI_SIZE AmlLength, + ACPI_WALK_AML_CALLBACK UserFunction, + void *Context); + ACPI_STATUS AcpiUtValidateResource ( void *Aml, @@ -794,23 +844,6 @@ AcpiUtGetResourceEndTag ( ACPI_OPERAND_OBJECT *ObjDesc, UINT8 **EndTag); -UINT32 -AcpiUtDwordByteSwap ( - UINT32 Value); - -void -AcpiUtSetIntegerWidth ( - UINT8 Revision); - -#ifdef ACPI_DEBUG_OUTPUT -void -AcpiUtDisplayInitPathname ( - UINT8 Type, - ACPI_NAMESPACE_NODE *ObjHandle, - const char *Path); - -#endif - /* * utmutex - mutex support @@ -860,7 +893,7 @@ AcpiUtAllocate ( UINT32 Line); void * -AcpiUtCallocate ( +AcpiUtAllocateZeroed ( ACPI_SIZE Size, UINT32 Component, const char *Module, @@ -875,7 +908,7 @@ AcpiUtAllocateAndTrack ( UINT32 Line); void * -AcpiUtCallocateAndTrack ( +AcpiUtAllocateZeroedAndTrack ( ACPI_SIZE Size, UINT32 Component, const char *Module, @@ -895,7 +928,15 @@ AcpiUtDumpAllocationInfo ( void AcpiUtDumpAllocations ( UINT32 Component, - const char *Module); + char *Module); + +ACPI_STATUS +AcpiUtCreateList ( + const char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache); + + #endif #endif /* _ACUTILS_H */ diff --git a/sys/dist/acpica/aecommon.h b/sys/dist/acpica/aecommon.h new file mode 100644 index 00000000000..97d84a207e5 --- /dev/null +++ b/sys/dist/acpica/aecommon.h @@ -0,0 +1,243 @@ +/****************************************************************************** + * + * Module Name: aecommon - common include for the AcpiExec utility + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _AECOMMON +#define _AECOMMON + +#ifdef _MSC_VER /* disable some level-4 warnings */ +#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> + +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdebug.h> +#include <dist/acpica/actables.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acapps.h> + +extern FILE *AcpiGbl_DebugFile; +extern BOOLEAN AcpiGbl_IgnoreErrors; + +/* + * Debug Regions + */ +typedef struct Region +{ + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + void *Buffer; + void *NextRegion; + UINT8 SpaceId; + +} REGION; + +typedef struct DebugRegions +{ + UINT32 NumberOfRegions; + REGION *RegionList; + +} DEBUG_REGIONS; + + +/* + * Pointer overlay for 16-bit code + */ +typedef union ptr_ovl +{ + void *ptr; + UINT32 dword; + struct + { + UINT16 offset; + UINT16 base; + } ovl; + +} PTR_OVL; + + +#define GET_SEGMENT(ptr) ((UINT16)(_segment)(ptr)) +#define GET_OFFSET(ptr) ((UINT16)(UINT32) (ptr)) +#define GET_PHYSICAL_ADDRESS(ptr) (((((UINT32)GET_SEGMENT(ptr)) << 4)) + GET_OFFSET(ptr)) +#define PTR_OVL_BUILD_PTR(p,b,o) {p.ovl.base=b;p.ovl.offset=o;} + + +#define TEST_OUTPUT_LEVEL(lvl) if ((lvl) & OutputLevel) + +#define OSD_PRINT(lvl,fp) TEST_OUTPUT_LEVEL(lvl) {\ + AcpiOsPrintf PARAM_LIST(fp);} + +void __cdecl +AeCtrlCHandler ( + int Sig); + +ACPI_STATUS +AeBuildLocalTables ( + ACPI_TABLE_HEADER *UserTable); + +ACPI_STATUS +AeInstallTables ( + void); + +void +AeDumpNamespace ( + void); + +void +AeDumpObject ( + char *MethodName, + ACPI_BUFFER *ReturnObj); + +void +AeDumpBuffer ( + UINT32 Address); + +void +AeExecute ( + char *Name); + +void +AeSetScope ( + char *Name); + +void +AeCloseDebugFile ( + void); + +void +AeOpenDebugFile ( + char *Name); + +ACPI_STATUS +AeDisplayAllMethods ( + UINT32 DisplayCount); + +ACPI_STATUS +AeInstallHandlers ( + void); + +void +AeMiscellaneousTests ( + void); + + +#endif /* _AECOMMON */ + diff --git a/sys/dist/acpica/amlcode.h b/sys/dist/acpica/amlcode.h index 4cdc46ccd1a..d197804ecbc 100644 --- a/sys/dist/acpica/amlcode.h +++ b/sys/dist/acpica/amlcode.h @@ -3,7 +3,7 @@ * Name: amlcode.h - Definitions for AML, as included in "definition blocks" * Declarations and definitions contained herein are derived * directly from the ACPI specification. - * xRevision: 1.83 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -254,8 +254,10 @@ #define AML_DATA_REGION_OP (UINT16) 0x5b88 /* ACPI 2.0 */ -/* Bogus opcodes (they are actually two separate opcodes) */ - +/* + * Combination opcodes (actually two one-byte opcodes) + * Used by the disassembler and iASL compiler + */ #define AML_LGREATEREQUAL_OP (UINT16) 0x9295 #define AML_LLESSEQUAL_OP (UINT16) 0x9294 #define AML_LNOTEQUAL_OP (UINT16) 0x9293 @@ -347,7 +349,7 @@ #define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/ #define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ #define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ -#define ARGI_REGION_OR_FIELD 0x15 /* Used by LOAD op only */ +#define ARGI_REGION_OR_BUFFER 0x15 /* Used by LOAD op only */ #define ARGI_DATAREFOBJ 0x16 /* Note: types above can expand to 0x1F maximum */ diff --git a/sys/dist/acpica/amlresrc.h b/sys/dist/acpica/amlresrc.h index a4a196cc45b..b0d00ce8cb9 100644 --- a/sys/dist/acpica/amlresrc.h +++ b/sys/dist/acpica/amlresrc.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amlresrc.h - AML resource descriptors - * xRevision: 1.35 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,41 +115,46 @@ * *****************************************************************************/ +/* acpisrc:StructDefs -- for acpisrc conversion */ #ifndef __AMLRESRC_H #define __AMLRESRC_H -#define ASL_RESNAME_ADDRESS "_ADR" -#define ASL_RESNAME_ALIGNMENT "_ALN" -#define ASL_RESNAME_ADDRESSSPACE "_ASI" -#define ASL_RESNAME_ACCESSSIZE "_ASZ" -#define ASL_RESNAME_TYPESPECIFICATTRIBUTES "_ATT" -#define ASL_RESNAME_BASEADDRESS "_BAS" -#define ASL_RESNAME_BUSMASTER "_BM_" /* Master(1), Slave(0) */ -#define ASL_RESNAME_DECODE "_DEC" -#define ASL_RESNAME_DMA "_DMA" -#define ASL_RESNAME_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ -#define ASL_RESNAME_GRANULARITY "_GRA" -#define ASL_RESNAME_INTERRUPT "_INT" -#define ASL_RESNAME_INTERRUPTLEVEL "_LL_" /* ActiveLo(1), ActiveHi(0) */ -#define ASL_RESNAME_INTERRUPTSHARE "_SHR" /* Shareable(1), NoShare(0) */ -#define ASL_RESNAME_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ -#define ASL_RESNAME_LENGTH "_LEN" -#define ASL_RESNAME_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ -#define ASL_RESNAME_MEMTYPE "_MEM" /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ -#define ASL_RESNAME_MAXADDR "_MAX" -#define ASL_RESNAME_MINADDR "_MIN" -#define ASL_RESNAME_MAXTYPE "_MAF" -#define ASL_RESNAME_MINTYPE "_MIF" -#define ASL_RESNAME_REGISTERBITOFFSET "_RBO" -#define ASL_RESNAME_REGISTERBITWIDTH "_RBW" -#define ASL_RESNAME_RANGETYPE "_RNG" -#define ASL_RESNAME_READWRITETYPE "_RW_" /* ReadOnly(0), Writeable (1) */ -#define ASL_RESNAME_TRANSLATION "_TRA" -#define ASL_RESNAME_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ -#define ASL_RESNAME_TYPE "_TTP" /* Translation(1), Static (0) */ -#define ASL_RESNAME_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */ +/* + * Resource descriptor tags, as defined in the ACPI specification. + * Used to symbolically reference fields within a descriptor. + */ +#define ACPI_RESTAG_ADDRESS "_ADR" +#define ACPI_RESTAG_ALIGNMENT "_ALN" +#define ACPI_RESTAG_ADDRESSSPACE "_ASI" +#define ACPI_RESTAG_ACCESSSIZE "_ASZ" +#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT" +#define ACPI_RESTAG_BASEADDRESS "_BAS" +#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */ +#define ACPI_RESTAG_DECODE "_DEC" +#define ACPI_RESTAG_DMA "_DMA" +#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ +#define ACPI_RESTAG_GRANULARITY "_GRA" +#define ACPI_RESTAG_INTERRUPT "_INT" +#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* ActiveLo(1), ActiveHi(0) */ +#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), NoShare(0) */ +#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ +#define ACPI_RESTAG_LENGTH "_LEN" +#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ +#define ACPI_RESTAG_MEMTYPE "_MEM" /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ +#define ACPI_RESTAG_MAXADDR "_MAX" +#define ACPI_RESTAG_MINADDR "_MIN" +#define ACPI_RESTAG_MAXTYPE "_MAF" +#define ACPI_RESTAG_MINTYPE "_MIF" +#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO" +#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW" +#define ACPI_RESTAG_RANGETYPE "_RNG" +#define ACPI_RESTAG_READWRITETYPE "_RW_" /* ReadOnly(0), Writeable (1) */ +#define ACPI_RESTAG_TRANSLATION "_TRA" +#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ +#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */ +#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */ /* Default sizes for "small" resource descriptors */ @@ -165,9 +170,9 @@ typedef struct asl_resource_node { - UINT32 BufferLength; - void *Buffer; - struct asl_resource_node *Next; + UINT32 BufferLength; + void *Buffer; + struct asl_resource_node *Next; } ASL_RESOURCE_NODE; @@ -189,7 +194,7 @@ typedef struct asl_resource_node * SMALL descriptors */ #define AML_RESOURCE_SMALL_HEADER_COMMON \ - UINT8 DescriptorType; + UINT8 DescriptorType; typedef struct aml_resource_small_header { @@ -201,8 +206,8 @@ typedef struct aml_resource_small_header typedef struct aml_resource_irq { AML_RESOURCE_SMALL_HEADER_COMMON - UINT16 IrqMask; - UINT8 Flags; + UINT16 IrqMask; + UINT8 Flags; } AML_RESOURCE_IRQ; @@ -210,7 +215,7 @@ typedef struct aml_resource_irq typedef struct aml_resource_irq_noflags { AML_RESOURCE_SMALL_HEADER_COMMON - UINT16 IrqMask; + UINT16 IrqMask; } AML_RESOURCE_IRQ_NOFLAGS; @@ -218,8 +223,8 @@ typedef struct aml_resource_irq_noflags typedef struct aml_resource_dma { AML_RESOURCE_SMALL_HEADER_COMMON - UINT8 DmaChannelMask; - UINT8 Flags; + UINT8 DmaChannelMask; + UINT8 Flags; } AML_RESOURCE_DMA; @@ -227,7 +232,7 @@ typedef struct aml_resource_dma typedef struct aml_resource_start_dependent { AML_RESOURCE_SMALL_HEADER_COMMON - UINT8 Flags; + UINT8 Flags; } AML_RESOURCE_START_DEPENDENT; @@ -249,11 +254,11 @@ typedef struct aml_resource_end_dependent typedef struct aml_resource_io { AML_RESOURCE_SMALL_HEADER_COMMON - UINT8 Flags; - UINT16 Minimum; - UINT16 Maximum; - UINT8 Alignment; - UINT8 AddressLength; + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; + UINT8 Alignment; + UINT8 AddressLength; } AML_RESOURCE_IO; @@ -261,8 +266,8 @@ typedef struct aml_resource_io typedef struct aml_resource_fixed_io { AML_RESOURCE_SMALL_HEADER_COMMON - UINT16 Address; - UINT8 AddressLength; + UINT16 Address; + UINT8 AddressLength; } AML_RESOURCE_FIXED_IO; @@ -277,7 +282,7 @@ typedef struct aml_resource_vendor_small typedef struct aml_resource_end_tag { AML_RESOURCE_SMALL_HEADER_COMMON - UINT8 Checksum; + UINT8 Checksum; } AML_RESOURCE_END_TAG; @@ -286,8 +291,8 @@ typedef struct aml_resource_end_tag * LARGE descriptors */ #define AML_RESOURCE_LARGE_HEADER_COMMON \ - UINT8 DescriptorType;\ - UINT16 ResourceLength; + UINT8 DescriptorType;\ + UINT16 ResourceLength; typedef struct aml_resource_large_header { @@ -299,11 +304,11 @@ typedef struct aml_resource_large_header typedef struct aml_resource_memory24 { AML_RESOURCE_LARGE_HEADER_COMMON - UINT8 Flags; - UINT16 Minimum; - UINT16 Maximum; - UINT16 Alignment; - UINT16 AddressLength; + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; } AML_RESOURCE_MEMORY24; @@ -318,11 +323,11 @@ typedef struct aml_resource_vendor_large typedef struct aml_resource_memory32 { AML_RESOURCE_LARGE_HEADER_COMMON - UINT8 Flags; - UINT32 Minimum; - UINT32 Maximum; - UINT32 Alignment; - UINT32 AddressLength; + UINT8 Flags; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; } AML_RESOURCE_MEMORY32; @@ -330,17 +335,17 @@ typedef struct aml_resource_memory32 typedef struct aml_resource_fixed_memory32 { AML_RESOURCE_LARGE_HEADER_COMMON - UINT8 Flags; - UINT32 Address; - UINT32 AddressLength; + UINT8 Flags; + UINT32 Address; + UINT32 AddressLength; } AML_RESOURCE_FIXED_MEMORY32; #define AML_RESOURCE_ADDRESS_COMMON \ - UINT8 ResourceType; \ - UINT8 Flags; \ - UINT8 SpecificFlags; + UINT8 ResourceType; \ + UINT8 Flags; \ + UINT8 SpecificFlags; typedef struct aml_resource_address @@ -355,14 +360,14 @@ typedef struct aml_resource_extended_address64 { AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON - UINT8 RevisionID; - UINT8 Reserved; - UINT64 Granularity; - UINT64 Minimum; - UINT64 Maximum; - UINT64 TranslationOffset; - UINT64 AddressLength; - UINT64 TypeSpecific; + UINT8 RevisionID; + UINT8 Reserved; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; } AML_RESOURCE_EXTENDED_ADDRESS64; @@ -373,11 +378,11 @@ typedef struct aml_resource_address64 { AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON - UINT64 Granularity; - UINT64 Minimum; - UINT64 Maximum; - UINT64 TranslationOffset; - UINT64 AddressLength; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; } AML_RESOURCE_ADDRESS64; @@ -386,11 +391,11 @@ typedef struct aml_resource_address32 { AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON - UINT32 Granularity; - UINT32 Minimum; - UINT32 Maximum; - UINT32 TranslationOffset; - UINT32 AddressLength; + UINT32 Granularity; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; + UINT32 AddressLength; } AML_RESOURCE_ADDRESS32; @@ -399,11 +404,11 @@ typedef struct aml_resource_address16 { AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON - UINT16 Granularity; - UINT16 Minimum; - UINT16 Maximum; - UINT16 TranslationOffset; - UINT16 AddressLength; + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; } AML_RESOURCE_ADDRESS16; @@ -411,9 +416,9 @@ typedef struct aml_resource_address16 typedef struct aml_resource_extended_irq { AML_RESOURCE_LARGE_HEADER_COMMON - UINT8 Flags; - UINT8 InterruptCount; - UINT32 Interrupts[1]; + UINT8 Flags; + UINT8 InterruptCount; + UINT32 Interrupts[1]; /* ResSourceIndex, ResSource optional fields follow */ } AML_RESOURCE_EXTENDED_IRQ; @@ -422,11 +427,11 @@ typedef struct aml_resource_extended_irq typedef struct aml_resource_generic_register { AML_RESOURCE_LARGE_HEADER_COMMON - UINT8 AddressSpaceId; - UINT8 BitWidth; - UINT8 BitOffset; - UINT8 AccessSize; /* ACPI 3.0, was previously Reserved */ - UINT64 Address; + UINT8 AddressSpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; /* ACPI 3.0, was previously Reserved */ + UINT64 Address; } AML_RESOURCE_GENERIC_REGISTER; @@ -440,42 +445,42 @@ typedef union aml_resource { /* Descriptor headers */ - AML_RESOURCE_SMALL_HEADER SmallHeader; - AML_RESOURCE_LARGE_HEADER LargeHeader; + UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER SmallHeader; + AML_RESOURCE_LARGE_HEADER LargeHeader; /* Small resource descriptors */ - AML_RESOURCE_IRQ Irq; - AML_RESOURCE_DMA Dma; - AML_RESOURCE_START_DEPENDENT StartDpf; - AML_RESOURCE_END_DEPENDENT EndDpf; - AML_RESOURCE_IO Io; - AML_RESOURCE_FIXED_IO FixedIo; - AML_RESOURCE_VENDOR_SMALL VendorSmall; - AML_RESOURCE_END_TAG EndTag; + AML_RESOURCE_IRQ Irq; + AML_RESOURCE_DMA Dma; + AML_RESOURCE_START_DEPENDENT StartDpf; + AML_RESOURCE_END_DEPENDENT EndDpf; + AML_RESOURCE_IO Io; + AML_RESOURCE_FIXED_IO FixedIo; + AML_RESOURCE_VENDOR_SMALL VendorSmall; + AML_RESOURCE_END_TAG EndTag; /* Large resource descriptors */ - AML_RESOURCE_MEMORY24 Memory24; - AML_RESOURCE_GENERIC_REGISTER GenericReg; - AML_RESOURCE_VENDOR_LARGE VendorLarge; - AML_RESOURCE_MEMORY32 Memory32; - AML_RESOURCE_FIXED_MEMORY32 FixedMemory32; - AML_RESOURCE_ADDRESS16 Address16; - AML_RESOURCE_ADDRESS32 Address32; - AML_RESOURCE_ADDRESS64 Address64; - AML_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; - AML_RESOURCE_EXTENDED_IRQ ExtendedIrq; + AML_RESOURCE_MEMORY24 Memory24; + AML_RESOURCE_GENERIC_REGISTER GenericReg; + AML_RESOURCE_VENDOR_LARGE VendorLarge; + AML_RESOURCE_MEMORY32 Memory32; + AML_RESOURCE_FIXED_MEMORY32 FixedMemory32; + AML_RESOURCE_ADDRESS16 Address16; + AML_RESOURCE_ADDRESS32 Address32; + AML_RESOURCE_ADDRESS64 Address64; + AML_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + AML_RESOURCE_EXTENDED_IRQ ExtendedIrq; /* Utility overlays */ - AML_RESOURCE_ADDRESS Address; - UINT32 U32Item; - UINT16 U16Item; - UINT8 U8Item; + AML_RESOURCE_ADDRESS Address; + UINT32 DwordItem; + UINT16 WordItem; + UINT8 ByteItem; } AML_RESOURCE; - #endif diff --git a/sys/dist/acpica/dbcmds.c b/sys/dist/acpica/dbcmds.c index 095b3f4fd10..8bfe94b2000 100644 --- a/sys/dist/acpica/dbcmds.c +++ b/sys/dist/acpica/dbcmds.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbcmds - debug commands and output routines - * xRevision: 1.140 $ + * $Revision: 1.4 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,20 +115,17 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbcmds.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acdebug.h> +#include <dist/acpica/acresrc.h> +#include <dist/acpica/acdisasm.h> -#include "acpi.h" -#include "acdispat.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acevents.h" -#include "acdebug.h" -#include "acresrc.h" -#include "acdisasm.h" - -#include "acparser.h" +#include <dist/acpica/acparser.h> #ifdef ACPI_DEBUGGER @@ -288,9 +285,6 @@ ACPI_STATUS AcpiDbSleep ( char *ObjectArg) { -#if ACPI_MACHINE_WIDTH == 16 - return (AE_OK); -#else ACPI_STATUS Status; UINT8 SleepState; @@ -315,7 +309,6 @@ AcpiDbSleep ( Status = AcpiLeaveSleepState (SleepState); return (Status); -#endif } @@ -414,11 +407,11 @@ AcpiDbDisplayLocks ( UINT32 i; - for (i = 0; i < MAX_MUTEX; i++) + for (i = 0; i < ACPI_MAX_MUTEX; i++) { AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), - AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED - ? "Locked" : "Unlocked"); + AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED + ? "Locked" : "Unlocked"); } } @@ -440,30 +433,28 @@ void AcpiDbDisplayTableInfo ( char *TableArg) { - UINT32 i; + ACPI_NATIVE_UINT i; ACPI_TABLE_DESC *TableDesc; - for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) + /* + * Walk the root table list + */ + for (i = 0; i < AcpiGbl_RootTableList.Count; i++) { - TableDesc = AcpiGbl_TableLists[i].Next; - while (TableDesc) - { - AcpiOsPrintf ( "%s at %p length %.5X", - AcpiGbl_TableData[i].Name, TableDesc->Pointer, - (UINT32) TableDesc->Length); + TableDesc = &AcpiGbl_RootTableList.Tables[i]; + AcpiOsPrintf ( "%4.4s at %p length %.5X", + TableDesc->Signature.Ascii, TableDesc->Pointer, + (UINT32) TableDesc->Length); - if (i != ACPI_TABLE_FACS) - { - AcpiOsPrintf (" OemID=%6s TableId=%8s OemRevision=%8.8X", - TableDesc->Pointer->OemId, - TableDesc->Pointer->OemTableId, - TableDesc->Pointer->OemRevision); - } - AcpiOsPrintf ("\n"); - - TableDesc = TableDesc->Next; + if (TableDesc->Pointer && (i != ACPI_TABLE_INDEX_FACS)) + { + AcpiOsPrintf (" OemId=\"%6s\" OemTableId=\"%8s\" OemRevision=%8.8X", + TableDesc->Pointer->OemId, + TableDesc->Pointer->OemTableId, + TableDesc->Pointer->OemRevision); } + AcpiOsPrintf ("\n"); } } @@ -488,13 +479,16 @@ AcpiDbUnloadAcpiTable ( char *TableArg, char *InstanceArg) { +/* TBD: Need to reimplement for new data structures */ + +#if 0 UINT32 i; ACPI_STATUS Status; /* Search all tables for the target type */ - for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) + for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++) { if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature, AcpiGbl_TableData[i].SigLength)) @@ -517,6 +511,7 @@ AcpiDbUnloadAcpiTable ( } AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); +#endif } @@ -628,7 +623,9 @@ AcpiDbDisassembleAml ( NumStatements = ACPI_STRTOUL (Statements, NULL, 0); } +#ifdef ACPI_DISASSEMBLER AcpiDmDisassemble (NULL, Op, NumStatements); +#endif } @@ -680,7 +677,7 @@ AcpiDbDisassembleMethod ( Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, NULL, 1); + ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); if (ACPI_FAILURE (Status)) { return (Status); @@ -692,7 +689,9 @@ AcpiDbDisassembleMethod ( WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; Status = AcpiPsParseAml (WalkState); +#ifdef ACPI_DISASSEMBLER AcpiDmDisassemble (NULL, Op, 0); +#endif AcpiPsDeleteParseTree (Op); return (AE_OK); } @@ -1025,7 +1024,7 @@ AcpiDbWalkForSpecificObjects ( } AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); - ACPI_MEM_FREE (Buffer.Pointer); + ACPI_FREE (Buffer.Pointer); /* Dump short info about the object */ @@ -1149,7 +1148,7 @@ AcpiDbWalkAndMatchName ( AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL); - ACPI_MEM_FREE (Buffer.Pointer); + ACPI_FREE (Buffer.Pointer); } return (AE_OK); @@ -1224,8 +1223,8 @@ AcpiDbSetScope ( { /* Validate new scope from the root */ - Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, - ACPI_NS_NO_UPSEARCH, &Node); + Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH, + &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -1238,8 +1237,8 @@ AcpiDbSetScope ( { /* Validate new scope relative to old scope */ - Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, - ACPI_NS_NO_UPSEARCH, &Node); + Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH, + &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -1421,11 +1420,11 @@ AcpiDmTestResourceConversion ( /* Cleanup and exit */ - ACPI_MEM_FREE (NewAml.Pointer); + ACPI_FREE (NewAml.Pointer); Exit2: - ACPI_MEM_FREE (ResourceObj.Pointer); + ACPI_FREE (ResourceObj.Pointer); Exit1: - ACPI_MEM_FREE (ReturnObj.Pointer); + ACPI_FREE (ReturnObj.Pointer); return (Status); } @@ -1446,8 +1445,6 @@ void AcpiDbDisplayResources ( char *ObjectArg) { -#if ACPI_MACHINE_WIDTH != 16 - ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_BUFFER ReturnObj; @@ -1585,7 +1582,6 @@ Cleanup: AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); return; -#endif } @@ -1765,7 +1761,7 @@ AcpiDbBusWalk ( /* Display the full path */ AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer); - ACPI_MEM_FREE (Buffer.Pointer); + ACPI_FREE (Buffer.Pointer); /* _PRT info */ @@ -1809,7 +1805,7 @@ AcpiDbBusWalk ( if (ACPI_SUCCESS (Status)) { AcpiOsPrintf (" _CID=%s", Cid->Id[0].Value); - ACPI_MEM_FREE (Cid); + ACPI_FREE (Cid); } AcpiOsPrintf ("\n"); diff --git a/sys/dist/acpica/dbdisply.c b/sys/dist/acpica/dbdisply.c index 1eb5548b9b8..8805d2b7ba9 100644 --- a/sys/dist/acpica/dbdisply.c +++ b/sys/dist/acpica/dbdisply.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbdisply - debug display commands - * xRevision: 1.114 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,17 +115,14 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbdisply.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acnamesp.h" -#include "acparser.h" -#include "acinterp.h" -#include "acdebug.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acdebug.h> +#include <dist/acpica/acdisasm.h> #ifdef ACPI_DEBUGGER @@ -163,24 +160,7 @@ AcpiDbGetPointer ( void *ObjPtr; -#if ACPI_MACHINE_WIDTH == 16 -#include <stdio.h> - - /* Have to handle 16-bit pointers of the form segment:offset */ - - if (!sscanf (Target, "%p", &ObjPtr)) - { - AcpiOsPrintf ("Invalid pointer: %s\n", Target); - return (NULL); - } - -#else - - /* Simple flat pointer */ - ObjPtr = ACPI_TO_POINTER (ACPI_STRTOUL (Target, NULL, 16)); -#endif - return (ObjPtr); } @@ -438,8 +418,6 @@ AcpiDbDisplayMethodInfo ( UINT32 NumRemainingOps = 0; UINT32 NumRemainingOperands = 0; UINT32 NumRemainingOperators = 0; - UINT32 NumArgs; - UINT32 Concurrency; BOOLEAN CountRemaining = FALSE; @@ -453,13 +431,11 @@ AcpiDbDisplayMethodInfo ( ObjDesc = WalkState->MethodDesc; Node = WalkState->MethodNode; - NumArgs = ObjDesc->Method.ParamCount; - Concurrency = ObjDesc->Method.Concurrency; - AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", AcpiUtGetNodeName (Node)); - AcpiOsPrintf ("%X arguments, max concurrency = %X\n", - NumArgs, Concurrency); + AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n", + (UINT32) ObjDesc->Method.ParamCount, + (UINT32) ObjDesc->Method.SyncLevel); RootOp = StartOp; @@ -604,8 +580,10 @@ AcpiDbDisplayResults ( UINT32 i; ACPI_WALK_STATE *WalkState; ACPI_OPERAND_OBJECT *ObjDesc; - UINT32 NumResults = 0; + UINT32 ResultCount = 0; ACPI_NAMESPACE_NODE *Node; + ACPI_GENERIC_STATE *Frame; + UINT32 Index; /* Index onto current frame */ WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); @@ -620,17 +598,28 @@ AcpiDbDisplayResults ( if (WalkState->Results) { - NumResults = WalkState->Results->Results.NumResults; + ResultCount = WalkState->ResultCount; } AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n", - AcpiUtGetNodeName (Node), NumResults); + AcpiUtGetNodeName (Node), ResultCount); + + /* From the top element of result stack */ - for (i = 0; i < NumResults; i++) + Frame = WalkState->Results; + Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM; + + for (i = 0; i < ResultCount; i++) { - ObjDesc = WalkState->Results->Results.ObjDesc[i]; + ObjDesc = Frame->Results.ObjDesc[Index]; AcpiOsPrintf ("Result%d: ", i); AcpiDmDisplayInternalObject (ObjDesc, WalkState); + if (Index == 0) + { + Frame = Frame->Results.Next; + Index = ACPI_RESULTS_FRAME_OBJ_NUM; + } + Index--; } } @@ -723,7 +712,7 @@ AcpiDbDisplayObjectType ( } } - ACPI_MEM_FREE (Info); + ACPI_FREE (Info); } else { @@ -860,8 +849,8 @@ AcpiDbDisplayGpes ( AcpiOsPrintf ( " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", GpeBlock->RegisterInfo, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->StatusAddress.Address)), - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->EnableAddress.Address))); + ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address), + ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address)); AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); @@ -875,8 +864,8 @@ AcpiDbDisplayGpes ( " Reg %u: WakeEnable %2.2X, RunEnable %2.2X Status %8.8X%8.8X Enable %8.8X%8.8X\n", i, GpeRegisterInfo->EnableForWake, GpeRegisterInfo->EnableForRun, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->StatusAddress.Address)), - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address))); + ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address), + ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address)); /* Now look at the individual GPEs in this byte register */ @@ -893,9 +882,9 @@ AcpiDbDisplayGpes ( } AcpiOsPrintf ( - " GPE %.3X: %p Bit %2.2X Flags %2.2X: ", + " GPE %.3X: %p Flags %2.2X: ", GpeBlock->BlockBaseNumber + GpeIndex, - GpeEventInfo, GpeEventInfo->RegisterBit, + GpeEventInfo, GpeEventInfo->Flags); if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) diff --git a/sys/dist/acpica/dbexec.c b/sys/dist/acpica/dbexec.c index c62a949f564..6f132864f26 100644 --- a/sys/dist/acpica/dbexec.c +++ b/sys/dist/acpica/dbexec.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbexec - debugger control method execution - * xRevision: 1.74 $ + * $Revision: 1.4 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,9 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbexec.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acdebug.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdebug.h> +#include <dist/acpica/acnamesp.h> #ifdef ACPI_DEBUGGER @@ -156,12 +153,6 @@ AcpiDbExecutionWalk ( void *Context, void **ReturnValue); -#ifdef ACPI_DBG_TRACK_ALLOCATIONS -static UINT32 -AcpiDbGetCacheInfo ( - ACPI_MEMORY_LIST *Cache); -#endif - /******************************************************************************* * @@ -214,7 +205,7 @@ AcpiDbExecuteMethod ( Params[1].Type = ACPI_TYPE_STRING; Params[1].String.Length = 12; - Params[1].String.Pointer = "AML Debugger"; + Params[1].String.Pointer = __UNCONST("AML Debugger"); /* XXX */ ParamObjects.Pointer = Params; ParamObjects.Count = 2; @@ -286,7 +277,7 @@ AcpiDbExecuteSetup ( #ifdef ACPI_DBG_TRACK_ALLOCATIONS -static UINT32 +UINT32 AcpiDbGetCacheInfo ( ACPI_MEMORY_LIST *Cache) { @@ -423,12 +414,14 @@ AcpiDbExecute ( } else { - NameString = ACPI_MEM_ALLOCATE (ACPI_STRLEN (Name) + 1); + NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1); if (!NameString) { return; } + ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); + ACPI_STRCPY (NameString, Name); AcpiUtStrupr (NameString); AcpiGbl_DbMethodInfo.Name = NameString; @@ -440,7 +433,7 @@ AcpiDbExecute ( AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj); - ACPI_MEM_FREE (NameString); + ACPI_FREE (NameString); } /* @@ -512,9 +505,21 @@ AcpiDbMethodThread ( ACPI_STATUS Status; ACPI_DB_METHOD_INFO *Info = Context; UINT32 i; + UINT8 Allow; ACPI_BUFFER ReturnObj; + if (Info->InitArgs) + { + AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr); + AcpiDbUInt32ToHexString (AcpiOsGetThreadId (), Info->IdOfThreadStr); + } + + if (Info->Threads && (Info->NumCreated < Info->NumThreads)) + { + Info->Threads[Info->NumCreated++] = AcpiOsGetThreadId(); + } + for (i = 0; i < Info->NumLoops; i++) { Status = AcpiDbExecuteMethod (Info, &ReturnObj); @@ -528,12 +533,12 @@ AcpiDbMethodThread ( } } +#if 0 if ((i % 100) == 0) { - AcpiOsPrintf ("%d executions\n", i); + AcpiOsPrintf ("%d executions, Thread 0x%x\n", i, AcpiOsGetThreadId ()); } -#if 0 if (ReturnObj.Length) { AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", @@ -545,11 +550,26 @@ AcpiDbMethodThread ( /* Signal our completion */ - Status = AcpiOsSignalSemaphore (Info->ThreadGate, 1); - if (ACPI_FAILURE (Status)) + Allow = 0; + AcpiOsWaitSemaphore (Info->ThreadCompleteGate, 1, ACPI_WAIT_FOREVER); + Info->NumCompleted++; + + if (Info->NumCompleted == Info->NumThreads) { - AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n", - AcpiFormatException (Status)); + /* Do signal for main thread once only */ + Allow = 1; + } + + AcpiOsSignalSemaphore (Info->ThreadCompleteGate, 1); + + if (Allow) + { + Status = AcpiOsSignalSemaphore (Info->MainThreadGate, 1); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n", + AcpiFormatException (Status)); + } } } @@ -578,8 +598,9 @@ AcpiDbCreateExecutionThreads ( UINT32 NumThreads; UINT32 NumLoops; UINT32 i; - ACPI_HANDLE ThreadGate; - + UINT32 Size; + ACPI_MUTEX MainThreadGate; + ACPI_MUTEX ThreadCompleteGate; /* Get the arguments */ @@ -593,23 +614,64 @@ AcpiDbCreateExecutionThreads ( return; } - /* Create the synchronization semaphore */ + /* + * Create the semaphore for synchronization of + * the created threads with the main thread. + */ + Status = AcpiOsCreateSemaphore (1, 0, &MainThreadGate); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not create semaphore for synchronization with the main thread, %s\n", + AcpiFormatException (Status)); + return; + } - Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate); + /* + * Create the semaphore for synchronization + * between the created threads. + */ + Status = AcpiOsCreateSemaphore (1, 1, &ThreadCompleteGate); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not create semaphore, %s\n", + AcpiOsPrintf ("Could not create semaphore for synchronization between the created threads, %s\n", AcpiFormatException (Status)); + (void) AcpiOsDeleteSemaphore (MainThreadGate); + return; + } + + ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO)); + + /* Array to store IDs of threads */ + + AcpiGbl_DbMethodInfo.NumThreads = NumThreads; + Size = 4 * AcpiGbl_DbMethodInfo.NumThreads; + AcpiGbl_DbMethodInfo.Threads = (UINT32 *) AcpiOsAllocate (Size); + if (AcpiGbl_DbMethodInfo.Threads == NULL) + { + AcpiOsPrintf ("No memory for thread IDs array\n"); + (void) AcpiOsDeleteSemaphore (MainThreadGate); + (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); return; } + ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size); /* Setup the context to be passed to each thread */ AcpiGbl_DbMethodInfo.Name = MethodNameArg; - AcpiGbl_DbMethodInfo.Args = NULL; AcpiGbl_DbMethodInfo.Flags = 0; AcpiGbl_DbMethodInfo.NumLoops = NumLoops; - AcpiGbl_DbMethodInfo.ThreadGate = ThreadGate; + AcpiGbl_DbMethodInfo.MainThreadGate = MainThreadGate; + AcpiGbl_DbMethodInfo.ThreadCompleteGate = ThreadCompleteGate; + + /* Init arguments to be passed to method */ + + AcpiGbl_DbMethodInfo.InitArgs = 1; + AcpiGbl_DbMethodInfo.Args = AcpiGbl_DbMethodInfo.Arguments; + AcpiGbl_DbMethodInfo.Arguments[0] = AcpiGbl_DbMethodInfo.NumThreadsStr; + AcpiGbl_DbMethodInfo.Arguments[1] = AcpiGbl_DbMethodInfo.IdOfThreadStr; + AcpiGbl_DbMethodInfo.Arguments[2] = AcpiGbl_DbMethodInfo.IndexOfThreadStr; + AcpiGbl_DbMethodInfo.Arguments[3] = NULL; + AcpiDbUInt32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr); AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); @@ -620,7 +682,7 @@ AcpiDbCreateExecutionThreads ( for (i = 0; i < (NumThreads); i++) { - Status = AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, + Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbMethodThread, &AcpiGbl_DbMethodInfo); if (ACPI_FAILURE (Status)) { @@ -630,20 +692,19 @@ AcpiDbCreateExecutionThreads ( /* Wait for all threads to complete */ - i = NumThreads; - while (i) /* Brain damage for host OSs that only support wait of 1 unit */ - { - Status = AcpiOsWaitSemaphore (ThreadGate, 1, ACPI_WAIT_FOREVER); - i--; - } - - /* Cleanup and exit */ - - (void) AcpiOsDeleteSemaphore (ThreadGate); + AcpiOsWaitSemaphore (MainThreadGate, 1, ACPI_WAIT_FOREVER); AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); + + /* Cleanup and exit */ + + (void) AcpiOsDeleteSemaphore (MainThreadGate); + (void) AcpiOsDeleteSemaphore (ThreadCompleteGate); + + AcpiOsFree (AcpiGbl_DbMethodInfo.Threads); + AcpiGbl_DbMethodInfo.Threads = NULL; } #endif /* ACPI_DEBUGGER */ diff --git a/sys/dist/acpica/dbfileio.c b/sys/dist/acpica/dbfileio.c index 03e3f431b92..25d3d134252 100644 --- a/sys/dist/acpica/dbfileio.c +++ b/sys/dist/acpica/dbfileio.c @@ -2,7 +2,7 @@ * * Module Name: dbfileio - Debugger file I/O commands. These can't usually * be used when running the debugger in Ring 0 (Kernel mode) - * xRevision: 1.87 $ + * $Revision: 1.5 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,13 +116,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbfileio.c,v 1.4 2006/11/25 16:48:32 christos Exp $"); - -#include "acpi.h" -#include "acdebug.h" -#include "acnamesp.h" -#include "actables.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdebug.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/actables.h> +#include <dist/acpica/acdisasm.h> #if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER) @@ -265,7 +263,7 @@ AcpiDbCheckTextModeCorruption ( { if (Table[i - 1] != 0x0D) { - /* The LF does not have a preceding CR, table not corrupted */ + /* The LF does not have a preceeding CR, table not corrupted */ return (AE_OK); } @@ -279,6 +277,11 @@ AcpiDbCheckTextModeCorruption ( } } + if (!Pairs) + { + return (AE_OK); + } + /* * Entire table scanned, each CR is part of a CR/LF pair -- * meaning that the table was treated as a text file somewhere. @@ -318,61 +321,95 @@ AcpiDbReadTable ( UINT32 Actual; ACPI_STATUS Status; UINT32 FileSize; + BOOLEAN StandardHeader = TRUE; + + /* Get the file size */ fseek (fp, 0, SEEK_END); FileSize = (UINT32) ftell (fp); fseek (fp, 0, SEEK_SET); - /* Read the table header */ - - if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != - sizeof (ACPI_TABLE_HEADER)) + if (FileSize < 4) { - AcpiOsPrintf ("Could not read the table header\n"); return (AE_BAD_HEADER); } - /* Validate the table header/length */ + /* Read the signature */ - Status = AcpiTbValidateTableHeader (&TableHeader); - if (ACPI_FAILURE (Status)) + if (fread (&TableHeader, 1, 4, fp) != 4) { - AcpiOsPrintf ("Table header is invalid!\n"); - return (Status); + AcpiOsPrintf ("Could not read the table signature\n"); + return (AE_BAD_HEADER); } - /* File size must be at least as long as the Header-specified length */ + fseek (fp, 0, SEEK_SET); - if (TableHeader.Length > FileSize) + /* The RSDT and FACS tables do not have standard ACPI headers */ + + if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD ") || + ACPI_COMPARE_NAME (TableHeader.Signature, "FACS")) { - AcpiOsPrintf ( - "TableHeader length [0x%X] greater than the input file size [0x%X]\n", - TableHeader.Length, FileSize); - return (AE_BAD_HEADER); + *TableLength = FileSize; + StandardHeader = FALSE; } + else + { + /* Read the table header */ + + if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != + sizeof (ACPI_TABLE_HEADER)) + { + AcpiOsPrintf ("Could not read the table header\n"); + return (AE_BAD_HEADER); + } - /* We only support a limited number of table types */ +#if 0 + /* Validate the table header/length */ - if (ACPI_STRNCMP ((char *) TableHeader.Signature, DSDT_SIG, 4) && - ACPI_STRNCMP ((char *) TableHeader.Signature, PSDT_SIG, 4) && - ACPI_STRNCMP ((char *) TableHeader.Signature, SSDT_SIG, 4)) - { - AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", - (char *) TableHeader.Signature); - ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); - return (AE_ERROR); + Status = AcpiTbValidateTableHeader (&TableHeader); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Table header is invalid!\n"); + return (Status); + } +#endif + + /* File size must be at least as long as the Header-specified length */ + + if (TableHeader.Length > FileSize) + { + AcpiOsPrintf ( + "TableHeader length [0x%X] greater than the input file size [0x%X]\n", + TableHeader.Length, FileSize); + return (AE_BAD_HEADER); + } + +#ifdef ACPI_OBSOLETE_CODE + /* We only support a limited number of table types */ + + if (ACPI_STRNCMP ((char *) TableHeader.Signature, DSDT_SIG, 4) && + ACPI_STRNCMP ((char *) TableHeader.Signature, PSDT_SIG, 4) && + ACPI_STRNCMP ((char *) TableHeader.Signature, SSDT_SIG, 4)) + { + AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", + (char *) TableHeader.Signature); + ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); + return (AE_ERROR); + } +#endif + + *TableLength = TableHeader.Length; } /* Allocate a buffer for the table */ - *TableLength = TableHeader.Length; - *Table = AcpiOsAllocate ((size_t) (FileSize)); + *Table = AcpiOsAllocate ((size_t) FileSize); if (!*Table) { AcpiOsPrintf ( "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", - TableHeader.Signature, TableHeader.Length); + TableHeader.Signature, *TableLength); return (AE_NO_MEMORY); } @@ -382,15 +419,19 @@ AcpiDbReadTable ( Actual = fread (*Table, 1, (size_t) FileSize, fp); if (Actual == FileSize) { - /* Now validate the checksum */ + if (StandardHeader) + { + /* Now validate the checksum */ - Status = AcpiTbVerifyTableChecksum (*Table); + Status = AcpiTbChecksum ((void *) *Table, + ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length); - if (Status == AE_BAD_CHECKSUM) - { - Status = AcpiDbCheckTextModeCorruption ((UINT8 *) *Table, - FileSize, (*Table)->Length); - return (Status); + if (Status == AE_BAD_CHECKSUM) + { + Status = AcpiDbCheckTextModeCorruption ((UINT8 *) *Table, + FileSize, (*Table)->Length); + return (Status); + } } return (AE_OK); } @@ -431,11 +472,12 @@ static ACPI_STATUS AeLocalLoadTable ( ACPI_TABLE_HEADER *Table) { - ACPI_STATUS Status; - ACPI_TABLE_DESC TableInfo; + ACPI_STATUS Status = AE_OK; +/* ACPI_TABLE_DESC TableInfo; */ - ACPI_FUNCTION_TRACE ("AeLocalLoadTable"); + ACPI_FUNCTION_TRACE (AeLocalLoadTable); +#if 0 if (!Table) @@ -475,10 +517,11 @@ AeLocalLoadTable ( { /* Uninstall table and free the buffer */ - AcpiTbDeleteTablesByType (ACPI_TABLE_DSDT); + AcpiTbDeleteTablesByType (ACPI_TABLE_ID_DSDT); return_ACPI_STATUS (Status); } #endif +#endif return_ACPI_STATUS (Status); } @@ -554,6 +597,7 @@ AcpiDbGetTableFromFile ( #ifdef ACPI_APPLICATION ACPI_STATUS Status; ACPI_TABLE_HEADER *Table; + BOOLEAN IsAmlTable = TRUE; Status = AcpiDbReadTableFromFile (Filename, &Table); @@ -562,28 +606,36 @@ AcpiDbGetTableFromFile ( return (Status); } - /* Attempt to recognize and install the table */ +#ifdef ACPI_DATA_TABLE_DISASSEMBLY + IsAmlTable = AcpiUtIsAmlTable (Table); +#endif - Status = AeLocalLoadTable (Table); - if (ACPI_FAILURE (Status)) + if (IsAmlTable) { - if (Status == AE_ALREADY_EXISTS) - { - AcpiOsPrintf ("Table %4.4s is already installed\n", - Table->Signature); - } - else + /* Attempt to recognize and install the table */ + + Status = AeLocalLoadTable (Table); + if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not install table, %s\n", - AcpiFormatException (Status)); + if (Status == AE_ALREADY_EXISTS) + { + AcpiOsPrintf ("Table %4.4s is already installed\n", + Table->Signature); + } + else + { + AcpiOsPrintf ("Could not install table, %s\n", + AcpiFormatException (Status)); + } + + return (Status); } - return (Status); + fprintf (stderr, + "Acpi table [%4.4s] successfully installed and loaded\n", + Table->Signature); } - fprintf (stderr, "Acpi table [%4.4s] successfully installed and loaded\n", - Table->Signature); - AcpiGbl_AcpiHardwarePresent = FALSE; if (ReturnTable) { diff --git a/sys/dist/acpica/dbhistry.c b/sys/dist/acpica/dbhistry.c index d983e4c13e2..60399c65004 100644 --- a/sys/dist/acpica/dbhistry.c +++ b/sys/dist/acpica/dbhistry.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dbhistry - debugger HISTORY command - * xRevision: 1.33 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,11 +115,8 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbhistry.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acdebug.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdebug.h> #ifdef ACPI_DEBUGGER diff --git a/sys/dist/acpica/dbinput.c b/sys/dist/acpica/dbinput.c index 03e720c425a..7014a2a6e97 100644 --- a/sys/dist/acpica/dbinput.c +++ b/sys/dist/acpica/dbinput.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbinput - user front-end to the AML debugger - * xRevision: 1.113 $ + * $Revision: 1.4 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,11 +115,8 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbinput.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acdebug.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdebug.h> #ifdef ACPI_DEBUGGER diff --git a/sys/dist/acpica/dbstats.c b/sys/dist/acpica/dbstats.c index 1e786005bc1..879716fd024 100644 --- a/sys/dist/acpica/dbstats.c +++ b/sys/dist/acpica/dbstats.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbstats - Generation and display of ACPI table statistics - * xRevision: 1.81 $ + * $Revision: 1.4 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,9 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbstats.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acdebug.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdebug.h> +#include <dist/acpica/acnamesp.h> #ifdef ACPI_DEBUGGER @@ -144,9 +141,11 @@ AcpiDbClassifyOneObject ( void *Context, void **ReturnValue); +#if defined ACPI_DBG_TRACK_ALLOCATIONS || defined ACPI_USE_LOCAL_CACHE static void AcpiDbListInfo ( ACPI_MEMORY_LIST *List); +#endif /* @@ -173,6 +172,8 @@ static ARGUMENT_INFO AcpiDbStatTypes [] = #define CMD_STAT_STACK 6 +#if defined ACPI_DBG_TRACK_ALLOCATIONS || defined ACPI_USE_LOCAL_CACHE + /******************************************************************************* * * FUNCTION: AcpiDbListInfo @@ -191,7 +192,6 @@ AcpiDbListInfo ( { #ifdef ACPI_DBG_TRACK_ALLOCATIONS UINT32 Outstanding; - UINT32 Temp; #endif AcpiOsPrintf ("\n%s\n", List->ListName); @@ -201,7 +201,7 @@ AcpiDbListInfo ( if (List->MaxDepth > 0) { AcpiOsPrintf ( - " Cache: [Depth Max Avail Size] % 7d % 7d % 7d % 7d B\n", + " Cache: [Depth MaxD Avail Size] %8.2X %8.2X %8.2X %8.2X\n", List->CurrentDepth, List->MaxDepth, List->MaxDepth - List->CurrentDepth, @@ -212,33 +212,39 @@ AcpiDbListInfo ( if (List->MaxDepth > 0) { AcpiOsPrintf ( - " Cache: [Requests Hits Misses ObjSize] % 7d % 7d % 7d % 7d B\n", + " Cache: [Requests Hits Misses ObjSize] %8.2X %8.2X %8.2X %8.2X\n", List->Requests, List->Hits, List->Requests - List->Hits, List->ObjectSize); } - Outstanding = List->TotalAllocated - - List->TotalFreed - - List->CurrentDepth; + Outstanding = AcpiDbGetCacheInfo (List); if (List->ObjectSize) { - Temp = ACPI_ROUND_UP_TO_1K (Outstanding * List->ObjectSize); + AcpiOsPrintf ( + " Mem: [Alloc Free Max CurSize Outstanding] %8.2X %8.2X %8.2X %8.2X %8.2X\n", + List->TotalAllocated, + List->TotalFreed, + List->MaxOccupied, + Outstanding * List->ObjectSize, + Outstanding); } else { - Temp = ACPI_ROUND_UP_TO_1K (List->CurrentTotalSize); + AcpiOsPrintf ( + " Mem: [Alloc Free Max CurSize Outstanding Total] %8.2X %8.2X %8.2X %8.2X %8.2X %8.2X\n", + List->TotalAllocated, + List->TotalFreed, + List->MaxOccupied, + List->CurrentTotalSize, + Outstanding, + List->TotalSize); } - - AcpiOsPrintf ( - " Mem: [Alloc Free Outstanding Size] % 7d % 7d % 7d % 7d Kb\n", - List->TotalAllocated, - List->TotalFreed, - Outstanding, Temp); #endif } +#endif /******************************************************************************* @@ -465,11 +471,6 @@ AcpiDbDisplayStatistics ( UINT32 Temp; - if (!AcpiGbl_DSDT) - { - AcpiOsPrintf ("*** Warning: There is no DSDT loaded\n"); - } - if (!TypeArg) { AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n"); @@ -496,12 +497,7 @@ AcpiDbDisplayStatistics ( case CMD_STAT_TABLES: - AcpiOsPrintf ("ACPI Table Information:\n\n"); - if (AcpiGbl_DSDT) - { - AcpiOsPrintf ("DSDT Length:................% 7ld (%X)\n", - AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length); - } + AcpiOsPrintf ("ACPI Table Information (not implemented):\n\n"); break; case CMD_STAT_OBJECTS: @@ -528,18 +524,19 @@ AcpiDbDisplayStatistics ( case CMD_STAT_MEMORY: #ifdef ACPI_DBG_TRACK_ALLOCATIONS - AcpiOsPrintf ("\n----Object and Cache Statistics---------------------------------------------\n"); + AcpiOsPrintf ("\n----Object Statistics (all in hex)---------\n"); AcpiDbListInfo (AcpiGbl_GlobalList); AcpiDbListInfo (AcpiGbl_NsNodeList); +#endif #ifdef ACPI_USE_LOCAL_CACHE + AcpiOsPrintf ("\n----Cache Statistics (all in hex)----------\n"); AcpiDbListInfo (AcpiGbl_OperandCache); AcpiDbListInfo (AcpiGbl_PsNodeCache); AcpiDbListInfo (AcpiGbl_PsNodeExtCache); AcpiDbListInfo (AcpiGbl_StateCache); #endif -#endif break; @@ -554,7 +551,7 @@ AcpiDbDisplayStatistics ( AcpiOsPrintf ("\n"); AcpiOsPrintf ("Mutex usage:\n\n"); - for (i = 0; i < NUM_MUTEX; i++) + for (i = 0; i < ACPI_NUM_MUTEX; i++) { AcpiOsPrintf ("%-28s: % 7ld\n", AcpiUtGetMutexName (i), AcpiGbl_MutexInfo[i].UseCount); diff --git a/sys/dist/acpica/dbutils.c b/sys/dist/acpica/dbutils.c index c89d38d03ef..c26e03e907e 100644 --- a/sys/dist/acpica/dbutils.c +++ b/sys/dist/acpica/dbutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbutils - AML debugger utilities - * xRevision: 1.80 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,10 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbutils.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acnamesp.h" -#include "acdebug.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdebug.h> +#include <dist/acpica/acdisasm.h> #ifdef ACPI_DEBUGGER @@ -141,6 +138,8 @@ AcpiDbDumpBuffer ( UINT32 Address); #endif +static const char *Converter = "0123456789ABCDEF"; + /******************************************************************************* * @@ -426,11 +425,52 @@ AcpiDbLocalNsLookup ( Name, AcpiFormatException (Status)); } - ACPI_MEM_FREE (InternalPath); + ACPI_FREE (InternalPath); return (Node); } +/******************************************************************************* + * + * FUNCTION: AcpiDbUInt32ToHexString + * + * PARAMETERS: Value - The value to be converted to string + * Buffer - Buffer for result (not less than 11 bytes) + * + * RETURN: None + * + * DESCRIPTION: Convert the unsigned 32-bit value to the hexadecimal image + * + * NOTE: It is the caller's responsibility to ensure that the length of buffer + * is sufficient. + * + ******************************************************************************/ + +void +AcpiDbUInt32ToHexString ( + UINT32 Value, + char *Buffer) +{ + UINT8 i; + + + if (Value == 0) + { + ACPI_STRCPY (Buffer, "0"); + return; + } + + ACPI_STRCPY (Buffer, "0x"); + Buffer[10] = '\0'; + + for (i = 9; i > 1; i--) + { + Buffer[i] = Converter [Value & 0x0F]; + Value = Value >> 4; + } +} + + #ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * diff --git a/sys/dist/acpica/dbxface.c b/sys/dist/acpica/dbxface.c index 1840a51e85b..0cd30bd4567 100644 --- a/sys/dist/acpica/dbxface.c +++ b/sys/dist/acpica/dbxface.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbxface - AML Debugger external interfaces - * xRevision: 1.76 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,10 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbxface.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "amlcode.h" -#include "acdebug.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdebug.h> +#include <dist/acpica/acdisasm.h> #ifdef ACPI_DEBUGGER @@ -376,7 +373,9 @@ AcpiDbSingleStep ( /* Now we can display it */ +#ifdef ACPI_DISASSEMBLER AcpiDmDisassemble (WalkState, DisplayOp, ACPI_UINT32_MAX); +#endif if ((Op->Common.AmlOpcode == AML_IF_OP) || (Op->Common.AmlOpcode == AML_WHILE_OP)) @@ -488,9 +487,11 @@ AcpiDbInitialize ( AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; AcpiGbl_DbOpt_tables = FALSE; - AcpiGbl_DbOpt_disasm = FALSE; AcpiGbl_DbOpt_stats = FALSE; +#ifdef ACPI_DISASSEMBLER + AcpiGbl_DbOpt_disasm = FALSE; AcpiGbl_DbOpt_verbose = TRUE; +#endif AcpiGbl_DbOpt_ini_methods = TRUE; AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE); @@ -531,7 +532,7 @@ AcpiDbInitialize ( /* Create the debug execution thread to execute commands */ - Status = AcpiOsQueueForExecution (0, AcpiDbExecuteThread, NULL); + Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not start debugger thread\n"); @@ -539,11 +540,13 @@ AcpiDbInitialize ( } } +#ifdef ACPI_DISASSEMBLER if (!AcpiGbl_DbOpt_verbose) { AcpiGbl_DbOpt_disasm = TRUE; AcpiGbl_DbOpt_stats = FALSE; } +#endif return (AE_OK); } diff --git a/sys/dist/acpica/dmbuffer.c b/sys/dist/acpica/dmbuffer.c index b4c4ff5f148..024a00c088e 100644 --- a/sys/dist/acpica/dmbuffer.c +++ b/sys/dist/acpica/dmbuffer.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmbuffer - AML disassembler, buffer and string support - * xRevision: 1.20 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,10 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmbuffer.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acdisasm.h" -#include "acparser.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdisasm.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> #ifdef ACPI_DISASSEMBLER @@ -146,7 +143,8 @@ AcpiDmUnicode ( * * RETURN: None * - * DESCRIPTION: Dump an AML "ByteList" in Hex format + * DESCRIPTION: Dump an AML "ByteList" in Hex format. 8 bytes per line, prefixed + * with the hex buffer offset. * ******************************************************************************/ @@ -159,12 +157,31 @@ AcpiDmDisasmByteList ( UINT32 i; - AcpiDmIndent (Level); + if (!ByteCount) + { + return; + } /* Dump the byte list */ for (i = 0; i < ByteCount; i++) { + /* New line every 8 bytes */ + + if (((i % 8) == 0) && (i < ByteCount)) + { + if (i > 0) + { + AcpiOsPrintf ("\n"); + } + + AcpiDmIndent (Level); + if (ByteCount > 7) + { + AcpiOsPrintf ("/* %04X */ ", i); + } + } + AcpiOsPrintf ("0x%2.2X", (UINT32) ByteData[i]); /* Add comma if there are more bytes to display */ @@ -173,14 +190,6 @@ AcpiDmDisasmByteList ( { AcpiOsPrintf (", "); } - - /* New line every 8 bytes */ - - if ((((i+1) % 8) == 0) && ((i+1) < ByteCount)) - { - AcpiOsPrintf ("\n"); - AcpiDmIndent (Level); - } } if (Level) @@ -224,7 +233,7 @@ AcpiDmByteList ( { case ACPI_DASM_RESOURCE: - AcpiDmResourceTemplate (Info, ByteData, ByteCount); + AcpiDmResourceTemplate (Info, Op->Common.Parent, ByteData, ByteCount); break; case ACPI_DASM_STRING: @@ -463,7 +472,7 @@ AcpiDmIsEisaId ( /* We are looking for _HID */ - if (ACPI_STRNCMP ((char *) &Name, METHOD_NAME__HID, 4)) + if (ACPI_STRNCMP((char *)&Name, METHOD_NAME__HID, 4)) { return; } diff --git a/sys/dist/acpica/dmnames.c b/sys/dist/acpica/dmnames.c index 10f1f0a4dbf..42322487ab4 100644 --- a/sys/dist/acpica/dmnames.c +++ b/sys/dist/acpica/dmnames.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmnames - AML disassembler, names, namestrings, pathnames - * xRevision: 1.12 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmnames.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdisasm.h> #ifdef ACPI_DISASSEMBLER @@ -157,21 +154,33 @@ AcpiDmDumpName ( { UINT32 i; UINT32 Length; - char *End = Name + ACPI_NAME_SIZE; + char NewName[4]; + + + /* Ensure that the name is printable, even if we have to fix it */ + + *(UINT32 *) NewName = AcpiUtRepairName (Name); + /* Remove all trailing underscores from the name */ - for (i = 0; i < ACPI_NAME_SIZE; i++) + Length = ACPI_NAME_SIZE; + for (i = (ACPI_NAME_SIZE - 1); i != 0; i--) { - if (Name[i] != '_') + if (NewName[i] == '_') { - End = &Name[i]; + Length--; + } + else + { + break; } } - Length = (UINT32)(End - Name) + 1; + /* Dump the name, up to the start of the trailing underscores */ + for (i = 0; i < Length; i++) { - AcpiOsPrintf ("%c", Name[i]); + AcpiOsPrintf ("%c", NewName[i]); } return (Length); @@ -248,7 +257,7 @@ AcpiPsDisplayObjectPathname ( } AcpiOsPrintf (" (Path %s)", (char *) Buffer.Pointer); - ACPI_MEM_FREE (Buffer.Pointer); + ACPI_FREE (Buffer.Pointer); Exit: diff --git a/sys/dist/acpica/dmobject.c b/sys/dist/acpica/dmobject.c index 9459f9527e8..e0e805d8955 100644 --- a/sys/dist/acpica/dmobject.c +++ b/sys/dist/acpica/dmobject.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmobject - ACPI object decode and display - * xRevision: 1.19 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmobject.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acdisasm.h" -#include "acparser.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdisasm.h> +#include <dist/acpica/acparser.h> #ifdef ACPI_DISASSEMBLER @@ -213,13 +210,16 @@ AcpiDmDumpMethodInfo ( if (NextWalkState == WalkState) { - /* Display currently executing ASL statement */ + if (Op) + { + /* Display currently executing ASL statement */ - Next = Op->Common.Next; - Op->Common.Next = NULL; + Next = Op->Common.Next; + Op->Common.Next = NULL; - AcpiDmDisassemble (NextWalkState, Op, ACPI_UINT32_MAX); - Op->Common.Next = Next; + AcpiDmDisassemble (NextWalkState, Op, ACPI_UINT32_MAX); + Op->Common.Next = Next; + } } else { @@ -614,8 +614,6 @@ AcpiDmDisplayArguments ( { UINT32 i; ACPI_OPERAND_OBJECT *ObjDesc; - UINT32 NumArgs; - UINT32 Concurrency; ACPI_NAMESPACE_NODE *Node; @@ -634,12 +632,9 @@ AcpiDmDisplayArguments ( return; } - NumArgs = ObjDesc->Method.ParamCount; - Concurrency = ObjDesc->Method.Concurrency; - AcpiOsPrintf ( "Arguments for Method [%4.4s]: (%X arguments defined, max concurrency = %X)\n", - AcpiUtGetNodeName (Node), NumArgs, Concurrency); + AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount, ObjDesc->Method.SyncLevel); for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { diff --git a/sys/dist/acpica/dmopcode.c b/sys/dist/acpica/dmopcode.c index 30af068962a..004edfa01d5 100644 --- a/sys/dist/acpica/dmopcode.c +++ b/sys/dist/acpica/dmopcode.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmopcode - AML disassembler, specific AML opcodes - * xRevision: 1.93 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmopcode.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdisasm.h> #ifdef ACPI_DISASSEMBLER @@ -214,7 +211,7 @@ AcpiDmFieldFlags ( Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; - AcpiOsPrintf ("%s, ", AcpiGbl_AccessTypes [Flags & 0x0F]); + AcpiOsPrintf ("%s, ", AcpiGbl_AccessTypes [Flags & 0x07]); AcpiOsPrintf ("%s, ", AcpiGbl_LockRule [(Flags & 0x10) >> 4]); AcpiOsPrintf ("%s)", AcpiGbl_UpdateRules [(Flags & 0x60) >> 5]); } @@ -343,7 +340,7 @@ AcpiDmMatchKeyword ( { - if (((UINT32) Op->Common.Value.Integer) >= ACPI_NUM_MATCH_OPS) + if (((UINT32) Op->Common.Value.Integer) > ACPI_MAX_MATCH_OPCODE) { AcpiOsPrintf ("/* Unknown Match Keyword encoding */"); } @@ -378,6 +375,8 @@ AcpiDmDisassembleOneOp ( const ACPI_OPCODE_INFO *OpInfo = NULL; UINT32 Offset; UINT32 Length; + ACPI_PARSE_OBJECT *Child; + ACPI_STATUS Status; if (!Op) @@ -393,38 +392,52 @@ AcpiDmDisassembleOneOp ( AcpiDmMatchKeyword (Op); return; - default: - break; - } - - /* The op and arguments */ - - switch (Op->Common.AmlOpcode) - { - case AML_ZERO_OP: - - AcpiOsPrintf ("Zero"); - break; + case ACPI_DASM_LNOT_SUFFIX: + switch (Op->Common.AmlOpcode) + { + case AML_LEQUAL_OP: + AcpiOsPrintf ("LNotEqual"); + break; + case AML_LGREATER_OP: + AcpiOsPrintf ("LLessEqual"); + break; - case AML_ONE_OP: + case AML_LLESS_OP: + AcpiOsPrintf ("LGreaterEqual"); + break; + } + Op->Common.DisasmOpcode = 0; + Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; + return; - AcpiOsPrintf ("One"); + default: break; + } - case AML_ONES_OP: - - AcpiOsPrintf ("Ones"); - break; + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + /* The op and arguments */ - case AML_REVISION_OP: + switch (Op->Common.AmlOpcode) + { + case AML_LNOT_OP: - AcpiOsPrintf ("Revision"); + Child = Op->Common.Value.Arg; + if ((Child->Common.AmlOpcode == AML_LEQUAL_OP) || + (Child->Common.AmlOpcode == AML_LGREATER_OP) || + (Child->Common.AmlOpcode == AML_LLESS_OP)) + { + Child->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX; + Op->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX; + } + else + { + AcpiOsPrintf ("%s", OpInfo->Name); + } break; - case AML_BYTE_OP: AcpiOsPrintf ("0x%2.2X", (UINT32) Op->Common.Value.Integer); @@ -484,12 +497,19 @@ AcpiDmDisassembleOneOp ( * types of buffers, we have to closely look at the data in the * buffer to determine the type. */ - if (AcpiDmIsResourceTemplate (Op)) + Status = AcpiDmIsResourceTemplate (Op); + if (ACPI_SUCCESS (Status)) { Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE; AcpiOsPrintf ("ResourceTemplate"); + break; } - else if (AcpiDmIsUnicodeBuffer (Op)) + else if (Status == AE_AML_NO_RESOURCE_END_TAG) + { + AcpiOsPrintf ("/**** Is ResourceTemplate, but EndTag not at buffer end ****/ "); + } + + if (AcpiDmIsUnicodeBuffer (Op)) { Op->Common.DisasmOpcode = ACPI_DASM_UNICODE; AcpiOsPrintf ("Unicode ("); @@ -546,7 +566,7 @@ AcpiDmDisassembleOneOp ( if (Info->BitOffset % 8 == 0) { - AcpiOsPrintf ("Offset (0x%.2X)", ACPI_DIV_8 (Info->BitOffset)); + AcpiOsPrintf (" Offset (0x%.2X)", ACPI_DIV_8 (Info->BitOffset)); } else { @@ -559,8 +579,8 @@ AcpiDmDisassembleOneOp ( case AML_INT_ACCESSFIELD_OP: - AcpiOsPrintf ("AccessAs (%s, ", - AcpiGbl_AccessTypes [(UINT32) Op->Common.Value.Integer >> 8]); + AcpiOsPrintf (" AccessAs (%s, ", + AcpiGbl_AccessTypes [(UINT32) (Op->Common.Value.Integer >> 8) & 0x7]); AcpiDmDecodeAttribute ((UINT8) Op->Common.Value.Integer); AcpiOsPrintf (")"); @@ -576,7 +596,6 @@ AcpiDmDisassembleOneOp ( case AML_INT_METHODCALL_OP: - OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); Op = AcpiPsGetDepthNext (NULL, Op); Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; @@ -588,7 +607,6 @@ AcpiDmDisassembleOneOp ( /* Just get the opcode name and print it */ - OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); AcpiOsPrintf ("%s", OpInfo->Name); @@ -597,13 +615,15 @@ AcpiDmDisassembleOneOp ( if ((Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) && (WalkState) && (WalkState->Results) && - (WalkState->Results->Results.NumResults)) + (WalkState->ResultCount)) { AcpiDmDecodeInternalObject ( WalkState->Results->Results.ObjDesc [ - WalkState->Results->Results.NumResults-1]); + (WalkState->ResultCount - 1) % + ACPI_RESULTS_FRAME_OBJ_NUM]); } #endif + break; } } diff --git a/sys/dist/acpica/dmresrc.c b/sys/dist/acpica/dmresrc.c index 358596bf070..aae477e33f1 100644 --- a/sys/dist/acpica/dmresrc.c +++ b/sys/dist/acpica/dmresrc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmresrc.c - Resource Descriptor disassembly - * xRevision: 1.29 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,9 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmresrc.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "amlcode.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdisasm.h> #ifdef ACPI_DISASSEMBLER @@ -174,6 +171,41 @@ static ACPI_RESOURCE_HANDLER AcpiGbl_DumpResourceDispatch [] = }; +/* Only used for single-threaded applications */ +/* TBD: remove when name is passed as parameter to the dump functions */ + +static UINT32 ResourceName; + + +/******************************************************************************* + * + * FUNCTION: AcpiDmDescriptorName + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Emit a name for the descriptor if one is present (indicated + * by the name being changed from the default name.) A name is only + * emitted if a reference to the descriptor has been made somewhere + * in the original ASL code. + * + ******************************************************************************/ + +void +AcpiDmDescriptorName ( + void) +{ + + if (ResourceName == ACPI_DEFAULT_RESNAME) + { + return; + } + + AcpiOsPrintf ("%4.4s", (char *) &ResourceName); +} + + /******************************************************************************* * * FUNCTION: AcpiDmDumpInteger* @@ -216,8 +248,7 @@ AcpiDmDumpInteger64 ( UINT64 Value, const char *Name) { - AcpiOsPrintf ("0x%8.8X%8.8X, // %s\n", - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Value)), Name); + AcpiOsPrintf ("0x%8.8X%8.8X, // %s\n", ACPI_FORMAT_UINT64 (Value), Name); } @@ -289,6 +320,7 @@ AcpiDmBitList ( void AcpiDmResourceTemplate ( ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op, UINT8 *ByteData, UINT32 ByteCount) { @@ -300,9 +332,16 @@ AcpiDmResourceTemplate ( UINT32 Level; BOOLEAN DependentFns = FALSE; UINT8 ResourceIndex; + ACPI_NAMESPACE_NODE *Node; Level = Info->Level; + ResourceName = ACPI_DEFAULT_RESNAME; + Node = Op->Common.Node; + if (Node) + { + Node = Node->Child; + } for (CurrentByteOffset = 0; CurrentByteOffset < ByteCount; ) { @@ -378,6 +417,12 @@ AcpiDmResourceTemplate ( /* Disassemble the resource structure */ + if (Node) + { + ResourceName = Node->Name.Integer; + Node = Node->Peer; + } + AcpiGbl_DumpResourceDispatch [ResourceIndex] ( Aml, ResourceLength, Level); @@ -398,18 +443,18 @@ AcpiDmResourceTemplate ( * * PARAMETERS: Op - Buffer Op to be examined * - * RETURN: TRUE if this Buffer Op contains a valid resource - * descriptor. + * RETURN: Status. AE_OK if valid template * * DESCRIPTION: Walk a byte list to determine if it consists of a valid set * of resource descriptors. Nothing is output. * ******************************************************************************/ -BOOLEAN +ACPI_STATUS AcpiDmIsResourceTemplate ( ACPI_PARSE_OBJECT *Op) { + ACPI_STATUS Status; ACPI_PARSE_OBJECT *NextOp; UINT8 *Aml; UINT8 *EndAml; @@ -420,77 +465,45 @@ AcpiDmIsResourceTemplate ( if (Op->Common.AmlOpcode != AML_BUFFER_OP) { - return FALSE; + return (AE_TYPE); } - /* Get to the ByteData list */ + /* Get the ByteData list and length */ NextOp = Op->Common.Value.Arg; NextOp = NextOp->Common.Next; if (!NextOp) { - return (FALSE); + return (AE_TYPE); } - /* Extract the data length and data pointer */ - Aml = NextOp->Named.Data; Length = (ACPI_SIZE) NextOp->Common.Value.Integer; - /* Point to where the EndTag descriptor should be */ + /* Walk the byte list, abort on any invalid descriptor type or length */ - EndAml = Aml + Length - sizeof (AML_RESOURCE_END_TAG); + Status = AcpiUtWalkAmlResources (Aml, Length, NULL, &EndAml); + if (ACPI_FAILURE (Status)) + { + return (AE_TYPE); + } /* - * The absolute minimum resource template is an EndTag (2 bytes), - * and the list must be terminated by a valid 2-byte EndTag (length 1) + * For the resource template to be valid, one EndTag must appear + * at the very end of the ByteList, not before. (For proper disassembly + * of a ResourceTemplate, the buffer must not have any extra data after + * the EndTag.) */ - if ((Length < sizeof (AML_RESOURCE_END_TAG)) || - - (*EndAml != (ACPI_RESOURCE_NAME_END_TAG | 1))) + if ((Aml + Length - sizeof (AML_RESOURCE_END_TAG)) != EndAml) { - return (FALSE); + return (AE_AML_NO_RESOURCE_END_TAG); } - /* Walk the byte list, abort on any invalid descriptor type or length */ - - while (Aml <= EndAml) - { - /* Validate the Resource Type and Resource Length */ - - if (ACPI_FAILURE (AcpiUtValidateResource (Aml, NULL))) - { - return (FALSE); - } - - /* An EndTag descriptor terminates this resource template */ - - if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) - { - /* - * For the resource template to be valid, one EndTag must appear - * at the very end of the ByteList, not before - */ - if (Aml != EndAml) - { - return (FALSE); - } - - /* - * All resource descriptors are valid, therefore this list appears - * to be a valid resource template - */ - return (TRUE); - } - - /* This descriptor is valid, point to the next descriptor */ - - Aml += AcpiUtGetDescriptorLength (Aml); - } - - /* Did not find an EndTag, not a valid resource template */ - - return (FALSE); + /* + * All resource descriptors are valid, therefore this list appears + * to be a valid resource template + */ + return (AE_OK); } #endif diff --git a/sys/dist/acpica/dmresrcl.c b/sys/dist/acpica/dmresrcl.c index 2286396b673..ab0b14071e1 100644 --- a/sys/dist/acpica/dmresrcl.c +++ b/sys/dist/acpica/dmresrcl.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmresrcl.c - "Large" Resource Descriptor disassembly - * xRevision: 1.31 $ + * $Revision: 1.4 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,11 +115,8 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmresrcl.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdisasm.h> #ifdef ACPI_DISASSEMBLER @@ -132,19 +129,19 @@ __KERNEL_RCSID(0, "$NetBSD: dmresrcl.c,v 1.3 2006/11/16 01:33:31 christos Exp $" static const char *AcpiDmAddressNames[] = { - "Address Space Granularity", - "Address Range Minimum", - "Address Range Maximum", - "Address Translation Offset", - "Address Length" + "Granularity", + "Range Minimum", + "Range Maximum", + "Translation Offset", + "Length" }; static const char *AcpiDmMemoryNames[] = { - "Address Range Minimum", - "Address Range Maximum", - "Address Alignment", - "Address Length" + "Range Minimum", + "Range Maximum", + "Alignment", + "Length" }; @@ -393,7 +390,7 @@ AcpiDmAddressCommon ( /* This is either a Memory, IO, or BusNumber descriptor (0,1,2) */ - AcpiOsPrintf ("%s (", AcpiGbl_WordDecode [ResourceType]); + AcpiOsPrintf ("%s (", AcpiGbl_WordDecode [ResourceType & 0x3]); /* Decode the general and type-specific flags */ @@ -406,7 +403,7 @@ AcpiDmAddressCommon ( AcpiDmIoFlags (Flags); if (ResourceType == ACPI_IO_RANGE) { - AcpiOsPrintf (" %s,", AcpiGbl_RNGDecode [SpecificFlags & 0x3]); + AcpiOsPrintf (" %s,", AcpiGbl_RngDecode [SpecificFlags & 0x3]); } } } @@ -459,7 +456,7 @@ AcpiDmSpaceFlags ( AcpiOsPrintf ("%s, %s, %s, %s,", AcpiGbl_ConsumeDecode [(Flags & 1)], - AcpiGbl_DECDecode [(Flags & 0x2) >> 1], + AcpiGbl_DecDecode [(Flags & 0x2) >> 1], AcpiGbl_MinDecode [(Flags & 0x4) >> 2], AcpiGbl_MaxDecode [(Flags & 0x8) >> 3]); } @@ -485,7 +482,7 @@ AcpiDmIoFlags ( AcpiGbl_ConsumeDecode [(Flags & 1)], AcpiGbl_MinDecode [(Flags & 0x4) >> 2], AcpiGbl_MaxDecode [(Flags & 0x8) >> 3], - AcpiGbl_DECDecode [(Flags & 0x2) >> 1]); + AcpiGbl_DecDecode [(Flags & 0x2) >> 1]); } @@ -507,14 +504,14 @@ AcpiDmIoFlags2 ( { AcpiOsPrintf (", %s", - AcpiGbl_TTPDecode [(SpecificFlags & 0x10) >> 4]); + AcpiGbl_TtpDecode [(SpecificFlags & 0x10) >> 4]); /* TRS is only used if TTP is TypeTranslation */ if (SpecificFlags & 0x10) { AcpiOsPrintf (", %s", - AcpiGbl_TRSDecode [(SpecificFlags & 0x20) >> 5]); + AcpiGbl_TrsDecode [(SpecificFlags & 0x20) >> 5]); } } @@ -540,11 +537,11 @@ AcpiDmMemoryFlags ( AcpiOsPrintf ("%s, %s, %s, %s, %s, %s,", AcpiGbl_ConsumeDecode [(Flags & 1)], - AcpiGbl_DECDecode [(Flags & 0x2) >> 1], + AcpiGbl_DecDecode [(Flags & 0x2) >> 1], AcpiGbl_MinDecode [(Flags & 0x4) >> 2], AcpiGbl_MaxDecode [(Flags & 0x8) >> 3], - AcpiGbl_MEMDecode [(SpecificFlags & 0x6) >> 1], - AcpiGbl_RWDecode [(SpecificFlags & 0x1)]); + AcpiGbl_MemDecode [(SpecificFlags & 0x6) >> 1], + AcpiGbl_RwDecode [(SpecificFlags & 0x1)]); } @@ -566,8 +563,8 @@ AcpiDmMemoryFlags2 ( { AcpiOsPrintf (", %s, %s", - AcpiGbl_MTPDecode [(SpecificFlags & 0x18) >> 3], - AcpiGbl_TTPDecode [(SpecificFlags & 0x20) >> 5]); + AcpiGbl_MtpDecode [(SpecificFlags & 0x18) >> 3], + AcpiGbl_TtpDecode [(SpecificFlags & 0x20) >> 5]); } @@ -603,7 +600,7 @@ AcpiDmResourceSource ( { /* The two optional fields are not used */ - AcpiOsPrintf (",,"); + AcpiOsPrintf (",, "); return; } @@ -631,7 +628,7 @@ AcpiDmResourceSource ( AcpiUtPrintString ((char *) &AmlResourceSource[1], ACPI_UINT8_MAX); } - AcpiOsPrintf (","); + AcpiOsPrintf (", "); } @@ -669,6 +666,10 @@ AcpiDmWordDescriptor ( AcpiDmIndent (Level + 1); AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS16), Length); + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); + /* Type-specific flags */ AcpiDmAddressFlags (Resource); @@ -710,6 +711,10 @@ AcpiDmDwordDescriptor ( AcpiDmIndent (Level + 1); AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS32), Length); + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); + /* Type-specific flags */ AcpiDmAddressFlags (Resource); @@ -751,6 +756,10 @@ AcpiDmQwordDescriptor ( AcpiDmIndent (Level + 1); AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS64), Length); + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); + /* Type-specific flags */ AcpiDmAddressFlags (Resource); @@ -793,9 +802,13 @@ AcpiDmExtendedDescriptor ( AcpiDmDumpInteger64 (Resource->ExtAddress64.TypeSpecific, "Type-Specific Attributes"); - /* Type-specific flags */ + /* Insert a descriptor name */ AcpiDmIndent (Level + 1); + AcpiDmDescriptorName (); + + /* Type-specific flags */ + AcpiDmAddressFlags (Resource); AcpiOsPrintf (")\n"); } @@ -826,13 +839,16 @@ AcpiDmMemory24Descriptor ( AcpiDmIndent (Level); AcpiOsPrintf ("Memory24 (%s,\n", - AcpiGbl_RWDecode [Resource->Memory24.Flags & 1]); + AcpiGbl_RwDecode [Resource->Memory24.Flags & 1]); /* Dump the 4 contiguous WORD values */ AcpiDmMemoryFields (&Resource->Memory24.Minimum, 16, Level); + /* Insert a descriptor name */ + AcpiDmIndent (Level + 1); + AcpiDmDescriptorName (); AcpiOsPrintf (")\n"); } @@ -862,13 +878,16 @@ AcpiDmMemory32Descriptor ( AcpiDmIndent (Level); AcpiOsPrintf ("Memory32 (%s,\n", - AcpiGbl_RWDecode [Resource->Memory32.Flags & 1]); + AcpiGbl_RwDecode [Resource->Memory32.Flags & 1]); /* Dump the 4 contiguous DWORD values */ AcpiDmMemoryFields (&Resource->Memory32.Minimum, 32, Level); + /* Insert a descriptor name */ + AcpiDmIndent (Level + 1); + AcpiDmDescriptorName (); AcpiOsPrintf (")\n"); } @@ -898,7 +917,7 @@ AcpiDmFixedMemory32Descriptor ( AcpiDmIndent (Level); AcpiOsPrintf ("Memory32Fixed (%s,\n", - AcpiGbl_RWDecode [Resource->FixedMemory32.Flags & 1]); + AcpiGbl_RwDecode [Resource->FixedMemory32.Flags & 1]); AcpiDmIndent (Level + 1); AcpiDmDumpInteger32 (Resource->FixedMemory32.Address, "Address Base"); @@ -906,7 +925,10 @@ AcpiDmFixedMemory32Descriptor ( AcpiDmIndent (Level + 1); AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength, "Address Length"); + /* Insert a descriptor name */ + AcpiDmIndent (Level + 1); + AcpiDmDescriptorName (); AcpiOsPrintf (")\n"); } @@ -938,24 +960,31 @@ AcpiDmGenericRegisterDescriptor ( AcpiOsPrintf ("\n"); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger8 (Resource->GenericReg.BitWidth, "Register Bit Width"); + AcpiDmDumpInteger8 (Resource->GenericReg.BitWidth, "Bit Width"); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Register Bit Offset"); + AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Bit Offset"); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Register Address"); + AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address"); /* Optional field for ACPI 3.0 */ + AcpiDmIndent (Level + 1); if (Resource->GenericReg.AccessSize) { - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%2.2X // %s\n", + AcpiOsPrintf ("0x%2.2X, // %s\n", Resource->GenericReg.AccessSize, "Access Size"); + AcpiDmIndent (Level + 1); + } + else + { + AcpiOsPrintf (","); } - AcpiDmIndent (Level + 1); + /* DescriptorName was added for ACPI 3.0+ */ + + AcpiDmDescriptorName (); AcpiOsPrintf (")\n"); } @@ -986,9 +1015,9 @@ AcpiDmInterruptDescriptor ( AcpiDmIndent (Level); AcpiOsPrintf ("Interrupt (%s, %s, %s, %s, ", AcpiGbl_ConsumeDecode [(Resource->ExtendedIrq.Flags & 1)], - AcpiGbl_HEDecode [(Resource->ExtendedIrq.Flags >> 1) & 1], - AcpiGbl_LLDecode [(Resource->ExtendedIrq.Flags >> 2) & 1], - AcpiGbl_SHRDecode [(Resource->ExtendedIrq.Flags >> 3) & 1]); + AcpiGbl_HeDecode [(Resource->ExtendedIrq.Flags >> 1) & 1], + AcpiGbl_LlDecode [(Resource->ExtendedIrq.Flags >> 2) & 1], + AcpiGbl_ShrDecode [(Resource->ExtendedIrq.Flags >> 3) & 1]); /* * The ResourceSource fields are optional and appear after the interrupt @@ -1000,9 +1029,13 @@ AcpiDmInterruptDescriptor ( (Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32), Resource->ExtendedIrq.ResourceLength); - /* Dump the interrupt list */ + /* Insert a descriptor name */ + AcpiDmDescriptorName (); AcpiOsPrintf (")\n"); + + /* Dump the interrupt list */ + AcpiDmIndent (Level); AcpiOsPrintf ("{\n"); for (i = 0; i < Resource->ExtendedIrq.InterruptCount; i++) @@ -1040,10 +1073,15 @@ AcpiDmVendorCommon ( UINT32 Level) { - /* Dump descriptor name */ + /* Dump macro name */ AcpiDmIndent (Level); - AcpiOsPrintf ("Vendor%s // Length = 0x%.2X\n", Name, Length); + AcpiOsPrintf ("Vendor%s (", Name); + + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); + AcpiOsPrintf (") // Length = 0x%.2X\n", Length); /* Dump the vendor bytes */ @@ -1078,7 +1116,7 @@ AcpiDmVendorLargeDescriptor ( UINT32 Level) { - AcpiDmVendorCommon ("Long () ", + AcpiDmVendorCommon ("Long ", ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_LARGE_HEADER)), Length, Level); } diff --git a/sys/dist/acpica/dmresrcs.c b/sys/dist/acpica/dmresrcs.c index dd051353783..eae88076262 100644 --- a/sys/dist/acpica/dmresrcs.c +++ b/sys/dist/acpica/dmresrcs.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmresrcs.c - "Small" Resource Descriptor disassembly - * xRevision: 1.12 $ + * $Revision: 1.4 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,11 +115,8 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmresrcs.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdisasm.h> #ifdef ACPI_DISASSEMBLER @@ -157,11 +154,15 @@ AcpiDmIrqDescriptor ( if (Length & 1) { - AcpiOsPrintf ("%s, %s, %s", - AcpiGbl_HEDecode [Resource->Irq.Flags & 1], - AcpiGbl_LLDecode [(Resource->Irq.Flags >> 3) & 1], - AcpiGbl_SHRDecode [(Resource->Irq.Flags >> 4) & 1]); + AcpiOsPrintf ("%s, %s, %s, ", + AcpiGbl_HeDecode [Resource->Irq.Flags & 1], + AcpiGbl_LlDecode [(Resource->Irq.Flags >> 3) & 1], + AcpiGbl_ShrDecode [(Resource->Irq.Flags >> 4) & 1]); } + + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); AcpiOsPrintf (")\n"); AcpiDmIndent (Level + 1); @@ -191,10 +192,15 @@ AcpiDmDmaDescriptor ( { AcpiDmIndent (Level); - AcpiOsPrintf ("DMA (%s, %s, %s)\n", - AcpiGbl_TYPDecode [(Resource->Dma.Flags >> 5) & 3], - AcpiGbl_BMDecode [(Resource->Dma.Flags >> 2) & 1], - AcpiGbl_SIZDecode [(Resource->Dma.Flags >> 0) & 3]); + AcpiOsPrintf ("DMA (%s, %s, %s, ", + AcpiGbl_TypDecode [(Resource->Dma.Flags >> 5) & 3], + AcpiGbl_BmDecode [(Resource->Dma.Flags >> 2) & 1], + AcpiGbl_SizDecode [(Resource->Dma.Flags >> 0) & 3]); + + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); + AcpiOsPrintf (")\n"); AcpiDmIndent (Level + 1); AcpiDmBitList (Resource->Dma.DmaChannelMask); @@ -227,18 +233,21 @@ AcpiDmIoDescriptor ( AcpiGbl_IoDecode [(Resource->Io.Flags & 1)]); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger16 (Resource->Io.Minimum, "Address Range Minimum"); + AcpiDmDumpInteger16 (Resource->Io.Minimum, "Range Minimum"); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger16 (Resource->Io.Maximum, "Address Range Maximum"); + AcpiDmDumpInteger16 (Resource->Io.Maximum, "Range Maximum"); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger8 (Resource->Io.Alignment, "Address Alignment"); + AcpiDmDumpInteger8 (Resource->Io.Alignment, "Alignment"); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger8 (Resource->Io.AddressLength, "Address Length"); + AcpiDmDumpInteger8 (Resource->Io.AddressLength, "Length"); + + /* Insert a descriptor name */ AcpiDmIndent (Level + 1); + AcpiDmDescriptorName (); AcpiOsPrintf (")\n"); } @@ -268,12 +277,15 @@ AcpiDmFixedIoDescriptor ( AcpiOsPrintf ("FixedIO (\n"); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address Base"); + AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address"); AcpiDmIndent (Level + 1); - AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Address Length"); + AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Length"); + + /* Insert a descriptor name */ AcpiDmIndent (Level + 1); + AcpiDmDescriptorName (); AcpiOsPrintf (")\n"); } @@ -366,7 +378,7 @@ AcpiDmVendorSmallDescriptor ( UINT32 Level) { - AcpiDmVendorCommon ("Short ()", + AcpiDmVendorCommon ("Short", ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_SMALL_HEADER)), Length, Level); } diff --git a/sys/dist/acpica/dmutils.c b/sys/dist/acpica/dmutils.c index ae5e83f0a0d..13476425fcb 100644 --- a/sys/dist/acpica/dmutils.c +++ b/sys/dist/acpica/dmutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmutils - AML disassembler utilities - * xRevision: 1.21 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,15 +115,12 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmutils.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "amlcode.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdisasm.h> #ifdef ACPI_ASL_COMPILER -#include <acnamesp.h> +#include <dist/acpica/acnamesp.h> #endif #ifdef ACPI_DISASSEMBLER @@ -137,7 +134,7 @@ ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList = NULL; /* Data used in keeping track of fields */ #if 0 -const char *AcpiGbl_FENames[ACPI_NUM_FIELD_NAMES] = +const char *AcpiGbl_FENames[] = { "skip", "?access?" @@ -146,7 +143,7 @@ const char *AcpiGbl_FENames[ACPI_NUM_FIELD_NAMES] = /* Operators for Match() */ -const char *AcpiGbl_MatchOps[ACPI_NUM_MATCH_OPS] = +const char *AcpiGbl_MatchOps[] = { "MTR", "MEQ", @@ -158,7 +155,7 @@ const char *AcpiGbl_MatchOps[ACPI_NUM_MATCH_OPS] = /* Access type decoding */ -const char *AcpiGbl_AccessTypes[ACPI_NUM_ACCESS_TYPES] = +const char *AcpiGbl_AccessTypes[] = { "AnyAcc", "ByteAcc", @@ -166,11 +163,13 @@ const char *AcpiGbl_AccessTypes[ACPI_NUM_ACCESS_TYPES] = "DWordAcc", "QWordAcc", "BufferAcc", + "InvalidAccType", + "InvalidAccType" }; /* Lock rule decoding */ -const char *AcpiGbl_LockRule[ACPI_NUM_LOCK_RULES] = +const char *AcpiGbl_LockRule[] = { "NoLock", "Lock" @@ -178,24 +177,25 @@ const char *AcpiGbl_LockRule[ACPI_NUM_LOCK_RULES] = /* Update rule decoding */ -const char *AcpiGbl_UpdateRules[ACPI_NUM_UPDATE_RULES] = +const char *AcpiGbl_UpdateRules[] = { "Preserve", "WriteAsOnes", - "WriteAsZeros" + "WriteAsZeros", + "InvalidUpdateRule" }; /* Strings used to decode resource descriptors */ -const char *AcpiGbl_WordDecode[4] = +const char *AcpiGbl_WordDecode[] = { "Memory", "IO", "BusNumber", - "Unknown-resource-type" + "UnknownResourceType" }; -const char *AcpiGbl_IrqDecode[2] = +const char *AcpiGbl_IrqDecode[] = { "IRQNoFlags", "IRQ" @@ -219,10 +219,14 @@ const char *AcpiGbl_IrqDecode[2] = void AcpiDmAddToExternalList ( - char *Path) + char *Path, + UINT8 Type, + UINT32 Value) { char *ExternalPath; ACPI_EXTERNAL_LIST *NewExternal; + ACPI_EXTERNAL_LIST *NextExternal; + ACPI_EXTERNAL_LIST *PrevExternal = NULL; ACPI_STATUS Status; @@ -235,24 +239,84 @@ AcpiDmAddToExternalList ( Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path, NULL, &ExternalPath); - if (ACPI_SUCCESS (Status)) + if (ACPI_FAILURE (Status)) { - /* Allocate and init a new External() descriptor */ + return; + } - NewExternal = ACPI_MEM_CALLOCATE (sizeof (ACPI_EXTERNAL_LIST)); - NewExternal->Path = ExternalPath; + /* Ensure that we don't have duplicate externals */ - /* Link the new descriptor into the global list */ + NextExternal = AcpiGbl_ExternalList; + while (NextExternal) + { + /* Allow upgrade of type from ANY */ - if (AcpiGbl_ExternalList) + if (!ACPI_STRCMP (ExternalPath, NextExternal->Path)) { - NewExternal->Next = AcpiGbl_ExternalList; + /* Duplicate method, check that the Value (ArgCount) is the same */ + + if ((NextExternal->Type == ACPI_TYPE_METHOD) && + (NextExternal->Value != Value)) + { + ACPI_ERROR ((AE_INFO, "Argument count mismatch for method %s %d %d", + NextExternal->Path, NextExternal->Value, Value)); + } + if (NextExternal->Type == ACPI_TYPE_ANY) + { + NextExternal->Type = Type; + NextExternal->Value = Value; + } + ACPI_FREE (ExternalPath); + return; } + NextExternal = NextExternal->Next; + } + + /* Allocate and init a new External() descriptor */ + + NewExternal = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_LIST)); + NewExternal->InternalPath = Path; + NewExternal->Path = ExternalPath; + NewExternal->Type = Type; + NewExternal->Value = Value; + NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath); + + /* Link the new descriptor into the global list, ordered by string length */ + + NextExternal = AcpiGbl_ExternalList; + while (NextExternal) + { + if (NewExternal->Length <= NextExternal->Length) + { + if (PrevExternal) + { + PrevExternal->Next = NewExternal; + } + else + { + AcpiGbl_ExternalList = NewExternal; + } + + NewExternal->Next = NextExternal; + return; + } + + PrevExternal = NextExternal; + NextExternal = NextExternal->Next; + } + + if (PrevExternal) + { + PrevExternal->Next = NewExternal; + } + else + { AcpiGbl_ExternalList = NewExternal; } } #endif + /******************************************************************************* * * FUNCTION: AcpiDmDecodeAttribute diff --git a/sys/dist/acpica/dmwalk.c b/sys/dist/acpica/dmwalk.c index 389ee28b6ed..2dd72b83596 100644 --- a/sys/dist/acpica/dmwalk.c +++ b/sys/dist/acpica/dmwalk.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmwalk - AML disassembly tree walk - * xRevision: 1.27 $ + * $Revision: 1.4 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmwalk.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acdisasm.h" -#include "acdebug.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdisasm.h> +#include <dist/acpica/acdebug.h> #ifdef ACPI_DISASSEMBLER @@ -147,13 +144,6 @@ AcpiDmAscendingOp ( UINT32 Level, void *Context); -static void -AcpiDmWalkParseTree ( - ACPI_PARSE_OBJECT *Op, - ASL_WALK_CALLBACK DescendingCallback, - ASL_WALK_CALLBACK AscendingCallback, - void *Context); - static UINT32 AcpiDmBlockType ( ACPI_PARSE_OBJECT *Op); @@ -191,6 +181,7 @@ AcpiDmDisassemble ( Info.Flags = 0; Info.Level = 0; + Info.Count = 0; Info.WalkState = WalkState; AcpiDmWalkParseTree (Op, AcpiDmDescendingOp, AcpiDmAscendingOp, &Info); return; @@ -212,7 +203,7 @@ AcpiDmDisassemble ( * ******************************************************************************/ -static void +void AcpiDmWalkParseTree ( ACPI_PARSE_OBJECT *Op, ASL_WALK_CALLBACK DescendingCallback, @@ -233,10 +224,13 @@ AcpiDmWalkParseTree ( { if (NodePreviouslyVisited) { - Status = AscendingCallback (Op, Info->Level, Context); - if (ACPI_FAILURE (Status)) + if (AscendingCallback) { - return; + Status = AscendingCallback (Op, Info->Level, Context); + if (ACPI_FAILURE (Status)) + { + return; + } } } else @@ -499,21 +493,47 @@ AcpiDmDescendingOp ( if (AcpiGbl_ExternalList) { - AcpiOsPrintf ( - " /*\n * These objects were referenced but not defined in this table\n */\n"); - /* * Walk the list of externals (unresolved references) * found during parsing */ while (AcpiGbl_ExternalList) { - AcpiOsPrintf (" External (%s, DeviceObj)\n", + AcpiOsPrintf (" External (%s", AcpiGbl_ExternalList->Path); + /* TBD: should be a lookup table */ + + switch (AcpiGbl_ExternalList->Type) + { + case ACPI_TYPE_DEVICE: + AcpiOsPrintf (", DeviceObj"); + break; + + case ACPI_TYPE_METHOD: + AcpiOsPrintf (", MethodObj"); + break; + + case ACPI_TYPE_INTEGER: + AcpiOsPrintf (", IntObj"); + break; + + default: + break; + } + + if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) + { + AcpiOsPrintf (") // %d Arguments\n", AcpiGbl_ExternalList->Value); + } + else + { + AcpiOsPrintf (")\n"); + } + NextExternal = AcpiGbl_ExternalList->Next; - ACPI_MEM_FREE (AcpiGbl_ExternalList->Path); - ACPI_MEM_FREE (AcpiGbl_ExternalList); + ACPI_FREE (AcpiGbl_ExternalList->Path); + ACPI_FREE (AcpiGbl_ExternalList); AcpiGbl_ExternalList = NextExternal; } AcpiOsPrintf ("\n"); @@ -531,12 +551,33 @@ AcpiDmDescendingOp ( * indent a new line */ AcpiDmIndent (Level); + Info->LastLevel = Level; + Info->Count = 0; + } + + /* + * This is an inexpensive mechanism to try and keep lines from getting + * too long. When the limit is hit, start a new line at the previous + * indent plus one. A better but more expensive mechanism would be to + * keep track of the current column. + */ + Info->Count++; + if (Info->Count /*+Info->LastLevel*/ > 10) + { + Info->Count = 0; + AcpiOsPrintf ("\n"); + AcpiDmIndent (Info->LastLevel + 1); } /* Print the opcode name */ AcpiDmDisassembleOneOp (NULL, Info, Op); + if (Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX) + { + return (AE_OK); + } + if ((Op->Common.AmlOpcode == AML_NAME_OP) || (Op->Common.AmlOpcode == AML_RETURN_OP)) { @@ -648,6 +689,7 @@ AcpiDmDescendingOp ( case AML_MUTEX_OP: + case AML_DATA_REGION_OP: AcpiOsPrintf (", "); return (AE_OK); @@ -704,7 +746,7 @@ AcpiDmDescendingOp ( * Bank Value. This is a TermArg in the middle of the parameter * list, must handle it here. * - * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMLIST + * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMLIST * eliminates newline in the output. */ NextOp = NextOp->Common.Next; diff --git a/sys/dist/acpica/dsfield.c b/sys/dist/acpica/dsfield.c index a0409ba6270..b3a6be8201b 100644 --- a/sys/dist/acpica/dsfield.c +++ b/sys/dist/acpica/dsfield.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsfield - Dispatcher field routines - * xRevision: 1.81 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,17 +114,14 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsfield.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __DSFIELD_C__ -#include "acpi.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acparser.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acparser.h> #define _COMPONENT ACPI_DISPATCHER @@ -171,7 +168,7 @@ AcpiDsCreateBufferField ( UINT32 Flags; - ACPI_FUNCTION_TRACE ("DsCreateBufferField"); + ACPI_FUNCTION_TRACE (DsCreateBufferField); /* Get the NameString argument */ @@ -227,7 +224,8 @@ AcpiDsCreateBufferField ( } } - /* We could put the returned object (Node) on the object stack for later, + /* + * We could put the returned object (Node) on the object stack for later, * but for now, we will put it in the "op" object that the parser uses, * so we can get it again at the end of this scope */ @@ -311,7 +309,7 @@ AcpiDsGetFieldNames ( ACPI_INTEGER Position; - ACPI_FUNCTION_TRACE_PTR ("DsGetFieldNames", Info); + ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info); /* First field starts at bit zero */ @@ -454,7 +452,7 @@ AcpiDsCreateField ( ACPI_CREATE_FIELD_INFO Info; - ACPI_FUNCTION_TRACE_PTR ("DsCreateField", Op); + ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op); /* First arg is the name of the parent OpRegion (must already exist) */ @@ -515,7 +513,7 @@ AcpiDsInitFieldObjects ( UINT8 Type = 0; - ACPI_FUNCTION_TRACE_PTR ("DsInitFieldObjects", Op); + ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op); switch (WalkState->Opcode) @@ -604,7 +602,7 @@ AcpiDsCreateBankField ( ACPI_CREATE_FIELD_INFO Info; - ACPI_FUNCTION_TRACE_PTR ("DsCreateBankField", Op); + ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op); /* First arg is the name of the parent OpRegion (must already exist) */ @@ -636,8 +634,33 @@ AcpiDsCreateBankField ( /* Third arg is the BankValue */ + /* TBD: This arg is a TermArg, not a constant, and must be evaluated */ + Arg = Arg->Common.Next; - Info.BankValue = (UINT32) Arg->Common.Value.Integer; + + /* Currently, only the following constants are supported */ + + switch (Arg->Common.AmlOpcode) + { + case AML_ZERO_OP: + Info.BankValue = 0; + break; + + case AML_ONE_OP: + Info.BankValue = 1; + break; + + case AML_BYTE_OP: + case AML_WORD_OP: + case AML_DWORD_OP: + case AML_QWORD_OP: + Info.BankValue = (UINT32) Arg->Common.Value.Integer; + break; + + default: + Info.BankValue = 0; + ACPI_ERROR ((AE_INFO, "Non-constant BankValue for BankField is not implemented")); + } /* Fourth arg is the field flags */ @@ -680,7 +703,7 @@ AcpiDsCreateIndexField ( ACPI_CREATE_FIELD_INFO Info; - ACPI_FUNCTION_TRACE_PTR ("DsCreateIndexField", Op); + ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op); /* First arg is the name of the Index register (must already exist) */ diff --git a/sys/dist/acpica/dsinit.c b/sys/dist/acpica/dsinit.c index 3c87729df3b..38919b70708 100644 --- a/sys/dist/acpica/dsinit.c +++ b/sys/dist/acpica/dsinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsinit - Object initialization namespace walk - * xRevision: 1.22 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,14 +114,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsinit.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __DSINIT_C__ -#include "acpi.h" -#include "acdispat.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsinit") @@ -176,7 +174,7 @@ AcpiDsInitOneObject ( * We are only interested in NS nodes owned by the table that * was just loaded */ - if (Node->OwnerId != Info->TableDesc->OwnerId) + if (Node->OwnerId != Info->OwnerId) { return (AE_OK); } @@ -205,49 +203,6 @@ AcpiDsInitOneObject ( case ACPI_TYPE_METHOD: - /* - * Set the execution data width (32 or 64) based upon the - * revision number of the parent ACPI table. - * TBD: This is really for possible future support of integer width - * on a per-table basis. Currently, we just use a global for the width. - */ - if (Info->TableDesc->Pointer->Revision == 1) - { - Node->Flags |= ANOBJ_DATA_WIDTH_32; - } - -#ifdef ACPI_INIT_PARSE_METHODS - /* - * Note 11/2005: Removed this code to parse all methods during table - * load because it causes problems if there are any errors during the - * parse. Also, it seems like overkill and we probably don't want to - * abort a table load because of an issue with a single method. - */ - - /* - * Print a dot for each method unless we are going to print - * the entire pathname - */ - if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); - } - - /* - * Always parse methods to detect errors, we will delete - * the parse tree below - */ - Status = AcpiDsParseMethod (ObjHandle); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Method %p [%4.4s] - parse failure, %s", - ObjHandle, AcpiUtGetNodeName (ObjHandle), - AcpiFormatException (Status))); - - /* This parse failed, but we will continue parsing more methods */ - } -#endif Info->MethodCount++; break; @@ -286,15 +241,23 @@ AcpiDsInitOneObject ( ACPI_STATUS AcpiDsInitializeObjects ( - ACPI_TABLE_DESC *TableDesc, + ACPI_NATIVE_UINT TableIndex, ACPI_NAMESPACE_NODE *StartNode) { ACPI_STATUS Status; ACPI_INIT_WALK_INFO Info; + ACPI_TABLE_HEADER *Table; + ACPI_OWNER_ID OwnerId; + + ACPI_FUNCTION_TRACE (DsInitializeObjects); - ACPI_FUNCTION_TRACE ("DsInitializeObjects"); + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); @@ -304,7 +267,8 @@ AcpiDsInitializeObjects ( Info.OpRegionCount = 0; Info.ObjectCount = 0; Info.DeviceCount = 0; - Info.TableDesc = TableDesc; + Info.TableIndex = TableIndex; + Info.OwnerId = OwnerId; /* Walk entire namespace from the supplied root */ @@ -315,9 +279,15 @@ AcpiDsInitializeObjects ( ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); } + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", - TableDesc->Pointer->Signature, TableDesc->OwnerId, Info.ObjectCount, + Table->Signature, OwnerId, Info.ObjectCount, Info.DeviceCount, Info.MethodCount, Info.OpRegionCount)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, diff --git a/sys/dist/acpica/dsmethod.c b/sys/dist/acpica/dsmethod.c index 282bac57fbe..32e8f3f8e24 100644 --- a/sys/dist/acpica/dsmethod.c +++ b/sys/dist/acpica/dsmethod.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsmethod - Parser/Interpreter interface - control method parsing - * xRevision: 1.116 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,23 +114,26 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsmethod.c,v 1.3 2006/04/13 07:31:29 kochi Exp $"); - #define __DSMETHOD_C__ -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdisasm.h> #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsmethod") +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsCreateMethodMutex ( + ACPI_OPERAND_OBJECT *MethodDesc); + /******************************************************************************* * @@ -198,11 +201,57 @@ AcpiDsMethodError ( /******************************************************************************* * + * FUNCTION: AcpiDsCreateMethodMutex + * + * PARAMETERS: ObjDesc - The method object + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object for a serialized control method + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsCreateMethodMutex ( + ACPI_OPERAND_OBJECT *MethodDesc) +{ + ACPI_OPERAND_OBJECT *MutexDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DsCreateMethodMutex); + + + /* Create the new mutex object */ + + MutexDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); + if (!MutexDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Create the actual OS Mutex */ + + Status = AcpiOsCreateMutex (&MutexDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + MutexDesc->Mutex.SyncLevel = MethodDesc->Method.SyncLevel; + MethodDesc->Method.Mutex = MutexDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDsBeginMethodExecution * * PARAMETERS: MethodNode - Node of the method * ObjDesc - The method object - * CallingMethodNode - Caller of this method (if non-null) + * WalkState - current state, NULL if not yet executing + * a method. * * RETURN: Status * @@ -216,12 +265,12 @@ ACPI_STATUS AcpiDsBeginMethodExecution ( ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_NAMESPACE_NODE *CallingMethodNode) + ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_PTR ("DsBeginMethodExecution", MethodNode); + ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode); if (!MethodNode) @@ -239,33 +288,81 @@ AcpiDsBeginMethodExecution ( } /* - * If there is a concurrency limit on this method, we need to - * obtain a unit from the method semaphore. + * If this method is serialized, we need to acquire the method mutex. */ - if (ObjDesc->Method.Semaphore) + if (ObjDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) { /* - * Allow recursive method calls, up to the reentrancy/concurrency - * limit imposed by the SERIALIZED rule and the SyncLevel method - * parameter. - * - * The point of this code is to avoid permanently blocking a - * thread that is making recursive method calls. + * Create a mutex for the method if it is defined to be Serialized + * and a mutex has not already been created. We defer the mutex creation + * until a method is actually executed, to minimize the object count */ - if (MethodNode == CallingMethodNode) + if (!ObjDesc->Method.Mutex) { - if (ObjDesc->Method.ThreadCount >= ObjDesc->Method.Concurrency) + Status = AcpiDsCreateMethodMutex (ObjDesc); + if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (AE_AML_METHOD_LIMIT); + return_ACPI_STATUS (Status); } } /* - * Get a unit from the method semaphore. This releases the - * interpreter if we block + * The CurrentSyncLevel (per-thread) must be less than or equal to + * the sync level of the method. This mechanism provides some + * deadlock prevention + * + * Top-level method invocation has no walk state at this point */ - Status = AcpiExSystemWaitSemaphore (ObjDesc->Method.Semaphore, - ACPI_WAIT_FOREVER); + if (WalkState && + (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel)) + { + ACPI_ERROR ((AE_INFO, + "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)", + AcpiUtGetNodeName (MethodNode), + WalkState->Thread->CurrentSyncLevel)); + + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + /* + * Obtain the method mutex if necessary. Do not acquire mutex for a + * recursive call. + */ + if (!WalkState || + !ObjDesc->Method.Mutex->Mutex.ThreadId || + (WalkState->Thread->ThreadId != ObjDesc->Method.Mutex->Mutex.ThreadId)) + { + /* + * Acquire the method mutex. This releases the interpreter if we + * block (and reacquires it before it returns) + */ + Status = AcpiExSystemWaitMutex (ObjDesc->Method.Mutex->Mutex.OsMutex, + ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Update the mutex and walk info and save the original SyncLevel */ + + if (WalkState) + { + ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = + WalkState->Thread->CurrentSyncLevel; + + ObjDesc->Method.Mutex->Mutex.ThreadId = WalkState->Thread->ThreadId; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Method.SyncLevel; + } + else + { + ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = + ObjDesc->Method.Mutex->Mutex.SyncLevel; + } + } + + /* Always increase acquisition depth */ + + ObjDesc->Method.Mutex->Mutex.AcquisitionDepth++; } /* @@ -278,7 +375,7 @@ AcpiDsBeginMethodExecution ( Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Cleanup; } } @@ -288,6 +385,16 @@ AcpiDsBeginMethodExecution ( */ ObjDesc->Method.ThreadCount++; return_ACPI_STATUS (Status); + + +Cleanup: + /* On error, must release the method mutex (if present) */ + + if (ObjDesc->Method.Mutex) + { + AcpiOsReleaseMutex (ObjDesc->Method.Mutex->Mutex.OsMutex); + } + return_ACPI_STATUS (Status); } @@ -315,13 +422,13 @@ AcpiDsCallControlMethod ( ACPI_NAMESPACE_NODE *MethodNode; ACPI_WALK_STATE *NextWalkState = NULL; ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_PARAMETER_INFO Info; + ACPI_EVALUATE_INFO *Info; UINT32 i; - ACPI_FUNCTION_TRACE_PTR ("DsCallControlMethod", ThisWalkState); + ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Calling method %p, currentstate=%p\n", ThisWalkState->PrevOp, ThisWalkState)); /* @@ -339,57 +446,25 @@ AcpiDsCallControlMethod ( return_ACPI_STATUS (AE_NULL_OBJECT); } - /* Init for new method, wait on concurrency semaphore */ + /* Init for new method, possibly wait on method mutex */ Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, - ThisWalkState->MethodNode); + ThisWalkState); if (ACPI_FAILURE (Status)) { - goto Cleanup; - } - - if (!(ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY)) - { - /* 1) Parse: Create a new walk state for the preempting walk */ - - NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId, - Op, ObjDesc, NULL); - if (!NextWalkState) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Create and init a Root Node */ - - Op = AcpiPsCreateScopeOp (); - if (!Op) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - Status = AcpiDsInitAmlWalk (NextWalkState, Op, MethodNode, - ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, - NULL, 1); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Begin AML parse */ - - Status = AcpiPsParseAml (NextWalkState); - AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); } - /* 2) Execute: Create a new state for the preempting walk */ + /* Begin method parse/execution. Create a new walk state */ NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId, - NULL, ObjDesc, Thread); + NULL, ObjDesc, Thread); if (!NextWalkState) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup; } + /* * The resolved arguments were put on the previous walk state's operand * stack. Operands on the previous walk state stack always @@ -397,12 +472,25 @@ AcpiDsCallControlMethod ( */ ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL; - Info.Parameters = &ThisWalkState->Operands[0]; - Info.ParameterType = ACPI_PARAM_ARGS; + /* + * Allocate and initialize the evaluation information block + * TBD: this is somewhat inefficient, should change interface to + * DsInitAmlWalk. For now, keeps this struct off the CPU stack + */ + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Parameters = &ThisWalkState->Operands[0]; + Info->ParameterType = ACPI_PARAM_ARGS; Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode, - ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, - &Info, 3); + ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, + Info, ACPI_IMODE_EXECUTE); + + ACPI_FREE (Info); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -423,7 +511,10 @@ AcpiDsCallControlMethod ( ThisWalkState->NumOperands = 0; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Starting nested execution, newstate=%p\n", NextWalkState)); + "**** Begin nested execution of [%4.4s] **** WalkState=%p\n", + MethodNode->Name.Ascii, NextWalkState)); + + /* Invoke an internal method if necessary */ if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) { @@ -434,17 +525,15 @@ AcpiDsCallControlMethod ( Cleanup: - /* Decrement the thread count on the method parse tree */ - if (NextWalkState && (NextWalkState->MethodDesc)) + /* On error, we must terminate the method properly */ + + AcpiDsTerminateControlMethod (ObjDesc, NextWalkState); + if (NextWalkState) { - NextWalkState->MethodDesc->Method.ThreadCount--; + AcpiDsDeleteWalkState (NextWalkState); } - /* On error, we must delete the new walk state */ - - AcpiDsTerminateControlMethod (NextWalkState); - AcpiDsDeleteWalkState (NextWalkState); return_ACPI_STATUS (Status); } @@ -469,15 +558,16 @@ AcpiDsRestartControlMethod ( ACPI_OPERAND_OBJECT *ReturnDesc) { ACPI_STATUS Status; + int SameAsImplicitReturn; - ACPI_FUNCTION_TRACE_PTR ("DsRestartControlMethod", WalkState); + ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n", - (char *) &WalkState->MethodNode->Name, WalkState->MethodCallOp, - ReturnDesc)); + AcpiUtGetNodeName (WalkState->MethodNode), + WalkState->MethodCallOp, ReturnDesc)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n", @@ -488,6 +578,10 @@ AcpiDsRestartControlMethod ( if (ReturnDesc) { + /* Is the implicit return object the same as the return desc? */ + + SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc); + /* Are we actually going to use the return value? */ if (WalkState->ReturnUsed) @@ -509,18 +603,23 @@ AcpiDsRestartControlMethod ( } /* - * The following code is the - * optional support for a so-called "implicit return". Some AML code - * assumes that the last value of the method is "implicitly" returned - * to the caller. Just save the last result as the return value. + * The following code is the optional support for the so-called + * "implicit return". Some AML code assumes that the last value of the + * method is "implicitly" returned to the caller, in the absence of an + * explicit return value. + * + * Just save the last result of the method as the return value. + * * NOTE: this is optional because the ASL language does not actually * support this behavior. */ - else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE)) + else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) || + SameAsImplicitReturn) { /* * Delete the return value if it will not be used by the - * calling method + * calling method or remove one reference if the explicit return + * is the same as the implicit return value. */ AcpiUtRemoveReference (ReturnDesc); } @@ -534,7 +633,8 @@ AcpiDsRestartControlMethod ( * * FUNCTION: AcpiDsTerminateControlMethod * - * PARAMETERS: WalkState - State of the method + * PARAMETERS: MethodDesc - Method object + * WalkState - State associated with the method * * RETURN: None * @@ -542,97 +642,78 @@ AcpiDsRestartControlMethod ( * created, delete all locals and arguments, and delete the parse * tree if requested. * + * MUTEX: Interpreter is locked + * ******************************************************************************/ void AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, ACPI_WALK_STATE *WalkState) { - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *MethodNode; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("DsTerminateControlMethod", WalkState); + ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState); - if (!WalkState) - { - return_VOID; - } + /* MethodDesc is required, WalkState is optional */ - /* The current method object was saved in the walk state */ - - ObjDesc = WalkState->MethodDesc; - if (!ObjDesc) + if (!MethodDesc) { return_VOID; } - /* Delete all arguments and locals */ + if (WalkState) + { + /* Delete all arguments and locals */ - AcpiDsMethodDataDeleteAll (WalkState); + AcpiDsMethodDataDeleteAll (WalkState); + } /* - * Lock the parser while we terminate this method. - * If this is the last thread executing the method, - * we have additional cleanup to perform + * If method is serialized, release the mutex and restore the + * current sync level for this thread */ - Status = AcpiUtAcquireMutex (ACPI_MTX_PARSER); - if (ACPI_FAILURE (Status)) + if (MethodDesc->Method.Mutex) { - return_VOID; - } + /* Acquisition Depth handles recursive calls */ - /* Signal completion of the execution of this method if necessary */ - - if (WalkState->MethodDesc->Method.Semaphore) - { - Status = AcpiOsSignalSemaphore ( - WalkState->MethodDesc->Method.Semaphore, 1); - if (ACPI_FAILURE (Status)) + MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--; + if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth) { - ACPI_ERROR ((AE_INFO, "Could not signal method semaphore")); + WalkState->Thread->CurrentSyncLevel = + MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; - /* Ignore error and continue cleanup */ + AcpiOsReleaseMutex (MethodDesc->Method.Mutex->Mutex.OsMutex); + MethodDesc->Method.Mutex->Mutex.ThreadId = 0; } } - /* - * There are no more threads executing this method. Perform - * additional cleanup. - * - * The method Node is stored in the walk state - */ - MethodNode = WalkState->MethodNode; + if (WalkState) + { + /* + * Delete any namespace objects created anywhere within + * the namespace by the execution of this method + */ + AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); + } - /* Lock namespace for possible update */ + /* Decrement the thread count on the method */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) + if (MethodDesc->Method.ThreadCount) { - goto Exit; + MethodDesc->Method.ThreadCount--; } - - /* - * Delete any namespace entries created immediately underneath - * the method - */ - if (MethodNode->Child) + else { - AcpiNsDeleteNamespaceSubtree (MethodNode); + ACPI_ERROR ((AE_INFO, + "Invalid zero thread count in method")); } - /* - * Delete any namespace entries created anywhere else within - * the namespace by the execution of this method - */ - AcpiNsDeleteNamespaceByOwner (WalkState->MethodDesc->Method.OwnerId); - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - /* Are there any other threads currently executing this method? */ - if (WalkState->MethodDesc->Method.ThreadCount) + if (MethodDesc->Method.ThreadCount) { /* * Additional threads. Do not release the OwnerId in this case, @@ -640,7 +721,7 @@ AcpiDsTerminateControlMethod ( */ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "*** Completed execution of one thread, %d threads remaining\n", - WalkState->MethodDesc->Method.ThreadCount)); + MethodDesc->Method.ThreadCount)); } else { @@ -649,177 +730,25 @@ AcpiDsTerminateControlMethod ( /* * Support to dynamically change a method from NotSerialized to * Serialized if it appears that the method is incorrectly written and - * does not support multiple thread execution. The best example of this - * is if such a method creates namespace objects and blocks. A second + * does not support multiple thread execution. The best example of this + * is if such a method creates namespace objects and blocks. A second * thread will fail with an AE_ALREADY_EXISTS exception * * This code is here because we must wait until the last thread exits * before creating the synchronization semaphore. */ - if ((WalkState->MethodDesc->Method.Concurrency == 1) && - (!WalkState->MethodDesc->Method.Semaphore)) + if ((MethodDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) && + (!MethodDesc->Method.Mutex)) { - Status = AcpiOsCreateSemaphore (1, 1, - &WalkState->MethodDesc->Method.Semaphore); + Status = AcpiDsCreateMethodMutex (MethodDesc); } /* No more threads, we can free the OwnerId */ - AcpiUtReleaseOwnerId (&WalkState->MethodDesc->Method.OwnerId); + AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId); } -Exit: - (void) AcpiUtReleaseMutex (ACPI_MTX_PARSER); return_VOID; } -#ifdef ACPI_INIT_PARSE_METHODS - /* - * Note 11/2005: Removed this code to parse all methods during table - * load because it causes problems if there are any errors during the - * parse. Also, it seems like overkill and we probably don't want to - * abort a table load because of an issue with a single method. - */ - -/******************************************************************************* - * - * FUNCTION: AcpiDsParseMethod - * - * PARAMETERS: Node - Method node - * - * RETURN: Status - * - * DESCRIPTION: Parse the AML that is associated with the method. - * - * MUTEX: Assumes parser is locked - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsParseMethod ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_PARSE_OBJECT *Op; - ACPI_WALK_STATE *WalkState; - - - ACPI_FUNCTION_TRACE_PTR ("DsParseMethod", Node); - - - /* Parameter Validation */ - - if (!Node) - { - return_ACPI_STATUS (AE_NULL_ENTRY); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** NamedObj=%p\n", - AcpiUtGetNodeName (Node), Node)); - - /* Extract the method object from the method Node */ - - ObjDesc = AcpiNsGetAttachedObject (Node); - if (!ObjDesc) - { - return_ACPI_STATUS (AE_NULL_OBJECT); - } - - /* Create a mutex for the method if there is a concurrency limit */ - - if ((ObjDesc->Method.Concurrency != ACPI_INFINITE_CONCURRENCY) && - (!ObjDesc->Method.Semaphore)) - { - Status = AcpiOsCreateSemaphore (ObjDesc->Method.Concurrency, - ObjDesc->Method.Concurrency, - &ObjDesc->Method.Semaphore); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* - * Allocate a new parser op to be the root of the parsed - * method tree - */ - Op = AcpiPsAllocOp (AML_METHOD_OP); - if (!Op) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Init new op with the method name and pointer back to the Node */ - - AcpiPsSetName (Op, Node->Name.Integer); - Op->Common.Node = Node; - - /* - * Get a new OwnerId for objects created by this method. Namespace - * objects (such as Operation Regions) can be created during the - * first pass parse. - */ - Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Create and initialize a new walk state */ - - WalkState = AcpiDsCreateWalkState ( - ObjDesc->Method.OwnerId, NULL, NULL, NULL); - if (!WalkState) - { - Status = AE_NO_MEMORY; - goto Cleanup2; - } - - Status = AcpiDsInitAmlWalk (WalkState, Op, Node, - ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, NULL, 1); - if (ACPI_FAILURE (Status)) - { - AcpiDsDeleteWalkState (WalkState); - goto Cleanup2; - } - - /* - * Parse the method, first pass - * - * The first pass load is where newly declared named objects are added into - * the namespace. Actual evaluation of the named objects (what would be - * called a "second pass") happens during the actual execution of the - * method so that operands to the named objects can take on dynamic - * run-time values. - */ - Status = AcpiPsParseAml (WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup2; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "**** [%4.4s] Parsed **** NamedObj=%p Op=%p\n", - AcpiUtGetNodeName (Node), Node, Op)); - - /* - * Delete the parse tree. We simply re-parse the method for every - * execution since there isn't much overhead (compared to keeping lots - * of parse trees around) - */ - AcpiNsDeleteNamespaceSubtree (Node); - AcpiNsDeleteNamespaceByOwner (ObjDesc->Method.OwnerId); - -Cleanup2: - AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId); - -Cleanup: - AcpiPsDeleteParseTree (Op); - return_ACPI_STATUS (Status); -} -#endif - - diff --git a/sys/dist/acpica/dsmthdat.c b/sys/dist/acpica/dsmthdat.c index f1fadb9bfd8..0d68116f392 100644 --- a/sys/dist/acpica/dsmthdat.c +++ b/sys/dist/acpica/dsmthdat.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dsmthdat - control method arguments and local variables - * xRevision: 1.88 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,16 +114,13 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsmthdat.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __DSMTHDAT_C__ -#include "acpi.h" -#include "acdispat.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_DISPATCHER @@ -167,7 +164,7 @@ AcpiDsMethodDataGetType ( * special data types. * * NOTES: WalkState fields are initialized to zero by the - * ACPI_MEM_CALLOCATE(). + * ACPI_ALLOCATE_ZEROED(). * * A pseudo-Namespace Node is assigned to each argument and local * so that RefOf() can return a pointer to the Node. @@ -181,34 +178,32 @@ AcpiDsMethodDataInit ( UINT32 i; - ACPI_FUNCTION_TRACE ("DsMethodDataInit"); + ACPI_FUNCTION_TRACE (DsMethodDataInit); /* Init the method arguments */ for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { - ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, - NAMEOF_ARG_NTE); + ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE); WalkState->Arguments[i].Name.Integer |= (i << 24); - WalkState->Arguments[i].Descriptor = ACPI_DESC_TYPE_NAMED; - WalkState->Arguments[i].Type = ACPI_TYPE_ANY; - WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | - ANOBJ_METHOD_ARG; + WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED; + WalkState->Arguments[i].Type = ACPI_TYPE_ANY; + WalkState->Arguments[i].Flags = + ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; } /* Init the method locals */ for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) { - ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, - NAMEOF_LOCAL_NTE); + ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE); WalkState->LocalVariables[i].Name.Integer |= (i << 24); - WalkState->LocalVariables[i].Descriptor = ACPI_DESC_TYPE_NAMED; - WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; - WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | - ANOBJ_METHOD_LOCAL; + WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED; + WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; + WalkState->LocalVariables[i].Flags = + ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; } return_VOID; @@ -235,7 +230,7 @@ AcpiDsMethodDataDeleteAll ( UINT32 Index; - ACPI_FUNCTION_TRACE ("DsMethodDataDeleteAll"); + ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll); /* Detach the locals */ @@ -298,7 +293,7 @@ AcpiDsMethodDataInitArgs ( UINT32 Index = 0; - ACPI_FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); + ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params); if (!Params) @@ -355,7 +350,7 @@ AcpiDsMethodDataGetNode ( ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node) { - ACPI_FUNCTION_TRACE ("DsMethodDataGetNode"); + ACPI_FUNCTION_TRACE (DsMethodDataGetNode); /* @@ -429,7 +424,7 @@ AcpiDsMethodDataSetValue ( ACPI_NAMESPACE_NODE *Node; - ACPI_FUNCTION_TRACE ("DsMethodDataSetValue"); + ACPI_FUNCTION_TRACE (DsMethodDataSetValue); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, @@ -488,7 +483,7 @@ AcpiDsMethodDataGetValue ( ACPI_OPERAND_OBJECT *Object; - ACPI_FUNCTION_TRACE ("DsMethodDataGetValue"); + ACPI_FUNCTION_TRACE (DsMethodDataGetValue); /* Validate the object descriptor */ @@ -600,7 +595,7 @@ AcpiDsMethodDataDeleteValue ( ACPI_OPERAND_OBJECT *Object; - ACPI_FUNCTION_TRACE ("DsMethodDataDeleteValue"); + ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue); /* Get the namespace node for the arg/local */ @@ -667,7 +662,7 @@ AcpiDsStoreObjectToLocal ( ACPI_OPERAND_OBJECT *NewObjDesc; - ACPI_FUNCTION_TRACE ("DsStoreObjectToLocal"); + ACPI_FUNCTION_TRACE (DsStoreObjectToLocal); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", Opcode, Index, ObjDesc)); @@ -819,7 +814,7 @@ AcpiDsMethodDataGetType ( ACPI_OPERAND_OBJECT *Object; - ACPI_FUNCTION_TRACE ("DsMethodDataGetType"); + ACPI_FUNCTION_TRACE (DsMethodDataGetType); /* Get the namespace node for the arg/local */ diff --git a/sys/dist/acpica/dsobject.c b/sys/dist/acpica/dsobject.c index 4d4e94ae8d8..cd223b3cad9 100644 --- a/sys/dist/acpica/dsobject.c +++ b/sys/dist/acpica/dsobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines - * xRevision: 1.129 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,17 +114,14 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsobject.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __DSOBJECT_C__ -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acnamesp.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsobject") @@ -164,7 +161,7 @@ AcpiDsBuildInternalObject ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("DsBuildInternalObject"); + ACPI_FUNCTION_TRACE (DsBuildInternalObject); *ObjDescPtr = NULL; @@ -267,7 +264,7 @@ AcpiDsBuildInternalBufferObj ( UINT32 ByteListLength = 0; - ACPI_FUNCTION_TRACE ("DsBuildInternalBufferObj"); + ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj); /* @@ -332,7 +329,7 @@ AcpiDsBuildInternalBufferObj ( } else { - ObjDesc->Buffer.Pointer = ACPI_MEM_CALLOCATE ( + ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED ( ObjDesc->Buffer.Length); if (!ObjDesc->Buffer.Pointer) { @@ -350,7 +347,7 @@ AcpiDsBuildInternalBufferObj ( } ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; - Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); return_ACPI_STATUS (AE_OK); } @@ -361,7 +358,8 @@ AcpiDsBuildInternalBufferObj ( * * PARAMETERS: WalkState - Current walk state * Op - Parser object to be translated - * PackageLength - Number of elements in the package + * ElementCount - Number of elements in the package - this is + * the NumElements argument to Package() * ObjDescPtr - Where the ACPI internal object is returned * * RETURN: Status @@ -369,24 +367,37 @@ AcpiDsBuildInternalBufferObj ( * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * + * NOTE: The number of elements in the package will be always be the NumElements + * count, regardless of the number of elements in the package list. If + * NumElements is smaller, only that many package list elements are used. + * if NumElements is larger, the Package object is padded out with + * objects of type Uninitialized (as per ACPI spec.) + * + * Even though the ASL compilers do not allow NumElements to be smaller + * than the Package list length (for the fixed length package opcode), some + * BIOS code modifies the AML on the fly to adjust the NumElements, and + * this code compensates for that. This also provides compatibility with + * other AML interpreters. + * ******************************************************************************/ ACPI_STATUS AcpiDsBuildInternalPackageObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, - UINT32 PackageLength, + UINT32 ElementCount, ACPI_OPERAND_OBJECT **ObjDescPtr) { ACPI_PARSE_OBJECT *Arg; ACPI_PARSE_OBJECT *Parent; ACPI_OPERAND_OBJECT *ObjDesc = NULL; - UINT32 PackageListLength; ACPI_STATUS Status = AE_OK; ACPI_NATIVE_UINT i; + UINT16 Index; + UINT16 ReferenceCount; - ACPI_FUNCTION_TRACE ("DsBuildInternalPackageObj"); + ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj); /* Find the parent of a possibly nested package */ @@ -415,33 +426,13 @@ AcpiDsBuildInternalPackageObj ( ObjDesc->Package.Node = Parent->Common.Node; } - ObjDesc->Package.Count = PackageLength; - - /* Count the number of items in the package list */ - - Arg = Op->Common.Value.Arg; - Arg = Arg->Common.Next; - for (PackageListLength = 0; Arg; PackageListLength++) - { - Arg = Arg->Common.Next; - } - - /* - * The package length (number of elements) will be the greater - * of the specified length and the length of the initializer list - */ - if (PackageListLength > PackageLength) - { - ObjDesc->Package.Count = PackageListLength; - } - /* - * Allocate the pointer array (array of pointers to the - * individual objects). Add an extra pointer slot so - * that the list is always null terminated. + * Allocate the element array (array of pointers to the individual + * objects) based on the NumElements parameter. Add an extra pointer slot + * so that the list is always null terminated. */ - ObjDesc->Package.Elements = ACPI_MEM_CALLOCATE ( - ((ACPI_SIZE) ObjDesc->Package.Count + 1) * sizeof (void *)); + ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) ElementCount + 1) * sizeof (void *)); if (!ObjDesc->Package.Elements) { @@ -449,16 +440,21 @@ AcpiDsBuildInternalPackageObj ( return_ACPI_STATUS (AE_NO_MEMORY); } + ObjDesc->Package.Count = ElementCount; + /* - * Initialize all elements of the package + * Initialize the elements of the package, up to the NumElements count. + * Package is automatically padded with uninitialized (NULL) elements + * if NumElements is greater than the package list length. Likewise, + * Package is truncated if NumElements is less than the list length. */ Arg = Op->Common.Value.Arg; Arg = Arg->Common.Next; - for (i = 0; Arg; i++) + for (i = 0; Arg && (i < ElementCount); i++) { if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) { - /* Object (package or buffer) is already built */ + /* This package element is already built, just get it */ ObjDesc->Package.Elements[i] = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); @@ -468,11 +464,35 @@ AcpiDsBuildInternalPackageObj ( Status = AcpiDsBuildInternalObject (WalkState, Arg, &ObjDesc->Package.Elements[i]); } + + if (*ObjDescPtr) + { + /* Existing package, get existing reference count */ + + ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount; + if (ReferenceCount > 1) + { + /* Make new element ref count match original ref count */ + + for (Index = 0; Index < (ReferenceCount - 1); Index++) + { + AcpiUtAddReference ((ObjDesc->Package.Elements[i])); + } + } + } + Arg = Arg->Common.Next; } + if (!Arg) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Package List length larger than NumElements count (%X), truncated\n", + ElementCount)); + } + ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; - Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); return_ACPI_STATUS (Status); } @@ -501,7 +521,7 @@ AcpiDsCreateNode ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_TRACE_PTR ("DsCreateNode", Op); + ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op); /* @@ -576,7 +596,7 @@ AcpiDsInitObjectFromOp ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("DsInitObjectFromOp"); + ACPI_FUNCTION_TRACE (DsInitObjectFromOp); ObjDesc = *RetObjDesc; @@ -597,8 +617,8 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Buffer TermArg operand */ - ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) - WalkState->Operands[0]; + ObjDesc->Buffer.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); ObjDesc->Buffer.AmlStart = Op->Named.Data; ObjDesc->Buffer.AmlLength = Op->Named.Length; break; @@ -609,8 +629,8 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Package TermArg operand */ - ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) - WalkState->Operands[0]; + ObjDesc->Package.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); ObjDesc->Package.AmlStart = Op->Named.Data; ObjDesc->Package.AmlLength = Op->Named.Length; break; diff --git a/sys/dist/acpica/dsopcode.c b/sys/dist/acpica/dsopcode.c index 28e05d6caeb..7ca46aeaac4 100644 --- a/sys/dist/acpica/dsopcode.c +++ b/sys/dist/acpica/dsopcode.c @@ -2,7 +2,7 @@ * * Module Name: dsopcode - Dispatcher Op Region support and handling of * "control" opcodes - * xRevision: 1.106 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,18 +115,15 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsopcode.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __DSOPCODE_C__ -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsopcode") @@ -177,7 +174,7 @@ AcpiDsExecuteArguments ( ACPI_WALK_STATE *WalkState; - ACPI_FUNCTION_TRACE ("DsExecuteArguments"); + ACPI_FUNCTION_TRACE (DsExecuteArguments); /* @@ -203,7 +200,7 @@ AcpiDsExecuteArguments ( } Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, 1); + AmlLength, NULL, ACPI_IMODE_LOAD_PASS1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -250,7 +247,7 @@ AcpiDsExecuteArguments ( /* Execute the opcode and arguments */ Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, 3); + AmlLength, NULL, ACPI_IMODE_EXECUTE); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -290,7 +287,7 @@ AcpiDsGetBufferFieldArguments ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments, ObjDesc); if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) @@ -336,7 +333,7 @@ AcpiDsGetBufferArguments ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("DsGetBufferArguments", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments, ObjDesc); if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) @@ -385,7 +382,7 @@ AcpiDsGetPackageArguments ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("DsGetPackageArguments", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments, ObjDesc); if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) @@ -435,7 +432,7 @@ AcpiDsGetRegionArguments ( ACPI_OPERAND_OBJECT *ExtraDesc; - ACPI_FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments, ObjDesc); if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) @@ -462,6 +459,28 @@ AcpiDsGetRegionArguments ( Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate the region address/length via the host OS */ + + Status = AcpiOsValidateAddress (ObjDesc->Region.SpaceId, + ObjDesc->Region.Address, (ACPI_SIZE) ObjDesc->Region.Length); + if (ACPI_FAILURE (Status)) + { + /* + * Invalid address/length. We will emit an error message and mark + * the region as invalid, so that it will cause an additional error if + * it is ever used. Then return AE_OK. + */ + ACPI_EXCEPTION ((AE_INFO, Status, + "During address validation of OpRegion [%4.4s]", Node->Name.Ascii)); + ObjDesc->Common.Flags |= AOPOBJ_INVALID; + Status = AE_OK; + } + return_ACPI_STATUS (Status); } @@ -528,7 +547,7 @@ AcpiDsInitBufferField ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc); /* Host object must be a Buffer */ @@ -728,7 +747,7 @@ AcpiDsEvalBufferFieldOperands ( ACPI_PARSE_OBJECT *NextOp; - ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op); + ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op); /* @@ -821,7 +840,7 @@ AcpiDsEvalRegionOperands ( ACPI_PARSE_OBJECT *NextOp; - ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op); + ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op); /* @@ -923,11 +942,17 @@ AcpiDsEvalDataObjectOperands ( UINT32 Length; - ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands"); + ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands); /* The first operand (for all of these data objects) is the length */ + /* + * Set proper index into operand stack for AcpiDsObjStackPush + * invoked inside AcpiDsCreateOperand. + */ + WalkState->OperandIndex = WalkState->NumOperands; + Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); if (ACPI_FAILURE (Status)) { @@ -1020,7 +1045,7 @@ AcpiDsExecBeginControlOp ( ACPI_GENERIC_STATE *ControlState; - ACPI_FUNCTION_NAME ("DsExecBeginControlOp"); + ACPI_FUNCTION_NAME (DsExecBeginControlOp); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, @@ -1103,7 +1128,7 @@ AcpiDsExecEndControlOp ( ACPI_GENERIC_STATE *ControlState; - ACPI_FUNCTION_NAME ("DsExecEndControlOp"); + ACPI_FUNCTION_NAME (DsExecEndControlOp); switch (Op->Common.AmlOpcode) @@ -1198,8 +1223,7 @@ AcpiDsExecEndControlOp ( */ WalkState->ReturnDesc = WalkState->Operands[0]; } - else if ((WalkState->Results) && - (WalkState->Results->Results.NumResults > 0)) + else if (WalkState->ResultCount) { /* Since we have a real Return(), delete any implicit return */ diff --git a/sys/dist/acpica/dsutils.c b/sys/dist/acpica/dsutils.c index a19301974d4..79ca7389fff 100644 --- a/sys/dist/acpica/dsutils.c +++ b/sys/dist/acpica/dsutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dsutils - Dispatcher utilities - * xRevision: 1.119 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,18 +114,15 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsutils.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __DSUTILS_C__ -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acdebug.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdebug.h> #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsutils") @@ -150,7 +147,7 @@ void AcpiDsClearImplicitReturn ( ACPI_WALK_STATE *WalkState) { - ACPI_FUNCTION_NAME ("DsClearImplicitReturn"); + ACPI_FUNCTION_NAME (DsClearImplicitReturn); /* @@ -203,7 +200,7 @@ AcpiDsDoImplicitReturn ( ACPI_WALK_STATE *WalkState, BOOLEAN AddReference) { - ACPI_FUNCTION_NAME ("DsDoImplicitReturn"); + ACPI_FUNCTION_NAME (DsDoImplicitReturn); /* @@ -268,7 +265,7 @@ AcpiDsIsResultUsed ( { const ACPI_OPCODE_INFO *ParentInfo; - ACPI_FUNCTION_TRACE_PTR ("DsIsResultUsed", Op); + ACPI_FUNCTION_TRACE_PTR (DsIsResultUsed, Op); /* Must have both an Op and a Result Object */ @@ -445,7 +442,7 @@ AcpiDsDeleteResultIfNotUsed ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("DsDeleteResultIfNotUsed", ResultObj); + ACPI_FUNCTION_TRACE_PTR (DsDeleteResultIfNotUsed, ResultObj); if (!Op) @@ -496,7 +493,7 @@ AcpiDsResolveOperands ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_PTR ("DsResolveOperands", WalkState); + ACPI_FUNCTION_TRACE_PTR (DsResolveOperands, WalkState); /* @@ -536,7 +533,7 @@ AcpiDsClearOperands ( UINT32 i; - ACPI_FUNCTION_TRACE_PTR ("DsClearOperands", WalkState); + ACPI_FUNCTION_TRACE_PTR (DsClearOperands, WalkState); /* Remove a reference on each operand on the stack */ @@ -590,13 +587,14 @@ AcpiDsCreateOperand ( const ACPI_OPCODE_INFO *OpInfo; - ACPI_FUNCTION_TRACE_PTR ("DsCreateOperand", Arg); + ACPI_FUNCTION_TRACE_PTR (DsCreateOperand, Arg); /* A valid name must be looked up in the namespace */ if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && - (Arg->Common.Value.String)) + (Arg->Common.Value.String) && + !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg)); @@ -696,7 +694,7 @@ AcpiDsCreateOperand ( /* Free the namestring created above */ - ACPI_MEM_FREE (NameString); + ACPI_FREE (NameString); /* Check status from the lookup */ @@ -718,7 +716,8 @@ AcpiDsCreateOperand ( { /* Check for null name case */ - if (Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) + if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && + !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) { /* * If the name is null, this means that this is an @@ -744,7 +743,7 @@ AcpiDsCreateOperand ( return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } - if (OpInfo->Flags & AML_HAS_RETVAL) + if ((OpInfo->Flags & AML_HAS_RETVAL) || (Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Argument previously created, already stacked\n")); @@ -756,7 +755,7 @@ AcpiDsCreateOperand ( * Use value that was already previously returned * by the evaluation of this argument */ - Status = AcpiDsResultPopFromBottom (&ObjDesc, WalkState); + Status = AcpiDsResultPop (&ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { /* @@ -826,30 +825,59 @@ AcpiDsCreateOperands ( { ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *Arg; - UINT32 ArgCount = 0; + ACPI_PARSE_OBJECT *Arguments[ACPI_OBJ_NUM_OPERANDS]; + UINT8 ArgCount = 0; + UINT8 Count = 0; + UINT8 Index = WalkState->NumOperands; + UINT8 i; - ACPI_FUNCTION_TRACE_PTR ("DsCreateOperands", FirstArg); + ACPI_FUNCTION_TRACE_PTR (DsCreateOperands, FirstArg); - /* For all arguments in the list... */ + /* Get all arguments in the list */ Arg = FirstArg; while (Arg) { - Status = AcpiDsCreateOperand (WalkState, Arg, ArgCount); - if (ACPI_FAILURE (Status)) + if (Index >= ACPI_OBJ_NUM_OPERANDS) { - goto Cleanup; + return_ACPI_STATUS (AE_BAD_DATA); } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n", - ArgCount, Arg, FirstArg)); + Arguments[Index] = Arg; + WalkState->Operands [Index] = NULL; /* Move on to next argument, if any */ Arg = Arg->Common.Next; ArgCount++; + Index++; + } + + Index--; + + /* It is the appropriate order to get objects from the Result stack */ + + for (i = 0; i < ArgCount; i++) + { + Arg = Arguments[Index]; + + /* Force the filling of the operand stack in inverse order */ + + WalkState->OperandIndex = Index; + + Status = AcpiDsCreateOperand (WalkState, Arg, Index); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Count++; + Index--; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n", + Index, Arg, FirstArg)); } return_ACPI_STATUS (Status); @@ -861,11 +889,122 @@ Cleanup: * pop everything off of the operand stack and delete those * objects */ - (void) AcpiDsObjStackPopAndDelete (ArgCount, WalkState); + AcpiDsObjStackPopAndDelete (ArgCount, WalkState); - ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %d", - (ArgCount + 1))); + ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %d", Index)); return_ACPI_STATUS (Status); } +/***************************************************************************** + * + * FUNCTION: AcpiDsEvaluateNamePath + * + * PARAMETERS: WalkState - Current state of the parse tree walk, + * the opcode of current operation should be + * AML_INT_NAMEPATH_OP + * + * RETURN: Status + * + * DESCRIPTION: Translate the -NamePath- parse tree object to the equivalent + * interpreter object, convert it to value, if needed, duplicate + * it, if needed, and push it onto the current result stack. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsEvaluateNamePath ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = WalkState->Op; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *NewObjDesc; + UINT8 Type; + + + ACPI_FUNCTION_TRACE_PTR (DsEvaluateNamePath, WalkState); + + + if (!Op->Common.Parent) + { + /* This happens after certain exception processing */ + + goto Exit; + } + + if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_REF_OF_OP)) + { + /* TBD: Should we specify this feature as a bit of OpInfo->Flags of these opcodes? */ + + goto Exit; + } + + Status = AcpiDsCreateOperand (WalkState, Op, 0); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Op->Common.Flags & ACPI_PARSEOP_TARGET) + { + NewObjDesc = *Operand; + goto PushResult; + } + + Type = ACPI_GET_OBJECT_TYPE (*Operand); + + Status = AcpiExResolveToValue (Operand, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Type == ACPI_TYPE_INTEGER) + { + /* It was incremented by AcpiExResolveToValue */ + + AcpiUtRemoveReference (*Operand); + + Status = AcpiUtCopyIobjectToIobject (*Operand, &NewObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + else + { + /* + * The object either was anew created or is + * a Namespace node - don't decrement it. + */ + NewObjDesc = *Operand; + } + + /* Cleanup for name-path operand */ + + Status = AcpiDsObjStackPop (1, WalkState); + if (ACPI_FAILURE (Status)) + { + WalkState->ResultObj = NewObjDesc; + goto Exit; + } + +PushResult: + + WalkState->ResultObj = NewObjDesc; + + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + if (ACPI_SUCCESS (Status)) + { + /* Force to take it from stack */ + + Op->Common.Flags |= ACPI_PARSEOP_IN_STACK; + } + +Exit: + + return_ACPI_STATUS (Status); +} diff --git a/sys/dist/acpica/dswexec.c b/sys/dist/acpica/dswexec.c index 546eec09a2b..9d43a263476 100644 --- a/sys/dist/acpica/dswexec.c +++ b/sys/dist/acpica/dswexec.c @@ -2,7 +2,7 @@ * * Module Name: dswexec - Dispatcher method execution callbacks; * dispatch to interpreter. - * xRevision: 1.125 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,19 +115,15 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dswexec.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __DSWEXEC_C__ -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acdebug.h" -#include "acdisasm.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdebug.h> #define _COMPONENT ACPI_DISPATCHER @@ -136,19 +132,21 @@ __KERNEL_RCSID(0, "$NetBSD: dswexec.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); /* * Dispatch table for opcode classes */ -static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = { - AcpiExOpcode_0A_0T_1R, - AcpiExOpcode_1A_0T_0R, - AcpiExOpcode_1A_0T_1R, - AcpiExOpcode_1A_1T_0R, - AcpiExOpcode_1A_1T_1R, - AcpiExOpcode_2A_0T_0R, - AcpiExOpcode_2A_0T_1R, - AcpiExOpcode_2A_1T_1R, - AcpiExOpcode_2A_2T_1R, - AcpiExOpcode_3A_0T_0R, - AcpiExOpcode_3A_1T_1R, - AcpiExOpcode_6A_0T_1R}; +static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = +{ + AcpiExOpcode_0A_0T_1R, + AcpiExOpcode_1A_0T_0R, + AcpiExOpcode_1A_0T_1R, + AcpiExOpcode_1A_1T_0R, + AcpiExOpcode_1A_1T_1R, + AcpiExOpcode_2A_0T_0R, + AcpiExOpcode_2A_0T_1R, + AcpiExOpcode_2A_1T_1R, + AcpiExOpcode_2A_2T_1R, + AcpiExOpcode_3A_0T_0R, + AcpiExOpcode_3A_1T_1R, + AcpiExOpcode_6A_0T_1R +}; /***************************************************************************** @@ -174,7 +172,7 @@ AcpiDsGetPredicateValue ( ACPI_OPERAND_OBJECT *LocalObjDesc = NULL; - ACPI_FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState); + ACPI_FUNCTION_TRACE_PTR (DsGetPredicateValue, WalkState); WalkState->ControlState->Common.State = 0; @@ -308,7 +306,7 @@ AcpiDsExecBeginOp ( UINT32 OpcodeClass; - ACPI_FUNCTION_TRACE_PTR ("DsExecBeginOp", WalkState); + ACPI_FUNCTION_TRACE_PTR (DsExecBeginOp, WalkState); Op = WalkState->Op; @@ -317,7 +315,7 @@ AcpiDsExecBeginOp ( Status = AcpiDsLoad2BeginOp (WalkState, OutOp); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto ErrorExit; } Op = *OutOp; @@ -334,7 +332,7 @@ AcpiDsExecBeginOp ( Status = AcpiDsScopeStackPop (WalkState); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto ErrorExit; } } } @@ -385,19 +383,13 @@ AcpiDsExecBeginOp ( { case AML_CLASS_CONTROL: - Status = AcpiDsResultStackPush (WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - Status = AcpiDsExecBeginControlOp (WalkState, Op); break; case AML_CLASS_NAMED_OBJECT: - if (WalkState->WalkType == ACPI_WALK_METHOD) + if (WalkState->WalkType & ACPI_WALK_METHOD) { /* * Found a named object declaration during method execution; @@ -408,23 +400,12 @@ AcpiDsExecBeginOp ( Status = AcpiDsLoad2BeginOp (WalkState, NULL); } - if (Op->Common.AmlOpcode == AML_REGION_OP) - { - Status = AcpiDsResultStackPush (WalkState); - } break; case AML_CLASS_EXECUTE: case AML_CLASS_CREATE: - /* - * Most operators with arguments. - * Start a new result/operand state - */ - if (WalkState->Opcode != AML_CREATE_FIELD_OP) - { - Status = AcpiDsResultStackPush (WalkState); - } + break; @@ -435,6 +416,11 @@ AcpiDsExecBeginOp ( /* Nothing to do here during method execution */ return_ACPI_STATUS (Status); + + +ErrorExit: + Status = AcpiDsMethodError (Status, WalkState); + return_ACPI_STATUS (Status); } @@ -464,7 +450,7 @@ AcpiDsExecEndOp ( ACPI_PARSE_OBJECT *FirstArg; - ACPI_FUNCTION_TRACE_PTR ("DsExecEndOp", WalkState); + ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState); Op = WalkState->Op; @@ -482,6 +468,7 @@ AcpiDsExecEndOp ( /* Init the walk state */ WalkState->NumOperands = 0; + WalkState->OperandIndex = 0; WalkState->ReturnDesc = NULL; WalkState->ResultObj = NULL; @@ -494,11 +481,20 @@ AcpiDsExecEndOp ( switch (OpClass) { - case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */ + case AML_CLASS_ARGUMENT: /* Constants, literals, etc. */ + + if (WalkState->Opcode == AML_INT_NAMEPATH_OP) + { + Status = AcpiDsEvaluateNamePath (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } break; - case AML_CLASS_EXECUTE: /* most operators with arguments */ + case AML_CLASS_EXECUTE: /* Most operators with arguments */ /* Build resolved operand stack */ @@ -508,14 +504,6 @@ AcpiDsExecEndOp ( goto Cleanup; } - /* Done with this result state (Now that operand stack is built) */ - - Status = AcpiDsResultStackPop (WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - /* * All opcodes require operand resolution, with the only exceptions * being the ObjectType and SizeOf operators. @@ -582,7 +570,6 @@ AcpiDsExecEndOp ( { Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); } - break; @@ -596,20 +583,6 @@ AcpiDsExecEndOp ( Status = AcpiDsExecEndControlOp (WalkState, Op); - /* Make sure to properly pop the result stack */ - - if (ACPI_SUCCESS (Status)) - { - Status = AcpiDsResultStackPop (WalkState); - } - else if (Status == AE_CTRL_PENDING) - { - Status = AcpiDsResultStackPop (WalkState); - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_PENDING; - } - } break; @@ -626,6 +599,7 @@ AcpiDsExecEndOp ( { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method Reference in a Package, Op=%p\n", Op)); + Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node->Object; AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object); return_ACPI_STATUS (AE_OK); @@ -735,14 +709,6 @@ AcpiDsExecEndOp ( break; } - /* Done with result state (Now that operand stack is built) */ - - Status = AcpiDsResultStackPop (WalkState); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - /* * If a result object was returned from above, push it on the * current result stack @@ -775,10 +741,7 @@ AcpiDsExecEndOp ( { break; } - - Status = AcpiDsResultStackPop (WalkState); } - break; @@ -818,7 +781,6 @@ AcpiDsExecEndOp ( * Check if we just completed the evaluation of a * conditional predicate */ - if ((ACPI_SUCCESS (Status)) && (WalkState->ControlState) && (WalkState->ControlState->Common.State == diff --git a/sys/dist/acpica/dswload.c b/sys/dist/acpica/dswload.c index 71a13fb7165..3e791b07ffe 100644 --- a/sys/dist/acpica/dswload.c +++ b/sys/dist/acpica/dswload.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswload - Dispatcher namespace load callbacks - * xRevision: 1.106 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,21 +114,18 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dswload.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __DSWLOAD_C__ -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> #ifdef ACPI_ASL_COMPILER -#include "acdisasm.h" +#include <dist/acpica/acdisasm.h> #endif #define _COMPONENT ACPI_DISPATCHER @@ -213,7 +210,7 @@ AcpiDsLoad1BeginOp ( UINT32 Flags; - ACPI_FUNCTION_TRACE ("DsLoad1BeginOp"); + ACPI_FUNCTION_TRACE (DsLoad1BeginOp); Op = WalkState->Op; @@ -263,13 +260,13 @@ AcpiDsLoad1BeginOp ( { /* * Table disassembly: - * Target of Scope() not found. Generate an External for it, and + * Target of Scope() not found. Generate an External for it, and * insert the name into the namespace. */ - AcpiDmAddToExternalList (Path); + AcpiDmAddToExternalList (Path, ACPI_TYPE_DEVICE, 0); Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, - WalkState, &(Node)); + WalkState, &Node); } #endif if (ACPI_FAILURE (Status)) @@ -284,6 +281,7 @@ AcpiDsLoad1BeginOp ( */ switch (Node->Type) { + case ACPI_TYPE_ANY: case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ case ACPI_TYPE_DEVICE: case ACPI_TYPE_POWER: @@ -298,16 +296,15 @@ AcpiDsLoad1BeginOp ( case ACPI_TYPE_BUFFER: /* - * These types we will allow, but we will change the type. This + * These types we will allow, but we will change the type. This * enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } * - * Note: silently change the type here. On the second pass, we will report + * Note: silently change the type here. On the second pass, we will report * a warning */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", Path, AcpiUtGetTypeName (Node->Type))); @@ -330,7 +327,6 @@ AcpiDsLoad1BeginOp ( default: - /* * For all other named opcodes, we will enter the name into * the namespace. @@ -347,7 +343,6 @@ AcpiDsLoad1BeginOp ( * BufferField, or Package), the name of the object is already * in the namespace. */ - if (WalkState->DeferredNode) { /* This name is already in the namespace, get the node */ @@ -384,22 +379,52 @@ AcpiDsLoad1BeginOp ( } /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that * involve arguments to the opcode must be created as we go back up the * parse tree later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); + ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); if (ACPI_FAILURE (Status)) { - ACPI_ERROR_NAMESPACE (Path, Status); - return_ACPI_STATUS (Status); + if (Status == AE_ALREADY_EXISTS) + { + /* The name already exists in this scope */ + + if (Node->Flags & ANOBJ_IS_EXTERNAL) + { + /* + * Allow one create on an object or segment that was + * previously declared External + */ + Node->Flags &= ~ANOBJ_IS_EXTERNAL; + Node->Type = (UINT8) ObjectType; + + /* Just retyped a node, probably will need to open a scope */ + + if (AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + Status = AE_OK; + } + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + return_ACPI_STATUS (Status); + } } break; } - /* Common exit */ if (!Op) @@ -457,7 +482,7 @@ AcpiDsLoad1EndOp ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("DsLoad1EndOp"); + ACPI_FUNCTION_TRACE (DsLoad1EndOp); Op = WalkState->Op; @@ -502,9 +527,8 @@ AcpiDsLoad1EndOp ( if (Op->Common.AmlOpcode == AML_REGION_OP) { Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, - (ACPI_ADR_SPACE_TYPE) - ((Op->Common.Value.Arg)->Common.Value.Integer), - WalkState); + (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -543,7 +567,7 @@ AcpiDsLoad1EndOp ( * MethodOp PkgLength NameString MethodFlags TermList * * Note: We must create the method node/object pair as soon as we - * see the method declaration. This allows later pass1 parsing + * see the method declaration. This allows later pass1 parsing * of invocations of the method (need to know the number of * arguments.) */ @@ -562,6 +586,7 @@ AcpiDsLoad1EndOp ( Status = AcpiExCreateMethod (Op->Named.Data, Op->Named.Length, WalkState); } + WalkState->Operands[0] = NULL; WalkState->NumOperands = 0; @@ -611,9 +636,10 @@ AcpiDsLoad2BeginOp ( ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; char *BufferPtr; + UINT32 Flags; - ACPI_FUNCTION_TRACE ("DsLoad2BeginOp"); + ACPI_FUNCTION_TRACE (DsLoad2BeginOp); Op = WalkState->Op; @@ -641,7 +667,6 @@ AcpiDsLoad2BeginOp ( if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Begin/EXEC: %s (fl %8.8X)\n", WalkState->OpInfo->Name, WalkState->OpInfo->Flags)); @@ -673,7 +698,7 @@ AcpiDsLoad2BeginOp ( { /* Get name from the op */ - BufferPtr = (char *) &Op->Named.Name; + BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name); } } else @@ -690,7 +715,6 @@ AcpiDsLoad2BeginOp ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType)); - switch (WalkState->Opcode) { case AML_FIELD_OP: @@ -702,7 +726,6 @@ AcpiDsLoad2BeginOp ( break; case AML_INT_NAMEPATH_OP: - /* * The NamePath is an object reference to an existing object. * Don't enter the name into the namespace, but look it up @@ -714,7 +737,6 @@ AcpiDsLoad2BeginOp ( break; case AML_SCOPE_OP: - /* * The Path is an object reference to an existing object. * Don't enter the name into the namespace, but look it up @@ -739,12 +761,14 @@ AcpiDsLoad2BeginOp ( #endif return_ACPI_STATUS (Status); } + /* * We must check to make sure that the target is * one of the opcodes that actually opens a scope */ switch (Node->Type) { + case ACPI_TYPE_ANY: case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ case ACPI_TYPE_DEVICE: case ACPI_TYPE_POWER: @@ -759,13 +783,12 @@ AcpiDsLoad2BeginOp ( case ACPI_TYPE_BUFFER: /* - * These types we will allow, but we will change the type. This + * These types we will allow, but we will change the type. This * enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } */ - ACPI_WARNING ((AE_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)", BufferPtr, AcpiUtGetTypeName (Node->Type))); @@ -803,14 +826,14 @@ AcpiDsLoad2BeginOp ( { return_ACPI_STATUS (Status); } - } + return_ACPI_STATUS (AE_OK); } /* - * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that * involve arguments to the opcode must be created as we go back up the * parse tree later. * @@ -825,11 +848,18 @@ AcpiDsLoad2BeginOp ( break; } - /* Add new entry into namespace */ + Flags = ACPI_NS_NO_UPSEARCH; + if (WalkState->PassNumber == ACPI_IMODE_EXECUTE) + { + /* Execution mode, node cannot already exist, node is temporary */ + + Flags |= (ACPI_NS_ERROR_IF_FOUND | ACPI_NS_TEMPORARY); + } + + /* Add new entry or lookup existing entry */ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, - WalkState, &(Node)); + ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node); break; } @@ -863,7 +893,6 @@ AcpiDsLoad2BeginOp ( * can get it again quickly when this scope is closed */ Op->Common.Node = Node; - return_ACPI_STATUS (Status); } @@ -896,7 +925,7 @@ AcpiDsLoad2EndOp ( #endif - ACPI_FUNCTION_TRACE ("DsLoad2EndOp"); + ACPI_FUNCTION_TRACE (DsLoad2EndOp); Op = WalkState->Op; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", @@ -1004,7 +1033,6 @@ AcpiDsLoad2EndOp ( #ifndef ACPI_NO_METHOD_EXECUTION case AML_TYPE_CREATE_FIELD: - /* * Create the field object, but the field buffer and index must * be evaluated later during the execution phase @@ -1014,7 +1042,6 @@ AcpiDsLoad2EndOp ( case AML_TYPE_NAMED_FIELD: - /* * If we are executing a method, initialize the field */ @@ -1129,13 +1156,17 @@ AcpiDsLoad2EndOp ( } /* - * The OpRegion is not fully parsed at this time. Only valid + * The OpRegion is not fully parsed at this time. Only valid * argument is the SpaceId. (We must save the address of the * AML of the address and length operands) */ + /* * If we have a valid region, initialize it * Namespace is NOT locked at this point. + * + * TBD: need to unlock interpreter if it is locked, in order + * to allow _REG methods to be run. */ Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), FALSE); @@ -1165,7 +1196,7 @@ AcpiDsLoad2EndOp ( * MethodOp PkgLength NameString MethodFlags TermList * * Note: We must create the method node/object pair as soon as we - * see the method declaration. This allows later pass1 parsing + * see the method declaration. This allows later pass1 parsing * of invocations of the method (need to know the number of * arguments.) */ diff --git a/sys/dist/acpica/dswscope.c b/sys/dist/acpica/dswscope.c index 853864b8ec5..20df2b8ba59 100644 --- a/sys/dist/acpica/dswscope.c +++ b/sys/dist/acpica/dswscope.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswscope - Scope stack manipulation - * xRevision: 1.66 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dswscope.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __DSWSCOPE_C__ -#include "acpi.h" -#include "acdispat.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdispat.h> #define _COMPONENT ACPI_DISPATCHER @@ -146,7 +143,7 @@ AcpiDsScopeStackClear ( { ACPI_GENERIC_STATE *ScopeInfo; - ACPI_FUNCTION_NAME ("DsScopeStackClear"); + ACPI_FUNCTION_NAME (DsScopeStackClear); while (WalkState->ScopeInfo) @@ -189,7 +186,7 @@ AcpiDsScopeStackPush ( ACPI_GENERIC_STATE *OldScopeInfo; - ACPI_FUNCTION_TRACE ("DsScopeStackPush"); + ACPI_FUNCTION_TRACE (DsScopeStackPush); if (!Node) @@ -218,9 +215,9 @@ AcpiDsScopeStackPush ( /* Init new scope object */ - ScopeInfo->Common.DataType = ACPI_DESC_TYPE_STATE_WSCOPE; - ScopeInfo->Scope.Node = Node; - ScopeInfo->Common.Value = (UINT16) Type; + ScopeInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_WSCOPE; + ScopeInfo->Scope.Node = Node; + ScopeInfo->Common.Value = (UINT16) Type; WalkState->ScopeDepth++; @@ -273,7 +270,7 @@ AcpiDsScopeStackPop ( ACPI_GENERIC_STATE *NewScopeInfo; - ACPI_FUNCTION_TRACE ("DsScopeStackPop"); + ACPI_FUNCTION_TRACE (DsScopeStackPop); /* diff --git a/sys/dist/acpica/dswstate.c b/sys/dist/acpica/dswstate.c index e9cc18f501a..6dc91755b02 100644 --- a/sys/dist/acpica/dswstate.c +++ b/sys/dist/acpica/dswstate.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines - * xRevision: 1.93 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,276 +115,158 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dswstate.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __DSWSTATE_C__ -#include "acpi.h" -#include "acparser.h" -#include "acdispat.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dswstate") /* Local prototypes */ -#ifdef ACPI_OBSOLETE_FUNCTIONS -ACPI_STATUS -AcpiDsResultInsert ( - void *Object, - UINT32 Index, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiDsObjStackDeleteAll ( - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiDsObjStackPopObject ( - ACPI_OPERAND_OBJECT **Object, +static ACPI_STATUS +AcpiDsResultStackPush ( ACPI_WALK_STATE *WalkState); -void * -AcpiDsObjStackGetValue ( - UINT32 Index, +static ACPI_STATUS +AcpiDsResultStackPop ( ACPI_WALK_STATE *WalkState); -#endif /******************************************************************************* * - * FUNCTION: AcpiDsResultRemove + * FUNCTION: AcpiDsResultPop * * PARAMETERS: Object - Where to return the popped object - * Index - Where to extract the object * WalkState - Current Walk state * * RETURN: Status * - * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In - * other words, this is a FIFO. + * DESCRIPTION: Pop an object off the top of this walk's result stack * ******************************************************************************/ ACPI_STATUS -AcpiDsResultRemove ( +AcpiDsResultPop ( ACPI_OPERAND_OBJECT **Object, - UINT32 Index, ACPI_WALK_STATE *WalkState) { + ACPI_NATIVE_UINT Index; ACPI_GENERIC_STATE *State; + ACPI_STATUS Status; - ACPI_FUNCTION_NAME ("DsResultRemove"); + ACPI_FUNCTION_NAME (DsResultPop); State = WalkState->Results; - if (!State) + + /* Incorrect state of result stack */ + + if (State && !WalkState->ResultCount) { - ACPI_ERROR ((AE_INFO, "No result object pushed! State=%p", - WalkState)); - return (AE_NOT_EXIST); + ACPI_ERROR ((AE_INFO, "No results on result stack")); + return (AE_AML_INTERNAL); } - if (Index >= ACPI_OBJ_MAX_OPERAND) + if (!State && WalkState->ResultCount) { - ACPI_ERROR ((AE_INFO, - "Index out of range: %X State=%p Num=%X", - Index, WalkState, State->Results.NumResults)); + ACPI_ERROR ((AE_INFO, "No result state for result stack")); + return (AE_AML_INTERNAL); } - /* Check for a valid result object */ + /* Empty result stack */ - if (!State->Results.ObjDesc [Index]) + if (!State) { - ACPI_ERROR ((AE_INFO, - "Null operand! State=%p #Ops=%X, Index=%X", - WalkState, State->Results.NumResults, Index)); + ACPI_ERROR ((AE_INFO, "Result stack is empty! State=%p", WalkState)); return (AE_AML_NO_RETURN_VALUE); } - /* Remove the object */ + /* Return object of the top element and clean that top element result stack */ - State->Results.NumResults--; + WalkState->ResultCount--; + Index = WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; *Object = State->Results.ObjDesc [Index]; - State->Results.ObjDesc [Index] = NULL; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] Index=%X State=%p Num=%X\n", - *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", - Index, WalkState, State->Results.NumResults)); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsResultPop - * - * PARAMETERS: Object - Where to return the popped object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In - * other words, this is a FIFO. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsResultPop ( - ACPI_OPERAND_OBJECT **Object, - ACPI_WALK_STATE *WalkState) -{ - ACPI_NATIVE_UINT Index; - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_NAME ("DsResultPop"); - - - State = WalkState->Results; - if (!State) - { - return (AE_OK); - } - - if (!State->Results.NumResults) + if (!*Object) { - ACPI_ERROR ((AE_INFO, "Result stack is empty! State=%p", + ACPI_ERROR ((AE_INFO, "No result objects on result stack, State=%p", WalkState)); return (AE_AML_NO_RETURN_VALUE); } - /* Remove top element */ - - State->Results.NumResults--; - - for (Index = ACPI_OBJ_NUM_OPERANDS; Index; Index--) + State->Results.ObjDesc [Index] = NULL; + if (Index == 0) { - /* Check for a valid result object */ - - if (State->Results.ObjDesc [Index -1]) + Status = AcpiDsResultStackPop (WalkState); + if (ACPI_FAILURE (Status)) { - *Object = State->Results.ObjDesc [Index -1]; - State->Results.ObjDesc [Index -1] = NULL; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] Index=%X State=%p Num=%X\n", - *Object, - (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", - (UINT32) Index -1, WalkState, State->Results.NumResults)); - - return (AE_OK); + return (Status); } } - ACPI_ERROR ((AE_INFO, - "No result objects! State=%p", WalkState)); - return (AE_AML_NO_RETURN_VALUE); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object, + AcpiUtGetObjectTypeName (*Object), + (UINT32) Index, WalkState, WalkState->ResultCount)); + + return (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiDsResultPopFromBottom + * FUNCTION: AcpiDsResultPush * * PARAMETERS: Object - Where to return the popped object * WalkState - Current Walk state * * RETURN: Status * - * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In - * other words, this is a FIFO. + * DESCRIPTION: Push an object onto the current result stack * ******************************************************************************/ ACPI_STATUS -AcpiDsResultPopFromBottom ( - ACPI_OPERAND_OBJECT **Object, +AcpiDsResultPush ( + ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState) { - ACPI_NATIVE_UINT Index; ACPI_GENERIC_STATE *State; + ACPI_STATUS Status; + ACPI_NATIVE_UINT Index; - ACPI_FUNCTION_NAME ("DsResultPopFromBottom"); + ACPI_FUNCTION_NAME (DsResultPush); - State = WalkState->Results; - if (!State) + if (WalkState->ResultCount > WalkState->ResultSize) { - ACPI_ERROR ((AE_INFO, - "No result object pushed! State=%p", WalkState)); - return (AE_NOT_EXIST); + ACPI_ERROR ((AE_INFO, "Result stack is full")); + return (AE_AML_INTERNAL); } - - if (!State->Results.NumResults) + else if (WalkState->ResultCount == WalkState->ResultSize) { - ACPI_ERROR ((AE_INFO, "No result objects! State=%p", - WalkState)); - return (AE_AML_NO_RETURN_VALUE); - } - - /* Remove Bottom element */ - - *Object = State->Results.ObjDesc [0]; + /* Extend the result stack */ - /* Push entire stack down one element */ - - for (Index = 0; Index < State->Results.NumResults; Index++) - { - State->Results.ObjDesc [Index] = State->Results.ObjDesc [Index + 1]; + Status = AcpiDsResultStackPush (WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Failed to extend the result stack")); + return (Status); + } } - State->Results.NumResults--; - - /* Check for a valid result object */ - - if (!*Object) + if (!(WalkState->ResultCount < WalkState->ResultSize)) { - ACPI_ERROR ((AE_INFO, - "Null operand! State=%p #Ops=%X Index=%X", - WalkState, State->Results.NumResults, (UINT32) Index)); - return (AE_AML_NO_RETURN_VALUE); + ACPI_ERROR ((AE_INFO, "No free elements in result stack")); + return (AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n", - *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", - State, WalkState)); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsResultPush - * - * PARAMETERS: Object - Where to return the popped object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Push an object onto the current result stack - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsResultPush ( - ACPI_OPERAND_OBJECT *Object, - ACPI_WALK_STATE *WalkState) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_NAME ("DsResultPush"); - - State = WalkState->Results; if (!State) { @@ -392,28 +274,23 @@ AcpiDsResultPush ( return (AE_AML_INTERNAL); } - if (State->Results.NumResults == ACPI_OBJ_NUM_OPERANDS) - { - ACPI_ERROR ((AE_INFO, - "Result stack overflow: Obj=%p State=%p Num=%X", - Object, WalkState, State->Results.NumResults)); - return (AE_STACK_OVERFLOW); - } - if (!Object) { ACPI_ERROR ((AE_INFO, "Null Object! Obj=%p State=%p Num=%X", - Object, WalkState, State->Results.NumResults)); + Object, WalkState, WalkState->ResultCount)); return (AE_BAD_PARAMETER); } - State->Results.ObjDesc [State->Results.NumResults] = Object; - State->Results.NumResults++; + /* Assign the address of object to the top free element of result stack */ + + Index = WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; + State->Results.ObjDesc [Index] = Object; + WalkState->ResultCount++; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", - Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", - WalkState, State->Results.NumResults, WalkState->CurrentResult)); + Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), + WalkState, WalkState->ResultCount, WalkState->CurrentResult)); return (AE_OK); } @@ -427,18 +304,29 @@ AcpiDsResultPush ( * * RETURN: Status * - * DESCRIPTION: Push an object onto the WalkState result stack. + * DESCRIPTION: Push an object onto the WalkState result stack * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsResultStackPush ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_NAME ("DsResultStackPush"); + ACPI_FUNCTION_NAME (DsResultStackPush); + + + /* Check for stack overflow */ + + if ((WalkState->ResultSize + ACPI_RESULTS_FRAME_OBJ_NUM) > + ACPI_RESULTS_OBJ_NUM_MAX) + { + ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%X", + WalkState, WalkState->ResultSize)); + return (AE_STACK_OVERFLOW); + } State = AcpiUtCreateGenericState (); if (!State) @@ -446,9 +334,13 @@ AcpiDsResultStackPush ( return (AE_NO_MEMORY); } - State->Common.DataType = ACPI_DESC_TYPE_STATE_RESULT; + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RESULT; AcpiUtPushGenericState (&WalkState->Results, State); + /* Increase the length of the result stack by the length of frame */ + + WalkState->ResultSize += ACPI_RESULTS_FRAME_OBJ_NUM; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", State, WalkState)); @@ -464,35 +356,45 @@ AcpiDsResultStackPush ( * * RETURN: Status * - * DESCRIPTION: Pop an object off of the WalkState result stack. + * DESCRIPTION: Pop an object off of the WalkState result stack * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsResultStackPop ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_NAME ("DsResultStackPop"); + + ACPI_FUNCTION_NAME (DsResultStackPop); /* Check for stack underflow */ if (WalkState->Results == NULL) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result stack underflow - State=%p\n", WalkState)); return (AE_AML_NO_OPERAND); } + if (WalkState->ResultSize < ACPI_RESULTS_FRAME_OBJ_NUM) + { + ACPI_ERROR ((AE_INFO, "Insufficient result stack size")); + return (AE_AML_INTERNAL); + } + State = AcpiUtPopGenericState (&WalkState->Results); + AcpiUtDeleteGenericState (State); + + /* Decrease the length of result stack by the length of frame */ + + WalkState->ResultSize -= ACPI_RESULTS_FRAME_OBJ_NUM; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result=%p RemainingResults=%X State=%p\n", - State, State->Results.NumResults, WalkState)); - - AcpiUtDeleteGenericState (State); + State, WalkState->ResultCount, WalkState)); return (AE_OK); } @@ -516,7 +418,7 @@ AcpiDsObjStackPush ( void *Object, ACPI_WALK_STATE *WalkState) { - ACPI_FUNCTION_NAME ("DsObjStackPush"); + ACPI_FUNCTION_NAME (DsObjStackPush); /* Check for stack overflow */ @@ -531,12 +433,16 @@ AcpiDsObjStackPush ( /* Put the object onto the stack */ - WalkState->Operands [WalkState->NumOperands] = Object; + WalkState->Operands [WalkState->OperandIndex] = Object; WalkState->NumOperands++; + /* For the usual order of filling the operand stack */ + + WalkState->OperandIndex++; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", - Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), - WalkState, WalkState->NumOperands)); + Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), + WalkState, WalkState->NumOperands)); return (AE_OK); } @@ -563,7 +469,8 @@ AcpiDsObjStackPop ( { UINT32 i; - ACPI_FUNCTION_NAME ("DsObjStackPop"); + + ACPI_FUNCTION_NAME (DsObjStackPop); for (i = 0; i < PopCount; i++) @@ -585,7 +492,7 @@ AcpiDsObjStackPop ( } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", - PopCount, WalkState, WalkState->NumOperands)); + PopCount, WalkState, WalkState->NumOperands)); return (AE_OK); } @@ -605,7 +512,7 @@ AcpiDsObjStackPop ( * ******************************************************************************/ -ACPI_STATUS +void AcpiDsObjStackPopAndDelete ( UINT32 PopCount, ACPI_WALK_STATE *WalkState) @@ -614,36 +521,34 @@ AcpiDsObjStackPopAndDelete ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_NAME ("DsObjStackPopAndDelete"); + ACPI_FUNCTION_NAME (DsObjStackPopAndDelete); - for (i = 0; i < PopCount; i++) + if (PopCount == 0) { - /* Check for stack underflow */ + return; + } + for (i = (PopCount - 1); i != (UINT32)-1; i--) + { if (WalkState->NumOperands == 0) { - ACPI_ERROR ((AE_INFO, - "Object stack underflow! Count=%X State=%p #Ops=%X", - PopCount, WalkState, WalkState->NumOperands)); - return (AE_STACK_UNDERFLOW); + return; } /* Pop the stack and delete an object if present in this stack entry */ WalkState->NumOperands--; - ObjDesc = WalkState->Operands [WalkState->NumOperands]; + ObjDesc = WalkState->Operands [i]; if (ObjDesc) { - AcpiUtRemoveReference (WalkState->Operands [WalkState->NumOperands]); - WalkState->Operands [WalkState->NumOperands] = NULL; + AcpiUtRemoveReference (WalkState->Operands [i]); + WalkState->Operands [i] = NULL; } } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", - PopCount, WalkState, WalkState->NumOperands)); - - return (AE_OK); + PopCount, WalkState, WalkState->NumOperands)); } @@ -663,9 +568,8 @@ AcpiDsObjStackPopAndDelete ( ACPI_WALK_STATE * AcpiDsGetCurrentWalkState ( ACPI_THREAD_STATE *Thread) - { - ACPI_FUNCTION_NAME ("DsGetCurrentWalkState"); + ACPI_FUNCTION_NAME (DsGetCurrentWalkState); if (!Thread) @@ -689,7 +593,7 @@ AcpiDsGetCurrentWalkState ( * * RETURN: None * - * DESCRIPTION: Place the Thread state at the head of the state list. + * DESCRIPTION: Place the Thread state at the head of the state list * ******************************************************************************/ @@ -698,10 +602,10 @@ AcpiDsPushWalkState ( ACPI_WALK_STATE *WalkState, ACPI_THREAD_STATE *Thread) { - ACPI_FUNCTION_TRACE ("DsPushWalkState"); + ACPI_FUNCTION_TRACE (DsPushWalkState); - WalkState->Next = Thread->WalkStateList; + WalkState->Next = Thread->WalkStateList; Thread->WalkStateList = WalkState; return_VOID; @@ -729,7 +633,7 @@ AcpiDsPopWalkState ( ACPI_WALK_STATE *WalkState; - ACPI_FUNCTION_TRACE ("DsPopWalkState"); + ACPI_FUNCTION_TRACE (DsPopWalkState); WalkState = Thread->WalkStateList; @@ -757,7 +661,7 @@ AcpiDsPopWalkState ( * * PARAMETERS: OwnerId - ID for object creation * Origin - Starting point for this walk - * MthDesc - Method object + * MethodDesc - Method object * Thread - Current thread state * * RETURN: Pointer to the new walk state. @@ -771,27 +675,26 @@ ACPI_WALK_STATE * AcpiDsCreateWalkState ( ACPI_OWNER_ID OwnerId, ACPI_PARSE_OBJECT *Origin, - ACPI_OPERAND_OBJECT *MthDesc, + ACPI_OPERAND_OBJECT *MethodDesc, ACPI_THREAD_STATE *Thread) { ACPI_WALK_STATE *WalkState; - ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("DsCreateWalkState"); + ACPI_FUNCTION_TRACE (DsCreateWalkState); - WalkState = ACPI_MEM_CALLOCATE (sizeof (ACPI_WALK_STATE)); + WalkState = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_WALK_STATE)); if (!WalkState) { return_PTR (NULL); } - WalkState->DataType = ACPI_DESC_TYPE_WALK; - WalkState->OwnerId = OwnerId; - WalkState->Origin = Origin; - WalkState->MethodDesc = MthDesc; - WalkState->Thread = Thread; + WalkState->DescriptorType = ACPI_DESC_TYPE_WALK; + WalkState->MethodDesc = MethodDesc; + WalkState->OwnerId = OwnerId; + WalkState->Origin = Origin; + WalkState->Thread = Thread; WalkState->ParserState.StartOp = Origin; @@ -801,15 +704,6 @@ AcpiDsCreateWalkState ( AcpiDsMethodDataInit (WalkState); #endif - /* Create an initial result stack entry */ - - Status = AcpiDsResultStackPush (WalkState); - if (ACPI_FAILURE (Status)) - { - ACPI_MEM_FREE (WalkState); - return_PTR (NULL); - } - /* Put the new state at the head of the walk list */ if (Thread) @@ -846,7 +740,7 @@ AcpiDsInitAmlWalk ( ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, - ACPI_PARAMETER_INFO *Info, + ACPI_EVALUATE_INFO *Info, UINT8 PassNumber) { ACPI_STATUS Status; @@ -854,13 +748,13 @@ AcpiDsInitAmlWalk ( ACPI_PARSE_OBJECT *ExtraOp; - ACPI_FUNCTION_TRACE ("DsInitAmlWalk"); + ACPI_FUNCTION_TRACE (DsInitAmlWalk); - WalkState->ParserState.Aml = + WalkState->ParserState.Aml = WalkState->ParserState.AmlStart = AmlStart; - WalkState->ParserState.AmlEnd = - WalkState->ParserState.PkgEnd = AmlStart + AmlLength; + WalkState->ParserState.AmlEnd = + WalkState->ParserState.PkgEnd = AmlStart + AmlLength; /* The NextOp of the NextWalk will be the beginning of the method */ @@ -871,12 +765,12 @@ AcpiDsInitAmlWalk ( { if (Info->ParameterType == ACPI_PARAM_GPE) { - WalkState->GpeEventInfo = ACPI_CAST_PTR (ACPI_GPE_EVENT_INFO, - Info->Parameters); + WalkState->GpeEventInfo = + ACPI_CAST_PTR (ACPI_GPE_EVENT_INFO, Info->Parameters); } else { - WalkState->Params = Info->Parameters; + WalkState->Params = Info->Parameters; WalkState->CallerReturnDesc = &Info->ReturnObject; } } @@ -890,9 +784,9 @@ AcpiDsInitAmlWalk ( if (MethodNode) { WalkState->ParserState.StartNode = MethodNode; - WalkState->WalkType = ACPI_WALK_METHOD; - WalkState->MethodNode = MethodNode; - WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode); + WalkState->WalkType = ACPI_WALK_METHOD; + WalkState->MethodNode = MethodNode; + WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode); /* Push start scope on scope stack and make it current */ @@ -971,7 +865,7 @@ AcpiDsDeleteWalkState ( ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); + ACPI_FUNCTION_TRACE_PTR (DsDeleteWalkState, WalkState); if (!WalkState) @@ -979,17 +873,20 @@ AcpiDsDeleteWalkState ( return; } - if (WalkState->DataType != ACPI_DESC_TYPE_WALK) + if (WalkState->DescriptorType != ACPI_DESC_TYPE_WALK) { ACPI_ERROR ((AE_INFO, "%p is not a valid walk state", WalkState)); return; } + /* There should not be any open scopes */ + if (WalkState->ParserState.Scope) { ACPI_ERROR ((AE_INFO, "%p walk still has a scope list", WalkState)); + AcpiPsCleanupScope (&WalkState->ParserState); } /* Always must free any linked control states */ @@ -1022,214 +919,8 @@ AcpiDsDeleteWalkState ( AcpiUtDeleteGenericState (State); } - ACPI_MEM_FREE (WalkState); + ACPI_FREE (WalkState); return_VOID; } -#ifdef ACPI_OBSOLETE_FUNCTIONS -/******************************************************************************* - * - * FUNCTION: AcpiDsResultInsert - * - * PARAMETERS: Object - Object to push - * Index - Where to insert the object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Insert an object onto this walk's result stack - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsResultInsert ( - void *Object, - UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_NAME ("DsResultInsert"); - - - State = WalkState->Results; - if (!State) - { - ACPI_ERROR ((AE_INFO, "No result object pushed! State=%p", - WalkState)); - return (AE_NOT_EXIST); - } - - if (Index >= ACPI_OBJ_NUM_OPERANDS) - { - ACPI_ERROR ((AE_INFO, - "Index out of range: %X Obj=%p State=%p Num=%X", - Index, Object, WalkState, State->Results.NumResults)); - return (AE_BAD_PARAMETER); - } - - if (!Object) - { - ACPI_ERROR ((AE_INFO, - "Null Object! Index=%X Obj=%p State=%p Num=%X", - Index, Object, WalkState, State->Results.NumResults)); - return (AE_BAD_PARAMETER); - } - - State->Results.ObjDesc [Index] = Object; - State->Results.NumResults++; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] State=%p Num=%X Cur=%X\n", - Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", - WalkState, State->Results.NumResults, WalkState->CurrentResult)); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsObjStackDeleteAll - * - * PARAMETERS: WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Clear the object stack by deleting all objects that are on it. - * Should be used with great care, if at all! - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsObjStackDeleteAll ( - ACPI_WALK_STATE *WalkState) -{ - UINT32 i; - - - ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); - - - /* The stack size is configurable, but fixed */ - - for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) - { - if (WalkState->Operands[i]) - { - AcpiUtRemoveReference (WalkState->Operands[i]); - WalkState->Operands[i] = NULL; - } - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsObjStackPopObject - * - * PARAMETERS: Object - Where to return the popped object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT - * deleted by this routine. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsObjStackPopObject ( - ACPI_OPERAND_OBJECT **Object, - ACPI_WALK_STATE *WalkState) -{ - ACPI_FUNCTION_NAME ("DsObjStackPopObject"); - - - /* Check for stack underflow */ - - if (WalkState->NumOperands == 0) - { - ACPI_ERROR ((AE_INFO, - "Missing operand/stack empty! State=%p #Ops=%X", - WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); - } - - /* Pop the stack */ - - WalkState->NumOperands--; - - /* Check for a valid operand */ - - if (!WalkState->Operands [WalkState->NumOperands]) - { - ACPI_ERROR ((AE_INFO, - "Null operand! State=%p #Ops=%X", - WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); - } - - /* Get operand and set stack entry to null */ - - *Object = WalkState->Operands [WalkState->NumOperands]; - WalkState->Operands [WalkState->NumOperands] = NULL; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", - *Object, AcpiUtGetObjectTypeName (*Object), - WalkState, WalkState->NumOperands)); - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDsObjStackGetValue - * - * PARAMETERS: Index - Stack index whose value is desired. Based - * on the top of the stack (index=0 == top) - * WalkState - Current Walk state - * - * RETURN: Pointer to the requested operand - * - * DESCRIPTION: Retrieve an object from this walk's operand stack. Index must - * be within the range of the current stack pointer. - * - ******************************************************************************/ - -void * -AcpiDsObjStackGetValue ( - UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - - ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); - - - /* Can't do it if the stack is empty */ - - if (WalkState->NumOperands == 0) - { - return_PTR (NULL); - } - - /* or if the index is past the top of the stack */ - - if (Index > (WalkState->NumOperands - (UINT32) 1)) - { - return_PTR (NULL); - } - - return_PTR (WalkState->Operands[(ACPI_NATIVE_UINT)(WalkState->NumOperands - 1) - - Index]); -} -#endif - - diff --git a/sys/dist/acpica/evevent.c b/sys/dist/acpica/evevent.c index ceffe7dcf6e..4c2833d2937 100644 --- a/sys/dist/acpica/evevent.c +++ b/sys/dist/acpica/evevent.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evevent - Fixed Event handling and dispatch - * xRevision: 1.121 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,11 +114,8 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evevent.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evevent") @@ -153,16 +150,8 @@ AcpiEvInitializeEvents ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvInitializeEvents"); - - - /* Make sure we have ACPI tables */ + ACPI_FUNCTION_TRACE (EvInitializeEvents); - if (!AcpiGbl_DSDT) - { - ACPI_WARNING ((AE_INFO, "No ACPI tables present!")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } /* * Initialize the Fixed and General Purpose Events. This is done prior to @@ -211,7 +200,7 @@ AcpiEvInstallFadtGpes ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvInstallFadtGpes"); + ACPI_FUNCTION_TRACE (EvInstallFadtGpes); /* Namespace must be locked */ @@ -256,7 +245,7 @@ AcpiEvInstallXruptHandlers ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvInstallXruptHandlers"); + ACPI_FUNCTION_TRACE (EvInstallXruptHandlers); /* Install the SCI handler */ @@ -318,8 +307,7 @@ AcpiEvFixedEventInitialize ( if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) { Status = AcpiSetRegister ( - AcpiGbl_FixedEventInfo[i].EnableRegisterId, - 0, ACPI_MTX_LOCK); + AcpiGbl_FixedEventInfo[i].EnableRegisterId, 0); if (ACPI_FAILURE (Status)) { return (Status); @@ -353,7 +341,7 @@ AcpiEvFixedEventDetect ( ACPI_NATIVE_UINT i; - ACPI_FUNCTION_NAME ("EvFixedEventDetect"); + ACPI_FUNCTION_NAME (EvFixedEventDetect); /* @@ -413,8 +401,7 @@ AcpiEvFixedEventDispatch ( /* Clear the status bit */ - (void) AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, - 1, ACPI_MTX_DO_NOT_LOCK); + (void) AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, 1); /* * Make sure we've got a handler. If not, report an error. @@ -422,8 +409,7 @@ AcpiEvFixedEventDispatch ( */ if (NULL == AcpiGbl_FixedEventHandlers[Event].Handler) { - (void) AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - 0, ACPI_MTX_DO_NOT_LOCK); + (void) AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 0); ACPI_ERROR ((AE_INFO, "No installed handler for fixed event [%08X]", diff --git a/sys/dist/acpica/evgpe.c b/sys/dist/acpica/evgpe.c index 7e4faf35b38..02d7da63107 100644 --- a/sys/dist/acpica/evgpe.c +++ b/sys/dist/acpica/evgpe.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evgpe - General Purpose Event handling and dispatch - * xRevision: 1.57 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,12 +114,9 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evgpe.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evgpe") @@ -152,7 +149,7 @@ AcpiEvSetGpeType ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvSetGpeType"); + ACPI_FUNCTION_TRACE (EvSetGpeType); /* Validate type and update register enable masks */ @@ -203,7 +200,7 @@ AcpiEvUpdateGpeEnableMasks ( UINT8 RegisterBit; - ACPI_FUNCTION_TRACE ("EvUpdateGpeEnableMasks"); + ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMasks); GpeRegisterInfo = GpeEventInfo->RegisterInfo; @@ -211,7 +208,8 @@ AcpiEvUpdateGpeEnableMasks ( { return_ACPI_STATUS (AE_NOT_EXIST); } - RegisterBit = GpeEventInfo->RegisterBit; + RegisterBit = (UINT8) + (1 << (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber)); /* 1) Disable case. Simply clear all enable bits */ @@ -271,7 +269,7 @@ AcpiEvEnableGpe ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvEnableGpe"); + ACPI_FUNCTION_TRACE (EvEnableGpe); /* Make sure HW enable masks are updated */ @@ -344,7 +342,7 @@ AcpiEvDisableGpe ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvDisableGpe"); + ACPI_FUNCTION_TRACE (EvDisableGpe); if (!(GpeEventInfo->Flags & ACPI_GPE_ENABLE_MASK)) @@ -496,7 +494,7 @@ AcpiEvGpeDetect ( ACPI_NATIVE_UINT j; - ACPI_FUNCTION_NAME ("EvGpeDetect"); + ACPI_FUNCTION_NAME (EvGpeDetect); /* Check for the case where there are no GPEs */ @@ -505,9 +503,15 @@ AcpiEvGpeDetect ( return (IntStatus); } + /* + * We need to obtain the GPE lock for both the data structs and registers + * Note: Not necessary to obtain the hardware lock, since the GPE registers + * are owned by the GpeLock. + */ + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + /* Examine all GPE blocks attached to this interrupt level */ - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); GpeBlock = GpeXruptList->GpeBlockListHead; while (GpeBlock) { @@ -560,7 +564,7 @@ AcpiEvGpeDetect ( { /* Examine one GPE bit */ - if (EnabledStatusByte & AcpiGbl_DecodeTo8bit[j]) + if (EnabledStatusByte & (1 << j)) { /* * Found an active GPE. Dispatch the event to a handler @@ -591,9 +595,9 @@ UnlockAndExit: * * RETURN: None * - * DESCRIPTION: Perform the actual execution of a GPE control method. This - * function is called from an invocation of AcpiOsQueueForExecution - * (and therefore does NOT execute at interrupt level) so that + * DESCRIPTION: Perform the actual execution of a GPE control method. This + * function is called from an invocation of AcpiOsExecute and + * therefore does NOT execute at interrupt level - so that * the control method itself is not executed in the context of * an interrupt handler. * @@ -604,13 +608,12 @@ AcpiEvAsynchExecuteGpeMethod ( void *Context) { ACPI_GPE_EVENT_INFO *GpeEventInfo = (void *) Context; - UINT32 GpeNumber = 0; ACPI_STATUS Status; ACPI_GPE_EVENT_INFO LocalGpeEventInfo; - ACPI_PARAMETER_INFO Info; + ACPI_EVALUATE_INFO *Info; - ACPI_FUNCTION_TRACE ("EvAsynchExecuteGpeMethod"); + ACPI_FUNCTION_TRACE (EvAsynchExecuteGpeMethod); Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); @@ -651,21 +654,33 @@ AcpiEvAsynchExecuteGpeMethod ( if ((LocalGpeEventInfo.Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) { - /* - * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx - * control method that corresponds to this GPE - */ - Info.Node = LocalGpeEventInfo.Dispatch.MethodNode; - Info.Parameters = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT *, GpeEventInfo); - Info.ParameterType = ACPI_PARAM_GPE; + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + Status = AE_NO_MEMORY; + } + else + { + /* + * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx + * control method that corresponds to this GPE + */ + Info->PrefixNode = LocalGpeEventInfo.Dispatch.MethodNode; + Info->Parameters = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT *, GpeEventInfo); + Info->ParameterType = ACPI_PARAM_GPE; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info); + ACPI_FREE (Info); + } - Status = AcpiNsEvaluateByHandle (&Info); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "While evaluating method [%4.4s] for GPE[%2X]", - AcpiUtGetNodeName (LocalGpeEventInfo.Dispatch.MethodNode), - GpeNumber)); + "while evaluating GPE method [%4.4s]", + AcpiUtGetNodeName (LocalGpeEventInfo.Dispatch.MethodNode))); } } @@ -714,9 +729,11 @@ AcpiEvGpeDispatch ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvGpeDispatch"); + ACPI_FUNCTION_TRACE (EvGpeDispatch); + AcpiGpeCount++; + /* * If edge-triggered, clear the GPE status bit now. Note that * level-triggered events are cleared after the GPE is serviced. @@ -733,23 +750,24 @@ AcpiEvGpeDispatch ( } } - /* Save current system state */ - - if (AcpiGbl_SystemAwakeAndRunning) - { - ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_SYSTEM_RUNNING); - } - else + if (!AcpiGbl_SystemAwakeAndRunning) { - ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_SYSTEM_RUNNING); + /* + * We just woke up because of a wake GPE. Disable any further GPEs + * until we are fully up and running (Only wake GPEs should be enabled + * at this time, but we just brute-force disable them all.) + * 1) We must disable this particular wake GPE so it won't fire again + * 2) We want to disable all wake GPEs, since we are now awake + */ + (void) AcpiHwDisableAllGpes (); } /* - * Dispatch the GPE to either an installed handler, or the control - * method associated with this GPE (_Lxx or _Exx). - * If a handler exists, we invoke it and do not attempt to run the method. - * If there is neither a handler nor a method, we disable the level to - * prevent further events from coming in here. + * Dispatch the GPE to either an installed handler, or the control method + * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke + * it and do not attempt to run the method. If there is neither a handler + * nor a method, we disable this GPE to prevent further such pointless + * events from firing. */ switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) { @@ -780,8 +798,8 @@ AcpiEvGpeDispatch ( case ACPI_GPE_DISPATCH_METHOD: /* - * Disable GPE, so it doesn't keep firing before the method has a - * chance to run. + * Disable the GPE, so it doesn't keep firing before the method has a + * chance to run (it runs asynchronously with interrupts enabled). */ Status = AcpiEvDisableGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) @@ -795,7 +813,7 @@ AcpiEvGpeDispatch ( * Execute the method associated with the GPE * NOTE: Level-triggered GPEs are cleared after the method completes. */ - Status = AcpiOsQueueForExecution (OSD_PRIORITY_GPE, + Status = AcpiOsExecute (OSL_GPE_HANDLER, AcpiEvAsynchExecuteGpeMethod, GpeEventInfo); if (ACPI_FAILURE (Status)) { @@ -814,7 +832,7 @@ AcpiEvGpeDispatch ( GpeNumber)); /* - * Disable the GPE. The GPE will remain disabled until the ACPI + * Disable the GPE. The GPE will remain disabled until the ACPI * Core Subsystem is restarted, or a handler is installed. */ Status = AcpiEvDisableGpe (GpeEventInfo); @@ -830,55 +848,3 @@ AcpiEvGpeDispatch ( return_UINT32 (ACPI_INTERRUPT_HANDLED); } - -#ifdef ACPI_GPE_NOTIFY_CHECK -/******************************************************************************* - * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED - * - * FUNCTION: AcpiEvCheckForWakeOnlyGpe - * - * PARAMETERS: GpeEventInfo - info for this GPE - * - * RETURN: Status - * - * DESCRIPTION: Determine if a a GPE is "wake-only". - * - * Called from Notify() code in interpreter when a "DeviceWake" - * Notify comes in. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvCheckForWakeOnlyGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE ("EvCheckForWakeOnlyGpe"); - - - if ((GpeEventInfo) && /* Only >0 for _Lxx/_Exx */ - ((GpeEventInfo->Flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ - { - /* This must be a wake-only GPE, disable it */ - - Status = AcpiEvDisableGpe (GpeEventInfo); - - /* Set GPE to wake-only. Do not change wake disabled/enabled status */ - - AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE); - - ACPI_INFO ((AE_INFO, "GPE %p was updated from wake/run to wake-only", - GpeEventInfo)); - - /* This was a wake-only GPE */ - - return_ACPI_STATUS (AE_WAKE_ONLY_GPE); - } - - return_ACPI_STATUS (AE_OK); -} -#endif - - diff --git a/sys/dist/acpica/evgpeblk.c b/sys/dist/acpica/evgpeblk.c index e5b75df4880..9e7d4eb6e9f 100644 --- a/sys/dist/acpica/evgpeblk.c +++ b/sys/dist/acpica/evgpeblk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evgpeblk - GPE block creation and initialization. - * xRevision: 1.53 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,12 +114,9 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evgpeblk.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evgpeblk") @@ -234,7 +231,7 @@ AcpiEvWalkGpeList ( ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE ("EvWalkGpeList"); + ACPI_FUNCTION_TRACE (EvWalkGpeList); Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); @@ -293,7 +290,7 @@ AcpiEvDeleteGpeHandlers ( ACPI_NATIVE_UINT j; - ACPI_FUNCTION_TRACE ("EvDeleteGpeHandlers"); + ACPI_FUNCTION_TRACE (EvDeleteGpeHandlers); /* Examine each GPE Register within the block */ @@ -309,7 +306,7 @@ AcpiEvDeleteGpeHandlers ( if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { - ACPI_MEM_FREE (GpeEventInfo->Dispatch.Handler); + ACPI_FREE (GpeEventInfo->Dispatch.Handler); GpeEventInfo->Dispatch.Handler = NULL; GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; } @@ -357,7 +354,7 @@ AcpiEvSaveMethodInfo ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvSaveMethodInfo"); + ACPI_FUNCTION_TRACE (EvSaveMethodInfo); /* @@ -389,8 +386,8 @@ AcpiEvSaveMethodInfo ( default: /* Unknown method type, just ignore it! */ - ACPI_ERROR ((AE_INFO, - "Unknown GPE method type: %s (name not of form _Lxx or _Exx)", + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Ignoring unknown GPE method type: %s (name not of form _Lxx or _Exx)", Name)); return_ACPI_STATUS (AE_OK); } @@ -402,7 +399,7 @@ AcpiEvSaveMethodInfo ( { /* Conversion failed; invalid method, just ignore it */ - ACPI_ERROR ((AE_INFO, + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)", Name)); return_ACPI_STATUS (AE_OK); @@ -477,7 +474,7 @@ AcpiEvMatchPrwAndGpe ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvMatchPrwAndGpe"); + ACPI_FUNCTION_TRACE (EvMatchPrwAndGpe); /* Check for a _PRW method under this device */ @@ -599,7 +596,7 @@ AcpiEvGetGpeXruptBlock ( ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE ("EvGetGpeXruptBlock"); + ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock); /* No need for lock since we are not changing any list elements here */ @@ -617,7 +614,7 @@ AcpiEvGetGpeXruptBlock ( /* Not found, must allocate a new xrupt descriptor */ - GpeXrupt = ACPI_MEM_CALLOCATE (sizeof (ACPI_GPE_XRUPT_INFO)); + GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO)); if (!GpeXrupt) { return_PTR (NULL); @@ -647,7 +644,7 @@ AcpiEvGetGpeXruptBlock ( /* Install new interrupt handler if not SCI_INT */ - if (InterruptNumber != AcpiGbl_FADT->SciInt) + if (InterruptNumber != AcpiGbl_FADT.SciInterrupt) { Status = AcpiOsInstallInterruptHandler (InterruptNumber, AcpiEvGpeXruptHandler, GpeXrupt); @@ -685,12 +682,12 @@ AcpiEvDeleteGpeXrupt ( ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE ("EvDeleteGpeXrupt"); + ACPI_FUNCTION_TRACE (EvDeleteGpeXrupt); /* We never want to remove the SCI interrupt handler */ - if (GpeXrupt->InterruptNumber == AcpiGbl_FADT->SciInt) + if (GpeXrupt->InterruptNumber == AcpiGbl_FADT.SciInterrupt) { GpeXrupt->GpeBlockListHead = NULL; return_ACPI_STATUS (AE_OK); @@ -721,7 +718,7 @@ AcpiEvDeleteGpeXrupt ( /* Free the block */ - ACPI_MEM_FREE (GpeXrupt); + ACPI_FREE (GpeXrupt); return_ACPI_STATUS (AE_OK); } @@ -750,7 +747,7 @@ AcpiEvInstallGpeBlock ( ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE ("EvInstallGpeBlock"); + ACPI_FUNCTION_TRACE (EvInstallGpeBlock); Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); @@ -815,7 +812,7 @@ AcpiEvDeleteGpeBlock ( ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE ("EvInstallGpeBlock"); + ACPI_FUNCTION_TRACE (EvInstallGpeBlock); Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); @@ -861,9 +858,9 @@ AcpiEvDeleteGpeBlock ( /* Free the GpeBlock */ - ACPI_MEM_FREE (GpeBlock->RegisterInfo); - ACPI_MEM_FREE (GpeBlock->EventInfo); - ACPI_MEM_FREE (GpeBlock); + ACPI_FREE (GpeBlock->RegisterInfo); + ACPI_FREE (GpeBlock->EventInfo); + ACPI_FREE (GpeBlock); UnlockAndExit: Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); @@ -896,12 +893,12 @@ AcpiEvCreateGpeInfoBlocks ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvCreateGpeInfoBlocks"); + ACPI_FUNCTION_TRACE (EvCreateGpeInfoBlocks); /* Allocate the GPE register information block */ - GpeRegisterInfo = ACPI_MEM_CALLOCATE ( + GpeRegisterInfo = ACPI_ALLOCATE_ZEROED ( (ACPI_SIZE) GpeBlock->RegisterCount * sizeof (ACPI_GPE_REGISTER_INFO)); if (!GpeRegisterInfo) @@ -915,7 +912,7 @@ AcpiEvCreateGpeInfoBlocks ( * Allocate the GPE EventInfo block. There are eight distinct GPEs * per register. Initialization to zeros is sufficient. */ - GpeEventInfo = ACPI_MEM_CALLOCATE ( + GpeEventInfo = ACPI_ALLOCATE_ZEROED ( ((ACPI_SIZE) GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) * sizeof (ACPI_GPE_EVENT_INFO)); @@ -948,27 +945,24 @@ AcpiEvCreateGpeInfoBlocks ( ThisRegister->BaseGpeNumber = (UINT8) (GpeBlock->BlockBaseNumber + (i * ACPI_GPE_REGISTER_WIDTH)); - ACPI_STORE_ADDRESS (ThisRegister->StatusAddress.Address, - (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address) - + i)); + ThisRegister->StatusAddress.Address = + GpeBlock->BlockAddress.Address + i; - ACPI_STORE_ADDRESS (ThisRegister->EnableAddress.Address, - (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address) - + i - + GpeBlock->RegisterCount)); + ThisRegister->EnableAddress.Address = + GpeBlock->BlockAddress.Address + i + GpeBlock->RegisterCount; - ThisRegister->StatusAddress.AddressSpaceId = GpeBlock->BlockAddress.AddressSpaceId; - ThisRegister->EnableAddress.AddressSpaceId = GpeBlock->BlockAddress.AddressSpaceId; - ThisRegister->StatusAddress.RegisterBitWidth = ACPI_GPE_REGISTER_WIDTH; - ThisRegister->EnableAddress.RegisterBitWidth = ACPI_GPE_REGISTER_WIDTH; - ThisRegister->StatusAddress.RegisterBitOffset = ACPI_GPE_REGISTER_WIDTH; - ThisRegister->EnableAddress.RegisterBitOffset = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->StatusAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; + ThisRegister->EnableAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; + ThisRegister->StatusAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->EnableAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->StatusAddress.BitOffset = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->EnableAddress.BitOffset = ACPI_GPE_REGISTER_WIDTH; /* Init the EventInfo for each GPE within this register */ for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { - ThisEvent->RegisterBit = AcpiGbl_DecodeTo8bit[j]; + ThisEvent->GpeNumber = (UINT8) (ThisRegister->BaseGpeNumber + j); ThisEvent->RegisterInfo = ThisRegister; ThisEvent++; } @@ -1000,11 +994,11 @@ AcpiEvCreateGpeInfoBlocks ( ErrorExit: if (GpeRegisterInfo) { - ACPI_MEM_FREE (GpeRegisterInfo); + ACPI_FREE (GpeRegisterInfo); } if (GpeEventInfo) { - ACPI_MEM_FREE (GpeEventInfo); + ACPI_FREE (GpeEventInfo); } return_ACPI_STATUS (Status); @@ -1043,7 +1037,7 @@ AcpiEvCreateGpeBlock ( ACPI_GPE_BLOCK_INFO *GpeBlock; - ACPI_FUNCTION_TRACE ("EvCreateGpeBlock"); + ACPI_FUNCTION_TRACE (EvCreateGpeBlock); if (!RegisterCount) @@ -1053,7 +1047,7 @@ AcpiEvCreateGpeBlock ( /* Allocate a new GPE block */ - GpeBlock = ACPI_MEM_CALLOCATE (sizeof (ACPI_GPE_BLOCK_INFO)); + GpeBlock = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_BLOCK_INFO)); if (!GpeBlock) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -1075,7 +1069,7 @@ AcpiEvCreateGpeBlock ( Status = AcpiEvCreateGpeInfoBlocks (GpeBlock); if (ACPI_FAILURE (Status)) { - ACPI_MEM_FREE (GpeBlock); + ACPI_FREE (GpeBlock); return_ACPI_STATUS (Status); } @@ -1084,7 +1078,7 @@ AcpiEvCreateGpeBlock ( Status = AcpiEvInstallGpeBlock (GpeBlock, InterruptNumber); if (ACPI_FAILURE (Status)) { - ACPI_MEM_FREE (GpeBlock); + ACPI_FREE (GpeBlock); return_ACPI_STATUS (Status); } @@ -1144,7 +1138,7 @@ AcpiEvInitializeGpeBlock ( ACPI_NATIVE_UINT j; - ACPI_FUNCTION_TRACE ("EvInitializeGpeBlock"); + ACPI_FUNCTION_TRACE (EvInitializeGpeBlock); /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */ @@ -1245,7 +1239,7 @@ AcpiEvGpeInitialize ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvGpeInitialize"); + ACPI_FUNCTION_TRACE (EvGpeInitialize); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); @@ -1279,20 +1273,20 @@ AcpiEvGpeInitialize ( * If EITHER the register length OR the block address are zero, then that * particular block is not supported. */ - if (AcpiGbl_FADT->Gpe0BlkLen && - ACPI_GET_ADDRESS (AcpiGbl_FADT->XGpe0Blk.Address)) + if (AcpiGbl_FADT.Gpe0BlockLength && + AcpiGbl_FADT.XGpe0Block.Address) { /* GPE block 0 exists (has both length and address > 0) */ - RegisterCount0 = (UINT16) (AcpiGbl_FADT->Gpe0BlkLen / 2); + RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2); GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1; /* Install GPE Block 0 */ Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - &AcpiGbl_FADT->XGpe0Blk, RegisterCount0, 0, - AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[0]); + &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); if (ACPI_FAILURE (Status)) { @@ -1301,22 +1295,22 @@ AcpiEvGpeInitialize ( } } - if (AcpiGbl_FADT->Gpe1BlkLen && - ACPI_GET_ADDRESS (AcpiGbl_FADT->XGpe1Blk.Address)) + if (AcpiGbl_FADT.Gpe1BlockLength && + AcpiGbl_FADT.XGpe1Block.Address) { /* GPE block 1 exists (has both length and address > 0) */ - RegisterCount1 = (UINT16) (AcpiGbl_FADT->Gpe1BlkLen / 2); + RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2); /* Check for GPE0/GPE1 overlap (if both banks exist) */ if ((RegisterCount0) && - (GpeNumberMax >= AcpiGbl_FADT->Gpe1Base)) + (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base)) { ACPI_ERROR ((AE_INFO, "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1", - GpeNumberMax, AcpiGbl_FADT->Gpe1Base, - AcpiGbl_FADT->Gpe1Base + + GpeNumberMax, AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.Gpe1Base + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1))); /* Ignore GPE1 block by setting the register count to zero */ @@ -1328,9 +1322,9 @@ AcpiEvGpeInitialize ( /* Install GPE Block 1 */ Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - &AcpiGbl_FADT->XGpe1Blk, RegisterCount1, - AcpiGbl_FADT->Gpe1Base, - AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[1]); + &AcpiGbl_FADT.XGpe1Block, RegisterCount1, + AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); if (ACPI_FAILURE (Status)) { @@ -1342,7 +1336,7 @@ AcpiEvGpeInitialize ( * GPE0 and GPE1 do not have to be contiguous in the GPE number * space. However, GPE0 always starts at GPE number zero. */ - GpeNumberMax = AcpiGbl_FADT->Gpe1Base + + GpeNumberMax = AcpiGbl_FADT.Gpe1Base + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); } } diff --git a/sys/dist/acpica/evmisc.c b/sys/dist/acpica/evmisc.c index 5472a22f02b..44713afd256 100644 --- a/sys/dist/acpica/evmisc.c +++ b/sys/dist/acpica/evmisc.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evmisc - Miscellaneous event manager support functions - * xRevision: 1.89 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,25 +114,24 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evmisc.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evmisc") +/* Names for Notify() values, used for debug output */ + #ifdef ACPI_DEBUG_OUTPUT static const char *AcpiNotifyValueNames[] = { "Bus Check", "Device Check", "Device Wake", - "Eject request", + "Eject Request", "Device Check Light", "Frequency Mismatch", "Bus Mode Mismatch", @@ -140,20 +139,24 @@ static const char *AcpiNotifyValueNames[] = }; #endif +/* Pointer to FACS needed for the Global Lock */ + +static ACPI_TABLE_FACS *Facs = NULL; + /* Local prototypes */ static void ACPI_SYSTEM_XFACE AcpiEvNotifyDispatch ( void *Context); -static void ACPI_SYSTEM_XFACE -AcpiEvGlobalLockThread ( - void *Context); - static UINT32 AcpiEvGlobalLockHandler ( void *Context); +static ACPI_STATUS +AcpiEvRemoveGlobalLockHandler ( + void); + /******************************************************************************* * @@ -215,7 +218,7 @@ AcpiEvQueueNotifyRequest ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_NAME ("EvQueueNotifyRequest"); + ACPI_FUNCTION_NAME (EvQueueNotifyRequest); /* @@ -231,7 +234,7 @@ AcpiEvQueueNotifyRequest ( if (NotifyValue <= 7) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: %s\n", - AcpiNotifyValueNames[NotifyValue])); + AcpiNotifyValueNames[NotifyValue])); } else { @@ -282,13 +285,13 @@ AcpiEvQueueNotifyRequest ( return (AE_NO_MEMORY); } - NotifyInfo->Common.DataType = ACPI_DESC_TYPE_STATE_NOTIFY; - NotifyInfo->Notify.Node = Node; - NotifyInfo->Notify.Value = (UINT16) NotifyValue; + NotifyInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY; + NotifyInfo->Notify.Node = Node; + NotifyInfo->Notify.Value = (UINT16) NotifyValue; NotifyInfo->Notify.HandlerObj = HandlerObj; - Status = AcpiOsQueueForExecution (OSD_PRIORITY_HIGH, - AcpiEvNotifyDispatch, NotifyInfo); + Status = AcpiOsExecute ( + OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, NotifyInfo); if (ACPI_FAILURE (Status)) { AcpiUtDeleteGenericState (NotifyInfo); @@ -388,52 +391,19 @@ AcpiEvNotifyDispatch ( /******************************************************************************* * - * FUNCTION: AcpiEvGlobalLockThread - * - * PARAMETERS: Context - From thread interface, not used - * - * RETURN: None - * - * DESCRIPTION: Invoked by SCI interrupt handler upon acquisition of the - * Global Lock. Simply signal all threads that are waiting - * for the lock. - * - ******************************************************************************/ - -static void ACPI_SYSTEM_XFACE -AcpiEvGlobalLockThread ( - void *Context) -{ - ACPI_STATUS Status; - - - /* Signal threads that are waiting for the lock */ - - if (AcpiGbl_GlobalLockThreadCount) - { - /* Send sufficient units to the semaphore */ - - Status = AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, - AcpiGbl_GlobalLockThreadCount); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, "Could not signal Global Lock semaphore")); - } - } -} - - -/******************************************************************************* - * * FUNCTION: AcpiEvGlobalLockHandler * * PARAMETERS: Context - From thread interface, not used * - * RETURN: ACPI_INTERRUPT_HANDLED or ACPI_INTERRUPT_NOT_HANDLED + * RETURN: ACPI_INTERRUPT_HANDLED * * DESCRIPTION: Invoked directly from the SCI handler when a global lock - * release interrupt occurs. Grab the global lock and queue - * the global lock thread for execution + * release interrupt occurs. Attempt to acquire the global lock, + * if successful, signal the thread waiting for the lock. + * + * NOTE: Assumes that the semaphore can be signaled from interrupt level. If + * this is not possible for some reason, a separate thread will have to be + * scheduled to do this. * ******************************************************************************/ @@ -446,27 +416,24 @@ AcpiEvGlobalLockHandler ( /* - * Attempt to get the lock + * Attempt to get the lock. + * * If we don't get it now, it will be marked pending and we will * take another interrupt when it becomes free. */ - ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Acquired); + ACPI_ACQUIRE_GLOBAL_LOCK (Facs, Acquired); if (Acquired) { - /* Got the lock, now wake all threads waiting for it */ + /* Got the lock, now wake the thread waiting for it */ AcpiGbl_GlobalLockAcquired = TRUE; - /* Run the Global Lock thread which will signal all waiting threads */ + /* Send a unit to the semaphore */ - Status = AcpiOsQueueForExecution (OSD_PRIORITY_HIGH, - AcpiEvGlobalLockThread, Context); + Status = AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, 1); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not queue Global Lock thread")); - - return (ACPI_INTERRUPT_NOT_HANDLED); + ACPI_ERROR ((AE_INFO, "Could not signal Global Lock semaphore")); } } @@ -493,8 +460,15 @@ AcpiEvInitGlobalLockHandler ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvInitGlobalLockHandler"); + ACPI_FUNCTION_TRACE (EvInitGlobalLockHandler); + + Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, + ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } AcpiGbl_GlobalLockPresent = TRUE; Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, @@ -520,6 +494,35 @@ AcpiEvInitGlobalLockHandler ( } +/******************************************************************************* + * + * FUNCTION: AcpiEvRemoveGlobalLockHandler + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Remove the handler for the Global Lock + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvRemoveGlobalLockHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvRemoveGlobalLockHandler); + + AcpiGbl_GlobalLockPresent = FALSE; + Status = AcpiRemoveFixedEventHandler (ACPI_EVENT_GLOBAL, + AcpiEvGlobalLockHandler); + + return_ACPI_STATUS (Status); +} + + /****************************************************************************** * * FUNCTION: AcpiEvAcquireGlobalLock @@ -530,6 +533,16 @@ AcpiEvInitGlobalLockHandler ( * * DESCRIPTION: Attempt to gain ownership of the Global Lock. * + * MUTEX: Interpreter must be locked + * + * Note: The original implementation allowed multiple threads to "acquire" the + * Global Lock, and the OS would hold the lock until the last thread had + * released it. However, this could potentially starve the BIOS out of the + * lock, especially in the case where there is a tight handshake between the + * Embedded Controller driver and the BIOS. Therefore, this implementation + * allows only one thread to acquire the HW Global Lock at a time, and makes + * the global lock appear as a standard mutex on the OS side. + * *****************************************************************************/ ACPI_STATUS @@ -540,56 +553,70 @@ AcpiEvAcquireGlobalLock ( BOOLEAN Acquired = FALSE; - ACPI_FUNCTION_TRACE ("EvAcquireGlobalLock"); + ACPI_FUNCTION_TRACE (EvAcquireGlobalLock); -#ifndef ACPI_APPLICATION - /* Make sure that we actually have a global lock */ - - if (!AcpiGbl_GlobalLockPresent) + /* + * Only one thread can acquire the GL at a time, the GlobalLockMutex + * enforces this. This interface releases the interpreter if we must wait. + */ + Status = AcpiExSystemWaitMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex, + Timeout); + if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (AE_NO_GLOBAL_LOCK); + return_ACPI_STATUS (Status); } -#endif - - /* One more thread wants the global lock */ - AcpiGbl_GlobalLockThreadCount++; + /* + * Update the global lock handle and check for wraparound. The handle is + * only used for the external global lock interfaces, but it is updated + * here to properly handle the case where a single thread may acquire the + * lock via both the AML and the AcpiAcquireGlobalLock interfaces. The + * handle is therefore updated on the first acquire from a given thread + * regardless of where the acquisition request originated. + */ + AcpiGbl_GlobalLockHandle++; + if (AcpiGbl_GlobalLockHandle == 0) + { + AcpiGbl_GlobalLockHandle = 1; + } /* - * If we (OS side vs. BIOS side) have the hardware lock already, - * we are done + * Make sure that a global lock actually exists. If not, just treat + * the lock as a standard mutex. */ - if (AcpiGbl_GlobalLockAcquired) + if (!AcpiGbl_GlobalLockPresent) { + AcpiGbl_GlobalLockAcquired = TRUE; return_ACPI_STATUS (AE_OK); } - /* We must acquire the actual hardware lock */ + /* Attempt to acquire the actual hardware lock */ - ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Acquired); + ACPI_ACQUIRE_GLOBAL_LOCK (Facs, Acquired); if (Acquired) { /* We got the lock */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired hardware Global Lock\n")); AcpiGbl_GlobalLockAcquired = TRUE; return_ACPI_STATUS (AE_OK); } /* - * Did not get the lock. The pending bit was set above, and we must now + * Did not get the lock. The pending bit was set above, and we must now * wait until we get the global lock released interrupt. */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for hardware Global Lock\n")); /* - * Acquire the global lock semaphore first. - * Since this wait will block, we must release the interpreter + * Wait for handshake with the global lock interrupt handler. + * This interface releases the interpreter if we must wait. */ Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, - Timeout); + ACPI_WAIT_FOREVER); + return_ACPI_STATUS (Status); } @@ -614,43 +641,42 @@ AcpiEvReleaseGlobalLock ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("EvReleaseGlobalLock"); + ACPI_FUNCTION_TRACE (EvReleaseGlobalLock); + + /* Lock must be already acquired */ - if (!AcpiGbl_GlobalLockThreadCount) + if (!AcpiGbl_GlobalLockAcquired) { ACPI_WARNING ((AE_INFO, - "Cannot release HW Global Lock, it has not been acquired")); + "Cannot release the ACPI Global Lock, it has not been acquired")); return_ACPI_STATUS (AE_NOT_ACQUIRED); } - /* One fewer thread has the global lock */ - - AcpiGbl_GlobalLockThreadCount--; - if (AcpiGbl_GlobalLockThreadCount) + if (AcpiGbl_GlobalLockPresent) { - /* There are still some threads holding the lock, cannot release */ + /* Allow any thread to release the lock */ - return_ACPI_STATUS (AE_OK); + ACPI_RELEASE_GLOBAL_LOCK (Facs, Pending); + + /* + * If the pending bit was set, we must write GBL_RLS to the control + * register + */ + if (Pending) + { + Status = AcpiSetRegister ( + ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Released hardware Global Lock\n")); } - /* - * No more threads holding lock, we can do the actual hardware - * release - */ - ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Pending); AcpiGbl_GlobalLockAcquired = FALSE; - /* - * If the pending bit was set, we must write GBL_RLS to the control - * register - */ - if (Pending) - { - Status = AcpiSetRegister (ACPI_BITREG_GLOBAL_LOCK_RELEASE, - 1, ACPI_MTX_LOCK); - } + /* Release the local GL mutex */ + AcpiOsReleaseMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex); return_ACPI_STATUS (Status); } @@ -675,7 +701,7 @@ AcpiEvTerminate ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvTerminate"); + ACPI_FUNCTION_TRACE (EvTerminate); if (AcpiGbl_EventsInitialized) @@ -709,6 +735,13 @@ AcpiEvTerminate ( ACPI_ERROR ((AE_INFO, "Could not remove SCI handler")); } + + Status = AcpiEvRemoveGlobalLockHandler (); + if (ACPI_FAILURE(Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not remove Global Lock handler")); + } } /* Deallocate all handler objects installed within GPE info structs */ diff --git a/sys/dist/acpica/evregion.c b/sys/dist/acpica/evregion.c index d4ac40ff2ae..b7e8ea00d75 100644 --- a/sys/dist/acpica/evregion.c +++ b/sys/dist/acpica/evregion.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch - * xRevision: 1.159 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,26 +115,25 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evregion.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __EVREGION_C__ -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evregion") #define ACPI_NUM_DEFAULT_SPACES 4 -static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = { - ACPI_ADR_SPACE_SYSTEM_MEMORY, - ACPI_ADR_SPACE_SYSTEM_IO, - ACPI_ADR_SPACE_PCI_CONFIG, - ACPI_ADR_SPACE_DATA_TABLE}; +static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = +{ + ACPI_ADR_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_IO, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_ADR_SPACE_DATA_TABLE +}; /* Local prototypes */ @@ -173,7 +172,7 @@ AcpiEvInstallRegionHandlers ( ACPI_NATIVE_UINT i; - ACPI_FUNCTION_TRACE ("EvInstallRegionHandlers"); + ACPI_FUNCTION_TRACE (EvInstallRegionHandlers); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); @@ -203,8 +202,8 @@ AcpiEvInstallRegionHandlers ( for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode, - AcpiGbl_DefaultAddressSpaces[i], - ACPI_DEFAULT_HANDLER, NULL, NULL); + AcpiGbl_DefaultAddressSpaces[i], + ACPI_DEFAULT_HANDLER, NULL, NULL); switch (Status) { case AE_OK: @@ -249,7 +248,7 @@ AcpiEvInitializeOpRegions ( ACPI_NATIVE_UINT i; - ACPI_FUNCTION_TRACE ("EvInitializeOpRegions"); + ACPI_FUNCTION_TRACE (EvInitializeOpRegions); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); @@ -267,7 +266,7 @@ AcpiEvInitializeOpRegions ( * _REG will have already been run. */ Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, - AcpiGbl_DefaultAddressSpaces[i]); + AcpiGbl_DefaultAddressSpaces[i]); } (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -293,13 +292,13 @@ AcpiEvExecuteRegMethod ( ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function) { - ACPI_PARAMETER_INFO Info; - ACPI_OPERAND_OBJECT *Params[3]; + ACPI_EVALUATE_INFO *Info; + ACPI_OPERAND_OBJECT *Args[3]; ACPI_OPERAND_OBJECT *RegionObj2; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvExecuteRegMethod"); + ACPI_FUNCTION_TRACE (EvExecuteRegMethod); RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); @@ -313,50 +312,63 @@ AcpiEvExecuteRegMethod ( return_ACPI_STATUS (AE_OK); } + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = RegionObj2->Extra.Method_REG; + Info->Pathname = NULL; + Info->Parameters = Args; + Info->ParameterType = ACPI_PARAM_ARGS; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + /* * The _REG method has two arguments: * - * Arg0, Integer: Operation region space ID - * Same value as RegionObj->Region.SpaceId - * Arg1, Integer: connection status - * 1 for connecting the handler, - * 0 for disconnecting the handler - * Passed as a parameter + * Arg0 - Integer: + * Operation region space ID Same value as RegionObj->Region.SpaceId + * + * Arg1 - Integer: + * connection status 1 for connecting the handler, 0 for disconnecting + * the handler (Passed as a parameter) */ - Params[0] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!Params[0]) + Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!Args[0]) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup1; } - Params[1] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!Params[1]) + Args[1] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!Args[1]) { Status = AE_NO_MEMORY; - goto Cleanup; + goto Cleanup2; } /* Setup the parameter objects */ - Params[0]->Integer.Value = RegionObj->Region.SpaceId; - Params[1]->Integer.Value = Function; - Params[2] = NULL; - - Info.Node = RegionObj2->Extra.Method_REG; - Info.Parameters = Params; - Info.ParameterType = ACPI_PARAM_ARGS; + Args[0]->Integer.Value = RegionObj->Region.SpaceId; + Args[1]->Integer.Value = Function; + Args[2] = NULL; /* Execute the method, no return value */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( - ACPI_TYPE_METHOD, Info.Node, NULL)); - Status = AcpiNsEvaluateByHandle (&Info); + ACPI_DEBUG_EXEC ( + AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Info->PrefixNode, NULL)); - AcpiUtRemoveReference (Params[1]); + Status = AcpiNsEvaluate (Info); + AcpiUtRemoveReference (Args[1]); -Cleanup: - AcpiUtRemoveReference (Params[0]); +Cleanup2: + AcpiUtRemoveReference (Args[0]); +Cleanup1: + ACPI_FREE (Info); return_ACPI_STATUS (Status); } @@ -369,7 +381,8 @@ Cleanup: * Function - Read or Write operation * Address - Where in the space to read or write * BitWidth - Field width in bits (8, 16, 32, or 64) - * Value - Pointer to in or out value + * Value - Pointer to in or out value, must be + * full 64-bit ACPI_INTEGER * * RETURN: Status * @@ -384,10 +397,9 @@ AcpiEvAddressSpaceDispatch ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, - void *Value) + ACPI_INTEGER *Value) { ACPI_STATUS Status; - ACPI_STATUS Status2; ACPI_ADR_SPACE_HANDLER Handler; ACPI_ADR_SPACE_SETUP RegionSetup; ACPI_OPERAND_OBJECT *HandlerDesc; @@ -395,7 +407,7 @@ AcpiEvAddressSpaceDispatch ( void *RegionContext = NULL; - ACPI_FUNCTION_TRACE ("EvAddressSpaceDispatch"); + ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch); RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); @@ -442,18 +454,14 @@ AcpiEvAddressSpaceDispatch ( * setup will potentially execute control methods * (e.g., _REG method for this region) */ - AcpiExExitInterpreter (); + AcpiExRelinquishInterpreter (); Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE, - HandlerDesc->AddressSpace.Context, &RegionContext); + HandlerDesc->AddressSpace.Context, &RegionContext); /* Re-enter the interpreter */ - Status2 = AcpiExEnterInterpreter (); - if (ACPI_FAILURE (Status2)) - { - return_ACPI_STATUS (Status2); - } + AcpiExReacquireInterpreter (); /* Check for failure of the Region Setup */ @@ -476,7 +484,7 @@ AcpiEvAddressSpaceDispatch ( { /* The handler for this region was already installed */ - ACPI_MEM_FREE (RegionContext); + ACPI_FREE (RegionContext); } else { @@ -499,21 +507,21 @@ AcpiEvAddressSpaceDispatch ( ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (RegionObj->Region.SpaceId))); - if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + if (!(HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * For handlers other than the default (supplied) handlers, we must * exit the interpreter because the handler *might* block -- we don't * know what it will do, so we can't hold the lock on the intepreter. */ - AcpiExExitInterpreter(); + AcpiExRelinquishInterpreter(); } /* Call the handler */ Status = Handler (Function, Address, BitWidth, Value, - HandlerDesc->AddressSpace.Context, - RegionObj2->Extra.RegionContext); + HandlerDesc->AddressSpace.Context, RegionObj2->Extra.RegionContext); if (ACPI_FAILURE (Status)) { @@ -521,17 +529,14 @@ AcpiEvAddressSpaceDispatch ( AcpiUtGetRegionName (RegionObj->Region.SpaceId))); } - if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + if (!(HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * We just returned from a non-default handler, we must re-enter the * interpreter */ - Status2 = AcpiExEnterInterpreter (); - if (ACPI_FAILURE (Status2)) - { - return_ACPI_STATUS (Status2); - } + AcpiExReacquireInterpreter (); } return_ACPI_STATUS (Status); @@ -566,7 +571,7 @@ AcpiEvDetachRegion( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvDetachRegion"); + ACPI_FUNCTION_TRACE (EvDetachRegion); RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); @@ -633,31 +638,36 @@ AcpiEvDetachRegion( } } - /* Call the setup handler with the deactivate notification */ + /* + * If the region has been activated, call the setup handler + * with the deactivate notification + */ + if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) + { + RegionSetup = HandlerObj->AddressSpace.Setup; + Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE, + HandlerObj->AddressSpace.Context, RegionContext); - RegionSetup = HandlerObj->AddressSpace.Setup; - Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE, - HandlerObj->AddressSpace.Context, RegionContext); + /* Init routine may fail, Just ignore errors */ - /* Init routine may fail, Just ignore errors */ + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "from region handler - deactivate, [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "from region init, [%s]", - AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + RegionObj->Region.Flags &= ~(AOPOBJ_SETUP_COMPLETE); } - RegionObj->Region.Flags &= ~(AOPOBJ_SETUP_COMPLETE); - /* * Remove handler reference in the region * - * NOTE: this doesn't mean that the region goes away - * The region is just inaccessible as indicated to - * the _REG method + * NOTE: this doesn't mean that the region goes away, the region + * is just inaccessible as indicated to the _REG method * - * If the region is on the handler's list - * this better be the region's handler + * If the region is on the handler's list, this must be the + * region's handler */ RegionObj->Region.Handler = NULL; AcpiUtRemoveReference (HandlerObj); @@ -703,7 +713,7 @@ AcpiEvAttachRegion ( BOOLEAN AcpiNsIsLocked) { - ACPI_FUNCTION_TRACE ("EvAttachRegion"); + ACPI_FUNCTION_TRACE (EvAttachRegion); ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, @@ -762,7 +772,7 @@ AcpiEvInstallHandler ( ACPI_STATUS Status; - ACPI_FUNCTION_NAME ("EvInstallHandler"); + ACPI_FUNCTION_NAME (EvInstallHandler); HandlerObj = (ACPI_OPERAND_OBJECT *) Context; @@ -899,10 +909,10 @@ AcpiEvInstallSpaceHandler ( ACPI_OPERAND_OBJECT *HandlerObj; ACPI_STATUS Status; ACPI_OBJECT_TYPE Type; - UINT16 Flags = 0; + UINT8 Flags = 0; - ACPI_FUNCTION_TRACE ("EvInstallSpaceHandler"); + ACPI_FUNCTION_TRACE (EvInstallSpaceHandler); /* @@ -1073,17 +1083,17 @@ AcpiEvInstallSpaceHandler ( /* Init handler obj */ - HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId; - HandlerObj->AddressSpace.Hflags = Flags; - HandlerObj->AddressSpace.RegionList = NULL; - HandlerObj->AddressSpace.Node = Node; - HandlerObj->AddressSpace.Handler = Handler; - HandlerObj->AddressSpace.Context = Context; - HandlerObj->AddressSpace.Setup = Setup; + HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId; + HandlerObj->AddressSpace.HandlerFlags = Flags; + HandlerObj->AddressSpace.RegionList = NULL; + HandlerObj->AddressSpace.Node = Node; + HandlerObj->AddressSpace.Handler = Handler; + HandlerObj->AddressSpace.Context = Context; + HandlerObj->AddressSpace.Setup = Setup; /* Install at head of Device.AddressSpace list */ - HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; + HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; /* * The Device object is the first reference on the HandlerObj. @@ -1104,8 +1114,8 @@ AcpiEvInstallSpaceHandler ( * of the branch */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, - HandlerObj, NULL); + ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, + HandlerObj, NULL); UnlockAndExit: return_ACPI_STATUS (Status); @@ -1134,7 +1144,7 @@ AcpiEvExecuteRegMethods ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvExecuteRegMethods"); + ACPI_FUNCTION_TRACE (EvExecuteRegMethods); /* @@ -1145,8 +1155,8 @@ AcpiEvExecuteRegMethods ( * can run any _REG methods) */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, - &SpaceId, NULL); + ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, + &SpaceId, NULL); return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/evrgnini.c b/sys/dist/acpica/evrgnini.c index ef232985fa8..0395559a265 100644 --- a/sys/dist/acpica/evrgnini.c +++ b/sys/dist/acpica/evrgnini.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init - * xRevision: 1.80 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,18 +115,25 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evrgnini.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __EVRGNINI_C__ -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evrgnini") +/* Local prototypes */ + +static BOOLEAN +AcpiEvMatchPciRootBridge ( + char *Id); + +static BOOLEAN +AcpiEvIsPciRootBridge ( + ACPI_NAMESPACE_NODE *Node); + /******************************************************************************* * @@ -154,14 +161,23 @@ AcpiEvSystemMemoryRegionSetup ( ACPI_MEM_SPACE_CONTEXT *LocalRegionContext; - ACPI_FUNCTION_TRACE ("EvSystemMemoryRegionSetup"); + ACPI_FUNCTION_TRACE (EvSystemMemoryRegionSetup); if (Function == ACPI_REGION_DEACTIVATE) { if (*RegionContext) { - ACPI_MEM_FREE (*RegionContext); + LocalRegionContext = (ACPI_MEM_SPACE_CONTEXT *) *RegionContext; + + /* Delete a cached mapping if present */ + + if (LocalRegionContext->MappedLength) + { + AcpiOsUnmapMemory (LocalRegionContext->MappedLogicalAddress, + LocalRegionContext->MappedLength); + } + ACPI_FREE (LocalRegionContext); *RegionContext = NULL; } return_ACPI_STATUS (AE_OK); @@ -169,7 +185,7 @@ AcpiEvSystemMemoryRegionSetup ( /* Create a new context */ - LocalRegionContext = ACPI_MEM_CALLOCATE (sizeof (ACPI_MEM_SPACE_CONTEXT)); + LocalRegionContext = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_MEM_SPACE_CONTEXT)); if (!(LocalRegionContext)) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -207,7 +223,7 @@ AcpiEvIoSpaceRegionSetup ( void *HandlerContext, void **RegionContext) { - ACPI_FUNCTION_TRACE ("EvIoSpaceRegionSetup"); + ACPI_FUNCTION_TRACE (EvIoSpaceRegionSetup); if (Function == ACPI_REGION_DEACTIVATE) @@ -253,11 +269,11 @@ AcpiEvPciConfigRegionSetup ( ACPI_OPERAND_OBJECT *HandlerObj; ACPI_NAMESPACE_NODE *ParentNode; ACPI_NAMESPACE_NODE *PciRootNode; + ACPI_NAMESPACE_NODE *PciDeviceNode; ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; - ACPI_DEVICE_ID ObjectHID; - ACPI_FUNCTION_TRACE ("EvPciConfigRegionSetup"); + ACPI_FUNCTION_TRACE (EvPciConfigRegionSetup); HandlerObj = RegionObj->Region.Handler; @@ -277,7 +293,7 @@ AcpiEvPciConfigRegionSetup ( { if (PciId) { - ACPI_MEM_FREE (PciId); + ACPI_FREE (PciId); } return_ACPI_STATUS (Status); } @@ -304,43 +320,35 @@ AcpiEvPciConfigRegionSetup ( PciRootNode = ParentNode; while (PciRootNode != AcpiGbl_RootNode) { - Status = AcpiUtExecute_HID (PciRootNode, &ObjectHID); - if (ACPI_SUCCESS (Status)) + /* Get the _HID/_CID in order to detect a RootBridge */ + + if (AcpiEvIsPciRootBridge (PciRootNode)) { - /* - * Got a valid _HID string, check if this is a PCI root. - * New for ACPI 3.0: check for a PCI Express root also. - */ - if (!(ACPI_STRNCMP (ObjectHID.Value, PCI_ROOT_HID_STRING, - sizeof (PCI_ROOT_HID_STRING)) || - !(ACPI_STRNCMP (ObjectHID.Value, PCI_EXPRESS_ROOT_HID_STRING, - sizeof (PCI_EXPRESS_ROOT_HID_STRING))))) - { - /* Install a handler for this PCI root bridge */ + /* Install a handler for this PCI root bridge */ - Status = AcpiInstallAddressSpaceHandler ((ACPI_HANDLE) PciRootNode, - ACPI_ADR_SPACE_PCI_CONFIG, - ACPI_DEFAULT_HANDLER, NULL, NULL); - if (ACPI_FAILURE (Status)) + Status = AcpiInstallAddressSpaceHandler ( + (ACPI_HANDLE) PciRootNode, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_SAME_HANDLER) { - if (Status == AE_SAME_HANDLER) - { - /* - * It is OK if the handler is already installed on the root - * bridge. Still need to return a context object for the - * new PCI_Config operation region, however. - */ - Status = AE_OK; - } - else - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not install PciConfig handler for Root Bridge %4.4s", - AcpiUtGetNodeName (PciRootNode))); - } + /* + * It is OK if the handler is already installed on the root + * bridge. Still need to return a context object for the + * new PCI_Config operation region, however. + */ + Status = AE_OK; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not install PciConfig handler for Root Bridge %4.4s", + AcpiUtGetNodeName (PciRootNode))); } - break; } + break; } PciRootNode = AcpiNsGetParentNode (PciRootNode); @@ -364,7 +372,7 @@ AcpiEvPciConfigRegionSetup ( /* Region is still not initialized. Create a new context */ - PciId = ACPI_MEM_CALLOCATE (sizeof (ACPI_PCI_ID)); + PciId = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PCI_ID)); if (!PciId) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -373,13 +381,26 @@ AcpiEvPciConfigRegionSetup ( /* * For PCI_Config space access, we need the segment, bus, * device and function numbers. Acquire them here. + * + * Find the parent device object. (This allows the operation region to be + * within a subscope under the device, such as a control method.) */ + PciDeviceNode = RegionObj->Region.Node; + while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE)) + { + PciDeviceNode = AcpiNsGetParentNode (PciDeviceNode); + } + + if (!PciDeviceNode) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } /* * Get the PCI device and function numbers from the _ADR object * contained in the parent's scope. */ - Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, ParentNode, &PciValue); + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, PciDeviceNode, &PciValue); /* * The default is zero, and since the allocation above zeroed @@ -418,6 +439,105 @@ AcpiEvPciConfigRegionSetup ( /******************************************************************************* * + * FUNCTION: AcpiEvMatchPciRootBridge + * + * PARAMETERS: Id - The HID/CID in string format + * + * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. + * + ******************************************************************************/ + +static BOOLEAN +AcpiEvMatchPciRootBridge ( + char *Id) +{ + + /* + * Check if this is a PCI root. + * ACPI 3.0+: check for a PCI Express root also. + */ + if (!(ACPI_STRNCMP (Id, + PCI_ROOT_HID_STRING, + sizeof (PCI_ROOT_HID_STRING))) || + + !(ACPI_STRNCMP (Id, + PCI_EXPRESS_ROOT_HID_STRING, + sizeof (PCI_EXPRESS_ROOT_HID_STRING)))) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIsPciRootBridge + * + * PARAMETERS: Node - Device node being examined + * + * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input device represents a PCI Root Bridge by + * examining the _HID and _CID for the device. + * + ******************************************************************************/ + +static BOOLEAN +AcpiEvIsPciRootBridge ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + ACPI_DEVICE_ID Hid; + ACPI_COMPATIBLE_ID_LIST *Cid; + ACPI_NATIVE_UINT i; + + + /* + * Get the _HID and check for a PCI Root Bridge + */ + Status = AcpiUtExecute_HID (Node, &Hid); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + + if (AcpiEvMatchPciRootBridge (Hid.Value)) + { + return (TRUE); + } + + /* + * The _HID did not match. + * Get the _CID and check for a PCI Root Bridge + */ + Status = AcpiUtExecute_CID (Node, &Cid); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + + /* Check all _CIDs in the returned list */ + + for (i = 0; i < Cid->Count; i++) + { + if (AcpiEvMatchPciRootBridge (Cid->Id[i].Value)) + { + ACPI_FREE (Cid); + return (TRUE); + } + } + + ACPI_FREE (Cid); + return (FALSE); +} + + +/******************************************************************************* + * * FUNCTION: AcpiEvPciBarRegionSetup * * PARAMETERS: Handle - Region we are interested in @@ -440,7 +560,7 @@ AcpiEvPciBarRegionSetup ( void *HandlerContext, void **RegionContext) { - ACPI_FUNCTION_TRACE ("EvPciBarRegionSetup"); + ACPI_FUNCTION_TRACE (EvPciBarRegionSetup); return_ACPI_STATUS (AE_OK); @@ -471,7 +591,7 @@ AcpiEvCmosRegionSetup ( void *HandlerContext, void **RegionContext) { - ACPI_FUNCTION_TRACE ("EvCmosRegionSetup"); + ACPI_FUNCTION_TRACE (EvCmosRegionSetup); return_ACPI_STATUS (AE_OK); @@ -500,7 +620,7 @@ AcpiEvDefaultRegionSetup ( void *HandlerContext, void **RegionContext) { - ACPI_FUNCTION_TRACE ("EvDefaultRegionSetup"); + ACPI_FUNCTION_TRACE (EvDefaultRegionSetup); if (Function == ACPI_REGION_DEACTIVATE) @@ -536,6 +656,9 @@ AcpiEvDefaultRegionSetup ( * a PCI address in the scope of the definition. This address is * required to perform an access to PCI config space. * + * MUTEX: Interpreter should be unlocked, because we may run the _REG + * method for this region. + * ******************************************************************************/ ACPI_STATUS @@ -553,7 +676,7 @@ AcpiEvInitializeRegion ( ACPI_OPERAND_OBJECT *RegionObj2; - ACPI_FUNCTION_TRACE_U32 ("EvInitializeRegion", AcpiNsLocked); + ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); if (!RegionObj) @@ -584,8 +707,8 @@ AcpiEvInitializeRegion ( /* Find any "_REG" method associated with this region definition */ - Status = AcpiNsSearchNode (*RegNamePtr, Node, - ACPI_TYPE_METHOD, &MethodNode); + Status = AcpiNsSearchOneScope ( + *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); if (ACPI_SUCCESS (Status)) { /* diff --git a/sys/dist/acpica/evsci.c b/sys/dist/acpica/evsci.c index 5bbb8714b3e..53fa0a60eb5 100644 --- a/sys/dist/acpica/evsci.c +++ b/sys/dist/acpica/evsci.c @@ -2,7 +2,7 @@ * * Module Name: evsci - System Control Interrupt configuration and * legacy to ACPI mode state transition functions - * xRevision: 1.99 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,11 +116,8 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evsci.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> #define _COMPONENT ACPI_EVENTS @@ -154,7 +151,7 @@ AcpiEvSciXruptHandler ( UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; - ACPI_FUNCTION_TRACE("EvSciXruptHandler"); + ACPI_FUNCTION_TRACE (EvSciXruptHandler); /* @@ -198,7 +195,7 @@ AcpiEvGpeXruptHandler ( UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; - ACPI_FUNCTION_TRACE("EvGpeXruptHandler"); + ACPI_FUNCTION_TRACE (EvGpeXruptHandler); /* @@ -235,11 +232,11 @@ AcpiEvInstallSciHandler ( UINT32 Status = AE_OK; - ACPI_FUNCTION_TRACE ("EvInstallSciHandler"); + ACPI_FUNCTION_TRACE (EvInstallSciHandler); - Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT->SciInt, - AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead); + Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, + AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead); return_ACPI_STATUS (Status); } @@ -270,13 +267,13 @@ AcpiEvRemoveSciHandler ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvRemoveSciHandler"); + ACPI_FUNCTION_TRACE (EvRemoveSciHandler); /* Just let the OS remove the handler and disable the level */ - Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT->SciInt, - AcpiEvSciXruptHandler); + Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, + AcpiEvSciXruptHandler); return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/evxface.c b/sys/dist/acpica/evxface.c index c0ee20625f5..f25e5f2ad2f 100644 --- a/sys/dist/acpica/evxface.c +++ b/sys/dist/acpica/evxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evxface - External interfaces for ACPI events - * xRevision: 1.157 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,15 +115,12 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evxface.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __EVXFACE_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acevents.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evxface") @@ -149,7 +146,7 @@ AcpiInstallExceptionHandler ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiInstallExceptionHandler"); + ACPI_FUNCTION_TRACE (AcpiInstallExceptionHandler); Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); @@ -175,6 +172,8 @@ Cleanup: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInstallExceptionHandler) + /******************************************************************************* * @@ -201,7 +200,7 @@ AcpiInstallFixedEventHandler ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiInstallFixedEventHandler"); + ACPI_FUNCTION_TRACE (AcpiInstallFixedEventHandler); /* Parameter validation */ @@ -252,6 +251,8 @@ Cleanup: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInstallFixedEventHandler) + /******************************************************************************* * @@ -274,7 +275,7 @@ AcpiRemoveFixedEventHandler ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("AcpiRemoveFixedEventHandler"); + ACPI_FUNCTION_TRACE (AcpiRemoveFixedEventHandler); /* Parameter validation */ @@ -313,6 +314,8 @@ AcpiRemoveFixedEventHandler ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiRemoveFixedEventHandler) + /******************************************************************************* * @@ -345,7 +348,7 @@ AcpiInstallNotifyHandler ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiInstallNotifyHandler"); + ACPI_FUNCTION_TRACE (AcpiInstallNotifyHandler); /* Parameter validation */ @@ -500,6 +503,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInstallNotifyHandler) + /******************************************************************************* * @@ -530,7 +535,7 @@ AcpiRemoveNotifyHandler ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiRemoveNotifyHandler"); + ACPI_FUNCTION_TRACE (AcpiRemoveNotifyHandler); /* Parameter validation */ @@ -614,8 +619,13 @@ AcpiRemoveNotifyHandler ( if (HandlerType & ACPI_SYSTEM_NOTIFY) { NotifyObj = ObjDesc->CommonNotify.SystemNotify; - if ((!NotifyObj) || - (NotifyObj->Notify.Handler != Handler)) + if (!NotifyObj) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (NotifyObj->Notify.Handler != Handler) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; @@ -630,8 +640,13 @@ AcpiRemoveNotifyHandler ( if (HandlerType & ACPI_DEVICE_NOTIFY) { NotifyObj = ObjDesc->CommonNotify.DeviceNotify; - if ((!NotifyObj) || - (NotifyObj->Notify.Handler != Handler)) + if (!NotifyObj) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (NotifyObj->Notify.Handler != Handler) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; @@ -650,6 +665,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiRemoveNotifyHandler) + /******************************************************************************* * @@ -683,7 +700,7 @@ AcpiInstallGpeHandler ( ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE ("AcpiInstallGpeHandler"); + ACPI_FUNCTION_TRACE (AcpiInstallGpeHandler); /* Parameter validation */ @@ -718,7 +735,7 @@ AcpiInstallGpeHandler ( /* Allocate and init handler object */ - Handler = ACPI_MEM_CALLOCATE (sizeof (ACPI_HANDLER_INFO)); + Handler = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_HANDLER_INFO)); if (!Handler) { Status = AE_NO_MEMORY; @@ -755,6 +772,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInstallGpeHandler) + /******************************************************************************* * @@ -783,7 +802,7 @@ AcpiRemoveGpeHandler ( ACPI_CPU_FLAGS Flags; - ACPI_FUNCTION_TRACE ("AcpiRemoveGpeHandler"); + ACPI_FUNCTION_TRACE (AcpiRemoveGpeHandler); /* Parameter validation */ @@ -849,7 +868,7 @@ AcpiRemoveGpeHandler ( /* Now we can free the handler object */ - ACPI_MEM_FREE (Handler); + ACPI_FREE (Handler); UnlockAndExit: @@ -857,6 +876,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiRemoveGpeHandler) + /******************************************************************************* * @@ -870,6 +891,12 @@ UnlockAndExit: * * DESCRIPTION: Acquire the ACPI Global Lock * + * Note: Allows callers with the same thread ID to acquire the global lock + * multiple times. In other words, externally, the behavior of the global lock + * is identical to an AML mutex. On the first acquire, a new handle is + * returned. On any subsequent calls to acquire by the same thread, the same + * handle is returned. + * ******************************************************************************/ ACPI_STATUS @@ -885,24 +912,26 @@ AcpiAcquireGlobalLock ( return (AE_BAD_PARAMETER); } - Status = AcpiExEnterInterpreter (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + /* Must lock interpreter to prevent race conditions */ - Status = AcpiEvAcquireGlobalLock (Timeout); - AcpiExExitInterpreter (); + AcpiExEnterInterpreter (); + + Status = AcpiExAcquireMutexObject (Timeout, + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); if (ACPI_SUCCESS (Status)) { - AcpiGbl_GlobalLockHandle++; + /* Return the global lock handle (updated in AcpiEvAcquireGlobalLock) */ + *Handle = AcpiGbl_GlobalLockHandle; } + AcpiExExitInterpreter (); return (Status); } +ACPI_EXPORT_SYMBOL (AcpiAcquireGlobalLock) + /******************************************************************************* * @@ -923,13 +952,14 @@ AcpiReleaseGlobalLock ( ACPI_STATUS Status; - if (Handle != AcpiGbl_GlobalLockHandle) + if (!Handle || (Handle != AcpiGbl_GlobalLockHandle)) { return (AE_NOT_ACQUIRED); } - Status = AcpiEvReleaseGlobalLock (); + Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); return (Status); } +ACPI_EXPORT_SYMBOL (AcpiReleaseGlobalLock) diff --git a/sys/dist/acpica/evxfevnt.c b/sys/dist/acpica/evxfevnt.c index 05aa74da7ce..83eaf07622e 100644 --- a/sys/dist/acpica/evxfevnt.c +++ b/sys/dist/acpica/evxfevnt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable - * xRevision: 1.86 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,12 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evxfevnt.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __EVXFEVNT_C__ -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evxfevnt") @@ -147,17 +145,18 @@ AcpiEnable ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("AcpiEnable"); + ACPI_FUNCTION_TRACE (AcpiEnable); - /* Make sure we have the FADT*/ + /* ACPI tables must be present */ - if (!AcpiGbl_FADT) + if (!AcpiTbTablesLoaded ()) { - ACPI_WARNING ((AE_INFO, "No FADT information present!")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } + /* Check current mode */ + if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); @@ -180,6 +179,8 @@ AcpiEnable ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiEnable) + /******************************************************************************* * @@ -200,15 +201,9 @@ AcpiDisable ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("AcpiDisable"); + ACPI_FUNCTION_TRACE (AcpiDisable); - if (!AcpiGbl_FADT) - { - ACPI_WARNING ((AE_INFO, "No FADT information present!")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, @@ -233,6 +228,8 @@ AcpiDisable ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiDisable) + /******************************************************************************* * @@ -256,7 +253,7 @@ AcpiEnableEvent ( UINT32 Value; - ACPI_FUNCTION_TRACE ("AcpiEnableEvent"); + ACPI_FUNCTION_TRACE (AcpiEnableEvent); /* Decode the Fixed Event */ @@ -270,8 +267,7 @@ AcpiEnableEvent ( * Enable the requested fixed event (by writing a one to the * enable register bit) */ - Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - 1, ACPI_MTX_LOCK); + Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 1); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -280,7 +276,7 @@ AcpiEnableEvent ( /* Make sure that the hardware responded */ Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - &Value, ACPI_MTX_LOCK); + &Value); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -296,6 +292,8 @@ AcpiEnableEvent ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiEnableEvent) + /******************************************************************************* * @@ -321,7 +319,7 @@ AcpiSetGpeType ( ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_FUNCTION_TRACE ("AcpiSetGpeType"); + ACPI_FUNCTION_TRACE (AcpiSetGpeType); /* Ensure that we have a valid GPE number */ @@ -346,6 +344,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiSetGpeType) + /******************************************************************************* * @@ -372,7 +372,7 @@ AcpiEnableGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_FUNCTION_TRACE ("AcpiEnableGpe"); + ACPI_FUNCTION_TRACE (AcpiEnableGpe); /* Use semaphore lock if not executing at interrupt level */ @@ -407,6 +407,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiEnableGpe) + /******************************************************************************* * @@ -433,7 +435,7 @@ AcpiDisableGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_FUNCTION_TRACE ("AcpiDisableGpe"); + ACPI_FUNCTION_TRACE (AcpiDisableGpe); /* Use semaphore lock if not executing at interrupt level */ @@ -466,6 +468,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiDisableGpe) + /******************************************************************************* * @@ -489,7 +493,7 @@ AcpiDisableEvent ( UINT32 Value; - ACPI_FUNCTION_TRACE ("AcpiDisableEvent"); + ACPI_FUNCTION_TRACE (AcpiDisableEvent); /* Decode the Fixed Event */ @@ -503,15 +507,14 @@ AcpiDisableEvent ( * Disable the requested fixed event (by writing a zero to the * enable register bit) */ - Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - 0, ACPI_MTX_LOCK); + Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 0); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - &Value, ACPI_MTX_LOCK); + &Value); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -527,6 +530,8 @@ AcpiDisableEvent ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiDisableEvent) + /******************************************************************************* * @@ -547,7 +552,7 @@ AcpiClearEvent ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("AcpiClearEvent"); + ACPI_FUNCTION_TRACE (AcpiClearEvent); /* Decode the Fixed Event */ @@ -561,12 +566,13 @@ AcpiClearEvent ( * Clear the requested fixed event (By writing a one to the * status register bit) */ - Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, - 1, ACPI_MTX_LOCK); + Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, 1); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiClearEvent) + /******************************************************************************* * @@ -592,7 +598,7 @@ AcpiClearGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_FUNCTION_TRACE ("AcpiClearGpe"); + ACPI_FUNCTION_TRACE (AcpiClearGpe); /* Use semaphore lock if not executing at interrupt level */ @@ -625,6 +631,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiClearGpe) + /******************************************************************************* * @@ -648,7 +656,7 @@ AcpiGetEventStatus ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("AcpiGetEventStatus"); + ACPI_FUNCTION_TRACE (AcpiGetEventStatus); if (!EventStatus) @@ -666,11 +674,13 @@ AcpiGetEventStatus ( /* Get the status of the requested fixed event */ Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, - EventStatus, ACPI_MTX_LOCK); + EventStatus); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetEventStatus) + /******************************************************************************* * @@ -699,7 +709,7 @@ AcpiGetGpeStatus ( ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_FUNCTION_TRACE ("AcpiGetGpeStatus"); + ACPI_FUNCTION_TRACE (AcpiGetGpeStatus); /* Use semaphore lock if not executing at interrupt level */ @@ -734,6 +744,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus) + /******************************************************************************* * @@ -763,7 +775,7 @@ AcpiInstallGpeBlock ( ACPI_GPE_BLOCK_INFO *GpeBlock; - ACPI_FUNCTION_TRACE ("AcpiInstallGpeBlock"); + ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock); if ((!GpeDevice) || @@ -841,6 +853,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock) + /******************************************************************************* * @@ -863,7 +877,7 @@ AcpiRemoveGpeBlock ( ACPI_NAMESPACE_NODE *Node; - ACPI_FUNCTION_TRACE ("AcpiRemoveGpeBlock"); + ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock); if (!GpeDevice) @@ -906,3 +920,5 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock) + diff --git a/sys/dist/acpica/evxfregn.c b/sys/dist/acpica/evxfregn.c index c0cd7543d65..d14b322e0b9 100644 --- a/sys/dist/acpica/evxfregn.c +++ b/sys/dist/acpica/evxfregn.c @@ -2,7 +2,7 @@ * * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and * Address Spaces. - * xRevision: 1.66 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evxfregn.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __EVXFREGN_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evxfregn") @@ -156,7 +153,7 @@ AcpiInstallAddressSpaceHandler ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiInstallAddressSpaceHandler"); + ACPI_FUNCTION_TRACE (AcpiInstallAddressSpaceHandler); /* Parameter validation */ @@ -198,6 +195,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInstallAddressSpaceHandler) + /******************************************************************************* * @@ -227,7 +226,7 @@ AcpiRemoveAddressSpaceHandler ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiRemoveAddressSpaceHandler"); + ACPI_FUNCTION_TRACE (AcpiRemoveAddressSpaceHandler); /* Parameter validation */ @@ -246,7 +245,11 @@ AcpiRemoveAddressSpaceHandler ( /* Convert and validate the device handle */ Node = AcpiNsMapHandleToNode (Device); - if (!Node) + if (!Node || + ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode))) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; @@ -271,6 +274,14 @@ AcpiRemoveAddressSpaceHandler ( if (HandlerObj->AddressSpace.SpaceId == SpaceId) { + /* Handler must be the same as the installed handler */ + + if (HandlerObj->AddressSpace.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + /* Matched SpaceId, first dereference this in the Regions */ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, @@ -330,4 +341,5 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiRemoveAddressSpaceHandler) diff --git a/sys/dist/acpica/exconfig.c b/sys/dist/acpica/exconfig.c index 914665c288b..8dabc97c3b7 100644 --- a/sys/dist/acpica/exconfig.c +++ b/sys/dist/acpica/exconfig.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) - * xRevision: 1.90 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,18 +115,15 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exconfig.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXCONFIG_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acevents.h" -#include "actables.h" -#include "acdispat.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/actables.h> +#include <dist/acpica/acdispat.h> #define _COMPONENT ACPI_EXECUTER @@ -136,7 +133,7 @@ __KERNEL_RCSID(0, "$NetBSD: exconfig.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); static ACPI_STATUS AcpiExAddTable ( - ACPI_TABLE_HEADER *Table, + ACPI_NATIVE_UINT TableIndex, ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle); @@ -158,16 +155,15 @@ AcpiExAddTable ( static ACPI_STATUS AcpiExAddTable ( - ACPI_TABLE_HEADER *Table, + ACPI_NATIVE_UINT TableIndex, ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle) { ACPI_STATUS Status; - ACPI_TABLE_DESC TableInfo; ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_TRACE ("ExAddTable"); + ACPI_FUNCTION_TRACE (ExAddTable); /* Create an object to be the table handle */ @@ -185,44 +181,17 @@ AcpiExAddTable ( /* Install the new table into the local data structures */ - ACPI_MEMSET (&TableInfo, 0, sizeof (ACPI_TABLE_DESC)); - - TableInfo.Type = ACPI_TABLE_SSDT; - TableInfo.Pointer = Table; - TableInfo.Length = (ACPI_SIZE) Table->Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; - - Status = AcpiTbInstallTable (&TableInfo); - ObjDesc->Reference.Object = TableInfo.InstalledDesc; - - if (ACPI_FAILURE (Status)) - { - if (Status == AE_ALREADY_EXISTS) - { - /* Table already exists, just return the handle */ - - return_ACPI_STATUS (AE_OK); - } - goto Cleanup; - } + ObjDesc->Reference.Object = ACPI_CAST_PTR (void, TableIndex); /* Add the table to the namespace */ - Status = AcpiNsLoadTable (TableInfo.InstalledDesc, ParentNode); + Status = AcpiNsLoadTable (TableIndex, ParentNode); if (ACPI_FAILURE (Status)) { - /* Uninstall table on error */ - - (void) AcpiTbUninstallTable (TableInfo.InstalledDesc); - goto Cleanup; + AcpiUtRemoveReference (ObjDesc); + *DdbHandle = NULL; } - return_ACPI_STATUS (AE_OK); - - -Cleanup: - AcpiUtRemoveReference (ObjDesc); - *DdbHandle = NULL; return_ACPI_STATUS (Status); } @@ -236,7 +205,7 @@ Cleanup: * * RETURN: Status * - * DESCRIPTION: Load an ACPI table + * DESCRIPTION: Load an ACPI table from the RSDT/XSDT * ******************************************************************************/ @@ -247,35 +216,22 @@ AcpiExLoadTableOp ( { ACPI_STATUS Status; ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_TABLE_HEADER *Table; + ACPI_NATIVE_UINT TableIndex; ACPI_NAMESPACE_NODE *ParentNode; ACPI_NAMESPACE_NODE *StartNode; ACPI_NAMESPACE_NODE *ParameterNode = NULL; ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *Table; - ACPI_FUNCTION_TRACE ("ExLoadTableOp"); + ACPI_FUNCTION_TRACE (ExLoadTableOp); -#if 0 - /* - * Make sure that the signature does not match one of the tables that - * is already loaded. - */ - Status = AcpiTbMatchSignature (Operand[0]->String.Pointer, NULL); - if (Status == AE_OK) - { - /* Signature matched -- don't allow override */ - - return_ACPI_STATUS (AE_ALREADY_EXISTS); - } -#endif - - /* Find the ACPI table */ + /* Find the ACPI table in the RSDT/XSDT */ Status = AcpiTbFindTable (Operand[0]->String.Pointer, Operand[1]->String.Pointer, - Operand[2]->String.Pointer, &Table); + Operand[2]->String.Pointer, &TableIndex); if (ACPI_FAILURE (Status)) { if (Status != AE_NOT_FOUND) @@ -310,8 +266,8 @@ AcpiExLoadTableOp ( * Find the node referenced by the RootPathString. This is the * location within the namespace where the table will be loaded. */ - Status = AcpiNsGetNodeByPath (Operand[3]->String.Pointer, StartNode, - ACPI_NS_SEARCH_PARENT, &ParentNode); + Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer, + ACPI_NS_SEARCH_PARENT, &ParentNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -334,7 +290,7 @@ AcpiExLoadTableOp ( /* Find the node referenced by the ParameterPathString */ - Status = AcpiNsGetNodeByPath (Operand[4]->String.Pointer, StartNode, + Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer, ACPI_NS_SEARCH_PARENT, &ParameterNode); if (ACPI_FAILURE (Status)) { @@ -344,7 +300,7 @@ AcpiExLoadTableOp ( /* Load the table into the namespace */ - Status = AcpiExAddTable (Table, ParentNode, &DdbHandle); + Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -366,6 +322,14 @@ AcpiExLoadTableOp ( } } + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + ACPI_INFO ((AE_INFO, + "Dynamic OEM Table Load - [%4.4s] OemId [%6.6s] OemTableId [%8.8s]", + Table->Signature, Table->OemId, Table->OemTableId)); + } + *ReturnDesc = DdbHandle; return_ACPI_STATUS (Status); } @@ -375,7 +339,7 @@ AcpiExLoadTableOp ( * * FUNCTION: AcpiExLoadOp * - * PARAMETERS: ObjDesc - Region or Field where the table will be + * PARAMETERS: ObjDesc - Region or Buffer/Field where the table will be * obtained * Target - Where a handle to the table will be stored * WalkState - Current state @@ -384,6 +348,12 @@ AcpiExLoadTableOp ( * * DESCRIPTION: Load an ACPI table from a field or operation region * + * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer + * objects before this code is reached. + * + * If source is an operation region, it must refer to SystemMemory, as + * per the ACPI specification. + * ******************************************************************************/ ACPI_STATUS @@ -392,23 +362,31 @@ AcpiExLoadOp ( ACPI_OPERAND_OBJECT *Target, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status; ACPI_OPERAND_OBJECT *DdbHandle; - ACPI_OPERAND_OBJECT *BufferDesc = NULL; - ACPI_TABLE_HEADER *TablePtr = NULL; - ACPI_PHYSICAL_ADDRESS Address; - ACPI_TABLE_HEADER TableHeader; - UINT32 i; + ACPI_TABLE_DESC TableDesc; + ACPI_NATIVE_UINT TableIndex; + ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExLoadOp"); + ACPI_FUNCTION_TRACE (ExLoadOp); - /* Object can be either an OpRegion or a Field */ + + ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC)); + TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED; + + /* Source Object can be either an OpRegion or a Buffer/Field */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_REGION: + /* Region must be SystemMemory (from ACPI spec) */ + + if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); @@ -425,113 +403,40 @@ AcpiExLoadOp ( } } - /* Get the base physical address of the region */ - - Address = ObjDesc->Region.Address; - - /* Get the table length from the table header */ - - TableHeader.Length = 0; - for (i = 0; i < 8; i++) - { - Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) (i + Address), 8, - ((UINT8 *) &TableHeader) + i); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Sanity check the table length */ - - if (TableHeader.Length < sizeof (ACPI_TABLE_HEADER)) - { - return_ACPI_STATUS (AE_BAD_HEADER); - } - - /* Allocate a buffer for the entire table */ - - TablePtr = ACPI_MEM_ALLOCATE (TableHeader.Length); - if (!TablePtr) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Get the entire table from the op region */ - - for (i = 0; i < TableHeader.Length; i++) - { - Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) (i + Address), 8, - ((UINT8 *) TablePtr + i)); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - } + TableDesc.Address = ObjDesc->Region.Address; + TableDesc.Length = ObjDesc->Region.Length; + TableDesc.Flags = ACPI_TABLE_ORIGIN_MAPPED; break; + case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */ - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* Simply extract the buffer from the buffer object */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Buffer or Field %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); - /* - * The length of the field must be at least as large as the table. - * Read the entire field and thus the entire table. Buffer is - * allocated during the read. - */ - Status = AcpiExReadDataFromField (WalkState, ObjDesc, &BufferDesc); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, - BufferDesc->Buffer.Pointer); - - /* All done with the BufferDesc, delete it */ - - BufferDesc->Buffer.Pointer = NULL; - AcpiUtRemoveReference (BufferDesc); - - /* Sanity check the table length */ + TableDesc.Pointer = ACPI_CAST_PTR (ACPI_TABLE_HEADER, + ObjDesc->Buffer.Pointer); + TableDesc.Length = TableDesc.Pointer->Length; + TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED; - if (TablePtr->Length < sizeof (ACPI_TABLE_HEADER)) - { - Status = AE_BAD_HEADER; - goto Cleanup; - } + ObjDesc->Buffer.Pointer = NULL; break; - default: return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - /* The table must be either an SSDT or a PSDT */ - - if ((!ACPI_STRNCMP (TablePtr->Signature, - AcpiGbl_TableData[ACPI_TABLE_PSDT].Signature, - AcpiGbl_TableData[ACPI_TABLE_PSDT].SigLength)) && - (!ACPI_STRNCMP (TablePtr->Signature, - AcpiGbl_TableData[ACPI_TABLE_SSDT].Signature, - AcpiGbl_TableData[ACPI_TABLE_SSDT].SigLength))) + /* + * Install the new table into the local data structures + */ + Status = AcpiTbAddTable (&TableDesc, &TableIndex); + if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, - "Table has invalid signature [%4.4s], must be SSDT or PSDT", - TablePtr->Signature)); - Status = AE_BAD_SIGNATURE; goto Cleanup; } - /* Install the new table into the local data structures */ - - Status = AcpiExAddTable (TablePtr, AcpiGbl_RootNode, &DdbHandle); + Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle); if (ACPI_FAILURE (Status)) { /* On error, TablePtr was deallocated above */ @@ -554,7 +459,7 @@ AcpiExLoadOp ( Cleanup: if (ACPI_FAILURE (Status)) { - ACPI_MEM_FREE (TablePtr); + AcpiTbDeleteTable (&TableDesc); } return_ACPI_STATUS (Status); } @@ -578,10 +483,10 @@ AcpiExUnloadTable ( { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; - ACPI_TABLE_DESC *TableInfo; + ACPI_NATIVE_UINT TableIndex; - ACPI_FUNCTION_TRACE ("ExUnloadTable"); + ACPI_FUNCTION_TRACE (ExUnloadTable); /* @@ -597,20 +502,18 @@ AcpiExUnloadTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get the actual table descriptor from the DdbHandle */ + /* Get the table index from the DdbHandle */ - TableInfo = (ACPI_TABLE_DESC *) TableDesc->Reference.Object; + TableIndex = (ACPI_NATIVE_UINT) TableDesc->Reference.Object; /* * Delete the entire namespace under this table Node * (Offset contains the TableId) */ - AcpiNsDeleteNamespaceByOwner (TableInfo->OwnerId); - AcpiUtReleaseOwnerId (&TableInfo->OwnerId); - - /* Delete the table itself */ + AcpiTbDeleteNamespaceByOwner (TableIndex); + AcpiTbReleaseOwnerId (TableIndex); - (void) AcpiTbUninstallTable (TableInfo->InstalledDesc); + AcpiTbSetTableLoadedFlag (TableIndex, FALSE); /* Delete the table descriptor (DdbHandle) */ diff --git a/sys/dist/acpica/exconvrt.c b/sys/dist/acpica/exconvrt.c index 940b6aa65ae..d5572c9fa22 100644 --- a/sys/dist/acpica/exconvrt.c +++ b/sys/dist/acpica/exconvrt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exconvrt - Object conversion routines - * xRevision: 1.71 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exconvrt.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXCONVRT_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_EXECUTER @@ -167,7 +164,7 @@ AcpiExConvertToInteger ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("ExConvertToInteger", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) @@ -268,6 +265,9 @@ AcpiExConvertToInteger ( return_ACPI_STATUS (AE_NO_MEMORY); } + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Result))); + /* Save the Result */ ReturnDesc->Integer.Value = Result; @@ -300,7 +300,7 @@ AcpiExConvertToBuffer ( UINT8 *NewBuf; - ACPI_FUNCTION_TRACE_PTR ("ExConvertToBuffer", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) @@ -521,7 +521,7 @@ AcpiExConvertToString ( UINT8 Separator = ','; - ACPI_FUNCTION_TRACE_PTR ("ExConvertToString", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) @@ -700,7 +700,7 @@ AcpiExConvertToTargetType ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("ExConvertToTargetType"); + ACPI_FUNCTION_TRACE (ExConvertToTargetType); /* Default behavior */ diff --git a/sys/dist/acpica/excreate.c b/sys/dist/acpica/excreate.c index 39330166d50..cd4f2ac6e8a 100644 --- a/sys/dist/acpica/excreate.c +++ b/sys/dist/acpica/excreate.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: excreate - Named object creation - * xRevision: 1.108 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,17 +115,14 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: excreate.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXCREATE_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acevents.h" -#include "actables.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_EXECUTER @@ -154,7 +151,7 @@ AcpiExCreateAlias ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("ExCreateAlias"); + ACPI_FUNCTION_TRACE (ExCreateAlias); /* Get the source/alias operands (both namespace nodes) */ @@ -250,7 +247,7 @@ AcpiExCreateEvent ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_TRACE ("ExCreateEvent"); + ACPI_FUNCTION_TRACE (ExCreateEvent); ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); @@ -265,7 +262,7 @@ AcpiExCreateEvent ( * that the event is created in an unsignalled state */ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, - &ObjDesc->Event.Semaphore); + &ObjDesc->Event.OsSemaphore); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -308,7 +305,7 @@ AcpiExCreateMutex ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_TRACE_PTR ("ExCreateMutex", ACPI_WALK_OPERANDS); + ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS); /* Create the new mutex object */ @@ -320,12 +317,9 @@ AcpiExCreateMutex ( goto Cleanup; } - /* - * Create the actual OS semaphore. - * One unit max to make it a mutex, with one initial unit to allow - * the mutex to be acquired. - */ - Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); + /* Create the actual OS Mutex */ + + Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -336,8 +330,7 @@ AcpiExCreateMutex ( ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, - ObjDesc, ACPI_TYPE_MUTEX); + Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); Cleanup: @@ -378,7 +371,7 @@ AcpiExCreateRegion ( ACPI_OPERAND_OBJECT *RegionObj2; - ACPI_FUNCTION_TRACE ("ExCreateRegion"); + ACPI_FUNCTION_TRACE (ExCreateRegion); /* Get the Namespace Node */ @@ -421,16 +414,16 @@ AcpiExCreateRegion ( * Remember location in AML stream of address & length * operands since they need to be evaluated at run time. */ - RegionObj2 = ObjDesc->Common.NextObject; - RegionObj2->Extra.AmlStart = AmlStart; + RegionObj2 = ObjDesc->Common.NextObject; + RegionObj2->Extra.AmlStart = AmlStart; RegionObj2->Extra.AmlLength = AmlLength; /* Init the region from the operands */ ObjDesc->Region.SpaceId = RegionSpace; ObjDesc->Region.Address = 0; - ObjDesc->Region.Length = 0; - ObjDesc->Region.Node = Node; + ObjDesc->Region.Length = 0; + ObjDesc->Region.Node = Node; /* Install the new region object in the parent Node */ @@ -466,11 +459,12 @@ AcpiExCreateTableRegion ( ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; - ACPI_TABLE_HEADER *Table; ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_NATIVE_UINT TableIndex; + ACPI_TABLE_HEADER *Table; - ACPI_FUNCTION_TRACE ("ExCreateTableRegion"); + ACPI_FUNCTION_TRACE (ExCreateTableRegion); /* Get the Node from the object stack */ @@ -489,8 +483,8 @@ AcpiExCreateTableRegion ( /* Find the ACPI table */ Status = AcpiTbFindTable (Operand[1]->String.Pointer, - Operand[2]->String.Pointer, - Operand[3]->String.Pointer, &Table); + Operand[2]->String.Pointer, Operand[3]->String.Pointer, + &TableIndex); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -504,16 +498,22 @@ AcpiExCreateTableRegion ( return_ACPI_STATUS (AE_NO_MEMORY); } - RegionObj2 = ObjDesc->Common.NextObject; + RegionObj2 = ObjDesc->Common.NextObject; RegionObj2->Extra.RegionContext = NULL; + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* Init the region from the operands */ ObjDesc->Region.SpaceId = REGION_DATA_TABLE; ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); - ObjDesc->Region.Length = Table->Length; - ObjDesc->Region.Node = Node; - ObjDesc->Region.Flags = AOPOBJ_DATA_VALID; + ObjDesc->Region.Length = Table->Length; + ObjDesc->Region.Node = Node; + ObjDesc->Region.Flags = AOPOBJ_DATA_VALID; /* Install the new region object in the parent Node */ @@ -571,7 +571,7 @@ AcpiExCreateProcessor ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("ExCreateProcessor", WalkState); + ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState); /* Create the processor object */ @@ -584,9 +584,9 @@ AcpiExCreateProcessor ( /* Initialize the processor object from the operands */ - ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; + ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; + ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; - ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; /* Install the processor object in the parent Node */ @@ -623,7 +623,7 @@ AcpiExCreatePowerResource ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_TRACE_PTR ("ExCreatePowerResource", WalkState); + ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState); /* Create the power resource object */ @@ -636,7 +636,7 @@ AcpiExCreatePowerResource ( /* Initialize the power object from the operands */ - ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; + ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; /* Install the power resource object in the parent Node */ @@ -678,7 +678,7 @@ AcpiExCreateMethod ( UINT8 MethodFlags; - ACPI_FUNCTION_TRACE_PTR ("ExCreateMethod", WalkState); + ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState); /* Create a new method object */ @@ -686,44 +686,36 @@ AcpiExCreateMethod ( ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); if (!ObjDesc) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Exit; } /* Save the method's AML pointer and length */ - ObjDesc->Method.AmlStart = AmlStart; + ObjDesc->Method.AmlStart = AmlStart; ObjDesc->Method.AmlLength = AmlLength; /* - * Disassemble the method flags. Split off the Arg Count + * Disassemble the method flags. Split off the Arg Count * for efficiency */ MethodFlags = (UINT8) Operand[1]->Integer.Value; ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT); - ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT); + ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT); /* - * Get the concurrency count. If required, a semaphore will be + * Get the SyncLevel. If method is serialized, a mutex will be * created for this method when it is parsed. */ - if (AcpiGbl_AllMethodsSerialized) - { - ObjDesc->Method.Concurrency = 1; - ObjDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED; - } - else if (MethodFlags & AML_METHOD_SERIALIZED) + if (MethodFlags & AML_METHOD_SERIALIZED) { /* - * ACPI 1.0: Concurrency = 1 - * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1) + * ACPI 1.0: SyncLevel = 0 + * ACPI 2.0: SyncLevel = SyncLevel in method declaration */ - ObjDesc->Method.Concurrency = (UINT8) - (((MethodFlags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1); - } - else - { - ObjDesc->Method.Concurrency = ACPI_INFINITE_CONCURRENCY; + ObjDesc->Method.SyncLevel = (UINT8) + ((MethodFlags & AML_METHOD_SYNCH_LEVEL) >> 4); } /* Attach the new object to the method Node */ @@ -735,6 +727,7 @@ AcpiExCreateMethod ( AcpiUtRemoveReference (ObjDesc); +Exit: /* Remove a reference to the operand */ AcpiUtRemoveReference (Operand[1]); diff --git a/sys/dist/acpica/exdump.c b/sys/dist/acpica/exdump.c index e7c53f2cd12..9c72a508be8 100644 --- a/sys/dist/acpica/exdump.c +++ b/sys/dist/acpica/exdump.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exdump - Interpreter debug output routines - * xRevision: 1.194 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,16 +114,13 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exdump.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __EXDUMP_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acparser.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acparser.h> #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exdump") @@ -143,12 +140,12 @@ AcpiExOutString ( static void AcpiExOutPointer ( const char *Title, - const void *Value); + void *Value); static void -AcpiExOutAddress ( - const char *Title, - ACPI_PHYSICAL_ADDRESS Value); +AcpiExDumpObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_EXDUMP_INFO *Info); static void AcpiExDumpReferenceObj ( @@ -184,11 +181,12 @@ static ACPI_EXDUMP_INFO AcpiExDumpString[4] = {ACPI_EXD_STRING, 0, NULL} }; -static ACPI_EXDUMP_INFO AcpiExDumpBuffer[4] = +static ACPI_EXDUMP_INFO AcpiExDumpBuffer[5] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer), NULL}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Buffer.Length), "Length"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Pointer), "Pointer"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"}, {ACPI_EXD_BUFFER, 0, NULL} }; @@ -212,15 +210,15 @@ static ACPI_EXDUMP_INFO AcpiExDumpDevice[4] = static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent), NULL}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.Semaphore), "Semaphore"} + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.OsSemaphore), "OsSemaphore"} }; static ACPI_EXDUMP_INFO AcpiExDumpMethod[8] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "ParamCount"}, - {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.Concurrency), "Concurrency"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Semaphore), "Semaphore"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.OwnerId), "Owner Id"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ThreadCount), "Thread Count"}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Method.AmlLength), "Aml Length"}, @@ -233,7 +231,7 @@ static ACPI_EXDUMP_INFO AcpiExDumpMutex[5] = {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"}, {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"}, - {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.Semaphore), "Semaphore"} + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"} }; static ACPI_EXDUMP_INFO AcpiExDumpRegion[7] = @@ -259,8 +257,8 @@ static ACPI_EXDUMP_INFO AcpiExDumpPower[5] = static ACPI_EXDUMP_INFO AcpiExDumpProcessor[7] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor), NULL}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Processor.ProcId), "Processor ID"}, - {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Processor.Length), "Length"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Processor.ProcId), "Processor ID"}, + {ACPI_EXD_UINT8 , ACPI_EXD_OFFSET (Processor.Length), "Length"}, {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Processor.Address), "Address"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.SystemNotify), "System Notify"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.DeviceNotify), "Device Notify"}, @@ -359,12 +357,11 @@ static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] = {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"} }; -static ACPI_EXDUMP_INFO AcpiExDumpNode[6] = +static ACPI_EXDUMP_INFO AcpiExDumpNode[5] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNode), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (Flags), "Flags"}, {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (OwnerId), "Owner Id"}, - {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET (ReferenceCount), "Reference Count"}, {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Child), "Child List"}, {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Peer), "Next Peer"} }; @@ -477,13 +474,9 @@ AcpiExDumpObject ( break; case ACPI_EXD_POINTER: - - AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target)); - break; - case ACPI_EXD_ADDRESS: - AcpiExOutAddress (Name, *ACPI_CAST_PTR (ACPI_PHYSICAL_ADDRESS, Target)); + AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target)); break; case ACPI_EXD_STRING: @@ -550,7 +543,7 @@ AcpiExDumpOperand ( UINT32 Index; - ACPI_FUNCTION_NAME ("ExDumpOperand") + ACPI_FUNCTION_NAME (ExDumpOperand) if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) @@ -608,14 +601,6 @@ AcpiExDumpOperand ( break; - case AML_NAME_OP: - - ACPI_DUMP_PATHNAME (ObjDesc->Reference.Object, - "Reference: Name: ", ACPI_LV_INFO, _COMPONENT); - ACPI_DUMP_ENTRY (ObjDesc->Reference.Object, ACPI_LV_INFO); - break; - - case AML_INDEX_OP: AcpiOsPrintf ("Reference: Index %p\n", @@ -908,7 +893,7 @@ AcpiExDumpOperands ( ACPI_NATIVE_UINT i; - ACPI_FUNCTION_NAME ("ExDumpOperands"); + ACPI_FUNCTION_NAME (ExDumpOperands); if (!Ident) @@ -968,24 +953,11 @@ AcpiExOutString ( static void AcpiExOutPointer ( const char *Title, - const void *Value) + void *Value) { AcpiOsPrintf ("%20s : %p\n", Title, Value); } -static void -AcpiExOutAddress ( - const char *Title, - ACPI_PHYSICAL_ADDRESS Value) -{ - -#if ACPI_MACHINE_WIDTH == 16 - AcpiOsPrintf ("%20s : %p\n", Title, Value); -#else - AcpiOsPrintf ("%20s : %8.8X%8.8X\n", Title, ACPI_FORMAT_UINT64 (Value)); -#endif -} - /******************************************************************************* * @@ -1015,7 +987,6 @@ AcpiExDumpNamespaceNode ( } } - AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node)); @@ -1058,7 +1029,7 @@ AcpiExDumpReferenceObj ( else { AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer); - ACPI_MEM_FREE (RetBuf.Pointer); + ACPI_FREE (RetBuf.Pointer); } } else if (ObjDesc->Reference.Object) @@ -1191,7 +1162,7 @@ AcpiExDumpObjectDescriptor ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 Flags) { - ACPI_FUNCTION_TRACE ("ExDumpObjectDescriptor"); + ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor); if (!ObjDesc) diff --git a/sys/dist/acpica/exfield.c b/sys/dist/acpica/exfield.c index a180768a609..ea69d33decf 100644 --- a/sys/dist/acpica/exfield.c +++ b/sys/dist/acpica/exfield.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfield - ACPI AML (p-code) execution - field manipulation - * xRevision: 1.126 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exfield.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __EXFIELD_C__ -#include "acpi.h" -#include "acdispat.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_EXECUTER @@ -154,10 +151,9 @@ AcpiExReadDataFromField ( ACPI_OPERAND_OBJECT *BufferDesc; ACPI_SIZE Length; void *Buffer; - BOOLEAN Locked; - ACPI_FUNCTION_TRACE_PTR ("ExReadDataFromField", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc); /* Parameter validation */ @@ -201,7 +197,7 @@ AcpiExReadDataFromField ( /* Lock entire transaction if requested */ - Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); /* * Perform the read. @@ -210,7 +206,7 @@ AcpiExReadDataFromField ( Status = AcpiExAccessRegion (ObjDesc, 0, ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), ACPI_READ | (ObjDesc->Field.Attribute << 16)); - AcpiExReleaseGlobalLock (Locked); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); goto Exit; } @@ -262,12 +258,12 @@ AcpiExReadDataFromField ( /* Lock entire transaction if requested */ - Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); /* Read from the field */ Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length); - AcpiExReleaseGlobalLock (Locked); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); Exit: @@ -309,11 +305,10 @@ AcpiExWriteDataToField ( UINT32 RequiredLength; void *Buffer; void *NewBuffer; - BOOLEAN Locked; ACPI_OPERAND_OBJECT *BufferDesc; - ACPI_FUNCTION_TRACE_PTR ("ExWriteDataToField", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc); /* Parameter validation */ @@ -376,7 +371,7 @@ AcpiExWriteDataToField ( /* Lock entire transaction if requested */ - Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); /* * Perform the write (returns status and perhaps data in the @@ -386,7 +381,7 @@ AcpiExWriteDataToField ( Status = AcpiExAccessRegion (ObjDesc, 0, (ACPI_INTEGER *) Buffer, ACPI_WRITE | (ObjDesc->Field.Attribute << 16)); - AcpiExReleaseGlobalLock (Locked); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); *ResultDesc = BufferDesc; return_ACPI_STATUS (Status); @@ -429,7 +424,7 @@ AcpiExWriteDataToField ( { /* We need to create a new buffer */ - NewBuffer = ACPI_MEM_CALLOCATE (RequiredLength); + NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength); if (!NewBuffer) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -460,18 +455,18 @@ AcpiExWriteDataToField ( /* Lock entire transaction if requested */ - Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); /* Write to the field */ Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length); - AcpiExReleaseGlobalLock (Locked); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); /* Free temporary buffer if we used one */ if (NewBuffer) { - ACPI_MEM_FREE (NewBuffer); + ACPI_FREE (NewBuffer); } return_ACPI_STATUS (Status); diff --git a/sys/dist/acpica/exfldio.c b/sys/dist/acpica/exfldio.c index 61aabbd5243..7c2819ba570 100644 --- a/sys/dist/acpica/exfldio.c +++ b/sys/dist/acpica/exfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfldio - Aml Field I/O - * xRevision: 1.119 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,16 +115,13 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exfldio.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXFLDIO_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acevents.h" -#include "acdispat.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acdispat.h> #define _COMPONENT ACPI_EXECUTER @@ -175,7 +172,7 @@ AcpiExSetupRegion ( ACPI_OPERAND_OBJECT *RgnDesc; - ACPI_FUNCTION_TRACE_U32 ("ExSetupRegion", FieldDatumByteOffset); + ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset); RgnDesc = ObjDesc->CommonField.RegionObj; @@ -204,6 +201,17 @@ AcpiExSetupRegion ( } } + /* Exit if Address/Length have been disallowed by the host OS */ + + if (RgnDesc->Common.Flags & AOPOBJ_INVALID) + { + return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS); + } + + /* + * Exit now for SMBus address space, it has a non-linear address space + * and the request cannot be directly validated + */ if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) { /* SMBus has a non-linear address space */ @@ -230,9 +238,10 @@ AcpiExSetupRegion ( * length of one field datum (access width) must fit within the region. * (Region length is specified in bytes) */ - if (RgnDesc->Region.Length < (ObjDesc->CommonField.BaseByteOffset + - FieldDatumByteOffset + - ObjDesc->CommonField.AccessByteWidth)) + if (RgnDesc->Region.Length < + (ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset + + ObjDesc->CommonField.AccessByteWidth)) { if (AcpiGbl_EnableInterpreterSlack) { @@ -242,10 +251,10 @@ AcpiExSetupRegion ( * access width boundary. */ if (ACPI_ROUND_UP (RgnDesc->Region.Length, - ObjDesc->CommonField.AccessByteWidth) >= + ObjDesc->CommonField.AccessByteWidth) >= (ObjDesc->CommonField.BaseByteOffset + - (ACPI_NATIVE_UINT) ObjDesc->CommonField.AccessByteWidth + - FieldDatumByteOffset)) + (ACPI_NATIVE_UINT) ObjDesc->CommonField.AccessByteWidth + + FieldDatumByteOffset)) { return_ACPI_STATUS (AE_OK); } @@ -315,7 +324,7 @@ AcpiExAccessRegion ( ACPI_PHYSICAL_ADDRESS Address; - ACPI_FUNCTION_TRACE ("ExAccessRegion"); + ACPI_FUNCTION_TRACE (ExAccessRegion); /* @@ -350,13 +359,13 @@ AcpiExAccessRegion ( } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD, - " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %8.8X%8.8X\n", + " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n", AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId, ObjDesc->CommonField.AccessByteWidth, ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, - ACPI_FORMAT_UINT64 (Address))); + (void *) Address)); /* Invoke the appropriate AddressSpace/OpRegion handler */ @@ -462,7 +471,7 @@ AcpiExFieldDatumIo ( ACPI_INTEGER LocalValue; - ACPI_FUNCTION_TRACE_U32 ("ExFieldDatumIo", FieldDatumByteOffset); + ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset); if (ReadWrite == ACPI_READ) @@ -525,9 +534,9 @@ AcpiExFieldDatumIo ( * Length is the field width in bytes. */ ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + - ObjDesc->BufferField.BaseByteOffset + - FieldDatumByteOffset, - Value, ObjDesc->CommonField.AccessByteWidth); + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, + Value, ObjDesc->CommonField.AccessByteWidth); } Status = AE_OK; @@ -541,7 +550,7 @@ AcpiExFieldDatumIo ( * the register */ if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj, - (ACPI_INTEGER) ObjDesc->BankField.Value)) + (ACPI_INTEGER) ObjDesc->BankField.Value)) { return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); } @@ -551,8 +560,8 @@ AcpiExFieldDatumIo ( * (itself a RegionField) before we can access the data. */ Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj, - &ObjDesc->BankField.Value, - sizeof (ObjDesc->BankField.Value)); + &ObjDesc->BankField.Value, + sizeof (ObjDesc->BankField.Value)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -572,7 +581,7 @@ AcpiExFieldDatumIo ( * Operation Region. */ Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value, - ReadWrite); + ReadWrite); break; @@ -584,7 +593,7 @@ AcpiExFieldDatumIo ( * the register */ if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj, - (ACPI_INTEGER) ObjDesc->IndexField.Value)) + (ACPI_INTEGER) ObjDesc->IndexField.Value)) { return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); } @@ -594,34 +603,33 @@ AcpiExFieldDatumIo ( FieldDatumByteOffset += ObjDesc->IndexField.Value; ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Write to Index Register: Value %8.8X\n", - FieldDatumByteOffset)); + "Write to Index Register: Value %8.8X\n", + FieldDatumByteOffset)); Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj, - &FieldDatumByteOffset, - sizeof (FieldDatumByteOffset)); + &FieldDatumByteOffset, + sizeof (FieldDatumByteOffset)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "I/O to Data Register: ValuePtr %p\n", - Value)); + "I/O to Data Register: ValuePtr %p\n", Value)); if (ReadWrite == ACPI_READ) { /* Read the datum from the DataRegister */ Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj, - Value, sizeof (ACPI_INTEGER)); + Value, sizeof (ACPI_INTEGER)); } else { /* Write the datum to the DataRegister */ Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj, - Value, sizeof (ACPI_INTEGER)); + Value, sizeof (ACPI_INTEGER)); } break; @@ -683,7 +691,7 @@ AcpiExWriteWithUpdateRule ( ACPI_INTEGER CurrentValue; - ACPI_FUNCTION_TRACE_U32 ("ExWriteWithUpdateRule", Mask); + ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask); /* Start with the new bits */ @@ -711,7 +719,7 @@ AcpiExWriteWithUpdateRule ( * the field, and merge with the new field value. */ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, - &CurrentValue, ACPI_READ); + &CurrentValue, ACPI_READ); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -755,7 +763,7 @@ AcpiExWriteWithUpdateRule ( /* Write the merged value */ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, - &MergedValue, ACPI_WRITE); + &MergedValue, ACPI_WRITE); return_ACPI_STATUS (Status); } @@ -792,13 +800,13 @@ AcpiExExtractFromField ( UINT32 i; - ACPI_FUNCTION_TRACE ("ExExtractFromField"); + ACPI_FUNCTION_TRACE (ExExtractFromField); /* Validate target buffer and clear it */ - if (BufferLength < ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.BitLength)) + if (BufferLength < + ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength)) { ACPI_ERROR ((AE_INFO, "Field size %X (bits) is too large for buffer (%X)", @@ -835,17 +843,27 @@ AcpiExExtractFromField ( FieldOffset += ObjDesc->CommonField.AccessByteWidth; Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, - &RawDatum, ACPI_READ); + &RawDatum, ACPI_READ); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* Merge with previous datum if necessary */ - - MergedDatum |= RawDatum << - (ObjDesc->CommonField.AccessBitWidth - - ObjDesc->CommonField.StartFieldBitOffset); + /* + * Merge with previous datum if necessary. + * + * Note: Before the shift, check if the shift value will be larger than + * the integer size. If so, there is no need to perform the operation. + * This avoids the differences in behavior between different compilers + * concerning shift values larger than the target data width. + */ + if ((ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + { + MergedDatum |= RawDatum << + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + } if (i == DatumCount) { @@ -856,7 +874,7 @@ AcpiExExtractFromField ( ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, - BufferLength - BufferOffset)); + BufferLength - BufferOffset)); BufferOffset += ObjDesc->CommonField.AccessByteWidth; MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; @@ -875,7 +893,7 @@ AcpiExExtractFromField ( ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, - BufferLength - BufferOffset)); + BufferLength - BufferOffset)); return_ACPI_STATUS (AE_OK); } @@ -903,6 +921,7 @@ AcpiExInsertIntoField ( { ACPI_STATUS Status; ACPI_INTEGER Mask; + ACPI_INTEGER WidthMask; ACPI_INTEGER MergedDatum; ACPI_INTEGER RawDatum = 0; UINT32 FieldOffset = 0; @@ -913,13 +932,13 @@ AcpiExInsertIntoField ( UINT32 i; - ACPI_FUNCTION_TRACE ("ExInsertIntoField"); + ACPI_FUNCTION_TRACE (ExInsertIntoField); /* Validate input buffer */ - if (BufferLength < ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.BitLength)) + if (BufferLength < + ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength)) { ACPI_ERROR ((AE_INFO, "Field size %X (bits) is too large for buffer (%X)", @@ -928,11 +947,28 @@ AcpiExInsertIntoField ( return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } + /* + * Create the bitmasks used for bit insertion. + * Note: This if/else is used to bypass compiler differences with the + * shift operator + */ + if (ObjDesc->CommonField.AccessBitWidth == ACPI_INTEGER_BIT_SIZE) + { + WidthMask = ACPI_INTEGER_MAX; + } + else + { + WidthMask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.AccessBitWidth); + } + + Mask = WidthMask & + ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); + /* Compute the number of datums (access width data items) */ - Mask = ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength, ObjDesc->CommonField.AccessBitWidth); + FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength + ObjDesc->CommonField.StartFieldBitOffset, ObjDesc->CommonField.AccessBitWidth); @@ -941,7 +977,7 @@ AcpiExInsertIntoField ( ACPI_MEMCPY (&RawDatum, Buffer, ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, - BufferLength - BufferOffset)); + BufferLength - BufferOffset)); MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset; @@ -959,13 +995,30 @@ AcpiExInsertIntoField ( return_ACPI_STATUS (Status); } - /* Start new output datum by merging with previous input datum */ - FieldOffset += ObjDesc->CommonField.AccessByteWidth; - MergedDatum = RawDatum >> - (ObjDesc->CommonField.AccessBitWidth - - ObjDesc->CommonField.StartFieldBitOffset); - Mask = ACPI_INTEGER_MAX; + + /* + * Start new output datum by merging with previous input datum + * if necessary. + * + * Note: Before the shift, check if the shift value will be larger than + * the integer size. If so, there is no need to perform the operation. + * This avoids the differences in behavior between different compilers + * concerning shift values larger than the target data width. + */ + if ((ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + { + MergedDatum = RawDatum >> + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + } + else + { + MergedDatum = 0; + } + + Mask = WidthMask; if (i == DatumCount) { diff --git a/sys/dist/acpica/exmisc.c b/sys/dist/acpica/exmisc.c index a42e1286661..21581e2f1d7 100644 --- a/sys/dist/acpica/exmisc.c +++ b/sys/dist/acpica/exmisc.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes - * xRevision: 1.141 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,15 +116,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exmisc.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __EXMISC_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" -#include "amlresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/amlresrc.h> #define _COMPONENT ACPI_EXECUTER @@ -156,7 +153,7 @@ AcpiExGetObjectReference ( ACPI_OPERAND_OBJECT *ReferencedObj; - ACPI_FUNCTION_TRACE_PTR ("ExGetObjectReference", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc); *ReturnDesc = NULL; @@ -261,7 +258,7 @@ AcpiExConcatTemplate ( ACPI_SIZE NewLength; - ACPI_FUNCTION_TRACE ("ExConcatTemplate"); + ACPI_FUNCTION_TRACE (ExConcatTemplate); /* @@ -350,7 +347,7 @@ AcpiExDoConcatenate ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExDoConcatenate"); + ACPI_FUNCTION_TRACE (ExDoConcatenate); /* @@ -560,11 +557,27 @@ AcpiExDoMathOp ( case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/ + /* + * We need to check if the shiftcount is larger than the integer bit + * width since the behavior of this is not well-defined in the C language. + */ + if (Integer1 >= AcpiGbl_IntegerBitWidth) + { + return (0); + } return (Integer0 << Integer1); case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ + /* + * We need to check if the shiftcount is larger than the integer bit + * width since the behavior of this is not well-defined in the C language. + */ + if (Integer1 >= AcpiGbl_IntegerBitWidth) + { + return (0); + } return (Integer0 >> Integer1); @@ -610,7 +623,7 @@ AcpiExDoLogicalNumericOp ( BOOLEAN LocalResult = FALSE; - ACPI_FUNCTION_TRACE ("ExDoLogicalNumericOp"); + ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp); switch (Opcode) @@ -686,7 +699,7 @@ AcpiExDoLogicalOp ( int Compare; - ACPI_FUNCTION_TRACE ("ExDoLogicalOp"); + ACPI_FUNCTION_TRACE (ExDoLogicalOp); /* diff --git a/sys/dist/acpica/exmutex.c b/sys/dist/acpica/exmutex.c index db42ea6a032..f57685c0403 100644 --- a/sys/dist/acpica/exmutex.c +++ b/sys/dist/acpica/exmutex.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmutex - ASL Mutex Acquire/Release functions - * xRevision: 1.31 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,11 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exmutex.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXMUTEX_C__ -#include "acpi.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acevents.h> #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exmutex") @@ -219,6 +217,88 @@ AcpiExLinkMutex ( /******************************************************************************* * + * FUNCTION: AcpiExAcquireMutexObject + * + * PARAMETERS: TimeDesc - Timeout in milliseconds + * ObjDesc - Mutex object + * Thread - Current thread state + * + * RETURN: Status + * + * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common + * path that supports multiple acquires by the same thread. + * + * MUTEX: Interpreter must be locked + * + * NOTE: This interface is called from three places: + * 1) From AcpiExAcquireMutex, via an AML Acquire() operator + * 2) From AcpiExAcquireGlobalLock when an AML Field access requires the + * global lock + * 3) From the external interface, AcpiAcquireGlobalLock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAcquireMutexObject ( + UINT16 Timeout, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_ID ThreadId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Support for multiple acquires by the owning thread */ + + if (ObjDesc->Mutex.ThreadId == ThreadId) + { + /* + * The mutex is already owned by this thread, just increment the + * acquisition depth + */ + ObjDesc->Mutex.AcquisitionDepth++; + return_ACPI_STATUS (AE_OK); + } + + /* Acquire the mutex, wait if necessary. Special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + Status = AcpiEvAcquireGlobalLock (Timeout); + } + else + { + Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, + Timeout); + } + + if (ACPI_FAILURE (Status)) + { + /* Includes failure from a timeout on TimeDesc */ + + return_ACPI_STATUS (Status); + } + + /* Acquired the mutex: update mutex object */ + + ObjDesc->Mutex.ThreadId = ThreadId; + ObjDesc->Mutex.AcquisitionDepth = 1; + ObjDesc->Mutex.OriginalSyncLevel = 0; + ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */ + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: AcpiExAcquireMutex * * PARAMETERS: TimeDesc - Timeout integer @@ -240,7 +320,7 @@ AcpiExAcquireMutex ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("ExAcquireMutex", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc); if (!ObjDesc) @@ -248,7 +328,7 @@ AcpiExAcquireMutex ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Sanity check -- we must have a valid thread ID */ + /* Must have a valid thread ID */ if (!WalkState->Thread) { @@ -258,60 +338,107 @@ AcpiExAcquireMutex ( } /* - * Current Sync must be less than or equal to the sync level of the - * mutex. This mechanism provides some deadlock prevention + * Current sync level must be less than or equal to the sync level of the + * mutex. This mechanism provides some deadlock prevention */ if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) { ACPI_ERROR ((AE_INFO, - "Cannot acquire Mutex [%4.4s], incorrect SyncLevel", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)", + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + WalkState->Thread->CurrentSyncLevel)); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } - /* Support for multiple acquires by the owning thread */ - - if (ObjDesc->Mutex.OwnerThread) + Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value, + ObjDesc, WalkState->Thread->ThreadId); + if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1) { - /* Special case for Global Lock, allow all threads */ + /* Save Thread object, original/current sync levels */ - if ((ObjDesc->Mutex.OwnerThread->ThreadId == - WalkState->Thread->ThreadId) || - (ObjDesc->Mutex.Semaphore == - AcpiGbl_GlobalLockSemaphore)) - { - /* - * The mutex is already owned by this thread, - * just increment the acquisition depth - */ - ObjDesc->Mutex.AcquisitionDepth++; - return_ACPI_STATUS (AE_OK); - } + ObjDesc->Mutex.OwnerThread = WalkState->Thread; + ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; + + /* Link the mutex to the current thread for force-unlock at method exit */ + + AcpiExLinkMutex (ObjDesc, WalkState->Thread); } - /* Acquire the mutex, wait if necessary */ + return_ACPI_STATUS (Status); +} - Status = AcpiExSystemAcquireMutex (TimeDesc, ObjDesc); - if (ACPI_FAILURE (Status)) + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseMutexObject + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Release a previously acquired Mutex, low level interface. + * Provides a common path that supports multiple releases (after + * previous multiple acquires) by the same thread. + * + * MUTEX: Interpreter must be locked + * + * NOTE: This interface is called from three places: + * 1) From AcpiExReleaseMutex, via an AML Acquire() operator + * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the + * global lock + * 3) From the external interface, AcpiReleaseGlobalLock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReleaseMutexObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExReleaseMutexObject); + + + if (ObjDesc->Mutex.AcquisitionDepth == 0) { - /* Includes failure from a timeout on TimeDesc */ + return (AE_NOT_ACQUIRED); + } - return_ACPI_STATUS (Status); + /* Match multiple Acquires with multiple Releases */ + + ObjDesc->Mutex.AcquisitionDepth--; + if (ObjDesc->Mutex.AcquisitionDepth != 0) + { + /* Just decrement the depth and return */ + + return_ACPI_STATUS (AE_OK); } - /* Have the mutex: update mutex and walk info and save the SyncLevel */ + if (ObjDesc->Mutex.OwnerThread) + { + /* Unlink the mutex from the owner's list */ - ObjDesc->Mutex.OwnerThread = WalkState->Thread; - ObjDesc->Mutex.AcquisitionDepth = 1; - ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; + AcpiExUnlinkMutex (ObjDesc); + ObjDesc->Mutex.OwnerThread = NULL; + } - WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; + /* Release the mutex, special case for Global Lock */ - /* Link the mutex to the current thread for force-unlock at method exit */ + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + Status = AcpiEvReleaseGlobalLock (); + } + else + { + AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); + } - AcpiExLinkMutex (ObjDesc, WalkState->Thread); + /* Clear mutex info */ - return_ACPI_STATUS (AE_OK); + ObjDesc->Mutex.ThreadId = 0; + return_ACPI_STATUS (Status); } @@ -333,10 +460,10 @@ AcpiExReleaseMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("ExReleaseMutex"); + ACPI_FUNCTION_TRACE (ExReleaseMutex); if (!ObjDesc) @@ -353,65 +480,51 @@ AcpiExReleaseMutex ( return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED); } - /* Sanity check -- we must have a valid thread ID */ - - if (!WalkState->Thread) - { - ACPI_ERROR ((AE_INFO, "Cannot release Mutex [%4.4s], null thread info", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - /* * The Mutex is owned, but this thread must be the owner. * Special case for Global Lock, any thread can release */ if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) && - (ObjDesc->Mutex.Semaphore != AcpiGbl_GlobalLockSemaphore)) + (ObjDesc != AcpiGbl_GlobalLockMutex)) { ACPI_ERROR ((AE_INFO, "Thread %X cannot release Mutex [%4.4s] acquired by thread %X", - WalkState->Thread->ThreadId, + (UINT32)WalkState->Thread->ThreadId, AcpiUtGetNodeName (ObjDesc->Mutex.Node), - ObjDesc->Mutex.OwnerThread->ThreadId)); + (UINT32)ObjDesc->Mutex.OwnerThread->ThreadId)); return_ACPI_STATUS (AE_AML_NOT_OWNER); } + /* Must have a valid thread ID */ + + if (!WalkState->Thread) + { + ACPI_ERROR ((AE_INFO, "Cannot release Mutex [%4.4s], null thread info", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + /* - * The sync level of the mutex must be less than or - * equal to the current sync level + * The sync level of the mutex must be less than or equal to the current + * sync level */ if (ObjDesc->Mutex.SyncLevel > WalkState->Thread->CurrentSyncLevel) { ACPI_ERROR ((AE_INFO, - "Cannot release Mutex [%4.4s], incorrect SyncLevel", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %d current %d", + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel)); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } - /* Match multiple Acquires with multiple Releases */ + Status = AcpiExReleaseMutexObject (ObjDesc); - ObjDesc->Mutex.AcquisitionDepth--; - if (ObjDesc->Mutex.AcquisitionDepth != 0) + if (ObjDesc->Mutex.AcquisitionDepth == 0) { - /* Just decrement the depth and return */ + /* Restore the original SyncLevel */ - return_ACPI_STATUS (AE_OK); + WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; } - - /* Unlink the mutex from the owner's list */ - - AcpiExUnlinkMutex (ObjDesc); - - /* Release the mutex */ - - Status = AcpiExSystemReleaseMutex (ObjDesc); - - /* Update the mutex and walk state, restore SyncLevel before acquire */ - - ObjDesc->Mutex.OwnerThread = NULL; - WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; - return_ACPI_STATUS (Status); } @@ -426,6 +539,12 @@ AcpiExReleaseMutex ( * * DESCRIPTION: Release all mutexes held by this thread * + * NOTE: This function is called as the thread is exiting the interpreter. + * Mutexes are not released when an individual control method is exited, but + * only when the parent thread actually exits the interpreter. This allows one + * method to acquire a mutex, and a different method to release it, as long as + * this is performed underneath a single parent control method. + * ******************************************************************************/ void @@ -433,8 +552,7 @@ AcpiExReleaseAllMutexes ( ACPI_THREAD_STATE *Thread) { ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList; - ACPI_OPERAND_OBJECT *This; - ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_ENTRY (); @@ -444,28 +562,34 @@ AcpiExReleaseAllMutexes ( while (Next) { - This = Next; - Next = This->Mutex.Next; + ObjDesc = Next; + Next = ObjDesc->Mutex.Next; + + ObjDesc->Mutex.Prev = NULL; + ObjDesc->Mutex.Next = NULL; + ObjDesc->Mutex.AcquisitionDepth = 0; - This->Mutex.AcquisitionDepth = 1; - This->Mutex.Prev = NULL; - This->Mutex.Next = NULL; + /* Release the mutex, special case for Global Lock */ - /* Release the mutex */ + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + /* Ignore errors */ - Status = AcpiExSystemReleaseMutex (This); - if (ACPI_FAILURE (Status)) + (void) AcpiEvReleaseGlobalLock (); + } + else { - continue; + AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); } /* Mark mutex unowned */ - This->Mutex.OwnerThread = NULL; + ObjDesc->Mutex.OwnerThread = NULL; + ObjDesc->Mutex.ThreadId = 0; /* Update Thread SyncLevel (Last mutex is the important one) */ - Thread->CurrentSyncLevel = This->Mutex.OriginalSyncLevel; + Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; } } diff --git a/sys/dist/acpica/exnames.c b/sys/dist/acpica/exnames.c index 98e14b5971b..f12ff12c419 100644 --- a/sys/dist/acpica/exnames.c +++ b/sys/dist/acpica/exnames.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exnames - interpreter/scanner name load/execute - * xRevision: 1.107 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exnames.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXNAMES_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exnames") @@ -165,7 +162,7 @@ AcpiExAllocateNameString ( char *NameString; UINT32 SizeNeeded; - ACPI_FUNCTION_TRACE ("ExAllocateNameString"); + ACPI_FUNCTION_TRACE (ExAllocateNameString); /* @@ -188,7 +185,7 @@ AcpiExAllocateNameString ( * Allocate a buffer for the name. * This buffer must be deleted by the caller! */ - NameString = ACPI_MEM_ALLOCATE (SizeNeeded); + NameString = ACPI_ALLOCATE (SizeNeeded); if (!NameString) { ACPI_ERROR ((AE_INFO, @@ -263,7 +260,7 @@ AcpiExNameSegment ( char CharBuf[5]; - ACPI_FUNCTION_TRACE ("ExNameSegment"); + ACPI_FUNCTION_TRACE (ExNameSegment); /* @@ -281,7 +278,7 @@ AcpiExNameSegment ( ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); for (Index = 0; - (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiCharacter (*AmlAddress)); + (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0)); Index++) { CharBuf[Index] = *AmlAddress++; @@ -369,7 +366,7 @@ AcpiExGetNameString ( BOOLEAN HasPrefix = FALSE; - ACPI_FUNCTION_TRACE_PTR ("ExGetNameString", AmlAddress); + ACPI_FUNCTION_TRACE_PTR (ExGetNameString, AmlAddress); if (ACPI_TYPE_LOCAL_REGION_FIELD == DataType || @@ -549,7 +546,7 @@ AcpiExGetNameString ( { if (NameString) { - ACPI_MEM_FREE (NameString); + ACPI_FREE (NameString); } return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/exoparg1.c b/sys/dist/acpica/exoparg1.c index 0d512e1f768..513bf5449a9 100644 --- a/sys/dist/acpica/exoparg1.c +++ b/sys/dist/acpica/exoparg1.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg1 - AML execution - opcodes with 1 argument - * xRevision: 1.176 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,17 +115,14 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exoparg1.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXOPARG1_C__ -#include "acpi.h" -#include "acparser.h" -#include "acdispat.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_EXECUTER @@ -174,7 +171,7 @@ AcpiExOpcode_0A_0T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_0A_0T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -192,9 +189,7 @@ AcpiExOpcode_0A_0T_1R ( Status = AE_NO_MEMORY; goto Cleanup; } -#if ACPI_MACHINE_WIDTH != 16 ReturnDesc->Integer.Value = AcpiOsGetTimer (); -#endif break; default: /* Unknown opcode */ @@ -212,6 +207,7 @@ Cleanup: if ((ACPI_FAILURE (Status)) || WalkState->ResultObj) { AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; } else { @@ -245,7 +241,7 @@ AcpiExOpcode_1A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -322,7 +318,7 @@ AcpiExOpcode_1A_1T_0R ( ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -377,7 +373,7 @@ AcpiExOpcode_1A_1T_1R ( ACPI_INTEGER Digit; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -443,8 +439,8 @@ AcpiExOpcode_1A_1T_1R ( /* Since the bit position is one-based, subtract from 33 (65) */ - ReturnDesc->Integer.Value = Temp32 == 0 ? 0 : - (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; + ReturnDesc->Integer.Value = + Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; break; @@ -481,8 +477,8 @@ AcpiExOpcode_1A_1T_1R ( /* Sum the digit into the result with the current power of 10 */ - ReturnDesc->Integer.Value += (((ACPI_INTEGER) Temp32) * - PowerOfTen); + ReturnDesc->Integer.Value += + (((ACPI_INTEGER) Temp32) * PowerOfTen); /* Shift to next BCD digit */ @@ -510,8 +506,8 @@ AcpiExOpcode_1A_1T_1R ( * Insert the BCD digit that resides in the * remainder from above */ - ReturnDesc->Integer.Value |= (((ACPI_INTEGER) Temp32) << - ACPI_MUL_4 (i)); + ReturnDesc->Integer.Value |= + (((ACPI_INTEGER) Temp32) << ACPI_MUL_4 (i)); } /* Overflow if there is any data left in Digit */ @@ -685,11 +681,6 @@ AcpiExOpcode_1A_1T_1R ( Cleanup: - if (!WalkState->ResultObj) - { - WalkState->ResultObj = ReturnDesc; - } - /* Delete return object on error */ if (ACPI_FAILURE (Status)) @@ -697,6 +688,13 @@ Cleanup: AcpiUtRemoveReference (ReturnDesc); } + /* Save return object on success */ + + else if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } + return_ACPI_STATUS (Status); } @@ -725,7 +723,7 @@ AcpiExOpcode_1A_0T_1R ( ACPI_INTEGER Value; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -837,6 +835,7 @@ AcpiExOpcode_1A_0T_1R ( { goto Cleanup; } + /* Allocate a descriptor to hold the type. */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); @@ -1018,8 +1017,8 @@ AcpiExOpcode_1A_0T_1R ( * 2) Dereference the node to an actual object. Could be a * Field, so we need to resolve the node to a value. */ - Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer, - WalkState->ScopeInfo->Scope.Node, + Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node, + Operand[0]->String.Pointer, ACPI_NS_SEARCH_PARENT, ACPI_CAST_INDIRECT_PTR ( ACPI_NAMESPACE_NODE, &ReturnDesc)); @@ -1106,7 +1105,6 @@ AcpiExOpcode_1A_0T_1R ( { AcpiUtAddReference (ReturnDesc); } - break; @@ -1128,7 +1126,6 @@ AcpiExOpcode_1A_0T_1R ( if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == ACPI_DESC_TYPE_NAMED) { - ReturnDesc = AcpiNsGetAttachedObject ( (ACPI_NAMESPACE_NODE *) ReturnDesc); } @@ -1141,7 +1138,7 @@ AcpiExOpcode_1A_0T_1R ( default: ACPI_ERROR ((AE_INFO, - "Unknown opcode in ref(%p) - %X", + "Unknown opcode in reference(%p) - %X", Operand[0], Operand[0]->Reference.Opcode)); Status = AE_TYPE; @@ -1169,7 +1166,13 @@ Cleanup: AcpiUtRemoveReference (ReturnDesc); } - WalkState->ResultObj = ReturnDesc; + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/exoparg2.c b/sys/dist/acpica/exoparg2.c index 91c0cad282a..b6bc7007ed3 100644 --- a/sys/dist/acpica/exoparg2.c +++ b/sys/dist/acpica/exoparg2.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exoparg2 - AML execution - opcodes with 2 arguments - * xRevision: 1.139 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,16 +115,13 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exoparg2.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXOPARG2_C__ -#include "acpi.h" -#include "acparser.h" -#include "acinterp.h" -#include "acevents.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_EXECUTER @@ -179,7 +176,7 @@ AcpiExOpcode_2A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_0R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -281,7 +278,7 @@ AcpiExOpcode_2A_2T_1R ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_2T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -342,11 +339,6 @@ AcpiExOpcode_2A_2T_1R ( goto Cleanup; } - /* Return the remainder */ - - WalkState->ResultObj = ReturnDesc1; - - Cleanup: /* * Since the remainder is not returned indirectly, remove a reference to @@ -361,6 +353,13 @@ Cleanup: AcpiUtRemoveReference (ReturnDesc1); } + /* Save return object (the remainder) on success */ + + else + { + WalkState->ResultObj = ReturnDesc1; + } + return_ACPI_STATUS (Status); } @@ -389,7 +388,7 @@ AcpiExOpcode_2A_1T_1R ( ACPI_SIZE Length; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_1T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -507,7 +506,6 @@ AcpiExOpcode_2A_1T_1R ( Index = Operand[1]->Integer.Value; ReturnDesc->Reference.Offset = (UINT32) Index; ReturnDesc->Reference.Opcode = AML_INDEX_OP; - ReturnDesc->Reference.Object = Operand[0]; /* * At this point, the Source operand is a String, Buffer, or Package. @@ -563,9 +561,10 @@ AcpiExOpcode_2A_1T_1R ( } /* - * Add a reference to the target package/buffer/string for the life + * Save the target object and add a reference to it for the life * of the index */ + ReturnDesc->Reference.Object = Operand[0]; AcpiUtAddReference (Operand[0]); /* Store the reference to the Target */ @@ -615,6 +614,7 @@ Cleanup: if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; } return_ACPI_STATUS (Status); @@ -643,7 +643,7 @@ AcpiExOpcode_2A_0T_1R ( BOOLEAN LogicalResult = FALSE; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -719,9 +719,6 @@ StoreLogicalResult: ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; } - WalkState->ResultObj = ReturnDesc; - - Cleanup: /* Delete return object on error */ @@ -731,6 +728,13 @@ Cleanup: AcpiUtRemoveReference (ReturnDesc); } + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/exoparg3.c b/sys/dist/acpica/exoparg3.c index 3c6b38f5274..fa172dfead2 100644 --- a/sys/dist/acpica/exoparg3.c +++ b/sys/dist/acpica/exoparg3.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg3 - AML execution - opcodes with 3 arguments - * xRevision: 1.31 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,15 +116,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exoparg3.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXOPARG3_C__ -#include "acpi.h" -#include "acinterp.h" -#include "acparser.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_EXECUTER @@ -175,7 +172,7 @@ AcpiExOpcode_3A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_0T_0R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -189,7 +186,7 @@ AcpiExOpcode_3A_0T_0R ( (UINT32) Operand[1]->Integer.Value, (UINT32) Operand[2]->Integer.Value)); - Fatal = ACPI_MEM_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); + Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); if (Fatal) { Fatal->Type = (UINT32) Operand[0]->Integer.Value; @@ -203,7 +200,7 @@ AcpiExOpcode_3A_0T_0R ( /* Might return while OS is shutting down, just continue */ - ACPI_MEM_FREE (Fatal); + ACPI_FREE (Fatal); break; @@ -246,7 +243,7 @@ AcpiExOpcode_3A_1T_1R ( ACPI_SIZE Length; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_1T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -296,7 +293,7 @@ AcpiExOpcode_3A_1T_1R ( /* Always allocate a new buffer for the String */ - Buffer = ACPI_MEM_CALLOCATE ((ACPI_SIZE) Length + 1); + Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1); if (!Buffer) { Status = AE_NO_MEMORY; @@ -312,7 +309,7 @@ AcpiExOpcode_3A_1T_1R ( { /* Allocate a new buffer for the Buffer */ - Buffer = ACPI_MEM_CALLOCATE (Length); + Buffer = ACPI_ALLOCATE_ZEROED (Length); if (!Buffer) { Status = AE_NO_MEMORY; @@ -365,6 +362,7 @@ Cleanup: if (ACPI_FAILURE (Status) || WalkState->ResultObj) { AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; } /* Set the return object and exit */ diff --git a/sys/dist/acpica/exoparg6.c b/sys/dist/acpica/exoparg6.c index 49718718314..225f7052840 100644 --- a/sys/dist/acpica/exoparg6.c +++ b/sys/dist/acpica/exoparg6.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg6 - AML execution - opcodes with 6 arguments - * xRevision: 1.26 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,15 +116,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exoparg6.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXOPARG6_C__ -#include "acpi.h" -#include "acinterp.h" -#include "acparser.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_EXECUTER @@ -312,7 +309,7 @@ AcpiExOpcode_6A_0T_1R ( ACPI_OPERAND_OBJECT *ThisElement; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_6A_0T_1R", + ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R, AcpiPsGetOpcodeName (WalkState->Opcode)); @@ -423,8 +420,6 @@ AcpiExOpcode_6A_0T_1R ( goto Cleanup; } - WalkState->ResultObj = ReturnDesc; - Cleanup: @@ -435,5 +430,12 @@ Cleanup: AcpiUtRemoveReference (ReturnDesc); } + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/exprep.c b/sys/dist/acpica/exprep.c index 689c4dc6b12..5edb0188bc2 100644 --- a/sys/dist/acpica/exprep.c +++ b/sys/dist/acpica/exprep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities - * xRevision: 1.139 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,15 +115,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exprep.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXPREP_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_EXECUTER @@ -185,7 +182,7 @@ AcpiExGenerateAccess ( UINT32 Accesses; - ACPI_FUNCTION_TRACE ("ExGenerateAccess"); + ACPI_FUNCTION_TRACE (ExGenerateAccess); /* Round Field start offset and length to "minimal" byte boundaries */ @@ -319,7 +316,7 @@ AcpiExDecodeFieldAccess ( UINT32 BitLength; - ACPI_FUNCTION_TRACE ("ExDecodeFieldAccess"); + ACPI_FUNCTION_TRACE (ExDecodeFieldAccess); Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK); @@ -419,7 +416,7 @@ AcpiExPrepCommonFieldObject ( UINT32 NearestByteAddress; - ACPI_FUNCTION_TRACE ("ExPrepCommonFieldObject"); + ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject); /* @@ -518,7 +515,7 @@ AcpiExPrepFieldValue ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExPrepFieldValue"); + ACPI_FUNCTION_TRACE (ExPrepFieldValue); /* Parameter validation */ @@ -625,19 +622,25 @@ AcpiExPrepFieldValue ( AcpiUtAddReference (ObjDesc->IndexField.IndexObj); /* - * February 2006: Changed to match MS behavior + * April 2006: Changed to match MS behavior * * The value written to the Index register is the byte offset of the - * target field. + * target field in units of the granularity of the IndexField * * Previously, the value was calculated as an index in terms of the * width of the Data register, as below: * - * ObjDesc->IndexField.Value = (UINT32) - * (Info->FieldBitPosition / ACPI_MUL_8 ( - * ObjDesc->Field.AccessByteWidth)); + * ObjDesc->IndexField.Value = (UINT32) + * (Info->FieldBitPosition / ACPI_MUL_8 ( + * ObjDesc->Field.AccessByteWidth)); + * + * February 2006: Tried value as a byte offset: + * ObjDesc->IndexField.Value = (UINT32) + * ACPI_DIV_8 (Info->FieldBitPosition); */ - ObjDesc->IndexField.Value = (UINT32) ACPI_DIV_8 (Info->FieldBitPosition); + ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN ( + ACPI_DIV_8 (Info->FieldBitPosition), + ObjDesc->IndexField.AccessByteWidth); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", diff --git a/sys/dist/acpica/exregion.c b/sys/dist/acpica/exregion.c index 171e3b64f8a..6530d67a337 100644 --- a/sys/dist/acpica/exregion.c +++ b/sys/dist/acpica/exregion.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exregion - ACPI default OpRegion (address space) handlers - * xRevision: 1.95 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,13 +116,10 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exregion.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __EXREGION_C__ -#include "acpi.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_EXECUTER @@ -165,7 +162,8 @@ AcpiExSystemMemorySpaceHandler ( UINT32 Remainder; #endif - ACPI_FUNCTION_TRACE ("ExSystemMemorySpaceHandler"); + + ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler); /* Validate and translate the bit width */ @@ -225,7 +223,7 @@ AcpiExSystemMemorySpaceHandler ( /* Valid mapping, delete it */ AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress, - MemInfo->MappedLength); + MemInfo->MappedLength); } /* @@ -242,15 +240,14 @@ AcpiExSystemMemorySpaceHandler ( /* Create a new mapping starting at the address given */ - Status = AcpiOsMapMemory (Address, WindowSize, - (void **) &MemInfo->MappedLogicalAddress); - if (ACPI_FAILURE (Status)) + MemInfo->MappedLogicalAddress = AcpiOsMapMemory ((ACPI_NATIVE_UINT) Address, WindowSize); + if (!MemInfo->MappedLogicalAddress) { ACPI_ERROR ((AE_INFO, "Could not map memory at %8.8X%8.8X, size %X", ACPI_FORMAT_UINT64 (Address), (UINT32) WindowSize)); MemInfo->MappedLength = 0; - return_ACPI_STATUS (Status); + return_ACPI_STATUS (AE_NO_MEMORY); } /* Save the physical address and mapping size */ @@ -264,22 +261,20 @@ AcpiExSystemMemorySpaceHandler ( * access */ LogicalAddrPtr = MemInfo->MappedLogicalAddress + - ((ACPI_INTEGER) Address - - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); + ((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "SystemMemory %d (%d width) Address=%8.8X%8.8X\n", - Function, BitWidth, - ACPI_FORMAT_UINT64 (Address))); - - /* - * Perform the memory read or write - * - * Note: For machines that do not support non-aligned transfers, the target - * address was checked for alignment above. We do not attempt to break the - * transfer up into smaller (byte-size) chunks because the AML specifically - * asked for a transfer width that the hardware may require. - */ + "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", + BitWidth, Function, ACPI_FORMAT_UINT64 (Address))); + + /* + * Perform the memory read or write + * + * Note: For machines that do not support non-aligned transfers, the target + * address was checked for alignment above. We do not attempt to break the + * transfer up into smaller (byte-size) chunks because the AML specifically + * asked for a transfer width that the hardware may require. + */ switch (Function) { case ACPI_READ: @@ -299,11 +294,10 @@ AcpiExSystemMemorySpaceHandler ( *Value = (ACPI_INTEGER) ACPI_GET32 (LogicalAddrPtr); break; -#if ACPI_MACHINE_WIDTH != 16 case 64: *Value = (ACPI_INTEGER) ACPI_GET64 (LogicalAddrPtr); break; -#endif + default: /* BitWidth was already validated */ break; @@ -326,11 +320,9 @@ AcpiExSystemMemorySpaceHandler ( ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value; break; -#if ACPI_MACHINE_WIDTH != 16 case 64: ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value; break; -#endif default: /* BitWidth was already validated */ @@ -378,12 +370,12 @@ AcpiExSystemIoSpaceHandler ( UINT32 Value32; - ACPI_FUNCTION_TRACE ("ExSystemIoSpaceHandler"); + ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "SystemIO %d (%d width) Address=%8.8X%8.8X\n", Function, BitWidth, - ACPI_FORMAT_UINT64 (Address))); + "System-IO (width %d) R/W %d Address=%8.8X%8.8X\n", + BitWidth, Function, ACPI_FORMAT_UINT64 (Address))); /* Decode the function parameter */ @@ -443,7 +435,7 @@ AcpiExPciConfigSpaceHandler ( UINT16 PciRegister; - ACPI_FUNCTION_TRACE ("ExPciConfigSpaceHandler"); + ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler); /* @@ -462,7 +454,7 @@ AcpiExPciConfigSpaceHandler ( PciRegister = (UINT16) (UINT32) Address; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "PciConfig %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", + "Pci-Config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device, PciId->Function, PciRegister)); @@ -521,7 +513,7 @@ AcpiExCmosSpaceHandler ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("ExCmosSpaceHandler"); + ACPI_FUNCTION_TRACE (ExCmosSpaceHandler); return_ACPI_STATUS (Status); @@ -558,7 +550,7 @@ AcpiExPciBarSpaceHandler ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("ExPciBarSpaceHandler"); + ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler); return_ACPI_STATUS (Status); @@ -592,27 +584,17 @@ AcpiExDataTableSpaceHandler ( void *HandlerContext, void *RegionContext) { - ACPI_STATUS Status = AE_OK; - UINT32 ByteWidth = ACPI_DIV_8 (BitWidth); - UINT32 i; - char *LogicalAddrPtr; - - - ACPI_FUNCTION_TRACE ("ExDataTableSpaceHandler"); + ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler); - LogicalAddrPtr = ACPI_PHYSADDR_TO_PTR (Address); - /* Perform the memory read or write */ switch (Function) { case ACPI_READ: - for (i = 0; i < ByteWidth; i++) - { - ((char *) Value) [i] = LogicalAddrPtr[i]; - } + ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address), + ACPI_DIV_8 (BitWidth)); break; case ACPI_WRITE: @@ -621,7 +603,7 @@ AcpiExDataTableSpaceHandler ( return_ACPI_STATUS (AE_SUPPORT); } - return_ACPI_STATUS (Status); + return_ACPI_STATUS (AE_OK); } diff --git a/sys/dist/acpica/exresnte.c b/sys/dist/acpica/exresnte.c index da3a71416e3..2234d0549fc 100644 --- a/sys/dist/acpica/exresnte.c +++ b/sys/dist/acpica/exresnte.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresnte - AML Interpreter object resolution - * xRevision: 1.72 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,17 +115,14 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exresnte.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXRESNTE_C__ -#include "acpi.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acparser.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_EXECUTER @@ -171,7 +168,7 @@ AcpiExResolveNodeToValue ( ACPI_OBJECT_TYPE EntryType; - ACPI_FUNCTION_TRACE ("ExResolveNodeToValue"); + ACPI_FUNCTION_TRACE (ExResolveNodeToValue); /* @@ -198,10 +195,11 @@ AcpiExResolveNodeToValue ( /* * Several object types require no further processing: - * 1) Devices rarely have an attached object, return the Node + * 1) Device/Thermal objects don't have a "real" subobject, return the Node * 2) Method locals and arguments have a pseudo-Node */ - if (EntryType == ACPI_TYPE_DEVICE || + if ((EntryType == ACPI_TYPE_DEVICE) || + (EntryType == ACPI_TYPE_THERMAL) || (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) { return_ACPI_STATUS (AE_OK); @@ -310,7 +308,6 @@ AcpiExResolveNodeToValue ( case ACPI_TYPE_METHOD: case ACPI_TYPE_POWER: case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_THERMAL: case ACPI_TYPE_EVENT: case ACPI_TYPE_REGION: diff --git a/sys/dist/acpica/exresolv.c b/sys/dist/acpica/exresolv.c index 02111a0c64f..cb90f498867 100644 --- a/sys/dist/acpica/exresolv.c +++ b/sys/dist/acpica/exresolv.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresolv - AML Interpreter object resolution - * xRevision: 1.136 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,17 +115,14 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exresolv.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXRESOLV_C__ -#include "acpi.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acparser.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acparser.h> #define _COMPONENT ACPI_EXECUTER @@ -162,7 +159,7 @@ AcpiExResolveToValue ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_PTR ("ExResolveToValue", StackPtr); + ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr); if (!StackPtr || !*StackPtr) @@ -232,12 +229,11 @@ AcpiExResolveObjectToValue ( { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *StackDesc; - void *TempNode; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; UINT16 Opcode; - ACPI_FUNCTION_TRACE ("ExResolveObjectToValue"); + ACPI_FUNCTION_TRACE (ExResolveObjectToValue); StackDesc = *StackPtr; @@ -252,24 +248,6 @@ AcpiExResolveObjectToValue ( switch (Opcode) { - case AML_NAME_OP: - - /* - * Convert name reference to a namespace node - * Then, AcpiExResolveNodeToValue can be used to get the value - */ - TempNode = StackDesc->Reference.Object; - - /* Delete the Reference Object */ - - AcpiUtRemoveReference (StackDesc); - - /* Return the namespace node */ - - (*StackPtr) = TempNode; - break; - - case AML_LOCAL_OP: case AML_ARG_OP: @@ -357,10 +335,23 @@ AcpiExResolveObjectToValue ( case AML_INT_NAMEPATH_OP: /* Reference to a named object */ - /* Get the object pointed to by the namespace node */ + /* Dereference the name */ + + if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) || + (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL)) + { + /* These node types do not have 'real' subobjects */ + + *StackPtr = (void *) StackDesc->Reference.Node; + } + else + { + /* Get the object pointed to by the namespace node */ + + *StackPtr = (StackDesc->Reference.Node)->Object; + AcpiUtAddReference (*StackPtr); + } - *StackPtr = (StackDesc->Reference.Node)->Object; - AcpiUtAddReference (*StackPtr); AcpiUtRemoveReference (StackDesc); break; @@ -387,8 +378,6 @@ AcpiExResolveObjectToValue ( break; - /* These cases may never happen here, but just in case.. */ - case ACPI_TYPE_BUFFER_FIELD: case ACPI_TYPE_LOCAL_REGION_FIELD: case ACPI_TYPE_LOCAL_BANK_FIELD: @@ -398,6 +387,10 @@ AcpiExResolveObjectToValue ( StackDesc, ACPI_GET_OBJECT_TYPE (StackDesc))); Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); + + /* Remove a reference to the original operand, then override */ + + AcpiUtRemoveReference (*StackPtr); *StackPtr = (void *) ObjDesc; break; @@ -438,7 +431,7 @@ AcpiExResolveMultiple ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiExResolveMultiple"); + ACPI_FUNCTION_TRACE (AcpiExResolveMultiple); /* Operand can be either a namespace node or an operand descriptor */ diff --git a/sys/dist/acpica/exresop.c b/sys/dist/acpica/exresop.c index b77fade87e2..7f7a95d2c5f 100644 --- a/sys/dist/acpica/exresop.c +++ b/sys/dist/acpica/exresop.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresop - AML Interpreter operand/object resolution - * xRevision: 1.90 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,16 +115,13 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exresop.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXRESOP_C__ -#include "acpi.h" -#include "amlcode.h" -#include "acparser.h" -#include "acinterp.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_EXECUTER @@ -227,7 +224,6 @@ AcpiExResolveOperands ( ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status = AE_OK; UINT8 ObjectType; - void *TempNode; UINT32 ArgTypes; const ACPI_OPCODE_INFO *OpInfo; UINT32 ThisArgType; @@ -235,7 +231,7 @@ AcpiExResolveOperands ( UINT16 TargetOp = 0; - ACPI_FUNCTION_TRACE_U32 ("ExResolveOperands", Opcode); + ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode); OpInfo = AcpiPsGetOpcodeInfo (Opcode); @@ -289,7 +285,7 @@ AcpiExResolveOperands ( ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; /* - * Resolve an alias object. The construction of these objects + * Resolve an alias object. The construction of these objects * guarantees that there is only one level of alias indirection; * thus, the attached object is always the aliased namespace node */ @@ -336,7 +332,6 @@ AcpiExResolveOperands ( /*lint -fallthrough */ - case AML_NAME_OP: case AML_INDEX_OP: case AML_REF_OF_OP: case AML_ARG_OP: @@ -423,15 +418,6 @@ AcpiExResolveOperands ( { return_ACPI_STATUS (Status); } - - if (ObjDesc->Reference.Opcode == AML_NAME_OP) - { - /* Convert a named reference to the actual named object */ - - TempNode = ObjDesc->Reference.Object; - AcpiUtRemoveReference (ObjDesc); - (*StackPtr) = TempNode; - } goto NextOperand; @@ -717,23 +703,21 @@ AcpiExResolveOperands ( goto NextOperand; - case ARGI_REGION_OR_FIELD: + case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ - /* Need an operand of type REGION or a FIELD in a region */ + /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { + case ACPI_TYPE_BUFFER: case ACPI_TYPE_REGION: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: /* Valid operand */ break; default: ACPI_ERROR ((AE_INFO, - "Needed [Region/RegionField], found [%s] %p", + "Needed [Region/Buffer], found [%s] %p", AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); diff --git a/sys/dist/acpica/exstore.c b/sys/dist/acpica/exstore.c index ac9b32d8439..c2a9363e66e 100644 --- a/sys/dist/acpica/exstore.c +++ b/sys/dist/acpica/exstore.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exstore - AML Interpreter object store support - * xRevision: 1.199 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,17 +115,14 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exstore.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXSTORE_C__ -#include "acpi.h" -#include "acdispat.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acparser.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acparser.h> #define _COMPONENT ACPI_EXECUTER @@ -169,7 +166,7 @@ AcpiExDoDebugObject ( UINT32 i; - ACPI_FUNCTION_TRACE_PTR ("ExDoDebugObject", SourceDesc); + ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", @@ -236,7 +233,7 @@ AcpiExDoDebugObject ( ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length)); ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, - (SourceDesc->Buffer.Length < 32) ? SourceDesc->Buffer.Length : 32); + (SourceDesc->Buffer.Length < 256) ? SourceDesc->Buffer.Length : 256); break; case ACPI_TYPE_STRING: @@ -337,7 +334,7 @@ AcpiExStore ( ACPI_OPERAND_OBJECT *RefDesc = DestDesc; - ACPI_FUNCTION_TRACE_PTR ("ExStore", DestDesc); + ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); /* Validate parameters */ @@ -407,7 +404,6 @@ AcpiExStore ( */ switch (RefDesc->Reference.Opcode) { - case AML_NAME_OP: case AML_REF_OF_OP: /* Storing an object into a Name "container" */ @@ -491,7 +487,7 @@ AcpiExStoreObjectToIndex ( UINT32 i; - ACPI_FUNCTION_TRACE ("ExStoreObjectToIndex"); + ACPI_FUNCTION_TRACE (ExStoreObjectToIndex); /* @@ -656,7 +652,7 @@ AcpiExStoreObjectToNode ( ACPI_OBJECT_TYPE TargetType; - ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc); + ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc); /* Get current type of the node, and object attached to Node */ diff --git a/sys/dist/acpica/exstoren.c b/sys/dist/acpica/exstoren.c index 711adb4275f..d2d9efdcc17 100644 --- a/sys/dist/acpica/exstoren.c +++ b/sys/dist/acpica/exstoren.c @@ -3,7 +3,7 @@ * * Module Name: exstoren - AML Interpreter object store support, * Store to Node (namespace object) - * xRevision: 1.68 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,14 +116,11 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exstoren.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXSTOREN_C__ -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_EXECUTER @@ -155,7 +152,7 @@ AcpiExResolveObject ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("ExResolveObject"); + ACPI_FUNCTION_TRACE (ExResolveObject); /* Ensure we have a Target that can be stored to */ @@ -220,7 +217,7 @@ AcpiExResolveObject ( case ACPI_TYPE_LOCAL_METHOD_ALIAS: /* - * All aliases should have been resolved earlier, during the + * All aliases should have been resolved earlier, during the * operand resolution phase. */ ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object")); @@ -288,7 +285,7 @@ AcpiExStoreObjectToObject ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToObject", SourceDesc); + ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc); ActualSrcDesc = SourceDesc; diff --git a/sys/dist/acpica/exstorob.c b/sys/dist/acpica/exstorob.c index 4ca235e5340..ba210fa5095 100644 --- a/sys/dist/acpica/exstorob.c +++ b/sys/dist/acpica/exstorob.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exstorob - AML Interpreter object store support, store to object - * xRevision: 1.59 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exstorob.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXSTOROB_C__ -#include "acpi.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_EXECUTER @@ -150,7 +147,7 @@ AcpiExStoreBufferToBuffer ( UINT8 *Buffer; - ACPI_FUNCTION_TRACE_PTR ("ExStoreBufferToBuffer", SourceDesc); + ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc); /* We know that SourceDesc is a buffer by now */ @@ -165,7 +162,7 @@ AcpiExStoreBufferToBuffer ( if ((TargetDesc->Buffer.Length == 0) || (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)) { - TargetDesc->Buffer.Pointer = ACPI_MEM_ALLOCATE (Length); + TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length); if (!TargetDesc->Buffer.Pointer) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -248,7 +245,7 @@ AcpiExStoreStringToString ( UINT8 *Buffer; - ACPI_FUNCTION_TRACE_PTR ("ExStoreStringToString", SourceDesc); + ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc); /* We know that SourceDesc is a string by now */ @@ -282,10 +279,10 @@ AcpiExStoreStringToString ( { /* Only free if not a pointer into the DSDT */ - ACPI_MEM_FREE (TargetDesc->String.Pointer); + ACPI_FREE (TargetDesc->String.Pointer); } - TargetDesc->String.Pointer = ACPI_MEM_CALLOCATE ( + TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED ( (ACPI_SIZE) Length + 1); if (!TargetDesc->String.Pointer) { diff --git a/sys/dist/acpica/exsystem.c b/sys/dist/acpica/exsystem.c index 6699e91b963..e6996bcee61 100644 --- a/sys/dist/acpica/exsystem.c +++ b/sys/dist/acpica/exsystem.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exsystem - Interface to OS services - * xRevision: 1.87 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exsystem.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXSYSTEM_C__ -#include "acpi.h" -#include "acinterp.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acevents.h> #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exsystem") @@ -139,23 +136,22 @@ __KERNEL_RCSID(0, "$NetBSD: exsystem.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); * * DESCRIPTION: Implements a semaphore wait with a check to see if the * semaphore is available immediately. If it is not, the - * interpreter is released. + * interpreter is released before waiting. * ******************************************************************************/ ACPI_STATUS AcpiExSystemWaitSemaphore ( - ACPI_HANDLE Semaphore, + ACPI_SEMAPHORE Semaphore, UINT16 Timeout) { ACPI_STATUS Status; - ACPI_STATUS Status2; - ACPI_FUNCTION_TRACE ("ExSystemWaitSemaphore"); + ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore); - Status = AcpiOsWaitSemaphore (Semaphore, 1, 0); + Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); @@ -165,7 +161,7 @@ AcpiExSystemWaitSemaphore ( { /* We must wait, so unlock the interpreter */ - AcpiExExitInterpreter (); + AcpiExRelinquishInterpreter (); Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); @@ -175,13 +171,60 @@ AcpiExSystemWaitSemaphore ( /* Reacquire the interpreter */ - Status2 = AcpiExEnterInterpreter (); - if (ACPI_FAILURE (Status2)) - { - /* Report fatal error, could not acquire interpreter */ + AcpiExReacquireInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitMutex + * + * PARAMETERS: Mutex - Mutex to wait on + * Timeout - Max time to wait + * + * RETURN: Status + * + * DESCRIPTION: Implements a mutex wait with a check to see if the + * mutex is available immediately. If it is not, the + * interpreter is released before waiting. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitMutex ( + ACPI_MUTEX Mutex, + UINT16 Timeout) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExSystemWaitMutex); - return_ACPI_STATUS (Status2); - } + + Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Status == AE_TIME) + { + /* We must wait, so unlock the interpreter */ + + AcpiExRelinquishInterpreter (); + + Status = AcpiOsAcquireMutex (Mutex, Timeout); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", + AcpiFormatException (Status))); + + /* Reacquire the interpreter */ + + AcpiExReacquireInterpreter (); } return_ACPI_STATUS (Status); @@ -253,110 +296,19 @@ ACPI_STATUS AcpiExSystemDoSuspend ( ACPI_INTEGER HowLong) { - ACPI_STATUS Status; - - ACPI_FUNCTION_ENTRY (); /* Since this thread will sleep, we must release the interpreter */ - AcpiExExitInterpreter (); + AcpiExRelinquishInterpreter (); AcpiOsSleep (HowLong); /* And now we must get the interpreter again */ - Status = AcpiExEnterInterpreter (); - return (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemAcquireMutex - * - * PARAMETERS: TimeDesc - The 'time to delay' object descriptor - * ObjDesc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Provides an access point to perform synchronization operations - * within the AML. This function will cause a lock to be generated - * for the Mutex pointed to by ObjDesc. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemAcquireMutex ( - ACPI_OPERAND_OBJECT *TimeDesc, - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("ExSystemAcquireMutex", ObjDesc); - - - if (!ObjDesc) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Support for the _GL_ Mutex object -- go get the global lock */ - - if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) - { - Status = AcpiEvAcquireGlobalLock ((UINT16) TimeDesc->Integer.Value); - return_ACPI_STATUS (Status); - } - - Status = AcpiExSystemWaitSemaphore (ObjDesc->Mutex.Semaphore, - (UINT16) TimeDesc->Integer.Value); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSystemReleaseMutex - * - * PARAMETERS: ObjDesc - The object descriptor for this op - * - * RETURN: Status - * - * DESCRIPTION: Provides an access point to perform synchronization operations - * within the AML. This operation is a request to release a - * previously acquired Mutex. If the Mutex variable is set then - * it will be decremented. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExSystemReleaseMutex ( - ACPI_OPERAND_OBJECT *ObjDesc) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE ("ExSystemReleaseMutex"); - - - if (!ObjDesc) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Support for the _GL_ Mutex object -- release the global lock */ - - if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) - { - Status = AcpiEvReleaseGlobalLock (); - return_ACPI_STATUS (Status); - } - - Status = AcpiOsSignalSemaphore (ObjDesc->Mutex.Semaphore, 1); - return_ACPI_STATUS (Status); + AcpiExReacquireInterpreter (); + return (AE_OK); } @@ -380,12 +332,12 @@ AcpiExSystemSignalEvent ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("ExSystemSignalEvent"); + ACPI_FUNCTION_TRACE (ExSystemSignalEvent); if (ObjDesc) { - Status = AcpiOsSignalSemaphore (ObjDesc->Event.Semaphore, 1); + Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1); } return_ACPI_STATUS (Status); @@ -415,12 +367,12 @@ AcpiExSystemWaitEvent ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("ExSystemWaitEvent"); + ACPI_FUNCTION_TRACE (ExSystemWaitEvent); if (ObjDesc) { - Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.Semaphore, + Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore, (UINT16) TimeDesc->Integer.Value); } @@ -445,7 +397,7 @@ AcpiExSystemResetEvent ( ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_STATUS Status = AE_OK; - void *TempSemaphore; + ACPI_SEMAPHORE TempSemaphore; ACPI_FUNCTION_ENTRY (); @@ -458,8 +410,8 @@ AcpiExSystemResetEvent ( Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore); if (ACPI_SUCCESS (Status)) { - (void) AcpiOsDeleteSemaphore (ObjDesc->Event.Semaphore); - ObjDesc->Event.Semaphore = TempSemaphore; + (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore); + ObjDesc->Event.OsSemaphore = TempSemaphore; } return (Status); diff --git a/sys/dist/acpica/exutils.c b/sys/dist/acpica/exutils.c index d249edd78b3..a4a3790c653 100644 --- a/sys/dist/acpica/exutils.c +++ b/sys/dist/acpica/exutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exutils - interpreter/scanner utilities - * xRevision: 1.121 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,9 +115,6 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exutils.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __EXUTILS_C__ /* @@ -136,10 +133,10 @@ __KERNEL_RCSID(0, "$NetBSD: exutils.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); #define DEFINE_AML_GLOBALS -#include "acpi.h" -#include "acinterp.h" -#include "amlcode.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acevents.h> #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exutils") @@ -159,51 +156,81 @@ AcpiExDigitsNeeded ( * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Enter the interpreter execution region. Failure to enter - * the interpreter region is a fatal system error + * DESCRIPTION: Enter the interpreter execution region. Failure to enter + * the interpreter region is a fatal system error. Used in + * conjunction with ExitInterpreter. * ******************************************************************************/ -ACPI_STATUS +void AcpiExEnterInterpreter ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExEnterInterpreter"); + ACPI_FUNCTION_TRACE (ExEnterInterpreter); - Status = AcpiUtAcquireMutex (ACPI_MTX_EXECUTE); + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, "Could not acquire interpreter mutex")); + ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex")); } - return_ACPI_STATUS (Status); + return_VOID; } /******************************************************************************* * - * FUNCTION: AcpiExExitInterpreter + * FUNCTION: AcpiExReacquireInterpreter * * PARAMETERS: None * * RETURN: None * - * DESCRIPTION: Exit the interpreter execution region + * DESCRIPTION: Reacquire the interpreter execution region from within the + * interpreter code. Failure to enter the interpreter region is a + * fatal system error. Used in conjuction with + * RelinquishInterpreter + * + ******************************************************************************/ + +void +AcpiExReacquireInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExReacquireInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter, + * since it was not actually released by AcpiExRelinquishInterpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExEnterInterpreter (); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExExitInterpreter + * + * PARAMETERS: None + * + * RETURN: None * - * Cases where the interpreter is unlocked: - * 1) Completion of the execution of a control method - * 2) Method blocked on a Sleep() AML opcode - * 3) Method blocked on an Acquire() AML opcode - * 4) Method blocked on a Wait() AML opcode - * 5) Method blocked to acquire the global lock - * 6) Method blocked to execute a serialized control method that is - * already executing - * 7) About to invoke a user-installed opregion handler + * DESCRIPTION: Exit the interpreter execution region. This is the top level + * routine used to exit the interpreter when all processing has + * been completed. * ******************************************************************************/ @@ -214,13 +241,56 @@ AcpiExExitInterpreter ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExExitInterpreter"); + ACPI_FUNCTION_TRACE (ExExitInterpreter); - Status = AcpiUtReleaseMutex (ACPI_MTX_EXECUTE); + Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, "Could not release interpreter mutex")); + ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRelinquishInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Exit the interpreter execution region, from within the + * interpreter - before attempting an operation that will possibly + * block the running thread. + * + * Cases where the interpreter is unlocked internally + * 1) Method to be blocked on a Sleep() AML opcode + * 2) Method to be blocked on an Acquire() AML opcode + * 3) Method to be blocked on a Wait() AML opcode + * 4) Method to be blocked to acquire the global lock + * 5) Method to be blocked waiting to execute a serialized control method + * that is currently executing + * 6) About to invoke a user-installed opregion handler + * + ******************************************************************************/ + +void +AcpiExRelinquishInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExRelinquishInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExExitInterpreter (); } return_VOID; @@ -235,8 +305,8 @@ AcpiExExitInterpreter ( * * RETURN: none * - * DESCRIPTION: Truncate a number to 32-bits if the currently executing method - * belongs to a 32-bit ACPI table. + * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is + * 32-bit, as determined by the revision of the DSDT. * ******************************************************************************/ @@ -250,9 +320,10 @@ AcpiExTruncateFor32bitTable ( /* * Object must be a valid number and we must be executing - * a control method + * a control method. NS node could be there for AML_INT_NAMEPATH_OP. */ if ((!ObjDesc) || + (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) || (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER)) { return; @@ -276,44 +347,42 @@ AcpiExTruncateFor32bitTable ( * PARAMETERS: FieldFlags - Flags with Lock rule: * AlwaysLock or NeverLock * - * RETURN: TRUE/FALSE indicating whether the lock was actually acquired + * RETURN: None * - * DESCRIPTION: Obtain the global lock and keep track of this fact via two - * methods. A global variable keeps the state of the lock, and - * the state is returned to the caller. + * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field + * flags specifiy that it is to be obtained before field access. * ******************************************************************************/ -BOOLEAN +void AcpiExAcquireGlobalLock ( UINT32 FieldFlags) { - BOOLEAN Locked = FALSE; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExAcquireGlobalLock"); + ACPI_FUNCTION_TRACE (ExAcquireGlobalLock); - /* Only attempt lock if the AlwaysLock bit is set */ + /* Only use the lock if the AlwaysLock bit is set */ - if (FieldFlags & AML_FIELD_LOCK_RULE_MASK) + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) + { + return_VOID; + } + + /* Attempt to get the global lock, wait forever */ + + Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER, + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + + if (ACPI_FAILURE (Status)) { - /* We should attempt to get the lock, wait forever */ - - Status = AcpiEvAcquireGlobalLock (ACPI_WAIT_FOREVER); - if (ACPI_SUCCESS (Status)) - { - Locked = TRUE; - } - else - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not acquire Global Lock")); - } + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not acquire Global Lock")); } - return_UINT8 (Locked); + return_VOID; } @@ -321,39 +390,41 @@ AcpiExAcquireGlobalLock ( * * FUNCTION: AcpiExReleaseGlobalLock * - * PARAMETERS: LockedByMe - Return value from corresponding call to - * AcquireGlobalLock. + * PARAMETERS: FieldFlags - Flags with Lock rule: + * AlwaysLock or NeverLock * * RETURN: None * - * DESCRIPTION: Release the global lock if it is locked. + * DESCRIPTION: Release the ACPI hardware Global Lock * ******************************************************************************/ void AcpiExReleaseGlobalLock ( - BOOLEAN LockedByMe) + UINT32 FieldFlags) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("ExReleaseGlobalLock"); + ACPI_FUNCTION_TRACE (ExReleaseGlobalLock); - /* Only attempt unlock if the caller locked it */ + /* Only use the lock if the AlwaysLock bit is set */ - if (LockedByMe) + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) { - /* OK, now release the lock */ + return_VOID; + } + + /* Release the global lock */ - Status = AcpiEvReleaseGlobalLock (); - if (ACPI_FAILURE (Status)) - { - /* Report the error, but there isn't much else we can do */ + Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); + if (ACPI_FAILURE (Status)) + { + /* Report the error, but there isn't much else we can do */ - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not release ACPI Global Lock")); - } + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not release Global Lock")); } return_VOID; @@ -383,7 +454,7 @@ AcpiExDigitsNeeded ( ACPI_INTEGER CurrentValue; - ACPI_FUNCTION_TRACE ("ExDigitsNeeded"); + ACPI_FUNCTION_TRACE (ExDigitsNeeded); /* ACPI_INTEGER is unsigned, so we don't worry about a '-' prefix */ diff --git a/sys/dist/acpica/hwacpi.c b/sys/dist/acpica/hwacpi.c index 62931fc18b4..b2ce486cda4 100644 --- a/sys/dist/acpica/hwacpi.c +++ b/sys/dist/acpica/hwacpi.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface - * xRevision: 1.73 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,9 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwacpi.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __HWACPI_C__ -#include "acpi.h" +#include <dist/acpica/acpi.h> #define _COMPONENT ACPI_HARDWARE @@ -129,49 +126,6 @@ __KERNEL_RCSID(0, "$NetBSD: hwacpi.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); /****************************************************************************** * - * FUNCTION: AcpiHwInitialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize and validate the various ACPI registers defined in - * the FADT. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiHwInitialize ( - void) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE ("HwInitialize"); - - - /* We must have the ACPI tables by the time we get here */ - - if (!AcpiGbl_FADT) - { - ACPI_ERROR ((AE_INFO, "No FADT is present")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - - /* Sanity check the FADT for valid values */ - - Status = AcpiUtValidateFadt (); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - return_ACPI_STATUS (AE_OK); -} - - -/****************************************************************************** - * * FUNCTION: AcpiHwSetMode * * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY @@ -191,13 +145,13 @@ AcpiHwSetMode ( UINT32 Retry; - ACPI_FUNCTION_TRACE ("HwSetMode"); + ACPI_FUNCTION_TRACE (HwSetMode); /* * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, * system does not support mode transition. */ - if (!AcpiGbl_FADT->SmiCmd) + if (!AcpiGbl_FADT.SmiCommand) { ACPI_ERROR ((AE_INFO, "No SMI_CMD in FADT, mode transition failed")); return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); @@ -210,7 +164,7 @@ AcpiHwSetMode ( * we make sure both the numbers are zero to determine these * transitions are not supported. */ - if (!AcpiGbl_FADT->AcpiEnable && !AcpiGbl_FADT->AcpiDisable) + if (!AcpiGbl_FADT.AcpiEnable && !AcpiGbl_FADT.AcpiDisable) { ACPI_ERROR ((AE_INFO, "No ACPI mode transition supported in this system (enable/disable both zero)")); @@ -223,8 +177,8 @@ AcpiHwSetMode ( /* BIOS should have disabled ALL fixed and GP events */ - Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, - (UINT32) AcpiGbl_FADT->AcpiEnable, 8); + Status = AcpiOsWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.AcpiEnable, 8); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); break; @@ -234,8 +188,8 @@ AcpiHwSetMode ( * BIOS should clear all fixed status bits and restore fixed event * enable bits to default */ - Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, - (UINT32) AcpiGbl_FADT->AcpiDisable, 8); + Status = AcpiOsWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.AcpiDisable, 8); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable Legacy (non-ACPI) mode\n")); break; @@ -294,19 +248,19 @@ AcpiHwGetMode ( UINT32 Value; - ACPI_FUNCTION_TRACE ("HwGetMode"); + ACPI_FUNCTION_TRACE (HwGetMode); /* * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, * system does not support mode transition. */ - if (!AcpiGbl_FADT->SmiCmd) + if (!AcpiGbl_FADT.SmiCommand) { return_UINT32 (ACPI_SYS_MODE_ACPI); } - Status = AcpiGetRegister (ACPI_BITREG_SCI_ENABLE, &Value, ACPI_MTX_LOCK); + Status = AcpiGetRegister (ACPI_BITREG_SCI_ENABLE, &Value); if (ACPI_FAILURE (Status)) { return_UINT32 (ACPI_SYS_MODE_LEGACY); diff --git a/sys/dist/acpica/hwgpe.c b/sys/dist/acpica/hwgpe.c index be13d6f3261..490cf76f73f 100644 --- a/sys/dist/acpica/hwgpe.c +++ b/sys/dist/acpica/hwgpe.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: hwgpe - Low level GPE enable/disable/clear functions - * xRevision: 1.72 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,11 +115,8 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwgpe.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME ("hwgpe") @@ -191,16 +188,20 @@ AcpiHwClearGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo) { ACPI_STATUS Status; + UINT8 RegisterBit; ACPI_FUNCTION_ENTRY (); + RegisterBit = (UINT8) + (1 << (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + /* * Write a one to the appropriate bit in the status register to * clear this GPE. */ - Status = AcpiHwLowLevelWrite (8, GpeEventInfo->RegisterBit, + Status = AcpiHwLowLevelWrite (8, RegisterBit, &GpeEventInfo->RegisterInfo->StatusAddress); return (Status); @@ -246,7 +247,8 @@ AcpiHwGetGpeStatus ( /* Get the register bitmask for this GPE */ - RegisterBit = GpeEventInfo->RegisterBit; + RegisterBit = (UINT8) + (1 << (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); /* GPE currently enabled? (enabled for runtime?) */ @@ -479,7 +481,7 @@ AcpiHwDisableAllGpes ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("HwDisableAllGpes"); + ACPI_FUNCTION_TRACE (HwDisableAllGpes); Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock); @@ -507,7 +509,7 @@ AcpiHwEnableAllRuntimeGpes ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("HwEnableAllRuntimeGpes"); + ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes); Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock); @@ -534,7 +536,7 @@ AcpiHwEnableAllWakeupGpes ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("HwEnableAllWakeupGpes"); + ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes); Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock); diff --git a/sys/dist/acpica/hwregs.c b/sys/dist/acpica/hwregs.c index e4f3f16df65..2cc992d6223 100644 --- a/sys/dist/acpica/hwregs.c +++ b/sys/dist/acpica/hwregs.c @@ -3,7 +3,7 @@ * * Module Name: hwregs - Read/write access functions for the various ACPI * control and status registers. - * xRevision: 1.176 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,14 +116,11 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwregs.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __HWREGS_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME ("hwregs") @@ -133,9 +130,9 @@ __KERNEL_RCSID(0, "$NetBSD: hwregs.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); * * FUNCTION: AcpiHwClearAcpiStatus * - * PARAMETERS: Flags - Lock the hardware or not + * PARAMETERS: None * - * RETURN: none + * RETURN: None * * DESCRIPTION: Clears all fixed and general purpose status bits * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED @@ -144,26 +141,20 @@ __KERNEL_RCSID(0, "$NetBSD: hwregs.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); ACPI_STATUS AcpiHwClearAcpiStatus ( - UINT32 Flags) + void) { ACPI_STATUS Status; + ACPI_CPU_FLAGS LockFlags = 0; - ACPI_FUNCTION_TRACE ("HwClearAcpiStatus"); + ACPI_FUNCTION_TRACE (HwClearAcpiStatus); ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n", ACPI_BITMASK_ALL_FIXED_STATUS, - (UINT16) ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm1aEvtBlk.Address))); + (UINT16) AcpiGbl_FADT.XPm1aEventBlock.Address)); - if (Flags & ACPI_MTX_LOCK) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, @@ -175,10 +166,10 @@ AcpiHwClearAcpiStatus ( /* Clear the fixed events */ - if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1bEvtBlk.Address)) + if (AcpiGbl_FADT.XPm1bEventBlock.Address) { Status = AcpiHwLowLevelWrite (16, ACPI_BITMASK_ALL_FIXED_STATUS, - &AcpiGbl_FADT->XPm1bEvtBlk); + &AcpiGbl_FADT.XPm1bEventBlock); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -190,10 +181,7 @@ AcpiHwClearAcpiStatus ( Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); UnlockAndExit: - if (Flags & ACPI_MTX_LOCK) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); - } + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); return_ACPI_STATUS (Status); } @@ -220,11 +208,10 @@ AcpiGetSleepTypeData ( UINT8 *SleepTypeB) { ACPI_STATUS Status = AE_OK; - ACPI_PARAMETER_INFO Info; - const char *SleepStateName; + ACPI_EVALUATE_INFO *Info; - ACPI_FUNCTION_TRACE ("AcpiGetSleepTypeData"); + ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData); /* Validate parameters */ @@ -235,47 +222,53 @@ AcpiGetSleepTypeData ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Evaluate the namespace object containing the values for this state */ + /* Allocate the evaluation information block */ - Info.Parameters = NULL; - Info.ReturnObject = NULL; - SleepStateName = ACPI_CAST_CONST_PTR (char, AcpiGbl_SleepStateNames[SleepState]); + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Pathname = ACPI_CAST_CONST_PTR (char, AcpiGbl_SleepStateNames[SleepState]); + + /* Evaluate the namespace object containing the values for this state */ - Status = AcpiNsEvaluateByName (SleepStateName, &Info); + Status = AcpiNsEvaluate (Info); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating SleepState [%s]\n", - AcpiFormatException (Status), SleepStateName)); + AcpiFormatException (Status), Info->Pathname)); - return_ACPI_STATUS (Status); + goto Cleanup; } /* Must have a return object */ - if (!Info.ReturnObject) + if (!Info->ReturnObject) { ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]", - SleepStateName)); + Info->Pathname)); Status = AE_NOT_EXIST; } /* It must be of type Package */ - else if (ACPI_GET_OBJECT_TYPE (Info.ReturnObject) != ACPI_TYPE_PACKAGE) + else if (ACPI_GET_OBJECT_TYPE (Info->ReturnObject) != ACPI_TYPE_PACKAGE) { ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package")); Status = AE_AML_OPERAND_TYPE; } /* - * The package must have at least two elements. NOTE (March 2005): This + * The package must have at least two elements. NOTE (March 2005): This * goes against the current ACPI spec which defines this object as a - * package with one encoded DWORD element. However, existing practice + * package with one encoded DWORD element. However, existing practice * by BIOS vendors seems to be to have 2 or more elements, at least * one per sleep type (A/B). */ - else if (Info.ReturnObject->Package.Count < 2) + else if (Info->ReturnObject->Package.Count < 2) { ACPI_ERROR ((AE_INFO, "Sleep State return package does not have at least two elements")); @@ -284,15 +277,15 @@ AcpiGetSleepTypeData ( /* The first two elements must both be of type Integer */ - else if ((ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[0]) + else if ((ACPI_GET_OBJECT_TYPE (Info->ReturnObject->Package.Elements[0]) != ACPI_TYPE_INTEGER) || - (ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[1]) + (ACPI_GET_OBJECT_TYPE (Info->ReturnObject->Package.Elements[1]) != ACPI_TYPE_INTEGER)) { ACPI_ERROR ((AE_INFO, "Sleep State return package elements are not both Integers (%s, %s)", - AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[0]), - AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[1]))); + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[0]), + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[1]))); Status = AE_AML_OPERAND_TYPE; } else @@ -300,23 +293,28 @@ AcpiGetSleepTypeData ( /* Valid _Sx_ package size, type, and value */ *SleepTypeA = (UINT8) - (Info.ReturnObject->Package.Elements[0])->Integer.Value; + (Info->ReturnObject->Package.Elements[0])->Integer.Value; *SleepTypeB = (UINT8) - (Info.ReturnObject->Package.Elements[1])->Integer.Value; + (Info->ReturnObject->Package.Elements[1])->Integer.Value; } if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While evaluating SleepState [%s], bad Sleep object %p type %s", - SleepStateName, Info.ReturnObject, - AcpiUtGetObjectTypeName (Info.ReturnObject))); + Info->Pathname, Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); } - AcpiUtRemoveReference (Info.ReturnObject); + AcpiUtRemoveReference (Info->ReturnObject); + +Cleanup: + ACPI_FREE (Info); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData) + /******************************************************************************* * @@ -353,9 +351,8 @@ AcpiHwGetBitRegisterInfo ( * * PARAMETERS: RegisterId - ID of ACPI BitRegister to access * ReturnValue - Value that was read from the register - * Flags - Lock the hardware or not * - * RETURN: Status and the value read from specified Register. Value + * RETURN: Status and the value read from specified Register. Value * returned is normalized to bit0 (is shifted all the way right) * * DESCRIPTION: ACPI BitRegister read function. @@ -365,15 +362,14 @@ AcpiHwGetBitRegisterInfo ( ACPI_STATUS AcpiGetRegister ( UINT32 RegisterId, - UINT32 *ReturnValue, - UINT32 Flags) + UINT32 *ReturnValue) { UINT32 RegisterValue = 0; ACPI_BIT_REGISTER_INFO *BitRegInfo; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiGetRegister"); + ACPI_FUNCTION_TRACE (AcpiGetRegister); /* Get the info structure corresponding to the requested ACPI Register */ @@ -384,24 +380,10 @@ AcpiGetRegister ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - if (Flags & ACPI_MTX_LOCK) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - /* Read from the register */ - Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, - BitRegInfo->ParentRegister, &RegisterValue); - - if (Flags & ACPI_MTX_LOCK) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); - } + Status = AcpiHwRegisterRead (ACPI_MTX_LOCK, + BitRegInfo->ParentRegister, &RegisterValue); if (ACPI_SUCCESS (Status)) { @@ -413,12 +395,14 @@ AcpiGetRegister ( *ReturnValue = RegisterValue; ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %8.8X register %X\n", - RegisterValue, BitRegInfo->ParentRegister)); + RegisterValue, BitRegInfo->ParentRegister)); } return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetRegister) + /******************************************************************************* * @@ -427,7 +411,6 @@ AcpiGetRegister ( * PARAMETERS: RegisterId - ID of ACPI BitRegister to access * Value - (only used on write) value to write to the * Register, NOT pre-normalized to the bit pos - * Flags - Lock the hardware or not * * RETURN: Status * @@ -438,15 +421,15 @@ AcpiGetRegister ( ACPI_STATUS AcpiSetRegister ( UINT32 RegisterId, - UINT32 Value, - UINT32 Flags) + UINT32 Value) { UINT32 RegisterValue = 0; ACPI_BIT_REGISTER_INFO *BitRegInfo; ACPI_STATUS Status; + ACPI_CPU_FLAGS LockFlags; - ACPI_FUNCTION_TRACE_U32 ("AcpiSetRegister", RegisterId); + ACPI_FUNCTION_TRACE_U32 (AcpiSetRegister, RegisterId); /* Get the info structure corresponding to the requested ACPI Register */ @@ -458,14 +441,7 @@ AcpiSetRegister ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - if (Flags & ACPI_MTX_LOCK) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); /* Always do a register read first so we can insert the new bits */ @@ -488,8 +464,8 @@ AcpiSetRegister ( case ACPI_REGISTER_PM1_STATUS: /* - * Status Registers are different from the rest. Clear by - * writing 1, and writing 0 has no effect. So, the only relevant + * Status Registers are different from the rest. Clear by + * writing 1, and writing 0 has no effect. So, the only relevant * information is the single bit we're interested in, all others should * be written as 0 so they will be left unchanged. */ @@ -507,7 +483,7 @@ AcpiSetRegister ( case ACPI_REGISTER_PM1_ENABLE: ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, - BitRegInfo->AccessBitMask, Value); + BitRegInfo->AccessBitMask, Value); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, (UINT16) RegisterValue); @@ -521,10 +497,11 @@ AcpiSetRegister ( * Note that at this level, the fact that there are actually TWO * registers (A and B - and B may not exist) is abstracted. */ - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", RegisterValue)); + ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", + RegisterValue)); ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, - BitRegInfo->AccessBitMask, Value); + BitRegInfo->AccessBitMask, Value); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, (UINT16) RegisterValue); @@ -542,16 +519,14 @@ AcpiSetRegister ( ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n", RegisterValue, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( - AcpiGbl_FADT->XPm2CntBlk.Address)))); + ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XPm2ControlBlock.Address))); ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, BitRegInfo->AccessBitMask, Value); ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", RegisterValue, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( - AcpiGbl_FADT->XPm2CntBlk.Address)))); + ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XPm2ControlBlock.Address))); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue)); @@ -565,10 +540,7 @@ AcpiSetRegister ( UnlockAndExit: - if (Flags & ACPI_MTX_LOCK) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); - } + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); /* Normalize the value that was read */ @@ -577,23 +549,24 @@ UnlockAndExit: BitRegInfo->BitPosition)); ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", - Value, RegisterValue, BitRegInfo->ParentRegister)); + Value, RegisterValue, BitRegInfo->ParentRegister)); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiSetRegister) + /****************************************************************************** * * FUNCTION: AcpiHwRegisterRead * - * PARAMETERS: UseLock - Mutex hw access - * RegisterId - RegisterID + Offset + * PARAMETERS: UseLock - Lock hardware? True/False + * RegisterId - ACPI Register ID * ReturnValue - Where the register value is returned * * RETURN: Status and the value read. * - * DESCRIPTION: Acpi register read function. Registers are read at the - * given offset. + * DESCRIPTION: Read from the specified ACPI register * ******************************************************************************/ @@ -606,25 +579,22 @@ AcpiHwRegisterRead ( UINT32 Value1 = 0; UINT32 Value2 = 0; ACPI_STATUS Status; + ACPI_CPU_FLAGS LockFlags = 0; - ACPI_FUNCTION_TRACE ("HwRegisterRead"); + ACPI_FUNCTION_TRACE (HwRegisterRead); if (ACPI_MTX_LOCK == UseLock) { - Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); } switch (RegisterId) { case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ - Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aEvtBlk); + Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT.XPm1aEventBlock); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -632,7 +602,7 @@ AcpiHwRegisterRead ( /* PM1B is optional */ - Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bEvtBlk); + Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT.XPm1bEventBlock); Value1 |= Value2; break; @@ -654,31 +624,31 @@ AcpiHwRegisterRead ( case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ - Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aCntBlk); + Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT.XPm1aControlBlock); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } - Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bCntBlk); + Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT.XPm1bControlBlock); Value1 |= Value2; break; case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - Status = AcpiHwLowLevelRead (8, &Value1, &AcpiGbl_FADT->XPm2CntBlk); + Status = AcpiHwLowLevelRead (8, &Value1, &AcpiGbl_FADT.XPm2ControlBlock); break; case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - Status = AcpiHwLowLevelRead (32, &Value1, &AcpiGbl_FADT->XPmTmrBlk); + Status = AcpiHwLowLevelRead (32, &Value1, &AcpiGbl_FADT.XPmTimerBlock); break; case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ - Status = AcpiOsReadPort (AcpiGbl_FADT->SmiCmd, &Value1, 8); + Status = AcpiOsReadPort (AcpiGbl_FADT.SmiCommand, &Value1, 8); break; default: @@ -691,7 +661,7 @@ AcpiHwRegisterRead ( UnlockAndExit: if (ACPI_MTX_LOCK == UseLock) { - (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); } if (ACPI_SUCCESS (Status)) @@ -707,14 +677,26 @@ UnlockAndExit: * * FUNCTION: AcpiHwRegisterWrite * - * PARAMETERS: UseLock - Mutex hw access - * RegisterId - RegisterID + Offset + * PARAMETERS: UseLock - Lock hardware? True/False + * RegisterId - ACPI Register ID * Value - The value to write * * RETURN: Status * - * DESCRIPTION: Acpi register Write function. Registers are written at the - * given offset. + * DESCRIPTION: Write to the specified ACPI register + * + * NOTE: In accordance with the ACPI specification, this function automatically + * preserves the value of the following bits, meaning that these bits cannot be + * changed via this interface: + * + * PM1_CONTROL[0] = SCI_EN + * PM1_CONTROL[9] + * PM1_STATUS[11] + * + * ACPI References: + * 1) Hardware Ignored Bits: When software writes to a register with ignored + * bit fields, it preserves the ignored bit fields + * 2) SCI_EN: OSPM always preserves this bit position * ******************************************************************************/ @@ -725,25 +707,38 @@ AcpiHwRegisterWrite ( UINT32 Value) { ACPI_STATUS Status; + ACPI_CPU_FLAGS LockFlags = 0; + UINT32 ReadValue; - ACPI_FUNCTION_TRACE ("HwRegisterWrite"); + ACPI_FUNCTION_TRACE (HwRegisterWrite); if (ACPI_MTX_LOCK == UseLock) { - Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); } switch (RegisterId) { case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aEvtBlk); + /* Perform a read first to preserve certain bits (per ACPI spec) */ + + Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_STATUS, &ReadValue); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS (Value, ACPI_PM1_STATUS_PRESERVED_BITS, ReadValue); + + /* Now we can write the data */ + + Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1aEventBlock); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -751,11 +746,11 @@ AcpiHwRegisterWrite ( /* PM1B is optional */ - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bEvtBlk); + Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1bEventBlock); break; - case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/ + case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_XPm1aEnable); if (ACPI_FAILURE (Status)) @@ -771,37 +766,55 @@ AcpiHwRegisterWrite ( case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk); + /* + * Perform a read first to preserve certain bits (per ACPI spec) + * + * Note: This includes SCI_EN, we never want to change this bit + */ + Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, &ReadValue); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS (Value, ACPI_PM1_CONTROL_PRESERVED_BITS, ReadValue); + + /* Now we can write the data */ + + Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1aControlBlock); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk); + Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1bControlBlock); break; case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk); + Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1aControlBlock); break; case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ - Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk); + Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT.XPm1bControlBlock); break; case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ - Status = AcpiHwLowLevelWrite (8, Value, &AcpiGbl_FADT->XPm2CntBlk); + Status = AcpiHwLowLevelWrite (8, Value, &AcpiGbl_FADT.XPm2ControlBlock); break; case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ - Status = AcpiHwLowLevelWrite (32, Value, &AcpiGbl_FADT->XPmTmrBlk); + Status = AcpiHwLowLevelWrite (32, Value, &AcpiGbl_FADT.XPmTimerBlock); break; @@ -809,7 +822,7 @@ AcpiHwRegisterWrite ( /* SMI_CMD is currently always in IO space */ - Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, Value, 8); + Status = AcpiOsWritePort (AcpiGbl_FADT.SmiCommand, Value, 8); break; @@ -821,7 +834,7 @@ AcpiHwRegisterWrite ( UnlockAndExit: if (ACPI_MTX_LOCK == UseLock) { - (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); } return_ACPI_STATUS (Status); @@ -852,7 +865,7 @@ AcpiHwLowLevelRead ( ACPI_STATUS Status; - ACPI_FUNCTION_NAME ("HwLowLevelRead"); + ACPI_FUNCTION_NAME (HwLowLevelRead); /* @@ -865,10 +878,10 @@ AcpiHwLowLevelRead ( return (AE_OK); } - /* Get a local copy of the address. Handles possible alignment issues */ + /* Get a local copy of the address. Handles possible alignment issues */ ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); - if (!ACPI_VALID_ADDRESS (Address)) + if (!Address) { return (AE_OK); } @@ -878,34 +891,31 @@ AcpiHwLowLevelRead ( * Two address spaces supported: Memory or IO. * PCI_Config is not supported here because the GAS struct is insufficient */ - switch (Reg->AddressSpaceId) + switch (Reg->SpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: Status = AcpiOsReadMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Address), - Value, Width); + (ACPI_PHYSICAL_ADDRESS) Address, Value, Width); break; case ACPI_ADR_SPACE_SYSTEM_IO: - Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Address), - Value, Width); + Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) Address, Value, Width); break; default: ACPI_ERROR ((AE_INFO, - "Unsupported address space: %X", Reg->AddressSpaceId)); + "Unsupported address space: %X", Reg->SpaceId)); return (AE_BAD_PARAMETER); } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, Width, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Address)), - AcpiUtGetRegionName (Reg->AddressSpaceId))); + *Value, Width, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); return (Status); } @@ -935,7 +945,7 @@ AcpiHwLowLevelWrite ( ACPI_STATUS Status; - ACPI_FUNCTION_NAME ("HwLowLevelWrite"); + ACPI_FUNCTION_NAME (HwLowLevelWrite); /* @@ -948,10 +958,10 @@ AcpiHwLowLevelWrite ( return (AE_OK); } - /* Get a local copy of the address. Handles possible alignment issues */ + /* Get a local copy of the address. Handles possible alignment issues */ ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); - if (!ACPI_VALID_ADDRESS (Address)) + if (!Address) { return (AE_OK); } @@ -960,34 +970,32 @@ AcpiHwLowLevelWrite ( * Two address spaces supported: Memory or IO. * PCI_Config is not supported here because the GAS struct is insufficient */ - switch (Reg->AddressSpaceId) + switch (Reg->SpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: Status = AcpiOsWriteMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Address), - Value, Width); + (ACPI_PHYSICAL_ADDRESS) Address, Value, Width); break; case ACPI_ADR_SPACE_SYSTEM_IO: - Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Address), - Value, Width); + Status = AcpiOsWritePort ( + (ACPI_IO_ADDRESS) Address, Value, Width); break; default: ACPI_ERROR ((AE_INFO, - "Unsupported address space: %X", Reg->AddressSpaceId)); + "Unsupported address space: %X", Reg->SpaceId)); return (AE_BAD_PARAMETER); } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, Width, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Address)), - AcpiUtGetRegionName (Reg->AddressSpaceId))); + Value, Width, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); return (Status); } diff --git a/sys/dist/acpica/hwsleep.c b/sys/dist/acpica/hwsleep.c index ab7f9ff73ab..fc9a460ee13 100644 --- a/sys/dist/acpica/hwsleep.c +++ b/sys/dist/acpica/hwsleep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface - * xRevision: 1.80 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,10 +115,8 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwsleep.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME ("hwsleep") @@ -139,28 +137,46 @@ __KERNEL_RCSID(0, "$NetBSD: hwsleep.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); ACPI_STATUS AcpiSetFirmwareWakingVector ( - ACPI_PHYSICAL_ADDRESS PhysicalAddress) + ACPI_PHYSICAL_ADDRESS PhysicalAddress) { + ACPI_TABLE_FACS *Facs; + ACPI_STATUS Status; + - ACPI_FUNCTION_TRACE ("AcpiSetFirmwareWakingVector"); + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); + /* Get the FACS */ + + Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, + ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } /* Set the vector */ - if (AcpiGbl_CommonFACS.VectorWidth == 32) + if ((Facs->Length < 32) || + (!(Facs->XFirmwareWakingVector))) { - *(ACPI_CAST_PTR (UINT32, AcpiGbl_CommonFACS.FirmwareWakingVector)) - = (UINT32) PhysicalAddress; + /* + * ACPI 1.0 FACS or short table or optional X_ field is zero + */ + Facs->FirmwareWakingVector = (UINT32) PhysicalAddress; } else { - *AcpiGbl_CommonFACS.FirmwareWakingVector - = PhysicalAddress; + /* + * ACPI 2.0 FACS with valid X_ field + */ + Facs->XFirmwareWakingVector = PhysicalAddress; } return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) + /******************************************************************************* * @@ -178,10 +194,13 @@ AcpiSetFirmwareWakingVector ( ACPI_STATUS AcpiGetFirmwareWakingVector ( - ACPI_PHYSICAL_ADDRESS *PhysicalAddress) + ACPI_PHYSICAL_ADDRESS *PhysicalAddress) { + ACPI_TABLE_FACS *Facs; + ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiGetFirmwareWakingVector"); + + ACPI_FUNCTION_TRACE (AcpiGetFirmwareWakingVector); if (!PhysicalAddress) @@ -189,22 +208,39 @@ AcpiGetFirmwareWakingVector ( return_ACPI_STATUS (AE_BAD_PARAMETER); } + /* Get the FACS */ + + Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, + ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Facs)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* Get the vector */ - if (AcpiGbl_CommonFACS.VectorWidth == 32) + if ((Facs->Length < 32) || + (!(Facs->XFirmwareWakingVector))) { - *PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) - *(ACPI_CAST_PTR (UINT32, AcpiGbl_CommonFACS.FirmwareWakingVector)); + /* + * ACPI 1.0 FACS or short table or optional X_ field is zero + */ + *PhysicalAddress = + (ACPI_PHYSICAL_ADDRESS) Facs->FirmwareWakingVector; } else { - *PhysicalAddress = - *AcpiGbl_CommonFACS.FirmwareWakingVector; + /* + * ACPI 2.0 FACS with valid X_ field + */ + *PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) Facs->XFirmwareWakingVector; } return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiGetFirmwareWakingVector) + /******************************************************************************* * @@ -230,7 +266,7 @@ AcpiEnterSleepStatePrep ( ACPI_OBJECT Arg; - ACPI_FUNCTION_TRACE ("AcpiEnterSleepStatePrep"); + ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); /* @@ -299,6 +335,8 @@ AcpiEnterSleepStatePrep ( return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep) + /******************************************************************************* * @@ -326,7 +364,7 @@ AcpiEnterSleepState ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiEnterSleepState"); + ACPI_FUNCTION_TRACE (AcpiEnterSleepState); if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || @@ -342,7 +380,7 @@ AcpiEnterSleepState ( /* Clear wake status */ - Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -350,7 +388,7 @@ AcpiEnterSleepState ( /* Clear all fixed and general purpose status bits */ - Status = AcpiHwClearAcpiStatus (ACPI_MTX_DO_NOT_LOCK); + Status = AcpiHwClearAcpiStatus (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -360,8 +398,7 @@ AcpiEnterSleepState ( { /* Disable BM arbitration */ - Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, - 1, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 1); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -480,19 +517,21 @@ AcpiEnterSleepState ( Retry = 1000; do { - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, - ACPI_MTX_DO_NOT_LOCK); + Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* - * Some BIOSs don't set WAK_STS at all. Give up waiting after + * Some BIOSs don't set WAK_STS at all. Give up waiting after * 1000 retries if it still isn't set. */ if (Retry-- == 0) + { break; + } + /* Spin until we wake */ } while (!InValue); @@ -500,6 +539,8 @@ AcpiEnterSleepState ( return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiEnterSleepState) + /******************************************************************************* * @@ -522,16 +563,16 @@ AcpiEnterSleepStateS4bios ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiEnterSleepStateS4bios"); + ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); - Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiHwClearAcpiStatus (ACPI_MTX_DO_NOT_LOCK); + Status = AcpiHwClearAcpiStatus (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -556,13 +597,12 @@ AcpiEnterSleepStateS4bios ( ACPI_FLUSH_CPU_CACHE (); - Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, - (UINT32) AcpiGbl_FADT->S4BiosReq, 8); + Status = AcpiOsWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); do { AcpiOsStall(1000); - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, - ACPI_MTX_DO_NOT_LOCK); + Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -572,6 +612,8 @@ AcpiEnterSleepStateS4bios ( return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios) + /******************************************************************************* * @@ -599,7 +641,7 @@ AcpiLeaveSleepState ( UINT32 PM1BControl; - ACPI_FUNCTION_TRACE ("AcpiLeaveSleepState"); + ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); /* @@ -694,16 +736,14 @@ AcpiLeaveSleepState ( /* Enable power button */ (void) AcpiSetRegister( - AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, - 1, ACPI_MTX_DO_NOT_LOCK); + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, 1); (void) AcpiSetRegister( - AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, - 1, ACPI_MTX_DO_NOT_LOCK); + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, 1); /* Enable BM arbitration */ - Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_LOCK); + Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -718,3 +758,6 @@ AcpiLeaveSleepState ( return_ACPI_STATUS (Status); } + +ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState) + diff --git a/sys/dist/acpica/hwtimer.c b/sys/dist/acpica/hwtimer.c index ce0b4d4042d..5515618df00 100644 --- a/sys/dist/acpica/hwtimer.c +++ b/sys/dist/acpica/hwtimer.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwtimer.c - ACPI Power Management Timer Interface - * xRevision: 1.31 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,10 +115,7 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwtimer.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" +#include <dist/acpica/acpi.h> #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME ("hwtimer") @@ -140,7 +137,7 @@ ACPI_STATUS AcpiGetTimerResolution ( UINT32 *Resolution) { - ACPI_FUNCTION_TRACE ("AcpiGetTimerResolution"); + ACPI_FUNCTION_TRACE (AcpiGetTimerResolution); if (!Resolution) @@ -148,7 +145,7 @@ AcpiGetTimerResolution ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - if (0 == AcpiGbl_FADT->TmrValExt) + if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0) { *Resolution = 24; } @@ -160,6 +157,8 @@ AcpiGetTimerResolution ( return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiGetTimerResolution) + /****************************************************************************** * @@ -180,7 +179,7 @@ AcpiGetTimer ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiGetTimer"); + ACPI_FUNCTION_TRACE (AcpiGetTimer); if (!Ticks) @@ -188,11 +187,13 @@ AcpiGetTimer ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - Status = AcpiHwLowLevelRead (32, Ticks, &AcpiGbl_FADT->XPmTmrBlk); + Status = AcpiHwLowLevelRead (32, Ticks, &AcpiGbl_FADT.XPmTimerBlock); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetTimer) + /****************************************************************************** * @@ -234,7 +235,7 @@ AcpiGetTimerDuration ( ACPI_INTEGER Quotient; - ACPI_FUNCTION_TRACE ("AcpiGetTimerDuration"); + ACPI_FUNCTION_TRACE (AcpiGetTimerDuration); if (!TimeElapsed) @@ -252,7 +253,7 @@ AcpiGetTimerDuration ( } else if (StartTicks > EndTicks) { - if (0 == AcpiGbl_FADT->TmrValExt) + if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0) { /* 24-bit Timer */ @@ -283,4 +284,5 @@ AcpiGetTimerDuration ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetTimerDuration) diff --git a/sys/dist/acpica/nsaccess.c b/sys/dist/acpica/nsaccess.c index 8dc240b6660..11b1583b206 100644 --- a/sys/dist/acpica/nsaccess.c +++ b/sys/dist/acpica/nsaccess.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsaccess - Top-level functions for accessing ACPI namespace - * xRevision: 1.196 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,15 +114,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsaccess.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSACCESS_C__ -#include "acpi.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acdispat.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdispat.h> #define _COMPONENT ACPI_NAMESPACE @@ -154,7 +151,7 @@ AcpiNsRootInitialize ( ACPI_STRING Val = NULL; - ACPI_FUNCTION_TRACE ("NsRootInitialize"); + ACPI_FUNCTION_TRACE (NsRootInitialize); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); @@ -221,8 +218,7 @@ AcpiNsRootInitialize ( if (!Val) { - /*XXXUNCONST*/ - Val = (void *)(intptr_t)InitVal->Val; + Val = __UNCONST(InitVal->Val); } /* @@ -285,32 +281,25 @@ AcpiNsRootInitialize ( ObjDesc->Mutex.Node = NewNode; ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1); - if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) - { - /* - * Create a counting semaphore for the - * global lock - */ - Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, - 1, &ObjDesc->Mutex.Semaphore); - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ObjDesc); - goto UnlockAndExit; - } + /* Create a mutex */ - /* - * We just created the mutex for the - * global lock, save it - */ - AcpiGbl_GlobalLockSemaphore = ObjDesc->Mutex.Semaphore; + Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + goto UnlockAndExit; } - else + + /* Special case for ACPI Global Lock */ + + if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) { - /* Create a mutex */ + AcpiGbl_GlobalLockMutex = ObjDesc; + + /* Create additional counting semaphore for global lock */ - Status = AcpiOsCreateSemaphore (1, 1, - &ObjDesc->Mutex.Semaphore); + Status = AcpiOsCreateSemaphore ( + 1, 0, &AcpiGbl_GlobalLockSemaphore); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); @@ -348,8 +337,8 @@ UnlockAndExit: if (ACPI_SUCCESS (Status)) { - Status = AcpiNsGetNodeByPath ("\\_GPE", NULL, ACPI_NS_NO_UPSEARCH, - &AcpiGbl_FadtGpeDevice); + Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH, + &AcpiGbl_FadtGpeDevice); } return_ACPI_STATUS (Status); @@ -400,11 +389,10 @@ AcpiNsLookup ( ACPI_OBJECT_TYPE TypeToCheckFor; ACPI_OBJECT_TYPE ThisSearchType; UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT; - UINT32 LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | - ACPI_NS_SEARCH_PARENT); + UINT32 LocalFlags; - ACPI_FUNCTION_TRACE ("NsLookup"); + ACPI_FUNCTION_TRACE (NsLookup); if (!ReturnNode) @@ -412,8 +400,9 @@ AcpiNsLookup ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - AcpiGbl_NsLookupCount++; + LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT); *ReturnNode = ACPI_ENTRY_NOT_FOUND; + AcpiGbl_NsLookupCount++; if (!AcpiGbl_RootNode) { @@ -443,15 +432,18 @@ AcpiNsLookup ( return_ACPI_STATUS (AE_AML_INTERNAL); } - /* - * This node might not be a actual "scope" node (such as a - * Device/Method, etc.) It could be a Package or other object node. - * Backup up the tree to find the containing scope node. - */ - while (!AcpiNsOpensScope (PrefixNode->Type) && - PrefixNode->Type != ACPI_TYPE_ANY) + if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE)) { - PrefixNode = AcpiNsGetParentNode (PrefixNode); + /* + * This node might not be a actual "scope" node (such as a + * Device/Method, etc.) It could be a Package or other object node. + * Backup up the tree to find the containing scope node. + */ + while (!AcpiNsOpensScope (PrefixNode->Type) && + PrefixNode->Type != ACPI_TYPE_ANY) + { + PrefixNode = AcpiNsGetParentNode (PrefixNode); + } } } diff --git a/sys/dist/acpica/nsalloc.c b/sys/dist/acpica/nsalloc.c index c62713526ab..afc72d322f6 100644 --- a/sys/dist/acpica/nsalloc.c +++ b/sys/dist/acpica/nsalloc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsalloc - Namespace allocation and deletion utilities - * xRevision: 1.100 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,24 +115,15 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsalloc.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSALLOC_C__ -#include "acpi.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsalloc") -/* Local prototypes */ - -static void -AcpiNsRemoveReference ( - ACPI_NAMESPACE_NODE *Node); - /******************************************************************************* * @@ -151,12 +142,15 @@ AcpiNsCreateNode ( UINT32 Name) { ACPI_NAMESPACE_NODE *Node; +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + UINT32 Temp; +#endif - ACPI_FUNCTION_TRACE ("NsCreateNode"); + ACPI_FUNCTION_TRACE (NsCreateNode); - Node = ACPI_MEM_CALLOCATE (sizeof (ACPI_NAMESPACE_NODE)); + Node = AcpiOsAcquireObject (AcpiGbl_NamespaceCache); if (!Node) { return_PTR (NULL); @@ -164,10 +158,16 @@ AcpiNsCreateNode ( ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++); - Node->Name.Integer = Name; - Node->ReferenceCount = 1; - ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED); +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + Temp = AcpiGbl_NsNodeList->TotalAllocated - AcpiGbl_NsNodeList->TotalFreed; + if (Temp > AcpiGbl_NsNodeList->MaxOccupied) + { + AcpiGbl_NsNodeList->MaxOccupied = Temp; + } +#endif + Node->Name.Integer = Name; + ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED); return_PTR (Node); } @@ -193,7 +193,7 @@ AcpiNsDeleteNode ( ACPI_NAMESPACE_NODE *NextNode; - ACPI_FUNCTION_TRACE_PTR ("NsDeleteNode", Node); + ACPI_FUNCTION_TRACE_PTR (NsDeleteNode, Node); ParentNode = AcpiNsGetParentNode (Node); @@ -239,10 +239,10 @@ AcpiNsDeleteNode ( ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); /* - * Detach an object if there is one then delete the node + * Detach an object if there is one, then delete the node */ AcpiNsDetachObject (Node); - ACPI_MEM_FREE (Node); + (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node); return_VOID; } @@ -278,7 +278,7 @@ AcpiNsInstallNode ( ACPI_NAMESPACE_NODE *ChildNode; - ACPI_FUNCTION_TRACE ("NsInstallNode"); + ACPI_FUNCTION_TRACE (NsInstallNode); /* @@ -327,15 +327,6 @@ AcpiNsInstallNode ( AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type), ParentNode)); - /* - * Increment the reference count(s) of all parents up to - * the root! - */ - while ((Node = AcpiNsGetParentNode (Node)) != NULL) - { - Node->ReferenceCount++; - } - return_VOID; } @@ -359,11 +350,10 @@ AcpiNsDeleteChildren ( { ACPI_NAMESPACE_NODE *ChildNode; ACPI_NAMESPACE_NODE *NextNode; - ACPI_NAMESPACE_NODE *Node; UINT8 Flags; - ACPI_FUNCTION_TRACE_PTR ("NsDeleteChildren", ParentNode); + ACPI_FUNCTION_TRACE_PTR (NsDeleteChildren, ParentNode); if (!ParentNode) @@ -386,8 +376,8 @@ AcpiNsDeleteChildren ( { /* Get the things we need */ - NextNode = ChildNode->Peer; - Flags = ChildNode->Flags; + NextNode = ChildNode->Peer; + Flags = ChildNode->Flags; /* Grandchildren should have all been deleted already */ @@ -409,28 +399,9 @@ AcpiNsDeleteChildren ( */ AcpiNsDetachObject (ChildNode); - /* - * Decrement the reference count(s) of all parents up to - * the root! (counts were incremented when the node was created) - */ - Node = ChildNode; - while ((Node = AcpiNsGetParentNode (Node)) != NULL) - { - Node->ReferenceCount--; - } - - /* There should be only one reference remaining on this node */ - - if (ChildNode->ReferenceCount != 1) - { - ACPI_WARNING ((AE_INFO, - "Existing references (%d) on node being deleted (%p)", - ChildNode->ReferenceCount, ChildNode)); - } - /* Now we can delete the node */ - ACPI_MEM_FREE (ChildNode); + (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, ChildNode); /* And move on to the next child in the list */ @@ -468,7 +439,7 @@ AcpiNsDeleteNamespaceSubtree ( UINT32 Level = 1; - ACPI_FUNCTION_TRACE ("NsDeleteNamespaceSubtree"); + ACPI_FUNCTION_TRACE (NsDeleteNamespaceSubtree); if (!ParentNode) @@ -484,8 +455,7 @@ AcpiNsDeleteNamespaceSubtree ( { /* Get the next node in this scope (NULL if none) */ - ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, - ChildNode); + ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode); if (ChildNode) { /* Found a child node - detach any attached object */ @@ -535,62 +505,6 @@ AcpiNsDeleteNamespaceSubtree ( /******************************************************************************* * - * FUNCTION: AcpiNsRemoveReference - * - * PARAMETERS: Node - Named node whose reference count is to be - * decremented - * - * RETURN: None. - * - * DESCRIPTION: Remove a Node reference. Decrements the reference count - * of all parent Nodes up to the root. Any node along - * the way that reaches zero references is freed. - * - ******************************************************************************/ - -static void -AcpiNsRemoveReference ( - ACPI_NAMESPACE_NODE *Node) -{ - ACPI_NAMESPACE_NODE *ParentNode; - ACPI_NAMESPACE_NODE *ThisNode; - - - ACPI_FUNCTION_ENTRY (); - - - /* - * Decrement the reference count(s) of this node and all - * nodes up to the root, Delete anything with zero remaining references. - */ - ThisNode = Node; - while (ThisNode) - { - /* Prepare to move up to parent */ - - ParentNode = AcpiNsGetParentNode (ThisNode); - - /* Decrement the reference count on this node */ - - ThisNode->ReferenceCount--; - - /* Delete the node if no more references */ - - if (!ThisNode->ReferenceCount) - { - /* Delete all children and delete the node */ - - AcpiNsDeleteChildren (ThisNode); - AcpiNsDeleteNode (ThisNode); - } - - ThisNode = ParentNode; - } -} - - -/******************************************************************************* - * * FUNCTION: AcpiNsDeleteNamespaceByOwner * * PARAMETERS: OwnerId - All nodes with this owner will be deleted @@ -601,6 +515,8 @@ AcpiNsRemoveReference ( * specific ID. Used to delete entire ACPI tables. All * reference counts are updated. * + * MUTEX: Locks namespace during deletion walk. + * ******************************************************************************/ void @@ -609,11 +525,12 @@ AcpiNsDeleteNamespaceByOwner ( { ACPI_NAMESPACE_NODE *ChildNode; ACPI_NAMESPACE_NODE *DeletionNode; - UINT32 Level; ACPI_NAMESPACE_NODE *ParentNode; + UINT32 Level; + ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_U32 ("NsDeleteNamespaceByOwner", OwnerId); + ACPI_FUNCTION_TRACE_U32 (NsDeleteNamespaceByOwner, OwnerId); if (OwnerId == 0) @@ -621,10 +538,18 @@ AcpiNsDeleteNamespaceByOwner ( return_VOID; } - ParentNode = AcpiGbl_RootNode; - ChildNode = NULL; - DeletionNode = NULL; - Level = 1; + /* Lock namespace for possible update */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + DeletionNode = NULL; + ParentNode = AcpiGbl_RootNode; + ChildNode = NULL; + Level = 1; /* * Traverse the tree of nodes until we bubble back up @@ -640,7 +565,8 @@ AcpiNsDeleteNamespaceByOwner ( if (DeletionNode) { - AcpiNsRemoveReference (DeletionNode); + AcpiNsDeleteChildren (DeletionNode); + AcpiNsDeleteNode (DeletionNode); DeletionNode = NULL; } @@ -695,6 +621,7 @@ AcpiNsDeleteNamespaceByOwner ( } } + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_VOID; } diff --git a/sys/dist/acpica/nsdump.c b/sys/dist/acpica/nsdump.c index 9f1f254868a..11db0b2d04b 100644 --- a/sys/dist/acpica/nsdump.c +++ b/sys/dist/acpica/nsdump.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsdump - table dumping routines for debug - * xRevision: 1.176 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsdump.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __NSDUMP_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acparser.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acparser.h> #define _COMPONENT ACPI_NAMESPACE @@ -166,7 +163,7 @@ AcpiNsPrintPathname ( ACPI_NATIVE_UINT i; - ACPI_FUNCTION_NAME ("NsPrintPathname"); + ACPI_FUNCTION_NAME (NsPrintPathname); if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE)) @@ -223,7 +220,7 @@ AcpiNsDumpPathname ( UINT32 Component) { - ACPI_FUNCTION_TRACE ("NsDumpPathname"); + ACPI_FUNCTION_TRACE (NsDumpPathname); /* Do this only if the requested debug level and component are enabled */ @@ -274,7 +271,7 @@ AcpiNsDumpOneObject ( UINT32 i; - ACPI_FUNCTION_NAME ("NsDumpOneObject"); + ACPI_FUNCTION_NAME (NsDumpOneObject); /* Is output enabled? */ @@ -316,6 +313,8 @@ AcpiNsDumpOneObject ( if (!AcpiUtValidAcpiName (ThisNode->Name.Integer)) { + ThisNode->Name.Integer = AcpiUtRepairName (ThisNode->Name.Ascii); + ACPI_WARNING ((AE_INFO, "Invalid ACPI Name %08X", ThisNode->Name.Integer)); } @@ -334,6 +333,13 @@ AcpiNsDumpOneObject ( ObjDesc = AcpiNsGetAttachedObject (ThisNode); AcpiDbgLevel = DbgLevel; + /* Temp nodes are those nodes created by a control method */ + + if (ThisNode->Flags & ANOBJ_TEMPORARY) + { + AcpiOsPrintf ("(T) "); + } + switch (Info->DisplayType & ACPI_DISPLAY_MASK) { case ACPI_DISPLAY_SUMMARY: @@ -729,8 +735,8 @@ AcpiNsDumpObjects ( Info.DisplayType = DisplayType; (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, - ACPI_NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject, - (void *) &Info, NULL); + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsDumpOneObject, (void *) &Info, NULL); } @@ -790,7 +796,7 @@ AcpiNsDumpTables ( ACPI_HANDLE SearchHandle = SearchBase; - ACPI_FUNCTION_TRACE ("NsDumpTables"); + ACPI_FUNCTION_TRACE (NsDumpTables); if (!AcpiGbl_RootNode) diff --git a/sys/dist/acpica/nsdumpdv.c b/sys/dist/acpica/nsdumpdv.c index c6049267489..fb2bf2c2fd8 100644 --- a/sys/dist/acpica/nsdumpdv.c +++ b/sys/dist/acpica/nsdumpdv.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsdump - table dumping routines for debug - * xRevision: 1.17 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,9 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsdumpdv.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSDUMPDV_C__ -#include "acpi.h" +#include <dist/acpica/acpi.h> /* TBD: This entire module is apparently obsolete and should be removed */ @@ -131,7 +128,7 @@ __KERNEL_RCSID(0, "$NetBSD: nsdumpdv.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); #ifdef ACPI_OBSOLETE_FUNCTIONS #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) -#include "acnamesp.h" +#include <dist/acpica/acnamesp.h> /******************************************************************************* * @@ -162,7 +159,7 @@ AcpiNsDumpOneDevice ( UINT32 i; - ACPI_FUNCTION_NAME ("NsDumpOneDevice"); + ACPI_FUNCTION_NAME (NsDumpOneDevice); Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); @@ -181,7 +178,7 @@ AcpiNsDumpOneDevice ( " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", Info->HardwareId.Value, ACPI_FORMAT_UINT64 (Info->Address), Info->CurrentStatus)); - ACPI_MEM_FREE (Info); + ACPI_FREE (Info); } return (Status); @@ -208,7 +205,7 @@ AcpiNsDumpRootDevices ( ACPI_STATUS Status; - ACPI_FUNCTION_NAME ("NsDumpRootDevices"); + ACPI_FUNCTION_NAME (NsDumpRootDevices); /* Only dump the table if tracing is enabled */ diff --git a/sys/dist/acpica/nseval.c b/sys/dist/acpica/nseval.c index ff7b667087e..1dbde832e35 100644 --- a/sys/dist/acpica/nseval.c +++ b/sys/dist/acpica/nseval.c @@ -1,8 +1,7 @@ /******************************************************************************* * - * Module Name: nseval - Object evaluation interfaces -- includes control - * method lookup and execution. - * xRevision: 1.137 $ + * Module Name: nseval - Object evaluation, includes control method execution + * $Revision: 1.2 $ * ******************************************************************************/ @@ -10,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,235 +115,26 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nseval.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSEVAL_C__ -#include "acpi.h" -#include "acparser.h" -#include "acinterp.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nseval") -/* Local prototypes */ - -static ACPI_STATUS -AcpiNsExecuteControlMethod ( - ACPI_PARAMETER_INFO *Info); - -static ACPI_STATUS -AcpiNsGetObjectValue ( - ACPI_PARAMETER_INFO *Info); - - -/******************************************************************************* - * - * FUNCTION: AcpiNsEvaluateRelative - * - * PARAMETERS: Pathname - Name of method to execute, If NULL, the - * handle is the object to execute - * Info - Method info block, contains: - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. - * Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * - * RETURN: Status - * - * DESCRIPTION: Evaluate the object or find and execute the requested method - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsEvaluateRelative ( - const char *Pathname, - ACPI_PARAMETER_INFO *Info) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node = NULL; - ACPI_GENERIC_STATE *ScopeInfo; - char *InternalPath = NULL; - - - ACPI_FUNCTION_TRACE ("NsEvaluateRelative"); - - - /* - * Must have a valid object handle - */ - if (!Info || !Info->Node) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Build an internal name string for the method */ - - Status = AcpiNsInternalizeName (Pathname, &InternalPath); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - ScopeInfo = AcpiUtCreateGenericState (); - if (!ScopeInfo) - { - goto Cleanup1; - } - - /* Get the prefix handle and Node */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - Info->Node = AcpiNsMapHandleToNode (Info->Node); - if (!Info->Node) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - Status = AE_BAD_PARAMETER; - goto Cleanup; - } - - /* Lookup the name in the namespace */ - - ScopeInfo->Scope.Node = Info->Node; - Status = AcpiNsLookup (ScopeInfo, InternalPath, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, - &Node); - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - - if (ACPI_FAILURE (Status)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object [%s] not found [%s]\n", - Pathname, AcpiFormatException (Status))); - goto Cleanup; - } - - /* - * Now that we have a handle to the object, we can attempt to evaluate it. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", - Pathname, Node, AcpiNsGetAttachedObject (Node))); - - Info->Node = Node; - Status = AcpiNsEvaluateByHandle (Info); - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", - Pathname)); - -Cleanup: - AcpiUtDeleteGenericState (ScopeInfo); - -Cleanup1: - ACPI_MEM_FREE (InternalPath); - return_ACPI_STATUS (Status); -} - /******************************************************************************* * - * FUNCTION: AcpiNsEvaluateByName + * FUNCTION: AcpiNsEvaluate * - * PARAMETERS: Pathname - Fully qualified pathname to the object - * Info - Method info block, contains: - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. - * Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * - * RETURN: Status - * - * DESCRIPTION: Evaluate the object or rind and execute the requested method - * passing the given parameters - * - * MUTEX: Locks Namespace - * - ******************************************************************************/ - -ACPI_STATUS -AcpiNsEvaluateByName ( - const char *Pathname, - ACPI_PARAMETER_INFO *Info) -{ - ACPI_STATUS Status; - char *InternalPath = NULL; - - - ACPI_FUNCTION_TRACE ("NsEvaluateByName"); - - - /* Build an internal name string for the method */ - - Status = AcpiNsInternalizeName (Pathname, &InternalPath); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Lookup the name in the namespace */ - - Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, - &Info->Node); - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - - if (ACPI_FAILURE (Status)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Object at [%s] was not found, status=%.4X\n", - Pathname, Status)); - goto Cleanup; - } - - /* - * Now that we have a handle to the object, we can attempt to evaluate it. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", - Pathname, Info->Node, AcpiNsGetAttachedObject (Info->Node))); - - Status = AcpiNsEvaluateByHandle (Info); - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", - Pathname)); - - -Cleanup: - - /* Cleanup */ - - if (InternalPath) - { - ACPI_MEM_FREE (InternalPath); - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsEvaluateByHandle - * - * PARAMETERS: Info - Method info block, contains: - * Node - Method/Object Node to execute + * PARAMETERS: Info - Evaluation info block, contains: + * PrefixNode - Prefix or Method/Object Node to execute + * Pathname - Name of method to execute, If NULL, the + * Node is the object to execute * Parameters - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. @@ -353,34 +143,26 @@ Cleanup: * ParameterType - Type of Parameter list * ReturnObject - Where to put method's return value (if * any). If NULL, no value is returned. + * Flags - ACPI_IGNORE_RETURN_VALUE to delete return * * RETURN: Status * - * DESCRIPTION: Evaluate object or execute the requested method passing the - * given parameters + * DESCRIPTION: Execute a control method or return the current value of an + * ACPI namespace object. * - * MUTEX: Locks Namespace + * MUTEX: Locks interpreter * ******************************************************************************/ ACPI_STATUS -AcpiNsEvaluateByHandle ( - ACPI_PARAMETER_INFO *Info) +AcpiNsEvaluate ( + ACPI_EVALUATE_INFO *Info) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("NsEvaluateByHandle"); - - - /* Check if namespace has been initialized */ + ACPI_FUNCTION_TRACE (NsEvaluate); - if (!AcpiGbl_RootNode) - { - return_ACPI_STATUS (AE_NO_NAMESPACE); - } - - /* Parameter Validation */ if (!Info) { @@ -391,229 +173,144 @@ AcpiNsEvaluateByHandle ( Info->ReturnObject = NULL; - /* Get the prefix handle and Node */ - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + /* + * Get the actual namespace node for the target object. Handles these cases: + * + * 1) Null node, Pathname (absolute path) + * 2) Node, Pathname (path relative to Node) + * 3) Node, Null Pathname + */ + Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname, + ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Info->Node = AcpiNsMapHandleToNode (Info->Node); - if (!Info->Node) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - /* * For a method alias, we must grab the actual method node so that proper * scoping context will be established before execution. */ - if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { - Info->Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->Node->Object); + Info->ResolvedNode = + ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object); } + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname, + Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode))); + /* * Two major cases here: - * 1) The object is an actual control method -- execute it. - * 2) The object is not a method -- just return it's current value * - * In both cases, the namespace is unlocked by the AcpiNs* procedure + * 1) The object is a control method -- execute it + * 2) The object is not a method -- just return it's current value */ - if (AcpiNsGetType (Info->Node) == ACPI_TYPE_METHOD) - { - /* - * Case 1) We have an actual control method to execute - */ - Status = AcpiNsExecuteControlMethod (Info); - } - else + if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD) { /* - * Case 2) Object is NOT a method, just return its current value + * 1) Object is a control method - execute it */ - Status = AcpiNsGetObjectValue (Info); - } - - /* - * Check if there is a return value on the stack that must be dealt with - */ - if (Status == AE_CTRL_RETURN_VALUE) - { - /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ - - Status = AE_OK; - } - - /* - * Namespace was unlocked by the handling AcpiNs* function, so we - * just return - */ - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsExecuteControlMethod - * - * PARAMETERS: Info - Method info block, contains: - * Node - Method Node to execute - * ObjDesc - Method object - * Parameters - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. - * ParameterType - Type of Parameter list - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. - * - * RETURN: Status - * - * DESCRIPTION: Execute the requested method passing the given parameters - * - * MUTEX: Assumes namespace is locked - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsExecuteControlMethod ( - ACPI_PARAMETER_INFO *Info) -{ - ACPI_STATUS Status; - - ACPI_FUNCTION_TRACE ("NsExecuteControlMethod"); + /* Verify that there is a method object associated with this node */ + Info->ObjDesc = AcpiNsGetAttachedObject (Info->ResolvedNode); + if (!Info->ObjDesc) + { + ACPI_ERROR ((AE_INFO, "Control method has no attached sub-object")); + return_ACPI_STATUS (AE_NULL_OBJECT); + } - /* Verify that there is a method associated with this object */ - - Info->ObjDesc = AcpiNsGetAttachedObject (Info->Node); - if (!Info->ObjDesc) - { - ACPI_ERROR ((AE_INFO, "No attached method object")); - - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (AE_NULL_OBJECT); - } - - ACPI_DUMP_PATHNAME (Info->Node, "Execute Method:", - ACPI_LV_INFO, _COMPONENT); + ACPI_DUMP_PATHNAME (Info->ResolvedNode, "Execute Method:", + ACPI_LV_INFO, _COMPONENT); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", - Info->ObjDesc->Method.AmlStart + 1, Info->ObjDesc->Method.AmlLength - 1)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Method at AML address %p Length %X\n", + Info->ObjDesc->Method.AmlStart + 1, + Info->ObjDesc->Method.AmlLength - 1)); - /* - * Unlock the namespace before execution. This allows namespace access - * via the external Acpi* interfaces while a method is being executed. - * However, any namespace deletion must acquire both the namespace and - * interpreter locks to ensure that no thread is using the portion of the - * namespace that is being deleted. - */ - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); + /* + * Any namespace deletion must acquire both the namespace and + * interpreter locks to ensure that no thread is using the portion of + * the namespace that is being deleted. + * + * Execute the method via the interpreter. The interpreter is locked + * here before calling into the AML parser + */ + AcpiExEnterInterpreter (); + Status = AcpiPsExecuteMethod (Info); + AcpiExExitInterpreter (); } - - /* - * Execute the method via the interpreter. The interpreter is locked - * here before calling into the AML parser - */ - Status = AcpiExEnterInterpreter (); - if (ACPI_FAILURE (Status)) + else { - return_ACPI_STATUS (Status); - } - - Status = AcpiPsExecuteMethod (Info); - AcpiExExitInterpreter (); - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiNsGetObjectValue - * - * PARAMETERS: Info - Method info block, contains: - * Node - Object's NS node - * ReturnObject - Where to put object value (if - * any). If NULL, no value is returned. - * - * RETURN: Status - * - * DESCRIPTION: Return the current value of the object - * - * MUTEX: Assumes namespace is locked, leaves namespace unlocked - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsGetObjectValue ( - ACPI_PARAMETER_INFO *Info) -{ - ACPI_STATUS Status = AE_OK; - ACPI_NAMESPACE_NODE *ResolvedNode = Info->Node; - - - ACPI_FUNCTION_TRACE ("NsGetObjectValue"); + /* + * 2) Object is not a method, return its current value + */ + /* + * Objects require additional resolution steps (e.g., the Node may be + * a field that must be read, etc.) -- we can't just grab the object + * out of the node. + * + * Use ResolveNodeToValue() to get the associated value. + * + * NOTE: we can get away with passing in NULL for a walk state because + * ResolvedNode is guaranteed to not be a reference to either a method + * local or a method argument (because this interface is never called + * from a running method.) + * + * Even though we do not directly invoke the interpreter for object + * resolution, we must lock it because we could access an opregion. + * The opregion access code assumes that the interpreter is locked. + */ + AcpiExEnterInterpreter (); - /* - * Objects require additional resolution steps (e.g., the Node may be a - * field that must be read, etc.) -- we can't just grab the object out of - * the node. - */ + /* Function has a strange interface */ - /* - * Use ResolveNodeToValue() to get the associated value. This call always - * deletes ObjDesc (allocated above). - * - * NOTE: we can get away with passing in NULL for a walk state because - * ObjDesc is guaranteed to not be a reference to either a method local or - * a method argument (because this interface can only be called from the - * AcpiEvaluate external interface, never called from a running method.) - * - * Even though we do not directly invoke the interpreter for this, we must - * enter it because we could access an opregion. The opregion access code - * assumes that the interpreter is locked. - * - * We must release the namespace lock before entering the intepreter. - */ - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL); + AcpiExExitInterpreter (); - Status = AcpiExEnterInterpreter (); - if (ACPI_SUCCESS (Status)) - { - Status = AcpiExResolveNodeToValue (&ResolvedNode, NULL); /* * If AcpiExResolveNodeToValue() succeeded, the return value was placed * in ResolvedNode. */ - AcpiExExitInterpreter (); - if (ACPI_SUCCESS (Status)) { Status = AE_CTRL_RETURN_VALUE; - Info->ReturnObject = ACPI_CAST_PTR - (ACPI_OPERAND_OBJECT, ResolvedNode); + Info->ReturnObject = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->ResolvedNode); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", Info->ReturnObject, AcpiUtGetObjectTypeName (Info->ReturnObject))); } } - /* Namespace is unlocked */ + /* + * Check if there is a return value that must be dealt with + */ + if (Status == AE_CTRL_RETURN_VALUE) + { + /* If caller does not want the return value, delete it */ + + if (Info->Flags & ACPI_IGNORE_RETURN_VALUE) + { + AcpiUtRemoveReference (Info->ReturnObject); + Info->ReturnObject = NULL; + } + + /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ + Status = AE_OK; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "*** Completed evaluation of object %s ***\n", Info->Pathname)); + + /* + * Namespace was unlocked by the handling AcpiNs* function, so we + * just return + */ return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/nsinit.c b/sys/dist/acpica/nsinit.c index 5249cac220d..8b1a026925e 100644 --- a/sys/dist/acpica/nsinit.c +++ b/sys/dist/acpica/nsinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsinit - namespace initialization - * xRevision: 1.74 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,15 +115,16 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsinit.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __NSXFINIT_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acdispat.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> + +#ifdef _KERNEL +#include <machine/acpi_machdep.h> +#endif #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsinit") @@ -144,6 +145,13 @@ AcpiNsInitOneDevice ( void *Context, void **ReturnValue); +static ACPI_STATUS +AcpiNsFindIniMethods ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + /******************************************************************************* * @@ -166,7 +174,7 @@ AcpiNsInitializeObjects ( ACPI_INIT_WALK_INFO Info; - ACPI_FUNCTION_TRACE ("NsInitializeObjects"); + ACPI_FUNCTION_TRACE (NsInitializeObjects); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, @@ -228,7 +236,7 @@ AcpiNsInitializeDevices ( ACPI_DEVICE_WALK_INFO Info; - ACPI_FUNCTION_TRACE ("NsInitializeDevices"); + ACPI_FUNCTION_TRACE (NsInitializeDevices); /* Init counters */ @@ -238,31 +246,47 @@ AcpiNsInitializeDevices ( Info.Num_INI = 0; ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "Executing all Device _STA and_INI methods:")); + "Initializing Device/Processor/Thermal objects by executing _INI methods:")); + + /* Tree analysis: find all subtrees that contain _INI methods */ - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, &Info, NULL); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto ErrorExit; } - /* Walk namespace for all objects */ + /* Allocate the evaluation information block */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, TRUE, AcpiNsInitOneDevice, &Info, NULL); + Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info.EvaluateInfo) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + /* Walk namespace to execute all _INIs on present devices */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, &Info, NULL); + + ACPI_FREE (Info.EvaluateInfo); if (ACPI_FAILURE (Status)) { - ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); + goto ErrorExit; } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, - "\n%hd Devices found - executed %hd _STA, %hd _INI methods\n", - Info.DeviceCount, Info.Num_STA, Info.Num_INI)); + "\nExecuted %hd _INI methods requiring %hd _STA executions (examined %hd objects)\n", + Info.Num_INI, Info.Num_STA, Info.DeviceCount)); return_ACPI_STATUS (Status); + + +ErrorExit: + ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization")); + return_ACPI_STATUS (Status); } @@ -294,13 +318,13 @@ AcpiNsInitOneObject ( void **ReturnValue) { ACPI_OBJECT_TYPE Type; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_NAME ("NsInitOneObject"); + ACPI_FUNCTION_NAME (NsInitOneObject); Info->ObjectCount++; @@ -351,11 +375,7 @@ AcpiNsInitOneObject ( /* * Must lock the interpreter before executing AML code */ - Status = AcpiExEnterInterpreter (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + AcpiExEnterInterpreter (); /* * Each of these types can contain executable AML code within the @@ -419,6 +439,80 @@ AcpiNsInitOneObject ( /******************************************************************************* * + * FUNCTION: AcpiNsFindIniMethods + * + * PARAMETERS: ACPI_WALK_CALLBACK + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Called during namespace walk. Finds objects named _INI under + * device/processor/thermal objects, and marks the entire subtree + * with a SUBTREE_HAS_INI flag. This flag is used during the + * subsequent device initialization walk to avoid entire subtrees + * that do not contain an _INI. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsFindIniMethods ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode; + + + /* Keep count of device/processor/thermal objects */ + + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + if ((Node->Type == ACPI_TYPE_DEVICE) || + (Node->Type == ACPI_TYPE_PROCESSOR) || + (Node->Type == ACPI_TYPE_THERMAL)) + { + Info->DeviceCount++; + return (AE_OK); + } + + /* We are only looking for methods named _INI */ + + if (ACPI_STRNCMP (Node->Name.Ascii, METHOD_NAME__INI, 4)) + { + return (AE_OK); + } + + /* + * The only _INI methods that we care about are those that are + * present under Device, Processor, and Thermal objects. + */ + ParentNode = AcpiNsGetParentNode (Node); + switch (ParentNode->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* Mark parent and bubble up the INI present flag to the root */ + + while (ParentNode) + { + ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI; + ParentNode = AcpiNsGetParentNode (ParentNode); + } + break; + + default: + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: AcpiNsInitOneDevice * * PARAMETERS: ACPI_WALK_CALLBACK @@ -438,26 +532,20 @@ AcpiNsInitOneDevice ( void *Context, void **ReturnValue) { - ACPI_DEVICE_WALK_INFO *Info = (ACPI_DEVICE_WALK_INFO *) Context; - ACPI_PARAMETER_INFO Pinfo; + ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); + ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo; UINT32 Flags; ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *IniNode; ACPI_NAMESPACE_NODE *DeviceNode; - ACPI_FUNCTION_TRACE ("NsInitOneDevice"); + ACPI_FUNCTION_TRACE (NsInitOneDevice); - DeviceNode = AcpiNsMapHandleToNode (ObjHandle); - if (!DeviceNode) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } + /* We are interested in Devices, Processors and ThermalZones only */ + + DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); - /* - * We will run _STA/_INI on Devices, Processors and ThermalZones only - */ if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && (DeviceNode->Type != ACPI_TYPE_THERMAL)) @@ -465,41 +553,33 @@ AcpiNsInitOneDevice ( return_ACPI_STATUS (AE_OK); } - if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && - (!(AcpiDbgLevel & ACPI_LV_INFO))) - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); - } - - Info->DeviceCount++; - /* - * Check if the _INI method exists for this device - - * if _INI does not exist, there is no need to run _STA - * No _INI means device requires no initialization + * Because of an earlier namespace analysis, all subtrees that contain an + * _INI method are tagged. + * + * If this device subtree does not contain any _INI methods, we + * can exit now and stop traversing this entire subtree. */ - Status = AcpiNsSearchNode (*ACPI_CAST_CONST_PTR (UINT32, METHOD_NAME__INI), - DeviceNode, ACPI_TYPE_METHOD, &IniNode); - if (ACPI_FAILURE (Status)) + if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI)) { - /* No _INI method found - move on to next device */ - - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (AE_CTRL_DEPTH); } /* - * Run _STA to determine if we can run _INI on the device - - * the device must be present before _INI can be run. - * However, _STA is not required - assume device present if no _STA + * Run _STA to determine if this device is present and functioning. We + * must know this information for two important reasons (from ACPI spec): + * + * 1) We can only run _INI if the device is present. + * 2) We must abort the device tree walk on this subtree if the device is + * not present and is not functional (we will not examine the children) + * + * The _STA method is not required to be present under the device, we + * assume the device is present if _STA does not exist. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, - DeviceNode, METHOD_NAME__STA)); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA)); - Pinfo.Node = DeviceNode; - Pinfo.Parameters = NULL; - Pinfo.ParameterType = ACPI_PARAM_ARGS; - - Status = AcpiUtExecute_STA (Pinfo.Node, &Flags); + Status = AcpiUtExecute_STA (DeviceNode, &Flags); if (ACPI_FAILURE (Status)) { /* Ignore error and move on to next device */ @@ -507,60 +587,120 @@ AcpiNsInitOneDevice ( return_ACPI_STATUS (AE_OK); } + /* + * Flags == -1 means that _STA was not found. In this case, we assume that + * the device is both present and functional. + * + * From the ACPI spec, description of _STA: + * + * "If a device object (including the processor object) does not have an + * _STA object, then OSPM assumes that all of the above bits are set (in + * other words, the device is present, ..., and functioning)" + */ if (Flags != ACPI_UINT32_MAX) { - Info->Num_STA++; + WalkInfo->Num_STA++; } + /* + * Examine the PRESENT and FUNCTIONING status bits + * + * Note: ACPI spec does not seem to specify behavior for the present but + * not functioning case, so we assume functioning if present. + */ if (!(Flags & ACPI_STA_DEVICE_PRESENT)) { - /* Don't look at children of a not present device */ + /* Device is not present, we must examine the Functioning bit */ - return_ACPI_STATUS (AE_CTRL_DEPTH); + if (Flags & ACPI_STA_DEVICE_FUNCTIONING) + { + /* + * Device is not present but is "functioning". In this case, + * we will not run _INI, but we continue to examine the children + * of this device. + * + * From the ACPI spec, description of _STA: (Note - no mention + * of whether to run _INI or not on the device in question) + * + * "_STA may return bit 0 clear (not present) with bit 3 set + * (device is functional). This case is used to indicate a valid + * device for which no device driver should be loaded (for example, + * a bridge device.) Children of this device may be present and + * valid. OSPM should continue enumeration below a device whose + * _STA returns this bit combination" + */ + return_ACPI_STATUS (AE_OK); + } + else + { + /* + * Device is not present and is not functioning. We must abort the + * walk of this subtree immediately -- don't look at the children + * of such a device. + * + * From the ACPI spec, description of _INI: + * + * "If the _STA method indicates that the device is not present, + * OSPM will not run the _INI and will not examine the children + * of the device for _INI methods" + */ + return_ACPI_STATUS (AE_CTRL_DEPTH); + } } /* - * The device is present and _INI exists. Run the _INI method. - * (We already have the _INI node from above) + * The device is present or is assumed present if no _STA exists. + * Run the _INI if it exists (not required to exist) + * + * Note: We know there is an _INI within this subtree, but it may not be + * under this particular device, it may be lower in the branch. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, - Pinfo.Node, METHOD_NAME__INI)); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); - Pinfo.Node = IniNode; - Status = AcpiNsEvaluateByHandle (&Pinfo); - if (ACPI_FAILURE (Status)) - { - /* Ignore error and move on to next device */ + Info->PrefixNode = DeviceNode; + Info->Pathname = METHOD_NAME__INI; + Info->Parameters = NULL; + Info->ParameterType = ACPI_PARAM_ARGS; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; -#ifdef ACPI_DEBUG_OUTPUT - char *ScopeName = AcpiNsGetExternalPathname (IniNode); - - ACPI_WARNING ((AE_INFO, "%s._INI failed: %s", - ScopeName, AcpiFormatException (Status))); - - ACPI_MEM_FREE (ScopeName); -#endif - } - else + Status = AcpiNsEvaluate (Info); + if (ACPI_SUCCESS (Status)) { - /* Delete any return object (especially if ImplicitReturn is enabled) */ + WalkInfo->Num_INI++; - if (Pinfo.ReturnObject) + if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && + (!(AcpiDbgLevel & ACPI_LV_INFO))) { - AcpiUtRemoveReference (Pinfo.ReturnObject); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); } + } - /* Count of successful INIs */ +#ifdef ACPI_DEBUG_OUTPUT + else if (Status != AE_NOT_FOUND) + { + /* Ignore error and move on to next device */ + + char *ScopeName = AcpiNsGetExternalPathname (Info->ResolvedNode); - Info->Num_INI++; + ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", + ScopeName)); + ACPI_FREE (ScopeName); } +#endif + /* Ignore errors from above */ + + Status = AE_OK; + + /* + * The _INI method has been run if present; call the Global Initialization + * Handler for this device. + */ if (AcpiGbl_InitHandler) { - /* External initialization handler is present, call it */ - - Status = AcpiGbl_InitHandler (Pinfo.Node, ACPI_INIT_DEVICE_INI); + Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/nsload.c b/sys/dist/acpica/nsload.c index 98f130c3d4d..6f414af2fe2 100644 --- a/sys/dist/acpica/nsload.c +++ b/sys/dist/acpica/nsload.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsload - namespace loading/expanding/contracting procedures - * xRevision: 1.76 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,14 +114,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsload.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSLOAD_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acdispat.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_NAMESPACE @@ -129,10 +127,6 @@ __KERNEL_RCSID(0, "$NetBSD: nsload.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); /* Local prototypes */ -static ACPI_STATUS -AcpiNsLoadTableByType ( - ACPI_TABLE_TYPE TableType); - #ifdef ACPI_FUTURE_IMPLEMENTATION ACPI_STATUS AcpiNsUnloadNamespace ( @@ -149,7 +143,7 @@ AcpiNsDeleteSubtree ( * * FUNCTION: AcpiNsLoadTable * - * PARAMETERS: TableDesc - Descriptor for table to be loaded + * PARAMETERS: TableIndex - Index for table to be loaded * Node - Owning NS node * * RETURN: Status @@ -160,43 +154,14 @@ AcpiNsDeleteSubtree ( ACPI_STATUS AcpiNsLoadTable ( - ACPI_TABLE_DESC *TableDesc, + ACPI_NATIVE_UINT TableIndex, ACPI_NAMESPACE_NODE *Node) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("NsLoadTable"); - - - /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */ - - if (!(AcpiGbl_TableData[TableDesc->Type].Flags & ACPI_TABLE_EXECUTABLE)) - { - /* Just ignore this table */ - - return_ACPI_STATUS (AE_OK); - } - - /* Check validity of the AML start and length */ - - if (!TableDesc->AmlStart) - { - ACPI_ERROR ((AE_INFO, "Null AML pointer")); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", - TableDesc->AmlStart)); + ACPI_FUNCTION_TRACE (NsLoadTable); - /* Ignore table if there is no AML contained within */ - - if (!TableDesc->AmlLength) - { - ACPI_WARNING ((AE_INFO, "Zero-length AML block in table [%4.4s]", - TableDesc->Pointer->Signature)); - return_ACPI_STATUS (AE_OK); - } /* * Parse the table and load the namespace with all named @@ -207,16 +172,40 @@ AcpiNsLoadTable ( * to another control method, we can't continue parsing * because we don't know how many arguments to parse next! */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* If table already loaded into namespace, just return */ + + if (AcpiTbIsTableLoaded (TableIndex)) + { + Status = AE_ALREADY_EXISTS; + goto Unlock; + } + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n")); - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + Status = AcpiTbAllocateOwnerId (TableIndex); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Unlock; } - Status = AcpiNsParseTable (TableDesc, Node->Child); + Status = AcpiNsParseTable (TableIndex, Node->Child); + if (ACPI_SUCCESS (Status)) + { + AcpiTbSetTableLoadedFlag (TableIndex, TRUE); + } + else + { + AcpiTbReleaseOwnerId (TableIndex); + } + +Unlock: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) @@ -233,7 +222,7 @@ AcpiNsLoadTable ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Begin Table Method Parsing and Object Initialization ****\n")); - Status = AcpiDsInitializeObjects (TableDesc, Node); + Status = AcpiDsInitializeObjects (TableIndex, Node); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Completed Table Method Parsing and Object Initialization ****\n")); @@ -242,111 +231,7 @@ AcpiNsLoadTable ( } -/******************************************************************************* - * - * FUNCTION: AcpiNsLoadTableByType - * - * PARAMETERS: TableType - Id of the table type to load - * - * RETURN: Status - * - * DESCRIPTION: Load an ACPI table or tables into the namespace. All tables - * of the given type are loaded. The mechanism allows this - * routine to be called repeatedly. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiNsLoadTableByType ( - ACPI_TABLE_TYPE TableType) -{ - UINT32 i; - ACPI_STATUS Status; - ACPI_TABLE_DESC *TableDesc; - - - ACPI_FUNCTION_TRACE ("NsLoadTableByType"); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Table types supported are: - * DSDT (one), SSDT/PSDT (multiple) - */ - switch (TableType) - { - case ACPI_TABLE_DSDT: - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace load: DSDT\n")); - - TableDesc = AcpiGbl_TableLists[ACPI_TABLE_DSDT].Next; - - /* If table already loaded into namespace, just return */ - - if (TableDesc->LoadedIntoNamespace) - { - goto UnlockAndExit; - } - - /* Now load the single DSDT */ - - Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode); - if (ACPI_SUCCESS (Status)) - { - TableDesc->LoadedIntoNamespace = TRUE; - } - break; - - - case ACPI_TABLE_SSDT: - case ACPI_TABLE_PSDT: - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace load: %d SSDT or PSDTs\n", - AcpiGbl_TableLists[TableType].Count)); - - /* - * Traverse list of SSDT or PSDT tables - */ - TableDesc = AcpiGbl_TableLists[TableType].Next; - for (i = 0; i < AcpiGbl_TableLists[TableType].Count; i++) - { - /* - * Only attempt to load table into namespace if it is not - * already loaded! - */ - if (!TableDesc->LoadedIntoNamespace) - { - Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode); - if (ACPI_FAILURE (Status)) - { - break; - } - - TableDesc->LoadedIntoNamespace = TRUE; - } - - TableDesc = TableDesc->Next; - } - break; - - - default: - Status = AE_SUPPORT; - break; - } - - -UnlockAndExit: - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); -} - - +#ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * * FUNCTION: AcpiLoadNamespace @@ -367,7 +252,7 @@ AcpiNsLoadNamespace ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiLoadNameSpace"); + ACPI_FUNCTION_TRACE (AcpiLoadNameSpace); /* There must be at least a DSDT installed */ @@ -382,7 +267,7 @@ AcpiNsLoadNamespace ( * Load the namespace. The DSDT is required, * but the SSDT and PSDT tables are optional. */ - Status = AcpiNsLoadTableByType (ACPI_TABLE_DSDT); + Status = AcpiNsLoadTableByType (ACPI_TABLE_ID_DSDT); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -390,8 +275,8 @@ AcpiNsLoadNamespace ( /* Ignore exceptions from these */ - (void) AcpiNsLoadTableByType (ACPI_TABLE_SSDT); - (void) AcpiNsLoadTableByType (ACPI_TABLE_PSDT); + (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_SSDT); + (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_PSDT); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "ACPI Namespace successfully loaded at root %p\n", @@ -399,7 +284,7 @@ AcpiNsLoadNamespace ( return_ACPI_STATUS (Status); } - +#endif #ifdef ACPI_FUTURE_IMPLEMENTATION /******************************************************************************* @@ -430,7 +315,7 @@ AcpiNsDeleteSubtree ( UINT32 Level; - ACPI_FUNCTION_TRACE ("NsDeleteSubtree"); + ACPI_FUNCTION_TRACE (NsDeleteSubtree); ParentHandle = StartHandle; @@ -518,7 +403,7 @@ AcpiNsUnloadNamespace ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("NsUnloadNameSpace"); + ACPI_FUNCTION_TRACE (NsUnloadNameSpace); /* Parameter validation */ diff --git a/sys/dist/acpica/nsnames.c b/sys/dist/acpica/nsnames.c index 19f94dc296a..0d61cdf63ea 100644 --- a/sys/dist/acpica/nsnames.c +++ b/sys/dist/acpica/nsnames.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsnames - Name manipulation and search - * xRevision: 1.94 $ + * $Revision: 1.3 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,27 +114,16 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsnames.c,v 1.2 2006/05/14 21:38:18 elad Exp $"); - #define __NSNAMES_C__ -#include "acpi.h" -#include "amlcode.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsnames") -/* Local prototypes */ - -static void -AcpiNsBuildExternalPath ( - ACPI_NAMESPACE_NODE *Node, - ACPI_SIZE Size, - char *NameBuffer); - /******************************************************************************* * @@ -151,7 +140,7 @@ AcpiNsBuildExternalPath ( * ******************************************************************************/ -static void +void AcpiNsBuildExternalPath ( ACPI_NAMESPACE_NODE *Node, ACPI_SIZE Size, @@ -232,7 +221,7 @@ AcpiNsGetExternalPathname ( ACPI_SIZE Size; - ACPI_FUNCTION_TRACE_PTR ("NsGetExternalPathname", Node); + ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node); /* Calculate required buffer size based on depth below root */ @@ -241,7 +230,7 @@ AcpiNsGetExternalPathname ( /* Allocate a buffer to be returned to caller */ - NameBuffer = ACPI_MEM_CALLOCATE (Size); + NameBuffer = ACPI_ALLOCATE_ZEROED (Size); if (!NameBuffer) { ACPI_ERROR ((AE_INFO, "Allocation failure")); @@ -325,7 +314,7 @@ AcpiNsHandleToPathname ( ACPI_SIZE RequiredSize; - ACPI_FUNCTION_TRACE_PTR ("NsHandleToPathname", TargetHandle); + ACPI_FUNCTION_TRACE_PTR (NsHandleToPathname, TargetHandle); Node = AcpiNsMapHandleToNode (TargetHandle); diff --git a/sys/dist/acpica/nsobject.c b/sys/dist/acpica/nsobject.c index a2f961dfebd..768a49315b8 100644 --- a/sys/dist/acpica/nsobject.c +++ b/sys/dist/acpica/nsobject.c @@ -2,7 +2,7 @@ * * Module Name: nsobject - Utilities for objects attached to namespace * table entries - * xRevision: 1.96 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,13 +116,10 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsobject.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSOBJECT_C__ -#include "acpi.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_NAMESPACE @@ -161,7 +158,7 @@ AcpiNsAttachObject ( ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY; - ACPI_FUNCTION_TRACE ("NsAttachObject"); + ACPI_FUNCTION_TRACE (NsAttachObject); /* @@ -301,7 +298,7 @@ AcpiNsDetachObject ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_TRACE ("NsDetachObject"); + ACPI_FUNCTION_TRACE (NsDetachObject); ObjDesc = Node->Object; @@ -356,7 +353,7 @@ ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject ( ACPI_NAMESPACE_NODE *Node) { - ACPI_FUNCTION_TRACE_PTR ("NsGetAttachedObject", Node); + ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node); if (!Node) @@ -394,7 +391,7 @@ ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject ( ACPI_OPERAND_OBJECT *ObjDesc) { - ACPI_FUNCTION_TRACE_PTR ("NsGetSecondaryObject", ObjDesc); + ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc); if ((!ObjDesc) || diff --git a/sys/dist/acpica/nsparse.c b/sys/dist/acpica/nsparse.c index b480ab82b1f..a53dc25b37e 100644 --- a/sys/dist/acpica/nsparse.c +++ b/sys/dist/acpica/nsparse.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsparse - namespace interface to AML parser - * xRevision: 1.11 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,15 +114,13 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsparse.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __NSPARSE_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acparser.h" -#include "acdispat.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_NAMESPACE @@ -144,16 +142,26 @@ __KERNEL_RCSID(0, "$NetBSD: nsparse.c,v 1.3 2006/11/16 01:33:31 christos Exp $") ACPI_STATUS AcpiNsOneCompleteParse ( - UINT8 PassNumber, - ACPI_TABLE_DESC *TableDesc) + ACPI_NATIVE_UINT PassNumber, + ACPI_NATIVE_UINT TableIndex) { ACPI_PARSE_OBJECT *ParseRoot; ACPI_STATUS Status; + ACPI_NATIVE_UINT AmlLength; + UINT8 *AmlStart; ACPI_WALK_STATE *WalkState; + ACPI_TABLE_HEADER *Table; + ACPI_OWNER_ID OwnerId; + + ACPI_FUNCTION_TRACE (NsOneCompleteParse); - ACPI_FUNCTION_TRACE ("NsOneCompleteParse"); + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } /* Create and init a Root Node */ @@ -165,26 +173,46 @@ AcpiNsOneCompleteParse ( /* Create and initialize a new walk state */ - WalkState = AcpiDsCreateWalkState (TableDesc->OwnerId, - NULL, NULL, NULL); + WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL); if (!WalkState) { AcpiPsFreeOp (ParseRoot); return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, - TableDesc->AmlStart, TableDesc->AmlLength, - NULL, PassNumber); + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + AcpiPsFreeOp (ParseRoot); + return_ACPI_STATUS (Status); + } + + /* Table must consist of at least a complete header */ + + if (Table->Length < sizeof (ACPI_TABLE_HEADER)) + { + Status = AE_BAD_HEADER; + } + else + { + AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); + AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); + Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, + AmlStart, AmlLength, NULL, (UINT8) PassNumber); + } + if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); + AcpiPsDeleteParseTree (ParseRoot); return_ACPI_STATUS (Status); } /* Parse the AML */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", PassNumber)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %lu parse\n", + (unsigned long) PassNumber)); Status = AcpiPsParseAml (WalkState); AcpiPsDeleteParseTree (ParseRoot); @@ -207,13 +235,13 @@ AcpiNsOneCompleteParse ( ACPI_STATUS AcpiNsParseTable ( - ACPI_TABLE_DESC *TableDesc, + ACPI_NATIVE_UINT TableIndex, ACPI_NAMESPACE_NODE *StartNode) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("NsParseTable"); + ACPI_FUNCTION_TRACE (NsParseTable); /* @@ -224,10 +252,10 @@ AcpiNsParseTable ( * each Parser Op subtree is deleted when it is finished. This saves * a great deal of memory, and allows a small cache of parse objects * to service the entire parse. The second pass of the parse then - * performs another complete parse of the AML.. + * performs another complete parse of the AML. */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); - Status = AcpiNsOneCompleteParse (1, TableDesc); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, TableIndex); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -243,7 +271,7 @@ AcpiNsParseTable ( * parse objects are all cached. */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); - Status = AcpiNsOneCompleteParse (2, TableDesc); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, TableIndex); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/dist/acpica/nssearch.c b/sys/dist/acpica/nssearch.c index dcb12f1b0a5..6aa43e2e287 100644 --- a/sys/dist/acpica/nssearch.c +++ b/sys/dist/acpica/nssearch.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nssearch - Namespace search - * xRevision: 1.110 $ + * $Revision: 1.4 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nssearch.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __NSSEARCH_C__ -#include "acpi.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_NAMESPACE @@ -138,16 +135,16 @@ AcpiNsSearchParentTree ( /******************************************************************************* * - * FUNCTION: AcpiNsSearchNode + * FUNCTION: AcpiNsSearchOneScope * * PARAMETERS: TargetName - Ascii ACPI name to search for - * Node - Starting node where search will begin + * ParentNode - Starting node where search will begin * Type - Object type to match * ReturnNode - Where the matched Named obj is returned * * RETURN: Status * - * DESCRIPTION: Search a single level of the namespace. Performs a + * DESCRIPTION: Search a single level of the namespace. Performs a * simple search of the specified level, and does not add * entries or search parents. * @@ -157,23 +154,28 @@ AcpiNsSearchParentTree ( * * All namespace searching is linear in this implementation, but * could be easily modified to support any improved search - * algorithm. However, the linear search was chosen for simplicity + * algorithm. However, the linear search was chosen for simplicity * and because the trees are small and the other interpreter * execution overhead is relatively high. * + * Note: CPU execution analysis has shown that the AML interpreter spends + * a very small percentage of its time searching the namespace. Therefore, + * the linear search seems to be sufficient, as there would seem to be + * little value in improving the search. + * ******************************************************************************/ ACPI_STATUS -AcpiNsSearchNode ( +AcpiNsSearchOneScope ( UINT32 TargetName, - ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ParentNode, ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE **ReturnNode) { - ACPI_NAMESPACE_NODE *NextNode; + ACPI_NAMESPACE_NODE *Node; - ACPI_FUNCTION_TRACE ("NsSearchNode"); + ACPI_FUNCTION_TRACE (NsSearchOneScope); #ifdef ACPI_DEBUG_OUTPUT @@ -181,15 +183,15 @@ AcpiNsSearchNode ( { char *ScopeName; - ScopeName = AcpiNsGetExternalPathname (Node); + ScopeName = AcpiNsGetExternalPathname (ParentNode); if (ScopeName) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s (%p) For [%4.4s] (%s)\n", - ScopeName, Node, ACPI_CAST_PTR (char, &TargetName), + ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type))); - ACPI_MEM_FREE (ScopeName); + ACPI_FREE (ScopeName); } } #endif @@ -198,30 +200,29 @@ AcpiNsSearchNode ( * Search for name at this namespace level, which is to say that we * must search for the name among the children of this object */ - NextNode = Node->Child; - while (NextNode) + Node = ParentNode->Child; + while (Node) { /* Check for match against the name */ - if (NextNode->Name.Integer == TargetName) + if (Node->Name.Integer == TargetName) { /* Resolve a control method alias if any */ - if (AcpiNsGetType (NextNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { - NextNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, NextNode->Object); + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); } - /* - * Found matching entry. - */ + /* Found matching entry */ + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", ACPI_CAST_PTR (char, &TargetName), - AcpiUtGetTypeName (NextNode->Type), - NextNode, AcpiUtGetNodeName (Node), Node)); + AcpiUtGetTypeName (Node->Type), + Node, AcpiUtGetNodeName (ParentNode), ParentNode)); - *ReturnNode = NextNode; + *ReturnNode = Node; return_ACPI_STATUS (AE_OK); } @@ -229,7 +230,7 @@ AcpiNsSearchNode ( * The last entry in the list points back to the parent, * so a flag is used to indicate the end-of-list */ - if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) + if (Node->Flags & ANOBJ_END_OF_PEER_LIST) { /* Searched entire list, we are done */ @@ -238,7 +239,7 @@ AcpiNsSearchNode ( /* Didn't match name, move on to the next peer object */ - NextNode = NextNode->Peer; + Node = Node->Peer; } /* Searched entire namespace level, not found */ @@ -246,7 +247,7 @@ AcpiNsSearchNode ( ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type), - AcpiUtGetNodeName (Node), Node, Node->Child)); + AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child)); return_ACPI_STATUS (AE_NOT_FOUND); } @@ -264,14 +265,14 @@ AcpiNsSearchNode ( * RETURN: Status * * DESCRIPTION: Called when a name has not been found in the current namespace - * level. Before adding it or giving up, ACPI scope rules require + * level. Before adding it or giving up, ACPI scope rules require * searching enclosing scopes in cases identified by AcpiNsLocal(). * * "A name is located by finding the matching name in the current * name space, and then in the parent name space. If the parent * name space does not contain the name, the search continues * recursively until either the name is found or the name space - * does not have a parent (the root of the name space). This + * does not have a parent (the root of the name space). This * indicates that the name is not found" (From ACPI Specification, * section 5.3) * @@ -288,7 +289,7 @@ AcpiNsSearchParentTree ( ACPI_NAMESPACE_NODE *ParentNode; - ACPI_FUNCTION_TRACE ("NsSearchParentTree"); + ACPI_FUNCTION_TRACE (NsSearchParentTree); ParentNode = AcpiNsGetParentNode (Node); @@ -324,21 +325,19 @@ AcpiNsSearchParentTree ( while (ParentNode) { /* - * Search parent scope. Use TYPE_ANY because we don't care about the + * Search parent scope. Use TYPE_ANY because we don't care about the * object type at this point, we only care about the existence of - * the actual name we are searching for. Typechecking comes later. + * the actual name we are searching for. Typechecking comes later. */ - Status = AcpiNsSearchNode (TargetName, ParentNode, - ACPI_TYPE_ANY, ReturnNode); + Status = AcpiNsSearchOneScope ( + TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); } - /* - * Not found here, go up another level - * (until we reach the root) - */ + /* Not found here, go up another level (until we reach the root) */ + ParentNode = AcpiNsGetParentNode (ParentNode); } @@ -364,7 +363,7 @@ AcpiNsSearchParentTree ( * RETURN: Status * * DESCRIPTION: Search for a name segment in a single namespace level, - * optionally adding it if it is not found. If the passed + * optionally adding it if it is not found. If the passed * Type is not Any and the type previously stored in the * entry was Any (i.e. unknown), update the stored type. * @@ -387,7 +386,7 @@ AcpiNsSearchAndEnter ( ACPI_NAMESPACE_NODE *NewNode; - ACPI_FUNCTION_TRACE ("NsSearchAndEnter"); + ACPI_FUNCTION_TRACE (NsSearchAndEnter); /* Parameter validation */ @@ -395,24 +394,44 @@ AcpiNsSearchAndEnter ( if (!Node || !TargetName || !ReturnNode) { ACPI_ERROR ((AE_INFO, - "Null param: Node %p Name %X ReturnNode %p", + "Null parameter: Node %p Name %X ReturnNode %p", Node, TargetName, ReturnNode)); return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Name must consist of printable characters */ - + /* + * Name must consist of valid ACPI characters. We will repair the name if + * necessary because we don't want to abort because of this, but we want + * all namespace names to be printable. A warning message is appropriate. + * + * This issue came up because there are in fact machines that exhibit + * this problem, and we want to be able to enable ACPI support for them, + * even though there are a few bad names. + */ if (!AcpiUtValidAcpiName (TargetName)) { - ACPI_ERROR ((AE_INFO, "Bad character in ACPI Name: %X", - TargetName)); - return_ACPI_STATUS (AE_BAD_CHARACTER); + TargetName = AcpiUtRepairName (ACPI_CAST_PTR (char, &TargetName)); + + /* Report warning only if in strict mode or debug mode */ + + if (!AcpiGbl_EnableInterpreterSlack) + { + ACPI_WARNING ((AE_INFO, + "Found bad character(s) in name, repaired: [%4.4s]\n", + ACPI_CAST_PTR (char, &TargetName))); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_WARN, + "Found bad character(s) in name, repaired: [%4.4s]\n", + ACPI_CAST_PTR (char, &TargetName))); + } } /* Try to find the name in the namespace level specified by the caller */ *ReturnNode = ACPI_ENTRY_NOT_FOUND; - Status = AcpiNsSearchNode (TargetName, Node, Type, ReturnNode); + Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode); if (Status != AE_NOT_FOUND) { /* @@ -425,18 +444,16 @@ AcpiNsSearchAndEnter ( Status = AE_ALREADY_EXISTS; } - /* - * Either found it or there was an error - * -- finished either way - */ + /* Either found it or there was an error: finished either way */ + return_ACPI_STATUS (Status); } /* - * The name was not found. If we are NOT performing the first pass + * The name was not found. If we are NOT performing the first pass * (name entry) of loading the namespace, search the parent tree (all the * way to the root if necessary.) We don't want to perform the parent - * search when the namespace is actually being loaded. We want to perform + * search when the namespace is actually being loaded. We want to perform * the search when namespace references are being resolved (load pass 2) * and during the execution phase. */ @@ -454,9 +471,8 @@ AcpiNsSearchAndEnter ( } } - /* - * In execute mode, just search, never add names. Exit now. - */ + /* In execute mode, just search, never add names. Exit now */ + if (InterpreterMode == ACPI_IMODE_EXECUTE) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, @@ -474,11 +490,25 @@ AcpiNsSearchAndEnter ( return_ACPI_STATUS (AE_NO_MEMORY); } +#ifdef ACPI_ASL_COMPILER + /* + * Node is an object defined by an External() statement + */ + if (Flags & ACPI_NS_EXTERNAL) + { + NewNode->Flags |= ANOBJ_IS_EXTERNAL; + } +#endif + + if (Flags & ACPI_NS_TEMPORARY) + { + NewNode->Flags |= ANOBJ_TEMPORARY; + } + /* Install the new object into the parent's list of children */ AcpiNsInstallNode (WalkState, Node, NewNode, Type); *ReturnNode = NewNode; - return_ACPI_STATUS (AE_OK); } diff --git a/sys/dist/acpica/nsutils.c b/sys/dist/acpica/nsutils.c index 2b3b174a008..9c1ec4ec3cb 100644 --- a/sys/dist/acpica/nsutils.c +++ b/sys/dist/acpica/nsutils.c @@ -2,7 +2,7 @@ * * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing * parents and siblings and Scope manipulation - * xRevision: 1.148 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,15 +115,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsutils.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSUTILS_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "amlcode.h" -#include "actables.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsutils") @@ -160,7 +157,7 @@ void AcpiNsReportError ( const char *ModuleName, UINT32 LineNumber, - const char *InternalName, + char *InternalName, ACPI_STATUS LookupStatus) { ACPI_STATUS Status; @@ -168,7 +165,7 @@ AcpiNsReportError ( char *Name = NULL; - AcpiUtReportError (ModuleName, LineNumber); + AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); if (LookupStatus == AE_BAD_CHARACTER) { @@ -197,7 +194,7 @@ AcpiNsReportError ( if (Name) { - ACPI_MEM_FREE (Name); + ACPI_FREE (Name); } } @@ -236,12 +233,12 @@ AcpiNsReportMethodError ( ACPI_NAMESPACE_NODE *Node = PrefixNode; - AcpiUtReportError (ModuleName, LineNumber); + AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); if (Path) { - Status = AcpiNsGetNodeByPath (Path, PrefixNode, - ACPI_NS_NO_UPSEARCH, &Node); + Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH, + &Node); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("[Could not get node by pathname]"); @@ -293,7 +290,7 @@ AcpiNsPrintNodePathname ( } AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node); - ACPI_MEM_FREE (Buffer.Pointer); + ACPI_FREE (Buffer.Pointer); } } @@ -356,7 +353,7 @@ ACPI_OBJECT_TYPE AcpiNsGetType ( ACPI_NAMESPACE_NODE *Node) { - ACPI_FUNCTION_TRACE ("NsGetType"); + ACPI_FUNCTION_TRACE (NsGetType); if (!Node) @@ -386,7 +383,7 @@ UINT32 AcpiNsLocal ( ACPI_OBJECT_TYPE Type) { - ACPI_FUNCTION_TRACE ("NsLocal"); + ACPI_FUNCTION_TRACE (NsLocal); if (!AcpiUtValidObjectType (Type)) @@ -503,7 +500,7 @@ AcpiNsBuildInternalName ( ACPI_NATIVE_UINT i; - ACPI_FUNCTION_TRACE ("NsBuildInternalName"); + ACPI_FUNCTION_TRACE (NsBuildInternalName); /* Setup the correct prefixes, counts, and pointers */ @@ -640,7 +637,7 @@ AcpiNsInternalizeName ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("NsInternalizeName"); + ACPI_FUNCTION_TRACE (NsInternalizeName); if ((!ExternalName) || @@ -657,7 +654,7 @@ AcpiNsInternalizeName ( /* We need a segment to store the internal name */ - InternalName = ACPI_MEM_CALLOCATE (Info.Length); + InternalName = ACPI_ALLOCATE_ZEROED (Info.Length); if (!InternalName) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -669,7 +666,7 @@ AcpiNsInternalizeName ( Status = AcpiNsBuildInternalName (&Info); if (ACPI_FAILURE (Status)) { - ACPI_MEM_FREE (InternalName); + ACPI_FREE (InternalName); return_ACPI_STATUS (Status); } @@ -698,7 +695,7 @@ AcpiNsInternalizeName ( ACPI_STATUS AcpiNsExternalizeName ( UINT32 InternalNameLength, - const char *InternalName, + char *InternalName, UINT32 *ConvertedNameLength, char **ConvertedName) { @@ -710,7 +707,7 @@ AcpiNsExternalizeName ( ACPI_NATIVE_UINT j = 0; - ACPI_FUNCTION_TRACE ("NsExternalizeName"); + ACPI_FUNCTION_TRACE (NsExternalizeName); if (!InternalNameLength || @@ -817,7 +814,7 @@ AcpiNsExternalizeName ( /* * Build ConvertedName */ - *ConvertedName = ACPI_MEM_CALLOCATE (RequiredLength); + *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength); if (!(*ConvertedName)) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -880,14 +877,9 @@ AcpiNsMapHandleToNode ( /* - * Simple implementation. + * Simple implementation */ - if (!Handle) - { - return (NULL); - } - - if (Handle == ACPI_ROOT_OBJECT) + if ((!Handle) || (Handle == ACPI_ROOT_OBJECT)) { return (AcpiGbl_RootNode); } @@ -899,7 +891,7 @@ AcpiNsMapHandleToNode ( return (NULL); } - return ((ACPI_NAMESPACE_NODE *) Handle); + return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle)); } @@ -964,7 +956,7 @@ AcpiNsTerminate ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_TRACE ("NsTerminate"); + ACPI_FUNCTION_TRACE (NsTerminate); /* @@ -983,13 +975,6 @@ AcpiNsTerminate ( } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); - - /* - * 2) Now we can delete the ACPI tables - */ - AcpiTbDeleteAllTables (); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); - return_VOID; } @@ -1009,7 +994,7 @@ UINT32 AcpiNsOpensScope ( ACPI_OBJECT_TYPE Type) { - ACPI_FUNCTION_TRACE_STR ("NsOpensScope", AcpiUtGetTypeName (Type)); + ACPI_FUNCTION_TRACE_STR (NsOpensScope, AcpiUtGetTypeName (Type)); if (!AcpiUtValidObjectType (Type)) @@ -1026,12 +1011,12 @@ AcpiNsOpensScope ( /******************************************************************************* * - * FUNCTION: AcpiNsGetNodeByPath + * FUNCTION: AcpiNsGetNode * * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The * \ (backslash) and ^ (carat) prefixes, and the * . (period) to separate segments are supported. - * StartNode - Root of subtree to be searched, or NS_ALL for the + * PrefixNode - Root of subtree to be searched, or NS_ALL for the * root of the name space. If Name is fully * qualified (first INT8 is '\'), the passed value * of Scope will not be accessed. @@ -1047,29 +1032,36 @@ AcpiNsOpensScope ( ******************************************************************************/ ACPI_STATUS -AcpiNsGetNodeByPath ( +AcpiNsGetNode ( + ACPI_NAMESPACE_NODE *PrefixNode, const char *Pathname, - ACPI_NAMESPACE_NODE *StartNode, UINT32 Flags, ACPI_NAMESPACE_NODE **ReturnNode) { ACPI_GENERIC_STATE ScopeInfo; ACPI_STATUS Status; - char *InternalPath = NULL; + char *InternalPath; - ACPI_FUNCTION_TRACE_PTR ("NsGetNodeByPath", Pathname); + ACPI_FUNCTION_TRACE_PTR (NsGetNode, Pathname); - if (Pathname) + if (!Pathname) { - /* Convert path to internal representation */ - - Status = AcpiNsInternalizeName (Pathname, &InternalPath); - if (ACPI_FAILURE (Status)) + *ReturnNode = PrefixNode; + if (!PrefixNode) { - return_ACPI_STATUS (Status); + *ReturnNode = AcpiGbl_RootNode; } + return_ACPI_STATUS (AE_OK); + } + + /* Convert path to internal representation */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); } /* Must lock namespace during lookup */ @@ -1082,27 +1074,23 @@ AcpiNsGetNodeByPath ( /* Setup lookup scope (search starting point) */ - ScopeInfo.Scope.Node = StartNode; + ScopeInfo.Scope.Node = PrefixNode; /* Lookup the name in the namespace */ - Status = AcpiNsLookup (&ScopeInfo, InternalPath, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - (Flags | ACPI_NS_DONT_OPEN_SCOPE), - NULL, ReturnNode); + Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), + NULL, ReturnNode); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n", - InternalPath, AcpiFormatException (Status))); + Pathname, AcpiFormatException (Status))); } (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Cleanup: - if (InternalPath) - { - ACPI_MEM_FREE (InternalPath); - } + ACPI_FREE (InternalPath); return_ACPI_STATUS (Status); } @@ -1199,7 +1187,7 @@ AcpiNsFindParentName ( ACPI_NAMESPACE_NODE *ParentNode; - ACPI_FUNCTION_TRACE ("NsFindParentName"); + ACPI_FUNCTION_TRACE (NsFindParentName); if (ChildNode) diff --git a/sys/dist/acpica/nswalk.c b/sys/dist/acpica/nswalk.c index 83aa3f0a2ea..19b4bf81e52 100644 --- a/sys/dist/acpica/nswalk.c +++ b/sys/dist/acpica/nswalk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nswalk - Functions for walking the ACPI namespace - * xRevision: 1.40 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,10 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nswalk.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSWALK_C__ -#include "acpi.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_NAMESPACE @@ -163,10 +160,7 @@ AcpiNsGetNextNode ( { /* It's really the parent's _scope_ that we want */ - if (ParentNode->Child) - { - NextNode = ParentNode->Child; - } + NextNode = ParentNode->Child; } else @@ -214,7 +208,7 @@ AcpiNsGetNextNode ( * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for * StartNode - Handle in namespace where search begins * MaxDepth - Depth to which search is to reach - * UnlockBeforeCallback- Whether to unlock the NS before invoking + * Flags - Whether to unlock the NS before invoking * the callback routine * UserFunction - Called when an object of "Type" is found * Context - Passed to user function @@ -242,7 +236,7 @@ AcpiNsWalkNamespace ( ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartNode, UINT32 MaxDepth, - BOOLEAN UnlockBeforeCallback, + UINT32 Flags, ACPI_WALK_CALLBACK UserFunction, void *Context, void **ReturnValue) @@ -255,7 +249,7 @@ AcpiNsWalkNamespace ( UINT32 Level; - ACPI_FUNCTION_TRACE ("NsWalkNamespace"); + ACPI_FUNCTION_TRACE (NsWalkNamespace); /* Special case for the namespace Root Node */ @@ -285,22 +279,36 @@ AcpiNsWalkNamespace ( ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode); if (ChildNode) { - /* - * Found node, Get the type if we are not - * searching for ANY - */ + /* Found next child, get the type if we are not searching for ANY */ + if (Type != ACPI_TYPE_ANY) { ChildType = ChildNode->Type; } - if (ChildType == Type) + /* + * Ignore all temporary namespace nodes (created during control + * method execution) unless told otherwise. These temporary nodes + * can cause a race condition because they can be deleted during the + * execution of the user function (if the namespace is unlocked before + * invocation of the user function.) Only the debugger namespace dump + * will examine the temporary nodes. + */ + if ((ChildNode->Flags & ANOBJ_TEMPORARY) && + !(Flags & ACPI_NS_WALK_TEMP_NODES)) + { + Status = AE_CTRL_DEPTH; + } + + /* Type must match requested type */ + + else if (ChildType == Type) { /* - * Found a matching node, invoke the user - * callback function + * Found a matching node, invoke the user callback function. + * Unlock the namespace if flag is set. */ - if (UnlockBeforeCallback) + if (Flags & ACPI_NS_WALK_UNLOCK) { MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (MutexStatus)) @@ -309,10 +317,9 @@ AcpiNsWalkNamespace ( } } - Status = UserFunction (ChildNode, Level, - Context, ReturnValue); + Status = UserFunction (ChildNode, Level, Context, ReturnValue); - if (UnlockBeforeCallback) + if (Flags & ACPI_NS_WALK_UNLOCK) { MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (MutexStatus)) @@ -344,33 +351,28 @@ AcpiNsWalkNamespace ( } /* - * Depth first search: - * Attempt to go down another level in the namespace - * if we are allowed to. Don't go any further if we - * have reached the caller specified maximum depth - * or if the user function has specified that the - * maximum depth has been reached. + * Depth first search: Attempt to go down another level in the + * namespace if we are allowed to. Don't go any further if we have + * reached the caller specified maximum depth or if the user + * function has specified that the maximum depth has been reached. */ if ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH)) { if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) { - /* - * There is at least one child of this - * node, visit the onde - */ + /* There is at least one child of this node, visit it */ + Level++; ParentNode = ChildNode; - ChildNode = NULL; + ChildNode = NULL; } } } else { /* - * No more children of this node (AcpiNsGetNextNode - * failed), go back upwards in the namespace tree to - * the node's parent. + * No more children of this node (AcpiNsGetNextNode failed), go + * back upwards in the namespace tree to the node's parent. */ Level--; ChildNode = ParentNode; diff --git a/sys/dist/acpica/nsxfeval.c b/sys/dist/acpica/nsxfeval.c index d50a1cf93e4..56e1ca66a59 100644 --- a/sys/dist/acpica/nsxfeval.c +++ b/sys/dist/acpica/nsxfeval.c @@ -2,7 +2,7 @@ * * Module Name: nsxfeval - Public interfaces to the ACPI subsystem * ACPI Object evaluation interfaces - * xRevision: 1.24 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,14 +116,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsxfeval.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSXFEVAL_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_NAMESPACE @@ -163,7 +160,7 @@ AcpiEvaluateObjectTyped ( BOOLEAN MustFree = FALSE; - ACPI_FUNCTION_TRACE ("AcpiEvaluateObjectTyped"); + ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped); /* Return buffer must be valid */ @@ -227,6 +224,8 @@ AcpiEvaluateObjectTyped ( return_ACPI_STATUS (AE_TYPE); } +ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped) + /******************************************************************************* * @@ -256,24 +255,37 @@ AcpiEvaluateObject ( ACPI_BUFFER *ReturnBuffer) { ACPI_STATUS Status; - ACPI_STATUS Status2; - ACPI_PARAMETER_INFO Info; + ACPI_EVALUATE_INFO *Info; ACPI_SIZE BufferSpaceNeeded; UINT32 i; - ACPI_FUNCTION_TRACE ("AcpiEvaluateObject"); + ACPI_FUNCTION_TRACE (AcpiEvaluateObject); + + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + Info->Pathname = Pathname; + Info->ParameterType = ACPI_PARAM_ARGS; - Info.Node = Handle; - Info.Parameters = NULL; - Info.ReturnObject = NULL; - Info.ParameterType = ACPI_PARAM_ARGS; + /* Convert and validate the device handle */ + + Info->PrefixNode = AcpiNsMapHandleToNode (Handle); + if (!Info->PrefixNode) + { + Status = AE_BAD_PARAMETER; + goto Cleanup; + } /* - * If there are parameters to be passed to the object - * (which must be a control method), the external objects - * must be converted to internal objects + * If there are parameters to be passed to a control method, the external + * objects must all be converted to internal objects */ if (ExternalParams && ExternalParams->Count) { @@ -281,29 +293,26 @@ AcpiEvaluateObject ( * Allocate a new parameter block for the internal objects * Add 1 to count to allow for null terminated internal list */ - Info.Parameters = ACPI_MEM_CALLOCATE ( - ((ACPI_SIZE) ExternalParams->Count + 1) * - sizeof (void *)); - if (!Info.Parameters) + Info->Parameters = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) ExternalParams->Count + 1) * sizeof (void *)); + if (!Info->Parameters) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup; } - /* - * Convert each external object in the list to an - * internal object - */ + /* Convert each external object in the list to an internal object */ + for (i = 0; i < ExternalParams->Count; i++) { - Status = AcpiUtCopyEobjectToIobject (&ExternalParams->Pointer[i], - &Info.Parameters[i]); + Status = AcpiUtCopyEobjectToIobject ( + &ExternalParams->Pointer[i], &Info->Parameters[i]); if (ACPI_FAILURE (Status)) { - AcpiUtDeleteInternalObjectList (Info.Parameters); - return_ACPI_STATUS (Status); + goto Cleanup; } } - Info.Parameters[ExternalParams->Count] = NULL; + Info->Parameters[ExternalParams->Count] = NULL; } /* @@ -317,14 +326,15 @@ AcpiEvaluateObject ( { /* The path is fully qualified, just evaluate by name */ - Status = AcpiNsEvaluateByName (Pathname, &Info); + Info->PrefixNode = NULL; + Status = AcpiNsEvaluate (Info); } else if (!Handle) { /* - * A handle is optional iff a fully qualified pathname - * is specified. Since we've already handled fully - * qualified names above, this is an error + * A handle is optional iff a fully qualified pathname is specified. + * Since we've already handled fully qualified names above, this is + * an error */ if (!Pathname) { @@ -341,41 +351,25 @@ AcpiEvaluateObject ( } else { - /* - * We get here if we have a handle -- and if we have a - * pathname it is relative. The handle will be validated - * in the lower procedures - */ - if (!Pathname) - { - /* - * The null pathname case means the handle is for - * the actual object to be evaluated - */ - Status = AcpiNsEvaluateByHandle (&Info); - } - else - { - /* Both a Handle and a relative Pathname */ + /* We have a namespace a node and a possible relative path */ - Status = AcpiNsEvaluateRelative (Pathname, &Info); - } + Status = AcpiNsEvaluate (Info); } - /* * If we are expecting a return value, and all went well above, * copy the return value to an external object. */ if (ReturnBuffer) { - if (!Info.ReturnObject) + if (!Info->ReturnObject) { ReturnBuffer->Length = 0; } else { - if (ACPI_GET_DESCRIPTOR_TYPE (Info.ReturnObject) == ACPI_DESC_TYPE_NAMED) + if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) == + ACPI_DESC_TYPE_NAMED) { /* * If we received a NS Node as a return object, this means that @@ -386,24 +380,22 @@ AcpiEvaluateObject ( * support for various types at a later date if necessary. */ Status = AE_TYPE; - Info.ReturnObject = NULL; /* No need to delete a NS Node */ + Info->ReturnObject = NULL; /* No need to delete a NS Node */ ReturnBuffer->Length = 0; } if (ACPI_SUCCESS (Status)) { - /* - * Find out how large a buffer is needed - * to contain the returned object - */ - Status = AcpiUtGetObjectSize (Info.ReturnObject, - &BufferSpaceNeeded); + /* Get the size of the returned object */ + + Status = AcpiUtGetObjectSize (Info->ReturnObject, + &BufferSpaceNeeded); if (ACPI_SUCCESS (Status)) { /* Validate/Allocate/Clear caller buffer */ Status = AcpiUtInitializeBuffer (ReturnBuffer, - BufferSpaceNeeded); + BufferSpaceNeeded); if (ACPI_FAILURE (Status)) { /* @@ -419,44 +411,46 @@ AcpiEvaluateObject ( { /* We have enough space for the object, build it */ - Status = AcpiUtCopyIobjectToEobject (Info.ReturnObject, - ReturnBuffer); + Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject, + ReturnBuffer); } } } } } - if (Info.ReturnObject) + if (Info->ReturnObject) { /* - * Delete the internal return object. NOTE: Interpreter - * must be locked to avoid race condition. + * Delete the internal return object. NOTE: Interpreter must be + * locked to avoid race condition. */ - Status2 = AcpiExEnterInterpreter (); - if (ACPI_SUCCESS (Status2)) - { - /* - * Delete the internal return object. (Or at least - * decrement the reference count by one) - */ - AcpiUtRemoveReference (Info.ReturnObject); - AcpiExExitInterpreter (); - } + AcpiExEnterInterpreter (); + + /* Remove one reference on the return object (should delete it) */ + + AcpiUtRemoveReference (Info->ReturnObject); + AcpiExExitInterpreter (); } + +Cleanup: + /* Free the input parameter list (if we created one) */ - if (Info.Parameters) + if (Info->Parameters) { /* Free the allocated parameter block */ - AcpiUtDeleteInternalObjectList (Info.Parameters); + AcpiUtDeleteInternalObjectList (Info->Parameters); } + ACPI_FREE (Info); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiEvaluateObject) + /******************************************************************************* * @@ -500,13 +494,13 @@ AcpiWalkNamespace ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiWalkNamespace"); + ACPI_FUNCTION_TRACE (AcpiWalkNamespace); /* Parameter validation */ if ((Type > ACPI_TYPE_LOCAL_MAX) || - (!MaxDepth) || + (!MaxDepth) || (!UserFunction)) { return_ACPI_STATUS (AE_BAD_PARAMETER); @@ -532,6 +526,8 @@ AcpiWalkNamespace ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiWalkNamespace) + /******************************************************************************* * @@ -631,11 +627,11 @@ AcpiNsGetDeviceCallback ( if (ACPI_STRNCMP (Cid->Id[i].Value, Info->Hid, sizeof (ACPI_COMPATIBLE_ID)) != 0) { - ACPI_MEM_FREE (Cid); + ACPI_FREE (Cid); return (AE_OK); } } - ACPI_MEM_FREE (Cid); + ACPI_FREE (Cid); } } @@ -681,7 +677,7 @@ AcpiGetDevices ( ACPI_GET_DEVICES_INFO Info; - ACPI_FUNCTION_TRACE ("AcpiGetDevices"); + ACPI_FUNCTION_TRACE (AcpiGetDevices); /* Parameter validation */ @@ -719,6 +715,8 @@ AcpiGetDevices ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetDevices) + /******************************************************************************* * @@ -775,6 +773,8 @@ UnlockAndExit: return (Status); } +ACPI_EXPORT_SYMBOL (AcpiAttachData) + /******************************************************************************* * @@ -828,6 +828,8 @@ UnlockAndExit: return (Status); } +ACPI_EXPORT_SYMBOL (AcpiDetachData) + /******************************************************************************* * @@ -884,4 +886,6 @@ UnlockAndExit: return (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetData) + diff --git a/sys/dist/acpica/nsxfname.c b/sys/dist/acpica/nsxfname.c index 99fdd3631cd..dd2c47c0d96 100644 --- a/sys/dist/acpica/nsxfname.c +++ b/sys/dist/acpica/nsxfname.c @@ -2,7 +2,7 @@ * * Module Name: nsxfname - Public interfaces to the ACPI subsystem * ACPI Namespace oriented interfaces - * xRevision: 1.106 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsxfname.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSXFNAME_C__ -#include "acpi.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_NAMESPACE @@ -171,41 +168,42 @@ AcpiGetHandle ( if (Parent) { - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - PrefixNode = AcpiNsMapHandleToNode (Parent); if (!PrefixNode) { - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (AE_BAD_PARAMETER); } + } + + /* + * Valid cases are: + * 1) Fully qualified pathname + * 2) Parent + Relative pathname + * + * Error for <null Parent + relative path> + */ + if (AcpiNsValidRootPrefix (Pathname[0])) + { + /* Pathname is fully qualified (starts with '\') */ + + /* Special case for root-only, since we can't search for it */ - Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) + if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH)) { - return (Status); + *RetHandle = AcpiNsConvertEntryToHandle (AcpiGbl_RootNode); + return (AE_OK); } } - - /* Special case for root, since we can't search for it */ - - if (ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH) == 0) + else if (!PrefixNode) { - *RetHandle = AcpiNsConvertEntryToHandle (AcpiGbl_RootNode); - return (AE_OK); + /* Relative path with null prefix is disallowed */ + + return (AE_BAD_PARAMETER); } - /* - * Find the Node and convert to a handle - */ - Status = AcpiNsGetNodeByPath (Pathname, PrefixNode, ACPI_NS_NO_UPSEARCH, - &Node); + /* Find the Node and convert to a handle */ - *RetHandle = NULL; + Status = AcpiNsGetNode (PrefixNode, Pathname, ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_SUCCESS (Status)) { *RetHandle = AcpiNsConvertEntryToHandle (Node); @@ -214,6 +212,8 @@ AcpiGetHandle ( return (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetHandle) + /****************************************************************************** * @@ -301,6 +301,8 @@ UnlockAndExit: return (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetName) + /****************************************************************************** * @@ -343,7 +345,7 @@ AcpiGetObjectInfo ( return (Status); } - Info = ACPI_MEM_CALLOCATE (sizeof (ACPI_DEVICE_INFO)); + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_INFO)); if (!Info) { return (AE_NO_MEMORY); @@ -460,11 +462,13 @@ AcpiGetObjectInfo ( Cleanup: - ACPI_MEM_FREE (Info); + ACPI_FREE (Info); if (CidList) { - ACPI_MEM_FREE (CidList); + ACPI_FREE (CidList); } return (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo) + diff --git a/sys/dist/acpica/nsxfobj.c b/sys/dist/acpica/nsxfobj.c index 0497d084de5..ee9f42420cd 100644 --- a/sys/dist/acpica/nsxfobj.c +++ b/sys/dist/acpica/nsxfobj.c @@ -2,7 +2,7 @@ * * Module Name: nsxfobj - Public interfaces to the ACPI subsystem * ACPI Object oriented interfaces - * xRevision: 1.120 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,13 +116,10 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsxfobj.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __NSXFOBJ_C__ -#include "acpi.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_NAMESPACE @@ -189,6 +186,8 @@ AcpiGetType ( return (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetType) + /******************************************************************************* * @@ -259,6 +258,8 @@ UnlockAndExit: return (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetParent) + /******************************************************************************* * @@ -351,4 +352,5 @@ UnlockAndExit: return (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetNextObject) diff --git a/sys/dist/acpica/psargs.c b/sys/dist/acpica/psargs.c index c59e20c670f..85cb6ec3617 100644 --- a/sys/dist/acpica/psargs.c +++ b/sys/dist/acpica/psargs.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psargs - Parse AML opcode arguments - * xRevision: 1.90 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,16 +114,13 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psargs.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __PSARGS_C__ -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acdispat.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdispat.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psargs") @@ -163,7 +160,7 @@ AcpiPsGetNextPackageLength ( UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */ - ACPI_FUNCTION_TRACE ("PsGetNextPackageLength"); + ACPI_FUNCTION_TRACE (PsGetNextPackageLength); /* @@ -218,7 +215,7 @@ AcpiPsGetNextPackageEnd ( UINT32 PackageLength; - ACPI_FUNCTION_TRACE ("PsGetNextPackageEnd"); + ACPI_FUNCTION_TRACE (PsGetNextPackageEnd); /* Function below updates ParserState->Aml */ @@ -252,7 +249,7 @@ AcpiPsGetNextNamestring ( UINT8 *End = ParserState->Aml; - ACPI_FUNCTION_TRACE ("PsGetNextNamestring"); + ACPI_FUNCTION_TRACE (PsGetNextNamestring); /* Point past any namestring prefix characters (backslash or carat) */ @@ -340,7 +337,7 @@ AcpiPsGetNextNamepath ( ACPI_GENERIC_STATE ScopeInfo; - ACPI_FUNCTION_TRACE ("PsGetNextNamepath"); + ACPI_FUNCTION_TRACE (PsGetNextNamepath); Path = AcpiPsGetNextNamestring (ParserState); @@ -502,7 +499,7 @@ AcpiPsGetNextSimpleArg ( UINT8 *Aml = ParserState->Aml; - ACPI_FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType); + ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType); switch (ArgType) @@ -609,7 +606,7 @@ AcpiPsGetNextField ( UINT32 Name; - ACPI_FUNCTION_TRACE ("PsGetNextField"); + ACPI_FUNCTION_TRACE (PsGetNextField); /* Determine field type */ @@ -722,7 +719,7 @@ AcpiPsGetNextArg ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_PTR ("PsGetNextArg", ParserState); + ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState); switch (ArgType) diff --git a/sys/dist/acpica/psloop.c b/sys/dist/acpica/psloop.c index e058e2ed8c8..11576821a38 100644 --- a/sys/dist/acpica/psloop.c +++ b/sys/dist/acpica/psloop.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psloop - Main AML parse loop - * xRevision: 1.10 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -116,21 +116,17 @@ /* - * Parse the AML and build an operation tree as most interpreters, - * like Perl, do. Parsing is done by hand rather than with a YACC - * generated parser to tightly constrain stack and dynamic memory - * usage. At the same time, parsing is kept flexible and the code - * fairly compact by parsing based on a list of AML opcode - * templates in AmlOpInfo[] + * Parse the AML and build an operation tree as most interpreters, (such as + * Perl) do. Parsing is done by hand rather than with a YACC generated parser + * to tightly constrain stack and dynamic memory usage. Parsing is kept + * flexible and the code fairly compact by parsing based on a list of AML + * opcode templates in AmlOpInfo[]. */ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psloop.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acparser.h" -#include "acdispat.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psloop") @@ -138,744 +134,739 @@ __KERNEL_RCSID(0, "$NetBSD: psloop.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); static UINT32 AcpiGbl_Depth = 0; +/* Local prototypes */ + +static ACPI_STATUS +AcpiPsGetAmlOpcode ( + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiPsBuildNamedOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *UnnamedOp, + ACPI_PARSE_OBJECT **Op); + +static ACPI_STATUS +AcpiPsCreateOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT **NewOp); + +static ACPI_STATUS +AcpiPsGetArguments ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *Op); + +static ACPI_STATUS +AcpiPsCompleteOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **Op, + ACPI_STATUS Status); + +static ACPI_STATUS +AcpiPsCompleteFinalOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS Status); + + /******************************************************************************* * - * FUNCTION: AcpiPsParseLoop + * FUNCTION: AcpiPsGetAmlOpcode * * PARAMETERS: WalkState - Current state * * RETURN: Status * - * DESCRIPTION: Parse AML (pointed to by the current parser state) and return - * a tree of ops. + * DESCRIPTION: Extract the next AML opcode from the input stream. * ******************************************************************************/ -ACPI_STATUS -AcpiPsParseLoop ( +static ACPI_STATUS +AcpiPsGetAmlOpcode ( ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status = AE_OK; - ACPI_STATUS Status2; - ACPI_PARSE_OBJECT *Op = NULL; /* current op */ - ACPI_PARSE_OBJECT *Arg = NULL; - ACPI_PARSE_OBJECT *PreOp = NULL; - ACPI_PARSE_STATE *ParserState; - UINT8 *AmlOpStart = NULL; + ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState); - ACPI_FUNCTION_TRACE_PTR ("PsParseLoop", WalkState); - if (WalkState->DescendingCallback == NULL) + WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, + WalkState->ParserState.AmlStart); + WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState)); + + /* + * First cut to determine what we have found: + * 1) A valid AML opcode + * 2) A name string + * 3) An unknown/invalid opcode + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + + switch (WalkState->OpInfo->Class) { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } + case AML_CLASS_ASCII: + case AML_CLASS_PREFIX: + /* + * Starts with a valid prefix or ASCII char, this is a name + * string. Convert the bare name string to a namepath. + */ + WalkState->Opcode = AML_INT_NAMEPATH_OP; + WalkState->ArgTypes = ARGP_NAMESTRING; + break; - ParserState = &WalkState->ParserState; - WalkState->ArgTypes = 0; + case AML_CLASS_UNKNOWN: -#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + /* The opcode is unrecognized. Just skip unknown opcodes */ - if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) - { - /* We are restarting a preempted control method */ + ACPI_ERROR ((AE_INFO, + "Found unknown opcode %X at AML address %p offset %X, ignoring", + WalkState->Opcode, WalkState->ParserState.Aml, WalkState->AmlOffset)); - if (AcpiPsHasCompletedScope (ParserState)) - { - /* - * We must check if a predicate to an IF or WHILE statement - * was just completed - */ - if ((ParserState->Scope->ParseScope.Op) && - ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) || - (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) && - (WalkState->ControlState) && - (WalkState->ControlState->Common.State == - ACPI_CONTROL_PREDICATE_EXECUTING)) - { - /* - * A predicate was just completed, get the value of the - * predicate and branch based on that value - */ - WalkState->Op = NULL; - Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE)); - if (ACPI_FAILURE (Status) && - ((Status & AE_CODE_MASK) != AE_CODE_CONTROL)) - { - if (Status == AE_AML_NO_RETURN_VALUE) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Invoked method did not return a value")); + ACPI_DUMP_BUFFER (WalkState->ParserState.Aml, 128); - } - ACPI_EXCEPTION ((AE_INFO, Status, - "GetPredicate Failed")); - return_ACPI_STATUS (Status); - } + /* Assume one-byte bad opcode */ - Status = AcpiPsNextParseState (WalkState, Op, Status); - } + WalkState->ParserState.Aml++; + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); - } - else if (WalkState->PrevOp) - { - /* We were in the middle of an op */ + default: - Op = WalkState->PrevOp; - WalkState->ArgTypes = WalkState->PrevArgTypes; - } - } -#endif + /* Found opcode info, this is a normal opcode */ - /* Iterative parsing loop, while there is more AML to process: */ + WalkState->ParserState.Aml += AcpiPsGetOpcodeSize (WalkState->Opcode); + WalkState->ArgTypes = WalkState->OpInfo->ParseArgs; + break; + } - while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) - { - AmlOpStart = ParserState->Aml; - if (!Op) - { - /* Get the next opcode from the AML stream */ + return_ACPI_STATUS (AE_OK); +} - WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, - ParserState->AmlStart); - WalkState->Opcode = AcpiPsPeekOpcode (ParserState); - /* - * First cut to determine what we have found: - * 1) A valid AML opcode - * 2) A name string - * 3) An unknown/invalid opcode - */ - WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); - switch (WalkState->OpInfo->Class) - { - case AML_CLASS_ASCII: - case AML_CLASS_PREFIX: - /* - * Starts with a valid prefix or ASCII char, this is a name - * string. Convert the bare name string to a namepath. - */ - WalkState->Opcode = AML_INT_NAMEPATH_OP; - WalkState->ArgTypes = ARGP_NAMESTRING; - break; +/******************************************************************************* + * + * FUNCTION: AcpiPsBuildNamedOp + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Begin of named Op in AML + * UnnamedOp - Early Op (not a named Op) + * Op - Returned Op + * + * RETURN: Status + * + * DESCRIPTION: Parse a named Op + * + ******************************************************************************/ - case AML_CLASS_UNKNOWN: +static ACPI_STATUS +AcpiPsBuildNamedOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *UnnamedOp, + ACPI_PARSE_OBJECT **Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg = NULL; - /* The opcode is unrecognized. Just skip unknown opcodes */ - ACPI_ERROR ((AE_INFO, - "Found unknown opcode %X at AML address %p offset %X, ignoring", - WalkState->Opcode, ParserState->Aml, WalkState->AmlOffset)); + ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState); - ACPI_DUMP_BUFFER (ParserState->Aml, 128); - /* Assume one-byte bad opcode */ + UnnamedOp->Common.Value.Arg = NULL; + UnnamedOp->Common.ArgListLength = 0; + UnnamedOp->Common.AmlOpcode = WalkState->Opcode; - ParserState->Aml++; - continue; + /* + * Get and append arguments until we find the node that contains + * the name (the type ARGP_NAME). + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && + (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME)) + { + Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - default: + AcpiPsAppendArg (UnnamedOp, Arg); + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } - /* Found opcode info, this is a normal opcode */ + /* + * Make sure that we found a NAME and didn't run out of arguments + */ + if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes)) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } - ParserState->Aml += AcpiPsGetOpcodeSize (WalkState->Opcode); - WalkState->ArgTypes = WalkState->OpInfo->ParseArgs; - break; - } + /* We know that this arg is a name, move to next arg */ - /* Create Op structure and append to parent's argument list */ + INCREMENT_ARG_LIST (WalkState->ArgTypes); - if (WalkState->OpInfo->Flags & AML_NAMED) - { - /* Allocate a new PreOp if necessary */ + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + WalkState->Op = NULL; - if (!PreOp) - { - PreOp = AcpiPsAllocOp (WalkState->Opcode); - if (!PreOp) - { - Status = AE_NO_MEMORY; - goto CloseThisOp; - } - } + Status = WalkState->DescendingCallback (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog")); + return_ACPI_STATUS (Status); + } - PreOp->Common.Value.Arg = NULL; - PreOp->Common.AmlOpcode = WalkState->Opcode; + if (!*Op) + { + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + } - /* - * Get and append arguments until we find the node that contains - * the name (the type ARGP_NAME). - */ - while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && - (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME)) - { - Status = AcpiPsGetNextArg (WalkState, ParserState, - GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } + Status = AcpiPsNextParseState (WalkState, *Op, Status); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_PENDING) + { + return_ACPI_STATUS (AE_CTRL_PARSE_PENDING); + } + return_ACPI_STATUS (Status); + } - AcpiPsAppendArg (PreOp, Arg); - INCREMENT_ARG_LIST (WalkState->ArgTypes); - } + AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg); + AcpiGbl_Depth++; - /* - * Make sure that we found a NAME and didn't run out of - * arguments - */ - if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes)) - { - Status = AE_AML_NO_OPERAND; - goto CloseThisOp; - } + if ((*Op)->Common.AmlOpcode == AML_REGION_OP) + { + /* + * Defer final parsing of an OperationRegion body, because we don't + * have enough info in the first pass to parse it correctly (i.e., + * there may be method calls within the TermArg elements of the body.) + * + * However, we must continue parsing because the opregion is not a + * standalone package -- we don't know where the end is at this point. + * + * (Length is unknown until parse of the body complete) + */ + (*Op)->Named.Data = AmlOpStart; + (*Op)->Named.Length = 0; + } - /* We know that this arg is a name, move to next arg */ + return_ACPI_STATUS (AE_OK); +} - INCREMENT_ARG_LIST (WalkState->ArgTypes); - /* - * Find the object. This will either insert the object into - * the namespace or simply look it up - */ - WalkState->Op = NULL; +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateOp + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Op start in AML + * NewOp - Returned Op + * + * RETURN: Status + * + * DESCRIPTION: Get Op from AML + * + ******************************************************************************/ - Status = WalkState->DescendingCallback (WalkState, &Op); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "During name lookup/catalog")); - goto CloseThisOp; - } +static ACPI_STATUS +AcpiPsCreateOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT **NewOp) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *NamedOp = NULL; + ACPI_PARSE_OBJECT *ParentScope; + UINT8 ArgumentCount; + const ACPI_OPCODE_INFO *OpInfo; - if (!Op) - { - continue; - } - Status = AcpiPsNextParseState (WalkState, Op, Status); - if (Status == AE_CTRL_PENDING) - { - Status = AE_OK; - goto CloseThisOp; - } + ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState); - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } - AcpiPsAppendArg (Op, PreOp->Common.Value.Arg); - AcpiGbl_Depth++; + Status = AcpiPsGetAmlOpcode (WalkState); + if (Status == AE_CTRL_PARSE_CONTINUE) + { + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + } - if (Op->Common.AmlOpcode == AML_REGION_OP) - { - /* - * Defer final parsing of an OperationRegion body, - * because we don't have enough info in the first pass - * to parse it correctly (i.e., there may be method - * calls within the TermArg elements of the body.) - * - * However, we must continue parsing because - * the opregion is not a standalone package -- - * we don't know where the end is at this point. - * - * (Length is unknown until parse of the body complete) - */ - Op->Named.Data = AmlOpStart; - Op->Named.Length = 0; - } - } - else - { - /* Not a named opcode, just allocate Op and append to parent */ + /* Create Op structure and append to parent's argument list */ - WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); - Op = AcpiPsAllocOp (WalkState->Opcode); - if (!Op) - { - Status = AE_NO_MEMORY; - goto CloseThisOp; - } + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } - if (WalkState->OpInfo->Flags & AML_CREATE) - { - /* - * Backup to beginning of CreateXXXfield declaration - * BodyLength is unknown until we parse the body - */ - Op->Named.Data = AmlOpStart; - Op->Named.Length = 0; - } + if (WalkState->OpInfo->Flags & AML_NAMED) + { + Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp); + AcpiPsFreeOp (Op); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op); + *NewOp = NamedOp; + return_ACPI_STATUS (AE_OK); + } - if ((WalkState->DescendingCallback != NULL)) - { - /* - * Find the object. This will either insert the object into - * the namespace or simply look it up - */ - WalkState->Op = Op; - - Status = WalkState->DescendingCallback (WalkState, &Op); - Status = AcpiPsNextParseState (WalkState, Op, Status); - if (Status == AE_CTRL_PENDING) - { - Status = AE_OK; - goto CloseThisOp; - } + /* Not a named opcode, just allocate Op and append to parent */ - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } - } - } + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration + * BodyLength is unknown until we parse the body + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = 0; + } - Op->Common.AmlOffset = WalkState->AmlOffset; + ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState)); + AcpiPsAppendArg (ParentScope, Op); - if (WalkState->OpInfo) + if (ParentScope) + { + OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode); + if (OpInfo->Flags & AML_HAS_TARGET) + { + ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type); + if (ParentScope->Common.ArgListLength > ArgumentCount) { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", - (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name, - Op, ParserState->Aml, Op->Common.AmlOffset)); + Op->Common.Flags |= ACPI_PARSEOP_TARGET; } } + else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) + { + Op->Common.Flags |= ACPI_PARSEOP_TARGET; + } + } - + if (WalkState->DescendingCallback != NULL) + { /* - * Start ArgCount at zero because we don't know if there are - * any args yet + * Find the object. This will either insert the object into + * the namespace or simply look it up */ - WalkState->ArgCount = 0; - - /* Are there any arguments that must be processed? */ + WalkState->Op = *NewOp = Op; - if (WalkState->ArgTypes) + Status = WalkState->DescendingCallback (WalkState, &Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) { - /* Get arguments */ - - switch (Op->Common.AmlOpcode) - { - case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ - case AML_WORD_OP: /* AML_WORDDATA_ARG */ - case AML_DWORD_OP: /* AML_DWORDATA_ARG */ - case AML_QWORD_OP: /* AML_QWORDATA_ARG */ - case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ - - /* Fill in constant or string argument directly */ + Status = AE_CTRL_PARSE_PENDING; + } + } - AcpiPsGetNextSimpleArg (ParserState, - GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op); - break; + return_ACPI_STATUS (Status); +} - case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ - Status = AcpiPsGetNextNamepath (WalkState, ParserState, Op, 1); - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArguments + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Op start in AML + * Op - Current Op + * + * RETURN: Status + * + * DESCRIPTION: Get arguments for passed Op. + * + ******************************************************************************/ - WalkState->ArgTypes = 0; - break; +static ACPI_STATUS +AcpiPsGetArguments ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg = NULL; - default: - /* - * Op is not a constant or string, append each argument - * to the Op - */ - while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && - !WalkState->ArgCount) - { - WalkState->AmlOffset = (UINT32) - ACPI_PTR_DIFF (ParserState->Aml, ParserState->AmlStart); - Status = AcpiPsGetNextArg (WalkState, ParserState, - GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), - &Arg); - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } + ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState); - if (Arg) - { - Arg->Common.AmlOffset = WalkState->AmlOffset; - AcpiPsAppendArg (Op, Arg); - } - INCREMENT_ARG_LIST (WalkState->ArgTypes); - } + switch (Op->Common.AmlOpcode) + { + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_QWORD_OP: /* AML_QWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ - /* Special processing for certain opcodes */ + /* Fill in constant or string argument directly */ - /* TBD (remove): Temporary mechanism to disable this code if needed */ + AcpiPsGetNextSimpleArg (&(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op); + break; -#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE + case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ - if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS1) && - ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0)) - { - /* - * We want to skip If/Else/While constructs during Pass1 - * because we want to actually conditionally execute the - * code during Pass2. - * - * Except for disassembly, where we always want to - * walk the If/Else/While packages - */ - switch (Op->Common.AmlOpcode) - { - case AML_IF_OP: - case AML_ELSE_OP: - case AML_WHILE_OP: + Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Pass1: Skipping an If/Else/While body\n")); + WalkState->ArgTypes = 0; + break; - /* Skip body of if/else/while in pass 1 */ + default: + /* + * Op is not a constant or string, append each argument to the Op + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount) + { + WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, + WalkState->ParserState.AmlStart); - ParserState->Aml = ParserState->PkgEnd; - WalkState->ArgCount = 0; - break; + Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - default: - break; - } - } -#endif - switch (Op->Common.AmlOpcode) - { - case AML_METHOD_OP: - - /* - * Skip parsing of control method - * because we don't have enough info in the first pass - * to parse it correctly. - * - * Save the length and address of the body - */ - Op->Named.Data = ParserState->Aml; - Op->Named.Length = (UINT32) (ParserState->PkgEnd - - ParserState->Aml); - - /* Skip body of method */ - - ParserState->Aml = ParserState->PkgEnd; - WalkState->ArgCount = 0; - break; - - case AML_BUFFER_OP: - case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: - - if ((Op->Common.Parent) && - (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && - (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) - { - /* - * Skip parsing of Buffers and Packages - * because we don't have enough info in the first pass - * to parse them correctly. - */ - Op->Named.Data = AmlOpStart; - Op->Named.Length = (UINT32) (ParserState->PkgEnd - - AmlOpStart); - - /* Skip body */ - - ParserState->Aml = ParserState->PkgEnd; - WalkState->ArgCount = 0; - } - break; + if (Arg) + { + Arg->Common.AmlOffset = WalkState->AmlOffset; + AcpiPsAppendArg (Op, Arg); + } - case AML_WHILE_OP: + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } - if (WalkState->ControlState) - { - WalkState->ControlState->Control.PackageEnd = - ParserState->PkgEnd; - } - break; - default: + /* Special processing for certain opcodes */ - /* No action for all other opcodes */ - break; - } - break; - } - } + /* TBD (remove): Temporary mechanism to disable this code if needed */ - /* Check for arguments that need to be processed */ +#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE - if (WalkState->ArgCount) + if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS1) && + ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0)) { /* - * There are arguments (complex ones), push Op and - * prepare for argument + * We want to skip If/Else/While constructs during Pass1 because we + * want to actually conditionally execute the code during Pass2. + * + * Except for disassembly, where we always want to walk the + * If/Else/While packages */ - Status = AcpiPsPushScope (ParserState, Op, - WalkState->ArgTypes, WalkState->ArgCount); - if (ACPI_FAILURE (Status)) + switch (Op->Common.AmlOpcode) { - goto CloseThisOp; - } - Op = NULL; - continue; - } + case AML_IF_OP: + case AML_ELSE_OP: + case AML_WHILE_OP: - /* - * All arguments have been processed -- Op is complete, - * prepare for next - */ - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - if (WalkState->OpInfo->Flags & AML_NAMED) - { - if (AcpiGbl_Depth) - { - AcpiGbl_Depth--; - } + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Pass1: Skipping an If/Else/While body\n")); - if (Op->Common.AmlOpcode == AML_REGION_OP) - { - /* - * Skip parsing of control method or opregion body, - * because we don't have enough info in the first pass - * to parse them correctly. - * - * Completed parsing an OpRegion declaration, we now - * know the length. - */ - Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + /* Skip body of if/else/while in pass 1 */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + break; + + default: + break; } } +#endif - if (WalkState->OpInfo->Flags & AML_CREATE) + switch (Op->Common.AmlOpcode) { + case AML_METHOD_OP: /* - * Backup to beginning of CreateXXXfield declaration (1 for - * Opcode) + * Skip parsing of control method because we don't have enough + * info in the first pass to parse it correctly. * - * BodyLength is unknown until we parse the body + * Save the length and address of the body */ - Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); - } + Op->Named.Data = WalkState->ParserState.Aml; + Op->Named.Length = (UINT32) + (WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml); - /* This op complete, notify the dispatcher */ + /* Skip body of method */ - if (WalkState->AscendingCallback != NULL) - { - WalkState->Op = Op; - WalkState->Opcode = Op->Common.AmlOpcode; + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + break; - Status = WalkState->AscendingCallback (WalkState); - Status = AcpiPsNextParseState (WalkState, Op, Status); - if (Status == AE_CTRL_PENDING) + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + if ((Op->Common.Parent) && + (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) { - Status = AE_OK; - goto CloseThisOp; + /* + * Skip parsing of Buffers and Packages because we don't have + * enough info in the first pass to parse them correctly. + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = (UINT32) + (WalkState->ParserState.PkgEnd - AmlOpStart); + + /* Skip body */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; } - } + break; + case AML_WHILE_OP: -CloseThisOp: - /* - * Finished one argument of the containing scope - */ - ParserState->Scope->ParseScope.ArgCount--; + if (WalkState->ControlState) + { + WalkState->ControlState->Control.PackageEnd = + WalkState->ParserState.PkgEnd; + } + break; - /* Finished with PreOp */ + default: - if (PreOp) - { - AcpiPsFreeOp (PreOp); - PreOp = NULL; + /* No action for all other opcodes */ + break; } - /* Close this Op (will result in parse subtree deletion) */ + break; + } - Status2 = AcpiPsCompleteThisOp (WalkState, Op); - if (ACPI_FAILURE (Status2)) - { - return_ACPI_STATUS (Status2); - } - Op = NULL; + return_ACPI_STATUS (AE_OK); +} - switch (Status) - { - case AE_OK: - break; +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteOp + * + * PARAMETERS: WalkState - Current state + * Op - Returned Op + * Status - Parse status before complete Op + * + * RETURN: Status + * + * DESCRIPTION: Complete Op + * + ******************************************************************************/ - case AE_CTRL_TRANSFER: +static ACPI_STATUS +AcpiPsCompleteOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **Op, + ACPI_STATUS Status) +{ + ACPI_STATUS Status2; - /* We are about to transfer to a called method. */ - WalkState->PrevOp = Op; - WalkState->PrevArgTypes = WalkState->ArgTypes; - return_ACPI_STATUS (Status); + ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState); - case AE_CTRL_END: + /* + * Finished one argument of the containing scope + */ + WalkState->ParserState.Scope->ParseScope.ArgCount--; - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); + /* Close this Op (will result in parse subtree deletion) */ - if (Op) - { - WalkState->Op = Op; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - WalkState->Opcode = Op->Common.AmlOpcode; + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } - Status = WalkState->AscendingCallback (WalkState); - Status = AcpiPsNextParseState (WalkState, Op, Status); + *Op = NULL; - Status2 = AcpiPsCompleteThisOp (WalkState, Op); - if (ACPI_FAILURE (Status2)) - { - return_ACPI_STATUS (Status2); - } - Op = NULL; - } - Status = AE_OK; - break; + switch (Status) + { + case AE_OK: + break; - case AE_CTRL_BREAK: - case AE_CTRL_CONTINUE: + case AE_CTRL_TRANSFER: - /* Pop off scopes until we find the While */ + /* We are about to transfer to a called method */ - while (!Op || (Op->Common.AmlOpcode != AML_WHILE_OP)) - { - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); + WalkState->PrevOp = NULL; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); - if (Op->Common.AmlOpcode != AML_WHILE_OP) - { - Status2 = AcpiDsResultStackPop (WalkState); - if (ACPI_FAILURE (Status2)) - { - return_ACPI_STATUS (Status2); - } - } - } - /* Close this iteration of the While loop */ + case AE_CTRL_END: - WalkState->Op = Op; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - WalkState->Opcode = Op->Common.AmlOpcode; + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + if (*Op) + { + WalkState->Op = *Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode); + WalkState->Opcode = (*Op)->Common.AmlOpcode; Status = WalkState->AscendingCallback (WalkState); - Status = AcpiPsNextParseState (WalkState, Op, Status); + Status = AcpiPsNextParseState (WalkState, *Op, Status); - Status2 = AcpiPsCompleteThisOp (WalkState, Op); + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); if (ACPI_FAILURE (Status2)) { return_ACPI_STATUS (Status2); } - Op = NULL; + } - Status = AE_OK; - break; + Status = AE_OK; + break; - case AE_CTRL_TERMINATE: + case AE_CTRL_BREAK: + case AE_CTRL_CONTINUE: - Status = AE_OK; + /* Pop off scopes until we find the While */ - /* Clean up */ - do - { - if (Op) - { - Status2 = AcpiPsCompleteThisOp (WalkState, Op); - if (ACPI_FAILURE (Status2)) - { - return_ACPI_STATUS (Status2); - } + while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP)) + { + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } - Status2 = AcpiDsResultStackPop (WalkState); - if (ACPI_FAILURE (Status2)) - { - return_ACPI_STATUS (Status2); - } + /* Close this iteration of the While loop */ - AcpiUtDeleteGenericState ( - AcpiUtPopGenericState (&WalkState->ControlState)); - } + WalkState->Op = *Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode); + WalkState->Opcode = (*Op)->Common.AmlOpcode; - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, *Op, Status); - } while (Op); + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } - return_ACPI_STATUS (Status); + Status = AE_OK; + break; - default: /* All other non-AE_OK status */ + case AE_CTRL_TERMINATE: - do + /* Clean up */ + do + { + if (*Op) { - if (Op) + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) { - Status2 = AcpiPsCompleteThisOp (WalkState, Op); - if (ACPI_FAILURE (Status2)) - { - return_ACPI_STATUS (Status2); - } + return_ACPI_STATUS (Status2); } - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); + AcpiUtDeleteGenericState ( + AcpiUtPopGenericState (&WalkState->ControlState)); + } - } while (Op); + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } while (*Op); - /* - * TBD: Cleanup parse ops on error - */ -#if 0 - if (Op == NULL) + return_ACPI_STATUS (AE_OK); + + + default: /* All other non-AE_OK status */ + + do + { + if (*Op) { - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } } -#endif - WalkState->PrevOp = Op; - WalkState->PrevArgTypes = WalkState->ArgTypes; - return_ACPI_STATUS (Status); - } - /* This scope complete? */ + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); - if (AcpiPsHasCompletedScope (ParserState)) + } while (*Op); + + +#if 0 + /* + * TBD: Cleanup parse ops on error + */ + if (*Op == NULL) { - AcpiPsPopScope (ParserState, &Op, + AcpiPsPopScope (ParserState, Op, &WalkState->ArgTypes, &WalkState->ArgCount); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); - } - else - { - Op = NULL; } +#endif + WalkState->PrevOp = NULL; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + } - } /* while ParserState->Aml */ + /* This scope complete? */ + + if (AcpiPsHasCompletedScope (&(WalkState->ParserState))) + { + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op)); + } + else + { + *Op = NULL; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteFinalOp + * + * PARAMETERS: WalkState - Current state + * Op - Current Op + * Status - Current parse status before complete last + * Op + * + * RETURN: Status + * + * DESCRIPTION: Complete last Op. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCompleteFinalOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS Status) +{ + ACPI_STATUS Status2; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState); /* * Complete the last Op (if not completed), and clear the scope stack. * It is easily possible to end an AML "package" with an unbounded number * of open scopes (such as when several ASL blocks are closed with - * sequential closing braces). We want to terminate each one cleanly. + * sequential closing braces). We want to terminate each one cleanly. */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op)); do @@ -884,7 +875,7 @@ CloseThisOp: { if (WalkState->AscendingCallback != NULL) { - WalkState->Op = Op; + WalkState->Op = Op; WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); WalkState->Opcode = Op->Common.AmlOpcode; @@ -892,8 +883,11 @@ CloseThisOp: Status = AcpiPsNextParseState (WalkState, Op, Status); if (Status == AE_CTRL_PENDING) { - Status = AE_OK; - goto CloseThisOp; + Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } if (Status == AE_CTRL_TERMINATE) @@ -912,7 +906,7 @@ CloseThisOp: } } - AcpiPsPopScope (ParserState, &Op, + AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes, &WalkState->ArgCount); } while (Op); @@ -936,7 +930,7 @@ CloseThisOp: } } - AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, + AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes, &WalkState->ArgCount); } while (Op); @@ -945,3 +939,248 @@ CloseThisOp: } +/******************************************************************************* + * + * FUNCTION: AcpiPsParseLoop + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Parse AML (pointed to by the current parser state) and return + * a tree of ops. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = NULL; /* current op */ + ACPI_PARSE_STATE *ParserState; + UINT8 *AmlOpStart = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState); + + + if (WalkState->DescendingCallback == NULL) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + ParserState = &WalkState->ParserState; + WalkState->ArgTypes = 0; + +#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + + if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) + { + /* We are restarting a preempted control method */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + /* + * We must check if a predicate to an IF or WHILE statement + * was just completed + */ + if ((ParserState->Scope->ParseScope.Op) && + ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) || + (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING)) + { + /* + * A predicate was just completed, get the value of the + * predicate and branch based on that value + */ + WalkState->Op = NULL; + Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE)); + if (ACPI_FAILURE (Status) && + ((Status & AE_CODE_MASK) != AE_CODE_CONTROL)) + { + if (Status == AE_AML_NO_RETURN_VALUE) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Invoked method did not return a value")); + + } + + ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed")); + return_ACPI_STATUS (Status); + } + + Status = AcpiPsNextParseState (WalkState, Op, Status); + } + + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); + } + else if (WalkState->PrevOp) + { + /* We were in the middle of an op */ + + Op = WalkState->PrevOp; + WalkState->ArgTypes = WalkState->PrevArgTypes; + } + } +#endif + + /* Iterative parsing loop, while there is more AML to process: */ + + while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) + { + AmlOpStart = ParserState->Aml; + if (!Op) + { + Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_PARSE_CONTINUE) + { + continue; + } + + if (Status == AE_CTRL_PARSE_PENDING) + { + Status = AE_OK; + } + + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + + Op->Common.AmlOffset = WalkState->AmlOffset; + + if (WalkState->OpInfo) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", + (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name, + Op, ParserState->Aml, Op->Common.AmlOffset)); + } + } + + + /* + * Start ArgCount at zero because we don't know if there are + * any args yet + */ + WalkState->ArgCount = 0; + + /* Are there any arguments that must be processed? */ + + if (WalkState->ArgTypes) + { + /* Get arguments */ + + Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op); + if (ACPI_FAILURE (Status)) + { + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + } + + /* Check for arguments that need to be processed */ + + if (WalkState->ArgCount) + { + /* + * There are arguments (complex ones), push Op and + * prepare for argument + */ + Status = AcpiPsPushScope (ParserState, Op, + WalkState->ArgTypes, WalkState->ArgCount); + if (ACPI_FAILURE (Status)) + { + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + + Op = NULL; + continue; + } + + /* + * All arguments have been processed -- Op is complete, + * prepare for next + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (WalkState->OpInfo->Flags & AML_NAMED) + { + if (AcpiGbl_Depth) + { + AcpiGbl_Depth--; + } + + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Completed parsing an OpRegion declaration, we now + * know the length. + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + } + + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + + /* This op complete, notify the dispatcher */ + + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + } + } + + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } /* while ParserState->Aml */ + + Status = AcpiPsCompleteFinalOp (WalkState, Op, Status); + return_ACPI_STATUS (Status); +} + diff --git a/sys/dist/acpica/psopcode.c b/sys/dist/acpica/psopcode.c index 3fad585f1af..b58b15925f5 100644 --- a/sys/dist/acpica/psopcode.c +++ b/sys/dist/acpica/psopcode.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psopcode - Parser/Interpreter opcode information table - * xRevision: 1.95 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,19 +115,19 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psopcode.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#include "acpi.h" -#include "acparser.h" -#include "acopcode.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acopcode.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psopcode") +const UINT8 AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6}; + + /******************************************************************************* * * NAME: AcpiGbl_AmlOpInfo @@ -498,7 +498,7 @@ const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo ( UINT16 Opcode) { - ACPI_FUNCTION_NAME ("PsGetOpcodeInfo"); + ACPI_FUNCTION_NAME (PsGetOpcodeInfo); /* @@ -557,8 +557,33 @@ AcpiPsGetOpcodeName ( return (Op->Name); #else - return ("AE_NOT_CONFIGURED"); + return ("OpcodeName unavailable"); #endif } + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArgumentCount + * + * PARAMETERS: OpType - Type associated with the AML opcode + * + * RETURN: Argument count + * + * DESCRIPTION: Obtain the number of expected arguments for an AML opcode + * + ******************************************************************************/ + +UINT8 +AcpiPsGetArgumentCount ( + UINT32 OpType) +{ + + if (OpType <= AML_TYPE_EXEC_6A_0T_1R) + { + return (AcpiGbl_ArgumentCount[OpType]); + } + + return (0); +} diff --git a/sys/dist/acpica/psparse.c b/sys/dist/acpica/psparse.c index 48663c1bc2b..92d5b906ea6 100644 --- a/sys/dist/acpica/psparse.c +++ b/sys/dist/acpica/psparse.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psparse - Parser top level AML parse routines - * xRevision: 1.163 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -124,15 +124,12 @@ * templates in AmlOpInfo[] */ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psparse.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acparser.h" -#include "acdispat.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psparse") @@ -227,7 +224,7 @@ AcpiPsCompleteThisOp ( ACPI_PARSE_OBJECT *ReplacementOp = NULL; - ACPI_FUNCTION_TRACE_PTR ("PsCompleteThisOp", Op); + ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op); /* Check for null Op, can happen if AML code is corrupt */ @@ -418,7 +415,7 @@ AcpiPsNextParseState ( ACPI_STATUS Status = AE_CTRL_PENDING; - ACPI_FUNCTION_TRACE_PTR ("PsNextParseState", Op); + ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op); switch (CallbackStatus) @@ -437,22 +434,14 @@ AcpiPsNextParseState ( ParserState->Aml = WalkState->AmlLastWhile; WalkState->ControlState->Common.Value = FALSE; - Status = AcpiDsResultStackPop (WalkState); - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_BREAK; - } + Status = AE_CTRL_BREAK; break; case AE_CTRL_CONTINUE: ParserState->Aml = WalkState->AmlLastWhile; - Status = AcpiDsResultStackPop (WalkState); - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_CONTINUE; - } + Status = AE_CTRL_CONTINUE; break; @@ -475,11 +464,7 @@ AcpiPsNextParseState ( * Just close out this package */ ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState); - Status = AcpiDsResultStackPop (WalkState); - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_PENDING; - } + Status = AE_CTRL_PENDING; break; @@ -552,7 +537,7 @@ AcpiPsParseAml ( ACPI_WALK_STATE *PreviousWalkState; - ACPI_FUNCTION_TRACE ("PsParseAml"); + ACPI_FUNCTION_TRACE (PsParseAml); ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with WalkState=%p Aml=%p size=%X\n", @@ -565,10 +550,21 @@ AcpiPsParseAml ( Thread = AcpiUtCreateThreadState (); if (!Thread) { + AcpiDsDeleteWalkState (WalkState); return_ACPI_STATUS (AE_NO_MEMORY); } WalkState->Thread = Thread; + + /* + * If executing a method, the starting SyncLevel is this method's + * SyncLevel + */ + if (WalkState->MethodDesc) + { + WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel; + } + AcpiDsPushWalkState (WalkState, Thread); /* @@ -606,6 +602,10 @@ AcpiPsParseAml ( * Transfer control to the called control method */ Status = AcpiDsCallControlMethod (Thread, WalkState, NULL); + if (ACPI_FAILURE (Status)) + { + Status = AcpiDsMethodError (Status, WalkState); + } /* * If the transfer to the new method method call worked, a new walk @@ -628,8 +628,11 @@ AcpiPsParseAml ( /* Check for possible multi-thread reentrancy problem */ if ((Status == AE_ALREADY_EXISTS) && - (!WalkState->MethodDesc->Method.Semaphore)) + (!WalkState->MethodDesc->Method.Mutex)) { + ACPI_INFO ((AE_INFO, "Marking method %4.4s as Serialized", + WalkState->MethodNode->Name.Ascii)); + /* * Method tried to create an object twice. The probable cause is * that the method cannot handle reentrancy. @@ -640,7 +643,7 @@ AcpiPsParseAml ( * as Serialized. */ WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED; - WalkState->MethodDesc->Method.Concurrency = 1; + WalkState->MethodDesc->Method.SyncLevel = 0; } } @@ -660,22 +663,7 @@ AcpiPsParseAml ( if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) || (ACPI_FAILURE (Status))) { - if (WalkState->MethodDesc) - { - /* Decrement the thread count on the method parse tree */ - - if (WalkState->MethodDesc->Method.ThreadCount) - { - WalkState->MethodDesc->Method.ThreadCount--; - } - else - { - ACPI_ERROR ((AE_INFO, - "Invalid zero thread count in method")); - } - } - - AcpiDsTerminateControlMethod (WalkState); + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); } /* Delete this walk state and all linked control states */ diff --git a/sys/dist/acpica/psscope.c b/sys/dist/acpica/psscope.c index 959888c0b02..2aa9d2fdb43 100644 --- a/sys/dist/acpica/psscope.c +++ b/sys/dist/acpica/psscope.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psscope - Parser scope stack management routines - * xRevision: 1.43 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,11 +115,8 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psscope.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acparser.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psscope") @@ -192,7 +189,7 @@ AcpiPsInitScope ( ACPI_GENERIC_STATE *Scope; - ACPI_FUNCTION_TRACE_PTR ("PsInitScope", RootOp); + ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp); Scope = AcpiUtCreateGenericState (); @@ -201,14 +198,14 @@ AcpiPsInitScope ( return_ACPI_STATUS (AE_NO_MEMORY); } - Scope->Common.DataType = ACPI_DESC_TYPE_STATE_RPSCOPE; - Scope->ParseScope.Op = RootOp; - Scope->ParseScope.ArgCount = ACPI_VAR_ARGS; - Scope->ParseScope.ArgEnd = ParserState->AmlEnd; - Scope->ParseScope.PkgEnd = ParserState->AmlEnd; + Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE; + Scope->ParseScope.Op = RootOp; + Scope->ParseScope.ArgCount = ACPI_VAR_ARGS; + Scope->ParseScope.ArgEnd = ParserState->AmlEnd; + Scope->ParseScope.PkgEnd = ParserState->AmlEnd; - ParserState->Scope = Scope; - ParserState->StartOp = RootOp; + ParserState->Scope = Scope; + ParserState->StartOp = RootOp; return_ACPI_STATUS (AE_OK); } @@ -239,7 +236,7 @@ AcpiPsPushScope ( ACPI_GENERIC_STATE *Scope; - ACPI_FUNCTION_TRACE_PTR ("PsPushScope", Op); + ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op); Scope = AcpiUtCreateGenericState (); @@ -248,11 +245,11 @@ AcpiPsPushScope ( return_ACPI_STATUS (AE_NO_MEMORY); } - Scope->Common.DataType = ACPI_DESC_TYPE_STATE_PSCOPE; - Scope->ParseScope.Op = Op; - Scope->ParseScope.ArgList = RemainingArgs; + Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE; + Scope->ParseScope.Op = Op; + Scope->ParseScope.ArgList = RemainingArgs; Scope->ParseScope.ArgCount = ArgCount; - Scope->ParseScope.PkgEnd = ParserState->PkgEnd; + Scope->ParseScope.PkgEnd = ParserState->PkgEnd; /* Push onto scope stack */ @@ -301,7 +298,7 @@ AcpiPsPopScope ( ACPI_GENERIC_STATE *Scope = ParserState->Scope; - ACPI_FUNCTION_TRACE ("PsPopScope"); + ACPI_FUNCTION_TRACE (PsPopScope); /* Only pop the scope if there is in fact a next scope */ @@ -310,7 +307,7 @@ AcpiPsPopScope ( { Scope = AcpiUtPopGenericState (&ParserState->Scope); - /* return to parsing previous op */ + /* Return to parsing previous op */ *Op = Scope->ParseScope.Op; *ArgList = Scope->ParseScope.ArgList; @@ -323,7 +320,7 @@ AcpiPsPopScope ( } else { - /* empty parse stack, prepare to fetch next opcode */ + /* Empty parse stack, prepare to fetch next opcode */ *Op = NULL; *ArgList = 0; @@ -356,7 +353,7 @@ AcpiPsCleanupScope ( ACPI_GENERIC_STATE *Scope; - ACPI_FUNCTION_TRACE_PTR ("PsCleanupScope", ParserState); + ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState); if (!ParserState) diff --git a/sys/dist/acpica/pstree.c b/sys/dist/acpica/pstree.c index 53eca098e87..decb2bb9b80 100644 --- a/sys/dist/acpica/pstree.c +++ b/sys/dist/acpica/pstree.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: pstree - Parser op tree manipulation/traversal/search - * xRevision: 1.49 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pstree.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __PSTREE_C__ -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("pstree") @@ -270,6 +267,8 @@ AcpiPsAppendArg ( { Arg->Common.Parent = Op; Arg = Arg->Common.Next; + + Op->Common.ArgListLength++; } } diff --git a/sys/dist/acpica/psutils.c b/sys/dist/acpica/psutils.c index ec4267480f6..5388935fde3 100644 --- a/sys/dist/acpica/psutils.c +++ b/sys/dist/acpica/psutils.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psutils - Parser miscellaneous utilities (Parser only) - * xRevision: 1.67 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,9 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psutils.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psutils") @@ -177,7 +174,7 @@ AcpiPsInitOp ( ACPI_FUNCTION_ENTRY (); - Op->Common.DataType = ACPI_DESC_TYPE_PARSER; + Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER; Op->Common.AmlOpcode = Opcode; ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName, @@ -273,7 +270,7 @@ void AcpiPsFreeOp ( ACPI_PARSE_OBJECT *Op) { - ACPI_FUNCTION_NAME ("PsFreeOp"); + ACPI_FUNCTION_NAME (PsFreeOp); if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) diff --git a/sys/dist/acpica/pswalk.c b/sys/dist/acpica/pswalk.c index 3576f362f5e..aae43244f7e 100644 --- a/sys/dist/acpica/pswalk.c +++ b/sys/dist/acpica/pswalk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: pswalk - Parser routines to walk parsed op tree(s) - * xRevision: 1.76 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,11 +115,8 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pswalk.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#include "acpi.h" -#include "acparser.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("pswalk") @@ -146,7 +143,7 @@ AcpiPsDeleteParseTree ( ACPI_PARSE_OBJECT *Parent = NULL; - ACPI_FUNCTION_TRACE_PTR ("PsDeleteParseTree", SubtreeRoot); + ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot); /* Visit all nodes in the subtree */ diff --git a/sys/dist/acpica/psxface.c b/sys/dist/acpica/psxface.c index 7efed5a63af..27639c70831 100644 --- a/sys/dist/acpica/psxface.c +++ b/sys/dist/acpica/psxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psxface - Parser external interfaces - * xRevision: 1.87 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,15 +114,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psxface.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __PSXFACE_C__ -#include "acpi.h" -#include "acparser.h" -#include "acdispat.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acparser.h> +#include <dist/acpica/acdispat.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_PARSER @@ -132,19 +129,15 @@ __KERNEL_RCSID(0, "$NetBSD: psxface.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); static void AcpiPsStartTrace ( - ACPI_PARAMETER_INFO *Info); + ACPI_EVALUATE_INFO *Info); static void AcpiPsStopTrace ( - ACPI_PARAMETER_INFO *Info); - -static ACPI_STATUS -AcpiPsExecutePass ( - ACPI_PARAMETER_INFO *Info); + ACPI_EVALUATE_INFO *Info); static void AcpiPsUpdateParameterList ( - ACPI_PARAMETER_INFO *Info, + ACPI_EVALUATE_INFO *Info, UINT16 Action); @@ -213,7 +206,7 @@ AcpiDebugTrace ( static void AcpiPsStartTrace ( - ACPI_PARAMETER_INFO *Info) + ACPI_EVALUATE_INFO *Info) { ACPI_STATUS Status; @@ -228,7 +221,7 @@ AcpiPsStartTrace ( } if ((!AcpiGbl_TraceMethodName) || - (AcpiGbl_TraceMethodName != Info->Node->Name.Integer)) + (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer)) { goto Exit; } @@ -268,7 +261,7 @@ Exit: static void AcpiPsStopTrace ( - ACPI_PARAMETER_INFO *Info) + ACPI_EVALUATE_INFO *Info) { ACPI_STATUS Status; @@ -283,7 +276,7 @@ AcpiPsStopTrace ( } if ((!AcpiGbl_TraceMethodName) || - (AcpiGbl_TraceMethodName != Info->Node->Name.Integer)) + (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer)) { goto Exit; } @@ -330,32 +323,33 @@ Exit: ACPI_STATUS AcpiPsExecuteMethod ( - ACPI_PARAMETER_INFO *Info) + ACPI_EVALUATE_INFO *Info) { ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; - ACPI_FUNCTION_TRACE ("PsExecuteMethod"); + ACPI_FUNCTION_TRACE (PsExecuteMethod); /* Validate the Info and method Node */ - if (!Info || !Info->Node) + if (!Info || !Info->ResolvedNode) { return_ACPI_STATUS (AE_NULL_ENTRY); } /* Init for new method, wait on concurrency semaphore */ - Status = AcpiDsBeginMethodExecution (Info->Node, Info->ObjDesc, NULL); + Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* - * The caller "owns" the parameters, so give each one an extra - * reference + * The caller "owns" the parameters, so give each one an extra reference */ AcpiPsUpdateParameterList (Info, REF_INCREMENT); @@ -364,32 +358,50 @@ AcpiPsExecuteMethod ( AcpiPsStartTrace (Info); /* - * 1) Perform the first pass parse of the method to enter any - * named objects that it creates into the namespace + * Execute the method. Performs parse simultaneously */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "**** Begin Method Parse **** Entry=%p obj=%p\n", - Info->Node, Info->ObjDesc)); + "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n", + Info->ResolvedNode->Name.Ascii, Info->ResolvedNode, Info->ObjDesc)); + + /* Create and init a Root Node */ - Info->PassNumber = 1; - Status = AcpiPsExecutePass (Info); + Op = AcpiPsCreateScopeOp (); + if (!Op) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create and initialize a new walk state */ + + Info->PassNumber = ACPI_IMODE_EXECUTE; + WalkState = AcpiDsCreateWalkState ( + Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->ResolvedNode, + Info->ObjDesc->Method.AmlStart, + Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber); if (ACPI_FAILURE (Status)) { + AcpiDsDeleteWalkState (WalkState); goto Cleanup; } - /* - * 2) Execute the method. Performs second pass parse simultaneously - */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "**** Begin Method Execution **** Entry=%p obj=%p\n", - Info->Node, Info->ObjDesc)); + /* Parse the AML */ - Info->PassNumber = 3; - Status = AcpiPsExecutePass (Info); + Status = AcpiPsParseAml (WalkState); + /* WalkState was deleted by ParseAml */ Cleanup: + AcpiPsDeleteParseTree (Op); + /* End optional tracing */ AcpiPsStopTrace (Info); @@ -426,7 +438,7 @@ Cleanup: * * FUNCTION: AcpiPsUpdateParameterList * - * PARAMETERS: Info - See ACPI_PARAMETER_INFO + * PARAMETERS: Info - See ACPI_EVALUATE_INFO * (Used: ParameterType and Parameters) * Action - Add or Remove reference * @@ -438,7 +450,7 @@ Cleanup: static void AcpiPsUpdateParameterList ( - ACPI_PARAMETER_INFO *Info, + ACPI_EVALUATE_INFO *Info, UINT16 Action) { ACPI_NATIVE_UINT i; @@ -459,69 +471,3 @@ AcpiPsUpdateParameterList ( } -/******************************************************************************* - * - * FUNCTION: AcpiPsExecutePass - * - * PARAMETERS: Info - See ACPI_PARAMETER_INFO - * (Used: PassNumber, Node, and ObjDesc) - * - * RETURN: Status - * - * DESCRIPTION: Single AML pass: Parse or Execute a control method - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiPsExecutePass ( - ACPI_PARAMETER_INFO *Info) -{ - ACPI_STATUS Status; - ACPI_PARSE_OBJECT *Op; - ACPI_WALK_STATE *WalkState; - - - ACPI_FUNCTION_TRACE ("PsExecutePass"); - - - /* Create and init a Root Node */ - - Op = AcpiPsCreateScopeOp (); - if (!Op) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Create and initialize a new walk state */ - - WalkState = AcpiDsCreateWalkState ( - Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL); - if (!WalkState) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, - Info->ObjDesc->Method.AmlStart, - Info->ObjDesc->Method.AmlLength, - Info->PassNumber == 1 ? NULL : Info, - Info->PassNumber); - if (ACPI_FAILURE (Status)) - { - AcpiDsDeleteWalkState (WalkState); - goto Cleanup; - } - - /* Parse the AML */ - - Status = AcpiPsParseAml (WalkState); - - /* Walk state was deleted by ParseAml */ - -Cleanup: - AcpiPsDeleteParseTree (Op); - return_ACPI_STATUS (Status); -} - - diff --git a/sys/dist/acpica/rsaddr.c b/sys/dist/acpica/rsaddr.c index 042b014984f..075f86dfd9e 100644 --- a/sys/dist/acpica/rsaddr.c +++ b/sys/dist/acpica/rsaddr.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsaddr - Address resource descriptors (16/32/64) - * xRevision: 1.49 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsaddr.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSADDR_C__ -#include "acpi.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsaddr") diff --git a/sys/dist/acpica/rscalc.c b/sys/dist/acpica/rscalc.c index 76c3754fd7d..e62d8f1646c 100644 --- a/sys/dist/acpica/rscalc.c +++ b/sys/dist/acpica/rscalc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rscalc - Calculate stream and list lengths - * xRevision: 1.75 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,15 +114,12 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rscalc.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSCALC_C__ -#include "acpi.h" -#include "acresrc.h" -#include "amlcode.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rscalc") @@ -291,7 +288,7 @@ AcpiRsGetAmlLength ( ACPI_RS_LENGTH TotalSize; - ACPI_FUNCTION_TRACE ("RsGetAmlLength"); + ACPI_FUNCTION_TRACE (RsGetAmlLength); /* Traverse entire list of internal resource descriptors */ @@ -450,7 +447,7 @@ AcpiRsGetListLength ( UINT8 MinimumAmlResourceLength; - ACPI_FUNCTION_TRACE ("RsGetListLength"); + ACPI_FUNCTION_TRACE (RsGetListLength); *SizeNeeded = 0; @@ -540,7 +537,7 @@ AcpiRsGetListLength ( * included in the minimum descriptor size (reason for the -1) */ ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32); - + /* Add the size of the optional ResourceSource */ ExtraStructBytes += AcpiRsStreamOptionLength ( @@ -560,17 +557,17 @@ AcpiRsGetListLength ( */ BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] + ExtraStructBytes; - BufferSize = ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize); + BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize); *SizeNeeded += BufferSize; ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, - "Type %.2X, Aml %.2X internal %.2X\n", + "Type %.2X, AmlLength %.2X InternalLength %.2X\n", AcpiUtGetResourceType (AmlBuffer), AcpiUtGetDescriptorLength (AmlBuffer), BufferSize)); /* - * Point to the next resource within the AML stream using the length + * Point to the next resource within the AML stream using the length * contained in the resource descriptor header */ AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer); @@ -614,7 +611,7 @@ AcpiRsGetPciRoutingTableLength ( UINT32 TableIndex; - ACPI_FUNCTION_TRACE ("RsGetPciRoutingTableLength"); + ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength); NumberOfElements = PackageObject->Package.Count; diff --git a/sys/dist/acpica/rscreate.c b/sys/dist/acpica/rscreate.c index 5349ee69725..4f07434cab3 100644 --- a/sys/dist/acpica/rscreate.c +++ b/sys/dist/acpica/rscreate.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rscreate - Create resource lists/tables - * xRevision: 1.75 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,15 +115,12 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rscreate.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSCREATE_C__ -#include "acpi.h" -#include "acresrc.h" -#include "amlcode.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> +#include <dist/acpica/amlcode.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rscreate") @@ -157,9 +154,10 @@ AcpiRsCreateResourceList ( UINT8 *AmlStart; ACPI_SIZE ListSizeNeeded = 0; UINT32 AmlBufferLength; + void *Resource; - ACPI_FUNCTION_TRACE ("RsCreateResourceList"); + ACPI_FUNCTION_TRACE (RsCreateResourceList); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n", @@ -194,8 +192,9 @@ AcpiRsCreateResourceList ( /* Do the conversion */ - Status = AcpiRsConvertAmlToResources (AmlStart, AmlBufferLength, - OutputBuffer->Pointer); + Resource = OutputBuffer->Pointer; + Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength, + AcpiRsConvertAmlToResources, &Resource); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -246,7 +245,7 @@ AcpiRsCreatePciRoutingTable ( ACPI_BUFFER PathBuffer; - ACPI_FUNCTION_TRACE ("RsCreatePciRoutingTable"); + ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable); /* Params already validated, so we don't re-validate here */ @@ -481,7 +480,7 @@ AcpiRsCreateAmlResources ( ACPI_SIZE AmlSizeNeeded = 0; - ACPI_FUNCTION_TRACE ("RsCreateAmlResources"); + ACPI_FUNCTION_TRACE (RsCreateAmlResources); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", diff --git a/sys/dist/acpica/rsdump.c b/sys/dist/acpica/rsdump.c index 2958afbb843..01386b27d00 100644 --- a/sys/dist/acpica/rsdump.c +++ b/sys/dist/acpica/rsdump.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsdump - Functions to display the resource structures. - * xRevision: 1.60 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,10 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsdump.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSDUMP_C__ -#include "acpi.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsdump") @@ -206,9 +203,9 @@ AcpiRsDumpDescriptor ( ACPI_RSDUMP_INFO AcpiRsDumpIrq[6] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq), "IRQ", NULL}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering), "Triggering", AcpiGbl_HEDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity), "Polarity", AcpiGbl_LLDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable), "Sharing", AcpiGbl_SHRDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering), "Triggering", AcpiGbl_HeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity), "Polarity", AcpiGbl_LlDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable), "Sharing", AcpiGbl_ShrDecode}, {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.InterruptCount), "Interrupt Count", NULL}, {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]), "Interrupt List", NULL} }; @@ -216,9 +213,9 @@ ACPI_RSDUMP_INFO AcpiRsDumpIrq[6] = ACPI_RSDUMP_INFO AcpiRsDumpDma[6] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma), "DMA", NULL}, - {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type), "Speed", AcpiGbl_TYPDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster), "Mastering", AcpiGbl_BMDecode}, - {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer), "Transfer Type", AcpiGbl_SIZDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type), "Speed", AcpiGbl_TypDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster), "Mastering", AcpiGbl_BmDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer), "Transfer Type", AcpiGbl_SizDecode}, {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Dma.ChannelCount), "Channel Count", NULL}, {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]), "Channel List", NULL} }; @@ -267,7 +264,7 @@ ACPI_RSDUMP_INFO AcpiRsDumpEndTag[1] = ACPI_RSDUMP_INFO AcpiRsDumpMemory24[6] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24), "24-Bit Memory Range", NULL}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect), "Write Protect", AcpiGbl_RWDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Minimum), "Address Minimum", NULL}, {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Maximum), "Address Maximum", NULL}, {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Alignment), "Alignment", NULL}, @@ -277,7 +274,7 @@ ACPI_RSDUMP_INFO AcpiRsDumpMemory24[6] = ACPI_RSDUMP_INFO AcpiRsDumpMemory32[6] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32), "32-Bit Memory Range", NULL}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect), "Write Protect", AcpiGbl_RWDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Minimum), "Address Minimum", NULL}, {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Maximum), "Address Maximum", NULL}, {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Alignment), "Alignment", NULL}, @@ -287,7 +284,7 @@ ACPI_RSDUMP_INFO AcpiRsDumpMemory32[6] = ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[4] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32), "32-Bit Fixed Memory Range",NULL}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect), "Write Protect", AcpiGbl_RWDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.Address), "Address", NULL}, {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.AddressLength), "Address Length", NULL} }; @@ -344,9 +341,9 @@ ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[8] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq), "Extended IRQ", NULL}, {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer), "Type", AcpiGbl_ConsumeDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering), "Triggering", AcpiGbl_HEDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity), "Polarity", AcpiGbl_LLDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable), "Sharing", AcpiGbl_SHRDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering), "Triggering", AcpiGbl_HeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity), "Polarity", AcpiGbl_LlDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable), "Sharing", AcpiGbl_ShrDecode}, {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource), NULL, NULL}, {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount), "Interrupt Count", NULL}, {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]), "Interrupt List", NULL} @@ -370,7 +367,7 @@ static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] = { {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags), NULL, NULL}, {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer), "Consumer/Producer", AcpiGbl_ConsumeDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode), "Address Decode", AcpiGbl_DECDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode), "Address Decode", AcpiGbl_DecDecode}, {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed), "Min Relocatability", AcpiGbl_MinDecode}, {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed), "Max Relocatability", AcpiGbl_MaxDecode} }; @@ -378,18 +375,18 @@ static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] = static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] = { {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags), "Resource Type", __UNCONST("Memory Range")}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect), "Write Protect", AcpiGbl_RWDecode}, - {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching), "Caching", AcpiGbl_MEMDecode}, - {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType), "Range Type", AcpiGbl_MTPDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation), "Translation", AcpiGbl_TTPDecode} + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching), "Caching", AcpiGbl_MemDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType), "Range Type", AcpiGbl_MtpDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation), "Translation", AcpiGbl_TtpDecode} }; static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] = { {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags), "Resource Type", __UNCONST("I/O Range")}, - {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType), "Range Type", AcpiGbl_RNGDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation), "Translation", AcpiGbl_TTPDecode}, - {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType), "Translation Type", AcpiGbl_TRSDecode} + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType), "Range Type", AcpiGbl_RngDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation), "Translation", AcpiGbl_TtpDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType), "Translation Type", AcpiGbl_TrsDecode} }; @@ -426,7 +423,7 @@ AcpiRsDumpDescriptor ( UINT8 *Target = NULL; UINT8 *PreviousTarget; const char *Name; - UINT8 Count; + UINT8 Count; /* First table entry must contain the table length (# of table entries) */ diff --git a/sys/dist/acpica/rsinfo.c b/sys/dist/acpica/rsinfo.c index 3050eaec6a8..0ee9a948c50 100644 --- a/sys/dist/acpica/rsinfo.c +++ b/sys/dist/acpica/rsinfo.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsinfo - Dispatch and Info tables - * xRevision: 1.7 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsinfo.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSINFO_C__ -#include "acpi.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsinfo") diff --git a/sys/dist/acpica/rsio.c b/sys/dist/acpica/rsio.c index f16d6ee5344..c9222762a6f 100644 --- a/sys/dist/acpica/rsio.c +++ b/sys/dist/acpica/rsio.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsio - IO and DMA resource descriptors - * xRevision: 1.34 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsio.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSIO_C__ -#include "acpi.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsio") diff --git a/sys/dist/acpica/rsirq.c b/sys/dist/acpica/rsirq.c index 22b8529c892..03964d79976 100644 --- a/sys/dist/acpica/rsirq.c +++ b/sys/dist/acpica/rsirq.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsirq - IRQ resource descriptors - * xRevision: 1.49 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsirq.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSIRQ_C__ -#include "acpi.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsirq") diff --git a/sys/dist/acpica/rslist.c b/sys/dist/acpica/rslist.c index ba6bc16ec80..44d8bd1d7e3 100644 --- a/sys/dist/acpica/rslist.c +++ b/sys/dist/acpica/rslist.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rslist - Linked list utilities - * xRevision: 1.54 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rslist.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSLIST_C__ -#include "acpi.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rslist") @@ -130,93 +127,66 @@ __KERNEL_RCSID(0, "$NetBSD: rslist.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); * * FUNCTION: AcpiRsConvertAmlToResources * - * PARAMETERS: Aml - Pointer to the resource byte stream - * AmlLength - Length of Aml - * OutputBuffer - Pointer to the buffer that will - * contain the output structures + * PARAMETERS: ACPI_WALK_AML_CALLBACK + * ResourcePtr - Pointer to the buffer that will + * contain the output structures * * RETURN: Status * - * DESCRIPTION: Takes the resource byte stream and parses it, creating a - * linked list of resources in the caller's output buffer + * DESCRIPTION: Convert an AML resource to an internal representation of the + * resource that is aligned and easier to access. * ******************************************************************************/ ACPI_STATUS AcpiRsConvertAmlToResources ( UINT8 *Aml, - UINT32 AmlLength, - UINT8 *OutputBuffer) + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context) { - ACPI_RESOURCE *Resource = (void *) OutputBuffer; + ACPI_RESOURCE **ResourcePtr = ACPI_CAST_INDIRECT_PTR ( + ACPI_RESOURCE, Context); + ACPI_RESOURCE *Resource; ACPI_STATUS Status; - UINT8 ResourceIndex; - UINT8 *EndAml; - - - ACPI_FUNCTION_TRACE ("RsConvertAmlToResources"); - EndAml = Aml + AmlLength; + ACPI_FUNCTION_TRACE (RsConvertAmlToResources); - /* Loop until end-of-buffer or an EndTag is found */ - while (Aml < EndAml) + /* + * Check that the input buffer and all subsequent pointers into it + * are aligned on a native word boundary. Most important on IA64 + */ + Resource = *ResourcePtr; + if (ACPI_IS_MISALIGNED (Resource)) { - /* - * Check that the input buffer and all subsequent pointers into it - * are aligned on a native word boundary. Most important on IA64 - */ - if (ACPI_IS_MISALIGNED (Resource)) - { - ACPI_WARNING ((AE_INFO, - "Misaligned resource pointer %p", Resource)); - } - - /* Validate the Resource Type and Resource Length */ - - Status = AcpiUtValidateResource (Aml, &ResourceIndex); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Convert the AML byte stream resource to a local resource struct */ - - Status = AcpiRsConvertAmlToResource ( - Resource, ACPI_CAST_PTR (AML_RESOURCE, Aml), - AcpiGbl_GetResourceDispatch[ResourceIndex]); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not convert AML resource (Type %X)", *Aml)); - return_ACPI_STATUS (Status); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, - "Type %.2X, Aml %.2X internal %.2X\n", - AcpiUtGetResourceType (Aml), AcpiUtGetDescriptorLength (Aml), - Resource->Length)); - - /* Normal exit on completion of an EndTag resource descriptor */ - - if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) - { - return_ACPI_STATUS (AE_OK); - } - - /* Point to the next input AML resource */ - - Aml += AcpiUtGetDescriptorLength (Aml); + ACPI_WARNING ((AE_INFO, + "Misaligned resource pointer %p", Resource)); + } - /* Point to the next structure in the output buffer */ + /* Convert the AML byte stream resource to a local resource struct */ - Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + Status = AcpiRsConvertAmlToResource ( + Resource, ACPI_CAST_PTR (AML_RESOURCE, Aml), + AcpiGbl_GetResourceDispatch[ResourceIndex]); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not convert AML resource (Type %X)", *Aml)); + return_ACPI_STATUS (Status); } - /* Did not find an EndTag resource descriptor */ + ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, + "Type %.2X, AmlLength %.2X InternalLength %.2X\n", + AcpiUtGetResourceType (Aml), Length, + Resource->Length)); - return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + /* Point to the next structure in the output buffer */ + + *ResourcePtr = ACPI_ADD_PTR (void, Resource, Resource->Length); + return_ACPI_STATUS (AE_OK); } @@ -250,7 +220,7 @@ AcpiRsConvertResourcesToAml ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("RsConvertResourcesToAml"); + ACPI_FUNCTION_TRACE (RsConvertResourcesToAml); /* Walk the resource descriptor list, convert each descriptor */ diff --git a/sys/dist/acpica/rsmemory.c b/sys/dist/acpica/rsmemory.c index 5c388886c87..18977f690ea 100644 --- a/sys/dist/acpica/rsmemory.c +++ b/sys/dist/acpica/rsmemory.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsmem24 - Memory resource descriptors - * xRevision: 1.33 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsmemory.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSMEMORY_C__ -#include "acpi.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsmemory") diff --git a/sys/dist/acpica/rsmisc.c b/sys/dist/acpica/rsmisc.c index 3f3ec8dcd90..88aaa47f9b9 100644 --- a/sys/dist/acpica/rsmisc.c +++ b/sys/dist/acpica/rsmisc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsmisc - Miscellaneous resource descriptors - * xRevision: 1.44 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsmisc.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSMISC_C__ -#include "acpi.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsmisc") @@ -166,7 +163,7 @@ AcpiRsConvertAmlToResource ( UINT16 Temp16 = 0; - ACPI_FUNCTION_TRACE ("RsConvertAmlToResource"); + ACPI_FUNCTION_TRACE (RsConvertAmlToResource); if (((ACPI_NATIVE_UINT) Resource) & 0x3) @@ -437,7 +434,7 @@ AcpiRsConvertResourceToAml ( UINT16 ItemCount = 0; - ACPI_FUNCTION_TRACE ("RsConvertResourceToAml"); + ACPI_FUNCTION_TRACE (RsConvertResourceToAml); /* diff --git a/sys/dist/acpica/rsutils.c b/sys/dist/acpica/rsutils.c index 94ceaa1b1e3..4d50112299b 100644 --- a/sys/dist/acpica/rsutils.c +++ b/sys/dist/acpica/rsutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsutils - Utilities for the resource manager - * xRevision: 1.59 $ + * $Revision: 1.3 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsutils.c,v 1.2 2006/11/24 19:47:00 christos Exp $"); - #define __RSUTILS_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acresrc.h> #define _COMPONENT ACPI_RESOURCES @@ -253,7 +250,7 @@ AcpiRsMoveData ( /* * 16-, 32-, and 64-bit cases must use the move macros that perform - * endian conversion and/or accommodate hardware that cannot perform + * endian conversion and/or accomodate hardware that cannot perform * misaligned memory transfers */ case ACPI_RSC_MOVE16: @@ -477,9 +474,10 @@ AcpiRsGetResourceSource ( * * Zero the entire area of the buffer. */ - TotalLength = ACPI_STRLEN (ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; + TotalLength = (UINT32) ACPI_STRLEN ( + ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); - + ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); /* Copy the ResourceSource string to the destination */ @@ -565,7 +563,7 @@ AcpiRsSetResourceSource ( * * FUNCTION: AcpiRsGetPrtMethodData * - * PARAMETERS: Handle - Handle to the containing object + * PARAMETERS: Node - Device node * RetBuffer - Pointer to a buffer structure for the * results * @@ -581,21 +579,21 @@ AcpiRsSetResourceSource ( ACPI_STATUS AcpiRsGetPrtMethodData ( - ACPI_HANDLE Handle, + ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("RsGetPrtMethodData"); + ACPI_FUNCTION_TRACE (RsGetPrtMethodData); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ - Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__PRT, + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc); if (ACPI_FAILURE (Status)) { @@ -619,7 +617,7 @@ AcpiRsGetPrtMethodData ( * * FUNCTION: AcpiRsGetCrsMethodData * - * PARAMETERS: Handle - Handle to the containing object + * PARAMETERS: Node - Device node * RetBuffer - Pointer to a buffer structure for the * results * @@ -635,21 +633,21 @@ AcpiRsGetPrtMethodData ( ACPI_STATUS AcpiRsGetCrsMethodData ( - ACPI_HANDLE Handle, + ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("RsGetCrsMethodData"); + ACPI_FUNCTION_TRACE (RsGetCrsMethodData); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ - Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__CRS, + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { @@ -674,7 +672,7 @@ AcpiRsGetCrsMethodData ( * * FUNCTION: AcpiRsGetPrsMethodData * - * PARAMETERS: Handle - Handle to the containing object + * PARAMETERS: Node - Device node * RetBuffer - Pointer to a buffer structure for the * results * @@ -690,21 +688,21 @@ AcpiRsGetCrsMethodData ( ACPI_STATUS AcpiRsGetPrsMethodData ( - ACPI_HANDLE Handle, + ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *RetBuffer) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("RsGetPrsMethodData"); + ACPI_FUNCTION_TRACE (RsGetPrsMethodData); /* Parameters guaranteed valid by caller */ /* Execute the method, no parameters */ - Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__PRS, + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { @@ -754,7 +752,7 @@ AcpiRsGetMethodData ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("RsGetMethodData"); + ACPI_FUNCTION_TRACE (RsGetMethodData); /* Parameters guaranteed valid by caller */ @@ -762,7 +760,8 @@ AcpiRsGetMethodData ( /* Execute the method, no parameters */ Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc); - if (ACPI_FAILURE (Status)) { + if (ACPI_FAILURE (Status)) + { return_ACPI_STATUS (Status); } @@ -784,7 +783,7 @@ AcpiRsGetMethodData ( * * FUNCTION: AcpiRsSetSrsMethodData * - * PARAMETERS: Handle - Handle to the containing object + * PARAMETERS: Node - Device node * InBuffer - Pointer to a buffer structure of the * parameter * @@ -796,27 +795,41 @@ AcpiRsGetMethodData ( * If the function fails an appropriate status will be returned * and the contents of the callers buffer is undefined. * + * Note: Parameters guaranteed valid by caller + * ******************************************************************************/ ACPI_STATUS AcpiRsSetSrsMethodData ( - ACPI_HANDLE Handle, + ACPI_NAMESPACE_NODE *Node, ACPI_BUFFER *InBuffer) { - ACPI_PARAMETER_INFO Info; - ACPI_OPERAND_OBJECT *Params[2]; + ACPI_EVALUATE_INFO *Info; + ACPI_OPERAND_OBJECT *Args[2]; ACPI_STATUS Status; ACPI_BUFFER Buffer; - ACPI_FUNCTION_TRACE ("RsSetSrsMethodData"); + ACPI_FUNCTION_TRACE (RsSetSrsMethodData); - /* Parameters guaranteed valid by caller */ + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = Node; + Info->Pathname = METHOD_NAME__SRS; + Info->Parameters = Args; + Info->ParameterType = ACPI_PARAM_ARGS; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; /* * The InBuffer parameter will point to a linked list of - * resource parameters. It needs to be formatted into a + * resource parameters. It needs to be formatted into a * byte stream to be sent in as an input parameter to _SRS * * Convert the linked list into a byte stream @@ -825,45 +838,38 @@ AcpiRsSetSrsMethodData ( Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Cleanup; } - /* Init the param object */ + /* Create and initialize the method parameter object */ - Params[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); - if (!Params[0]) + Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!Args[0]) { - AcpiOsFree (Buffer.Pointer); - return_ACPI_STATUS (AE_NO_MEMORY); + /* + * Must free the buffer allocated above (otherwise it is freed + * later) + */ + ACPI_FREE (Buffer.Pointer); + Status = AE_NO_MEMORY; + goto Cleanup; } - /* Set up the parameter object */ - - Params[0]->Buffer.Length = (UINT32) Buffer.Length; - Params[0]->Buffer.Pointer = Buffer.Pointer; - Params[0]->Common.Flags = AOPOBJ_DATA_VALID; - Params[1] = NULL; + Args[0]->Buffer.Length = (UINT32) Buffer.Length; + Args[0]->Buffer.Pointer = Buffer.Pointer; + Args[0]->Common.Flags = AOPOBJ_DATA_VALID; + Args[1] = NULL; - Info.Node = Handle; - Info.Parameters = Params; - Info.ParameterType = ACPI_PARAM_ARGS; + /* Execute the method, no return value is expected */ - /* Execute the method, no return value */ - - Status = AcpiNsEvaluateRelative (METHOD_NAME__SRS, &Info); - if (ACPI_SUCCESS (Status)) - { - /* Delete any return object (especially if ImplicitReturn is enabled) */ + Status = AcpiNsEvaluate (Info); - if (Info.ReturnObject) - { - AcpiUtRemoveReference (Info.ReturnObject); - } - } + /* Clean up and return the status from AcpiNsEvaluate */ - /* Clean up and return the status from AcpiNsEvaluateRelative */ + AcpiUtRemoveReference (Args[0]); - AcpiUtRemoveReference (Params[0]); +Cleanup: + ACPI_FREE (Info); return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/rsxface.c b/sys/dist/acpica/rsxface.c index 8664e89f815..5a1f9bd53d1 100644 --- a/sys/dist/acpica/rsxface.c +++ b/sys/dist/acpica/rsxface.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsxface - Public interfaces to the resource manager - * xRevision: 1.40 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,11 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsxface.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __RSXFACE_C__ -#include "acpi.h" -#include "acresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acresrc.h> +#include <dist/acpica/acnamesp.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsxface") @@ -151,289 +149,240 @@ AcpiRsMatchVendorResource ( ACPI_RESOURCE *Resource, void *Context); +static ACPI_STATUS +AcpiRsValidateParameters ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *Buffer, + ACPI_NAMESPACE_NODE **ReturnNode); + /******************************************************************************* * - * FUNCTION: AcpiGetIrqRoutingTable + * FUNCTION: AcpiRsValidateParameters * - * PARAMETERS: DeviceHandle - a handle to the Bus device we are querying - * RetBuffer - a pointer to a buffer to receive the - * current resources for the device + * PARAMETERS: DeviceHandle - Handle to a device + * Buffer - Pointer to a data buffer + * ReturnNode - Pointer to where the device node is returned * * RETURN: Status * - * DESCRIPTION: This function is called to get the IRQ routing table for a - * specific bus. The caller must first acquire a handle for the - * desired bus. The routine table is placed in the buffer pointed - * to by the RetBuffer variable parameter. - * - * If the function fails an appropriate status will be returned - * and the value of RetBuffer is undefined. - * - * This function attempts to execute the _PRT method contained in - * the object indicated by the passed DeviceHandle. + * DESCRIPTION: Common parameter validation for resource interfaces * ******************************************************************************/ -ACPI_STATUS -AcpiGetIrqRoutingTable ( +static ACPI_STATUS +AcpiRsValidateParameters ( ACPI_HANDLE DeviceHandle, - ACPI_BUFFER *RetBuffer) + ACPI_BUFFER *Buffer, + ACPI_NAMESPACE_NODE **ReturnNode) { ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; - ACPI_FUNCTION_TRACE ("AcpiGetIrqRoutingTable "); + ACPI_FUNCTION_TRACE (RsValidateParameters); /* - * Must have a valid handle and buffer, So we have to have a handle - * and a return buffer structure, and if there is a non-zero buffer length - * we also need a valid pointer in the buffer. If it's a zero buffer length, - * we'll be returning the needed buffer size, so keep going. + * Must have a valid handle to an ACPI device */ if (!DeviceHandle) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - Status = AcpiUtValidateBuffer (RetBuffer); + Node = AcpiNsMapHandleToNode (DeviceHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (Node->Type != ACPI_TYPE_DEVICE) + { + return_ACPI_STATUS (AE_TYPE); + } + + /* + * Validate the user buffer object + * + * if there is a non-zero buffer length we also need a valid pointer in + * the buffer. If it's a zero buffer length, we'll be returning the + * needed buffer size (later), so keep going. + */ + Status = AcpiUtValidateBuffer (Buffer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiRsGetPrtMethodData (DeviceHandle, RetBuffer); - return_ACPI_STATUS (Status); + *ReturnNode = Node; + return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiGetCurrentResources + * FUNCTION: AcpiGetIrqRoutingTable * - * PARAMETERS: DeviceHandle - a handle to the device object for the - * device we are querying - * RetBuffer - a pointer to a buffer to receive the + * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying + * RetBuffer - Pointer to a buffer to receive the * current resources for the device * * RETURN: Status * - * DESCRIPTION: This function is called to get the current resources for a - * specific device. The caller must first acquire a handle for - * the desired device. The resource data is placed in the buffer - * pointed to by the RetBuffer variable parameter. + * DESCRIPTION: This function is called to get the IRQ routing table for a + * specific bus. The caller must first acquire a handle for the + * desired bus. The routine table is placed in the buffer pointed + * to by the RetBuffer variable parameter. * * If the function fails an appropriate status will be returned * and the value of RetBuffer is undefined. * - * This function attempts to execute the _CRS method contained in + * This function attempts to execute the _PRT method contained in * the object indicated by the passed DeviceHandle. * ******************************************************************************/ ACPI_STATUS -AcpiGetCurrentResources ( +AcpiGetIrqRoutingTable ( ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer) { ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; - ACPI_FUNCTION_TRACE ("AcpiGetCurrentResources"); + ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable); - /* - * Must have a valid handle and buffer, So we have to have a handle - * and a return buffer structure, and if there is a non-zero buffer length - * we also need a valid pointer in the buffer. If it's a zero buffer length, - * we'll be returning the needed buffer size, so keep going. - */ - if (!DeviceHandle) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } + /* Validate parameters then dispatch to internal routine */ - Status = AcpiUtValidateBuffer (RetBuffer); + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiRsGetCrsMethodData (DeviceHandle, RetBuffer); + Status = AcpiRsGetPrtMethodData (Node, RetBuffer); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable) + /******************************************************************************* * - * FUNCTION: AcpiGetPossibleResources + * FUNCTION: AcpiGetCurrentResources * - * PARAMETERS: DeviceHandle - a handle to the device object for the + * PARAMETERS: DeviceHandle - Handle to the device object for the * device we are querying - * RetBuffer - a pointer to a buffer to receive the - * resources for the device + * RetBuffer - Pointer to a buffer to receive the + * current resources for the device * * RETURN: Status * - * DESCRIPTION: This function is called to get a list of the possible resources - * for a specific device. The caller must first acquire a handle - * for the desired device. The resource data is placed in the - * buffer pointed to by the RetBuffer variable. + * DESCRIPTION: This function is called to get the current resources for a + * specific device. The caller must first acquire a handle for + * the desired device. The resource data is placed in the buffer + * pointed to by the RetBuffer variable parameter. * * If the function fails an appropriate status will be returned * and the value of RetBuffer is undefined. * + * This function attempts to execute the _CRS method contained in + * the object indicated by the passed DeviceHandle. + * ******************************************************************************/ ACPI_STATUS -AcpiGetPossibleResources ( +AcpiGetCurrentResources ( ACPI_HANDLE DeviceHandle, ACPI_BUFFER *RetBuffer) { ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; - ACPI_FUNCTION_TRACE ("AcpiGetPossibleResources"); + ACPI_FUNCTION_TRACE (AcpiGetCurrentResources); - /* - * Must have a valid handle and buffer, So we have to have a handle - * and a return buffer structure, and if there is a non-zero buffer length - * we also need a valid pointer in the buffer. If it's a zero buffer length, - * we'll be returning the needed buffer size, so keep going. - */ - if (!DeviceHandle) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } + /* Validate parameters then dispatch to internal routine */ - Status = AcpiUtValidateBuffer (RetBuffer); + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiRsGetPrsMethodData (DeviceHandle, RetBuffer); + Status = AcpiRsGetCrsMethodData (Node, RetBuffer); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources) + /******************************************************************************* * - * FUNCTION: AcpiWalkResources + * FUNCTION: AcpiGetPossibleResources * * PARAMETERS: DeviceHandle - Handle to the device object for the * device we are querying - * Name - Method name of the resources we want - * (METHOD_NAME__CRS or METHOD_NAME__PRS) - * UserFunction - Called for each resource - * Context - Passed to UserFunction + * RetBuffer - Pointer to a buffer to receive the + * resources for the device * * RETURN: Status * - * DESCRIPTION: Retrieves the current or possible resource list for the - * specified device. The UserFunction is called once for - * each resource in the list. + * DESCRIPTION: This function is called to get a list of the possible resources + * for a specific device. The caller must first acquire a handle + * for the desired device. The resource data is placed in the + * buffer pointed to by the RetBuffer variable. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. * ******************************************************************************/ ACPI_STATUS -AcpiWalkResources ( - ACPI_HANDLE DeviceHandle, - const char *Name, - ACPI_WALK_RESOURCE_CALLBACK UserFunction, - void *Context) +AcpiGetPossibleResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) { - ACPI_STATUS Status; - ACPI_BUFFER Buffer; - ACPI_RESOURCE *Resource; - ACPI_RESOURCE *ResourceEnd; - - - ACPI_FUNCTION_TRACE ("AcpiWalkResources"); + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; - /* Parameter validation */ + ACPI_FUNCTION_TRACE (AcpiGetPossibleResources); - if (!DeviceHandle || !UserFunction || !Name || - (ACPI_STRNCMP (Name, METHOD_NAME__CRS, sizeof (METHOD_NAME__CRS)) && - ACPI_STRNCMP (Name, METHOD_NAME__PRS, sizeof (METHOD_NAME__PRS)))) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - /* Get the _CRS or _PRS resource list */ + /* Validate parameters then dispatch to internal routine */ - Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer); + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* Buffer now contains the resource list */ - - Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer); - ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length); - - /* Walk the resource list until the EndTag is found (or buffer end) */ - - while (Resource < ResourceEnd) - { - /* Sanity check the resource */ - - if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) - { - Status = AE_AML_INVALID_RESOURCE_TYPE; - break; - } - - /* Invoke the user function, abort on any error returned */ - - Status = UserFunction (Resource, Context); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_CTRL_TERMINATE) - { - /* This is an OK termination by the user function */ - - Status = AE_OK; - } - break; - } - - /* EndTag indicates end-of-list */ - - if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) - { - break; - } - - /* Get the next resource descriptor */ - - Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); - } - - ACPI_MEM_FREE (Buffer.Pointer); + Status = AcpiRsGetPrsMethodData (Node, RetBuffer); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources) + /******************************************************************************* * * FUNCTION: AcpiSetCurrentResources * - * PARAMETERS: DeviceHandle - a handle to the device object for the - * device we are changing the resources of - * InBuffer - a pointer to a buffer containing the + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are setting resources + * InBuffer - Pointer to a buffer containing the * resources to be set for the device * * RETURN: Status * * DESCRIPTION: This function is called to set the current resources for a - * specific device. The caller must first acquire a handle for - * the desired device. The resource data is passed to the routine + * specific device. The caller must first acquire a handle for + * the desired device. The resource data is passed to the routine * the buffer pointed to by the InBuffer variable. * ******************************************************************************/ @@ -444,39 +393,48 @@ AcpiSetCurrentResources ( ACPI_BUFFER *InBuffer) { ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; - ACPI_FUNCTION_TRACE ("AcpiSetCurrentResources"); + ACPI_FUNCTION_TRACE (AcpiSetCurrentResources); - /* Must have a valid handle and buffer */ + /* Validate the buffer, don't allow zero length */ - if ((!DeviceHandle) || - (!InBuffer) || - (!InBuffer->Pointer) || + if ((!InBuffer) || + (!InBuffer->Pointer) || (!InBuffer->Length)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - Status = AcpiRsSetSrsMethodData (DeviceHandle, InBuffer); + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsSetSrsMethodData (Node, InBuffer); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources) + /****************************************************************************** * * FUNCTION: AcpiResourceToAddress64 * - * PARAMETERS: Resource - Pointer to a resource - * Out - Pointer to the users's return - * buffer (a struct - * acpi_resource_address64) + * PARAMETERS: Resource - Pointer to a resource + * Out - Pointer to the users's return buffer + * (a struct acpi_resource_address64) * * RETURN: Status * * DESCRIPTION: If the resource is an address16, address32, or address64, - * copy it to the address64 return buffer. This saves the + * copy it to the address64 return buffer. This saves the * caller from having to duplicate code for different-sized * addresses. * @@ -526,17 +484,19 @@ AcpiResourceToAddress64 ( return (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64) + /******************************************************************************* * * FUNCTION: AcpiGetVendorResource * - * PARAMETERS: DeviceHandle - Handle for the parent device object - * Name - Method name for the parent resource - * (METHOD_NAME__CRS or METHOD_NAME__PRS) - * Uuid - Pointer to the UUID to be matched. - * includes both subtype and 16-byte UUID - * RetBuffer - Where the vendor resource is returned + * PARAMETERS: DeviceHandle - Handle for the parent device object + * Name - Method name for the parent resource + * (METHOD_NAME__CRS or METHOD_NAME__PRS) + * Uuid - Pointer to the UUID to be matched. + * includes both subtype and 16-byte UUID + * RetBuffer - Where the vendor resource is returned * * RETURN: Status * @@ -580,6 +540,8 @@ AcpiGetVendorResource ( return (Info.Status); } +ACPI_EXPORT_SYMBOL (AcpiGetVendorResource) + /******************************************************************************* * @@ -647,3 +609,105 @@ AcpiRsMatchVendorResource ( return (AE_CTRL_TERMINATE); } + +/******************************************************************************* + * + * FUNCTION: AcpiWalkResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * Name - Method name of the resources we want + * (METHOD_NAME__CRS or METHOD_NAME__PRS) + * UserFunction - Called for each resource + * Context - Passed to UserFunction + * + * RETURN: Status + * + * DESCRIPTION: Retrieves the current or possible resource list for the + * specified device. The UserFunction is called once for + * each resource in the list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWalkResources ( + ACPI_HANDLE DeviceHandle, + const char *Name, + ACPI_WALK_RESOURCE_CALLBACK UserFunction, + void *Context) +{ + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + ACPI_RESOURCE *Resource; + ACPI_RESOURCE *ResourceEnd; + + + ACPI_FUNCTION_TRACE (AcpiWalkResources); + + + /* Parameter validation */ + + if (!DeviceHandle || !UserFunction || !Name || + (ACPI_STRNCMP (Name, METHOD_NAME__CRS, 4) && + ACPI_STRNCMP (Name, METHOD_NAME__PRS, 4))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the _CRS or _PRS resource list */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Buffer now contains the resource list */ + + Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer); + ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length); + + /* Walk the resource list until the EndTag is found (or buffer end) */ + + while (Resource < ResourceEnd) + { + /* Sanity check the resource */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + Status = AE_AML_INVALID_RESOURCE_TYPE; + break; + } + + /* Invoke the user function, abort on any error returned */ + + Status = UserFunction (Resource, Context); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_TERMINATE) + { + /* This is an OK termination by the user function */ + + Status = AE_OK; + } + break; + } + + /* EndTag indicates end-of-list */ + + if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) + { + break; + } + + /* Get the next resource descriptor */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + ACPI_FREE (Buffer.Pointer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWalkResources) diff --git a/sys/dist/acpica/tbconvrt.c b/sys/dist/acpica/tbconvrt.c index d7c9e518009..e69de29bb2d 100644 --- a/sys/dist/acpica/tbconvrt.c +++ b/sys/dist/acpica/tbconvrt.c @@ -1,710 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbconvrt - ACPI Table conversion utilities - * xRevision: 1.67 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbconvrt.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - -#define __TBCONVRT_C__ - -#include "acpi.h" -#include "actables.h" - - -#define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbconvrt") - -/* Local prototypes */ - -static void -AcpiTbInitGenericAddress ( - ACPI_GENERIC_ADDRESS *NewGasStruct, - UINT8 RegisterBitWidth, - ACPI_PHYSICAL_ADDRESS Address); - -static void -AcpiTbConvertFadt1 ( - FADT_DESCRIPTOR_REV2 *LocalFadt, - FADT_DESCRIPTOR_REV1 *OriginalFadt); - -static void -AcpiTbConvertFadt2 ( - FADT_DESCRIPTOR_REV2 *LocalFadt, - FADT_DESCRIPTOR_REV2 *OriginalFadt); - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetTableCount - * - * PARAMETERS: RSDP - Pointer to the RSDP - * RSDT - Pointer to the RSDT/XSDT - * - * RETURN: The number of tables pointed to by the RSDT or XSDT. - * - * DESCRIPTION: Calculate the number of tables. Automatically handles either - * an RSDT or XSDT. - * - ******************************************************************************/ - -UINT32 -AcpiTbGetTableCount ( - RSDP_DESCRIPTOR *RSDP, - ACPI_TABLE_HEADER *RSDT) -{ - UINT32 PointerSize; - - - ACPI_FUNCTION_ENTRY (); - - - /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ - - if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) - { - PointerSize = sizeof (UINT32); - } - else - { - PointerSize = sizeof (UINT64); - } - - /* - * Determine the number of tables pointed to by the RSDT/XSDT. - * This is defined by the ACPI Specification to be the number of - * pointers contained within the RSDT/XSDT. The size of the pointers - * is architecture-dependent. - */ - return ((RSDT->Length - sizeof (ACPI_TABLE_HEADER)) / PointerSize); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbConvertToXsdt - * - * PARAMETERS: TableInfo - Info about the RSDT - * - * RETURN: Status - * - * DESCRIPTION: Convert an RSDT to an XSDT (internal common format) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbConvertToXsdt ( - ACPI_TABLE_DESC *TableInfo) -{ - ACPI_SIZE TableSize; - UINT32 i; - XSDT_DESCRIPTOR *NewTable; - - - ACPI_FUNCTION_ENTRY (); - - - /* Compute size of the converted XSDT */ - - TableSize = ((ACPI_SIZE) AcpiGbl_RsdtTableCount * sizeof (UINT64)) + - sizeof (ACPI_TABLE_HEADER); - - /* Allocate an XSDT */ - - NewTable = ACPI_MEM_CALLOCATE (TableSize); - if (!NewTable) - { - return (AE_NO_MEMORY); - } - - /* Copy the header and set the length */ - - ACPI_MEMCPY (NewTable, TableInfo->Pointer, sizeof (ACPI_TABLE_HEADER)); - NewTable->Length = (UINT32) TableSize; - - /* Copy the table pointers */ - - for (i = 0; i < AcpiGbl_RsdtTableCount; i++) - { - /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ - - if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) - { - ACPI_STORE_ADDRESS (NewTable->TableOffsetEntry[i], - (ACPI_CAST_PTR (RSDT_DESCRIPTOR_REV1, - TableInfo->Pointer))->TableOffsetEntry[i]); - } - else - { - NewTable->TableOffsetEntry[i] = - (ACPI_CAST_PTR (XSDT_DESCRIPTOR, - TableInfo->Pointer))->TableOffsetEntry[i]; - } - } - - /* Delete the original table (either mapped or in a buffer) */ - - AcpiTbDeleteSingleTable (TableInfo); - - /* Point the table descriptor to the new table */ - - TableInfo->Pointer = ACPI_CAST_PTR (ACPI_TABLE_HEADER, NewTable); - TableInfo->Length = TableSize; - TableInfo->Allocation = ACPI_MEM_ALLOCATED; - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbInitGenericAddress - * - * PARAMETERS: NewGasStruct - GAS struct to be initialized - * RegisterBitWidth - Width of this register - * Address - Address of the register - * - * RETURN: None - * - * DESCRIPTION: Initialize a GAS structure. - * - ******************************************************************************/ - -static void -AcpiTbInitGenericAddress ( - ACPI_GENERIC_ADDRESS *NewGasStruct, - UINT8 RegisterBitWidth, - ACPI_PHYSICAL_ADDRESS Address) -{ - - ACPI_STORE_ADDRESS (NewGasStruct->Address, Address); - - NewGasStruct->AddressSpaceId = ACPI_ADR_SPACE_SYSTEM_IO; - NewGasStruct->RegisterBitWidth = RegisterBitWidth; - NewGasStruct->RegisterBitOffset = 0; - NewGasStruct->AccessWidth = 0; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbConvertFadt1 - * - * PARAMETERS: LocalFadt - Pointer to new FADT - * OriginalFadt - Pointer to old FADT - * - * RETURN: None, populates LocalFadt - * - * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format - * - ******************************************************************************/ - -static void -AcpiTbConvertFadt1 ( - FADT_DESCRIPTOR_REV2 *LocalFadt, - FADT_DESCRIPTOR_REV1 *OriginalFadt) -{ - - /* ACPI 1.0 FACS */ - /* The BIOS stored FADT should agree with Revision 1.0 */ - - /* - * Copy the table header and the common part of the tables. - * - * The 2.0 table is an extension of the 1.0 table, so the entire 1.0 - * table can be copied first, then expand some fields to 64 bits. - */ - ACPI_MEMCPY (LocalFadt, OriginalFadt, sizeof (FADT_DESCRIPTOR_REV1)); - - /* Convert table pointers to 64-bit fields */ - - ACPI_STORE_ADDRESS (LocalFadt->XFirmwareCtrl, LocalFadt->V1_FirmwareCtrl); - ACPI_STORE_ADDRESS (LocalFadt->XDsdt, LocalFadt->V1_Dsdt); - - /* - * System Interrupt Model isn't used in ACPI 2.0 - * (LocalFadt->Reserved1 = 0;) - */ - - /* - * This field is set by the OEM to convey the preferred power management - * profile to OSPM. It doesn't have any 1.0 equivalence. Since we don't - * know what kind of 32-bit system this is, we will use "unspecified". - */ - LocalFadt->Prefer_PM_Profile = PM_UNSPECIFIED; - - /* - * Processor Performance State Control. This is the value OSPM writes to - * the SMI_CMD register to assume processor performance state control - * responsibility. There isn't any equivalence in 1.0, leave it zeroed. - */ - LocalFadt->PstateCnt = 0; - - /* - * Support for the _CST object and C States change notification. - * This data item hasn't any 1.0 equivalence so leave it zero. - */ - LocalFadt->CstCnt = 0; - - /* - * FADT Rev 2 was an interim FADT released between ACPI 1.0 and ACPI 2.0. - * It primarily adds the FADT reset mechanism. - */ - if ((OriginalFadt->Revision == 2) && - (OriginalFadt->Length == sizeof (FADT_DESCRIPTOR_REV2_MINUS))) - { - /* - * Grab the entire generic address struct, plus the 1-byte reset value - * that immediately follows. - */ - ACPI_MEMCPY (&LocalFadt->ResetRegister, - &(ACPI_CAST_PTR (FADT_DESCRIPTOR_REV2_MINUS, - OriginalFadt))->ResetRegister, - sizeof (ACPI_GENERIC_ADDRESS) + 1); - } - else - { - /* - * Since there isn't any equivalence in 1.0 and since it is highly - * likely that a 1.0 system has legacy support. - */ - LocalFadt->IapcBootArch = BAF_LEGACY_DEVICES; - } - - /* - * Convert the V1.0 block addresses to V2.0 GAS structures - */ - AcpiTbInitGenericAddress (&LocalFadt->XPm1aEvtBlk, LocalFadt->Pm1EvtLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aEvtBlk); - AcpiTbInitGenericAddress (&LocalFadt->XPm1bEvtBlk, LocalFadt->Pm1EvtLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bEvtBlk); - AcpiTbInitGenericAddress (&LocalFadt->XPm1aCntBlk, LocalFadt->Pm1CntLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aCntBlk); - AcpiTbInitGenericAddress (&LocalFadt->XPm1bCntBlk, LocalFadt->Pm1CntLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bCntBlk); - AcpiTbInitGenericAddress (&LocalFadt->XPm2CntBlk, LocalFadt->Pm2CntLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm2CntBlk); - AcpiTbInitGenericAddress (&LocalFadt->XPmTmrBlk, LocalFadt->PmTmLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_PmTmrBlk); - AcpiTbInitGenericAddress (&LocalFadt->XGpe0Blk, 0, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Gpe0Blk); - AcpiTbInitGenericAddress (&LocalFadt->XGpe1Blk, 0, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Gpe1Blk); - - /* Create separate GAS structs for the PM1 Enable registers */ - - AcpiTbInitGenericAddress (&AcpiGbl_XPm1aEnable, - (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) - (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + - ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); - - /* PM1B is optional; leave null if not present */ - - if (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address)) - { - AcpiTbInitGenericAddress (&AcpiGbl_XPm1bEnable, - (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) - (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + - ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbConvertFadt2 - * - * PARAMETERS: LocalFadt - Pointer to new FADT - * OriginalFadt - Pointer to old FADT - * - * RETURN: None, populates LocalFadt - * - * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format. - * Handles optional "X" fields. - * - ******************************************************************************/ - -static void -AcpiTbConvertFadt2 ( - FADT_DESCRIPTOR_REV2 *LocalFadt, - FADT_DESCRIPTOR_REV2 *OriginalFadt) -{ - - /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ - - ACPI_MEMCPY (LocalFadt, OriginalFadt, sizeof (FADT_DESCRIPTOR_REV2)); - - /* - * "X" fields are optional extensions to the original V1.0 fields, so - * we must selectively expand V1.0 fields if the corresponding X field - * is zero. - */ - if (!(ACPI_GET_ADDRESS (LocalFadt->XFirmwareCtrl))) - { - ACPI_STORE_ADDRESS (LocalFadt->XFirmwareCtrl, - LocalFadt->V1_FirmwareCtrl); - } - - if (!(ACPI_GET_ADDRESS (LocalFadt->XDsdt))) - { - ACPI_STORE_ADDRESS (LocalFadt->XDsdt, LocalFadt->V1_Dsdt); - } - - if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address))) - { - AcpiTbInitGenericAddress (&LocalFadt->XPm1aEvtBlk, - LocalFadt->Pm1EvtLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aEvtBlk); - } - - if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address))) - { - AcpiTbInitGenericAddress (&LocalFadt->XPm1bEvtBlk, - LocalFadt->Pm1EvtLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bEvtBlk); - } - - if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1aCntBlk.Address))) - { - AcpiTbInitGenericAddress (&LocalFadt->XPm1aCntBlk, - LocalFadt->Pm1CntLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aCntBlk); - } - - if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1bCntBlk.Address))) - { - AcpiTbInitGenericAddress (&LocalFadt->XPm1bCntBlk, - LocalFadt->Pm1CntLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bCntBlk); - } - - if (!(ACPI_GET_ADDRESS (LocalFadt->XPm2CntBlk.Address))) - { - AcpiTbInitGenericAddress (&LocalFadt->XPm2CntBlk, - LocalFadt->Pm2CntLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm2CntBlk); - } - - if (!(ACPI_GET_ADDRESS (LocalFadt->XPmTmrBlk.Address))) - { - AcpiTbInitGenericAddress (&LocalFadt->XPmTmrBlk, - LocalFadt->PmTmLen, - (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_PmTmrBlk); - } - - if (!(ACPI_GET_ADDRESS (LocalFadt->XGpe0Blk.Address))) - { - AcpiTbInitGenericAddress (&LocalFadt->XGpe0Blk, - 0, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Gpe0Blk); - } - - if (!(ACPI_GET_ADDRESS (LocalFadt->XGpe1Blk.Address))) - { - AcpiTbInitGenericAddress (&LocalFadt->XGpe1Blk, - 0, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Gpe1Blk); - } - - /* Create separate GAS structs for the PM1 Enable registers */ - - AcpiTbInitGenericAddress (&AcpiGbl_XPm1aEnable, - (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) - (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + - ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); - - AcpiGbl_XPm1aEnable.AddressSpaceId = - LocalFadt->XPm1aEvtBlk.AddressSpaceId; - - /* PM1B is optional; leave null if not present */ - - if (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address)) - { - AcpiTbInitGenericAddress (&AcpiGbl_XPm1bEnable, - (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) - (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + - ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); - - AcpiGbl_XPm1bEnable.AddressSpaceId = - LocalFadt->XPm1bEvtBlk.AddressSpaceId; - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbConvertTableFadt - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Converts a BIOS supplied ACPI 1.0 FADT to a local - * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply - * copied to the local FADT. The ACPI CA software uses this - * local FADT. Thus a significant amount of special #ifdef - * type codeing is saved. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbConvertTableFadt ( - void) -{ - FADT_DESCRIPTOR_REV2 *LocalFadt; - ACPI_TABLE_DESC *TableDesc; - - - ACPI_FUNCTION_TRACE ("TbConvertTableFadt"); - - - /* - * AcpiGbl_FADT is valid. Validate the FADT length. The table must be - * at least as long as the version 1.0 FADT - */ - if (AcpiGbl_FADT->Length < sizeof (FADT_DESCRIPTOR_REV1)) - { - ACPI_ERROR ((AE_INFO, "FADT is invalid, too short: 0x%X", - AcpiGbl_FADT->Length)); - return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); - } - - /* Allocate buffer for the ACPI 2.0(+) FADT */ - - LocalFadt = ACPI_MEM_CALLOCATE (sizeof (FADT_DESCRIPTOR_REV2)); - if (!LocalFadt) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - if (AcpiGbl_FADT->Revision >= FADT2_REVISION_ID) - { - if (AcpiGbl_FADT->Length < sizeof (FADT_DESCRIPTOR_REV2)) - { - /* Length is too short to be a V2.0 table */ - - ACPI_WARNING ((AE_INFO, - "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table", - AcpiGbl_FADT->Length, AcpiGbl_FADT->Revision)); - - AcpiTbConvertFadt1 (LocalFadt, (void *) AcpiGbl_FADT); - } - else - { - /* Valid V2.0 table */ - - AcpiTbConvertFadt2 (LocalFadt, AcpiGbl_FADT); - } - } - else - { - /* Valid V1.0 table */ - - AcpiTbConvertFadt1 (LocalFadt, (void *) AcpiGbl_FADT); - } - - /* Global FADT pointer will point to the new common V2.0 FADT */ - - AcpiGbl_FADT = LocalFadt; - AcpiGbl_FADT->Length = sizeof (FADT_DESCRIPTOR); - - /* Free the original table */ - - TableDesc = AcpiGbl_TableLists[ACPI_TABLE_FADT].Next; - AcpiTbDeleteSingleTable (TableDesc); - - /* Install the new table */ - - TableDesc->Pointer = ACPI_CAST_PTR (ACPI_TABLE_HEADER, AcpiGbl_FADT); - TableDesc->Allocation = ACPI_MEM_ALLOCATED; - TableDesc->Length = sizeof (FADT_DESCRIPTOR_REV2); - - /* Dump the entire FADT */ - - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, - "Hex dump of common internal FADT, size %d (%X)\n", - AcpiGbl_FADT->Length, AcpiGbl_FADT->Length)); - - ACPI_DUMP_BUFFER (ACPI_CAST_PTR (UINT8, AcpiGbl_FADT), - AcpiGbl_FADT->Length); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbBuildCommonFacs - * - * PARAMETERS: TableInfo - Info for currently installed FACS - * - * RETURN: Status - * - * DESCRIPTION: Convert ACPI 1.0 and ACPI 2.0 FACS to a common internal - * table format. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbBuildCommonFacs ( - ACPI_TABLE_DESC *TableInfo) -{ - - ACPI_FUNCTION_TRACE ("TbBuildCommonFacs"); - - - /* Absolute minimum length is 24, but the ACPI spec says 64 */ - - if (AcpiGbl_FACS->Length < 24) - { - ACPI_ERROR ((AE_INFO, "Invalid FACS table length: 0x%X", - AcpiGbl_FACS->Length)); - return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); - } - - if (AcpiGbl_FACS->Length < 64) - { - ACPI_WARNING ((AE_INFO, - "FACS is shorter than the ACPI specification allows: 0x%X, using anyway", - AcpiGbl_FACS->Length)); - } - - /* Copy fields to the new FACS */ - - AcpiGbl_CommonFACS.GlobalLock = &(AcpiGbl_FACS->GlobalLock); - - if ((AcpiGbl_RSDP->Revision < 2) || - (AcpiGbl_FACS->Length < 32) || - (!(ACPI_GET_ADDRESS (AcpiGbl_FACS->XFirmwareWakingVector)))) - { - /* ACPI 1.0 FACS or short table or optional X_ field is zero */ - - AcpiGbl_CommonFACS.FirmwareWakingVector = ACPI_CAST_PTR (UINT64, - &(AcpiGbl_FACS->FirmwareWakingVector)); - AcpiGbl_CommonFACS.VectorWidth = 32; - } - else - { - /* ACPI 2.0 FACS with valid X_ field */ - - AcpiGbl_CommonFACS.FirmwareWakingVector = &AcpiGbl_FACS->XFirmwareWakingVector; - AcpiGbl_CommonFACS.VectorWidth = 64; - } - - return_ACPI_STATUS (AE_OK); -} - - diff --git a/sys/dist/acpica/tbfadt.c b/sys/dist/acpica/tbfadt.c new file mode 100644 index 00000000000..b98b6ff0461 --- /dev/null +++ b/sys/dist/acpica/tbfadt.c @@ -0,0 +1,520 @@ +/****************************************************************************** + * + * Module Name: tbfadt - FADT table utilities + * $Revision: 1.2 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBFADT_C__ + +#include <dist/acpica/acpi.h> +#include <dist/acpica/actables.h> + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbfadt") + +/* Local prototypes */ + +static void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *GenericAddress, + UINT8 BitWidth, + UINT64 Address); + +static void +AcpiTbConvertFadt ( + void); + +static void +AcpiTbValidateFadt ( + void); + + +/* Table for conversion of FADT to common internal format and FADT validation */ + +typedef struct acpi_fadt_info +{ + const char *Name; + UINT8 Target; + UINT8 Source; + UINT8 Length; + UINT8 Type; + +} ACPI_FADT_INFO; + +#define ACPI_FADT_REQUIRED 1 +#define ACPI_FADT_SEPARATE_LENGTH 2 + +static ACPI_FADT_INFO FadtInfoTable[] = +{ + {"Pm1aEventBlock", ACPI_FADT_OFFSET (XPm1aEventBlock), + ACPI_FADT_OFFSET (Pm1aEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), ACPI_FADT_REQUIRED}, + + {"Pm1bEventBlock", ACPI_FADT_OFFSET (XPm1bEventBlock), + ACPI_FADT_OFFSET (Pm1bEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), 0}, + + {"Pm1aControlBlock", ACPI_FADT_OFFSET (XPm1aControlBlock), + ACPI_FADT_OFFSET (Pm1aControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), ACPI_FADT_REQUIRED}, + + {"Pm1bControlBlock", ACPI_FADT_OFFSET (XPm1bControlBlock), + ACPI_FADT_OFFSET (Pm1bControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), 0}, + + {"Pm2ControlBlock", ACPI_FADT_OFFSET (XPm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlLength), ACPI_FADT_SEPARATE_LENGTH}, + + {"PmTimerBlock", ACPI_FADT_OFFSET (XPmTimerBlock), + ACPI_FADT_OFFSET (PmTimerBlock), + ACPI_FADT_OFFSET (PmTimerLength), ACPI_FADT_REQUIRED}, + + {"Gpe0Block", ACPI_FADT_OFFSET (XGpe0Block), + ACPI_FADT_OFFSET (Gpe0Block), + ACPI_FADT_OFFSET (Gpe0BlockLength), ACPI_FADT_SEPARATE_LENGTH}, + + {"Gpe1Block", ACPI_FADT_OFFSET (XGpe1Block), + ACPI_FADT_OFFSET (Gpe1Block), + ACPI_FADT_OFFSET (Gpe1BlockLength), ACPI_FADT_SEPARATE_LENGTH} +}; + +#define ACPI_FADT_INFO_ENTRIES (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO)) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitGenericAddress + * + * PARAMETERS: GenericAddress - GAS struct to be initialized + * BitWidth - Width of this register + * Address - Address of the register + * + * RETURN: None + * + * DESCRIPTION: Initialize a Generic Address Structure (GAS) + * See the ACPI specification for a full description and + * definition of this structure. + * + ******************************************************************************/ + +static void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *GenericAddress, + UINT8 BitWidth, + UINT64 Address) +{ + + /* + * The 64-bit Address field is non-aligned in the byte packed + * GAS struct. + */ + ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address); + + /* All other fields are byte-wide */ + + GenericAddress->SpaceId = ACPI_ADR_SPACE_SYSTEM_IO; + GenericAddress->BitWidth = BitWidth; + GenericAddress->BitOffset = 0; + GenericAddress->AccessWidth = 0; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbParseFadt + * + * PARAMETERS: TableIndex - Index for the FADT + * Flags - Flags + * + * RETURN: None + * + * DESCRIPTION: Initialize the FADT, DSDT and FACS tables + * (FADT contains the addresses of the DSDT and FACS) + * + ******************************************************************************/ + +void +AcpiTbParseFadt ( + ACPI_NATIVE_UINT TableIndex, + UINT8 Flags) +{ + UINT32 Length; + ACPI_TABLE_HEADER *Table; + + + /* + * The FADT has multiple versions with different lengths, + * and it contains pointers to both the DSDT and FACS tables. + * + * Get a local copy of the FADT and convert it to a common format + * Map entire FADT, assumed to be smaller than one page. + */ + Length = AcpiGbl_RootTableList.Tables[TableIndex].Length; + + Table = AcpiOsMapMemory ( + AcpiGbl_RootTableList.Tables[TableIndex].Address, Length); + if (!Table) + { + return; + } + + /* + * Validate the FADT checksum before we copy the table. Ignore + * checksum error as we want to try to get the DSDT and FACS. + */ + (void) AcpiTbVerifyChecksum (Table, Length); + + /* Obtain a local copy of the FADT in common ACPI 2.0+ format */ + + AcpiTbCreateLocalFadt (Table, Length); + + /* All done with the real FADT, unmap it */ + + AcpiOsUnmapMemory (Table, Length); + + /* Obtain the DSDT and FACS tables via their addresses within the FADT */ + + AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, + Flags, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); + + AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, + Flags, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCreateLocalFadt + * + * PARAMETERS: Table - Pointer to BIOS FADT + * Length - Length of the table + * + * RETURN: None + * + * DESCRIPTION: Get a local copy of the FADT and convert it to a common format. + * Performs validation on some important FADT fields. + * + ******************************************************************************/ + +void +AcpiTbCreateLocalFadt ( + ACPI_TABLE_HEADER *Table, + UINT32 Length) +{ + + /* + * Check if the FADT is larger than what we know about (ACPI 2.0 version). + * Truncate the table, but make some noise. + */ + if (Length > sizeof (ACPI_TABLE_FADT)) + { + ACPI_WARNING ((AE_INFO, + "FADT (revision %u) is longer than ACPI 2.0 version, truncating length 0x%X to 0x%zX", + Table->Revision, Length, sizeof (ACPI_TABLE_FADT))); + } + + /* Copy the entire FADT locally. Zero first for TbConvertFadt */ + + ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT)); + + ACPI_MEMCPY (&AcpiGbl_FADT, Table, + ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT))); + + /* + * 1) Convert the local copy of the FADT to the common internal format + * 2) Validate some of the important values within the FADT + */ + AcpiTbConvertFadt (); + AcpiTbValidateFadt (); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbConvertFadt + * + * PARAMETERS: None, uses AcpiGbl_FADT + * + * RETURN: None + * + * DESCRIPTION: Converts all versions of the FADT to a common internal format. + * -> Expand all 32-bit addresses to 64-bit. + * + * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), + * and must contain a copy of the actual FADT. + * + * ACPICA will use the "X" fields of the FADT for all addresses. + * + * "X" fields are optional extensions to the original V1.0 fields. Even if + * they are present in the structure, they can be optionally not used by + * setting them to zero. Therefore, we must selectively expand V1.0 fields + * if the corresponding X field is zero. + * + * For ACPI 1.0 FADTs, all address fields are expanded to the corresponding + * "X" fields. + * + * For ACPI 2.0 FADTs, any "X" fields that are NULL are filled in by + * expanding the corresponding ACPI 1.0 field. + * + ******************************************************************************/ + +static void +AcpiTbConvertFadt ( + void) +{ + UINT8 Pm1RegisterLength; + ACPI_GENERIC_ADDRESS *Target; + ACPI_NATIVE_UINT i; + + + /* Update the local FADT table header length */ + + AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT); + + /* Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary */ + + if (!AcpiGbl_FADT.XFacs) + { + AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; + } + + if (!AcpiGbl_FADT.XDsdt) + { + AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; + } + + /* + * Expand the 32-bit V1.0 addresses to the 64-bit "X" generic address + * structures as necessary. + */ + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + Target = ACPI_ADD_PTR ( + ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, FadtInfoTable[i].Target); + + /* Expand only if the X target is null */ + + if (!Target->Address) + { + AcpiTbInitGenericAddress (Target, + *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length), + (UINT64) *ACPI_ADD_PTR (UINT32, &AcpiGbl_FADT, FadtInfoTable[i].Source)); + } + } + + /* + * Calculate separate GAS structs for the PM1 Enable registers. + * These addresses do not appear (directly) in the FADT, so it is + * useful to calculate them once, here. + * + * The PM event blocks are split into two register blocks, first is the + * PM Status Register block, followed immediately by the PM Enable Register + * block. Each is of length (Pm1EventLength/2) + */ + Pm1RegisterLength = (UINT8) ACPI_DIV_2 (AcpiGbl_FADT.Pm1EventLength); + + /* The PM1A register block is required */ + + AcpiTbInitGenericAddress (&AcpiGbl_XPm1aEnable, Pm1RegisterLength, + (AcpiGbl_FADT.XPm1aEventBlock.Address + Pm1RegisterLength)); + + /* The PM1B register block is optional, ignore if not present */ + + if (AcpiGbl_FADT.XPm1bEventBlock.Address) + { + AcpiTbInitGenericAddress (&AcpiGbl_XPm1bEnable, Pm1RegisterLength, + (AcpiGbl_FADT.XPm1bEventBlock.Address + Pm1RegisterLength)); + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiTbValidateFadt + * + * PARAMETERS: Table - Pointer to the FADT to be validated + * + * RETURN: None + * + * DESCRIPTION: Validate various important fields within the FADT. If a problem + * is found, issue a message, but no status is returned. + * Used by both the table manager and the disassembler. + * + * Possible additional checks: + * (AcpiGbl_FADT.Pm1EventLength >= 4) + * (AcpiGbl_FADT.Pm1ControlLength >= 2) + * (AcpiGbl_FADT.PmTimerLength >= 4) + * Gpe block lengths must be multiple of 2 + * + ******************************************************************************/ + +static void +AcpiTbValidateFadt ( + void) +{ + UINT32 *Address32; + ACPI_GENERIC_ADDRESS *Address64; + UINT8 Length; + ACPI_NATIVE_UINT i; + + + /* Examine all of the 64-bit extended address fields (X fields) */ + + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + /* Generate pointers to the 32-bit and 64-bit addresses and get the length */ + + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, FadtInfoTable[i].Target); + Address32 = ACPI_ADD_PTR (UINT32, &AcpiGbl_FADT, FadtInfoTable[i].Source); + Length = *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length); + + if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED) + { + /* + * Field is required (PM1aEvent, PM1aControl, PmTimer). + * Both the address and length must be non-zero. + */ + if (!Address64->Address || !Length) + { + ACPI_ERROR ((AE_INFO, + "Required field \"%s\" has zero address and/or length: %8.8X%8.8X/%X", + FadtInfoTable[i].Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + } + } + else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH) + { + /* + * Field is optional (PM2Control, GPE0, GPE1) AND has its own + * length field. If present, both the address and length must be valid. + */ + if ((Address64->Address && !Length) || (!Address64->Address && Length)) + { + ACPI_WARNING ((AE_INFO, + "Optional field \"%s\" has zero address or length: %8.8X%8.8X/%X", + FadtInfoTable[i].Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + } + } + + /* If both 32- and 64-bit addresses are valid (non-zero), they must match */ + + if (Address64->Address && *Address32 && + (Address64->Address != (UINT64) *Address32)) + { + ACPI_ERROR ((AE_INFO, + "32/64X address mismatch in \"%s\": [%8.8X] [%8.8X%8.8X], using 64X", + FadtInfoTable[i].Name, *Address32, ACPI_FORMAT_UINT64 (Address64->Address))); + } + } +} + diff --git a/sys/dist/acpica/tbfind.c b/sys/dist/acpica/tbfind.c new file mode 100644 index 00000000000..c0404636326 --- /dev/null +++ b/sys/dist/acpica/tbfind.c @@ -0,0 +1,205 @@ +/****************************************************************************** + * + * Module Name: tbfind - find table + * $Revision: 1.2 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __TBFIND_C__ + +#include <dist/acpica/acpi.h> +#include <dist/acpica/actables.h> + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbfind") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFindTable + * + * PARAMETERS: Signature - String with ACPI table signature + * OemId - String with the table OEM ID + * OemTableId - String with the OEM Table ID + * TableIndex - Where the table index is returned + * + * RETURN: Status and table index + * + * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the + * Signature, OEM ID and OEM Table ID. Returns an index that can + * be used to get the table header or entire table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + ACPI_NATIVE_UINT *TableIndex) +{ + ACPI_NATIVE_UINT i; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbFindTable); + + + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature), + Signature, ACPI_NAME_SIZE)) + { + /* Not the requested table */ + + continue; + } + + /* Table with matching signature has been found */ + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + /* Table is not currently mapped, map it */ + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + continue; + } + } + + /* Check for table match on all IDs */ + + if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature, + Signature, ACPI_NAME_SIZE) && + (!OemId[0] || + !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId, + OemId, ACPI_OEM_ID_SIZE)) && + (!OemTableId[0] || + !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId, + OemTableId, ACPI_OEM_TABLE_ID_SIZE))) + { + *TableIndex = i; + + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", + Signature)); + return_ACPI_STATUS (AE_OK); + } + } + + return_ACPI_STATUS (AE_NOT_FOUND); +} diff --git a/sys/dist/acpica/tbget.c b/sys/dist/acpica/tbget.c index 8dde53f9e9f..e69de29bb2d 100644 --- a/sys/dist/acpica/tbget.c +++ b/sys/dist/acpica/tbget.c @@ -1,602 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbget - ACPI Table get* routines - * xRevision: 1.98 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbget.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#define __TBGET_C__ - -#include "acpi.h" -#include "actables.h" - - -#define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbget") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiTbGetThisTable ( - ACPI_POINTER *Address, - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo); - -static ACPI_STATUS -AcpiTbTableOverride ( - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo); - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetTable - * - * PARAMETERS: Address - Address of table to retrieve. Can be - * Logical or Physical - * TableInfo - Where table info is returned - * - * RETURN: None - * - * DESCRIPTION: Get entire table of unknown size. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbGetTable ( - ACPI_POINTER *Address, - ACPI_TABLE_DESC *TableInfo) -{ - ACPI_STATUS Status; - ACPI_TABLE_HEADER Header; - - - ACPI_FUNCTION_TRACE ("TbGetTable"); - - - /* Get the header in order to get signature and table size */ - - Status = AcpiTbGetTableHeader (Address, &Header); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the entire table */ - - Status = AcpiTbGetTableBody (Address, &Header, TableInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not get ACPI table (size %X)", Header.Length)); - return_ACPI_STATUS (Status); - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetTableHeader - * - * PARAMETERS: Address - Address of table to retrieve. Can be - * Logical or Physical - * ReturnHeader - Where the table header is returned - * - * RETURN: Status - * - * DESCRIPTION: Get an ACPI table header. Works in both physical or virtual - * addressing mode. Works with both physical or logical pointers. - * Table is either copied or mapped, depending on the pointer - * type and mode of the processor. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbGetTableHeader ( - ACPI_POINTER *Address, - ACPI_TABLE_HEADER *ReturnHeader) -{ - ACPI_STATUS Status = AE_OK; - ACPI_TABLE_HEADER *Header = NULL; - - - ACPI_FUNCTION_TRACE ("TbGetTableHeader"); - - - /* - * Flags contains the current processor mode (Virtual or Physical - * addressing) The PointerType is either Logical or Physical - */ - switch (Address->PointerType) - { - case ACPI_PHYSMODE_PHYSPTR: - case ACPI_LOGMODE_LOGPTR: - - /* Pointer matches processor mode, copy the header */ - - ACPI_MEMCPY (ReturnHeader, Address->Pointer.Logical, - sizeof (ACPI_TABLE_HEADER)); - break; - - - case ACPI_LOGMODE_PHYSPTR: - - /* Create a logical address for the physical pointer*/ - - Status = AcpiOsMapMemory (Address->Pointer.Physical, - sizeof (ACPI_TABLE_HEADER), (void *) &Header); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not map memory at %8.8X%8.8X for table header", - ACPI_FORMAT_UINT64 (Address->Pointer.Physical))); - return_ACPI_STATUS (Status); - } - - /* Copy header and delete mapping */ - - ACPI_MEMCPY (ReturnHeader, Header, sizeof (ACPI_TABLE_HEADER)); - AcpiOsUnmapMemory (Header, sizeof (ACPI_TABLE_HEADER)); - break; - - - default: - - ACPI_ERROR ((AE_INFO, "Invalid address flags %X", - Address->PointerType)); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n", - ReturnHeader->Signature)); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetTableBody - * - * PARAMETERS: Address - Address of table to retrieve. Can be - * Logical or Physical - * Header - Header of the table to retrieve - * TableInfo - Where the table info is returned - * - * RETURN: Status - * - * DESCRIPTION: Get an entire ACPI table with support to allow the host OS to - * replace the table with a newer version (table override.) - * Works in both physical or virtual - * addressing mode. Works with both physical or logical pointers. - * Table is either copied or mapped, depending on the pointer - * type and mode of the processor. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbGetTableBody ( - ACPI_POINTER *Address, - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE ("TbGetTableBody"); - - - if (!TableInfo || !Address) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Attempt table override. */ - - Status = AcpiTbTableOverride (Header, TableInfo); - if (ACPI_SUCCESS (Status)) - { - /* Table was overridden by the host OS */ - - return_ACPI_STATUS (Status); - } - - /* No override, get the original table */ - - Status = AcpiTbGetThisTable (Address, Header, TableInfo); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbTableOverride - * - * PARAMETERS: Header - Pointer to table header - * TableInfo - Return info if table is overridden - * - * RETURN: None - * - * DESCRIPTION: Attempts override of current table with a new one if provided - * by the host OS. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiTbTableOverride ( - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo) -{ - ACPI_TABLE_HEADER *NewTable; - ACPI_STATUS Status; - ACPI_POINTER Address; - - - ACPI_FUNCTION_TRACE ("TbTableOverride"); - - - /* - * The OSL will examine the header and decide whether to override this - * table. If it decides to override, a table will be returned in NewTable, - * which we will then copy. - */ - Status = AcpiOsTableOverride (Header, &NewTable); - if (ACPI_FAILURE (Status)) - { - /* Some severe error from the OSL, but we basically ignore it */ - - ACPI_EXCEPTION ((AE_INFO, Status, "Could not override ACPI table")); - return_ACPI_STATUS (Status); - } - - if (!NewTable) - { - /* No table override */ - - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - - /* - * We have a new table to override the old one. Get a copy of - * the new one. We know that the new table has a logical pointer. - */ - Address.PointerType = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; - Address.Pointer.Logical = NewTable; - - Status = AcpiTbGetThisTable (&Address, NewTable, TableInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not copy ACPI table")); - return_ACPI_STATUS (Status); - } - - /* Copy the table info */ - - ACPI_INFO ((AE_INFO, "Table [%4.4s] replaced by host OS", - TableInfo->Pointer->Signature)); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetThisTable - * - * PARAMETERS: Address - Address of table to retrieve. Can be - * Logical or Physical - * Header - Header of the table to retrieve - * TableInfo - Where the table info is returned - * - * RETURN: Status - * - * DESCRIPTION: Get an entire ACPI table. Works in both physical or virtual - * addressing mode. Works with both physical or logical pointers. - * Table is either copied or mapped, depending on the pointer - * type and mode of the processor. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiTbGetThisTable ( - ACPI_POINTER *Address, - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo) -{ - ACPI_TABLE_HEADER *FullTable = NULL; - UINT8 Allocation; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE ("TbGetThisTable"); - - - /* - * Flags contains the current processor mode (Virtual or Physical - * addressing) The PointerType is either Logical or Physical - */ - switch (Address->PointerType) - { - case ACPI_PHYSMODE_PHYSPTR: - case ACPI_LOGMODE_LOGPTR: - - /* Pointer matches processor mode, copy the table to a new buffer */ - - FullTable = ACPI_MEM_ALLOCATE (Header->Length); - if (!FullTable) - { - ACPI_ERROR ((AE_INFO, - "Could not allocate table memory for [%4.4s] length %X", - Header->Signature, Header->Length)); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Copy the entire table (including header) to the local buffer */ - - ACPI_MEMCPY (FullTable, Address->Pointer.Logical, Header->Length); - - /* Save allocation type */ - - Allocation = ACPI_MEM_ALLOCATED; - break; - - - case ACPI_LOGMODE_PHYSPTR: - - /* - * Just map the table's physical memory - * into our address space. - */ - Status = AcpiOsMapMemory (Address->Pointer.Physical, - (ACPI_SIZE) Header->Length, (void *) &FullTable); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X", - Header->Signature, - ACPI_FORMAT_UINT64 (Address->Pointer.Physical), - Header->Length)); - return (Status); - } - - /* Save allocation type */ - - Allocation = ACPI_MEM_MAPPED; - break; - - - default: - - ACPI_ERROR ((AE_INFO, "Invalid address flags %X", - Address->PointerType)); - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* - * Validate checksum for _most_ tables, - * even the ones whose signature we don't recognize - */ - if (TableInfo->Type != ACPI_TABLE_FACS) - { - Status = AcpiTbVerifyTableChecksum (FullTable); - -#if (!ACPI_CHECKSUM_ABORT) - if (ACPI_FAILURE (Status)) - { - /* Ignore the error if configuration says so */ - - Status = AE_OK; - } -#endif - } - - /* Return values */ - - TableInfo->Pointer = FullTable; - TableInfo->Length = (ACPI_SIZE) Header->Length; - TableInfo->Allocation = Allocation; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n", - FullTable->Signature, - ACPI_FORMAT_UINT64 (Address->Pointer.Physical), FullTable)); - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetTablePtr - * - * PARAMETERS: TableType - one of the defined table types - * Instance - Which table of this type - * TablePtrLoc - pointer to location to place the pointer for - * return - * - * RETURN: Status - * - * DESCRIPTION: This function is called to get the pointer to an ACPI table. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbGetTablePtr ( - ACPI_TABLE_TYPE TableType, - UINT32 Instance, - ACPI_TABLE_HEADER **TablePtrLoc) -{ - ACPI_TABLE_DESC *TableDesc; - UINT32 i; - - - ACPI_FUNCTION_TRACE ("TbGetTablePtr"); - - - if (!AcpiGbl_DSDT) - { - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - - if (TableType > ACPI_TABLE_MAX) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* - * For all table types (Single/Multiple), the first - * instance is always in the list head. - */ - if (Instance == 1) - { - /* Get the first */ - - *TablePtrLoc = NULL; - if (AcpiGbl_TableLists[TableType].Next) - { - *TablePtrLoc = AcpiGbl_TableLists[TableType].Next->Pointer; - } - return_ACPI_STATUS (AE_OK); - } - - /* Check for instance out of range */ - - if (Instance > AcpiGbl_TableLists[TableType].Count) - { - return_ACPI_STATUS (AE_NOT_EXIST); - } - - /* Walk the list to get the desired table - * Since the if (Instance == 1) check above checked for the - * first table, setting TableDesc equal to the .Next member - * is actually pointing to the second table. Therefore, we - * need to walk from the 2nd table until we reach the Instance - * that the user is looking for and return its table pointer. - */ - TableDesc = AcpiGbl_TableLists[TableType].Next; - for (i = 2; i < Instance; i++) - { - TableDesc = TableDesc->Next; - } - - /* We are now pointing to the requested table's descriptor */ - - *TablePtrLoc = TableDesc->Pointer; - - return_ACPI_STATUS (AE_OK); -} - diff --git a/sys/dist/acpica/tbgetall.c b/sys/dist/acpica/tbgetall.c index 61de72b91bc..e69de29bb2d 100644 --- a/sys/dist/acpica/tbgetall.c +++ b/sys/dist/acpica/tbgetall.c @@ -1,420 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbgetall - Get all required ACPI tables - * xRevision: 1.16 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbgetall.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#define __TBGETALL_C__ - -#include "acpi.h" -#include "actables.h" - - -#define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbgetall") - -/* Local prototypes */ - -static ACPI_STATUS -AcpiTbGetPrimaryTable ( - ACPI_POINTER *Address, - ACPI_TABLE_DESC *TableInfo); - -static ACPI_STATUS -AcpiTbGetSecondaryTable ( - ACPI_POINTER *Address, - ACPI_CONST_STRING Signature, - ACPI_TABLE_DESC *TableInfo); - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetPrimaryTable - * - * PARAMETERS: Address - Physical address of table to retrieve - * *TableInfo - Where the table info is returned - * - * RETURN: Status - * - * DESCRIPTION: Maps the physical address of table into a logical address - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiTbGetPrimaryTable ( - ACPI_POINTER *Address, - ACPI_TABLE_DESC *TableInfo) -{ - ACPI_STATUS Status; - ACPI_TABLE_HEADER Header; - - - ACPI_FUNCTION_TRACE ("TbGetPrimaryTable"); - - - /* Ignore a NULL address in the RSDT */ - - if (!Address->Pointer.Value) - { - return_ACPI_STATUS (AE_OK); - } - - /* Get the header in order to get signature and table size */ - - Status = AcpiTbGetTableHeader (Address, &Header); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Clear the TableInfo */ - - ACPI_MEMSET (TableInfo, 0, sizeof (ACPI_TABLE_DESC)); - - /* - * Check the table signature and make sure it is recognized. - * Also checks the header checksum - */ - TableInfo->Pointer = &Header; - Status = AcpiTbRecognizeTable (TableInfo, ACPI_TABLE_PRIMARY); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the entire table */ - - Status = AcpiTbGetTableBody (Address, &Header, TableInfo); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Install the table */ - - Status = AcpiTbInstallTable (TableInfo); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetSecondaryTable - * - * PARAMETERS: Address - Physical address of table to retrieve - * *TableInfo - Where the table info is returned - * - * RETURN: Status - * - * DESCRIPTION: Maps the physical address of table into a logical address - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiTbGetSecondaryTable ( - ACPI_POINTER *Address, - ACPI_CONST_STRING Signature, - ACPI_TABLE_DESC *TableInfo) -{ - ACPI_STATUS Status; - ACPI_TABLE_HEADER Header; - - - ACPI_FUNCTION_TRACE_STR ("TbGetSecondaryTable", Signature); - - - /* Get the header in order to match the signature */ - - Status = AcpiTbGetTableHeader (Address, &Header); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Signature must match request */ - - if (ACPI_STRNCMP (Header.Signature, Signature, ACPI_NAME_SIZE)) - { - ACPI_ERROR ((AE_INFO, - "Incorrect table signature - wanted [%s] found [%4.4s]", - Signature, Header.Signature)); - return_ACPI_STATUS (AE_BAD_SIGNATURE); - } - - /* - * Check the table signature and make sure it is recognized. - * Also checks the header checksum - */ - TableInfo->Pointer = &Header; - Status = AcpiTbRecognizeTable (TableInfo, ACPI_TABLE_SECONDARY); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the entire table */ - - Status = AcpiTbGetTableBody (Address, &Header, TableInfo); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Install the table */ - - Status = AcpiTbInstallTable (TableInfo); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetRequiredTables - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Load and validate tables other than the RSDT. The RSDT must - * already be loaded and validated. - * - * Get the minimum set of ACPI tables, namely: - * - * 1) FADT (via RSDT in loop below) - * 2) FACS (via FADT) - * 3) DSDT (via FADT) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbGetRequiredTables ( - void) -{ - ACPI_STATUS Status = AE_OK; - UINT32 i; - ACPI_TABLE_DESC TableInfo; - ACPI_POINTER Address; - - - ACPI_FUNCTION_TRACE ("TbGetRequiredTables"); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%d ACPI tables in RSDT\n", - AcpiGbl_RsdtTableCount)); - - - Address.PointerType = AcpiGbl_TableFlags | ACPI_LOGICAL_ADDRESSING; - - /* - * Loop through all table pointers found in RSDT. - * This will NOT include the FACS and DSDT - we must get - * them after the loop. - * - * The only tables we are interested in getting here is the FADT and - * any SSDTs. - */ - for (i = 0; i < AcpiGbl_RsdtTableCount; i++) - { - /* Get the table address from the common internal XSDT */ - - Address.Pointer.Value = ACPI_GET_ADDRESS ( - AcpiGbl_XSDT->TableOffsetEntry[i]); - - /* - * Get the tables needed by this subsystem (FADT and any SSDTs). - * NOTE: All other tables are completely ignored at this time. - */ - Status = AcpiTbGetPrimaryTable (&Address, &TableInfo); - if ((Status != AE_OK) && (Status != AE_TABLE_NOT_SUPPORTED)) - { - ACPI_WARNING ((AE_INFO, "%s, while getting table at %8.8X%8.8X", - AcpiFormatException (Status), - ACPI_FORMAT_UINT64 (Address.Pointer.Value))); - } - } - - /* We must have a FADT to continue */ - - if (!AcpiGbl_FADT) - { - ACPI_ERROR ((AE_INFO, "No FADT present in RSDT/XSDT")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - - /* - * Convert the FADT to a common format. This allows earlier revisions of - * the table to coexist with newer versions, using common access code. - */ - Status = AcpiTbConvertTableFadt (); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not convert FADT to internal common format")); - return_ACPI_STATUS (Status); - } - - /* Get the FACS (Pointed to by the FADT) */ - - Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl); - - Status = AcpiTbGetSecondaryTable (&Address, FACS_SIG, &TableInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not get/install the FACS")); - return_ACPI_STATUS (Status); - } - - /* - * Create the common FACS pointer table - * (Contains pointers to the original table) - */ - Status = AcpiTbBuildCommonFacs (&TableInfo); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get/install the DSDT (Pointed to by the FADT) */ - - Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt); - - Status = AcpiTbGetSecondaryTable (&Address, DSDT_SIG, &TableInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, "Could not get/install the DSDT")); - return_ACPI_STATUS (Status); - } - - /* Set Integer Width (32/64) based upon DSDT revision */ - - AcpiUtSetIntegerWidth (AcpiGbl_DSDT->Revision); - - /* Dump the entire DSDT */ - - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, - "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", - AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length, AcpiGbl_IntegerBitWidth)); - - ACPI_DUMP_BUFFER (ACPI_CAST_PTR (UINT8, AcpiGbl_DSDT), - AcpiGbl_DSDT->Length); - - /* Always delete the RSDP mapping, we are done with it */ - - AcpiTbDeleteTablesByType (ACPI_TABLE_RSDP); - return_ACPI_STATUS (Status); -} - - diff --git a/sys/dist/acpica/tbinstal.c b/sys/dist/acpica/tbinstal.c index 86437e847f6..7252dc98f8f 100644 --- a/sys/dist/acpica/tbinstal.c +++ b/sys/dist/acpica/tbinstal.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbinstal - ACPI table installation and removal - * xRevision: 1.82 $ + * $Revision: 1.3 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,144 +115,157 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbinstal.c,v 1.2 2006/04/13 08:43:17 kochi Exp $"); - #define __TBINSTAL_C__ -#include "acpi.h" -#include "actables.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbinstal") -/* Local prototypes */ - -static ACPI_STATUS -AcpiTbMatchSignature ( - char *Signature, - ACPI_TABLE_DESC *TableInfo, - UINT8 SearchType); - -/******************************************************************************* +/****************************************************************************** * - * FUNCTION: AcpiTbMatchSignature + * FUNCTION: AcpiTbVerifyTable * - * PARAMETERS: Signature - Table signature to match - * TableInfo - Return data - * SearchType - Table type to match (primary/secondary) + * PARAMETERS: TableDesc - table * * RETURN: Status * - * DESCRIPTION: Compare signature against the list of "ACPI-subsystem-owned" - * tables (DSDT/FADT/SSDT, etc.) Returns the TableTypeID on match. + * DESCRIPTION: this function is called to verify and map table * - ******************************************************************************/ + *****************************************************************************/ -static ACPI_STATUS -AcpiTbMatchSignature ( - char *Signature, - ACPI_TABLE_DESC *TableInfo, - UINT8 SearchType) +ACPI_STATUS +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc) { - ACPI_NATIVE_UINT i; + ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("TbMatchSignature"); + ACPI_FUNCTION_TRACE (TbVerifyTable); - /* Search for a signature match among the known table types */ + /* Map the table if necessary */ - for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) + if (!TableDesc->Pointer) { - if (!(AcpiGbl_TableData[i].Flags & SearchType)) + if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_MAPPED) { - continue; + TableDesc->Pointer = AcpiOsMapMemory (TableDesc->Address, TableDesc->Length); } - if (!ACPI_STRNCMP (Signature, AcpiGbl_TableData[i].Signature, - AcpiGbl_TableData[i].SigLength)) + if (!TableDesc->Pointer) { - /* Found a signature match, return index if requested */ + return_ACPI_STATUS (AE_NO_MEMORY); + } + } - if (TableInfo) - { - TableInfo->Type = (UINT8) i; - } + /* FACS is the odd table, has no standard ACPI header and no checksum */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Table [%4.4s] is an ACPI table consumed by the core subsystem\n", - AcpiGbl_TableData[i].Signature)); + if (ACPI_STRNCMP ((const char *)&TableDesc->Signature, ACPI_SIG_FACS, 4)) + { + /* Always calculate checksum, ignore bad checksum if requested */ - return_ACPI_STATUS (AE_OK); - } + Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n", - (char *) Signature)); - - return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED); + return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiTbInstallTable + * FUNCTION: AcpiTbAddTable * - * PARAMETERS: TableInfo - Return value from AcpiTbGetTableBody + * PARAMETERS: TableDesc - Table descriptor + * TableIndex - Where the table index is returned * * RETURN: Status * - * DESCRIPTION: Install the table into the global data structures. + * DESCRIPTION: This function is called to add the ACPI table * ******************************************************************************/ ACPI_STATUS -AcpiTbInstallTable ( - ACPI_TABLE_DESC *TableInfo) +AcpiTbAddTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NATIVE_UINT *TableIndex) { - ACPI_STATUS Status; - + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT Length; + ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("TbInstallTable"); + ACPI_FUNCTION_TRACE (TbAddTable); - /* Lock tables while installing */ - Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (ACPI_FAILURE (Status)) + if (!TableDesc->Pointer) { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not acquire table mutex")); - return_ACPI_STATUS (Status); + Status = AcpiTbVerifyTable (TableDesc); + if (ACPI_FAILURE (Status) || !TableDesc->Pointer) + { + return_ACPI_STATUS (Status); + } } - /* - * Ignore a table that is already installed. For example, some BIOS - * ASL code will repeatedly attempt to load the same SSDT. - */ - Status = AcpiTbIsTableInstalled (TableInfo); - if (ACPI_FAILURE (Status)) + /* The table must be either an SSDT or a PSDT */ + + if ((ACPI_STRNCMP (TableDesc->Pointer->Signature, ACPI_SIG_PSDT, 4)) && + (ACPI_STRNCMP (TableDesc->Pointer->Signature, ACPI_SIG_SSDT, 4))) { - goto UnlockAndExit; + ACPI_ERROR ((AE_INFO, + "Table has invalid signature [%4.4s], must be SSDT or PSDT", + TableDesc->Pointer->Signature)); + return_ACPI_STATUS (AE_BAD_SIGNATURE); } - /* Install the table into the global data structure */ + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - Status = AcpiTbInitTableDescriptor (TableInfo->Type, TableInfo); - if (ACPI_FAILURE (Status)) + /* Check if table is already registered */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not install table [%4.4s]", - TableInfo->Pointer->Signature)); + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_FAILURE (Status) || !AcpiGbl_RootTableList.Tables[i].Pointer) + { + continue; + } + } + + Length = ACPI_MIN (TableDesc->Length, + AcpiGbl_RootTableList.Tables[i].Length); + if (ACPI_MEMCMP (TableDesc->Pointer, + AcpiGbl_RootTableList.Tables[i].Pointer, Length)) + { + continue; + } + + /* Table is already registered */ + + AcpiTbDeleteTable (TableDesc); + *TableIndex = i; + goto Release; } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", - AcpiGbl_TableData[TableInfo->Type].Name, TableInfo->Pointer)); + /* + * Add the table to the global table list + */ + Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer, + TableDesc->Length, TableDesc->Flags, TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Release; + } + AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); -UnlockAndExit: +Release: (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); } @@ -260,430 +273,412 @@ UnlockAndExit: /******************************************************************************* * - * FUNCTION: AcpiTbRecognizeTable + * FUNCTION: AcpiTbResizeRootTableList * - * PARAMETERS: TableInfo - Return value from AcpiTbGetTableBody - * SearchType - Table type to match (primary/secondary) + * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Check a table signature for a match against known table types - * - * NOTE: All table pointers are validated as follows: - * 1) Table pointer must point to valid physical memory - * 2) Signature must be 4 ASCII chars, even if we don't recognize the - * name - * 3) Table must be readable for length specified in the header - * 4) Table checksum must be valid (with the exception of the FACS - * which has no checksum for some odd reason) + * DESCRIPTION: Expand the size of global table array * ******************************************************************************/ ACPI_STATUS -AcpiTbRecognizeTable ( - ACPI_TABLE_DESC *TableInfo, - UINT8 SearchType) +AcpiTbResizeRootTableList ( + void) { - ACPI_TABLE_HEADER *TableHeader; - ACPI_STATUS Status; + ACPI_TABLE_DESC *Tables; - ACPI_FUNCTION_TRACE ("TbRecognizeTable"); + ACPI_FUNCTION_TRACE (TbResizeRootTableList); - /* Ensure that we have a valid table pointer */ + /* AllowResize flag is a parameter to AcpiInitializeTables */ - TableHeader = (ACPI_TABLE_HEADER *) TableInfo->Pointer; - if (!TableHeader) + if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); + return_ACPI_STATUS (AE_SUPPORT); } - /* - * We only "recognize" a limited number of ACPI tables -- namely, the - * ones that are used by the subsystem (DSDT, FADT, etc.) - * - * An AE_TABLE_NOT_SUPPORTED means that the table was not recognized. - * This can be any one of many valid ACPI tables, it just isn't one of - * the tables that is consumed by the core subsystem - */ - Status = AcpiTbMatchSignature (TableHeader->Signature, - TableInfo, SearchType); - if (ACPI_FAILURE (Status)) + /* Increase the Table Array size */ + + Tables = ACPI_ALLOCATE_ZEROED ( + (AcpiGbl_RootTableList.Size + ACPI_ROOT_TABLE_SIZE_INCREMENT) + * sizeof (ACPI_TABLE_DESC)); + if (!Tables) { - return_ACPI_STATUS (Status); + ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); + return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiTbValidateTableHeader (TableHeader); - if (ACPI_FAILURE (Status)) + /* Copy and free the previous table array */ + + if (AcpiGbl_RootTableList.Tables) { - return_ACPI_STATUS (Status); - } + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, + AcpiGbl_RootTableList.Size * sizeof (ACPI_TABLE_DESC)); - /* Return the table type and length via the info struct */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + } - TableInfo->Length = (ACPI_SIZE) TableHeader->Length; + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.Size += ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED; - return_ACPI_STATUS (Status); + return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiTbInitTableDescriptor + * FUNCTION: AcpiTbStoreTable * - * PARAMETERS: TableType - The type of the table - * TableInfo - A table info struct + * PARAMETERS: Address - Table address + * Table - Table header + * Length - Table length + * Flags - flags * - * RETURN: None. + * RETURN: Status and table index. * - * DESCRIPTION: Install a table into the global data structs. + * DESCRIPTION: Add an ACPI table to the global table list * ******************************************************************************/ ACPI_STATUS -AcpiTbInitTableDescriptor ( - ACPI_TABLE_TYPE TableType, - ACPI_TABLE_DESC *TableInfo) +AcpiTbStoreTable ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Table, + UINT32 Length, + UINT8 Flags, + ACPI_NATIVE_UINT *TableIndex) { - ACPI_TABLE_LIST *ListHead; - ACPI_TABLE_DESC *TableDesc; - ACPI_STATUS Status; - + ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_U32 ("TbInitTableDescriptor", TableType); + /* Ensure that there is room for the table in the Root Table List */ - /* Allocate a descriptor for this table */ - - TableDesc = ACPI_MEM_CALLOCATE (sizeof (ACPI_TABLE_DESC)); - if (!TableDesc) + if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AcpiTbResizeRootTableList(); + if (ACPI_FAILURE (Status)) + { + return (Status); + } } - /* Get a new owner ID for the table */ + /* Initialize added table */ - Status = AcpiUtAllocateOwnerId (&TableDesc->OwnerId); - if (ACPI_FAILURE (Status)) - { - ACPI_MEM_FREE (TableDesc); - return_ACPI_STATUS (Status); - } + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = Address; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Pointer = Table; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Length = Length; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].OwnerId = 0; + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Flags = Flags; - /* Install the table into the global data structure */ + ACPI_MOVE_32_TO_32 ( + &(AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Signature), + Table->Signature); - ListHead = &AcpiGbl_TableLists[TableType]; - - /* - * Two major types of tables: 1) Only one instance is allowed. This - * includes most ACPI tables such as the DSDT. 2) Multiple instances of - * the table are allowed. This includes SSDT and PSDTs. - */ - if (ACPI_IS_SINGLE_TABLE (AcpiGbl_TableData[TableType].Flags)) - { - /* - * Only one table allowed, and a table has alread been installed - * at this location, so return an error. - */ - if (ListHead->Next) - { - ACPI_MEM_FREE (TableDesc); - return_ACPI_STATUS (AE_ALREADY_EXISTS); - } + *TableIndex = AcpiGbl_RootTableList.Count; + AcpiGbl_RootTableList.Count++; + return (Status); +} - TableDesc->Next = ListHead->Next; - ListHead->Next = TableDesc; - if (TableDesc->Next) - { - TableDesc->Next->Prev = TableDesc; - } +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteTable + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: None + * + * DESCRIPTION: Delete one internal ACPI table + * + ******************************************************************************/ - ListHead->Count++; - } - else - { - /* - * Link the new table in to the list of tables of this type. - * Insert at the end of the list, order IS IMPORTANT. - * - * TableDesc->Prev & Next are already NULL from calloc() - */ - ListHead->Count++; - - if (!ListHead->Next) - { - ListHead->Next = TableDesc; - } - else - { - TableDesc->Next = ListHead->Next; +void +AcpiTbDeleteTable ( + ACPI_TABLE_DESC *TableDesc) +{ - while (TableDesc->Next->Next) - { - TableDesc->Next = TableDesc->Next->Next; - } + /* Table must be mapped or allocated */ - TableDesc->Next->Next = TableDesc; - TableDesc->Prev = TableDesc->Next; - TableDesc->Next = NULL; - } + if (!TableDesc->Pointer) + { + return; } - /* Finish initialization of the table descriptor */ - - TableDesc->Type = (UINT8) TableType; - TableDesc->Pointer = TableInfo->Pointer; - TableDesc->Length = TableInfo->Length; - TableDesc->Allocation = TableInfo->Allocation; - TableDesc->AmlStart = (UINT8 *) (TableDesc->Pointer + 1), - TableDesc->AmlLength = (UINT32) (TableDesc->Length - - (UINT32) sizeof (ACPI_TABLE_HEADER)); - TableDesc->LoadedIntoNamespace = FALSE; - - /* - * Set the appropriate global pointer (if there is one) to point to the - * newly installed table - */ - if (AcpiGbl_TableData[TableType].GlobalPtr) + switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) { - *(AcpiGbl_TableData[TableType].GlobalPtr) = TableInfo->Pointer; - } + case ACPI_TABLE_ORIGIN_MAPPED: + AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length); + break; - /* Return Data */ + case ACPI_TABLE_ORIGIN_ALLOCATED: + ACPI_FREE (TableDesc->Pointer); + break; - TableInfo->OwnerId = TableDesc->OwnerId; - TableInfo->InstalledDesc = TableDesc; + default: + break; + } - return_ACPI_STATUS (AE_OK); + TableDesc->Pointer = NULL; } /******************************************************************************* * - * FUNCTION: AcpiTbDeleteAllTables + * FUNCTION: AcpiTbTerminate * - * PARAMETERS: None. + * PARAMETERS: None * - * RETURN: None. + * RETURN: None * * DESCRIPTION: Delete all internal ACPI tables * ******************************************************************************/ void -AcpiTbDeleteAllTables ( +AcpiTbTerminate ( void) { - ACPI_TABLE_TYPE Type; + ACPI_NATIVE_UINT i; + + + ACPI_FUNCTION_TRACE (TbTerminate); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Delete the individual tables */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; i++) + { + AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); + } + /* - * Free memory allocated for ACPI tables - * Memory can either be mapped or allocated + * Delete the root table array if allocated locally. Array cannot be + * mapped, so we don't need to check for that flag. */ - for (Type = 0; Type < NUM_ACPI_TABLE_TYPES; Type++) + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) { - AcpiTbDeleteTablesByType (Type); + ACPI_FREE (AcpiGbl_RootTableList.Tables); } + + AcpiGbl_RootTableList.Tables = NULL; + AcpiGbl_RootTableList.Flags = 0; + AcpiGbl_RootTableList.Count = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); } /******************************************************************************* * - * FUNCTION: AcpiTbDeleteTablesByType + * FUNCTION: AcpiTbDeleteNamespaceByOwner * - * PARAMETERS: Type - The table type to be deleted + * PARAMETERS: TableIndex - Table index * - * RETURN: None. + * RETURN: None * - * DESCRIPTION: Delete an internal ACPI table - * Locks the ACPI table mutex + * DESCRIPTION: Delete all namespace objects created when this table was loaded. * ******************************************************************************/ void -AcpiTbDeleteTablesByType ( - ACPI_TABLE_TYPE Type) +AcpiTbDeleteNamespaceByOwner ( + ACPI_NATIVE_UINT TableIndex) { - ACPI_TABLE_DESC *TableDesc; - UINT32 Count; - UINT32 i; - + ACPI_OWNER_ID OwnerId; - ACPI_FUNCTION_TRACE_U32 ("TbDeleteTablesByType", Type); - - if (Type > ACPI_TABLE_MAX) + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) { - return_VOID; + OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; } - - if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_TABLES))) + else { + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return; } - /* Clear the appropriate "typed" global table pointer */ - - switch (Type) - { - case ACPI_TABLE_RSDP: - AcpiGbl_RSDP = NULL; - break; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + AcpiNsDeleteNamespaceByOwner (OwnerId); +} - case ACPI_TABLE_DSDT: - AcpiGbl_DSDT = NULL; - break; - case ACPI_TABLE_FADT: - AcpiGbl_FADT = NULL; - break; +/******************************************************************************* + * + * FUNCTION: AcpiTbAllocateOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Allocates OwnerId in TableDesc + * + ******************************************************************************/ - case ACPI_TABLE_FACS: - AcpiGbl_FACS = NULL; - break; +ACPI_STATUS +AcpiTbAllocateOwnerId ( + ACPI_NATIVE_UINT TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; - case ACPI_TABLE_XSDT: - AcpiGbl_XSDT = NULL; - break; - case ACPI_TABLE_SSDT: - case ACPI_TABLE_PSDT: - default: - break; - } + ACPI_FUNCTION_TRACE (TbAllocateOwnerId); - /* - * Free the table - * 1) Get the head of the list - */ - TableDesc = AcpiGbl_TableLists[Type].Next; - Count = AcpiGbl_TableLists[Type].Count; - /* - * 2) Walk the entire list, deleting both the allocated tables - * and the table descriptors - */ - for (i = 0; i < Count; i++) + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) { - TableDesc = AcpiTbUninstallTable (TableDesc); + Status = AcpiUtAllocateOwnerId + (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); } (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_VOID; + return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiTbDeleteSingleTable + * FUNCTION: AcpiTbReleaseOwnerId * - * PARAMETERS: TableInfo - A table info struct + * PARAMETERS: TableIndex - Table index * - * RETURN: None. + * RETURN: Status * - * DESCRIPTION: Low-level free for a single ACPI table. Handles cases where - * the table was allocated a buffer or was mapped. + * DESCRIPTION: Releases OwnerId in TableDesc * ******************************************************************************/ -void -AcpiTbDeleteSingleTable ( - ACPI_TABLE_DESC *TableDesc) +ACPI_STATUS +AcpiTbReleaseOwnerId ( + ACPI_NATIVE_UINT TableIndex) { + ACPI_STATUS Status = AE_BAD_PARAMETER; - /* Must have a valid table descriptor and pointer */ - if ((!TableDesc) || - (!TableDesc->Pointer)) - { - return; - } + ACPI_FUNCTION_TRACE (TbReleaseOwnerId); - /* Valid table, determine type of memory allocation */ - switch (TableDesc->Allocation) + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) { - case ACPI_MEM_NOT_ALLOCATED: - break; - - case ACPI_MEM_ALLOCATED: - - ACPI_MEM_FREE (TableDesc->Pointer); - break; - - case ACPI_MEM_MAPPED: - - AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length); - break; - - default: - break; + AcpiUtReleaseOwnerId (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + Status = AE_OK; } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiTbUninstallTable + * FUNCTION: AcpiTbGetOwnerId * - * PARAMETERS: TableInfo - A table info struct + * PARAMETERS: TableIndex - Table index + * OwnerId - Where the table OwnerId is returned * - * RETURN: Pointer to the next table in the list (of same type) + * RETURN: Status * - * DESCRIPTION: Free the memory associated with an internal ACPI table that - * is either installed or has never been installed. - * Table mutex should be locked. + * DESCRIPTION: returns OwnerId for the ACPI table * ******************************************************************************/ -ACPI_TABLE_DESC * -AcpiTbUninstallTable ( - ACPI_TABLE_DESC *TableDesc) +ACPI_STATUS +AcpiTbGetOwnerId ( + ACPI_NATIVE_UINT TableIndex, + ACPI_OWNER_ID *OwnerId) { - ACPI_TABLE_DESC *NextDesc; + ACPI_STATUS Status = AE_BAD_PARAMETER; - ACPI_FUNCTION_TRACE_PTR ("TbUninstallTable", TableDesc); + ACPI_FUNCTION_TRACE (TbGetOwnerId); - if (!TableDesc) + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) { - return_PTR (NULL); + *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + Status = AE_OK; } - /* Unlink the descriptor from the doubly linked list */ + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} - if (TableDesc->Prev) - { - TableDesc->Prev->Next = TableDesc->Next; - } - else - { - /* Is first on list, update list head */ - AcpiGbl_TableLists[TableDesc->Type].Next = TableDesc->Next; - } +/******************************************************************************* + * + * FUNCTION: AcpiTbIsTableLoaded + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Table Loaded Flag + * + ******************************************************************************/ - if (TableDesc->Next) +BOOLEAN +AcpiTbIsTableLoaded ( + ACPI_NATIVE_UINT TableIndex) +{ + BOOLEAN IsLoaded = FALSE; + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) { - TableDesc->Next->Prev = TableDesc->Prev; + IsLoaded = (BOOLEAN) + (AcpiGbl_RootTableList.Tables[TableIndex].Flags & ACPI_TABLE_IS_LOADED); } - /* Free the memory allocated for the table itself */ + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return (IsLoaded); +} - AcpiTbDeleteSingleTable (TableDesc); - /* Free the table descriptor */ +/******************************************************************************* + * + * FUNCTION: AcpiTbSetTableLoadedFlag + * + * PARAMETERS: TableIndex - Table index + * IsLoaded - TRUE if table is loaded, FALSE otherwise + * + * RETURN: None + * + * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. + * + ******************************************************************************/ - NextDesc = TableDesc->Next; - ACPI_MEM_FREE (TableDesc); +void +AcpiTbSetTableLoadedFlag ( + ACPI_NATIVE_UINT TableIndex, + BOOLEAN IsLoaded) +{ - /* Return pointer to the next descriptor */ + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + if (IsLoaded) + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags |= ACPI_TABLE_IS_LOADED; + } + else + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags &= ~ACPI_TABLE_IS_LOADED; + } + } - return_PTR (NextDesc); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); } - diff --git a/sys/dist/acpica/tbrsdt.c b/sys/dist/acpica/tbrsdt.c index e0350cf45b0..e69de29bb2d 100644 --- a/sys/dist/acpica/tbrsdt.c +++ b/sys/dist/acpica/tbrsdt.c @@ -1,402 +0,0 @@ -/****************************************************************************** - * - * Module Name: tbrsdt - ACPI RSDT table utilities - * xRevision: 1.23 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbrsdt.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - -#define __TBRSDT_C__ - -#include "acpi.h" -#include "actables.h" - - -#define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbrsdt") - - -/******************************************************************************* - * - * FUNCTION: AcpiTbVerifyRsdp - * - * PARAMETERS: Address - RSDP (Pointer to RSDT) - * - * RETURN: Status - * - * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbVerifyRsdp ( - ACPI_POINTER *Address) -{ - ACPI_TABLE_DESC TableInfo; - ACPI_STATUS Status; - RSDP_DESCRIPTOR *Rsdp; - - - ACPI_FUNCTION_TRACE ("TbVerifyRsdp"); - - - switch (Address->PointerType) - { - case ACPI_LOGICAL_POINTER: - - Rsdp = Address->Pointer.Logical; - break; - - case ACPI_PHYSICAL_POINTER: - /* - * Obtain access to the RSDP structure - */ - Status = AcpiOsMapMemory (Address->Pointer.Physical, - sizeof (RSDP_DESCRIPTOR), - (void *) &Rsdp); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - break; - - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Verify RSDP signature and checksum */ - - Status = AcpiTbValidateRsdp (Rsdp); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* The RSDP supplied is OK */ - - TableInfo.Pointer = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp); - TableInfo.Length = sizeof (RSDP_DESCRIPTOR); - TableInfo.Allocation = ACPI_MEM_MAPPED; - - /* Save the table pointers and allocation info */ - - Status = AcpiTbInitTableDescriptor (ACPI_TABLE_RSDP, &TableInfo); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Save the RSDP in a global for easy access */ - - AcpiGbl_RSDP = ACPI_CAST_PTR (RSDP_DESCRIPTOR, TableInfo.Pointer); - return_ACPI_STATUS (Status); - - - /* Error exit */ -Cleanup: - - if (AcpiGbl_TableFlags & ACPI_PHYSICAL_POINTER) - { - AcpiOsUnmapMemory (Rsdp, sizeof (RSDP_DESCRIPTOR)); - } - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetRsdtAddress - * - * PARAMETERS: OutAddress - Where the address is returned - * - * RETURN: None, Address - * - * DESCRIPTION: Extract the address of either the RSDT or XSDT, depending on the - * version of the RSDP and whether the XSDT pointer is valid - * - ******************************************************************************/ - -void -AcpiTbGetRsdtAddress ( - ACPI_POINTER *OutAddress) -{ - - ACPI_FUNCTION_ENTRY (); - - - OutAddress->PointerType = AcpiGbl_TableFlags | ACPI_LOGICAL_ADDRESSING; - - /* Use XSDT if it is present */ - - if ((AcpiGbl_RSDP->Revision >= 2) && - ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress)) - { - OutAddress->Pointer.Value = - ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress); - AcpiGbl_RootTableType = ACPI_TABLE_TYPE_XSDT; - } - else - { - /* No XSDT, use the RSDT */ - - OutAddress->Pointer.Value = AcpiGbl_RSDP->RsdtPhysicalAddress; - AcpiGbl_RootTableType = ACPI_TABLE_TYPE_RSDT; - } -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbValidateRsdt - * - * PARAMETERS: TablePtr - Addressable pointer to the RSDT. - * - * RETURN: Status - * - * DESCRIPTION: Validate signature for the RSDT or XSDT - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbValidateRsdt ( - ACPI_TABLE_HEADER *TablePtr) -{ - int NoMatch; - - - ACPI_FUNCTION_ENTRY (); - - - /* - * Search for appropriate signature, RSDT or XSDT - */ - if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) - { - NoMatch = ACPI_STRNCMP ((char *) TablePtr, RSDT_SIG, - sizeof (RSDT_SIG) -1); - } - else - { - NoMatch = ACPI_STRNCMP ((char *) TablePtr, XSDT_SIG, - sizeof (XSDT_SIG) -1); - } - - if (NoMatch) - { - /* Invalid RSDT or XSDT signature */ - - ACPI_ERROR ((AE_INFO, - "Invalid signature where RSDP indicates RSDT/XSDT should be located. RSDP:")); - - ACPI_DUMP_BUFFER (AcpiGbl_RSDP, 20); - - ACPI_ERROR ((AE_INFO, - "RSDT/XSDT signature at %X (%p) is invalid", - AcpiGbl_RSDP->RsdtPhysicalAddress, - (void *) (ACPI_NATIVE_UINT) AcpiGbl_RSDP->RsdtPhysicalAddress)); - - if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) - { - ACPI_ERROR ((AE_INFO, "Looking for RSDT")); - } - else - { - ACPI_ERROR ((AE_INFO, "Looking for XSDT")); - } - - ACPI_DUMP_BUFFER ((char *) TablePtr, 48); - return (AE_BAD_SIGNATURE); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbGetTableRsdt - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbGetTableRsdt ( - void) -{ - ACPI_TABLE_DESC TableInfo; - ACPI_STATUS Status; - ACPI_POINTER Address; - - - ACPI_FUNCTION_TRACE ("TbGetTableRsdt"); - - - /* Get the RSDT/XSDT via the RSDP */ - - AcpiTbGetRsdtAddress (&Address); - - TableInfo.Type = ACPI_TABLE_XSDT; - Status = AcpiTbGetTable (&Address, &TableInfo); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not get the RSDT/XSDT")); - return_ACPI_STATUS (Status); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "RSDP located at %p, points to RSDT physical=%8.8X%8.8X\n", - AcpiGbl_RSDP, - ACPI_FORMAT_UINT64 (Address.Pointer.Value))); - - /* Check the RSDT or XSDT signature */ - - Status = AcpiTbValidateRsdt (TableInfo.Pointer); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Get the number of tables defined in the RSDT or XSDT */ - - AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, - TableInfo.Pointer); - - /* Convert and/or copy to an XSDT structure */ - - Status = AcpiTbConvertToXsdt (&TableInfo); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Save the table pointers and allocation info */ - - Status = AcpiTbInitTableDescriptor (ACPI_TABLE_XSDT, &TableInfo); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - AcpiGbl_XSDT = ACPI_CAST_PTR (XSDT_DESCRIPTOR, TableInfo.Pointer); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", AcpiGbl_XSDT)); - return_ACPI_STATUS (Status); -} - - diff --git a/sys/dist/acpica/tbutils.c b/sys/dist/acpica/tbutils.c index 00035c7d7ad..706a2dbe364 100644 --- a/sys/dist/acpica/tbutils.c +++ b/sys/dist/acpica/tbutils.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: tbutils - Table manipulation utilities - * xRevision: 1.75 $ + * Module Name: tbutils - table utilities + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,297 +114,481 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbutils.c,v 1.1 2006/03/23 13:36:31 kochi Exp $"); - #define __TBUTILS_C__ -#include "acpi.h" -#include "actables.h" - +#include <dist/acpica/acpi.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbutils") /* Local prototypes */ -#ifdef ACPI_OBSOLETE_FUNCTIONS -ACPI_STATUS -AcpiTbHandleToObject ( - UINT16 TableId, - ACPI_TABLE_DESC **TableDesc); -#endif +static ACPI_PHYSICAL_ADDRESS +AcpiTbGetRootTableEntry ( + UINT8 *TableEntry, + ACPI_NATIVE_UINT TableEntrySize); /******************************************************************************* * - * FUNCTION: AcpiTbIsTableInstalled - * - * PARAMETERS: NewTableDesc - Descriptor for new table being installed + * FUNCTION: AcpiTbTablesLoaded * - * RETURN: Status - AE_ALREADY_EXISTS if the table is already installed + * PARAMETERS: None * - * DESCRIPTION: Determine if an ACPI table is already installed + * RETURN: TRUE if required ACPI tables are loaded * - * MUTEX: Table data structures should be locked + * DESCRIPTION: Determine if the minimum required ACPI tables are present + * (FADT, FACS, DSDT) * ******************************************************************************/ -ACPI_STATUS -AcpiTbIsTableInstalled ( - ACPI_TABLE_DESC *NewTableDesc) +BOOLEAN +AcpiTbTablesLoaded ( + void) { - ACPI_TABLE_DESC *TableDesc; - - ACPI_FUNCTION_TRACE ("TbIsTableInstalled"); + if (AcpiGbl_RootTableList.Count >= 3) + { + return (TRUE); + } + return (FALSE); +} - /* Get the list descriptor and first table descriptor */ - TableDesc = AcpiGbl_TableLists[NewTableDesc->Type].Next; +/******************************************************************************* + * + * FUNCTION: AcpiTbPrintTableHeader + * + * PARAMETERS: Address - Table physical address + * Header - Table header + * + * RETURN: None + * + * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. + * + ******************************************************************************/ - /* Examine all installed tables of this type */ +void +AcpiTbPrintTableHeader ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Header) +{ - while (TableDesc) + if (!ACPI_STRNCMP (Header->Signature, ACPI_SIG_FACS, 4)) { - /* - * If the table lengths match, perform a full bytewise compare. This - * means that we will allow tables with duplicate OemTableId(s), as - * long as the tables are different in some way. - * - * Checking if the table has been loaded into the namespace means that - * we don't check for duplicate tables during the initial installation - * of tables within the RSDT/XSDT. - */ - if ((TableDesc->LoadedIntoNamespace) && - (TableDesc->Pointer->Length == NewTableDesc->Pointer->Length) && - (!ACPI_MEMCMP (TableDesc->Pointer, NewTableDesc->Pointer, - NewTableDesc->Pointer->Length))) - { - /* Match: this table is already installed */ - - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, - "Table [%4.4s] already installed: Rev %X OemTableId [%8.8s]\n", - NewTableDesc->Pointer->Signature, - NewTableDesc->Pointer->Revision, - NewTableDesc->Pointer->OemTableId)); - - NewTableDesc->OwnerId = TableDesc->OwnerId; - NewTableDesc->InstalledDesc = TableDesc; + /* FACS only has signature and length fields of common table header */ - return_ACPI_STATUS (AE_ALREADY_EXISTS); - } - - /* Get next table on the list */ - - TableDesc = TableDesc->Next; + ACPI_INFO ((AE_INFO, "%4.4s @ 0x%p/0x%04X", + Header->Signature, ACPI_CAST_PTR (void, Address), Header->Length)); + } + else if (!ACPI_STRNCMP (Header->Signature, ACPI_SIG_RSDP, 4)) + { + /* RSDP has no common fields */ + + ACPI_INFO ((AE_INFO, "RSDP @ 0x%p/0x%04X (v%3.3d %6.6s)", + ACPI_CAST_PTR (void, Address), + (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ? + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId)); + } + else + { + /* Standard ACPI table with full common header */ + + ACPI_INFO ((AE_INFO, + "%4.4s @ 0x%p/0x%04X (v%3.3d %6.6s %8.8s 0x%08X %4.4s 0x%08X)", + Header->Signature, ACPI_CAST_PTR (void, Address), + Header->Length, Header->Revision, Header->OemId, + Header->OemTableId, Header->OemRevision, Header->AslCompilerId, + Header->AslCompilerRevision)); } - - return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiTbValidateTableHeader + * FUNCTION: AcpiTbValidateChecksum * - * PARAMETERS: TableHeader - Logical pointer to the table + * PARAMETERS: Table - ACPI table to verify + * Length - Length of entire table * * RETURN: Status * - * DESCRIPTION: Check an ACPI table header for validity - * - * NOTE: Table pointers are validated as follows: - * 1) Table pointer must point to valid physical memory - * 2) Signature must be 4 ASCII chars, even if we don't recognize the - * name - * 3) Table must be readable for length specified in the header - * 4) Table checksum must be valid (with the exception of the FACS - * which has no checksum because it contains variable fields) + * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns + * exception on bad checksum. * ******************************************************************************/ ACPI_STATUS -AcpiTbValidateTableHeader ( - ACPI_TABLE_HEADER *TableHeader) +AcpiTbVerifyChecksum ( + ACPI_TABLE_HEADER *Table, + UINT32 Length) { - ACPI_NAME Signature; + UINT8 Checksum; - ACPI_FUNCTION_ENTRY (); + /* Compute the checksum on the table */ + Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Length); - /* Verify that this is a valid address */ + /* Checksum ok? (should be zero) */ - if (!AcpiOsReadable (TableHeader, sizeof (ACPI_TABLE_HEADER))) + if (Checksum) { - ACPI_ERROR ((AE_INFO, - "Cannot read table header at %p", TableHeader)); + ACPI_WARNING ((AE_INFO, + "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X", + Table->Signature, Table->Checksum, (UINT8) (Table->Checksum - Checksum))); - return (AE_BAD_ADDRESS); +#if (ACPI_CHECKSUM_ABORT) + return (AE_BAD_CHECKSUM); +#endif } - /* Ensure that the signature is 4 ASCII characters */ + return (AE_OK); +} - ACPI_MOVE_32_TO_32 (&Signature, TableHeader->Signature); - if (!AcpiUtValidAcpiName (Signature)) - { - ACPI_ERROR ((AE_INFO, - "Table signature at %p [%p] has invalid characters", - TableHeader, &Signature)); - ACPI_WARNING ((AE_INFO, "Invalid table signature found: [%4.4s]", - ACPI_CAST_PTR (char, &Signature))); +/******************************************************************************* + * + * FUNCTION: AcpiTbChecksum + * + * PARAMETERS: Buffer - Pointer to memory region to be checked + * Length - Length of this memory region + * + * RETURN: Checksum (UINT8) + * + * DESCRIPTION: Calculates circular checksum of memory region. + * + ******************************************************************************/ - ACPI_DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); - return (AE_BAD_SIGNATURE); - } +UINT8 +AcpiTbChecksum ( + UINT8 *Buffer, + ACPI_NATIVE_UINT Length) +{ + UINT8 Sum = 0; + UINT8 *End = Buffer + Length; - /* Validate the table length */ - if (TableHeader->Length < sizeof (ACPI_TABLE_HEADER)) + while (Buffer < End) { - ACPI_ERROR ((AE_INFO, - "Invalid length in table header %p name %4.4s", - TableHeader, (char *) &Signature)); - - ACPI_WARNING ((AE_INFO, "Invalid table header length (0x%X) found", - (UINT32) TableHeader->Length)); - - ACPI_DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); - return (AE_BAD_HEADER); + Sum = (UINT8) (Sum + *(Buffer++)); } - return (AE_OK); + return Sum; } /******************************************************************************* * - * FUNCTION: AcpiTbVerifyTableChecksum + * FUNCTION: AcpiTbInstallTable * - * PARAMETERS: *TableHeader - ACPI table to verify + * PARAMETERS: Address - Physical address of DSDT or FACS + * Flags - Flags + * Signature - Table signature, NULL if no need to + * match + * TableIndex - Index into root table array * - * RETURN: 8 bit checksum of table + * RETURN: None * - * DESCRIPTION: Does an 8 bit checksum of table and returns status. A correct - * table should have a checksum of 0. + * DESCRIPTION: Install an ACPI table into the global data structure. * ******************************************************************************/ -ACPI_STATUS -AcpiTbVerifyTableChecksum ( - ACPI_TABLE_HEADER *TableHeader) +void +AcpiTbInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + const char *Signature, + ACPI_NATIVE_UINT TableIndex) { - UINT8 Checksum; - ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER *Table; - ACPI_FUNCTION_TRACE ("TbVerifyTableChecksum"); + if (!Address) + { + ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]", + Signature)); + return; + } + /* Map just the table header */ - /* Compute the checksum on the table */ + Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!Table) + { + return; + } + + /* If a particular signature is expected, signature must match */ + + if (Signature && ACPI_STRNCMP (Table->Signature, Signature, 4)) + { + ACPI_ERROR ((AE_INFO, "Invalid signature 0x%X for ACPI table [%s]", + *ACPI_CAST_PTR (UINT32, Table->Signature), Signature)); + goto UnmapAndExit; + } - Checksum = AcpiTbGenerateChecksum (TableHeader, TableHeader->Length); + /* Initialize the table entry */ - /* Return the appropriate exception */ + AcpiGbl_RootTableList.Tables[TableIndex].Address = Address; + AcpiGbl_RootTableList.Tables[TableIndex].Length = Table->Length; + AcpiGbl_RootTableList.Tables[TableIndex].Flags = Flags; - if (Checksum) + ACPI_MOVE_32_TO_32 ( + &(AcpiGbl_RootTableList.Tables[TableIndex].Signature), + Table->Signature); + + AcpiTbPrintTableHeader (Address, Table); + + if (TableIndex == ACPI_TABLE_INDEX_DSDT) { - ACPI_WARNING ((AE_INFO, - "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)", - TableHeader->Signature, (UINT32) TableHeader->Checksum, - (UINT32) Checksum)); + /* Global integer width is based upon revision of the DSDT */ - Status = AE_BAD_CHECKSUM; + AcpiUtSetIntegerWidth (Table->Revision); } - return_ACPI_STATUS (Status); + +UnmapAndExit: + AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); } /******************************************************************************* * - * FUNCTION: AcpiTbGenerateChecksum + * FUNCTION: AcpiTbGetRootTableEntry * - * PARAMETERS: Buffer - Buffer to checksum - * Length - Size of the buffer + * PARAMETERS: TableEntry - Pointer to the RSDT/XSDT table entry + * TableEntrySize - sizeof 32 or 64 (RSDT or XSDT) * - * RETURN: 8 bit checksum of buffer + * RETURN: Physical address extracted from the root table * - * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. + * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on + * both 32-bit and 64-bit platforms + * + * NOTE: ACPI_PHYSICAL_ADDRESS is 32-bit on 32-bit platforms, 64-bit on + * 64-bit platforms. * ******************************************************************************/ -UINT8 -AcpiTbGenerateChecksum ( - void *Buffer, - UINT32 Length) +static ACPI_PHYSICAL_ADDRESS +AcpiTbGetRootTableEntry ( + UINT8 *TableEntry, + ACPI_NATIVE_UINT TableEntrySize) { - UINT8 *EndBuffer; - UINT8 *Rover; - UINT8 Sum = 0; + UINT64 Address64; - if (Buffer && Length) + /* + * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): + * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT + */ + if (TableEntrySize == sizeof (UINT32)) { - /* Buffer and Length are valid */ - - EndBuffer = ACPI_ADD_PTR (UINT8, Buffer, Length); + /* + * 32-bit platform, RSDT: Return 32-bit table entry + * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return + */ + return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (UINT32, TableEntry))); + } + else + { + /* + * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return + * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, return 64-bit + */ + ACPI_MOVE_64_TO_64 (&Address64, TableEntry); - for (Rover = Buffer; Rover < EndBuffer; Rover++) +#if ACPI_MACHINE_WIDTH == 32 + if (Address64 > ACPI_UINT32_MAX) { - Sum = (UINT8) (Sum + *Rover); + /* Will truncate 64-bit address to 32 bits, issue warning */ + + ACPI_WARNING ((AE_INFO, + "64-bit Physical Address in XSDT is too large (%8.8X%8.8X), truncating", + ACPI_FORMAT_UINT64 (Address64))); } +#endif + return ((ACPI_PHYSICAL_ADDRESS) (Address64)); } - return (Sum); } -#ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * - * FUNCTION: AcpiTbHandleToObject + * FUNCTION: AcpiTbParseRootTable + * + * PARAMETERS: Rsdp - Pointer to the RSDP + * Flags - Flags * - * PARAMETERS: TableId - Id for which the function is searching - * TableDesc - Pointer to return the matching table - * descriptor. + * RETURN: Status + * + * DESCRIPTION: This function is called to parse the Root System Description + * Table (RSDT or XSDT) * - * RETURN: Search the tables to find one with a matching TableId and - * return a pointer to that table descriptor. + * NOTE: Tables are mapped (not copied) for efficiency. The FACS must + * be mapped and cannot be copied because it contains the actual + * memory location of the ACPI Global Lock. * ******************************************************************************/ ACPI_STATUS -AcpiTbHandleToObject ( - UINT16 TableId, - ACPI_TABLE_DESC **ReturnTableDesc) +AcpiTbParseRootTable ( + ACPI_PHYSICAL_ADDRESS RsdpAddress, + UINT8 Flags) { - UINT32 i; - ACPI_TABLE_DESC *TableDesc; + ACPI_TABLE_RSDP *Rsdp; + ACPI_NATIVE_UINT TableEntrySize; + ACPI_NATIVE_UINT i; + UINT32 TableCount; + ACPI_TABLE_HEADER *Table; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + UINT8 *TableEntry; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbParseRootTable); + + + /* + * Map the entire RSDP and extract the address of the RSDT or XSDT + */ + Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP)); + if (!Rsdp) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiTbPrintTableHeader (RsdpAddress, ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp)); + + /* Differentiate between RSDT and XSDT root tables */ + + if (Rsdp->Revision > 1 && Rsdp->XsdtPhysicalAddress) + { + /* + * Root table is an XSDT (64-bit physical addresses). We must use the + * XSDT if the revision is > 1 and the XSDT pointer is present, as per + * the ACPI specification. + */ + Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress; + TableEntrySize = sizeof (UINT64); + } + else + { + /* Root table is an RSDT (32-bit physical addresses) */ + + Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress; + TableEntrySize = sizeof (UINT32); + } + + /* + * It is not possible to map more than one entry in some environments, + * so unmap the RSDP here before mapping other tables + */ + AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP)); + + + /* Map the RSDT/XSDT table header to get the full table length */ + + Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiTbPrintTableHeader (Address, Table); + + /* Get the length of the full table, verify length and map entire table */ + + Length = Table->Length; + AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + ACPI_ERROR ((AE_INFO, "Invalid length 0x%X in RSDT/XSDT", Length)); + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + Table = AcpiOsMapMemory (Address, Length); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Validate the root table checksum */ + Status = AcpiTbVerifyChecksum (Table, Length); + if (ACPI_FAILURE (Status)) + { + AcpiOsUnmapMemory (Table, Length); + return_ACPI_STATUS (Status); + } + + /* Calculate the number of tables described in the root table */ - ACPI_FUNCTION_NAME ("TbHandleToObject"); + TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) / TableEntrySize); + /* + * First two entries in the table array are reserved for the DSDT and FACS, + * which are not actually present in the RSDT/XSDT - they come from the FADT + */ + TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER); + AcpiGbl_RootTableList.Count = 2; - for (i = 0; i < ACPI_TABLE_MAX; i++) + /* + * Initialize the root table array from the RSDT/XSDT + */ + for (i = 0; i < TableCount; i++) { - TableDesc = AcpiGbl_TableLists[i].Next; - while (TableDesc) + if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) { - if (TableDesc->TableId == TableId) + /* There is no more room in the root table array, attempt resize */ + + Status = AcpiTbResizeRootTableList (); + if (ACPI_FAILURE (Status)) { - *ReturnTableDesc = TableDesc; - return (AE_OK); + ACPI_WARNING ((AE_INFO, "Truncating %u table entries!", + (unsigned) (AcpiGbl_RootTableList.Size - AcpiGbl_RootTableList.Count))); + break; } - - TableDesc = TableDesc->Next; } + + /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ + + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = + AcpiTbGetRootTableEntry (TableEntry, TableEntrySize); + + TableEntry += TableEntrySize; + AcpiGbl_RootTableList.Count++; } - ACPI_ERROR ((AE_INFO, "TableId=%X does not exist", TableId)); - return (AE_BAD_PARAMETER); -} -#endif + /* + * It is not possible to map more than one entry in some environments, + * so unmap the root table here before mapping other tables + */ + AcpiOsUnmapMemory (Table, Length); + + /* + * Complete the initialization of the root table array by examining + * the header of each table + */ + for (i = 2; i < AcpiGbl_RootTableList.Count; i++) + { + AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, + Flags, NULL, i); + /* Special case for FADT - get the DSDT and FACS */ + + if (!ACPI_STRNCMP( + (const char *)&AcpiGbl_RootTableList.Tables[i].Signature, + ACPI_SIG_FADT, 4)) + { + AcpiTbParseFadt (i, Flags); + } + } + return_ACPI_STATUS (AE_OK); +} diff --git a/sys/dist/acpica/tbxface.c b/sys/dist/acpica/tbxface.c index 8c0e5b5d48e..99c1d6cd112 100644 --- a/sys/dist/acpica/tbxface.c +++ b/sys/dist/acpica/tbxface.c @@ -2,7 +2,7 @@ * * Module Name: tbxface - Public interfaces to the ACPI subsystem * ACPI table oriented interfaces - * xRevision: 1.73 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,433 +115,562 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbxface.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __TBXFACE_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "actables.h" - +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbxface") +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbLoadNamespace ( + void); + /******************************************************************************* * - * FUNCTION: AcpiLoadTables + * FUNCTION: AcpiAllocateRootTable * - * PARAMETERS: None + * PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of + * ACPI_TABLE_DESC structures * * RETURN: Status * - * DESCRIPTION: This function is called to load the ACPI tables from the - * provided RSDT + * DESCRIPTION: Allocate a root table array. Used by iASL compiler and + * AcpiInitializeTables. * ******************************************************************************/ ACPI_STATUS -AcpiLoadTables ( - void) +AcpiAllocateRootTable ( + UINT32 InitialTableCount) { - ACPI_POINTER RsdpAddress; - ACPI_STATUS Status; + AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE; - ACPI_FUNCTION_TRACE ("AcpiLoadTables"); - + return (AcpiTbResizeRootTableList ()); +} - /* Get the RSDP */ - Status = AcpiOsGetRootPointer (ACPI_LOGICAL_ADDRESSING, - &RsdpAddress); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not get the RSDP")); - goto ErrorExit; - } +/******************************************************************************* + * + * FUNCTION: AcpiInitializeTables + * + * PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated + * ACPI_TABLE_DESC structures. If NULL, the + * array is dynamically allocated. + * InitialTableCount - Size of InitialTableArray, in number of + * ACPI_TABLE_DESC structures + * AllowRealloc - Flag to tell Table Manager if resize of + * pre-allocated array is allowed. Ignored + * if InitialTableArray is NULL. + * + * RETURN: Status + * + * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT. + * + * NOTE: Allows static allocation of the initial table array in order + * to avoid the use of dynamic memory in confined environments + * such as the kernel boot sequence where it may not be available. + * + * If the host OS memory managers are initialized, use NULL for + * InitialTableArray, and the table will be dynamically allocated. + * + ******************************************************************************/ - /* Map and validate the RSDP */ +ACPI_STATUS +AcpiInitializeTables ( + ACPI_TABLE_DESC *InitialTableArray, + UINT32 InitialTableCount, + BOOLEAN AllowResize) +{ + ACPI_PHYSICAL_ADDRESS RsdpAddress; + ACPI_STATUS Status; - AcpiGbl_TableFlags = RsdpAddress.PointerType; - Status = AcpiTbVerifyRsdp (&RsdpAddress); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "During RSDP validation")); - goto ErrorExit; - } + ACPI_FUNCTION_TRACE (AcpiInitializeTables); - /* Get the RSDT via the RSDP */ - Status = AcpiTbGetTableRsdt (); - if (ACPI_FAILURE (Status)) + /* + * Set up the Root Table Array + * Allocate the table array if requested + */ + if (!InitialTableArray) { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not load RSDT")); - goto ErrorExit; + Status = AcpiAllocateRootTable (InitialTableCount); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } + else + { + /* Root Table Array has been statically allocated by the host */ - /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */ + ACPI_MEMSET (InitialTableArray, 0, + InitialTableCount * sizeof (ACPI_TABLE_DESC)); - Status = AcpiTbGetRequiredTables (); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not get all required tables (DSDT/FADT/FACS)")); - goto ErrorExit; + AcpiGbl_RootTableList.Tables = InitialTableArray; + AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN; + if (AllowResize) + { + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; + } } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); - - /* Load the namespace from the tables */ + /* Get the address of the RSDP */ - Status = AcpiNsLoadNamespace (); - if (ACPI_FAILURE (Status)) + RsdpAddress = AcpiOsGetRootPointer (); + if (!RsdpAddress) { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not load namespace")); - goto ErrorExit; + return_ACPI_STATUS (AE_NOT_FOUND); } - return_ACPI_STATUS (AE_OK); - - -ErrorExit: - ACPI_EXCEPTION ((AE_INFO, Status, "Could not load tables")); + /* + * Get the root table (RSDT or XSDT) and extract all entries to the local + * Root Table Array. This array contains the information of the RSDT/XSDT + * in a common, more useable format. + */ + Status = AcpiTbParseRootTable (RsdpAddress, ACPI_TABLE_ORIGIN_MAPPED); return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInitializeTables) + /******************************************************************************* * - * FUNCTION: AcpiLoadTable + * FUNCTION: AcpiReallocateRootTable * - * PARAMETERS: TablePtr - pointer to a buffer containing the entire - * table to be loaded + * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: This function is called to load a table from the caller's - * buffer. The buffer must contain an entire ACPI Table including - * a valid header. The header fields will be verified, and if it - * is determined that the table is invalid, the call will fail. + * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the + * root list from the previously provided scratch area. Should + * be called once dynamic memory allocation is available in the + * kernel * ******************************************************************************/ ACPI_STATUS -AcpiLoadTable ( - ACPI_TABLE_HEADER *TablePtr) +AcpiReallocateRootTable ( + void) { - ACPI_STATUS Status; - ACPI_TABLE_DESC TableInfo; - ACPI_POINTER Address; + ACPI_TABLE_DESC *Tables; + ACPI_SIZE NewSize; - ACPI_FUNCTION_TRACE ("AcpiLoadTable"); + ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); - if (!TablePtr) + /* + * Only reallocate the root table if the host provided a static buffer + * for the table array in the call to AcpiInitializeTables. + */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_SUPPORT); } - /* Copy the table to a local buffer */ + NewSize = (AcpiGbl_RootTableList.Count + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC); - Address.PointerType = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING; - Address.Pointer.Logical = TablePtr; + /* Create new array and copy the old array */ - Status = AcpiTbGetTableBody (&Address, TablePtr, &TableInfo); - if (ACPI_FAILURE (Status)) + Tables = ACPI_ALLOCATE_ZEROED (NewSize); + if (!Tables) { - return_ACPI_STATUS (Status); + return_ACPI_STATUS (AE_NO_MEMORY); } - /* Check signature for a valid table type */ + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, NewSize); - Status = AcpiTbRecognizeTable (&TableInfo, ACPI_TABLE_ALL); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + AcpiGbl_RootTableList.Size = AcpiGbl_RootTableList.Count; + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.Flags = + ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; - /* Install the new table into the local data structures */ + return_ACPI_STATUS (AE_OK); +} - Status = AcpiTbInstallTable (&TableInfo); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_ALREADY_EXISTS) - { - /* Table already exists, no error */ +ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable) - Status = AE_OK; - } - /* Free table allocated by AcpiTbGetTableBody */ - - AcpiTbDeleteSingleTable (&TableInfo); - return_ACPI_STATUS (Status); - } +/****************************************************************************** + * + * FUNCTION: AcpiGetTableHeader + * + * PARAMETERS: Signature - ACPI signature of needed table + * Instance - Which instance (for SSDTs) + * OutTableHeader - The pointer to the table header to fill + * + * RETURN: Status and pointer to mapped table header + * + * DESCRIPTION: Finds an ACPI table header. + * + * NOTE: Caller is responsible in unmapping the header with + * AcpiOsUnmapMemory + * + *****************************************************************************/ - /* Convert the table to common format if necessary */ +ACPI_STATUS +AcpiGetTableHeader ( + const char *Signature, + ACPI_NATIVE_UINT Instance, + ACPI_TABLE_HEADER *OutTableHeader) +{ + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT j; + ACPI_TABLE_HEADER *Header; - switch (TableInfo.Type) - { - case ACPI_TABLE_FADT: - Status = AcpiTbConvertTableFadt (); - break; + /* Parameter validation */ - case ACPI_TABLE_FACS: + if (!Signature || !OutTableHeader) + { + return (AE_BAD_PARAMETER); + } - Status = AcpiTbBuildCommonFacs (&TableInfo); - break; + /* + * Walk the root table list + */ + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + { + if (ACPI_STRNCMP( + (const char *)&(AcpiGbl_RootTableList.Tables[i].Signature), + Signature, 4)) + { + continue; + } - default: - /* Load table into namespace if it contains executable AML */ + if (++j < Instance) + { + continue; + } - Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); - break; - } + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + if ((AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_MAPPED) + { + Header = AcpiOsMapMemory (AcpiGbl_RootTableList.Tables[i].Address, + sizeof (ACPI_TABLE_HEADER)); + if (!Header) + { + return AE_NO_MEMORY; + } + + ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER)); + AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER)); + } + + else + { + return AE_NOT_FOUND; + } + } - if (ACPI_FAILURE (Status)) - { - /* Uninstall table and free the buffer */ + else + { + ACPI_MEMCPY (OutTableHeader, AcpiGbl_RootTableList.Tables[i].Pointer, + sizeof(ACPI_TABLE_HEADER)); + } - (void) AcpiTbUninstallTable (TableInfo.InstalledDesc); + return (AE_OK); } - return_ACPI_STATUS (Status); + return (AE_NOT_FOUND); } +ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) -/******************************************************************************* + +/****************************************************************************** * - * FUNCTION: AcpiUnloadTable + * FUNCTION: AcpiGetTable * - * PARAMETERS: TableType - Type of table to be unloaded + * PARAMETERS: Signature - ACPI signature of needed table + * Instance - Which instance (for SSDTs) + * OutTable - Where the pointer to the table is returned * - * RETURN: Status + * RETURN: Status and pointer to table * - * DESCRIPTION: This routine is used to force the unload of a table + * DESCRIPTION: Finds and verifies an ACPI table. * - ******************************************************************************/ + *****************************************************************************/ ACPI_STATUS -AcpiUnloadTable ( - ACPI_TABLE_TYPE TableType) +AcpiGetTable ( + const char *Signature, + ACPI_NATIVE_UINT Instance, + ACPI_TABLE_HEADER **OutTable) { - ACPI_TABLE_DESC *TableDesc; - - - ACPI_FUNCTION_TRACE ("AcpiUnloadTable"); + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT j; + ACPI_STATUS Status; /* Parameter validation */ - if (TableType > ACPI_TABLE_MAX) + if (!Signature || !OutTable) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return (AE_BAD_PARAMETER); } - /* Find all tables of the requested type */ - - TableDesc = AcpiGbl_TableLists[TableType].Next; - while (TableDesc) + /* + * Walk the root table list + */ + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) { - /* - * Delete all namespace entries owned by this table. Note that these - * entries can appear anywhere in the namespace by virtue of the AML - * "Scope" operator. Thus, we need to track ownership by an ID, not - * simply a position within the hierarchy - */ - AcpiNsDeleteNamespaceByOwner (TableDesc->OwnerId); - AcpiUtReleaseOwnerId (&TableDesc->OwnerId); - TableDesc = TableDesc->Next; - } + if (ACPI_STRNCMP ( + (const char *)&(AcpiGbl_RootTableList.Tables[i].Signature), + Signature, 4)) + { + continue; + } - /* Delete (or unmap) all tables of this type */ + if (++j < Instance) + { + continue; + } - AcpiTbDeleteTablesByType (TableType); - return_ACPI_STATUS (AE_OK); + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_SUCCESS (Status)) + { + *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer; + } + + return (Status); + } + + return (AE_NOT_FOUND); } +ACPI_EXPORT_SYMBOL (AcpiGetTable) + /******************************************************************************* * - * FUNCTION: AcpiGetTableHeader + * FUNCTION: AcpiGetTableByIndex * - * PARAMETERS: TableType - one of the defined table types - * Instance - the non zero instance of the table, allows - * support for multiple tables of the same type - * see AcpiGbl_AcpiTableFlag - * OutTableHeader - pointer to the ACPI_TABLE_HEADER if successful + * PARAMETERS: TableIndex - Table index + * Table - Where the pointer to the table is returned * - * DESCRIPTION: This function is called to get an ACPI table header. The caller - * supplies an pointer to a data area sufficient to contain an ACPI - * ACPI_TABLE_HEADER structure. + * RETURN: Status and pointer to the table * - * The header contains a length field that can be used to determine - * the size of the buffer needed to contain the entire table. This - * function is not valid for the RSD PTR table since it does not - * have a standard header and is fixed length. + * DESCRIPTION: Obtain a table by an index into the global table list. * ******************************************************************************/ ACPI_STATUS -AcpiGetTableHeader ( - ACPI_TABLE_TYPE TableType, - UINT32 Instance, - ACPI_TABLE_HEADER *OutTableHeader) +AcpiGetTableByIndex ( + ACPI_NATIVE_UINT TableIndex, + ACPI_TABLE_HEADER **Table) { - ACPI_TABLE_HEADER *TblPtr; ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiGetTableHeader"); + ACPI_FUNCTION_TRACE (AcpiGetTableByIndex); + + /* Parameter validation */ - if ((Instance == 0) || - (TableType == ACPI_TABLE_RSDP) || - (!OutTableHeader)) + if (!Table) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Check the table type and instance */ + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Validate index */ - if ((TableType > ACPI_TABLE_MAX) || - (ACPI_IS_SINGLE_TABLE (AcpiGbl_TableData[TableType].Flags) && - Instance > 1)) + if (TableIndex >= AcpiGbl_RootTableList.Count) { + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get a pointer to the entire table */ - - Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); - if (ACPI_FAILURE (Status)) + if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer) { - return_ACPI_STATUS (Status); - } - - /* The function will return a NULL pointer if the table is not loaded */ + /* Table is not mapped, map it */ - if (TblPtr == NULL) - { - return_ACPI_STATUS (AE_NOT_EXIST); + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + if (ACPI_FAILURE (Status)) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); + } } - /* Copy the header to the caller's buffer */ - - ACPI_MEMCPY ((void *) OutTableHeader, (void *) TblPtr, - sizeof (ACPI_TABLE_HEADER)); - - return_ACPI_STATUS (Status); + *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) + /******************************************************************************* * - * FUNCTION: AcpiGetTable + * FUNCTION: AcpiTbLoadNamespace * - * PARAMETERS: TableType - one of the defined table types - * Instance - the non zero instance of the table, allows - * support for multiple tables of the same type - * see AcpiGbl_AcpiTableFlag - * RetBuffer - pointer to a structure containing a buffer to - * receive the table + * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: This function is called to get an ACPI table. The caller - * supplies an OutBuffer large enough to contain the entire ACPI - * table. The caller should call the AcpiGetTableHeader function - * first to determine the buffer size needed. Upon completion - * the OutBuffer->Length field will indicate the number of bytes - * copied into the OutBuffer->BufPtr buffer. This table will be - * a complete table including the header. + * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in + * the RSDT/XSDT. * ******************************************************************************/ -ACPI_STATUS -AcpiGetTable ( - ACPI_TABLE_TYPE TableType, - UINT32 Instance, - ACPI_BUFFER *RetBuffer) +static ACPI_STATUS +AcpiTbLoadNamespace ( + void) { - ACPI_TABLE_HEADER *TblPtr; ACPI_STATUS Status; - ACPI_SIZE TableLength; + ACPI_TABLE_HEADER *Table; + ACPI_NATIVE_UINT i; + BOOLEAN DsdtOverriden; - ACPI_FUNCTION_TRACE ("AcpiGetTable"); + ACPI_FUNCTION_TRACE (TbLoadNamespace); - /* Parameter validation */ + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (Instance == 0) + /* + * Load the namespace. The DSDT is required, but any SSDT and PSDT tables + * are optional. + */ + if (!AcpiGbl_RootTableList.Count || + ACPI_STRNCMP ((const char *)&(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), + ACPI_SIG_DSDT, 4) || + ACPI_FAILURE (AcpiTbVerifyTable(&AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + Status = AE_NO_ACPI_TABLES; + goto UnlockAndExit; } - Status = AcpiUtValidateBuffer (RetBuffer); - if (ACPI_FAILURE (Status)) + /* + * Find DSDT table + */ + DsdtOverriden = FALSE; + Status = AcpiOsTableOverride ( + AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer, &Table); + if (ACPI_SUCCESS (Status) && Table) { - return_ACPI_STATUS (Status); + /* + * DSDT table has been found + */ + AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); + AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer = Table; + AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Length = Table->Length; + AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Flags = ACPI_TABLE_ORIGIN_UNKNOWN; + DsdtOverriden = TRUE; + + ACPI_INFO ((AE_INFO, "Table DSDT replaced by host OS")); + AcpiTbPrintTableHeader (0, Table); } - /* Check the table type and instance */ - - if ((TableType > ACPI_TABLE_MAX) || - (ACPI_IS_SINGLE_TABLE (AcpiGbl_TableData[TableType].Flags) && - Instance > 1)) + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); + if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + /* A valid DSDT is required */ + + Status = AE_NO_ACPI_TABLES; + goto UnlockAndExit; } - /* Get a pointer to the entire table */ + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); + /* + * Load and parse tables. + */ + Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* - * AcpiTbGetTablePtr will return a NULL pointer if the - * table is not loaded. + * Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ - if (TblPtr == NULL) + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + for (i = 2; i < AcpiGbl_RootTableList.Count; ++i) { - return_ACPI_STATUS (AE_NOT_EXIST); - } + if ((ACPI_STRNCMP ((const char *)&(AcpiGbl_RootTableList.Tables[i].Signature), + ACPI_SIG_SSDT, 4) && + ACPI_STRNCMP ((const char *)&(AcpiGbl_RootTableList.Tables[i].Signature), + ACPI_SIG_PSDT, 4)) || + ACPI_FAILURE (AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]))) + { + continue; + } - /* Get the table length */ + /* Delete SSDT when DSDT is overriden */ - if (TableType == ACPI_TABLE_RSDP) - { - /* RSD PTR is the only "table" without a header */ + if (!ACPI_STRNCMP ((const char *)&(AcpiGbl_RootTableList.Tables[i].Signature), + ACPI_SIG_SSDT, 4) && DsdtOverriden) + { + AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); + continue; + } - TableLength = sizeof (RSDP_DESCRIPTOR); - } - else - { - TableLength = (ACPI_SIZE) TblPtr->Length; + /* Ignore errors while loading tables, get as many as possible */ + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + (void) AcpiNsLoadTable (i, AcpiGbl_RootNode); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); } - /* Validate/Allocate/Clear caller buffer */ + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + - Status = AcpiUtInitializeBuffer (RetBuffer, TableLength); +/******************************************************************************* + * + * FUNCTION: AcpiLoadTables + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLoadTables ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiLoadTables); + + + /* + * Load the namespace from the tables + */ + Status = AcpiTbLoadNamespace (); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + ACPI_EXCEPTION ((AE_INFO, Status, "While loading namespace from ACPI tables")); } - /* Copy the table to the buffer */ - - ACPI_MEMCPY ((void *) RetBuffer->Pointer, (void *) TblPtr, TableLength); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiLoadTables) diff --git a/sys/dist/acpica/tbxfroot.c b/sys/dist/acpica/tbxfroot.c index ef2205a5537..03220f8da36 100644 --- a/sys/dist/acpica/tbxfroot.c +++ b/sys/dist/acpica/tbxfroot.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbxfroot - Find the root ACPI table (RSDT) - * xRevision: 1.94 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbxfroot.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __TBXFROOT_C__ -#include "acpi.h" -#include "actables.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_TABLES @@ -128,22 +125,21 @@ __KERNEL_RCSID(0, "$NetBSD: tbxfroot.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); /* Local prototypes */ -static ACPI_STATUS -AcpiTbFindRsdp ( - ACPI_TABLE_DESC *TableInfo, - UINT32 Flags); - static UINT8 * AcpiTbScanMemoryForRsdp ( UINT8 *StartAddress, UINT32 Length); +static ACPI_STATUS +AcpiTbValidateRsdp ( + ACPI_TABLE_RSDP *Rsdp); + /******************************************************************************* * * FUNCTION: AcpiTbValidateRsdp * - * PARAMETERS: Rsdp - Pointer to unvalidated RSDP + * PARAMETERS: Rsdp - Pointer to unvalidated RSDP * * RETURN: Status * @@ -151,17 +147,20 @@ AcpiTbScanMemoryForRsdp ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbValidateRsdp ( - RSDP_DESCRIPTOR *Rsdp) + ACPI_TABLE_RSDP *Rsdp) { ACPI_FUNCTION_ENTRY (); /* - * The signature and checksum must both be correct + * The signature and checksum must both be correct + * + * Note: Sometimes there exists more than one RSDP in memory; the valid + * RSDP has a valid checksum, all others have an invalid checksum. */ - if (ACPI_STRNCMP ((char *) Rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) + if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP, sizeof (ACPI_SIG_RSDP)-1) != 0) { /* Nope, BAD Signature */ @@ -170,7 +169,7 @@ AcpiTbValidateRsdp ( /* Check the standard checksum */ - if (AcpiTbGenerateChecksum (Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { return (AE_BAD_CHECKSUM); } @@ -178,7 +177,7 @@ AcpiTbValidateRsdp ( /* Check extended checksum if table version >= 2 */ if ((Rsdp->Revision >= 2) && - (AcpiTbGenerateChecksum (Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) + (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) { return (AE_BAD_CHECKSUM); } @@ -189,355 +188,129 @@ AcpiTbValidateRsdp ( /******************************************************************************* * - * FUNCTION: AcpiTbFindTable - * - * PARAMETERS: Signature - String with ACPI table signature - * OemId - String with the table OEM ID - * OemTableId - String with the OEM Table ID - * TablePtr - Where the table pointer is returned - * - * RETURN: Status - * - * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the - * Signature, OEM ID and OEM Table ID. + * FUNCTION: AcpiTbFindRsdp * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbFindTable ( - char *Signature, - char *OemId, - char *OemTableId, - ACPI_TABLE_HEADER **TablePtr) -{ - ACPI_STATUS Status; - ACPI_TABLE_HEADER *Table; - - - ACPI_FUNCTION_TRACE ("TbFindTable"); - - - /* Validate string lengths */ - - if ((ACPI_STRLEN (Signature) > ACPI_NAME_SIZE) || - (ACPI_STRLEN (OemId) > sizeof (Table->OemId)) || - (ACPI_STRLEN (OemTableId) > sizeof (Table->OemTableId))) - { - return_ACPI_STATUS (AE_AML_STRING_LIMIT); - } - - if (!ACPI_STRNCMP (Signature, DSDT_SIG, ACPI_NAME_SIZE)) - { - /* - * The DSDT pointer is contained in the FADT, not the RSDT. - * This code should suffice, because the only code that would perform - * a "find" on the DSDT is the DataTableRegion() AML opcode -- in - * which case, the DSDT is guaranteed to be already loaded. - * If this becomes insufficient, the FADT will have to be found first. - */ - if (!AcpiGbl_DSDT) - { - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - Table = AcpiGbl_DSDT; - } - else - { - /* Find the table */ - - Status = AcpiGetFirmwareTable (Signature, 1, - ACPI_LOGICAL_ADDRESSING, &Table); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Check OemId and OemTableId */ - - if ((OemId[0] && ACPI_STRNCMP ( - OemId, Table->OemId, - sizeof (Table->OemId))) || - - (OemTableId[0] && ACPI_STRNCMP ( - OemTableId, Table->OemTableId, - sizeof (Table->OemTableId)))) - { - return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", - Table->Signature)); - - *TablePtr = Table; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* + * PARAMETERS: TableAddress - Where the table pointer is returned * - * FUNCTION: AcpiGetFirmwareTable + * RETURN: Status, RSDP physical address * - * PARAMETERS: Signature - Any ACPI table signature - * Instance - the non zero instance of the table, allows - * support for multiple tables of the same type - * Flags - Physical/Virtual support - * TablePointer - Where a buffer containing the table is - * returned + * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor + * pointer structure. If it is found, set *RSDP to point to it. * - * RETURN: Status + * NOTE1: The RSDP must be either in the first 1K of the Extended + * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) + * Only a 32-bit physical address is necessary. * - * DESCRIPTION: This function is called to get an ACPI table. A buffer is - * allocated for the table and returned in TablePointer. - * This table will be a complete table including the header. + * NOTE2: This function is always available, regardless of the + * initialization state of the rest of ACPI. * ******************************************************************************/ ACPI_STATUS -AcpiGetFirmwareTable ( - ACPI_CONST_STRING Signature, - UINT32 Instance, - UINT32 Flags, - ACPI_TABLE_HEADER **TablePointer) +AcpiFindRootPointer ( + ACPI_NATIVE_UINT *TableAddress) { - ACPI_STATUS Status; - ACPI_POINTER Address; - ACPI_TABLE_HEADER *Header = NULL; - ACPI_TABLE_DESC *TableInfo = NULL; - ACPI_TABLE_DESC *RsdtInfo; - UINT32 TableCount; - UINT32 i; - UINT32 j; - + UINT8 *TablePtr; + UINT8 *MemRover; + UINT32 PhysicalAddress; - ACPI_FUNCTION_TRACE ("AcpiGetFirmwareTable"); + ACPI_FUNCTION_TRACE (AcpiFindRootPointer); - /* - * Ensure that at least the table manager is initialized. We don't - * require that the entire ACPI subsystem is up for this interface. - * If we have a buffer, we must have a length too - */ - if ((Instance == 0) || - (!Signature) || - (!TablePointer)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - /* Ensure that we have a RSDP */ + /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ - if (!AcpiGbl_RSDP) + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH); + if (!TablePtr) { - /* Get the RSDP */ + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); - Status = AcpiOsGetRootPointer (Flags, &Address); - if (ACPI_FAILURE (Status)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - - /* Map and validate the RSDP */ - - if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) - { - Status = AcpiOsMapMemory (Address.Pointer.Physical, - sizeof (RSDP_DESCRIPTOR), (void *) &AcpiGbl_RSDP); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - else - { - AcpiGbl_RSDP = Address.Pointer.Logical; - } - - /* The RDSP signature and checksum must both be correct */ - - Status = AcpiTbValidateRsdp (AcpiGbl_RSDP); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - /* Get the RSDT address via the RSDP */ - - AcpiTbGetRsdtAddress (&Address); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "RSDP located at %p, RSDT physical=%8.8X%8.8X\n", - AcpiGbl_RSDP, - ACPI_FORMAT_UINT64 (Address.Pointer.Value))); - - /* Insert ProcessorMode flags */ - - Address.PointerType |= Flags; - - /* Get and validate the RSDT */ - - RsdtInfo = ACPI_MEM_CALLOCATE (sizeof (ACPI_TABLE_DESC)); - if (!RsdtInfo) - { return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiTbGetTable (&Address, RsdtInfo); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - Status = AcpiTbValidateRsdt (RsdtInfo->Pointer); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* Allocate a scratch table header and table descriptor */ - - Header = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); - if (!Header) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } + ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr); - TableInfo = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_DESC)); - if (!TableInfo) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } + /* Convert segment part to physical address */ - /* Get the number of table pointers within the RSDT */ + PhysicalAddress <<= 4; + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH); - TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtInfo->Pointer); - Address.PointerType = AcpiGbl_TableFlags | Flags; + /* EBDA present? */ - /* - * Search the RSDT/XSDT for the correct instance of the - * requested table - */ - for (i = 0, j = 0; i < TableCount; i++) + if (PhysicalAddress > 0x400) { /* - * Get the next table pointer, handle RSDT vs. XSDT - * RSDT pointers are 32 bits, XSDT pointers are 64 bits + * 1b) Search EBDA paragraphs (EBDA is required to be a + * minimum of 1K length) */ - if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) - { - Address.Pointer.Value = (ACPI_CAST_PTR ( - RSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]; - } - else + TablePtr = AcpiOsMapMemory ( + (ACPI_NATIVE_UINT) PhysicalAddress, + ACPI_EBDA_WINDOW_SIZE); + if (!TablePtr) { - Address.Pointer.Value = ACPI_GET_ADDRESS ((ACPI_CAST_PTR ( - XSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]); + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); + + return_ACPI_STATUS (AE_NO_MEMORY); } - /* Get the table header */ + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE); + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); - Status = AcpiTbGetTableHeader (&Address, Header); - if (ACPI_FAILURE (Status)) + if (MemRover) { - goto Cleanup; - } + /* Return the physical address */ - /* Compare table signatures and table instance */ + PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr); - if (!ACPI_STRNCMP (Header->Signature, Signature, ACPI_NAME_SIZE)) - { - /* An instance of the table was found */ - - j++; - if (j >= Instance) - { - /* Found the correct instance, get the entire table */ - - Status = AcpiTbGetTableBody (&Address, Header, TableInfo); - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - *TablePointer = TableInfo->Pointer; - goto Cleanup; - } + *TableAddress = PhysicalAddress; + return_ACPI_STATUS (AE_OK); } } - /* Did not find the table */ - - Status = AE_NOT_EXIST; - + /* + * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh + */ + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE); -Cleanup: - if (RsdtInfo->Pointer) + if (!TablePtr) { - AcpiOsUnmapMemory (RsdtInfo->Pointer, - (ACPI_SIZE) RsdtInfo->Pointer->Length); - } - ACPI_MEM_FREE (RsdtInfo); + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); - if (Header) - { - ACPI_MEM_FREE (Header); - } - if (TableInfo) - { - ACPI_MEM_FREE (TableInfo); + return_ACPI_STATUS (AE_NO_MEMORY); } - return_ACPI_STATUS (Status); -} + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); + AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); -/* TBD: Move to a new file */ - -#if ACPI_MACHINE_WIDTH != 16 - -/******************************************************************************* - * - * FUNCTION: AcpiFindRootPointer - * - * PARAMETERS: Flags - Logical/Physical addressing - * RsdpAddress - Where to place the RSDP address - * - * RETURN: Status, Physical address of the RSDP - * - * DESCRIPTION: Find the RSDP - * - ******************************************************************************/ - -ACPI_STATUS -AcpiFindRootPointer ( - UINT32 Flags, - ACPI_POINTER *RsdpAddress) -{ - ACPI_TABLE_DESC TableInfo; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE ("AcpiFindRootPointer"); - - - /* Get the RSDP */ - - Status = AcpiTbFindRsdp (&TableInfo, Flags); - if (ACPI_FAILURE (Status)) + if (MemRover) { - ACPI_EXCEPTION ((AE_INFO, Status, - "RSDP structure not found - Flags=%X", Flags)); + /* Return the physical address */ + + PhysicalAddress = (UINT32) + (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr)); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); + *TableAddress = PhysicalAddress; + return_ACPI_STATUS (AE_OK); } - RsdpAddress->PointerType = ACPI_PHYSICAL_POINTER; - RsdpAddress->Pointer.Physical = TableInfo.PhysicalAddress; - return_ACPI_STATUS (AE_OK); + /* A valid RSDP was not found */ + + ACPI_ERROR ((AE_INFO, "A valid RSDP was not found")); + return_ACPI_STATUS (AE_NOT_FOUND); } +ACPI_EXPORT_SYMBOL (AcpiFindRootPointer) + /******************************************************************************* * @@ -562,7 +335,7 @@ AcpiTbScanMemoryForRsdp ( UINT8 *EndAddress; - ACPI_FUNCTION_TRACE ("TbScanMemoryForRsdp"); + ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp); EndAddress = StartAddress + Length; @@ -574,7 +347,7 @@ AcpiTbScanMemoryForRsdp ( { /* The RSDP signature and checksum must both be correct */ - Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (RSDP_DESCRIPTOR, MemRover)); + Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover)); if (ACPI_SUCCESS (Status)) { /* Sig and checksum valid, we have found a real RSDP */ @@ -595,186 +368,3 @@ AcpiTbScanMemoryForRsdp ( return_PTR (NULL); } - -/******************************************************************************* - * - * FUNCTION: AcpiTbFindRsdp - * - * PARAMETERS: TableInfo - Where the table info is returned - * Flags - Current memory mode (logical vs. - * physical addressing) - * - * RETURN: Status, RSDP physical address - * - * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor - * pointer structure. If it is found, set *RSDP to point to it. - * - * NOTE1: The RSDP must be either in the first 1K of the Extended - * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) - * Only a 32-bit physical address is necessary. - * - * NOTE2: This function is always available, regardless of the - * initialization state of the rest of ACPI. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiTbFindRsdp ( - ACPI_TABLE_DESC *TableInfo, - UINT32 Flags) -{ - UINT8 *TablePtr; - UINT8 *MemRover; - UINT32 PhysicalAddress; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE ("TbFindRsdp"); - - - /* - * Scan supports either logical addressing or physical addressing - */ - if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) - { - /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ - - Status = AcpiOsMapMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, - ACPI_EBDA_PTR_LENGTH, (void *) &TablePtr); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not map memory at %8.8X for length %X", - ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); - - return_ACPI_STATUS (Status); - } - - ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr); - - /* Convert segment part to physical address */ - - PhysicalAddress <<= 4; - AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH); - - /* EBDA present? */ - - if (PhysicalAddress > 0x400) - { - /* - * 1b) Search EBDA paragraphs (EBDA is required to be a - * minimum of 1K length) - */ - Status = AcpiOsMapMemory ( - (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, - ACPI_EBDA_WINDOW_SIZE, (void *) &TablePtr); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not map memory at %8.8X for length %X", - PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); - - return_ACPI_STATUS (Status); - } - - MemRover = AcpiTbScanMemoryForRsdp (TablePtr, - ACPI_EBDA_WINDOW_SIZE); - AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); - - if (MemRover) - { - /* Return the physical address */ - - PhysicalAddress += ACPI_PTR_DIFF (MemRover, TablePtr); - - TableInfo->PhysicalAddress = - (ACPI_PHYSICAL_ADDRESS) PhysicalAddress; - return_ACPI_STATUS (AE_OK); - } - } - - /* - * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh - */ - Status = AcpiOsMapMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, - ACPI_HI_RSDP_WINDOW_SIZE, (void *) &TablePtr); - - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not map memory at %8.8X for length %X", - ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); - - return_ACPI_STATUS (Status); - } - - MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); - AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); - - if (MemRover) - { - /* Return the physical address */ - - PhysicalAddress = - ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr); - - TableInfo->PhysicalAddress = - (ACPI_PHYSICAL_ADDRESS) PhysicalAddress; - return_ACPI_STATUS (AE_OK); - } - } - - /* - * Physical addressing - */ - else - { - /* 1a) Get the location of the EBDA */ - - ACPI_MOVE_16_TO_32 (&PhysicalAddress, ACPI_EBDA_PTR_LOCATION); - PhysicalAddress <<= 4; /* Convert segment to physical address */ - - /* EBDA present? */ - - if (PhysicalAddress > 0x400) - { - /* - * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of - * 1K length) - */ - MemRover = AcpiTbScanMemoryForRsdp ( - ACPI_PHYSADDR_TO_PTR (PhysicalAddress), - ACPI_EBDA_WINDOW_SIZE); - if (MemRover) - { - /* Return the physical address */ - - TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover); - return_ACPI_STATUS (AE_OK); - } - } - - /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ - - MemRover = AcpiTbScanMemoryForRsdp ( - ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), - ACPI_HI_RSDP_WINDOW_SIZE); - if (MemRover) - { - /* Found it, return the physical address */ - - TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover); - return_ACPI_STATUS (AE_OK); - } - } - - /* A valid RSDP was not found */ - - ACPI_ERROR ((AE_INFO, "No valid RSDP was found")); - return_ACPI_STATUS (AE_NOT_FOUND); -} - -#endif - diff --git a/sys/dist/acpica/utalloc.c b/sys/dist/acpica/utalloc.c index d5dbcd399c7..482b780ef9a 100644 --- a/sys/dist/acpica/utalloc.c +++ b/sys/dist/acpica/utalloc.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utalloc - local memory allocation routines - * xRevision: 1.154 $ + * $Revision: 1.5 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,47 +114,14 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utalloc.c,v 1.4 2006/11/16 01:33:31 christos Exp $"); - #define __UTALLOC_C__ -#include "acpi.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acdebug.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utalloc") -/* Local prototypes */ - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - -static ACPI_DEBUG_MEM_BLOCK * -AcpiUtFindAllocation ( - void *Allocation); - -static ACPI_STATUS -AcpiUtTrackAllocation ( - ACPI_DEBUG_MEM_BLOCK *Address, - ACPI_SIZE Size, - UINT8 AllocType, - UINT32 Component, - const char *Module, - UINT32 Line); - -static ACPI_STATUS -AcpiUtRemoveAllocation ( - ACPI_DEBUG_MEM_BLOCK *Address, - UINT32 Component, - const char *Module, - UINT32 Line); - -static ACPI_STATUS -AcpiUtCreateList ( - const char *ListName, - UINT16 ObjectSize, - ACPI_MEMORY_LIST **ReturnCache); -#endif - /******************************************************************************* * @@ -175,26 +142,14 @@ AcpiUtCreateCaches ( ACPI_STATUS Status; -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - - /* Memory allocation lists */ - - Status = AcpiUtCreateList ("Acpi-Global", 0, - &AcpiGbl_GlobalList); - if (ACPI_FAILURE (Status)) - { - return (Status); - } + /* Object Caches, for frequently used objects */ - Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), - &AcpiGbl_NsNodeList); + Status = AcpiOsCreateCache ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), + ACPI_MAX_NAMESPACE_CACHE_DEPTH, &AcpiGbl_NamespaceCache); if (ACPI_FAILURE (Status)) { return (Status); } -#endif - - /* Object Caches, for frequently used objects */ Status = AcpiOsCreateCache ("Acpi-State", sizeof (ACPI_GENERIC_STATE), ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache); @@ -224,6 +179,26 @@ AcpiUtCreateCaches ( return (Status); } + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Memory allocation lists */ + + Status = AcpiUtCreateList ("Acpi-Global", 0, + &AcpiGbl_GlobalList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), + &AcpiGbl_NsNodeList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } +#endif + return (AE_OK); } @@ -244,6 +219,18 @@ ACPI_STATUS AcpiUtDeleteCaches ( void) { +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + char Buffer[7]; + + if (AcpiGbl_DisplayFinalMemStats) + { + ACPI_STRCPY (Buffer, "MEMORY"); + AcpiDbDisplayStatistics (Buffer); + } +#endif + + (void) AcpiOsDeleteCache (AcpiGbl_NamespaceCache); + AcpiGbl_NamespaceCache = NULL; (void) AcpiOsDeleteCache (AcpiGbl_StateCache); AcpiGbl_StateCache = NULL; @@ -257,6 +244,22 @@ AcpiUtDeleteCaches ( (void) AcpiOsDeleteCache (AcpiGbl_PsNodeExtCache); AcpiGbl_PsNodeExtCache = NULL; + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Debug only - display leftover memory allocation, if any */ + + AcpiUtDumpAllocations (ACPI_UINT32_MAX, NULL); + + /* Free memory lists */ + + AcpiOsFree (AcpiGbl_GlobalList); + AcpiGbl_GlobalList = NULL; + + AcpiOsFree (AcpiGbl_NsNodeList); + AcpiGbl_NsNodeList = NULL; +#endif + return (AE_OK); } @@ -357,7 +360,7 @@ AcpiUtInitializeBuffer ( /* Allocate a new buffer with local interface to allow tracking */ - Buffer->Pointer = ACPI_MEM_CALLOCATE (RequiredLength); + Buffer->Pointer = ACPI_ALLOCATE_ZEROED (RequiredLength); if (!Buffer->Pointer) { return (AE_NO_MEMORY); @@ -397,7 +400,7 @@ AcpiUtInitializeBuffer ( * * RETURN: Address of the allocated memory on success, NULL on failure. * - * DESCRIPTION: The subsystem's equivalent of malloc. + * DESCRIPTION: Subsystem equivalent of malloc. * ******************************************************************************/ @@ -411,66 +414,14 @@ AcpiUtAllocate ( void *Allocation; - ACPI_FUNCTION_TRACE_U32 ("UtAllocate", Size); - - - /* Check for an inadvertent size of zero bytes */ - - if (!Size) - { - ACPI_ERROR ((Module, Line, - "UtAllocate: Attempt to allocate zero bytes, allocating 1 byte")); - Size = 1; - } - - Allocation = AcpiOsAllocate (Size); - if (!Allocation) - { - /* Report allocation error */ - - ACPI_ERROR ((Module, Line, - "UtAllocate: Could not allocate size %X", (UINT32) Size)); - - return_PTR (NULL); - } - - return_PTR (Allocation); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCallocate - * - * PARAMETERS: Size - Size of the allocation - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: Address of the allocated memory on success, NULL on failure. - * - * DESCRIPTION: Subsystem equivalent of calloc. - * - ******************************************************************************/ - -void * -AcpiUtCallocate ( - ACPI_SIZE Size, - UINT32 Component, - const char *Module, - UINT32 Line) -{ - void *Allocation; - - - ACPI_FUNCTION_TRACE_U32 ("UtCallocate", Size); + ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size); /* Check for an inadvertent size of zero bytes */ if (!Size) { - ACPI_ERROR ((Module, Line, + ACPI_WARNING ((Module, Line, "Attempt to allocate zero bytes, allocating 1 byte")); Size = 1; } @@ -480,120 +431,19 @@ AcpiUtCallocate ( { /* Report allocation error */ - ACPI_ERROR ((Module, Line, + ACPI_WARNING ((Module, Line, "Could not allocate size %X", (UINT32) Size)); + return_PTR (NULL); } - /* Clear the memory block */ - - ACPI_MEMSET (Allocation, 0, Size); return_PTR (Allocation); } -#ifdef ACPI_DBG_TRACK_ALLOCATIONS -/* - * These procedures are used for tracking memory leaks in the subsystem, and - * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set. - * - * Each memory allocation is tracked via a doubly linked list. Each - * element contains the caller's component, module name, function name, and - * line number. AcpiUtAllocate and AcpiUtCallocate call - * AcpiUtTrackAllocation to add an element to the list; deletion - * occurs in the body of AcpiUtFree. - */ - -/******************************************************************************* - * - * FUNCTION: AcpiUtCreateList - * - * PARAMETERS: CacheName - Ascii name for the cache - * ObjectSize - Size of each cached object - * ReturnCache - Where the new cache object is returned - * - * RETURN: Status - * - * DESCRIPTION: Create a local memory list for tracking purposed - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiUtCreateList ( - const char *ListName, - UINT16 ObjectSize, - ACPI_MEMORY_LIST **ReturnCache) -{ - ACPI_MEMORY_LIST *Cache; - - - Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); - if (!Cache) - { - return (AE_NO_MEMORY); - } - - ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); - - Cache->ListName = ListName; - Cache->ObjectSize = ObjectSize; - - *ReturnCache = Cache; - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtAllocateAndTrack - * - * PARAMETERS: Size - Size of the allocation - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: Address of the allocated memory on success, NULL on failure. - * - * DESCRIPTION: The subsystem's equivalent of malloc. - * - ******************************************************************************/ - -void * -AcpiUtAllocateAndTrack ( - ACPI_SIZE Size, - UINT32 Component, - const char *Module, - UINT32 Line) -{ - ACPI_DEBUG_MEM_BLOCK *Allocation; - ACPI_STATUS Status; - - - Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), - Component, Module, Line); - if (!Allocation) - { - return (NULL); - } - - Status = AcpiUtTrackAllocation (Allocation, Size, - ACPI_MEM_MALLOC, Component, Module, Line); - if (ACPI_FAILURE (Status)) - { - AcpiOsFree (Allocation); - return (NULL); - } - - AcpiGbl_GlobalList->TotalAllocated++; - AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; - - return ((void *) &Allocation->UserSpace); -} - - /******************************************************************************* * - * FUNCTION: AcpiUtCallocateAndTrack + * FUNCTION: AcpiUtAllocateZeroed * * PARAMETERS: Size - Size of the allocation * Component - Component type of caller @@ -602,462 +452,31 @@ AcpiUtAllocateAndTrack ( * * RETURN: Address of the allocated memory on success, NULL on failure. * - * DESCRIPTION: Subsystem equivalent of calloc. + * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory. * ******************************************************************************/ void * -AcpiUtCallocateAndTrack ( +AcpiUtAllocateZeroed ( ACPI_SIZE Size, UINT32 Component, const char *Module, UINT32 Line) { - ACPI_DEBUG_MEM_BLOCK *Allocation; - ACPI_STATUS Status; - - - Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), - Component, Module, Line); - if (!Allocation) - { - /* Report allocation error */ - - ACPI_ERROR ((Module, Line, - "Could not allocate size %X", (UINT32) Size)); - return (NULL); - } - - Status = AcpiUtTrackAllocation (Allocation, Size, - ACPI_MEM_CALLOC, Component, Module, Line); - if (ACPI_FAILURE (Status)) - { - AcpiOsFree (Allocation); - return (NULL); - } - - AcpiGbl_GlobalList->TotalAllocated++; - AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; - - return ((void *) &Allocation->UserSpace); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtFreeAndTrack - * - * PARAMETERS: Allocation - Address of the memory to deallocate - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: None - * - * DESCRIPTION: Frees the memory at Allocation - * - ******************************************************************************/ - -void -AcpiUtFreeAndTrack ( - void *Allocation, - UINT32 Component, - const char *Module, - UINT32 Line) -{ - ACPI_DEBUG_MEM_BLOCK *DebugBlock; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR ("UtFree", Allocation); - - - if (NULL == Allocation) - { - ACPI_ERROR ((Module, Line, - "Attempt to delete a NULL address")); - - return_VOID; - } - - DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, - (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); - - AcpiGbl_GlobalList->TotalFreed++; - AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size; - - Status = AcpiUtRemoveAllocation (DebugBlock, - Component, Module, Line); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory")); - } - - AcpiOsFree (DebugBlock); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation)); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtFindAllocation - * - * PARAMETERS: Allocation - Address of allocated memory - * - * RETURN: A list element if found; NULL otherwise. - * - * DESCRIPTION: Searches for an element in the global allocation tracking list. - * - ******************************************************************************/ - -static ACPI_DEBUG_MEM_BLOCK * -AcpiUtFindAllocation ( - void *Allocation) -{ - ACPI_DEBUG_MEM_BLOCK *Element; + void *Allocation; ACPI_FUNCTION_ENTRY (); - Element = AcpiGbl_GlobalList->ListHead; - - /* Search for the address. */ - - while (Element) + Allocation = AcpiUtAllocate (Size, Component, Module, Line); + if (Allocation) { - if (Element == Allocation) - { - return (Element); - } + /* Clear the memory block */ - Element = Element->Next; + ACPI_MEMSET (Allocation, 0, Size); } - return (NULL); + return (Allocation); } - -/******************************************************************************* - * - * FUNCTION: AcpiUtTrackAllocation - * - * PARAMETERS: Allocation - Address of allocated memory - * Size - Size of the allocation - * AllocType - MEM_MALLOC or MEM_CALLOC - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: None. - * - * DESCRIPTION: Inserts an element into the global allocation tracking list. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiUtTrackAllocation ( - ACPI_DEBUG_MEM_BLOCK *Allocation, - ACPI_SIZE Size, - UINT8 AllocType, - UINT32 Component, - const char *Module, - UINT32 Line) -{ - ACPI_MEMORY_LIST *MemList; - ACPI_DEBUG_MEM_BLOCK *Element; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE_PTR ("UtTrackAllocation", Allocation); - - - MemList = AcpiGbl_GlobalList; - Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* - * Search list for this address to make sure it is not already on the list. - * This will catch several kinds of problems. - */ - Element = AcpiUtFindAllocation (Allocation); - if (Element) - { - ACPI_ERROR ((AE_INFO, - "UtTrackAllocation: Allocation already present in list! (%p)", - Allocation)); - - ACPI_ERROR ((AE_INFO, "Element %p Address %p", - Element, Allocation)); - - goto UnlockAndExit; - } - - /* Fill in the instance data. */ - - Allocation->Size = (UINT32) Size; - Allocation->AllocType = AllocType; - Allocation->Component = Component; - Allocation->Line = Line; - - ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); - Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; - - /* Insert at list head */ - - if (MemList->ListHead) - { - ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation; - } - - Allocation->Next = MemList->ListHead; - Allocation->Previous = NULL; - - MemList->ListHead = Allocation; - - -UnlockAndExit: - Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtRemoveAllocation - * - * PARAMETERS: Allocation - Address of allocated memory - * Component - Component type of caller - * Module - Source file name of caller - * Line - Line number of caller - * - * RETURN: - * - * DESCRIPTION: Deletes an element from the global allocation tracking list. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiUtRemoveAllocation ( - ACPI_DEBUG_MEM_BLOCK *Allocation, - UINT32 Component, - const char *Module, - UINT32 Line) -{ - ACPI_MEMORY_LIST *MemList; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE ("UtRemoveAllocation"); - - - MemList = AcpiGbl_GlobalList; - if (NULL == MemList->ListHead) - { - /* No allocations! */ - - ACPI_ERROR ((Module, Line, - "Empty allocation list, nothing to free!")); - - return_ACPI_STATUS (AE_OK); - } - - Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Unlink */ - - if (Allocation->Previous) - { - (Allocation->Previous)->Next = Allocation->Next; - } - else - { - MemList->ListHead = Allocation->Next; - } - - if (Allocation->Next) - { - (Allocation->Next)->Previous = Allocation->Previous; - } - - /* Mark the segment as deleted */ - - ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); - - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", - Allocation->Size)); - - Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtDumpAllocationInfo - * - * PARAMETERS: - * - * RETURN: None - * - * DESCRIPTION: Print some info about the outstanding allocations. - * - ******************************************************************************/ - -void -AcpiUtDumpAllocationInfo ( - void) -{ -/* - ACPI_MEMORY_LIST *MemList; -*/ - - ACPI_FUNCTION_TRACE ("UtDumpAllocationInfo"); - -/* - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Current allocations", - MemList->CurrentCount, - ROUND_UP_TO_1K (MemList->CurrentSize))); - - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", - MemList->MaxConcurrentCount, - ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); - - - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", - RunningObjectCount, - ROUND_UP_TO_1K (RunningObjectSize))); - - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", - RunningAllocCount, - ROUND_UP_TO_1K (RunningAllocSize))); - - - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Current Nodes", - AcpiGbl_CurrentNodeCount, - ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); - - ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, - ("%30s: %4d (%3d Kb)\n", "Max Nodes", - AcpiGbl_MaxConcurrentNodeCount, - ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * - sizeof (ACPI_NAMESPACE_NODE))))); -*/ - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtDumpAllocations - * - * PARAMETERS: Component - Component(s) to dump info for. - * Module - Module to dump info for. NULL means all. - * - * RETURN: None - * - * DESCRIPTION: Print a list of all outstanding allocations. - * - ******************************************************************************/ - -void -AcpiUtDumpAllocations ( - UINT32 Component, - const char *Module) -{ - ACPI_DEBUG_MEM_BLOCK *Element; - ACPI_DESCRIPTOR *Descriptor; - UINT32 NumOutstanding = 0; - - - ACPI_FUNCTION_TRACE ("UtDumpAllocations"); - - - /* - * Walk the allocation list. - */ - if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY))) - { - return; - } - - Element = AcpiGbl_GlobalList->ListHead; - while (Element) - { - if ((Element->Component & Component) && - ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) - { - /* Ignore allocated objects that are in a cache */ - - Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); - if (Descriptor->DescriptorId != ACPI_DESC_TYPE_CACHED) - { - AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", - Descriptor, Element->Size, Element->Module, - Element->Line, AcpiUtGetDescriptorName (Descriptor)); - - /* Most of the elements will be Operand objects. */ - - switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) - { - case ACPI_DESC_TYPE_OPERAND: - AcpiOsPrintf ("%12.12s R%hd", - AcpiUtGetTypeName (Descriptor->Object.Common.Type), - Descriptor->Object.Common.ReferenceCount); - break; - - case ACPI_DESC_TYPE_PARSER: - AcpiOsPrintf ("AmlOpcode %04hX", - Descriptor->Op.Asl.AmlOpcode); - break; - - case ACPI_DESC_TYPE_NAMED: - AcpiOsPrintf ("%4.4s", - AcpiUtGetNodeName (&Descriptor->Node)); - break; - - default: - break; - } - - AcpiOsPrintf ( "\n"); - NumOutstanding++; - } - } - Element = Element->Next; - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY); - - /* Print summary */ - - if (!NumOutstanding) - { - ACPI_INFO ((AE_INFO, - "No outstanding allocations")); - } - else - { - ACPI_ERROR ((AE_INFO, - "%d(%X) Outstanding allocations", - NumOutstanding, NumOutstanding)); - } - - return_VOID; -} - -#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ - diff --git a/sys/dist/acpica/utcache.c b/sys/dist/acpica/utcache.c index 7b3b3620f5c..8519853b0bd 100644 --- a/sys/dist/acpica/utcache.c +++ b/sys/dist/acpica/utcache.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utcache - local cache allocation routines - * xRevision: 1.3 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,12 +114,9 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utcache.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __UTCACHE_C__ -#include "acpi.h" +#include <dist/acpica/acpi.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utcache") @@ -215,7 +212,7 @@ AcpiOsPurgeCache ( Next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) Cache->ListHead)[Cache->LinkOffset]))); - ACPI_MEM_FREE (Cache->ListHead); + ACPI_FREE (Cache->ListHead); Cache->ListHead = Next; Cache->CurrentDepth--; @@ -297,7 +294,7 @@ AcpiOsReleaseObject ( if (Cache->CurrentDepth >= Cache->MaxDepth) { - ACPI_MEM_FREE (Object); + ACPI_FREE (Object); ACPI_MEM_TRACKING (Cache->TotalFreed++); } @@ -351,7 +348,7 @@ AcpiOsAcquireObject ( void *Object; - ACPI_FUNCTION_NAME ("OsAcquireObject"); + ACPI_FUNCTION_NAME (OsAcquireObject); if (!Cache) @@ -380,8 +377,8 @@ AcpiOsAcquireObject ( Cache->CurrentDepth--; ACPI_MEM_TRACKING (Cache->Hits++); - ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Object %p from %s cache\n", Object, Cache->ListName))); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p from %s cache\n", Object, Cache->ListName)); Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (Status)) @@ -399,7 +396,14 @@ AcpiOsAcquireObject ( ACPI_MEM_TRACKING (Cache->TotalAllocated++); - /* Avoid deadlock with ACPI_MEM_CALLOCATE */ +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + if ((Cache->TotalAllocated - Cache->TotalFreed) > Cache->MaxOccupied) + { + Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed; + } +#endif + + /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */ Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); if (ACPI_FAILURE (Status)) @@ -407,7 +411,7 @@ AcpiOsAcquireObject ( return (NULL); } - Object = ACPI_MEM_CALLOCATE (Cache->ObjectSize); + Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize); if (!Object) { return (NULL); diff --git a/sys/dist/acpica/utclib.c b/sys/dist/acpica/utclib.c new file mode 100644 index 00000000000..e097aeded0e --- /dev/null +++ b/sys/dist/acpica/utclib.c @@ -0,0 +1,961 @@ +/****************************************************************************** + * + * Module Name: cmclib - Local implementation of C library functions + * $Revision: 1.2 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __CMCLIB_C__ + +#include <dist/acpica/acpi.h> + +/* + * These implementations of standard C Library routines can optionally be + * used if a C library is not available. In general, they are less efficient + * than an inline or assembly implementation + */ + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("cmclib") + + +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +#define NEGATIVE 1 +#define POSITIVE 0 + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemcmp (memcmp) + * + * PARAMETERS: Buffer1 - First Buffer + * Buffer2 - Second Buffer + * Count - Maximum # of bytes to compare + * + * RETURN: Index where Buffers mismatched, or 0 if Buffers matched + * + * DESCRIPTION: Compare two Buffers, with a maximum length + * + ******************************************************************************/ + +int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count) +{ + + for ( ; Count-- && (*Buffer1 == *Buffer2); Buffer1++, Buffer2++) + { + } + + return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *Buffer1 - + (unsigned char) *Buffer2)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemcpy (memcpy) + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory + * + ******************************************************************************/ + +void * +AcpiUtMemcpy ( + void *Dest, + const void *Src, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + char *Old = (char *) Src; + + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemset (memset) + * + * PARAMETERS: Dest - Buffer to set + * Value - Value to set each byte of memory + * Count - Number of bytes to set + * + * RETURN: Dest + * + * DESCRIPTION: Initialize a buffer to a known value. + * + ******************************************************************************/ + +void * +AcpiUtMemset ( + void *Dest, + ACPI_NATIVE_UINT Value, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + + + while (Count) + { + *New = (char) Value; + New++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrlen (strlen) + * + * PARAMETERS: String - Null terminated string + * + * RETURN: Length + * + * DESCRIPTION: Returns the length of the input string + * + ******************************************************************************/ + + +ACPI_SIZE +AcpiUtStrlen ( + const char *String) +{ + UINT32 Length = 0; + + + /* Count the string until a null is encountered */ + + while (*String) + { + Length++; + String++; + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcpy (strcpy) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string + * + ******************************************************************************/ + +char * +AcpiUtStrcpy ( + char *DstString, + const char *SrcString) +{ + char *String = DstString; + + + /* Move bytes brute force */ + + while (*SrcString) + { + *String = *SrcString; + + String++; + SrcString++; + } + + /* Null terminate */ + + *String = 0; + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncpy (strncpy) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string, with a maximum length + * + ******************************************************************************/ + +char * +AcpiUtStrncpy ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count) +{ + char *String = DstString; + + + /* Copy the string */ + + for (String = DstString; + Count && (Count--, (*String++ = *SrcString++)); ) + {;} + + /* Pad with nulls if necessary */ + + while (Count--) + { + *String = 0; + String++; + } + + /* Return original pointer */ + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcmp (strcmp) + * + * PARAMETERS: String1 - First string + * String2 - Second string + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings + * + ******************************************************************************/ + +int +AcpiUtStrcmp ( + const char *String1, + const char *String2) +{ + + + for ( ; (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((unsigned char) *String1 - (unsigned char) *String2); +} + + +#ifdef ACPI_FUTURE_IMPLEMENTATION +/* Not used at this time */ +/******************************************************************************* + * + * FUNCTION: AcpiUtStrchr (strchr) + * + * PARAMETERS: String - Search string + * ch - character to search for + * + * RETURN: Ptr to char or NULL if not found + * + * DESCRIPTION: Search a string for a character + * + ******************************************************************************/ + +char * +AcpiUtStrchr ( + const char *String, + int ch) +{ + + + for ( ; (*String); String++) + { + if ((*String) == (char) ch) + { + return ((char *) String); + } + } + + return (NULL); +} +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncmp (strncmp) + * + * PARAMETERS: String1 - First string + * String2 - Second string + * Count - Maximum # of bytes to compare + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings, with a maximum length + * + ******************************************************************************/ + +int +AcpiUtStrncmp ( + const char *String1, + const char *String2, + ACPI_SIZE Count) +{ + + + for ( ; Count-- && (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *String1 - + (unsigned char) *String2)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcat (Strcat) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string + * + ******************************************************************************/ + +char * +AcpiUtStrcat ( + char *DstString, + const char *SrcString) +{ + char *String; + + + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatenate the string */ + + for (--String; (*String++ = *SrcString++); ) + { ; } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncat (strncat) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string, + * with a maximum count. + * + ******************************************************************************/ + +char * +AcpiUtStrncat ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count) +{ + char *String; + + + if (Count) + { + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatenate the string */ + + for (--String; (*String++ = *SrcString++) && --Count; ) + { ; } + + /* Null terminate if necessary */ + + if (!Count) + { + *String = 0; + } + } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrstr (strstr) + * + * PARAMETERS: String1 - Target string + * String2 - Substring to search for + * + * RETURN: Where substring match starts, Null if no match found + * + * DESCRIPTION: Checks if String2 occurs in String1. This is not really a + * full implementation of strstr, only sufficient for command + * matching + * + ******************************************************************************/ + +char * +AcpiUtStrstr ( + char *String1, + char *String2) +{ + char *String; + + + if (AcpiUtStrlen (String2) > AcpiUtStrlen (String1)) + { + return (NULL); + } + + /* Walk entire string, comparing the letters */ + + for (String = String1; *String2; ) + { + if (*String2 != *String) + { + return (NULL); + } + + String2++; + String++; + } + + return (String1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoul (strtoul) + * + * PARAMETERS: String - Null terminated string + * Terminater - Where a pointer to the terminating byte is + * returned + * Base - Radix of the string + * + * RETURN: Converted value + * + * DESCRIPTION: Convert a string into a 32-bit unsigned value. + * Note: use AcpiUtStrtoul64 for 64-bit integers. + * + ******************************************************************************/ + +UINT32 +AcpiUtStrtoul ( + const char *String, + char **Terminator, + UINT32 Base) +{ + UINT32 converted = 0; + UINT32 index; + UINT32 sign; + const char *StringStart; + UINT32 ReturnValue = 0; + ACPI_STATUS Status = AE_OK; + + + /* + * Save the value of the pointer to the buffer's first + * character, save the current errno value, and then + * skip over any white space in the buffer: + */ + StringStart = String; + while (ACPI_IS_SPACE (*String) || *String == '\t') + { + ++String; + } + + /* + * The buffer may contain an optional plus or minus sign. + * If it does, then skip over it but remember what is was: + */ + if (*String == '-') + { + sign = NEGATIVE; + ++String; + } + else if (*String == '+') + { + ++String; + sign = POSITIVE; + } + else + { + sign = POSITIVE; + } + + /* + * If the input parameter Base is zero, then we need to + * determine if it is octal, decimal, or hexadecimal: + */ + if (Base == 0) + { + if (*String == '0') + { + if (AcpiUtToLower (*(++String)) == 'x') + { + Base = 16; + ++String; + } + else + { + Base = 8; + } + } + else + { + Base = 10; + } + } + else if (Base < 2 || Base > 36) + { + /* + * The specified Base parameter is not in the domain of + * this function: + */ + goto done; + } + + /* + * For octal and hexadecimal bases, skip over the leading + * 0 or 0x, if they are present. + */ + if (Base == 8 && *String == '0') + { + String++; + } + + if (Base == 16 && + *String == '0' && + AcpiUtToLower (*(++String)) == 'x') + { + String++; + } + + /* + * Main loop: convert the string to an unsigned long: + */ + while (*String) + { + if (ACPI_IS_DIGIT (*String)) + { + index = (UINT32) ((UINT8) *String - '0'); + } + else + { + index = (UINT32) AcpiUtToUpper (*String); + if (ACPI_IS_UPPER (index)) + { + index = index - 'A' + 10; + } + else + { + goto done; + } + } + + if (index >= Base) + { + goto done; + } + + /* + * Check to see if value is out of range: + */ + + if (ReturnValue > ((ACPI_UINT32_MAX - (UINT32) index) / + (UINT32) Base)) + { + Status = AE_ERROR; + ReturnValue = 0; /* reset */ + } + else + { + ReturnValue *= Base; + ReturnValue += index; + converted = 1; + } + + ++String; + } + +done: + /* + * If appropriate, update the caller's pointer to the next + * unconverted character in the buffer. + */ + if (Terminator) + { + if (converted == 0 && ReturnValue == 0 && String != NULL) + { + *Terminator = (char *) StringStart; + } + else + { + *Terminator = (char *) String; + } + } + + if (Status == AE_ERROR) + { + ReturnValue = ACPI_UINT32_MAX; + } + + /* + * If a minus sign was present, then "the conversion is negated": + */ + if (sign == NEGATIVE) + { + ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; + } + + return (ReturnValue); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtToUpper (TOUPPER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to uppercase + * + ******************************************************************************/ + +int +AcpiUtToUpper ( + int c) +{ + + return (ACPI_IS_LOWER(c) ? ((c)-0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtToLower (TOLOWER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to lowercase + * + ******************************************************************************/ + +int +AcpiUtToLower ( + int c) +{ + + return (ACPI_IS_UPPER(c) ? ((c)+0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: is* functions + * + * DESCRIPTION: is* functions use the ctype table below + * + ******************************************************************************/ + +const UINT8 _acpi_ctype[257] = { + _ACPI_CN, /* 0x0 0. */ + _ACPI_CN, /* 0x1 1. */ + _ACPI_CN, /* 0x2 2. */ + _ACPI_CN, /* 0x3 3. */ + _ACPI_CN, /* 0x4 4. */ + _ACPI_CN, /* 0x5 5. */ + _ACPI_CN, /* 0x6 6. */ + _ACPI_CN, /* 0x7 7. */ + _ACPI_CN, /* 0x8 8. */ + _ACPI_CN|_ACPI_SP, /* 0x9 9. */ + _ACPI_CN|_ACPI_SP, /* 0xA 10. */ + _ACPI_CN|_ACPI_SP, /* 0xB 11. */ + _ACPI_CN|_ACPI_SP, /* 0xC 12. */ + _ACPI_CN|_ACPI_SP, /* 0xD 13. */ + _ACPI_CN, /* 0xE 14. */ + _ACPI_CN, /* 0xF 15. */ + _ACPI_CN, /* 0x10 16. */ + _ACPI_CN, /* 0x11 17. */ + _ACPI_CN, /* 0x12 18. */ + _ACPI_CN, /* 0x13 19. */ + _ACPI_CN, /* 0x14 20. */ + _ACPI_CN, /* 0x15 21. */ + _ACPI_CN, /* 0x16 22. */ + _ACPI_CN, /* 0x17 23. */ + _ACPI_CN, /* 0x18 24. */ + _ACPI_CN, /* 0x19 25. */ + _ACPI_CN, /* 0x1A 26. */ + _ACPI_CN, /* 0x1B 27. */ + _ACPI_CN, /* 0x1C 28. */ + _ACPI_CN, /* 0x1D 29. */ + _ACPI_CN, /* 0x1E 30. */ + _ACPI_CN, /* 0x1F 31. */ + _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ + _ACPI_PU, /* 0x21 33. '!' */ + _ACPI_PU, /* 0x22 34. '"' */ + _ACPI_PU, /* 0x23 35. '#' */ + _ACPI_PU, /* 0x24 36. '$' */ + _ACPI_PU, /* 0x25 37. '%' */ + _ACPI_PU, /* 0x26 38. '&' */ + _ACPI_PU, /* 0x27 39. ''' */ + _ACPI_PU, /* 0x28 40. '(' */ + _ACPI_PU, /* 0x29 41. ')' */ + _ACPI_PU, /* 0x2A 42. '*' */ + _ACPI_PU, /* 0x2B 43. '+' */ + _ACPI_PU, /* 0x2C 44. ',' */ + _ACPI_PU, /* 0x2D 45. '-' */ + _ACPI_PU, /* 0x2E 46. '.' */ + _ACPI_PU, /* 0x2F 47. '/' */ + _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ + _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ + _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ + _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ + _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ + _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ + _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ + _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ + _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ + _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ + _ACPI_PU, /* 0x3A 58. ':' */ + _ACPI_PU, /* 0x3B 59. ';' */ + _ACPI_PU, /* 0x3C 60. '<' */ + _ACPI_PU, /* 0x3D 61. '=' */ + _ACPI_PU, /* 0x3E 62. '>' */ + _ACPI_PU, /* 0x3F 63. '?' */ + _ACPI_PU, /* 0x40 64. '@' */ + _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ + _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ + _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ + _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ + _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ + _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ + _ACPI_UP, /* 0x47 71. 'G' */ + _ACPI_UP, /* 0x48 72. 'H' */ + _ACPI_UP, /* 0x49 73. 'I' */ + _ACPI_UP, /* 0x4A 74. 'J' */ + _ACPI_UP, /* 0x4B 75. 'K' */ + _ACPI_UP, /* 0x4C 76. 'L' */ + _ACPI_UP, /* 0x4D 77. 'M' */ + _ACPI_UP, /* 0x4E 78. 'N' */ + _ACPI_UP, /* 0x4F 79. 'O' */ + _ACPI_UP, /* 0x50 80. 'P' */ + _ACPI_UP, /* 0x51 81. 'Q' */ + _ACPI_UP, /* 0x52 82. 'R' */ + _ACPI_UP, /* 0x53 83. 'S' */ + _ACPI_UP, /* 0x54 84. 'T' */ + _ACPI_UP, /* 0x55 85. 'U' */ + _ACPI_UP, /* 0x56 86. 'V' */ + _ACPI_UP, /* 0x57 87. 'W' */ + _ACPI_UP, /* 0x58 88. 'X' */ + _ACPI_UP, /* 0x59 89. 'Y' */ + _ACPI_UP, /* 0x5A 90. 'Z' */ + _ACPI_PU, /* 0x5B 91. '[' */ + _ACPI_PU, /* 0x5C 92. '\' */ + _ACPI_PU, /* 0x5D 93. ']' */ + _ACPI_PU, /* 0x5E 94. '^' */ + _ACPI_PU, /* 0x5F 95. '_' */ + _ACPI_PU, /* 0x60 96. '`' */ + _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ + _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ + _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ + _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ + _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ + _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ + _ACPI_LO, /* 0x67 103. 'g' */ + _ACPI_LO, /* 0x68 104. 'h' */ + _ACPI_LO, /* 0x69 105. 'i' */ + _ACPI_LO, /* 0x6A 106. 'j' */ + _ACPI_LO, /* 0x6B 107. 'k' */ + _ACPI_LO, /* 0x6C 108. 'l' */ + _ACPI_LO, /* 0x6D 109. 'm' */ + _ACPI_LO, /* 0x6E 110. 'n' */ + _ACPI_LO, /* 0x6F 111. 'o' */ + _ACPI_LO, /* 0x70 112. 'p' */ + _ACPI_LO, /* 0x71 113. 'q' */ + _ACPI_LO, /* 0x72 114. 'r' */ + _ACPI_LO, /* 0x73 115. 's' */ + _ACPI_LO, /* 0x74 116. 't' */ + _ACPI_LO, /* 0x75 117. 'u' */ + _ACPI_LO, /* 0x76 118. 'v' */ + _ACPI_LO, /* 0x77 119. 'w' */ + _ACPI_LO, /* 0x78 120. 'x' */ + _ACPI_LO, /* 0x79 121. 'y' */ + _ACPI_LO, /* 0x7A 122. 'z' */ + _ACPI_PU, /* 0x7B 123. '{' */ + _ACPI_PU, /* 0x7C 124. '|' */ + _ACPI_PU, /* 0x7D 125. '}' */ + _ACPI_PU, /* 0x7E 126. '~' */ + _ACPI_CN, /* 0x7F 127. */ + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ +}; + + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + diff --git a/sys/dist/acpica/utcopy.c b/sys/dist/acpica/utcopy.c index 7ea2e0e83ac..cf7cde4e526 100644 --- a/sys/dist/acpica/utcopy.c +++ b/sys/dist/acpica/utcopy.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utcopy - Internal to external object translation utilities - * xRevision: 1.126 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,13 +114,10 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utcopy.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __UTCOPY_C__ -#include "acpi.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_UTILITIES @@ -202,7 +199,7 @@ AcpiUtCopyIsimpleToEsimple ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("UtCopyIsimpleToEsimple"); + ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple); *BufferSpaceUsed = 0; @@ -428,7 +425,7 @@ AcpiUtCopyIpackageToEpackage ( ACPI_PKG_INFO Info; - ACPI_FUNCTION_TRACE ("UtCopyIpackageToEpackage"); + ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage); /* @@ -489,7 +486,7 @@ AcpiUtCopyIobjectToEobject ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("UtCopyIobjectToEobject"); + ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject); if (ACPI_GET_OBJECT_TYPE (InternalObject) == ACPI_TYPE_PACKAGE) @@ -546,7 +543,7 @@ AcpiUtCopyEsimpleToIsimple ( ACPI_OPERAND_OBJECT *InternalObject; - ACPI_FUNCTION_TRACE ("UtCopyEsimpleToIsimple"); + ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple); /* @@ -580,7 +577,7 @@ AcpiUtCopyEsimpleToIsimple ( case ACPI_TYPE_STRING: InternalObject->String.Pointer = - ACPI_MEM_CALLOCATE ((ACPI_SIZE) ExternalObject->String.Length + 1); + ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) ExternalObject->String.Length + 1); if (!InternalObject->String.Pointer) { goto ErrorExit; @@ -597,7 +594,7 @@ AcpiUtCopyEsimpleToIsimple ( case ACPI_TYPE_BUFFER: InternalObject->Buffer.Pointer = - ACPI_MEM_CALLOCATE (ExternalObject->Buffer.Length); + ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length); if (!InternalObject->Buffer.Pointer) { goto ErrorExit; @@ -668,7 +665,7 @@ AcpiUtCopyEpackageToIpackage ( ACPI_OBJECT *ThisExternalObj; - ACPI_FUNCTION_TRACE ("UtCopyEpackageToIpackage"); + ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage); /* @@ -721,7 +718,7 @@ AcpiUtCopyEobjectToIobject ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("UtCopyEobjectToIobject"); + ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject); if (ExternalObject->Type == ACPI_TYPE_PACKAGE) @@ -803,7 +800,7 @@ AcpiUtCopySimpleObject ( (SourceDesc->Buffer.Length)) { DestDesc->Buffer.Pointer = - ACPI_MEM_ALLOCATE (SourceDesc->Buffer.Length); + ACPI_ALLOCATE (SourceDesc->Buffer.Length); if (!DestDesc->Buffer.Pointer) { return (AE_NO_MEMORY); @@ -826,7 +823,7 @@ AcpiUtCopySimpleObject ( if (SourceDesc->String.Pointer) { DestDesc->String.Pointer = - ACPI_MEM_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); + ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); if (!DestDesc->String.Pointer) { return (AE_NO_MEMORY); @@ -847,6 +844,16 @@ AcpiUtCopySimpleObject ( AcpiUtAddReference (SourceDesc->Reference.Object); break; + case ACPI_TYPE_REGION: + /* + * We copied the Region Handler, so we now must add a reference + */ + if (DestDesc->Region.Handler) + { + AcpiUtAddReference (DestDesc->Region.Handler); + } + break; + default: /* Nothing to do for other simple objects */ break; @@ -941,9 +948,8 @@ AcpiUtCopyIelementToIelement ( /* * Create the object array */ - TargetObject->Package.Elements = - ACPI_MEM_CALLOCATE (((ACPI_SIZE) SourceObject->Package.Count + 1) * - sizeof (void *)); + TargetObject->Package.Elements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) SourceObject->Package.Count + 1) * sizeof (void *)); if (!TargetObject->Package.Elements) { Status = AE_NO_MEMORY; @@ -997,7 +1003,7 @@ AcpiUtCopyIpackageToIpackage ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("UtCopyIpackageToIpackage"); + ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage); DestObj->Common.Type = ACPI_GET_OBJECT_TYPE (SourceObj); @@ -1007,7 +1013,7 @@ AcpiUtCopyIpackageToIpackage ( /* * Create the object array and walk the source package tree */ - DestObj->Package.Elements = ACPI_MEM_CALLOCATE ( + DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED ( ((ACPI_SIZE) SourceObj->Package.Count + 1) * sizeof (void *)); if (!DestObj->Package.Elements) @@ -1056,7 +1062,7 @@ AcpiUtCopyIobjectToIobject ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("UtCopyIobjectToIobject"); + ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject); /* Create the top level object */ diff --git a/sys/dist/acpica/utdebug.c b/sys/dist/acpica/utdebug.c index 7bf81679c42..9e83d27056a 100644 --- a/sys/dist/acpica/utdebug.c +++ b/sys/dist/acpica/utdebug.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utdebug - Debug print routines - * xRevision: 1.127 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,12 +114,9 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utdebug.c,v 1.3 2006/11/16 01:33:31 christos Exp $"); - #define __UTDEBUG_C__ -#include "acpi.h" +#include <dist/acpica/acpi.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdebug") @@ -128,8 +125,8 @@ __KERNEL_RCSID(0, "$NetBSD: utdebug.c,v 1.3 2006/11/16 01:33:31 christos Exp $") #ifdef ACPI_DEBUG_OUTPUT static UINT32 AcpiGbl_PrevThreadId = 0xFFFFFFFF; -static const char *AcpiGbl_FnEntryStr = "----Entry"; -static const char *AcpiGbl_FnExitStr = "----Exit-"; +static const char *AcpiGbl_FnEntryStr = "----Entry"; +static const char *AcpiGbl_FnExitStr = "----Exit-"; /* Local prototypes */ @@ -262,7 +259,7 @@ AcpiUtDebugPrint ( const char *Format, ...) { - UINT32 ThreadId; + ACPI_THREAD_ID ThreadId; va_list args; @@ -279,7 +276,6 @@ AcpiUtDebugPrint ( * Thread tracking and context switch notification */ ThreadId = AcpiOsGetThreadId (); - if (ThreadId != AcpiGbl_PrevThreadId) { if (ACPI_LV_THREADS & AcpiDbgLevel) @@ -310,6 +306,8 @@ AcpiUtDebugPrint ( AcpiOsVprintf (Format, args); } +ACPI_EXPORT_SYMBOL (AcpiUtDebugPrint) + /******************************************************************************* * @@ -353,6 +351,8 @@ AcpiUtDebugPrintRaw ( AcpiOsVprintf (Format, args); } +ACPI_EXPORT_SYMBOL (AcpiUtDebugPrintRaw) + /******************************************************************************* * @@ -386,6 +386,8 @@ AcpiUtTrace ( "%s\n", AcpiGbl_FnEntryStr); } +ACPI_EXPORT_SYMBOL (AcpiUtTrace) + /******************************************************************************* * @@ -522,6 +524,8 @@ AcpiUtExit ( AcpiGbl_NestingLevel--; } +ACPI_EXPORT_SYMBOL (AcpiUtExit) + /******************************************************************************* * @@ -567,6 +571,8 @@ AcpiUtStatusExit ( AcpiGbl_NestingLevel--; } +ACPI_EXPORT_SYMBOL (AcpiUtStatusExit) + /******************************************************************************* * @@ -602,6 +608,8 @@ AcpiUtValueExit ( AcpiGbl_NestingLevel--; } +ACPI_EXPORT_SYMBOL (AcpiUtValueExit) + /******************************************************************************* * @@ -655,11 +663,10 @@ AcpiUtPtrExit ( ******************************************************************************/ void -AcpiUtDumpBuffer ( +AcpiUtDumpBuffer2 ( UINT8 *Buffer, UINT32 Count, - UINT32 Display, - UINT32 ComponentId) + UINT32 Display) { ACPI_NATIVE_UINT i = 0; ACPI_NATIVE_UINT j; @@ -667,14 +674,6 @@ AcpiUtDumpBuffer ( UINT8 BufChar; - /* Only dump the buffer if tracing is enabled */ - - if (!((ACPI_LV_TABLES & AcpiDbgLevel) && - (ComponentId & AcpiDbgLayer))) - { - return; - } - if ((Count < 4) || (Count & 0x01)) { Display = DB_BYTE_DISPLAY; @@ -703,6 +702,7 @@ AcpiUtDumpBuffer ( switch (Display) { + case DB_BYTE_DISPLAY: default: /* Default is BYTE display */ AcpiOsPrintf ("%02X ", Buffer[i + j]); @@ -769,3 +769,39 @@ AcpiUtDumpBuffer ( return; } + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpBuffer + * + * PARAMETERS: Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * Display - BYTE, WORD, DWORD, or QWORD display + * ComponentID - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii. + * + ******************************************************************************/ + +void +AcpiUtDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 ComponentId) +{ + + /* Only dump the buffer if tracing is enabled */ + + if (!((ACPI_LV_TABLES & AcpiDbgLevel) && + (ComponentId & AcpiDbgLayer))) + { + return; + } + + AcpiUtDumpBuffer2 (Buffer, Count, Display); +} + + diff --git a/sys/dist/acpica/utdelete.c b/sys/dist/acpica/utdelete.c index d9b85796ea3..8d8616e16e1 100644 --- a/sys/dist/acpica/utdelete.c +++ b/sys/dist/acpica/utdelete.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utdelete - object deletion and reference count utilities - * xRevision: 1.110 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,16 +114,13 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utdelete.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __UTDELETE_C__ -#include "acpi.h" -#include "acinterp.h" -#include "acnamesp.h" -#include "acevents.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acinterp.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdelete") @@ -163,7 +160,7 @@ AcpiUtDeleteInternalObj ( ACPI_OPERAND_OBJECT *NextDesc; - ACPI_FUNCTION_TRACE_PTR ("UtDeleteInternalObj", Object); + ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object); if (!Object) @@ -247,22 +244,35 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_MUTEX: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Mutex %p, Semaphore %p\n", - Object, Object->Mutex.Semaphore)); + "***** Mutex %p, OS Mutex %p\n", + Object, Object->Mutex.OsMutex)); + + if (Object == AcpiGbl_GlobalLockMutex) + { + /* Global Lock has extra semaphore */ - AcpiExUnlinkMutex (Object); - (void) AcpiOsDeleteSemaphore (Object->Mutex.Semaphore); + (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore); + AcpiGbl_GlobalLockSemaphore = NULL; + + AcpiOsDeleteMutex (Object->Mutex.OsMutex); + AcpiGbl_GlobalLockMutex = NULL; + } + else + { + AcpiExUnlinkMutex (Object); + AcpiOsDeleteMutex (Object->Mutex.OsMutex); + } break; case ACPI_TYPE_EVENT: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "***** Event %p, Semaphore %p\n", - Object, Object->Event.Semaphore)); + "***** Event %p, OS Semaphore %p\n", + Object, Object->Event.OsSemaphore)); - (void) AcpiOsDeleteSemaphore (Object->Event.Semaphore); - Object->Event.Semaphore = NULL; + (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore); + Object->Event.OsSemaphore = NULL; break; @@ -271,12 +281,13 @@ AcpiUtDeleteInternalObj ( ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Method %p\n", Object)); - /* Delete the method semaphore if it exists */ + /* Delete the method mutex if it exists */ - if (Object->Method.Semaphore) + if (Object->Method.Mutex) { - (void) AcpiOsDeleteSemaphore (Object->Method.Semaphore); - Object->Method.Semaphore = NULL; + AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex); + AcpiUtDeleteObjectDesc (Object->Method.Mutex); + Object->Method.Mutex = NULL; } break; @@ -297,9 +308,18 @@ AcpiUtDeleteInternalObj ( HandlerDesc = Object->Region.Handler; if (HandlerDesc) { - if (HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) + if (HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { - ObjPointer = SecondDesc->Extra.RegionContext; + /* Deactivate region and free region context */ + + if (HandlerDesc->AddressSpace.Setup) + { + (void) HandlerDesc->AddressSpace.Setup (Object, + ACPI_REGION_DEACTIVATE, + HandlerDesc->AddressSpace.Context, + &SecondDesc->Extra.RegionContext); + } } AcpiUtRemoveReference (HandlerDesc); @@ -334,14 +354,14 @@ AcpiUtDeleteInternalObj ( if (ObjPointer) { ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", - ObjPointer)); - ACPI_MEM_FREE (ObjPointer); + ObjPointer)); + ACPI_FREE (ObjPointer); } /* Now the object can be safely deleted */ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", - Object, AcpiUtGetObjectTypeName (Object))); + Object, AcpiUtGetObjectTypeName (Object))); AcpiUtDeleteObjectDesc (Object); return_VOID; @@ -368,7 +388,7 @@ AcpiUtDeleteInternalObjectList ( ACPI_OPERAND_OBJECT **InternalObj; - ACPI_FUNCTION_TRACE ("UtDeleteInternalObjectList"); + ACPI_FUNCTION_TRACE (UtDeleteInternalObjectList); /* Walk the null-terminated internal list */ @@ -380,7 +400,7 @@ AcpiUtDeleteInternalObjectList ( /* Free the combined parameter pointer list and object array */ - ACPI_MEM_FREE (ObjList); + ACPI_FREE (ObjList); return_VOID; } @@ -407,7 +427,7 @@ AcpiUtUpdateRefCount ( UINT16 NewCount; - ACPI_FUNCTION_NAME ("UtUpdateRefCount"); + ACPI_FUNCTION_NAME (UtUpdateRefCount); if (!Object) @@ -419,12 +439,10 @@ AcpiUtUpdateRefCount ( NewCount = Count; /* - * Perform the reference count action - * (increment, decrement, or force delete) + * Perform the reference count action (increment, decrement, force delete) */ switch (Action) { - case REF_INCREMENT: NewCount++; @@ -435,7 +453,6 @@ AcpiUtUpdateRefCount ( Object, NewCount)); break; - case REF_DECREMENT: if (Count < 1) @@ -458,8 +475,7 @@ AcpiUtUpdateRefCount ( if (ACPI_GET_OBJECT_TYPE (Object) == ACPI_TYPE_METHOD) { ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Method Obj %p Refs=%X, [Decremented]\n", - Object, NewCount)); + "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); } Object->Common.ReferenceCount = NewCount; @@ -467,22 +483,18 @@ AcpiUtUpdateRefCount ( { AcpiUtDeleteInternalObj (Object); } - break; - case REF_FORCE_DELETE: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, - "Obj %p Refs=%X, Force delete! (Set to 0)\n", - Object, Count)); + "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count)); NewCount = 0; Object->Common.ReferenceCount = NewCount; AcpiUtDeleteInternalObj (Object); break; - default: ACPI_ERROR ((AE_INFO, "Unknown action (%X)", Action)); @@ -495,13 +507,9 @@ AcpiUtUpdateRefCount ( */ if (Count > ACPI_MAX_REFERENCE_COUNT) { - ACPI_WARNING ((AE_INFO, - "Large Reference Count (%X) in object %p", - Count, Object)); + "Large Reference Count (%X) in object %p", Count, Object)); } - - return; } @@ -539,7 +547,7 @@ AcpiUtUpdateObjectReference ( ACPI_NATIVE_UINT i; - ACPI_FUNCTION_TRACE_PTR ("UtUpdateObjectReference", Object); + ACPI_FUNCTION_TRACE_PTR (UtUpdateObjectReference, Object); while (Object) @@ -560,9 +568,14 @@ AcpiUtUpdateObjectReference ( switch (ACPI_GET_OBJECT_TYPE (Object)) { case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_POWER: + case ACPI_TYPE_THERMAL: + + /* Update the notify objects for these types (if present) */ - AcpiUtUpdateRefCount (Object->Device.SystemNotify, Action); - AcpiUtUpdateRefCount (Object->Device.DeviceNotify, Action); + AcpiUtUpdateRefCount (Object->CommonNotify.SystemNotify, Action); + AcpiUtUpdateRefCount (Object->CommonNotify.DeviceNotify, Action); break; case ACPI_TYPE_PACKAGE: @@ -631,11 +644,11 @@ AcpiUtUpdateObjectReference ( case ACPI_TYPE_REGION: default: - break;/* No subobjects */ + break; /* No subobjects for all other types */ } /* - * Now we can update the count in the main object. This can only + * Now we can update the count in the main object. This can only * happen after we update the sub-objects in case this causes the * main object to be deleted. */ @@ -686,7 +699,7 @@ AcpiUtAddReference ( ACPI_OPERAND_OBJECT *Object) { - ACPI_FUNCTION_TRACE_PTR ("UtAddReference", Object); + ACPI_FUNCTION_TRACE_PTR (UtAddReference, Object); /* Ensure that we have a valid object */ @@ -702,7 +715,7 @@ AcpiUtAddReference ( /* Increment the reference count */ - (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); + (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); return_VOID; } @@ -724,12 +737,12 @@ AcpiUtRemoveReference ( ACPI_OPERAND_OBJECT *Object) { - ACPI_FUNCTION_TRACE_PTR ("UtRemoveReference", Object); + ACPI_FUNCTION_TRACE_PTR (UtRemoveReference, Object); /* - * Allow a NULL pointer to be passed in, just ignore it. This saves - * each caller from having to check. Also, ignore NS nodes. + * Allow a NULL pointer to be passed in, just ignore it. This saves + * each caller from having to check. Also, ignore NS nodes. * */ if (!Object || @@ -752,10 +765,10 @@ AcpiUtRemoveReference ( /* * Decrement the reference count, and only actually delete the object - * if the reference count becomes 0. (Must also decrement the ref count + * if the reference count becomes 0. (Must also decrement the ref count * of all subobjects!) */ - (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT); + (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT); return_VOID; } diff --git a/sys/dist/acpica/uteval.c b/sys/dist/acpica/uteval.c index 4b8448f4b8f..c0743a21dee 100644 --- a/sys/dist/acpica/uteval.c +++ b/sys/dist/acpica/uteval.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: uteval - Object evaluation - * xRevision: 1.64 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,14 +114,11 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uteval.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __UTEVAL_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acinterp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acinterp.h> #define _COMPONENT ACPI_UTILITIES @@ -141,6 +138,37 @@ AcpiUtTranslateOneCid ( ACPI_COMPATIBLE_ID *OneCid); +/* + * Strings supported by the _OSI predefined (internal) method. + */ +static const char *AcpiInterfacesSupported[] = +{ + /* Operating System Vendor Strings */ + + "Linux", + "Windows 2000", + "Windows 2001", + "Windows 2001 SP0", + "Windows 2001 SP1", + "Windows 2001 SP2", + "Windows 2001 SP3", + "Windows 2001 SP4", + "Windows 2001.1", + "Windows 2001.1 SP1", /* Added 03/2006 */ + "Windows 2006", /* Added 03/2006 */ + + /* Feature Group Strings */ + + "Extended Address Space Descriptor" + + /* + * All "optional" feature group strings (features that are implemented + * by the host) should be implemented in the host version of + * AcpiOsValidateInterface and should not be added here. + */ +}; + + /******************************************************************************* * * FUNCTION: AcpiUtOsiImplementation @@ -149,8 +177,7 @@ AcpiUtTranslateOneCid ( * * RETURN: Status * - * DESCRIPTION: Implementation of _OSI predefined control method - * Supported = _OSI (String) + * DESCRIPTION: Implementation of the _OSI predefined control method * ******************************************************************************/ @@ -158,12 +185,13 @@ ACPI_STATUS AcpiUtOsiImplementation ( ACPI_WALK_STATE *WalkState) { + ACPI_STATUS Status; ACPI_OPERAND_OBJECT *StringDesc; ACPI_OPERAND_OBJECT *ReturnDesc; ACPI_NATIVE_UINT i; - ACPI_FUNCTION_TRACE ("UtOsiImplementation"); + ACPI_FUNCTION_TRACE (UtOsiImplementation); /* Validate the string input argument */ @@ -174,7 +202,7 @@ AcpiUtOsiImplementation ( return_ACPI_STATUS (AE_TYPE); } - /* Create a return object (Default value = 0) */ + /* Create a return object */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) @@ -182,21 +210,39 @@ AcpiUtOsiImplementation ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* Compare input string to table of supported strings */ + /* Default return value is SUPPORTED */ + + ReturnDesc->Integer.Value = ACPI_UINT32_MAX; + WalkState->ReturnDesc = ReturnDesc; + + /* Compare input string to static table of supported interfaces */ - for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) + for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiInterfacesSupported); i++) { - if (!ACPI_STRCMP (StringDesc->String.Pointer, - ACPI_CAST_CONST_PTR (char, AcpiGbl_ValidOsiStrings[i]))) + if (!ACPI_STRCMP (StringDesc->String.Pointer, AcpiInterfacesSupported[i])) { - /* This string is supported */ + /* The interface is supported */ - ReturnDesc->Integer.Value = 0xFFFFFFFF; - break; + return_ACPI_STATUS (AE_CTRL_TERMINATE); } } - WalkState->ReturnDesc = ReturnDesc; + /* + * Did not match the string in the static table, call the host OSL to + * check for a match with one of the optional strings (such as + * "Module Device", "3.0 Thermal Model", etc.) + */ + Status = AcpiOsValidateInterface (StringDesc->String.Pointer); + if (ACPI_SUCCESS (Status)) + { + /* The interface is supported */ + + return_ACPI_STATUS (AE_CTRL_TERMINATE); + } + + /* The interface is not supported */ + + ReturnDesc->Integer.Value = 0; return_ACPI_STATUS (AE_CTRL_TERMINATE); } @@ -227,21 +273,29 @@ AcpiUtEvaluateObject ( UINT32 ExpectedReturnBtypes, ACPI_OPERAND_OBJECT **ReturnDesc) { - ACPI_PARAMETER_INFO Info; + ACPI_EVALUATE_INFO *Info; ACPI_STATUS Status; UINT32 ReturnBtype; - ACPI_FUNCTION_TRACE ("UtEvaluateObject"); + ACPI_FUNCTION_TRACE (UtEvaluateObject); + + + /* Allocate the evaluation information block */ + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } - Info.Node = PrefixNode; - Info.Parameters = NULL; - Info.ParameterType = ACPI_PARAM_ARGS; + Info->PrefixNode = PrefixNode; + Info->Pathname = Path; + Info->ParameterType = ACPI_PARAM_ARGS; /* Evaluate the object/method */ - Status = AcpiNsEvaluateRelative (Path, &Info); + Status = AcpiNsEvaluate (Info); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -255,27 +309,27 @@ AcpiUtEvaluateObject ( PrefixNode, Path, Status); } - return_ACPI_STATUS (Status); + goto Cleanup; } /* Did we get a return object? */ - if (!Info.ReturnObject) + if (!Info->ReturnObject) { if (ExpectedReturnBtypes) { ACPI_ERROR_METHOD ("No object was returned from", PrefixNode, Path, AE_NOT_EXIST); - return_ACPI_STATUS (AE_NOT_EXIST); + Status = AE_NOT_EXIST; } - return_ACPI_STATUS (AE_OK); + goto Cleanup; } /* Map the return object type to the bitmapped type */ - switch (ACPI_GET_OBJECT_TYPE (Info.ReturnObject)) + switch (ACPI_GET_OBJECT_TYPE (Info->ReturnObject)) { case ACPI_TYPE_INTEGER: ReturnBtype = ACPI_BTYPE_INTEGER; @@ -306,8 +360,8 @@ AcpiUtEvaluateObject ( * happen frequently if the "implicit return" feature is enabled. * Just delete the return object and return AE_OK. */ - AcpiUtRemoveReference (Info.ReturnObject); - return_ACPI_STATUS (AE_OK); + AcpiUtRemoveReference (Info->ReturnObject); + goto Cleanup; } /* Is the return object one of the expected types? */ @@ -319,19 +373,23 @@ AcpiUtEvaluateObject ( ACPI_ERROR ((AE_INFO, "Type returned from %s was incorrect: %s, expected Btypes: %X", - Path, AcpiUtGetObjectTypeName (Info.ReturnObject), + Path, AcpiUtGetObjectTypeName (Info->ReturnObject), ExpectedReturnBtypes)); /* On error exit, we must delete the return object */ - AcpiUtRemoveReference (Info.ReturnObject); - return_ACPI_STATUS (AE_TYPE); + AcpiUtRemoveReference (Info->ReturnObject); + Status = AE_TYPE; + goto Cleanup; } /* Object type is OK, return it */ - *ReturnDesc = Info.ReturnObject; - return_ACPI_STATUS (AE_OK); + *ReturnDesc = Info->ReturnObject; + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); } @@ -362,7 +420,7 @@ AcpiUtEvaluateNumericObject ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("UtEvaluateNumericObject"); + ACPI_FUNCTION_TRACE (UtEvaluateNumericObject); Status = AcpiUtEvaluateObject (DeviceNode, ObjectName, @@ -448,7 +506,7 @@ AcpiUtExecute_HID ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("UtExecute_HID"); + ACPI_FUNCTION_TRACE (UtExecute_HID); Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID, @@ -561,7 +619,7 @@ AcpiUtExecute_CID ( ACPI_NATIVE_UINT i; - ACPI_FUNCTION_TRACE ("UtExecute_CID"); + ACPI_FUNCTION_TRACE (UtExecute_CID); /* Evaluate the _CID method for this device */ @@ -587,7 +645,7 @@ AcpiUtExecute_CID ( Size = (((Count - 1) * sizeof (ACPI_COMPATIBLE_ID)) + sizeof (ACPI_COMPATIBLE_ID_LIST)); - CidList = ACPI_MEM_CALLOCATE ((ACPI_SIZE) Size); + CidList = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Size); if (!CidList) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -632,7 +690,7 @@ AcpiUtExecute_CID ( if (ACPI_FAILURE (Status)) { - ACPI_MEM_FREE (CidList); + ACPI_FREE (CidList); } else { @@ -671,7 +729,7 @@ AcpiUtExecute_UID ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("UtExecute_UID"); + ACPI_FUNCTION_TRACE (UtExecute_UID); Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID, @@ -727,7 +785,7 @@ AcpiUtExecute_STA ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("UtExecute_STA"); + ACPI_FUNCTION_TRACE (UtExecute_STA); Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA, @@ -784,7 +842,7 @@ AcpiUtExecute_Sxds ( UINT32 i; - ACPI_FUNCTION_TRACE ("UtExecute_Sxds"); + ACPI_FUNCTION_TRACE (UtExecute_Sxds); for (i = 0; i < 4; i++) diff --git a/sys/dist/acpica/utglobal.c b/sys/dist/acpica/utglobal.c index 42b047a3c56..fe3df0663aa 100644 --- a/sys/dist/acpica/utglobal.c +++ b/sys/dist/acpica/utglobal.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utglobal - Global variables for the ACPI subsystem - * xRevision: 1.227 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utglobal.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utglobal.c,v 1.2 2007/12/09 20:28:42 jmcneill Exp $"); #define __UTGLOBAL_C__ #define DEFINE_ACPI_GLOBALS @@ -240,7 +240,6 @@ UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT; UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; UINT32 AcpiGbl_NestingLevel = 0; - /* Debugger globals */ BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; @@ -255,8 +254,6 @@ UINT32 AcpiGbl_StartupFlags = 0; BOOLEAN AcpiGbl_Shutdown = TRUE; -const UINT8 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128}; - const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = { "\\_S0_", @@ -286,12 +283,14 @@ const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] = "Linux", "Windows 2000", "Windows 2001", - "Windows 2001.1", "Windows 2001 SP0", "Windows 2001 SP1", "Windows 2001 SP2", "Windows 2001 SP3", "Windows 2001 SP4", + "Windows 2001.1", + "Windows 2001.1 SP1", + "Windows 2006", /* Feature Group Strings */ @@ -407,35 +406,6 @@ AcpiUtHexToAsciiChar ( } -/******************************************************************************* - * - * Table name globals - * - * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes. - * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables - * that are not used by the subsystem are simply ignored. - * - * Do NOT add any table to this list that is not consumed directly by this - * subsystem (No MADT, ECDT, SBST, etc.) - * - ******************************************************************************/ - -ACPI_TABLE_LIST AcpiGbl_TableLists[NUM_ACPI_TABLE_TYPES]; - -ACPI_TABLE_SUPPORT AcpiGbl_TableData[NUM_ACPI_TABLE_TYPES] = -{ - /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */ - - /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, - /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &AcpiGbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE}, - /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &AcpiGbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}, - /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &AcpiGbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE}, - /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, - /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, - /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, -}; - - /****************************************************************************** * * Event and Hardware globals @@ -499,7 +469,6 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = { -/*! [Begin] no source code translation (keep these ASL Keywords as-is) */ "SystemMemory", "SystemIO", "PCI_Config", @@ -508,7 +477,6 @@ const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = "CMOS", "PCIBARTarget", "DataTable" -/*! [End] no source code translation !*/ }; @@ -546,13 +514,11 @@ AcpiUtGetRegionName ( static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = { -/*! [Begin] no source code translation (keep these strings as-is) */ "PM_Timer", "GlobalLock", "PowerButton", "SleepButton", "RealTimeClock", -/*! [End] no source code translation !*/ }; @@ -596,7 +562,6 @@ static const char AcpiGbl_BadType[] = "UNDEFINED"; static const char *AcpiGbl_NsTypeNames[] = { -/*! [Begin] no source code translation (keep these strings as-is) */ /* 00 */ "Untyped", /* 01 */ "Integer", /* 02 */ "String", @@ -628,7 +593,6 @@ static const char *AcpiGbl_NsTypeNames[] = /* 28 */ "Extra", /* 29 */ "Data", /* 30 */ "Invalid" -/*! [End] no source code translation !*/ }; @@ -696,7 +660,7 @@ AcpiUtGetNodeName ( /* Descriptor must be a namespace node */ - if (Node->Descriptor != ACPI_DESC_TYPE_NAMED) + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { return ("####"); } @@ -705,7 +669,7 @@ AcpiUtGetNodeName ( if (!AcpiUtValidAcpiName (Node->Name.Integer)) { - return ("????"); + Node->Name.Integer = AcpiUtRepairName (Node->Name.Ascii); } /* Return the name */ @@ -730,7 +694,6 @@ AcpiUtGetNodeName ( static const char *AcpiGbl_DescTypeNames[] = { -/*! [Begin] no source code translation (keep these ASL Keywords as-is) */ /* 00 */ "Invalid", /* 01 */ "Cached", /* 02 */ "State-Generic", @@ -747,7 +710,6 @@ static const char *AcpiGbl_DescTypeNames[] = /* 13 */ "Parser", /* 14 */ "Operand", /* 15 */ "Node" -/*! [End] no source code translation !*/ }; @@ -795,7 +757,7 @@ AcpiUtGetMutexName ( UINT32 MutexId) { - if (MutexId > MAX_MUTEX) + if (MutexId > ACPI_MAX_MUTEX) { return ("Invalid Mutex ID"); } @@ -854,7 +816,7 @@ AcpiUtInitGlobals ( UINT32 i; - ACPI_FUNCTION_TRACE ("UtInitGlobals"); + ACPI_FUNCTION_TRACE (UtInitGlobals); /* Create all memory caches */ @@ -865,17 +827,9 @@ AcpiUtInitGlobals ( return; } - /* ACPI table structure */ - - for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) - { - AcpiGbl_TableLists[i].Next = NULL; - AcpiGbl_TableLists[i].Count = 0; - } - /* Mutex locked flags */ - for (i = 0; i < NUM_MUTEX; i++) + for (i = 0; i < ACPI_NUM_MUTEX; i++) { AcpiGbl_MutexInfo[i].Mutex = NULL; AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; @@ -890,6 +844,7 @@ AcpiUtInitGlobals ( /* GPE support */ + AcpiGpeCount = 0; AcpiGbl_GpeXruptListHead = NULL; AcpiGbl_GpeFadtBlocks[0] = NULL; AcpiGbl_GpeFadtBlocks[1] = NULL; @@ -901,24 +856,15 @@ AcpiUtInitGlobals ( AcpiGbl_ExceptionHandler = NULL; AcpiGbl_InitHandler = NULL; - /* Global "typed" ACPI table pointers */ - - AcpiGbl_RSDP = NULL; - AcpiGbl_XSDT = NULL; - AcpiGbl_FACS = NULL; - AcpiGbl_FADT = NULL; - AcpiGbl_DSDT = NULL; - /* Global Lock support */ + AcpiGbl_GlobalLockSemaphore = NULL; + AcpiGbl_GlobalLockMutex = NULL; AcpiGbl_GlobalLockAcquired = FALSE; - AcpiGbl_GlobalLockThreadCount = 0; AcpiGbl_GlobalLockHandle = 0; /* Miscellaneous variables */ - AcpiGbl_TableFlags = ACPI_PHYSICAL_POINTER; - AcpiGbl_RsdpOriginalLocation = 0; AcpiGbl_CmSingleStep = FALSE; AcpiGbl_DbTerminateThreads = FALSE; AcpiGbl_Shutdown = FALSE; @@ -942,7 +888,7 @@ AcpiUtInitGlobals ( AcpiGbl_RootNode = NULL; AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; - AcpiGbl_RootNodeStruct.Descriptor = ACPI_DESC_TYPE_NAMED; + AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED; AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; AcpiGbl_RootNodeStruct.Child = NULL; AcpiGbl_RootNodeStruct.Peer = NULL; @@ -954,7 +900,17 @@ AcpiUtInitGlobals ( AcpiGbl_LowestStackPointer = ACPI_SIZE_MAX; #endif +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + AcpiGbl_DisplayFinalMemStats = FALSE; +#endif + return_VOID; } +/* Public globals */ + +ACPI_EXPORT_SYMBOL (AcpiDbgLevel) +ACPI_EXPORT_SYMBOL (AcpiDbgLayer) +ACPI_EXPORT_SYMBOL (AcpiGpeCount) + diff --git a/sys/dist/acpica/utinit.c b/sys/dist/acpica/utinit.c index da03b756ecf..f0254b3e634 100644 --- a/sys/dist/acpica/utinit.c +++ b/sys/dist/acpica/utinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utinit - Common ACPI subsystem initialization - * xRevision: 1.126 $ + * $Revision: 1.2 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,146 +115,22 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utinit.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __UTINIT_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "acevents.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/actables.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utinit") /* Local prototypes */ -static void -AcpiUtFadtRegisterError ( - const char *RegisterName, - UINT32 Value, - ACPI_SIZE Offset); - static void AcpiUtTerminate ( void); -/******************************************************************************* - * - * FUNCTION: AcpiUtFadtRegisterError - * - * PARAMETERS: RegisterName - Pointer to string identifying register - * Value - Actual register contents value - * Offset - Byte offset in the FADT - * - * RETURN: AE_BAD_VALUE - * - * DESCRIPTION: Display failure message - * - ******************************************************************************/ - -static void -AcpiUtFadtRegisterError ( - const char *RegisterName, - UINT32 Value, - ACPI_SIZE Offset) -{ - - ACPI_WARNING ((AE_INFO, - "Invalid FADT value %s=%X at offset %X FADT=%p", - RegisterName, Value, (UINT32) Offset, AcpiGbl_FADT)); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiUtValidateFadt - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Validate various ACPI registers in the FADT - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtValidateFadt ( - void) -{ - - /* - * Verify Fixed ACPI Description Table fields, - * but don't abort on any problems, just display error - */ - if (AcpiGbl_FADT->Pm1EvtLen < 4) - { - AcpiUtFadtRegisterError ("PM1_EVT_LEN", - (UINT32) AcpiGbl_FADT->Pm1EvtLen, - ACPI_FADT_OFFSET (Pm1EvtLen)); - } - - if (!AcpiGbl_FADT->Pm1CntLen) - { - AcpiUtFadtRegisterError ("PM1_CNT_LEN", 0, - ACPI_FADT_OFFSET (Pm1CntLen)); - } - - if (!ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1aEvtBlk.Address)) - { - AcpiUtFadtRegisterError ("X_PM1a_EVT_BLK", 0, - ACPI_FADT_OFFSET (XPm1aEvtBlk.Address)); - } - - if (!ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1aCntBlk.Address)) - { - AcpiUtFadtRegisterError ("X_PM1a_CNT_BLK", 0, - ACPI_FADT_OFFSET (XPm1aCntBlk.Address)); - } - - if (!ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPmTmrBlk.Address)) - { - AcpiUtFadtRegisterError ("X_PM_TMR_BLK", 0, - ACPI_FADT_OFFSET (XPmTmrBlk.Address)); - } - - if ((ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address) && - !AcpiGbl_FADT->Pm2CntLen)) - { - AcpiUtFadtRegisterError ("PM2_CNT_LEN", - (UINT32) AcpiGbl_FADT->Pm2CntLen, - ACPI_FADT_OFFSET (Pm2CntLen)); - } - - if (AcpiGbl_FADT->PmTmLen < 4) - { - AcpiUtFadtRegisterError ("PM_TM_LEN", - (UINT32) AcpiGbl_FADT->PmTmLen, - ACPI_FADT_OFFSET (PmTmLen)); - } - - /* Length of GPE blocks must be a multiple of 2 */ - - if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe0Blk.Address) && - (AcpiGbl_FADT->Gpe0BlkLen & 1)) - { - AcpiUtFadtRegisterError ("(x)GPE0_BLK_LEN", - (UINT32) AcpiGbl_FADT->Gpe0BlkLen, - ACPI_FADT_OFFSET (Gpe0BlkLen)); - } - - if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe1Blk.Address) && - (AcpiGbl_FADT->Gpe1BlkLen & 1)) - { - AcpiUtFadtRegisterError ("(x)GPE1_BLK_LEN", - (UINT32) AcpiGbl_FADT->Gpe1BlkLen, - ACPI_FADT_OFFSET (Gpe1BlkLen)); - } - - return (AE_OK); -} - - /****************************************************************************** * * FUNCTION: AcpiUtTerminate @@ -277,10 +153,9 @@ AcpiUtTerminate ( ACPI_GPE_XRUPT_INFO *NextGpeXruptInfo; - ACPI_FUNCTION_TRACE ("UtTerminate"); + ACPI_FUNCTION_TRACE (UtTerminate); - /* Free global tables, etc. */ /* Free global GPE blocks and related info structures */ GpeXruptInfo = AcpiGbl_GpeXruptListHead; @@ -290,14 +165,14 @@ AcpiUtTerminate ( while (GpeBlock) { NextGpeBlock = GpeBlock->Next; - ACPI_MEM_FREE (GpeBlock->EventInfo); - ACPI_MEM_FREE (GpeBlock->RegisterInfo); - ACPI_MEM_FREE (GpeBlock); + ACPI_FREE (GpeBlock->EventInfo); + ACPI_FREE (GpeBlock->RegisterInfo); + ACPI_FREE (GpeBlock); GpeBlock = NextGpeBlock; } NextGpeXruptInfo = GpeXruptInfo->Next; - ACPI_MEM_FREE (GpeXruptInfo); + ACPI_FREE (GpeXruptInfo); GpeXruptInfo = NextGpeXruptInfo; } @@ -323,7 +198,7 @@ AcpiUtSubsystemShutdown ( void) { - ACPI_FUNCTION_TRACE ("UtSubsystemShutdown"); + ACPI_FUNCTION_TRACE (UtSubsystemShutdown); /* Just exit if subsystem is already shutdown */ @@ -337,6 +212,7 @@ AcpiUtSubsystemShutdown ( /* Subsystem appears active, go ahead and shut it down */ AcpiGbl_Shutdown = TRUE; + AcpiGbl_StartupFlags = 0; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); @@ -348,6 +224,10 @@ AcpiUtSubsystemShutdown ( AcpiNsTerminate (); + /* Delete the ACPI tables */ + + AcpiTbTerminate (); + /* Close the globals */ AcpiUtTerminate (); @@ -355,13 +235,6 @@ AcpiUtSubsystemShutdown ( /* Purge the local caches */ (void) AcpiUtDeleteCaches (); - - /* Debug only - display leftover memory allocation, if any */ - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - AcpiUtDumpAllocations (ACPI_UINT32_MAX, NULL); -#endif - return_VOID; } diff --git a/sys/dist/acpica/utmath.c b/sys/dist/acpica/utmath.c index bd6dd099378..0d146846730 100644 --- a/sys/dist/acpica/utmath.c +++ b/sys/dist/acpica/utmath.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utmath - Integer math support routines - * xRevision: 1.20 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,9 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utmath.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __UTMATH_C__ -#include "acpi.h" +#include <dist/acpica/acpi.h> #define _COMPONENT ACPI_UTILITIES @@ -162,7 +159,7 @@ AcpiUtShortDivide ( UINT32 Remainder32; - ACPI_FUNCTION_TRACE ("UtShortDivide"); + ACPI_FUNCTION_TRACE (UtShortDivide); /* Always check for a zero divisor */ @@ -232,7 +229,7 @@ AcpiUtDivide ( UINT64_OVERLAY Partial3; - ACPI_FUNCTION_TRACE ("UtDivide"); + ACPI_FUNCTION_TRACE (UtDivide); /* Always check for a zero divisor */ @@ -371,7 +368,7 @@ AcpiUtShortDivide ( UINT32 *OutRemainder) { - ACPI_FUNCTION_TRACE ("UtShortDivide"); + ACPI_FUNCTION_TRACE (UtShortDivide); /* Always check for a zero divisor */ @@ -403,7 +400,7 @@ AcpiUtDivide ( ACPI_INTEGER *OutQuotient, ACPI_INTEGER *OutRemainder) { - ACPI_FUNCTION_TRACE ("UtDivide"); + ACPI_FUNCTION_TRACE (UtDivide); /* Always check for a zero divisor */ diff --git a/sys/dist/acpica/utmisc.c b/sys/dist/acpica/utmisc.c index 95da8382865..8bdccd58b92 100644 --- a/sys/dist/acpica/utmisc.c +++ b/sys/dist/acpica/utmisc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utmisc - common utility procedures - * xRevision: 1.136 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,13 +115,15 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utmisc.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __UTMISC_C__ -#include "acpi.h" -#include "acnamesp.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> + +#ifdef _KERNEL +/* pull in reboot.h for AB_VERBOSE definition */ +#include <sys/reboot.h> +#endif #define _COMPONENT ACPI_UTILITIES @@ -130,6 +132,118 @@ __KERNEL_RCSID(0, "$NetBSD: utmisc.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); /******************************************************************************* * + * FUNCTION: AcpiUtValidateException + * + * PARAMETERS: Status - The ACPI_STATUS code to be formatted + * + * RETURN: A string containing the exception text. NULL if exception is + * not valid. + * + * DESCRIPTION: This function validates and translates an ACPI exception into + * an ASCII string. + * + ******************************************************************************/ + +const char * +AcpiUtValidateException ( + ACPI_STATUS Status) +{ + ACPI_STATUS SubStatus; + const char *Exception = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Status is composed of two parts, a "type" and an actual code + */ + SubStatus = (Status & ~AE_CODE_MASK); + + switch (Status & AE_CODE_MASK) + { + case AE_CODE_ENVIRONMENTAL: + + if (SubStatus <= AE_CODE_ENV_MAX) + { + Exception = AcpiGbl_ExceptionNames_Env [SubStatus]; + } + break; + + case AE_CODE_PROGRAMMER: + + if (SubStatus <= AE_CODE_PGM_MAX) + { + Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1]; + } + break; + + case AE_CODE_ACPI_TABLES: + + if (SubStatus <= AE_CODE_TBL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1]; + } + break; + + case AE_CODE_AML: + + if (SubStatus <= AE_CODE_AML_MAX) + { + Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1]; + } + break; + + case AE_CODE_CONTROL: + + if (SubStatus <= AE_CODE_CTRL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1]; + } + break; + + default: + break; + } + + return (ACPI_CAST_CONST_PTR (const char, Exception)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtIsAmlTable + * + * PARAMETERS: Table - An ACPI table + * + * RETURN: TRUE if table contains executable AML; FALSE otherwise + * + * DESCRIPTION: Check ACPI Signature for a table that contains AML code. + * Currently, these are DSDT,SSDT,PSDT. All other table types are + * data tables that do not contain AML code. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtIsAmlTable ( + ACPI_TABLE_HEADER *Table) +{ + + /* These are the only tables that contain executable AML */ + + if (!ACPI_STRNCMP (Table->Signature, ACPI_SIG_DSDT, 4) || + !ACPI_STRNCMP (Table->Signature, ACPI_SIG_PSDT, 4) || + !ACPI_STRNCMP (Table->Signature, ACPI_SIG_SSDT, 4)) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * * FUNCTION: AcpiUtAllocateOwnerId * * PARAMETERS: OwnerId - Where the new owner ID is returned @@ -152,7 +266,7 @@ AcpiUtAllocateOwnerId ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("UtAllocateOwnerId"); + ACPI_FUNCTION_TRACE (UtAllocateOwnerId); /* Guard against multiple allocations of ID to the same location */ @@ -267,7 +381,7 @@ AcpiUtReleaseOwnerId ( UINT32 Bit; - ACPI_FUNCTION_TRACE_U32 ("UtReleaseOwnerId", OwnerId); + ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId); /* Always clear the input OwnerId (zero is an invalid ID) */ @@ -392,7 +506,7 @@ AcpiUtPrintString ( switch (String[i]) { case 0x07: - AcpiOsPrintf ("\\a"); /* BELL */ + AcpiOsPrintf ("\\a"); /* BELL */ break; case 0x08: @@ -515,14 +629,18 @@ AcpiUtSetIntegerWidth ( UINT8 Revision) { - if (Revision <= 1) + if (Revision < 2) { + /* 32-bit case */ + AcpiGbl_IntegerBitWidth = 32; AcpiGbl_IntegerNybbleWidth = 8; AcpiGbl_IntegerByteWidth = 4; } else { + /* 64-bit case (ACPI 2.0+) */ + AcpiGbl_IntegerBitWidth = 64; AcpiGbl_IntegerNybbleWidth = 16; AcpiGbl_IntegerByteWidth = 8; @@ -601,13 +719,55 @@ AcpiUtDisplayInitPathname ( } AcpiOsPrintf ("\n"); - ACPI_MEM_FREE (Buffer.Pointer); + ACPI_FREE (Buffer.Pointer); } #endif /******************************************************************************* * + * FUNCTION: AcpiUtValidAcpiChar + * + * PARAMETERS: Char - The character to be examined + * Position - Byte position (0-3) + * + * RETURN: TRUE if the character is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI character. Must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + * We allow a '!' as the last character because of the ASF! table + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidAcpiChar ( + char Character, + ACPI_NATIVE_UINT Position) +{ + + if (!((Character >= 'A' && Character <= 'Z') || + (Character >= '0' && Character <= '9') || + (Character == '_'))) + { + /* Allow a '!' in the last position */ + + if (Character == '!' && Position == 3) + { + return (TRUE); + } + + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * * FUNCTION: AcpiUtValidAcpiName * * PARAMETERS: Name - The name to be examined @@ -625,8 +785,6 @@ BOOLEAN AcpiUtValidAcpiName ( UINT32 Name) { - char *NamePtr = (char *) &Name; - char Character; ACPI_NATIVE_UINT i; @@ -635,12 +793,7 @@ AcpiUtValidAcpiName ( for (i = 0; i < ACPI_NAME_SIZE; i++) { - Character = *NamePtr; - NamePtr++; - - if (!((Character == '_') || - (Character >= 'A' && Character <= 'Z') || - (Character >= '0' && Character <= '9'))) + if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i)) { return (FALSE); } @@ -652,26 +805,41 @@ AcpiUtValidAcpiName ( /******************************************************************************* * - * FUNCTION: AcpiUtValidAcpiCharacter + * FUNCTION: AcpiUtRepairName * - * PARAMETERS: Character - The character to be examined + * PARAMETERS: Name - The ACPI name to be repaired * - * RETURN: 1 if Character may appear in a name, else 0 + * RETURN: Repaired version of the name * - * DESCRIPTION: Check for a printable character + * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and + * return the new name. * ******************************************************************************/ -BOOLEAN -AcpiUtValidAcpiCharacter ( - char Character) +ACPI_NAME +AcpiUtRepairName ( + char *Name) { + ACPI_NATIVE_UINT i; + char NewName[ACPI_NAME_SIZE]; - ACPI_FUNCTION_ENTRY (); - return ((BOOLEAN) ((Character == '_') || - (Character >= 'A' && Character <= 'Z') || - (Character >= '0' && Character <= '9'))); + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + NewName[i] = Name[i]; + + /* + * Replace a bad character with something printable, yet technically + * still invalid. This prevents any collisions with existing "good" + * names in the namespace. + */ + if (!AcpiUtValidAcpiChar (Name[i], i)) + { + NewName[i] = '*'; + } + } + + return (*(UINT32 *) NewName); } @@ -680,12 +848,15 @@ AcpiUtValidAcpiCharacter ( * FUNCTION: AcpiUtStrtoul64 * * PARAMETERS: String - Null terminated string - * Base - Radix of the string: 10, 16, or ACPI_ANY_BASE + * Base - Radix of the string: 16 or ACPI_ANY_BASE; + * ACPI_ANY_BASE means 'in behalf of ToInteger' * RetInteger - Where the converted integer is returned * * RETURN: Status and Converted value * - * DESCRIPTION: Convert a string into an unsigned value. + * DESCRIPTION: Convert a string into an unsigned value. Performs either a + * 32-bit or 64-bit conversion, depending on the current mode + * of the interpreter. * NOTE: Does not support Octal strings, not needed. * ******************************************************************************/ @@ -699,20 +870,20 @@ AcpiUtStrtoul64 ( UINT32 ThisDigit = 0; ACPI_INTEGER ReturnValue = 0; ACPI_INTEGER Quotient; + ACPI_INTEGER Dividend; + UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); + UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); + UINT8 ValidDigits = 0; + UINT8 SignOf0x = 0; + UINT8 Term = 0; - ACPI_FUNCTION_TRACE ("UtStroul64"); + ACPI_FUNCTION_TRACE_STR (UtStroul64, String); - if ((!String) || !(*String)) - { - goto ErrorExit; - } - switch (Base) { case ACPI_ANY_BASE: - case 10: case 16: break; @@ -721,23 +892,30 @@ AcpiUtStrtoul64 ( return_ACPI_STATUS (AE_BAD_PARAMETER); } + if (!String) + { + goto ErrorExit; + } + /* Skip over any white space in the buffer */ - while (ACPI_IS_SPACE (*String) || *String == '\t') + while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t')) { String++; } - /* - * If the input parameter Base is zero, then we need to - * determine if it is decimal or hexadecimal: - */ - if (Base == 0) + if (ToIntegerOp) { - if ((*String == '0') && - (ACPI_TOLOWER (*(String + 1)) == 'x')) + /* + * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. + * We need to determine if it is decimal or hexadecimal. + */ + if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x')) { + SignOf0x = 1; Base = 16; + + /* Skip over the leading '0x' */ String += 2; } else @@ -746,25 +924,27 @@ AcpiUtStrtoul64 ( } } - /* - * For hexadecimal base, skip over the leading - * 0 or 0x, if they are present. - */ - if ((Base == 16) && - (*String == '0') && - (ACPI_TOLOWER (*(String + 1)) == 'x')) - { - String += 2; - } - - /* Any string left? */ + /* Any string left? Check that '0x' is not followed by white space. */ - if (!(*String)) + if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t') { - goto ErrorExit; + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + goto AllDone; + } } - /* Main loop: convert the string to a 64-bit integer */ + /* + * Perform a 32-bit or 64-bit conversion, depending upon the current + * execution mode of the interpreter + */ + Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; + + /* Main loop: convert the string to a 32- or 64-bit integer */ while (*String) { @@ -774,15 +954,14 @@ AcpiUtStrtoul64 ( ThisDigit = ((UINT8) *String) - '0'; } - else + else if (Base == 10) { - if (Base == 10) - { - /* Digit is out of range */ - - goto ErrorExit; - } + /* Digit is out of range; possible in ToInteger case only */ + Term = 1; + } + else + { ThisDigit = (UINT8) ACPI_TOUPPER (*String); if (ACPI_IS_XDIGIT ((char) ThisDigit)) { @@ -792,21 +971,55 @@ AcpiUtStrtoul64 ( } else { - /* - * We allow non-hex chars, just stop now, same as end-of-string. - * See ACPI spec, string-to-integer conversion. - */ + Term = 1; + } + } + + if (Term) + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { break; } } + else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) + { + /* Skip zeros */ + String++; + continue; + } + + ValidDigits++; + + if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32))) + { + /* + * This is ToInteger operation case. + * No any restrictions for string-to-integer conversion, + * see ACPI spec. + */ + goto ErrorExit; + } /* Divide the digit into the correct position */ - (void) AcpiUtShortDivide ((ACPI_INTEGER_MAX - (ACPI_INTEGER) ThisDigit), + (void) AcpiUtShortDivide ((Dividend - (ACPI_INTEGER) ThisDigit), Base, &Quotient, NULL); + if (ReturnValue > Quotient) { - goto ErrorExit; + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + break; + } } ReturnValue *= Base; @@ -816,6 +1029,11 @@ AcpiUtStrtoul64 ( /* All done, normal exit */ +AllDone: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ReturnValue))); + *RetInteger = ReturnValue; return_ACPI_STATUS (AE_OK); @@ -907,7 +1125,7 @@ AcpiUtWalkPackageTree ( ACPI_OPERAND_OBJECT *ThisSourceObj; - ACPI_FUNCTION_TRACE ("UtWalkPackageTree"); + ACPI_FUNCTION_TRACE (UtWalkPackageTree); State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0); @@ -1082,55 +1300,20 @@ AcpiUtInfo ( { va_list args; +#ifdef _KERNEL + /* Temporarily hide too verbose printfs. */ + if (!bootverbose) + return; +#endif - AcpiOsPrintf ("ACPI (%s-%04d): ", ModuleName, LineNumber); + /* + * Removed ModuleName, LineNumber, and acpica version, not needed + * for info output + */ + AcpiOsPrintf ("ACPI: "); va_start (args, Format); AcpiOsVprintf (Format, args); - AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtReportError, Warning, Info - * - * PARAMETERS: ModuleName - Caller's module name (for error output) - * LineNumber - Caller's line number (for error output) - * - * RETURN: None - * - * DESCRIPTION: Print error message - * - * Note: Legacy only, should be removed when no longer used by drivers. - * - ******************************************************************************/ - -void -AcpiUtReportError ( - const char *ModuleName, - UINT32 LineNumber) -{ - - AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); -} - -void -AcpiUtReportWarning ( - const char *ModuleName, - UINT32 LineNumber) -{ - - AcpiOsPrintf ("ACPI Warning (%s-%04d): ", ModuleName, LineNumber); -} - -void -AcpiUtReportInfo ( - const char *ModuleName, - UINT32 LineNumber) -{ - - AcpiOsPrintf ("ACPI (%s-%04d): ", ModuleName, LineNumber); + AcpiOsPrintf ("\n"); } - diff --git a/sys/dist/acpica/utmutex.c b/sys/dist/acpica/utmutex.c index 788bcddda37..5484854da51 100644 --- a/sys/dist/acpica/utmutex.c +++ b/sys/dist/acpica/utmutex.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utmutex - local mutex support - * xRevision: 1.6 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,9 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utmutex.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __UTMUTEX_C__ -#include "acpi.h" +#include <dist/acpica/acpi.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utmutex") @@ -156,13 +153,13 @@ AcpiUtMutexInitialize ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("UtMutexInitialize"); + ACPI_FUNCTION_TRACE (UtMutexInitialize); /* * Create each of the predefined mutex objects */ - for (i = 0; i < NUM_MUTEX; i++) + for (i = 0; i < ACPI_NUM_MUTEX; i++) { Status = AcpiUtCreateMutex (i); if (ACPI_FAILURE (Status)) @@ -171,7 +168,15 @@ AcpiUtMutexInitialize ( } } + /* Create the spinlocks for use at interrupt level */ + Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock); return_ACPI_STATUS (Status); } @@ -195,18 +200,21 @@ AcpiUtMutexTerminate ( UINT32 i; - ACPI_FUNCTION_TRACE ("UtMutexTerminate"); + ACPI_FUNCTION_TRACE (UtMutexTerminate); /* * Delete each predefined mutex object */ - for (i = 0; i < NUM_MUTEX; i++) + for (i = 0; i < ACPI_NUM_MUTEX; i++) { (void) AcpiUtDeleteMutex (i); } + /* Delete the spinlocks */ + AcpiOsDeleteLock (AcpiGbl_GpeLock); + AcpiOsDeleteLock (AcpiGbl_HardwareLock); return_VOID; } @@ -230,18 +238,17 @@ AcpiUtCreateMutex ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_U32 ("UtCreateMutex", MutexId); + ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId); - if (MutexId > MAX_MUTEX) + if (MutexId > ACPI_MAX_MUTEX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } if (!AcpiGbl_MutexInfo[MutexId].Mutex) { - Status = AcpiOsCreateSemaphore (1, 1, - &AcpiGbl_MutexInfo[MutexId].Mutex); + Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex); AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; AcpiGbl_MutexInfo[MutexId].UseCount = 0; } @@ -266,23 +273,21 @@ static ACPI_STATUS AcpiUtDeleteMutex ( ACPI_MUTEX_HANDLE MutexId) { - ACPI_STATUS Status; - - ACPI_FUNCTION_TRACE_U32 ("UtDeleteMutex", MutexId); + ACPI_FUNCTION_TRACE_U32 (UtDeleteMutex, MutexId); - if (MutexId > MAX_MUTEX) + if (MutexId > ACPI_MAX_MUTEX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - Status = AcpiOsDeleteSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex); + AcpiOsDeleteMutex (AcpiGbl_MutexInfo[MutexId].Mutex); AcpiGbl_MutexInfo[MutexId].Mutex = NULL; AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; - return_ACPI_STATUS (Status); + return_ACPI_STATUS (AE_OK); } @@ -303,13 +308,13 @@ AcpiUtAcquireMutex ( ACPI_MUTEX_HANDLE MutexId) { ACPI_STATUS Status; - UINT32 ThisThreadId; + ACPI_THREAD_ID ThisThreadId; - ACPI_FUNCTION_NAME ("UtAcquireMutex"); + ACPI_FUNCTION_NAME (UtAcquireMutex); - if (MutexId > MAX_MUTEX) + if (MutexId > ACPI_MAX_MUTEX) { return (AE_BAD_PARAMETER); } @@ -327,15 +332,15 @@ AcpiUtAcquireMutex ( * the mutex ordering rule. This indicates a coding error somewhere in * the ACPI subsystem code. */ - for (i = MutexId; i < MAX_MUTEX; i++) + for (i = MutexId; i < ACPI_MAX_MUTEX; i++) { if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) { if (i == MutexId) { ACPI_ERROR ((AE_INFO, - "Mutex [%s] already acquired by this thread [%X]", - AcpiUtGetMutexName (MutexId), ThisThreadId)); + "Mutex [%s] already acquired by this thread [%jX]", + AcpiUtGetMutexName (MutexId), (uintmax_t)ThisThreadId)); return (AE_ALREADY_ACQUIRED); } @@ -352,15 +357,15 @@ AcpiUtAcquireMutex ( #endif ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X attempting to acquire Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); + "Thread %jX attempting to acquire Mutex [%s]\n", + (uintmax_t)ThisThreadId, AcpiUtGetMutexName (MutexId))); - Status = AcpiOsWaitSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex, - 1, ACPI_WAIT_FOREVER); + Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex, + ACPI_WAIT_FOREVER); if (ACPI_SUCCESS (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %jX acquired Mutex [%s]\n", + (uintmax_t)ThisThreadId, AcpiUtGetMutexName (MutexId))); AcpiGbl_MutexInfo[MutexId].UseCount++; AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId; @@ -368,7 +373,8 @@ AcpiUtAcquireMutex ( else { ACPI_EXCEPTION ((AE_INFO, Status, - "Thread %X could not acquire Mutex [%X]", ThisThreadId, MutexId)); + "Thread %jX could not acquire Mutex [%X]", (uintmax_t)ThisThreadId, + MutexId)); } return (Status); @@ -391,19 +397,18 @@ ACPI_STATUS AcpiUtReleaseMutex ( ACPI_MUTEX_HANDLE MutexId) { - ACPI_STATUS Status; - UINT32 ThisThreadId; + ACPI_THREAD_ID ThisThreadId; - ACPI_FUNCTION_NAME ("UtReleaseMutex"); + ACPI_FUNCTION_NAME (UtReleaseMutex); ThisThreadId = AcpiOsGetThreadId (); ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X releasing Mutex [%s]\n", ThisThreadId, + "Thread %jX releasing Mutex [%s]\n", (uintmax_t)ThisThreadId, AcpiUtGetMutexName (MutexId))); - if (MutexId > MAX_MUTEX) + if (MutexId > ACPI_MAX_MUTEX) { return (AE_BAD_PARAMETER); } @@ -430,7 +435,7 @@ AcpiUtReleaseMutex ( * ordering rule. This indicates a coding error somewhere in * the ACPI subsystem code. */ - for (i = MutexId; i < MAX_MUTEX; i++) + for (i = MutexId; i < ACPI_MAX_MUTEX; i++) { if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) { @@ -453,20 +458,8 @@ AcpiUtReleaseMutex ( AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; - Status = AcpiOsSignalSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex, 1); - - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Thread %X could not release Mutex [%X]", ThisThreadId, MutexId)); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); - } - - return (Status); + AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex); + return (AE_OK); } diff --git a/sys/dist/acpica/utobject.c b/sys/dist/acpica/utobject.c index f2f28214360..468ee408115 100644 --- a/sys/dist/acpica/utobject.c +++ b/sys/dist/acpica/utobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utobject - ACPI object create/delete/size/cache routines - * xRevision: 1.101 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -114,14 +114,11 @@ * *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utobject.c,v 1.3 2006/11/16 01:33:32 christos Exp $"); - #define __UTOBJECT_C__ -#include "acpi.h" -#include "acnamesp.h" -#include "amlcode.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/amlcode.h> #define _COMPONENT ACPI_UTILITIES @@ -179,7 +176,7 @@ AcpiUtCreateInternalObjectDbg ( ACPI_OPERAND_OBJECT *SecondObject; - ACPI_FUNCTION_TRACE_STR ("UtCreateInternalObjectDbg", + ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg, AcpiUtGetTypeName (Type)); @@ -253,7 +250,7 @@ AcpiUtCreateBufferObject ( UINT8 *Buffer = NULL; - ACPI_FUNCTION_TRACE_U32 ("UtCreateBufferObject", BufferSize); + ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize); /* Create a new Buffer object */ @@ -270,7 +267,7 @@ AcpiUtCreateBufferObject ( { /* Allocate the actual buffer */ - Buffer = ACPI_MEM_CALLOCATE (BufferSize); + Buffer = ACPI_ALLOCATE_ZEROED (BufferSize); if (!Buffer) { ACPI_ERROR ((AE_INFO, "Could not allocate size %X", @@ -314,7 +311,7 @@ AcpiUtCreateStringObject ( char *String; - ACPI_FUNCTION_TRACE_U32 ("UtCreateStringObject", StringSize); + ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize); /* Create a new String object */ @@ -329,7 +326,7 @@ AcpiUtCreateStringObject ( * Allocate the actual string buffer -- (Size + 1) for NULL terminator. * NOTE: Zero-length strings are NULL terminated */ - String = ACPI_MEM_CALLOCATE (StringSize + 1); + String = ACPI_ALLOCATE_ZEROED (StringSize + 1); if (!String) { ACPI_ERROR ((AE_INFO, "Could not allocate size %X", @@ -366,7 +363,7 @@ AcpiUtValidInternalObject ( void *Object) { - ACPI_FUNCTION_NAME ("UtValidInternalObject"); + ACPI_FUNCTION_NAME (UtValidInternalObject); /* Check for a null pointer */ @@ -422,7 +419,7 @@ AcpiUtAllocateObjectDescDbg ( ACPI_OPERAND_OBJECT *Object; - ACPI_FUNCTION_TRACE ("UtAllocateObjectDescDbg"); + ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg); Object = AcpiOsAcquireObject (AcpiGbl_OperandCache); @@ -461,7 +458,7 @@ void AcpiUtDeleteObjectDesc ( ACPI_OPERAND_OBJECT *Object) { - ACPI_FUNCTION_TRACE_PTR ("UtDeleteObjectDesc", Object); + ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object); /* Object must be an ACPI_OPERAND_OBJECT */ @@ -505,7 +502,7 @@ AcpiUtGetSimpleObjectSize ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_PTR ("UtGetSimpleObjectSize", InternalObject); + ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject); /* @@ -697,7 +694,7 @@ AcpiUtGetPackageObjectSize ( ACPI_PKG_INFO Info; - ACPI_FUNCTION_TRACE_PTR ("UtGetPackageObjectSize", InternalObject); + ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject); Info.Length = 0; diff --git a/sys/dist/acpica/utresrc.c b/sys/dist/acpica/utresrc.c index 1673e80d1ca..24e9acbb2b8 100644 --- a/sys/dist/acpica/utresrc.c +++ b/sys/dist/acpica/utresrc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utresrc - Resource managment utilities - * xRevision: 1.9 $ + * $Revision: 1.3 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,17 +115,14 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utresrc.c,v 1.2 2006/05/14 21:38:18 elad Exp $"); - #define __UTRESRC_C__ -#include "acpi.h" -#include "amlresrc.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/amlresrc.h> #define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("utmisc") + ACPI_MODULE_NAME ("utresrc") #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) @@ -134,13 +131,13 @@ __KERNEL_RCSID(0, "$NetBSD: utresrc.c,v 1.2 2006/05/14 21:38:18 elad Exp $"); * Strings used to decode resource descriptors. * Used by both the disasssembler and the debugger resource dump routines */ -const char *AcpiGbl_BMDecode[2] = +const char *AcpiGbl_BmDecode[] = { "NotBusMaster", "BusMaster" }; -const char *AcpiGbl_ConfigDecode[4] = +const char *AcpiGbl_ConfigDecode[] = { "0 - Good Configuration", "1 - Acceptable Configuration", @@ -148,43 +145,43 @@ const char *AcpiGbl_ConfigDecode[4] = "3 - ***Invalid Configuration***", }; -const char *AcpiGbl_ConsumeDecode[2] = +const char *AcpiGbl_ConsumeDecode[] = { "ResourceProducer", "ResourceConsumer" }; -const char *AcpiGbl_DECDecode[2] = +const char *AcpiGbl_DecDecode[] = { "PosDecode", "SubDecode" }; -const char *AcpiGbl_HEDecode[2] = +const char *AcpiGbl_HeDecode[] = { "Level", "Edge" }; -const char *AcpiGbl_IoDecode[2] = +const char *AcpiGbl_IoDecode[] = { "Decode10", "Decode16" }; -const char *AcpiGbl_LLDecode[2] = +const char *AcpiGbl_LlDecode[] = { "ActiveHigh", "ActiveLow" }; -const char *AcpiGbl_MaxDecode[2] = +const char *AcpiGbl_MaxDecode[] = { "MaxNotFixed", "MaxFixed" }; -const char *AcpiGbl_MEMDecode[4] = +const char *AcpiGbl_MemDecode[] = { "NonCacheable", "Cacheable", @@ -192,13 +189,13 @@ const char *AcpiGbl_MEMDecode[4] = "Prefetchable" }; -const char *AcpiGbl_MinDecode[2] = +const char *AcpiGbl_MinDecode[] = { "MinNotFixed", "MinFixed" }; -const char *AcpiGbl_MTPDecode[4] = +const char *AcpiGbl_MtpDecode[] = { "AddressRangeMemory", "AddressRangeReserved", @@ -206,7 +203,7 @@ const char *AcpiGbl_MTPDecode[4] = "AddressRangeNVS" }; -const char *AcpiGbl_RNGDecode[4] = +const char *AcpiGbl_RngDecode[] = { "InvalidRanges", "NonISAOnlyRanges", @@ -214,19 +211,19 @@ const char *AcpiGbl_RNGDecode[4] = "EntireRange" }; -const char *AcpiGbl_RWDecode[2] = +const char *AcpiGbl_RwDecode[] = { "ReadOnly", "ReadWrite" }; -const char *AcpiGbl_SHRDecode[2] = +const char *AcpiGbl_ShrDecode[] = { "Exclusive", "Shared" }; -const char *AcpiGbl_SIZDecode[4] = +const char *AcpiGbl_SizDecode[] = { "Transfer8", "Transfer8_16", @@ -234,19 +231,19 @@ const char *AcpiGbl_SIZDecode[4] = "InvalidSize" }; -const char *AcpiGbl_TRSDecode[2] = +const char *AcpiGbl_TrsDecode[] = { "DenseTranslation", "SparseTranslation" }; -const char *AcpiGbl_TTPDecode[2] = +const char *AcpiGbl_TtpDecode[] = { "TypeStatic", "TypeTranslation" }; -const char *AcpiGbl_TYPDecode[4] = +const char *AcpiGbl_TypDecode[] = { "Compatibility", "TypeA", @@ -345,6 +342,113 @@ static const UINT8 AcpiGbl_ResourceTypes[] = /******************************************************************************* * + * FUNCTION: AcpiUtWalkAmlResources + * + * PARAMETERS: Aml - Pointer to the raw AML resource template + * AmlLength - Length of the entire template + * UserFunction - Called once for each descriptor found. If + * NULL, a pointer to the EndTag is returned + * Context - Passed to UserFunction + * + * RETURN: Status + * + * DESCRIPTION: Walk a raw AML resource list(buffer). User function called + * once for each resource found. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtWalkAmlResources ( + UINT8 *Aml, + ACPI_SIZE AmlLength, + ACPI_WALK_AML_CALLBACK UserFunction, + void *Context) +{ + ACPI_STATUS Status; + UINT8 *EndAml; + UINT8 ResourceIndex; + UINT32 Length; + UINT32 Offset = 0; + + + ACPI_FUNCTION_TRACE (UtWalkAmlResources); + + + /* The absolute minimum resource template is one EndTag descriptor */ + + if (AmlLength < sizeof (AML_RESOURCE_END_TAG)) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + + /* Point to the end of the resource template buffer */ + + EndAml = Aml + AmlLength; + + /* Walk the byte list, abort on any invalid descriptor type or length */ + + while (Aml < EndAml) + { + /* Validate the Resource Type and Resource Length */ + + Status = AcpiUtValidateResource (Aml, &ResourceIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the length of this descriptor */ + + Length = AcpiUtGetDescriptorLength (Aml); + + /* Invoke the user function */ + + if (UserFunction) + { + Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* An EndTag descriptor terminates this resource template */ + + if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) + { + /* + * There must be at least one more byte in the buffer for + * the 2nd byte of the EndTag + */ + if ((Aml + 1) >= EndAml) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + + /* Return the pointer to the EndTag if requested */ + + if (!UserFunction) + { + *(void **) Context = Aml; + } + + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); + } + + Aml += Length; + Offset += Length; + } + + /* Did not find an EndTag descriptor */ + + return (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * * FUNCTION: AcpiUtValidateResource * * PARAMETERS: Aml - Pointer to the raw AML resource descriptor @@ -644,68 +748,25 @@ AcpiUtGetResourceEndTag ( UINT8 **EndTag) { ACPI_STATUS Status; - UINT8 *Aml; - UINT8 *EndAml; - ACPI_FUNCTION_TRACE ("UtGetResourceEndTag"); + ACPI_FUNCTION_TRACE (UtGetResourceEndTag); - /* Get start and end pointers */ - - Aml = ObjDesc->Buffer.Pointer; - EndAml = Aml + ObjDesc->Buffer.Length; - /* Allow a buffer length of zero */ if (!ObjDesc->Buffer.Length) { - *EndTag = Aml; + *EndTag = ObjDesc->Buffer.Pointer; return_ACPI_STATUS (AE_OK); } - /* Walk the resource template, one descriptor per iteration */ - - while (Aml < EndAml) - { - /* Validate the Resource Type and Resource Length */ - - Status = AcpiUtValidateResource (Aml, NULL); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* EndTag resource indicates the end of the resource template */ - - if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) - { - /* - * There must be at least one more byte in the buffer for - * the 2nd byte of the EndTag - */ - if ((Aml + 1) >= EndAml) - { - return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); - } - - /* Return the pointer to the EndTag */ - - *EndTag = Aml; - return_ACPI_STATUS (AE_OK); - } - - /* - * Point to the next resource descriptor in the AML buffer. The - * descriptor length is guaranteed to be non-zero by resource - * validation above. - */ - Aml += AcpiUtGetDescriptorLength (Aml); - } + /* Validate the template and get a pointer to the EndTag */ - /* Did not find an EndTag resource descriptor */ + Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length, NULL, EndTag); - return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + return_ACPI_STATUS (Status); } diff --git a/sys/dist/acpica/utstate.c b/sys/dist/acpica/utstate.c index f273fa9bd79..1cd29bc8212 100644 --- a/sys/dist/acpica/utstate.c +++ b/sys/dist/acpica/utstate.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utstate - state object support procedures - * xRevision: 1.3 $ + * $Revision: 1.2 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,9 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utstate.c,v 1.1 2006/03/23 13:36:32 kochi Exp $"); - #define __UTSTATE_C__ -#include "acpi.h" +#include <dist/acpica/acpi.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utstate") @@ -182,7 +179,7 @@ AcpiUtPushGenericState ( ACPI_GENERIC_STATE **ListHead, ACPI_GENERIC_STATE *State) { - ACPI_FUNCTION_TRACE ("UtPushGenericState"); + ACPI_FUNCTION_TRACE (UtPushGenericState); /* Push the state object onto the front of the list (stack) */ @@ -213,7 +210,7 @@ AcpiUtPopGenericState ( ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_TRACE ("UtPopGenericState"); + ACPI_FUNCTION_TRACE (UtPopGenericState); /* Remove the state object at the head of the list (stack) */ @@ -257,7 +254,7 @@ AcpiUtCreateGenericState ( if (State) { /* Initialize */ - State->Common.DataType = ACPI_DESC_TYPE_STATE; + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE; } return (State); @@ -284,7 +281,7 @@ AcpiUtCreateThreadState ( ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_TRACE ("UtCreateThreadState"); + ACPI_FUNCTION_TRACE (UtCreateThreadState); /* Create the generic state object */ @@ -297,9 +294,17 @@ AcpiUtCreateThreadState ( /* Init fields specific to the update struct */ - State->Common.DataType = ACPI_DESC_TYPE_STATE_THREAD; + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_THREAD; State->Thread.ThreadId = AcpiOsGetThreadId (); + /* Check for invalid thread ID - zero is very bad, it will break things */ + + if (!State->Thread.ThreadId) + { + ACPI_ERROR ((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId")); + State->Thread.ThreadId = 1; + } + return_PTR ((ACPI_THREAD_STATE *) State); } @@ -327,7 +332,7 @@ AcpiUtCreateUpdateState ( ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_TRACE_PTR ("UtCreateUpdateState", Object); + ACPI_FUNCTION_TRACE_PTR (UtCreateUpdateState, Object); /* Create the generic state object */ @@ -340,9 +345,9 @@ AcpiUtCreateUpdateState ( /* Init fields specific to the update struct */ - State->Common.DataType = ACPI_DESC_TYPE_STATE_UPDATE; + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_UPDATE; State->Update.Object = Object; - State->Update.Value = Action; + State->Update.Value = Action; return_PTR (State); } @@ -370,7 +375,7 @@ AcpiUtCreatePkgState ( ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_TRACE_PTR ("UtCreatePkgState", InternalObject); + ACPI_FUNCTION_TRACE_PTR (UtCreatePkgState, InternalObject); /* Create the generic state object */ @@ -383,11 +388,11 @@ AcpiUtCreatePkgState ( /* Init fields specific to the update struct */ - State->Common.DataType = ACPI_DESC_TYPE_STATE_PACKAGE; + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PACKAGE; State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject; - State->Pkg.DestObject = ExternalObject; - State->Pkg.Index = Index; - State->Pkg.NumPackages = 1; + State->Pkg.DestObject = ExternalObject; + State->Pkg.Index= Index; + State->Pkg.NumPackages = 1; return_PTR (State); } @@ -413,7 +418,7 @@ AcpiUtCreateControlState ( ACPI_GENERIC_STATE *State; - ACPI_FUNCTION_TRACE ("UtCreateControlState"); + ACPI_FUNCTION_TRACE (UtCreateControlState); /* Create the generic state object */ @@ -426,8 +431,8 @@ AcpiUtCreateControlState ( /* Init fields specific to the control struct */ - State->Common.DataType = ACPI_DESC_TYPE_STATE_CONTROL; - State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_CONTROL; + State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; return_PTR (State); } @@ -441,8 +446,8 @@ AcpiUtCreateControlState ( * * RETURN: None * - * DESCRIPTION: Put a state object back into the global state cache. The object - * is not actually freed at this time. + * DESCRIPTION: Release a state object to the state cache. NULL state objects + * are ignored. * ******************************************************************************/ @@ -450,10 +455,15 @@ void AcpiUtDeleteGenericState ( ACPI_GENERIC_STATE *State) { - ACPI_FUNCTION_TRACE ("UtDeleteGenericState"); + ACPI_FUNCTION_TRACE (UtDeleteGenericState); - (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State); + /* Ignore null state */ + + if (State) + { + (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State); + } return_VOID; } diff --git a/sys/dist/acpica/uttrack.c b/sys/dist/acpica/uttrack.c new file mode 100644 index 00000000000..7f5de295368 --- /dev/null +++ b/sys/dist/acpica/uttrack.c @@ -0,0 +1,726 @@ +/****************************************************************************** + * + * Module Name: uttrack - Memory allocation tracking routines (debug only) + * $Revision: 1.2 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +/* + * These procedures are used for tracking memory leaks in the subsystem, and + * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set. + * + * Each memory allocation is tracked via a doubly linked list. Each + * element contains the caller's component, module name, function name, and + * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call + * AcpiUtTrackAllocation to add an element to the list; deletion + * occurs in the body of AcpiUtFree. + */ + +#define __UTTRACK_C__ + +#include <dist/acpica/acpi.h> + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("uttrack") + +/* Local prototypes */ + +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + void *Allocation); + +static ACPI_STATUS +AcpiUtTrackAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + const char *Module, + UINT32 Line); + +static ACPI_STATUS +AcpiUtRemoveAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + UINT32 Component, + const char *Module, + UINT32 Line); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateList + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a local memory list for tracking purposed + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateList ( + const char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache) +{ + ACPI_MEMORY_LIST *Cache; + + + Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); + if (!Cache) + { + return (AE_NO_MEMORY); + } + + ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + + Cache->ListName = ListName; + Cache->ObjectSize = ObjectSize; + + *ReturnCache = Cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateAndTrack + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: The subsystem's equivalent of malloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocateAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *Allocation; + ACPI_STATUS Status; + + + Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); + if (!Allocation) + { + return (NULL); + } + + Status = AcpiUtTrackAllocation (Allocation, Size, + ACPI_MEM_MALLOC, Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Allocation); + return (NULL); + } + + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->TotalSize += (UINT32) Size; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; + if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + { + AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + } + + return ((void *) &Allocation->UserSpace); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateZeroedAndTrack + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of calloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocateZeroedAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *Allocation; + ACPI_STATUS Status; + + + Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); + if (!Allocation) + { + /* Report allocation error */ + + ACPI_ERROR ((Module, Line, + "Could not allocate size %X", (UINT32) Size)); + return (NULL); + } + + Status = AcpiUtTrackAllocation (Allocation, Size, + ACPI_MEM_CALLOC, Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Allocation); + return (NULL); + } + + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->TotalSize += (UINT32) Size; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; + if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + { + AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + } + + return ((void *) &Allocation->UserSpace); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFreeAndTrack + * + * PARAMETERS: Allocation - Address of the memory to deallocate + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None + * + * DESCRIPTION: Frees the memory at Allocation + * + ******************************************************************************/ + +void +AcpiUtFreeAndTrack ( + void *Allocation, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *DebugBlock; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation); + + + if (NULL == Allocation) + { + ACPI_ERROR ((Module, Line, + "Attempt to delete a NULL address")); + + return_VOID; + } + + DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, + (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); + + AcpiGbl_GlobalList->TotalFreed++; + AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size; + + Status = AcpiUtRemoveAllocation (DebugBlock, + Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory")); + } + + AcpiOsFree (DebugBlock); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFindAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * + * RETURN: A list element if found; NULL otherwise. + * + * DESCRIPTION: Searches for an element in the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + void *Allocation) +{ + ACPI_DEBUG_MEM_BLOCK *Element; + + + ACPI_FUNCTION_ENTRY (); + + + Element = AcpiGbl_GlobalList->ListHead; + + /* Search for the address. */ + + while (Element) + { + if (Element == Allocation) + { + return (Element); + } + + Element = Element->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrackAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * Size - Size of the allocation + * AllocType - MEM_MALLOC or MEM_CALLOC + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None. + * + * DESCRIPTION: Inserts an element into the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtTrackAllocation ( + ACPI_DEBUG_MEM_BLOCK *Allocation, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_MEMORY_LIST *MemList; + ACPI_DEBUG_MEM_BLOCK *Element; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation); + + + MemList = AcpiGbl_GlobalList; + Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Search list for this address to make sure it is not already on the list. + * This will catch several kinds of problems. + */ + Element = AcpiUtFindAllocation (Allocation); + if (Element) + { + ACPI_ERROR ((AE_INFO, + "UtTrackAllocation: Allocation already present in list! (%p)", + Allocation)); + + ACPI_ERROR ((AE_INFO, "Element %p Address %p", + Element, Allocation)); + + goto UnlockAndExit; + } + + /* Fill in the instance data. */ + + Allocation->Size = (UINT32) Size; + Allocation->AllocType = AllocType; + Allocation->Component = Component; + Allocation->Line = Line; + + ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); + Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; + + /* Insert at list head */ + + if (MemList->ListHead) + { + ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation; + } + + Allocation->Next = MemList->ListHead; + Allocation->Previous = NULL; + + MemList->ListHead = Allocation; + + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: + * + * DESCRIPTION: Deletes an element from the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtRemoveAllocation ( + ACPI_DEBUG_MEM_BLOCK *Allocation, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_MEMORY_LIST *MemList; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtRemoveAllocation); + + + MemList = AcpiGbl_GlobalList; + if (NULL == MemList->ListHead) + { + /* No allocations! */ + + ACPI_ERROR ((Module, Line, + "Empty allocation list, nothing to free!")); + + return_ACPI_STATUS (AE_OK); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Unlink */ + + if (Allocation->Previous) + { + (Allocation->Previous)->Next = Allocation->Next; + } + else + { + MemList->ListHead = Allocation->Next; + } + + if (Allocation->Next) + { + (Allocation->Next)->Previous = Allocation->Previous; + } + + /* Mark the segment as deleted */ + + ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", + Allocation->Size)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpAllocationInfo + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: Print some info about the outstanding allocations. + * + ******************************************************************************/ + +void +AcpiUtDumpAllocationInfo ( + void) +{ +/* + ACPI_MEMORY_LIST *MemList; +*/ + + ACPI_FUNCTION_TRACE (UtDumpAllocationInfo); + +/* + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current allocations", + MemList->CurrentCount, + ROUND_UP_TO_1K (MemList->CurrentSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", + MemList->MaxConcurrentCount, + ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); + + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", + RunningObjectCount, + ROUND_UP_TO_1K (RunningObjectSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", + RunningAllocCount, + ROUND_UP_TO_1K (RunningAllocSize))); + + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current Nodes", + AcpiGbl_CurrentNodeCount, + ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max Nodes", + AcpiGbl_MaxConcurrentNodeCount, + ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * + sizeof (ACPI_NAMESPACE_NODE))))); +*/ + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpAllocations + * + * PARAMETERS: Component - Component(s) to dump info for. + * Module - Module to dump info for. NULL means all. + * + * RETURN: None + * + * DESCRIPTION: Print a list of all outstanding allocations. + * + ******************************************************************************/ + +void +AcpiUtDumpAllocations ( + UINT32 Component, + char *Module) +{ + ACPI_DEBUG_MEM_BLOCK *Element; + ACPI_DESCRIPTOR *Descriptor; + UINT32 NumOutstanding = 0; + + + ACPI_FUNCTION_TRACE (UtDumpAllocations); + + + /* + * Walk the allocation list. + */ + if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY))) + { + return; + } + + Element = AcpiGbl_GlobalList->ListHead; + while (Element) + { + if ((Element->Component & Component) && + ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) + { + /* Ignore allocated objects that are in a cache */ + + Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); + if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) + { + AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", + Descriptor, Element->Size, Element->Module, + Element->Line, AcpiUtGetDescriptorName (Descriptor)); + + /* Most of the elements will be Operand objects. */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) + { + case ACPI_DESC_TYPE_OPERAND: + AcpiOsPrintf ("%12.12s R%hd", + AcpiUtGetTypeName (Descriptor->Object.Common.Type), + Descriptor->Object.Common.ReferenceCount); + break; + + case ACPI_DESC_TYPE_PARSER: + AcpiOsPrintf ("AmlOpcode %04hX", + Descriptor->Op.Asl.AmlOpcode); + break; + + case ACPI_DESC_TYPE_NAMED: + AcpiOsPrintf ("%4.4s", + AcpiUtGetNodeName (&Descriptor->Node)); + break; + + default: + break; + } + + AcpiOsPrintf ( "\n"); + NumOutstanding++; + } + } + Element = Element->Next; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + + /* Print summary */ + + if (!NumOutstanding) + { + ACPI_INFO ((AE_INFO, + "No outstanding allocations")); + } + else + { + ACPI_ERROR ((AE_INFO, + "%d(%X) Outstanding allocations", + NumOutstanding, NumOutstanding)); + } + + return_VOID; +} + +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + diff --git a/sys/dist/acpica/utxface.c b/sys/dist/acpica/utxface.c index 77614af678c..ce114a14831 100644 --- a/sys/dist/acpica/utxface.c +++ b/sys/dist/acpica/utxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utxface - External interfaces for "global" ACPI functions - * xRevision: 1.116 $ + * $Revision: 1.4 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -115,15 +115,12 @@ *****************************************************************************/ -#include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utxface.c,v 1.3 2006/11/16 01:33:32 christos Exp $"); - #define __UTXFACE_C__ -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" -#include "acdebug.h" +#include <dist/acpica/acpi.h> +#include <dist/acpica/acevents.h> +#include <dist/acpica/acnamesp.h> +#include <dist/acpica/acdebug.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utxface") @@ -149,9 +146,10 @@ AcpiInitializeSubsystem ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiInitializeSubsystem"); + ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem); + AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE; ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ()); /* Initialize the OS-Dependent layer */ @@ -193,6 +191,8 @@ AcpiInitializeSubsystem ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem) + /******************************************************************************* * @@ -214,25 +214,9 @@ AcpiEnableSubsystem ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("AcpiEnableSubsystem"); + ACPI_FUNCTION_TRACE (AcpiEnableSubsystem); - /* - * We must initialize the hardware before we can enable ACPI. - * The values from the FADT are validated here. - */ - if (!(Flags & ACPI_NO_HARDWARE_INIT)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "[Init] Initializing ACPI hardware\n")); - - Status = AcpiHwInitialize (); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - /* Enable ACPI mode */ if (!(Flags & ACPI_NO_ACPI_ENABLE)) @@ -329,6 +313,8 @@ AcpiEnableSubsystem ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem) + /******************************************************************************* * @@ -350,7 +336,7 @@ AcpiInitializeObjects ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("AcpiInitializeObjects"); + ACPI_FUNCTION_TRACE (AcpiInitializeObjects); /* @@ -416,6 +402,8 @@ AcpiInitializeObjects ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInitializeObjects) + /******************************************************************************* * @@ -436,7 +424,7 @@ AcpiTerminate ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("AcpiTerminate"); + ACPI_FUNCTION_TRACE (AcpiTerminate); /* Terminate the AML Debugger if present */ @@ -466,6 +454,8 @@ AcpiTerminate ( return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiTerminate) + /******************************************************************************* * @@ -496,6 +486,8 @@ AcpiSubsystemStatus ( } } +ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus) + /******************************************************************************* * @@ -521,10 +513,9 @@ AcpiGetSystemInfo ( { ACPI_SYSTEM_INFO *InfoPtr; ACPI_STATUS Status; - UINT32 i; - ACPI_FUNCTION_TRACE ("AcpiGetSystemInfo"); + ACPI_FUNCTION_TRACE (AcpiGetSystemInfo); /* Parameter validation */ @@ -548,19 +539,15 @@ AcpiGetSystemInfo ( */ InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer; - InfoPtr->AcpiCaVersion = ACPI_CA_VERSION; + InfoPtr->AcpiCaVersion = ACPI_CA_VERSION; /* System flags (ACPI capabilities) */ - InfoPtr->Flags = ACPI_SYS_MODE_ACPI; + InfoPtr->Flags = ACPI_SYS_MODE_ACPI; /* Timer resolution - 24 or 32 bits */ - if (!AcpiGbl_FADT) - { - InfoPtr->TimerResolution = 0; - } - else if (AcpiGbl_FADT->TmrValExt == 0) + if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) { InfoPtr->TimerResolution = 24; } @@ -571,25 +558,19 @@ AcpiGetSystemInfo ( /* Clear the reserved fields */ - InfoPtr->Reserved1 = 0; - InfoPtr->Reserved2 = 0; + InfoPtr->Reserved1 = 0; + InfoPtr->Reserved2 = 0; /* Current debug levels */ - InfoPtr->DebugLayer = AcpiDbgLayer; - InfoPtr->DebugLevel = AcpiDbgLevel; - - /* Current status of the ACPI tables, per table type */ - - InfoPtr->NumTableTypes = NUM_ACPI_TABLE_TYPES; - for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) - { - InfoPtr->TableInfo[i].Count = AcpiGbl_TableLists[i].Count; - } + InfoPtr->DebugLayer = AcpiDbgLayer; + InfoPtr->DebugLevel = AcpiDbgLevel; return_ACPI_STATUS (AE_OK); } +ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo) + /***************************************************************************** * @@ -626,6 +607,8 @@ AcpiInstallInitializationHandler ( return AE_OK; } +ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler) + /***************************************************************************** * @@ -643,7 +626,7 @@ ACPI_STATUS AcpiPurgeCachedObjects ( void) { - ACPI_FUNCTION_TRACE ("AcpiPurgeCachedObjects"); + ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects); (void) AcpiOsPurgeCache (AcpiGbl_StateCache); (void) AcpiOsPurgeCache (AcpiGbl_OperandCache); @@ -651,3 +634,5 @@ AcpiPurgeCachedObjects ( (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache); return_ACPI_STATUS (AE_OK); } + +ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects) diff --git a/sys/kern/kern_pmf.c b/sys/kern/kern_pmf.c new file mode 100644 index 00000000000..d2394bd0378 --- /dev/null +++ b/sys/kern/kern_pmf.c @@ -0,0 +1,600 @@ +/* $NetBSD: kern_pmf.c,v 1.2 2007/12/09 20:28:43 jmcneill Exp $ */ + +/*- + * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jared D. McNeill. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.2 2007/12/09 20:28:43 jmcneill Exp $"); + +#include <sys/types.h> +#include <sys/param.h> +#include <sys/malloc.h> +#include <sys/buf.h> +#include <sys/callout.h> +#include <sys/kernel.h> +#include <sys/device.h> +#include <sys/pmf.h> +#include <sys/queue.h> +#include <sys/kmem.h> +#include <sys/syscallargs.h> /* for sys_sync */ +#include <sys/workqueue.h> +#include <prop/proplib.h> + +#ifdef PMF_DEBUG +int pmf_debug_event; +int pmf_debug_idle; +int pmf_debug_transition; + +#define PMF_EVENT_PRINTF(x) if (pmf_debug_event) printf x +#define PMF_IDLE_PRINTF(x) if (pmf_debug_idle) printf x +#define PMF_TRANSITION_PRINTF(x) if (pmf_debug_transition) printf x +#define PMF_TRANSITION_PRINTF2(y,x) if (pmf_debug_transition>y) printf x +#else +#define PMF_EVENT_PRINTF(x) do { } while (0) +#define PMF_IDLE_PRINTF(x) do { } while (0) +#define PMF_TRANSITION_PRINTF(x) do { } while (0) +#define PMF_TRANSITION_PRINTF2(y,x) do { } while (0) +#endif + +/* #define PMF_DEBUG */ + +MALLOC_DEFINE(M_PMF, "pmf", "device pmf messaging memory"); + +static prop_dictionary_t pmf_platform = NULL; +static struct workqueue *pmf_event_workqueue; + +typedef struct pmf_event_handler { + TAILQ_ENTRY(pmf_event_handler) pmf_link; + pmf_generic_event_t pmf_event; + void (*pmf_handler)(device_t); + device_t pmf_device; + bool pmf_global; +} pmf_event_handler_t; + +static TAILQ_HEAD(, pmf_event_handler) pmf_all_events = + TAILQ_HEAD_INITIALIZER(pmf_all_events); + +typedef struct pmf_event_workitem { + struct work pew_work; + pmf_generic_event_t pew_event; + device_t pew_device; +} pmf_event_workitem_t; + +static void +pmf_event_worker(struct work *wk, void *dummy) +{ + pmf_event_workitem_t *pew; + pmf_event_handler_t *event; + + pew = (void *)wk; + KASSERT(wk == &pew->pew_work); + KASSERT(pew != NULL); + + TAILQ_FOREACH(event, &pmf_all_events, pmf_link) { + if (event->pmf_event != pew->pew_event) + continue; + if (event->pmf_device != pew->pew_device || event->pmf_global) + (*event->pmf_handler)(event->pmf_device); + } + + kmem_free(pew, sizeof(pmf_event_workitem_t)); + + return; +} + +static bool +pmf_check_system_drivers(void) +{ + device_t curdev; + bool unsupported_devs; + + unsupported_devs = false; + TAILQ_FOREACH(curdev, &alldevs, dv_list) { + if (device_pmf_is_registered(curdev)) + continue; + if (!unsupported_devs) + printf("Devices without power management support:"); + printf(" %s", device_xname(curdev)); + unsupported_devs = true; + } + if (unsupported_devs) { + printf("\n"); + return false; + } + return true; +} + +bool +pmf_system_resume(void) +{ + int depth, maxdepth; + bool rv; + device_t curdev, parent; + + if (!pmf_check_system_drivers()) + return false; + + maxdepth = 0; + TAILQ_FOREACH(curdev, &alldevs, dv_list) { + if (curdev->dv_depth > maxdepth) + maxdepth = curdev->dv_depth; + } + ++maxdepth; + + aprint_debug("Resuming devices:"); + /* D0 handlers are run in order */ + depth = 0; + rv = true; + for (depth = 0; depth < maxdepth; ++depth) { + TAILQ_FOREACH(curdev, &alldevs, dv_list) { + if (device_is_active(curdev) || + !device_is_enabled(curdev)) + continue; + if (curdev->dv_depth != depth) + continue; + parent = device_parent(curdev); + if (parent != NULL && + !device_is_active(parent)) + continue; + + aprint_debug(" %s", device_xname(curdev)); + + if (!pmf_device_resume(curdev)) { + rv = false; + aprint_debug("(failed)"); + } + } + } + aprint_debug(".\n"); + + return rv; +} + +bool +pmf_system_suspend(void) +{ + int depth, maxdepth; + device_t curdev; + + if (!pmf_check_system_drivers()) + return false; + + /* + * Flush buffers only if the shutdown didn't do so + * already and if there was no panic. + */ + if (doing_shutdown == 0 && panicstr == NULL) { + printf("Flushing disk caches: "); + sys_sync(NULL, NULL, NULL); + if (buf_syncwait() != 0) + printf("giving up\n"); + else + printf("done\n"); + } + + aprint_debug("Suspending devices:"); + + maxdepth = 0; + TAILQ_FOREACH(curdev, &alldevs, dv_list) { + if (curdev->dv_depth > maxdepth) + maxdepth = curdev->dv_depth; + } + + for (depth = maxdepth; depth >= 0; --depth) { + TAILQ_FOREACH_REVERSE(curdev, &alldevs, devicelist, dv_list) { + if (curdev->dv_depth != depth) + continue; + if (!device_is_active(curdev)) + continue; + + aprint_debug(" %s", device_xname(curdev)); + + /* XXX joerg check return value and abort suspend */ + if (!pmf_device_suspend(curdev)) + aprint_debug("(failed)"); + } + } + + aprint_debug(".\n"); + + return true; +} + +void +pmf_system_shutdown(void) +{ + int depth, maxdepth; + device_t curdev; + + if (!pmf_check_system_drivers()) + delay(2000000); + + aprint_debug("Shutting down devices:"); + + maxdepth = 0; + TAILQ_FOREACH(curdev, &alldevs, dv_list) { + if (curdev->dv_depth > maxdepth) + maxdepth = curdev->dv_depth; + } + + for (depth = maxdepth; depth >= 0; --depth) { + TAILQ_FOREACH_REVERSE(curdev, &alldevs, devicelist, dv_list) { + if (curdev->dv_depth != depth) + continue; + if (!device_is_active(curdev)) + continue; + + aprint_debug(" %s", device_xname(curdev)); + + if (!device_pmf_is_registered(curdev)) + continue; + if (!device_pmf_class_suspend(curdev)) { + aprint_debug("(failed)"); + continue; + } + if (!device_pmf_driver_suspend(curdev)) { + aprint_debug("(failed)"); + continue; + } + } + } + + aprint_debug(".\n"); +} + +bool +pmf_set_platform(const char *key, const char *value) +{ + if (pmf_platform == NULL) + pmf_platform = prop_dictionary_create(); + if (pmf_platform == NULL) + return false; + + return prop_dictionary_set_cstring(pmf_platform, key, value); +} + +const char * +pmf_get_platform(const char *key) +{ + const char *value; + + if (pmf_platform == NULL) + return NULL; + + if (!prop_dictionary_get_cstring_nocopy(pmf_platform, key, &value)) + return NULL; + + return value; +} + +bool +pmf_device_register(device_t dev, + bool (*suspend)(device_t), bool (*resume)(device_t)) +{ + device_pmf_driver_register(dev, suspend, resume); + + if (!device_pmf_driver_child_register(dev)) { + device_pmf_driver_deregister(dev); + return false; + } + + return true; +} + +void +pmf_device_deregister(device_t dev) +{ + device_pmf_class_deregister(dev); + device_pmf_bus_deregister(dev); + device_pmf_driver_deregister(dev); +} + +bool +pmf_device_suspend(device_t dev) +{ + PMF_TRANSITION_PRINTF(("%s: suspend enter\n", device_xname(dev))); + if (!device_pmf_is_registered(dev)) + return false; + PMF_TRANSITION_PRINTF2(1, ("%s: class suspend\n", device_xname(dev))); + if (!device_pmf_class_suspend(dev)) + return false; + PMF_TRANSITION_PRINTF2(1, ("%s: driver suspend\n", device_xname(dev))); + if (!device_pmf_driver_suspend(dev)) + return false; + PMF_TRANSITION_PRINTF2(1, ("%s: bus suspend\n", device_xname(dev))); + if (!device_pmf_bus_suspend(dev)) + return false; + PMF_TRANSITION_PRINTF(("%s: suspend exit\n", device_xname(dev))); + return true; +} + +bool +pmf_device_resume(device_t dev) +{ + PMF_TRANSITION_PRINTF(("%s: resume enter\n", device_xname(dev))); + if (!device_pmf_is_registered(dev)) + return false; + PMF_TRANSITION_PRINTF2(1, ("%s: bus resume\n", device_xname(dev))); + if (!device_pmf_bus_resume(dev)) + return false; + PMF_TRANSITION_PRINTF2(1, ("%s: driver resume\n", device_xname(dev))); + if (!device_pmf_driver_resume(dev)) + return false; + PMF_TRANSITION_PRINTF2(1, ("%s: class resume\n", device_xname(dev))); + if (!device_pmf_class_resume(dev)) + return false; + PMF_TRANSITION_PRINTF(("%s: resume exit\n", device_xname(dev))); + return true; +} + +bool +pmf_device_recursive_suspend(device_t dv) +{ + device_t curdev; + + if (!device_is_active(dv)) + return true; + + TAILQ_FOREACH(curdev, &alldevs, dv_list) { + if (device_parent(curdev) != dv) + continue; + if (!pmf_device_recursive_suspend(curdev)) + return false; + } + + return pmf_device_suspend(dv); +} + +bool +pmf_device_recursive_resume(device_t dv) +{ + device_t parent; + + if (device_is_active(dv)) + return true; + + parent = device_parent(dv); + if (parent != NULL) { + if (!pmf_device_recursive_resume(parent)) + return false; + } + + return pmf_device_resume(dv); +} + +bool +pmf_device_resume_subtree(device_t dv) +{ + device_t curdev; + + if (!pmf_device_recursive_resume(dv)) + return false; + + TAILQ_FOREACH(curdev, &alldevs, dv_list) { + if (device_parent(curdev) != dv) + continue; + if (!pmf_device_resume_subtree(curdev)) + return false; + } + return true; +} + +#include <net/if.h> + +static bool +pmf_class_network_suspend(device_t dev) +{ + struct ifnet *ifp = device_pmf_class_private(dev); + int s; + + s = splnet(); + (*ifp->if_stop)(ifp, 1); + splx(s); + + return true; +} + +static bool +pmf_class_network_resume(device_t dev) +{ + struct ifnet *ifp = device_pmf_class_private(dev); + int s; + + s = splnet(); + if (ifp->if_flags & IFF_UP) { + ifp->if_flags &= ~IFF_RUNNING; + (*ifp->if_init)(ifp); + (*ifp->if_start)(ifp); + } + splx(s); + + return true; +} + +void +pmf_class_network_register(device_t dev, struct ifnet *ifp) +{ + device_pmf_class_register(dev, ifp, pmf_class_network_suspend, + pmf_class_network_resume, NULL); +} + +bool +pmf_event_inject(device_t dv, pmf_generic_event_t ev) +{ + pmf_event_workitem_t *pew; + + pew = kmem_alloc(sizeof(pmf_event_workitem_t), KM_NOSLEEP); + if (pew == NULL) { + PMF_EVENT_PRINTF(("%s: PMF event %d dropped (no memory)\n", + dv ? device_xname(dv) : "<anonymous>", ev)); + return false; + } + + pew->pew_event = ev; + pew->pew_device = dv; + + workqueue_enqueue(pmf_event_workqueue, (void *)pew, NULL); + PMF_EVENT_PRINTF(("%s: PMF event %d injected\n", + dv ? device_xname(dv) : "<anonymous>", ev)); + + return true; +} + +bool +pmf_event_register(device_t dv, pmf_generic_event_t ev, + void (*handler)(device_t), bool global) +{ + pmf_event_handler_t *event; + + event = malloc(sizeof(*event), M_DEVBUF, M_WAITOK); + event->pmf_event = ev; + event->pmf_handler = handler; + event->pmf_device = dv; + event->pmf_global = global; + TAILQ_INSERT_TAIL(&pmf_all_events, event, pmf_link); + + return true; +} + +void +pmf_event_deregister(device_t dv, pmf_generic_event_t ev, + void (*handler)(device_t), bool global) +{ + pmf_event_handler_t *event; + + TAILQ_FOREACH(event, &pmf_all_events, pmf_link) { + if (event->pmf_event != ev) + continue; + if (event->pmf_device != dv) + continue; + if (event->pmf_global != global) + continue; + if (event->pmf_handler != handler) + continue; + TAILQ_REMOVE(&pmf_all_events, event, pmf_link); + free(event, M_WAITOK); + } +} + +struct display_class_softc { + TAILQ_ENTRY(display_class_softc) dc_link; + device_t dc_dev; +}; + +static TAILQ_HEAD(, display_class_softc) all_displays; +static callout_t global_idle_counter; +static int idle_timeout = 30; + +static void +input_idle(void *dummy) +{ + PMF_IDLE_PRINTF(("Input idle handler called\n")); + pmf_event_inject(NULL, PMFE_DISPLAY_OFF); +} + +static void +input_activity_handler(device_t dv, devactive_t type) +{ + if (!TAILQ_EMPTY(&all_displays)) + callout_schedule(&global_idle_counter, idle_timeout * hz); +} + +static void +pmf_class_input_deregister(device_t dv) +{ + device_active_deregister(dv, input_activity_handler); +} + +bool +pmf_class_input_register(device_t dv) +{ + if (!device_active_register(dv, input_activity_handler)) + return false; + + device_pmf_class_register(dv, NULL, NULL, NULL, + pmf_class_input_deregister); + + return true; +} + +static void +pmf_class_display_deregister(device_t dv) +{ + struct display_class_softc *sc = device_pmf_class_private(dv); + int s; + + s = splsoftclock(); + TAILQ_REMOVE(&all_displays, sc, dc_link); + if (TAILQ_EMPTY(&all_displays)) + callout_stop(&global_idle_counter); + splx(s); + + free(sc, M_DEVBUF); +} + +bool +pmf_class_display_register(device_t dv) +{ + struct display_class_softc *sc; + int s; + + sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK); + + s = splsoftclock(); + if (TAILQ_EMPTY(&all_displays)) + callout_schedule(&global_idle_counter, idle_timeout * hz); + + TAILQ_INSERT_HEAD(&all_displays, sc, dc_link); + splx(s); + + device_pmf_class_register(dv, sc, NULL, NULL, + pmf_class_display_deregister); + + return true; +} + +void +pmf_init(void) +{ + int err; + + KASSERT(pmf_event_workqueue == NULL); + err = workqueue_create(&pmf_event_workqueue, "pmfevent", + pmf_event_worker, NULL, PRI_IDLE, IPL_VM, 0); + if (err) + panic("couldn't create pmfevent workqueue"); + + callout_init(&global_idle_counter, 0); + callout_setfunc(&global_idle_counter, input_idle, NULL); + + return; +} diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index b66d3820d35..a511581f45d 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_subr.c,v 1.166 2007/11/26 19:02:02 pooka Exp $ */ +/* $NetBSD: kern_subr.c,v 1.167 2007/12/09 20:28:43 jmcneill Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2006 The NetBSD Foundation, Inc. @@ -86,7 +86,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.166 2007/11/26 19:02:02 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.167 2007/12/09 20:28:43 jmcneill Exp $"); #include "opt_ddb.h" #include "opt_md.h" @@ -114,6 +114,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.166 2007/11/26 19:02:02 pooka Exp $" #include <sys/fcntl.h> #include <sys/kauth.h> #include <sys/vnode.h> +#include <sys/pmf.h> #include <uvm/uvm_extern.h> @@ -500,6 +501,8 @@ doshutdownhooks(void) free(dp, M_DEVBUF); #endif } + + pmf_system_shutdown(); } /* @@ -645,6 +648,7 @@ powerhook_establish(const char *name, void (*fn)(int, void *), void *arg) strlcpy(ndp->sfd_name, name, sizeof(ndp->sfd_name)); CIRCLEQ_INSERT_HEAD(&powerhook_list, ndp, sfd_list); + aprint_error("%s: WARNING: powerhook_establish is deprecated\n", name); return (ndp); } diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index d070078ccff..7564492a7be 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.123 2007/11/26 19:02:03 pooka Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.124 2007/12/09 20:28:44 jmcneill Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.123 2007/11/26 19:02:03 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.124 2007/12/09 20:28:44 jmcneill Exp $"); #include "opt_multiprocessor.h" #include "opt_ddb.h" @@ -103,6 +103,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.123 2007/11/26 19:02:03 pooka Ex #include <sys/unistd.h> #include <sys/fcntl.h> #include <sys/lockf.h> +#include <sys/callout.h> #include <sys/disk.h> @@ -361,6 +362,7 @@ configure(void) /* Initialize data structures. */ config_init(); + pmf_init(); #ifdef USERCONF if (boothowto & RB_USERCONF) @@ -1132,15 +1134,22 @@ config_devalloc(const device_t parent, const cfdata_t cf, const int *locs) } if (dev == NULL) panic("config_devalloc: memory allocation for device_t failed"); + dev->dv_class = cd->cd_class; dev->dv_cfdata = cf; dev->dv_cfdriver = cd; dev->dv_cfattach = ca; dev->dv_unit = myunit; + dev->dv_activity_count = 0; + dev->dv_activity_handlers = NULL; dev->dv_private = dev_private; memcpy(dev->dv_xname, cd->cd_name, lname); memcpy(dev->dv_xname + lname, xunit, lunit); dev->dv_parent = parent; + if (parent != NULL) + dev->dv_depth = parent->dv_depth + 1; + else + dev->dv_depth = 0; dev->dv_flags = DVF_ACTIVE; /* always initially active */ dev->dv_flags |= ca->ca_flags; /* inherit flags from class */ if (locs) { @@ -1164,6 +1173,9 @@ config_devdealloc(device_t dev) KASSERT(dev->dv_properties != NULL); prop_object_release(dev->dv_properties); + if (dev->dv_activity_handlers) + panic("config_devdealloc with registered handlers"); + if (dev->dv_locators) free(dev->dv_locators, M_DEVBUF); @@ -1249,6 +1261,7 @@ config_attach_loc(device_t parent, cfdata_t cf, #ifdef __HAVE_DEVICE_REGISTER device_register(dev, aux); #endif + #if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS) if (splash_progress_state) splash_progress_update(splash_progress_state); @@ -1258,6 +1271,10 @@ config_attach_loc(device_t parent, cfdata_t cf, if (splash_progress_state) splash_progress_update(splash_progress_state); #endif + + if (!device_pmf_is_registered(dev)) + aprint_error_dev(dev, "WARNING: power management not supported\n"); + config_process_deferred(&deferred_config_queue, dev); return (dev); } @@ -1693,8 +1710,30 @@ device_parent(device_t dev) bool device_is_active(device_t dev) { + int active_flags; + + active_flags = DVF_ACTIVE; + active_flags |= DVF_CLASS_SUSPENDED; + active_flags |= DVF_DRIVER_SUSPENDED; + active_flags |= DVF_BUS_SUSPENDED; + + return ((dev->dv_flags & active_flags) == DVF_ACTIVE); +} + +bool +device_is_enabled(device_t dev) +{ + return (dev->dv_flags & DVF_ACTIVE) == DVF_ACTIVE; +} + +bool +device_has_power(device_t dev) +{ + int active_flags; - return ((dev->dv_flags & DVF_ACTIVE) != 0); + active_flags = DVF_ACTIVE | DVF_BUS_SUSPENDED; + + return ((dev->dv_flags & active_flags) == DVF_ACTIVE); } int @@ -1731,3 +1770,278 @@ device_is_a(device_t dev, const char *dname) return (strcmp(dev->dv_cfdriver->cd_name, dname) == 0); } + +/* + * Power management related functions. + */ + +bool +device_pmf_is_registered(device_t dev) +{ + return (dev->dv_flags & DVF_POWER_HANDLERS) != 0; +} + +bool +device_pmf_driver_suspend(device_t dev) +{ + if ((dev->dv_flags & DVF_DRIVER_SUSPENDED) != 0) + return true; + if ((dev->dv_flags & DVF_CLASS_SUSPENDED) == 0) + return false; + if (*dev->dv_driver_suspend != NULL && + !(*dev->dv_driver_suspend)(dev)) + return false; + + dev->dv_flags |= DVF_DRIVER_SUSPENDED; + return true; +} + +bool +device_pmf_driver_resume(device_t dev) +{ + if ((dev->dv_flags & DVF_DRIVER_SUSPENDED) == 0) + return true; + if ((dev->dv_flags & DVF_BUS_SUSPENDED) != 0) + return false; + if (*dev->dv_driver_resume != NULL && + !(*dev->dv_driver_resume)(dev)) + return false; + + dev->dv_flags &= ~DVF_DRIVER_SUSPENDED; + return true; +} + +void +device_pmf_driver_register(device_t dev, + bool (*suspend)(device_t), bool (*resume)(device_t)) +{ + dev->dv_driver_suspend = suspend; + dev->dv_driver_resume = resume; + dev->dv_flags |= DVF_POWER_HANDLERS; +} + +void +device_pmf_driver_deregister(device_t dev) +{ + dev->dv_driver_suspend = NULL; + dev->dv_driver_resume = NULL; + dev->dv_flags &= ~DVF_POWER_HANDLERS; +} + +bool +device_pmf_driver_child_register(device_t dev) +{ + device_t parent = device_parent(dev); + + if (parent == NULL || parent->dv_driver_child_register == NULL) + return true; + return (*parent->dv_driver_child_register)(dev); +} + +void +device_pmf_driver_set_child_register(device_t dev, + bool (*child_register)(device_t)) +{ + dev->dv_driver_child_register = child_register; +} + +void * +device_pmf_bus_private(device_t dev) +{ + return dev->dv_bus_private; +} + +bool +device_pmf_bus_suspend(device_t dev) +{ + if ((dev->dv_flags & DVF_BUS_SUSPENDED) != 0) + return true; + if ((dev->dv_flags & DVF_CLASS_SUSPENDED) == 0 || + (dev->dv_flags & DVF_DRIVER_SUSPENDED) == 0) + return false; + if (*dev->dv_bus_suspend != NULL && + !(*dev->dv_bus_suspend)(dev)) + return false; + + dev->dv_flags |= DVF_BUS_SUSPENDED; + return true; +} + +bool +device_pmf_bus_resume(device_t dev) +{ + if ((dev->dv_flags & DVF_BUS_SUSPENDED) == 0) + return true; + if (*dev->dv_bus_resume != NULL && + !(*dev->dv_bus_resume)(dev)) + return false; + + dev->dv_flags &= ~DVF_BUS_SUSPENDED; + return true; +} + +void +device_pmf_bus_register(device_t dev, void *priv, + bool (*suspend)(device_t), bool (*resume)(device_t), + void (*deregister)(device_t)) +{ + dev->dv_bus_private = priv; + dev->dv_bus_resume = resume; + dev->dv_bus_suspend = suspend; + dev->dv_bus_deregister = deregister; +} + +void +device_pmf_bus_deregister(device_t dev) +{ + if (dev->dv_bus_deregister == NULL) + return; + (*dev->dv_bus_deregister)(dev); + dev->dv_bus_private = NULL; + dev->dv_bus_suspend = NULL; + dev->dv_bus_resume = NULL; + dev->dv_bus_deregister = NULL; +} + +void * +device_pmf_class_private(device_t dev) +{ + return dev->dv_class_private; +} + +bool +device_pmf_class_suspend(device_t dev) +{ + if ((dev->dv_flags & DVF_CLASS_SUSPENDED) != 0) + return true; + if (*dev->dv_class_suspend != NULL && + !(*dev->dv_class_suspend)(dev)) + return false; + + dev->dv_flags |= DVF_CLASS_SUSPENDED; + return true; +} + +bool +device_pmf_class_resume(device_t dev) +{ + if ((dev->dv_flags & DVF_CLASS_SUSPENDED) == 0) + return true; + if ((dev->dv_flags & DVF_BUS_SUSPENDED) != 0 || + (dev->dv_flags & DVF_DRIVER_SUSPENDED) != 0) + return false; + if (*dev->dv_class_resume != NULL && + !(*dev->dv_class_resume)(dev)) + return false; + + dev->dv_flags &= ~DVF_CLASS_SUSPENDED; + return true; +} + +void +device_pmf_class_register(device_t dev, void *priv, + bool (*suspend)(device_t), bool (*resume)(device_t), + void (*deregister)(device_t)) +{ + dev->dv_class_private = priv; + dev->dv_class_suspend = suspend; + dev->dv_class_resume = resume; + dev->dv_class_deregister = deregister; +} + +void +device_pmf_class_deregister(device_t dev) +{ + if (dev->dv_class_deregister == NULL) + return; + (*dev->dv_class_deregister)(dev); + dev->dv_class_private = NULL; + dev->dv_class_suspend = NULL; + dev->dv_class_resume = NULL; + dev->dv_class_deregister = NULL; +} + +bool +device_active(device_t dev, devactive_t type) +{ + size_t i; + + if (dev->dv_activity_count == 0) + return false; + + for (i = 0; i < dev->dv_activity_count; ++i) + (*dev->dv_activity_handlers[i])(dev, type); + + return true; +} + +bool +device_active_register(device_t dev, void (*handler)(device_t, devactive_t)) +{ + void (**new_handlers)(device_t, devactive_t); + void (**old_handlers)(device_t, devactive_t); + size_t i, new_size; + int s; + + old_handlers = dev->dv_activity_handlers; + + for (i = 0; i < dev->dv_activity_count; ++i) { + if (old_handlers[i] == handler) + panic("Double registering of idle handlers"); + } + + new_size = dev->dv_activity_count + 1; + new_handlers = malloc(sizeof(void *) * new_size, M_DEVBUF, M_WAITOK); + + memcpy(new_handlers, old_handlers, + sizeof(void *) * dev->dv_activity_count); + new_handlers[new_size - 1] = handler; + + s = splhigh(); + dev->dv_activity_count = new_size; + dev->dv_activity_handlers = new_handlers; + splx(s); + + if (old_handlers != NULL) + free(old_handlers, M_DEVBUF); + + return true; +} + +void +device_active_deregister(device_t dev, void (*handler)(device_t, devactive_t)) +{ + void (**new_handlers)(device_t, devactive_t); + void (**old_handlers)(device_t, devactive_t); + size_t i, new_size; + int s; + + old_handlers = dev->dv_activity_handlers; + + for (i = 0; i < dev->dv_activity_count; ++i) { + if (old_handlers[i] == handler) + break; + } + + if (i == dev->dv_activity_count) + return; /* XXX panic? */ + + new_size = dev->dv_activity_count - 1; + + if (new_size == 0) { + new_handlers = NULL; + } else { + new_handlers = malloc(sizeof(void *) * new_size, M_DEVBUF, + M_WAITOK); + memcpy(new_handlers, old_handlers, sizeof(void *) * i); + memcpy(new_handlers + i, old_handlers + i + 1, + sizeof(void *) * (new_size - i)); + } + + s = splhigh(); + dev->dv_activity_count = new_size; + dev->dv_activity_handlers = new_handlers; + splx(s); + + free(old_handlers, M_DEVBUF); +} diff --git a/sys/sys/Makefile b/sys/sys/Makefile index 338cad87533..a6da3d524e7 100644 --- a/sys/sys/Makefile +++ b/sys/sys/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.102 2007/11/12 23:12:00 ad Exp $ +# $NetBSD: Makefile,v 1.103 2007/12/09 20:28:44 jmcneill Exp $ .include <bsd.sys.mk> @@ -22,7 +22,7 @@ INCS= acct.h agpio.h aio.h ansi.h ataio.h audioio.h \ malloc.h mallocvar.h mbuf.h md4.h \ md5.h midiio.h mman.h mount.h mqueue.h msg.h msgbuf.h mtio.h mutex.h \ namei.h null.h \ - param.h pipe.h pmc.h poll.h pool.h power.h proc.h \ + param.h pipe.h pmc.h pmf.h poll.h pool.h power.h proc.h \ protosw.h ptrace.h queue.h \ ras.h reboot.h radioio.h resource.h resourcevar.h rmd160.h rnd.h rwlock.h \ scanio.h sched.h scsiio.h select.h selinfo.h sem.h sha1.h sha2.h \ diff --git a/sys/sys/device.h b/sys/sys/device.h index f02a7efb14e..7853bca423a 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.98 2007/09/24 18:47:57 joerg Exp $ */ +/* $NetBSD: device.h,v 1.99 2007/12/09 20:28:44 jmcneill Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -80,6 +80,9 @@ #include <sys/evcnt.h> #include <sys/queue.h> +typedef struct device *device_t; +#include <sys/pmf.h> + #include <prop/proplib.h> /* @@ -92,7 +95,10 @@ typedef enum devclass { DV_DISK, /* disk drive (label, etc) */ DV_IFNET, /* network interface */ DV_TAPE, /* tape device */ - DV_TTY /* serial line interface (?) */ + DV_TTY, /* serial line interface (?) */ + DV_AUDIODEV, /* audio device */ + DV_DISPLAYDEV, /* display device */ + DV_BUS /* bus device */ } devclass_t; /* @@ -103,10 +109,14 @@ typedef enum devact { DVACT_DEACTIVATE /* deactivate the device */ } devact_t; +typedef enum { + DVA_SYSTEM, + DVA_HARDWARE +} devactive_t; + typedef struct cfdata *cfdata_t; typedef struct cfdriver *cfdriver_t; typedef struct cfattach *cfattach_t; -typedef struct device *device_t; struct device { devclass_t dv_class; /* this device's classification */ @@ -119,15 +129,37 @@ struct device { char dv_xname[16]; /* external name (name + unit) */ device_t dv_parent; /* pointer to parent device (NULL if pseudo- or root node) */ + int dv_depth; /* number of parents until root */ int dv_flags; /* misc. flags; see below */ void *dv_private; /* this device's private storage */ int *dv_locators; /* our actual locators (optional) */ prop_dictionary_t dv_properties;/* properties dictionary */ + + size_t dv_activity_count; + void (**dv_activity_handlers)(device_t, devactive_t); + + bool (*dv_driver_suspend)(device_t); + bool (*dv_driver_resume)(device_t); + bool (*dv_driver_child_register)(device_t); + + void *dv_bus_private; + bool (*dv_bus_suspend)(device_t); + bool (*dv_bus_resume)(device_t); + void (*dv_bus_deregister)(device_t); + + void *dv_class_private; + bool (*dv_class_suspend)(device_t); + bool (*dv_class_resume)(device_t); + void (*dv_class_deregister)(device_t); }; /* dv_flags */ -#define DVF_ACTIVE 0x0001 /* device is activated */ -#define DVF_PRIV_ALLOC 0x0002 /* device private storage != device */ +#define DVF_ACTIVE 0x0001 /* device is activated */ +#define DVF_PRIV_ALLOC 0x0002 /* device private storage != device */ +#define DVF_POWER_HANDLERS 0x0004 /* device has suspend/resume support */ +#define DVF_CLASS_SUSPENDED 0x0008 /* device class suspend was called */ +#define DVF_DRIVER_SUSPENDED 0x0010 /* device driver suspend was called */ +#define DVF_BUS_SUSPENDED 0x0020 /* device bus suspend was called */ TAILQ_HEAD(devicelist, device); @@ -393,12 +425,51 @@ int device_unit(device_t); const char *device_xname(device_t); device_t device_parent(device_t); bool device_is_active(device_t); +bool device_is_enabled(device_t); +bool device_has_power(device_t); int device_locator(device_t, u_int); void *device_private(device_t); prop_dictionary_t device_properties(device_t); +bool device_active(device_t, devactive_t); +bool device_active_register(device_t, + void (*)(device_t, devactive_t)); +void device_active_deregister(device_t, + void (*)(device_t, devactive_t)); + bool device_is_a(device_t, const char *); +bool device_pmf_is_registered(device_t); + +bool device_pmf_driver_suspend(device_t); +bool device_pmf_driver_resume(device_t); + +void device_pmf_driver_register(device_t, + bool (*)(device_t), bool (*)(device_t)); +void device_pmf_driver_deregister(device_t); + +bool device_pmf_driver_child_register(device_t); +void device_pmf_driver_set_child_register(device_t, + bool (*)(device_t)); + +void *device_pmf_bus_private(device_t); +bool device_pmf_bus_suspend(device_t); +bool device_pmf_bus_resume(device_t); + +void device_pmf_bus_register(device_t, void *, + bool (*)(device_t), bool (*)(device_t), + void (*)(device_t)); +void device_pmf_bus_deregister(device_t); + +void *device_pmf_class_private(device_t); +bool device_pmf_class_suspend(device_t); +bool device_pmf_class_resume(device_t); + +void device_pmf_class_register(device_t, void *, + bool (*)(device_t), bool (*)(device_t), + void (*)(device_t)); +void device_pmf_class_deregister(device_t); + #endif /* _KERNEL */ #endif /* !_SYS_DEVICE_H_ */ diff --git a/sys/sys/pmf.h b/sys/sys/pmf.h new file mode 100644 index 00000000000..c9da2312a52 --- /dev/null +++ b/sys/sys/pmf.h @@ -0,0 +1,87 @@ +/* $NetBSD: pmf.h,v 1.2 2007/12/09 20:28:44 jmcneill Exp $ */ + +/*- + * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jared D. McNeill. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_PMF_H +#define _SYS_PMF_H + +#include <sys/callout.h> + +typedef enum { + PMFE_DISPLAY_ON, + PMFE_DISPLAY_REDUCED, + PMFE_DISPLAY_STANDBY, + PMFE_DISPLAY_SUSPEND, + PMFE_DISPLAY_OFF, + PMFE_DISPLAY_BRIGHTNESS_UP, + PMFE_DISPLAY_BRIGHTNESS_DOWN, + PMFE_AUDIO_VOLUME_UP, + PMFE_AUDIO_VOLUME_DOWN, + PMFE_AUDIO_VOLUME_TOGGLE, + PMFE_CHASSIS_LID_CLOSE, + PMFE_CHASSIS_LID_OPEN +} pmf_generic_event_t; + +void pmf_init(void); + +bool pmf_event_inject(device_t, pmf_generic_event_t); +bool pmf_event_register(device_t, pmf_generic_event_t, + void (*)(device_t), bool); +void pmf_event_deregister(device_t, pmf_generic_event_t, + void (*)(device_t), bool); + +bool pmf_set_platform(const char *, const char *); +const char *pmf_get_platform(const char *); + +bool pmf_system_resume(void); +bool pmf_system_suspend(void); +void pmf_system_shutdown(void); + +bool pmf_device_register(device_t, + bool (*)(device_t), + bool (*)(device_t)); +void pmf_device_deregister(device_t); +bool pmf_device_suspend(device_t); +bool pmf_device_resume(device_t); + +bool pmf_device_recursive_suspend(device_t); +bool pmf_device_recursive_resume(device_t); +bool pmf_device_resume_subtree(device_t); + +struct ifnet; +void pmf_class_network_register(device_t, struct ifnet *); + +bool pmf_class_input_register(device_t); +bool pmf_class_display_register(device_t); + +#endif /* !_SYS_PMF_H */ |
