xref: /freebsd/sys/dev/proto/proto.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
167fb10f3SMarcel Moolenaar /*-
2*9f011bcaSMarcel Moolenaar  * Copyright (c) 2014, 2015, 2019 Marcel Moolenaar
367fb10f3SMarcel Moolenaar  * All rights reserved.
467fb10f3SMarcel Moolenaar  *
567fb10f3SMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
667fb10f3SMarcel Moolenaar  * modification, are permitted provided that the following conditions
767fb10f3SMarcel Moolenaar  * are met:
867fb10f3SMarcel Moolenaar  *
967fb10f3SMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
1067fb10f3SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
1167fb10f3SMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
1267fb10f3SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
1367fb10f3SMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
1467fb10f3SMarcel Moolenaar  *
1567fb10f3SMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1667fb10f3SMarcel Moolenaar  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1767fb10f3SMarcel Moolenaar  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1867fb10f3SMarcel Moolenaar  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1967fb10f3SMarcel Moolenaar  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2067fb10f3SMarcel Moolenaar  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2167fb10f3SMarcel Moolenaar  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2267fb10f3SMarcel Moolenaar  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2367fb10f3SMarcel Moolenaar  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2467fb10f3SMarcel Moolenaar  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2567fb10f3SMarcel Moolenaar  */
2667fb10f3SMarcel Moolenaar 
2767fb10f3SMarcel Moolenaar #ifndef _DEV_PROTO_H_
2867fb10f3SMarcel Moolenaar #define _DEV_PROTO_H_
2967fb10f3SMarcel Moolenaar 
3067fb10f3SMarcel Moolenaar #define	PROTO_RES_MAX	16
3167fb10f3SMarcel Moolenaar 
3267fb10f3SMarcel Moolenaar #define	PROTO_RES_UNUSED	0
3367fb10f3SMarcel Moolenaar #define	PROTO_RES_PCICFG	10
344f027abdSMarcel Moolenaar #define	PROTO_RES_BUSDMA	11
3567fb10f3SMarcel Moolenaar 
3667fb10f3SMarcel Moolenaar struct proto_res {
37*9f011bcaSMarcel Moolenaar 	u_int		r_type:8;
38*9f011bcaSMarcel Moolenaar 	u_int		r_opened:1;
3967fb10f3SMarcel Moolenaar 	int		r_rid;
404f027abdSMarcel Moolenaar 	union {
414f027abdSMarcel Moolenaar 		struct resource *res;
424f027abdSMarcel Moolenaar 		void *busdma;
434f027abdSMarcel Moolenaar 	} r_d;
4467fb10f3SMarcel Moolenaar 	u_long		r_size;
4567fb10f3SMarcel Moolenaar 	union {
4667fb10f3SMarcel Moolenaar 		void		*cookie;
4767fb10f3SMarcel Moolenaar 		struct cdev	*cdev;
4867fb10f3SMarcel Moolenaar 	} r_u;
4967fb10f3SMarcel Moolenaar };
5067fb10f3SMarcel Moolenaar 
5167fb10f3SMarcel Moolenaar struct proto_softc {
5267fb10f3SMarcel Moolenaar 	device_t	sc_dev;
5367fb10f3SMarcel Moolenaar 	struct proto_res sc_res[PROTO_RES_MAX];
5467fb10f3SMarcel Moolenaar 	int		sc_rescnt;
55*9f011bcaSMarcel Moolenaar 	int		sc_opencnt;
56*9f011bcaSMarcel Moolenaar 	struct mtx	sc_mtx;
5767fb10f3SMarcel Moolenaar };
5867fb10f3SMarcel Moolenaar 
5967fb10f3SMarcel Moolenaar extern char proto_driver_name[];
6067fb10f3SMarcel Moolenaar 
6167fb10f3SMarcel Moolenaar int proto_add_resource(struct proto_softc *, int, int, struct resource *);
6267fb10f3SMarcel Moolenaar 
63be00e098SMarcel Moolenaar int proto_probe(device_t dev, const char *prefix, char ***devnamesp);
6467fb10f3SMarcel Moolenaar int proto_attach(device_t dev);
6567fb10f3SMarcel Moolenaar int proto_detach(device_t dev);
6667fb10f3SMarcel Moolenaar 
6767fb10f3SMarcel Moolenaar #endif /* _DEV_PROTO_H_ */
68