/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2009 Marcel Moolenaar4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR15* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES16* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.17* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,18* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,19* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;20* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED21* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,22* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*/2627#include <sys/param.h>28#include <sys/bus.h>29#include <sys/malloc.h>30#include <machine/bus.h>31#include <sys/rman.h>3233#include <machine/intr_machdep.h>34#include <machine/resource.h>3536#include <isa/isareg.h>37#include <isa/isavar.h>38#include <isa/isa_common.h>3940void41isa_init(device_t dev)42{43}4445struct resource *46isa_alloc_resource(device_t bus, device_t child, int type, int *rid,47u_long start, u_long end, u_long count, u_int flags)48{49struct isa_device* idev = DEVTOISA(child);50struct resource_list *rl = &idev->id_resources;51int isdefault, passthrough, rids;5253isdefault = RMAN_IS_DEFAULT_RANGE(start, end) ? 1 : 0;54passthrough = (device_get_parent(child) != bus) ? 1 : 0;5556if (!passthrough && !isdefault &&57resource_list_find(rl, type, *rid) == NULL) {58switch (type) {59case SYS_RES_IOPORT: rids = ISA_PNP_NPORT; break;60case SYS_RES_IRQ: rids = ISA_PNP_NIRQ; break;61case SYS_RES_MEMORY: rids = ISA_PNP_NMEM; break;62default: rids = 0; break;63}64if (*rid < 0 || *rid >= rids)65return (NULL);6667resource_list_add(rl, type, *rid, start, end, count);68}6970return (resource_list_alloc(rl, bus, child, type, rid, start, end,71count, flags));72}7374int75isa_release_resource(device_t bus, device_t child, struct resource *r)76{77struct isa_device* idev = DEVTOISA(child);78struct resource_list *rl = &idev->id_resources;7980return (resource_list_release(rl, bus, child, r));81}828384