1/* 2 * Copyright 2007, Hugo Santos. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7/*- 8 * Copyright 1998 Massachusetts Institute of Technology 9 * 10 * Permission to use, copy, modify, and distribute this software and 11 * its documentation for any purpose and without fee is hereby 12 * granted, provided that both the above copyright notice and this 13 * permission notice appear in all copies, that both the above 14 * copyright notice and this permission notice appear in all 15 * supporting documentation, and that the name of M.I.T. not be used 16 * in advertising or publicity pertaining to distribution of the 17 * software without specific, written prior permission. M.I.T. makes 18 * no representations about the suitability of this software for any 19 * purpose. It is provided "as is" without express or implied 20 * warranty. 21 * 22 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS 23 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, 24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 26 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * $FreeBSD$ 36 */ 37#ifndef _FBSD_COMPAT_SYS_RMAN_H_ 38#define _FBSD_COMPAT_SYS_RMAN_H_ 39 40 41#include <machine/_bus.h> 42#include <machine/resource.h> 43 44 45#define RF_ACTIVE 0x0002 46#define RF_SHAREABLE 0x0004 47#define RF_OPTIONAL 0x0080 48 49#define RF_ALIGNMENT_SHIFT 10 /* alignment size bit starts bit 10 */ 50#define RF_ALIGNMENT_LOG2(x) ((x) << RF_ALIGNMENT_SHIFT) 51 52struct resource { 53 int r_type; 54 bus_space_tag_t r_bustag; /* bus_space tag */ 55 bus_space_handle_t r_bushandle; /* bus_space handle */ 56 area_id r_mapped_area; 57}; 58 59 60bus_space_handle_t rman_get_bushandle(struct resource *); 61bus_space_tag_t rman_get_bustag(struct resource *); 62int rman_get_rid(struct resource *); 63 64 65static inline u_long 66rman_get_start(struct resource *resourcePointer) 67{ 68 return resourcePointer->r_bushandle; 69} 70 71 72static inline uint32_t 73rman_make_alignment_flags(uint32_t size) 74{ 75 int i; 76 77 /* 78 * Find the hightest bit set, and add one if more than one bit 79 * set. We're effectively computing the ceil(log2(size)) here. 80 */ 81 for (i = 31; i > 0; i--) 82 if ((1 << i) & size) 83 break; 84 if (~(1 << i) & size) 85 i++; 86 87 return RF_ALIGNMENT_LOG2(i); 88} 89#endif /* _FBSD_COMPAT_SYS_RMAN_H_ */ 90