Index: conf/files =================================================================== RCS file: /home/ncvs/src/sys/conf/files,v retrieving revision 1.1063 diff -u -r1.1063 files --- conf/files 1 Nov 2005 22:44:07 -0000 1.1063 +++ conf/files 4 Nov 2005 00:10:17 -0000 @@ -237,8 +237,7 @@ contrib/dev/acpica/tbxface.c optional acpi contrib/dev/acpica/tbxfroot.c optional acpi contrib/dev/acpica/utalloc.c optional acpi -contrib/dev/acpica/utcache.c optional acpi \ - compile-with "${NORMAL_C} -DACPI_USE_LOCAL_CACHE" +contrib/dev/acpica/utcache.c optional acpi contrib/dev/acpica/utclib.c optional acpi contrib/dev/acpica/utcopy.c optional acpi contrib/dev/acpica/utdebug.c optional acpi @@ -401,6 +400,7 @@ dev/acpi_support/acpi_panasonic.c optional acpi_panasonic acpi dev/acpi_support/acpi_sony.c optional acpi_sony acpi dev/acpi_support/acpi_toshiba.c optional acpi_toshiba acpi +dev/acpica/Osd/OsdCache.c optional acpi dev/acpica/Osd/OsdDebug.c optional acpi dev/acpica/Osd/OsdHardware.c optional acpi dev/acpica/Osd/OsdInterrupt.c optional acpi Index: contrib/dev/acpica/acfreebsd.h =================================================================== RCS file: /home/ncvs/src/sys/contrib/dev/acpica/acfreebsd.h,v retrieving revision 1.30 diff -u -r1.30 acfreebsd.h --- contrib/dev/acpica/acfreebsd.h 1 Nov 2005 22:23:25 -0000 1.30 +++ contrib/dev/acpica/acfreebsd.h 4 Nov 2005 00:10:17 -0000 @@ -151,6 +151,21 @@ #endif /* DDB */ #endif /* ACPI_DEBUG_OUTPUT */ +#ifdef ACPI_USE_LOCAL_CACHE +#define acpi_cache_t struct acpi_memory_list +#else +#include +struct acpi_uma_zone { + uma_zone_t zone; + void *head; +#if 0 + uint16_t count; + uint16_t max; +#endif +}; +#define ACPI_CACHE_T struct acpi_uma_zone +#endif + #else /* _KERNEL */ /* Not building kernel code, so use libc */ Index: dev/acpica/Osd/OsdCache.c =================================================================== RCS file: dev/acpica/Osd/OsdCache.c diff -N dev/acpica/Osd/OsdCache.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ dev/acpica/Osd/OsdCache.c 4 Nov 2005 00:10:17 -0000 @@ -0,0 +1,165 @@ +/*- + * Copyright (c) 2005 Jung-uk Kim + * 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 +__FBSDID("$FreeBSD$"); + +#include + +#include "opt_acpi.h" +#include +#include + +#define _COMPONENT ACPI_OS_SERVICES +ACPI_MODULE_NAME("CACHE") + +#ifndef ACPI_USE_LOCAL_CACHE + +MALLOC_DEFINE(M_ACPICACHE, "acpicache", "ACPI cache memory pool"); + +ACPI_STATUS +AcpiOsCreateCache(char *CacheName, UINT16 ObjectSize, UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache) +{ + ACPI_CACHE_T *cache; + uma_zone_t zone; + + cache = (ACPI_CACHE_T *)malloc(sizeof(ACPI_CACHE_T), M_ACPICACHE, + M_WAITOK); + zone = uma_zcreate(CacheName, sizeof(void *) + ObjectSize, NULL, NULL, + NULL, NULL, UMA_ALIGN_PTR, 0); +#if 0 + /* XXX Something's requesting a lot more than it should. */ + uma_zone_set_max(zone, MaxDepth); + cache->count = 0; + cache->max = MaxDepth; +#endif + cache->zone = zone; + cache->head = NULL; + *ReturnCache = cache; + + return (AE_OK); +} + +ACPI_STATUS +AcpiOsPurgeCache(ACPI_CACHE_T *Cache) +{ + void *cp, *np; + + if (Cache == NULL) + return (AE_BAD_PARAMETER); + + cp = Cache->head; + while (cp != NULL) { + np = *(void **)cp; + AcpiOsReleaseObject(Cache, + (void *)((uintptr_t)cp + sizeof(void *))); + cp = np; + } + + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteCache(ACPI_CACHE_T *Cache) +{ + + if (Cache == NULL) + return (AE_BAD_PARAMETER); + + uma_zdestroy(Cache->zone); + free(Cache, M_ACPICACHE); + + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object) +{ + void *item, *cp, *pp, *np; + + if (Cache == NULL || Object == NULL) + return (AE_BAD_PARAMETER); + + if (Cache->head == NULL) + return (AE_NOT_FOUND); + + item = (void *)((uintptr_t)Object - sizeof(void *)); + + pp = Cache->head; + if (pp == item) { +#if 0 + Cache->count--; +#endif + Cache->head = *(void **)item; + uma_zfree(Cache->zone, item); + return (AE_OK); + } + + cp = *(void **)pp; + while (cp != NULL) { + np = *(void **)cp; + if (cp == item) { +#if 0 + Cache->count--; +#endif + *(void **)pp = np; + uma_zfree(Cache->zone, item); + return (AE_OK); + } + pp = cp; + cp = np; + } + + return (AE_NOT_FOUND); +} + +void * +AcpiOsAcquireObject(ACPI_CACHE_T *Cache) +{ + void *item; + + if (Cache == NULL) + return (NULL); + + item = uma_zalloc(Cache->zone, M_WAITOK | M_ZERO); + + if (Cache->head == NULL) + *(void **)item = NULL; + else + *(void **)item = *(void **)Cache->head; + Cache->head = item; +#if 0 + Cache->count++; + if (Cache->count > Cache->max) + printf("AcpiOsAcquireObject: Count = %u > MaxDepth = %d\n", + Cache->count, Cache->max); +#endif + + return ((void *)((uintptr_t)item + sizeof(void *))); +} + +#endif Index: modules/acpi/acpi/Makefile =================================================================== RCS file: /home/ncvs/src/sys/modules/acpi/acpi/Makefile,v retrieving revision 1.15 diff -u -r1.15 Makefile --- modules/acpi/acpi/Makefile 1 Nov 2005 22:44:08 -0000 1.15 +++ modules/acpi/acpi/Makefile 4 Nov 2005 00:10:17 -0000 @@ -64,7 +64,6 @@ DBSRC+= dmbuffer.c dmnames.c dmopcode.c dmobject.c dmresrc.c dmresrcl.c DBSRC+= dmresrcs.c dmutils.c dmwalk.c -CFLAGS+=-DACPI_USE_LOCAL_CACHE .if !defined(KERNBUILDDIR) .if ACPI_MAX_THREADS CFLAGS+=-DACPI_MAX_THREADS=${ACPI_MAX_THREADS}