OsdMemory.c (67760) | OsdMemory.c (69459) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2000 Mitsaru Iwasaki |
|
2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * | 3 * Copyright (c) 2000 Michael Smith 4 * Copyright (c) 2000 BSDi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
27 * $FreeBSD: head/sys/dev/acpica/Osd/OsdMemory.c 67760 2000-10-28 06:56:15Z msmith $ | 28 * $FreeBSD: head/sys/dev/acpica/Osd/OsdMemory.c 69459 2000-12-01 10:19:28Z msmith $ |
28 */ 29 30/* 31 * 6.2 : Memory Management 32 */ 33 34#include "acpi.h" 35 --- 23 unchanged lines hidden (view full) --- 59 60void 61AcpiOsFree (void *Memory) 62{ 63 free(Memory, M_ACPICA); 64} 65 66ACPI_STATUS | 29 */ 30 31/* 32 * 6.2 : Memory Management 33 */ 34 35#include "acpi.h" 36 --- 23 unchanged lines hidden (view full) --- 60 61void 62AcpiOsFree (void *Memory) 63{ 64 free(Memory, M_ACPICA); 65} 66 67ACPI_STATUS |
67AcpiOsMapMemory (void *PhysicalAddress, UINT32 Length, void **LogicalAddress) | 68AcpiOsMapMemory (ACPI_PHYSICAL_ADDRESS PhysicalAddress, UINT32 Length, void **LogicalAddress) |
68{ 69 *LogicalAddress = pmap_mapdev((vm_offset_t)PhysicalAddress, Length); 70 if (*LogicalAddress == NULL) 71 return(AE_BAD_ADDRESS); 72 return(AE_OK); 73} 74 75void --- 13 unchanged lines hidden (view full) --- 89} 90 91BOOLEAN 92AcpiOsWritable (void *Pointer, UINT32 Length) 93{ 94 return(TRUE); 95} 96 | 69{ 70 *LogicalAddress = pmap_mapdev((vm_offset_t)PhysicalAddress, Length); 71 if (*LogicalAddress == NULL) 72 return(AE_BAD_ADDRESS); 73 return(AE_OK); 74} 75 76void --- 13 unchanged lines hidden (view full) --- 90} 91 92BOOLEAN 93AcpiOsWritable (void *Pointer, UINT32 Length) 94{ 95 return(TRUE); 96} 97 |
98static __inline 99UINT32 100AcpiOsMemInX (UINT32 Length, ACPI_PHYSICAL_ADDRESS InAddr) 101{ 102 UINT32 Value; 103 void *LogicalAddress; 104 105 if (AcpiOsMapMemory(InAddr, Length, &LogicalAddress) != AE_OK) { 106 return(0); 107 } 108 109 switch (Length) { 110 case 1: 111 Value = (*(volatile u_int8_t *)LogicalAddress) & 0xff; 112 break; 113 case 2: 114 Value = (*(volatile u_int16_t *)LogicalAddress) & 0xffff; 115 break; 116 case 4: 117 Value = (*(volatile u_int32_t *)LogicalAddress); 118 break; 119 } 120 121 AcpiOsUnmapMemory(LogicalAddress, Length); 122 123 return(Value); 124} 125 126UINT8 127AcpiOsMemIn8 (ACPI_PHYSICAL_ADDRESS InAddr) 128{ 129 return((UINT8)AcpiOsMemInX(1, InAddr)); 130} 131 132UINT16 133AcpiOsMemIn16 (ACPI_PHYSICAL_ADDRESS InAddr) 134{ 135 return((UINT16)AcpiOsMemInX(2, InAddr)); 136} 137 138UINT32 139AcpiOsMemIn32 (ACPI_PHYSICAL_ADDRESS InAddr) 140{ 141 return((UINT32)AcpiOsMemInX(4, InAddr)); 142} 143 144static __inline 145void 146AcpiOsMemOutX (UINT32 Length, ACPI_PHYSICAL_ADDRESS OutAddr, UINT32 Value) 147{ 148 void *LogicalAddress; 149 150 if (AcpiOsMapMemory(OutAddr, Length, &LogicalAddress) != AE_OK) { 151 return; 152 } 153 154 switch (Length) { 155 case 1: 156 (*(volatile u_int8_t *)LogicalAddress) = Value & 0xff; 157 break; 158 case 2: 159 (*(volatile u_int16_t *)LogicalAddress) = Value & 0xffff; 160 break; 161 case 4: 162 (*(volatile u_int32_t *)LogicalAddress) = Value; 163 break; 164 } 165 166 AcpiOsUnmapMemory(LogicalAddress, Length); 167} 168 169void 170AcpiOsMemOut8 (ACPI_PHYSICAL_ADDRESS OutAddr, UINT8 Value) 171{ 172 AcpiOsMemOutX(1, OutAddr, (UINT32)Value); 173} 174 175void 176AcpiOsMemOut16 (ACPI_PHYSICAL_ADDRESS OutAddr, UINT16 Value) 177{ 178 AcpiOsMemOutX(2, OutAddr, (UINT32)Value); 179} 180 181void 182AcpiOsMemOut32 (ACPI_PHYSICAL_ADDRESS OutAddr, UINT32 Value) 183{ 184 AcpiOsMemOutX(4, OutAddr, (UINT32)Value); 185} 186 |
|