diff options
author | msmith <msmith@FreeBSD.org> | 2000-09-30 20:12:27 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 2000-09-30 20:12:27 +0000 |
commit | 43b494595ef50e9426434fd028f71567c7fc2e36 (patch) | |
tree | 04488cdbfa2a244cc961901253683a6d7f5405b8 /sys/i386 | |
parent | 8cc643d7ff3e76e0d1cadc99dbd6ad666b8a0171 (diff) | |
download | FreeBSD-src-43b494595ef50e9426434fd028f71567c7fc2e36.zip FreeBSD-src-43b494595ef50e9426434fd028f71567c7fc2e36.tar.gz |
More updates to the ACPI code:
- Move all register I/O into acpi_io.c
- Move event handling into acpi_event.c
- Reorganise headers into acpivar/acpireg/acpiio
- Move find-RSDT and find-ACPI-owned-memory into acpi_machdep
- Allocate all resources (except those detailed only by AML)
as real resources. Add infrastructure that will make adding
resource support to AML code easy.
- Remove all ACPI #ifdefs in non-ACPI code
- Removed unnecessary includes
- Minor style and commenting fixes
Reviewed by: iwasaki
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/i386/acpi_machdep.c | 114 | ||||
-rw-r--r-- | sys/i386/i386/bios.c | 25 | ||||
-rw-r--r-- | sys/i386/i386/machdep.c | 28 | ||||
-rw-r--r-- | sys/i386/include/pc/bios.h | 13 |
4 files changed, 125 insertions, 55 deletions
diff --git a/sys/i386/i386/acpi_machdep.c b/sys/i386/i386/acpi_machdep.c index 45c6916..ef25f0b 100644 --- a/sys/i386/i386/acpi_machdep.c +++ b/sys/i386/i386/acpi_machdep.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org> + * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,14 +23,116 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: acpi_machdep.c,v 1.4 2000/08/08 14:12:10 iwasaki Exp $ * $FreeBSD$ */ #include "opt_acpi.h" +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/bus.h> -#include <machine/acpi_machdep.h> +#include <vm/vm.h> +#include <vm/pmap.h> -#ifdef ACPI_NO_OSDFUNC_INLINE -#include <machine/acpica_osd.h> -#endif /* ACPI_NO_OSDFUNC_INLINE */ +#include <machine/bus.h> +#include <machine/md_var.h> +#include <machine/vmparam.h> +#include <machine/vm86.h> +#include <machine/pc/bios.h> + +#include <dev/acpi/acpireg.h> +#include <dev/acpi/acpivar.h> + +struct ACPIrsdp * +acpi_find_rsdp(void) +{ + u_long sigaddr; + struct ACPIrsdp *rsdp; + u_int8_t ck, *cv; + int i, year; + char *dp; + + /* + * Search for the RSD PTR signature. + */ + if ((sigaddr = bios_sigsearch(0, "RSD PTR ", 8, 16, 0)) == 0) + return(NULL); + + /* get a virtual pointer to the structure */ + rsdp = (struct ACPIrsdp *)(uintptr_t)BIOS_PADDRTOVADDR(sigaddr); + for (cv = (u_int8_t *)rsdp, ck = 0, i = 0; i < sizeof(struct ACPIrsdp); i++) { + ck += cv[i]; + } + + /* + * Fail if the checksum doesn't match. + */ + if (ck != 0) { + printf("ACPI: Bad ACPI BIOS data checksum\n"); + return(NULL); + } + + /* + * Fail if the BIOS is too old to be trustworthy. + * XXX we should check the ACPI BIOS blacklist/goodlist here. + */ + dp = (char *)(uintptr_t)BIOS_PADDRTOVADDR(0xffff5); + year = ((*(dp + 6) - '0') * 10) + (*(dp + 7) - '0'); + if (year < 70) + year += 100; + if (year < 99) { + printf("ACPI: BIOS too old (%.8s < 01/01/99)\n", dp); + return(NULL); + } + + return(rsdp); +} + +/* + * Find and map all memory regions that are regarded as belonging to ACPI + * and let the MI code know about them. Scan the ACPI memory map as managed + * by the MI code and map it into kernel space. + */ +void +acpi_mapmem(void) +{ + struct vm86frame vmf; + struct vm86context vmc; + struct bios_smap *smap; + vm_offset_t va; + int i; + + bzero(&vmf, sizeof(struct vm86frame)); + + acpi_init_addr_range(); + + /* + * Scan memory map with INT 15:E820 + */ + vmc.npages = 0; + smap = (void *)vm86_addpage(&vmc, 1, KERNBASE + (1 << PAGE_SHIFT)); + vm86_getptr(&vmc, (vm_offset_t)smap, &vmf.vmf_es, &vmf.vmf_di); + + vmf.vmf_ebx = 0; + do { + vmf.vmf_eax = 0xE820; + vmf.vmf_edx = SMAP_SIG; + vmf.vmf_ecx = sizeof(struct bios_smap); + i = vm86_datacall(0x15, &vmf, &vmc); + if (i || vmf.vmf_eax != SMAP_SIG) + break; + + /* ACPI-owned memory? */ + if (smap->type == 0x03 || smap->type == 0x04) { + acpi_register_addr_range(smap->base, smap->length, smap->type); + } + } while (vmf.vmf_ebx != 0); + + /* + * Map the physical ranges that have been registered into the kernel. + */ + for (i = 0; i < acpi_addr.entries; i++) { + va = (vm_offset_t)pmap_mapdev(acpi_addr.t[i].pa_base, acpi_addr.t[i].size); + acpi_addr.t[i].va_base = va; + } +} diff --git a/sys/i386/i386/bios.c b/sys/i386/i386/bios.c index 18f4989..56880ea 100644 --- a/sys/i386/i386/bios.c +++ b/sys/i386/i386/bios.c @@ -31,7 +31,6 @@ * Code for dealing with the BIOS in x86 PC systems. */ -#include "acpi.h" #include "isa.h" #include <sys/param.h> @@ -50,10 +49,6 @@ #include <isa/pnpreg.h> #include <isa/pnpvar.h> -#if NACPI > 0 -#include <sys/acpi.h> -#endif - #define BIOS_START 0xe0000 #define BIOS_SIZE 0x20000 @@ -148,26 +143,6 @@ 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"); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 69e241a..4fb4c45 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -37,7 +37,6 @@ * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD$ */ -#include "acpi.h" #include "apm.h" #include "npx.h" #include "opt_atalk.h" @@ -100,6 +99,7 @@ #include <machine/ipl.h> #include <machine/md_var.h> #include <machine/mutex.h> +#include <machine/pc/bios.h> #include <machine/pcb_ext.h> /* pcb.h included via sys/user.h */ #include <machine/globaldata.h> #include <machine/globals.h> @@ -120,10 +120,6 @@ #include <sys/ptrace.h> #include <machine/sigframe.h> -#if NACPI > 0 -#include <sys/acpi.h> -#endif - extern void init386 __P((int first)); extern void dblfault_handler __P((void)); @@ -1457,11 +1453,7 @@ getmemsize(int first) vm_offset_t pa, physmap[PHYSMAP_SIZE]; pt_entry_t pte; const char *cp; - struct { - u_int64_t base; - u_int64_t length; - u_int32_t type; - } *smap; + struct bios_smap *smap; bzero(&vmf, sizeof(struct vm86frame)); bzero(physmap, sizeof(physmap)); @@ -1521,22 +1513,16 @@ getmemsize(int first) /* * get memory map with INT 15:E820 */ -#define SMAPSIZ sizeof(*smap) -#define SMAP_SIG 0x534D4150 /* 'SMAP' */ - vmc.npages = 0; 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 { vmf.vmf_eax = 0xE820; vmf.vmf_edx = SMAP_SIG; - vmf.vmf_ecx = SMAPSIZ; + vmf.vmf_ecx = sizeof(struct bios_smap); i = vm86_datacall(0x15, &vmf, &vmc); if (i || vmf.vmf_eax != SMAP_SIG) break; @@ -1547,13 +1533,7 @@ 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/i386/include/pc/bios.h b/sys/i386/include/pc/bios.h index 1d8b893..9df5a0d 100644 --- a/sys/i386/include/pc/bios.h +++ b/sys/i386/include/pc/bios.h @@ -218,3 +218,16 @@ extern int bios16(struct bios_args *, char *, ...); extern int bios16_call(struct bios_regs *, char *); extern int bios32(struct bios_regs *, u_int, u_short); extern void set_bios_selectors(struct bios_segments *, int); + +/* + * Int 15:E820 'SMAP' structure + * + * XXX add constants for type + */ +#define SMAP_SIG 0x534D4150 /* 'SMAP' */ +struct bios_smap { + u_int64_t base; + u_int64_t length; + u_int32_t type; +} __attribute__ ((packed)); + |