From 8f6295e0c7ad66ba5a3462b84794e1cac156450b Mon Sep 17 00:00:00 2001 From: takawata Date: Thu, 31 Aug 2000 15:34:54 +0000 Subject: [PATCH] Merge rest piece of ACPI driver.To activate acpi driver ,add device acpi line. Merge finished. But still experimental phase.Need more hack! Obtained from:ACPI for FreeBSD project --- sys/amd64/amd64/bios.c | 25 ++++++++++++++++++++++++- sys/amd64/amd64/machdep.c | 17 +++++++++++++++-- sys/conf/NOTES | 7 +++++++ sys/conf/files | 11 +++++++++++ sys/conf/files.i386 | 1 + sys/conf/options | 6 ++++++ sys/i386/conf/NOTES | 7 +++++++ sys/i386/i386/bios.c | 25 ++++++++++++++++++++++++- sys/i386/i386/machdep.c | 17 +++++++++++++++-- 9 files changed, 110 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/bios.c b/sys/amd64/amd64/bios.c index fdcdbc66cc3..18f49894123 100644 --- a/sys/amd64/amd64/bios.c +++ b/sys/amd64/amd64/bios.c @@ -31,6 +31,7 @@ * Code for dealing with the BIOS in x86 PC systems. */ +#include "acpi.h" #include "isa.h" #include @@ -49,6 +50,10 @@ #include #include +#if NACPI > 0 +#include +#endif + #define BIOS_START 0xe0000 #define BIOS_SIZE 0x20000 @@ -143,11 +148,29 @@ bios32_init(void *junk) printf("pnpbios: Bad PnP BIOS data checksum\n"); } } +#if NACPI > 0 + /* + * ACPI BIOS + * acpi_rsdp is GLOBAL and holds RSD PTR signature + */ + if ((sigaddr = bios_sigsearch(0, "RSD PTR ", 8, 16, 0)) != 0) { + /* get a virtual pointer to the structure */ + acpi_rsdp = (struct ACPIrsdp *)(uintptr_t)BIOS_PADDRTOVADDR(sigaddr); + for (cv = (u_int8_t *)acpi_rsdp, ck = 0, i = 0; i < sizeof(struct ACPIrsdp); i++) { + ck += cv[i]; + } + + /* If checksum is NG, disable it */ + if (ck != 0) { + printf("ACPI: Bad ACPI BIOS data checksum\n"); + acpi_rsdp=NULL;/* 0xa0000<=RSD_PTR<0x100000*/ + } + } +#endif if (bootverbose) { /* look for other know signatures */ printf("Other BIOS signatures found:\n"); - printf("ACPI: %08x\n", bios_sigsearch(0, "RSD PTR ", 8, 16, 0)); } } diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 5e0dcba09de..781ff87195a 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -37,7 +37,7 @@ * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD$ */ - +#include "acpi.h" #include "apm.h" #include "npx.h" #include "opt_atalk.h" @@ -116,6 +116,10 @@ #include #include +#if NACPI > 0 +#include +#endif + extern void init386 __P((int first)); extern void dblfault_handler __P((void)); @@ -1489,6 +1493,9 @@ getmemsize(int first) smap = (void *)vm86_addpage(&vmc, 1, KERNBASE + (1 << PAGE_SHIFT)); vm86_getptr(&vmc, (vm_offset_t)smap, &vmf.vmf_es, &vmf.vmf_di); +#if NACPI > 0 + acpi_init_addr_range(); +#endif physmap_idx = 0; vmf.vmf_ebx = 0; do { @@ -1505,7 +1512,13 @@ getmemsize(int first) (u_int32_t)smap->base, *(u_int32_t *)((char *)&smap->length + 4), (u_int32_t)smap->length); - +#if NACPI > 0 + /* Save ACPI related memory Info */ + if (smap->type == 0x03 || smap->type == 0x04) { + acpi_register_addr_range(smap->base, + smap->length, smap->type); + } +#endif if (smap->type != 0x01) goto next_run; diff --git a/sys/conf/NOTES b/sys/conf/NOTES index c2c367855ac..b89221f76b6 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -1193,6 +1193,13 @@ hint.npx.0.irq="13" # Flag 0x08 automatically disables the i586 optimized routines. # +# ACPI Experimental Driver +device acpi +options ACPI_DEBUG +options AML_DEBUG +options ACPI_NO_ENABLE_ON_BOOT +options ACPI_NO_OSDFUNC_INLINE + # # Optional devices: # diff --git a/sys/conf/files b/sys/conf/files index 4ac48a6a2fb..33817e71d49 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -71,6 +71,17 @@ ddb/db_trap.c optional ddb ddb/db_variables.c optional ddb ddb/db_watch.c optional ddb ddb/db_write_cmd.c optional ddb +dev/acpi/acpi.c count acpi +dev/acpi/acpi_powerres.c optional acpi +dev/acpi/aml/aml_amlmem.c optional acpi +dev/acpi/aml/aml_common.c optional acpi +dev/acpi/aml/aml_evalobj.c optional acpi +dev/acpi/aml/aml_memman.c optional acpi +dev/acpi/aml/aml_name.c optional acpi +dev/acpi/aml/aml_obj.c optional acpi +dev/acpi/aml/aml_parse.c optional acpi +dev/acpi/aml/aml_store.c optional acpi +dev/acpi/aml/aml_region.c optional acpi dev/advansys/adv_eisa.c optional adv eisa dev/advansys/adv_pci.c optional adv pci dev/advansys/advansys.c optional adv diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index c904e86196f..99c60963434 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -144,6 +144,7 @@ gnu/i386/isa/sound/awe_wave.c optional awe i386/apm/apm.c count apm i386/i386/atomic.c standard \ compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} ${.IMPSRC}" +i386/i386/acpi_machdep.c optional acpi i386/i386/autoconf.c standard i386/i386/bios.c standard i386/i386/bioscall.s standard diff --git a/sys/conf/options b/sys/conf/options index a181a80718f..d4ce246ca0c 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -449,3 +449,9 @@ FDC_DEBUG opt_fdc.h PCFCLOCK_VERBOSE opt_pcfclock.h PCFCLOCK_MAX_RETRIES opt_pcfclock.h TDFX_LINUX opt_tdfx.h + +# options for ACPI support +ACPI_DEBUG opt_acpi.h +AML_DEBUG opt_acpi.h +ACPI_NO_ENABLE_ON_BOOT opt_acpi.h +ACPI_NO_OSDFUNC_INLINE opt_acpi.h diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index c2c367855ac..b89221f76b6 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -1193,6 +1193,13 @@ hint.npx.0.irq="13" # Flag 0x08 automatically disables the i586 optimized routines. # +# ACPI Experimental Driver +device acpi +options ACPI_DEBUG +options AML_DEBUG +options ACPI_NO_ENABLE_ON_BOOT +options ACPI_NO_OSDFUNC_INLINE + # # Optional devices: # diff --git a/sys/i386/i386/bios.c b/sys/i386/i386/bios.c index fdcdbc66cc3..18f49894123 100644 --- a/sys/i386/i386/bios.c +++ b/sys/i386/i386/bios.c @@ -31,6 +31,7 @@ * Code for dealing with the BIOS in x86 PC systems. */ +#include "acpi.h" #include "isa.h" #include @@ -49,6 +50,10 @@ #include #include +#if NACPI > 0 +#include +#endif + #define BIOS_START 0xe0000 #define BIOS_SIZE 0x20000 @@ -143,11 +148,29 @@ bios32_init(void *junk) printf("pnpbios: Bad PnP BIOS data checksum\n"); } } +#if NACPI > 0 + /* + * ACPI BIOS + * acpi_rsdp is GLOBAL and holds RSD PTR signature + */ + if ((sigaddr = bios_sigsearch(0, "RSD PTR ", 8, 16, 0)) != 0) { + /* get a virtual pointer to the structure */ + acpi_rsdp = (struct ACPIrsdp *)(uintptr_t)BIOS_PADDRTOVADDR(sigaddr); + for (cv = (u_int8_t *)acpi_rsdp, ck = 0, i = 0; i < sizeof(struct ACPIrsdp); i++) { + ck += cv[i]; + } + + /* If checksum is NG, disable it */ + if (ck != 0) { + printf("ACPI: Bad ACPI BIOS data checksum\n"); + acpi_rsdp=NULL;/* 0xa0000<=RSD_PTR<0x100000*/ + } + } +#endif if (bootverbose) { /* look for other know signatures */ printf("Other BIOS signatures found:\n"); - printf("ACPI: %08x\n", bios_sigsearch(0, "RSD PTR ", 8, 16, 0)); } } diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 5e0dcba09de..781ff87195a 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -37,7 +37,7 @@ * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD$ */ - +#include "acpi.h" #include "apm.h" #include "npx.h" #include "opt_atalk.h" @@ -116,6 +116,10 @@ #include #include +#if NACPI > 0 +#include +#endif + extern void init386 __P((int first)); extern void dblfault_handler __P((void)); @@ -1489,6 +1493,9 @@ getmemsize(int first) smap = (void *)vm86_addpage(&vmc, 1, KERNBASE + (1 << PAGE_SHIFT)); vm86_getptr(&vmc, (vm_offset_t)smap, &vmf.vmf_es, &vmf.vmf_di); +#if NACPI > 0 + acpi_init_addr_range(); +#endif physmap_idx = 0; vmf.vmf_ebx = 0; do { @@ -1505,7 +1512,13 @@ getmemsize(int first) (u_int32_t)smap->base, *(u_int32_t *)((char *)&smap->length + 4), (u_int32_t)smap->length); - +#if NACPI > 0 + /* Save ACPI related memory Info */ + if (smap->type == 0x03 || smap->type == 0x04) { + acpi_register_addr_range(smap->base, + smap->length, smap->type); + } +#endif if (smap->type != 0x01) goto next_run; -- 2.45.2