Home | History | Annotate | Line # | Download | only in acpica
OsdMemory.c revision 1.1.6.2
      1  1.1.6.2  elad /*	$NetBSD: OsdMemory.c,v 1.1.6.2 2006/04/19 03:24:24 elad Exp $	*/
      2  1.1.6.2  elad 
      3  1.1.6.2  elad /*
      4  1.1.6.2  elad  * Copyright 2001 Wasabi Systems, Inc.
      5  1.1.6.2  elad  * All rights reserved.
      6  1.1.6.2  elad  *
      7  1.1.6.2  elad  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8  1.1.6.2  elad  *
      9  1.1.6.2  elad  * Redistribution and use in source and binary forms, with or without
     10  1.1.6.2  elad  * modification, are permitted provided that the following conditions
     11  1.1.6.2  elad  * are met:
     12  1.1.6.2  elad  * 1. Redistributions of source code must retain the above copyright
     13  1.1.6.2  elad  *    notice, this list of conditions and the following disclaimer.
     14  1.1.6.2  elad  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1.6.2  elad  *    notice, this list of conditions and the following disclaimer in the
     16  1.1.6.2  elad  *    documentation and/or other materials provided with the distribution.
     17  1.1.6.2  elad  * 3. All advertising materials mentioning features or use of this software
     18  1.1.6.2  elad  *    must display the following acknowledgement:
     19  1.1.6.2  elad  *	This product includes software developed for the NetBSD Project by
     20  1.1.6.2  elad  *	Wasabi Systems, Inc.
     21  1.1.6.2  elad  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  1.1.6.2  elad  *    or promote products derived from this software without specific prior
     23  1.1.6.2  elad  *    written permission.
     24  1.1.6.2  elad  *
     25  1.1.6.2  elad  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  1.1.6.2  elad  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  1.1.6.2  elad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  1.1.6.2  elad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  1.1.6.2  elad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  1.1.6.2  elad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  1.1.6.2  elad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  1.1.6.2  elad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  1.1.6.2  elad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  1.1.6.2  elad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  1.1.6.2  elad  * POSSIBILITY OF SUCH DAMAGE.
     36  1.1.6.2  elad  */
     37  1.1.6.2  elad 
     38  1.1.6.2  elad /*
     39  1.1.6.2  elad  * OS Services Layer
     40  1.1.6.2  elad  *
     41  1.1.6.2  elad  * 6.2: Memory management.
     42  1.1.6.2  elad  */
     43  1.1.6.2  elad 
     44  1.1.6.2  elad #include <sys/cdefs.h>
     45  1.1.6.2  elad __KERNEL_RCSID(0, "$NetBSD: OsdMemory.c,v 1.1.6.2 2006/04/19 03:24:24 elad Exp $");
     46  1.1.6.2  elad 
     47  1.1.6.2  elad #include <sys/param.h>
     48  1.1.6.2  elad #include <sys/malloc.h>
     49  1.1.6.2  elad 
     50  1.1.6.2  elad #include <dev/acpi/acpica.h>
     51  1.1.6.2  elad 
     52  1.1.6.2  elad #include <machine/acpi_machdep.h>
     53  1.1.6.2  elad 
     54  1.1.6.2  elad MALLOC_DECLARE(M_ACPI);
     55  1.1.6.2  elad 
     56  1.1.6.2  elad /*
     57  1.1.6.2  elad  * AcpiOsMapMemory:
     58  1.1.6.2  elad  *
     59  1.1.6.2  elad  *	Map physical memory into the caller's address space.
     60  1.1.6.2  elad  */
     61  1.1.6.2  elad ACPI_STATUS
     62  1.1.6.2  elad AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length,
     63  1.1.6.2  elad     void **LogicalAddress)
     64  1.1.6.2  elad {
     65  1.1.6.2  elad 
     66  1.1.6.2  elad 	return acpi_md_OsMapMemory(PhysicalAddress, Length, LogicalAddress);
     67  1.1.6.2  elad }
     68  1.1.6.2  elad 
     69  1.1.6.2  elad /*
     70  1.1.6.2  elad  * AcpiOsUnmapMemory:
     71  1.1.6.2  elad  *
     72  1.1.6.2  elad  *	Remove a physical to logical memory mapping.
     73  1.1.6.2  elad  */
     74  1.1.6.2  elad void
     75  1.1.6.2  elad AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Length)
     76  1.1.6.2  elad {
     77  1.1.6.2  elad 
     78  1.1.6.2  elad 	acpi_md_OsUnmapMemory(LogicalAddress, Length);
     79  1.1.6.2  elad }
     80  1.1.6.2  elad 
     81  1.1.6.2  elad /*
     82  1.1.6.2  elad  * AcpiOsGetPhysicalAddress:
     83  1.1.6.2  elad  *
     84  1.1.6.2  elad  *	Translate a logical address to a physical address.
     85  1.1.6.2  elad  */
     86  1.1.6.2  elad ACPI_STATUS
     87  1.1.6.2  elad AcpiOsGetPhysicalAddress(void *LogicalAddress,
     88  1.1.6.2  elad     ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
     89  1.1.6.2  elad {
     90  1.1.6.2  elad 
     91  1.1.6.2  elad 	return acpi_md_OsGetPhysicalAddress(LogicalAddress, PhysicalAddress);
     92  1.1.6.2  elad }
     93  1.1.6.2  elad 
     94  1.1.6.2  elad /*
     95  1.1.6.2  elad  * AcpiOsAllocate:
     96  1.1.6.2  elad  *
     97  1.1.6.2  elad  *	Allocate memory from the dynamic memory pool.
     98  1.1.6.2  elad  */
     99  1.1.6.2  elad void *
    100  1.1.6.2  elad AcpiOsAllocate(ACPI_SIZE Size)
    101  1.1.6.2  elad {
    102  1.1.6.2  elad 
    103  1.1.6.2  elad 	return malloc(Size, M_ACPI, M_NOWAIT);
    104  1.1.6.2  elad }
    105  1.1.6.2  elad 
    106  1.1.6.2  elad /*
    107  1.1.6.2  elad  * AcpiOsFree:
    108  1.1.6.2  elad  *
    109  1.1.6.2  elad  *	Free previously allocated memory.
    110  1.1.6.2  elad  */
    111  1.1.6.2  elad void
    112  1.1.6.2  elad AcpiOsFree(void *Memory)
    113  1.1.6.2  elad {
    114  1.1.6.2  elad 
    115  1.1.6.2  elad 	free(Memory, M_ACPI);
    116  1.1.6.2  elad }
    117  1.1.6.2  elad 
    118  1.1.6.2  elad 
    119  1.1.6.2  elad /*
    120  1.1.6.2  elad  * AcpiOsReadable:
    121  1.1.6.2  elad  *
    122  1.1.6.2  elad  *	Check if a memory region is readable.
    123  1.1.6.2  elad  */
    124  1.1.6.2  elad BOOLEAN
    125  1.1.6.2  elad AcpiOsReadable(void *Pointer, ACPI_SIZE Length)
    126  1.1.6.2  elad {
    127  1.1.6.2  elad 
    128  1.1.6.2  elad 	return acpi_md_OsReadable(Pointer, Length);
    129  1.1.6.2  elad }
    130  1.1.6.2  elad 
    131  1.1.6.2  elad /*
    132  1.1.6.2  elad  * AcpiOsWritable:
    133  1.1.6.2  elad  *
    134  1.1.6.2  elad  *	Check if a memory region is writable (and readable).
    135  1.1.6.2  elad  */
    136  1.1.6.2  elad BOOLEAN
    137  1.1.6.2  elad AcpiOsWritable(void *Pointer, ACPI_SIZE Length)
    138  1.1.6.2  elad {
    139  1.1.6.2  elad 
    140  1.1.6.2  elad 	return acpi_md_OsWritable(Pointer, Length);
    141  1.1.6.2  elad }
    142