libbus.h revision 284080
1265056Smarcel/*- 2284080Smarcel * Copyright (c) 2014, 2015 Marcel Moolenaar 3265056Smarcel * All rights reserved. 4265056Smarcel * 5265056Smarcel * Redistribution and use in source and binary forms, with or without 6265056Smarcel * modification, are permitted provided that the following conditions 7265056Smarcel * are met: 8265056Smarcel * 9265056Smarcel * 1. Redistributions of source code must retain the above copyright 10265056Smarcel * notice, this list of conditions and the following disclaimer. 11265056Smarcel * 2. Redistributions in binary form must reproduce the above copyright 12265056Smarcel * notice, this list of conditions and the following disclaimer in the 13265056Smarcel * documentation and/or other materials provided with the distribution. 14265056Smarcel * 15265056Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16265056Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17265056Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18265056Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19265056Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20265056Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21265056Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22265056Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23265056Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24265056Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25265056Smarcel * 26265056Smarcel * $FreeBSD: head/tools/bus_space/C/libbus_space.h 284080 2015-06-06 16:14:03Z marcel $ 27265056Smarcel */ 28265056Smarcel 29265056Smarcel#ifndef _LIBBUS_SPACE_H_ 30265056Smarcel#define _LIBBUS_SPACE_H_ 31265056Smarcel 32284080Smarcelint bus_space_map(const char *dev); 33284080Smarcelint16_t bus_space_read_1(int rid, long ofs); 34284080Smarcelint32_t bus_space_read_2(int rid, long ofs); 35265056Smarcelint64_t bus_space_read_4(int rid, long ofs); 36284080Smarcelint bus_space_subregion(int rid, long ofs, long sz); 37284080Smarcelint bus_space_unmap(int rid); 38284080Smarcelint bus_space_write_1(int rid, long ofs, uint8_t val); 39284080Smarcelint bus_space_write_2(int rid, long ofs, uint16_t val); 40284080Smarcelint bus_space_write_4(int rid, long ofs, uint32_t val); 41265056Smarcel 42284080Smarceltypedef unsigned long bus_addr_t; 43284080Smarceltypedef unsigned long bus_size_t; 44284080Smarceltypedef int busdma_tag_t; 45284080Smarcel 46284080Smarcelint busdma_tag_create(const char *dev, bus_addr_t align, bus_addr_t bndry, 47284080Smarcel bus_addr_t maxaddr, bus_size_t maxsz, u_int nsegs, 48284080Smarcel bus_size_t maxsegsz, u_int datarate, u_int flags, 49284080Smarcel busdma_tag_t *out_p); 50284080Smarcelint busdma_tag_derive(busdma_tag_t tag, bus_addr_t align, bus_addr_t bndry, 51284080Smarcel bus_addr_t maxaddr, bus_size_t maxsz, u_int nsegs, 52284080Smarcel bus_size_t maxsegsz, u_int datarate, u_int flags, 53284080Smarcel busdma_tag_t *out_p); 54284080Smarcelint busdma_tag_destroy(busdma_tag_t tag); 55284080Smarcel 56265056Smarcel#endif /* _LIBBUS_SPACE_H_ */ 57