Deleted Added
full compact
acpi.c (225736) acpi.c (227397)
1/*-
2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org>
3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
4 * Copyright (c) 2000, 2001 Michael Smith
5 * Copyright (c) 2000 BSDi
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org>
3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
4 * Copyright (c) 2000, 2001 Michael Smith
5 * Copyright (c) 2000 BSDi
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: stable/9/sys/dev/acpica/acpi.c 225533 2011-09-13 15:57:29Z brueffer $");
31__FBSDID("$FreeBSD: stable/9/sys/dev/acpica/acpi.c 227397 2011-11-09 18:12:42Z jhb $");
32
33#include "opt_acpi.h"
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/proc.h>
37#include <sys/fcntl.h>
38#include <sys/malloc.h>
39#include <sys/module.h>

--- 1193 unchanged lines hidden (view full) ---

1233acpi_alloc_resource(device_t bus, device_t child, int type, int *rid,
1234 u_long start, u_long end, u_long count, u_int flags)
1235{
1236 ACPI_RESOURCE ares;
1237 struct acpi_device *ad;
1238 struct resource_list_entry *rle;
1239 struct resource_list *rl;
1240 struct resource *res;
32
33#include "opt_acpi.h"
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/proc.h>
37#include <sys/fcntl.h>
38#include <sys/malloc.h>
39#include <sys/module.h>

--- 1193 unchanged lines hidden (view full) ---

1233acpi_alloc_resource(device_t bus, device_t child, int type, int *rid,
1234 u_long start, u_long end, u_long count, u_int flags)
1235{
1236 ACPI_RESOURCE ares;
1237 struct acpi_device *ad;
1238 struct resource_list_entry *rle;
1239 struct resource_list *rl;
1240 struct resource *res;
1241 struct rman *rm;
1242 int isdefault = (start == 0UL && end == ~0UL);
1243
1244 /*
1245 * First attempt at allocating the resource. For direct children,
1246 * use resource_list_alloc() to handle reserved resources. For
1247 * other devices, pass the request up to our parent.
1248 */
1249 if (bus == device_get_parent(child)) {

--- 36 unchanged lines hidden (view full) ---

1286 start = rle->start;
1287 end = rle->end;
1288 count = rle->count;
1289 }
1290 }
1291 } else
1292 res = BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, rid,
1293 start, end, count, flags);
1241 int isdefault = (start == 0UL && end == ~0UL);
1242
1243 /*
1244 * First attempt at allocating the resource. For direct children,
1245 * use resource_list_alloc() to handle reserved resources. For
1246 * other devices, pass the request up to our parent.
1247 */
1248 if (bus == device_get_parent(child)) {

--- 36 unchanged lines hidden (view full) ---

1285 start = rle->start;
1286 end = rle->end;
1287 count = rle->count;
1288 }
1289 }
1290 } else
1291 res = BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, rid,
1292 start, end, count, flags);
1294 if (res != NULL || start + count - 1 != end)
1295 return (res);
1296
1297 /*
1298 * If the first attempt failed and this is an allocation of a
1299 * specific range, try to satisfy the request via a suballocation
1293
1294 /*
1295 * If the first attempt failed and this is an allocation of a
1296 * specific range, try to satisfy the request via a suballocation
1300 * from our system resource regions. Note that we only handle
1301 * memory and I/O port system resources.
1297 * from our system resource regions.
1302 */
1298 */
1299 if (res == NULL && start + count - 1 == end)
1300 res = acpi_alloc_sysres(child, type, rid, start, end, count, flags);
1301 return (res);
1302}
1303
1304/*
1305 * Attempt to allocate a specific resource range from the system
1306 * resource ranges. Note that we only handle memory and I/O port
1307 * system resources.
1308 */
1309struct resource *
1310acpi_alloc_sysres(device_t child, int type, int *rid, u_long start, u_long end,
1311 u_long count, u_int flags)
1312{
1313 struct rman *rm;
1314 struct resource *res;
1315
1303 switch (type) {
1304 case SYS_RES_IOPORT:
1305 rm = &acpi_rman_io;
1306 break;
1307 case SYS_RES_MEMORY:
1308 rm = &acpi_rman_mem;
1309 break;
1310 default:
1311 return (NULL);
1312 }
1313
1316 switch (type) {
1317 case SYS_RES_IOPORT:
1318 rm = &acpi_rman_io;
1319 break;
1320 case SYS_RES_MEMORY:
1321 rm = &acpi_rman_mem;
1322 break;
1323 default:
1324 return (NULL);
1325 }
1326
1327 KASSERT(start + count - 1 == end, ("wildcard resource range"));
1314 res = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE,
1315 child);
1316 if (res == NULL)
1317 return (NULL);
1318
1319 rman_set_rid(res, *rid);
1320
1321 /* If requested, activate the resource using the parent's method. */

--- 2512 unchanged lines hidden ---
1328 res = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE,
1329 child);
1330 if (res == NULL)
1331 return (NULL);
1332
1333 rman_set_rid(res, *rid);
1334
1335 /* If requested, activate the resource using the parent's method. */

--- 2512 unchanged lines hidden ---