Home | History | Annotate | Line # | Download | only in footbridge
      1 /*	$NetBSD: footbridge_com_io.c,v 1.10 2021/08/13 11:40:43 skrll Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997 Mark Brinicombe.
      5  * Copyright (c) 1997 Causality Limited.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by Mark Brinicombe
     19  *	for the NetBSD Project.
     20  * 4. The name of the company nor the name of the author may be used to
     21  *    endorse or promote products derived from this software without specific
     22  *    prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     25  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     26  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     27  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     28  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  * SUCH DAMAGE.
     35  */
     36 
     37 /*
     38  * This file provides the bus space tag for the footbridge serial console
     39  */
     40 
     41 /*
     42  * bus_space I/O functions for mainbus
     43  */
     44 
     45 #include <sys/cdefs.h>
     46 __KERNEL_RCSID(0, "$NetBSD: footbridge_com_io.c,v 1.10 2021/08/13 11:40:43 skrll Exp $");
     47 
     48 #include <sys/param.h>
     49 #include <sys/systm.h>
     50 #include <sys/bus.h>
     51 
     52 /* Proto types for all the bus_space structure functions */
     53 
     54 bs_protos(fcomcons);
     55 bs_protos(generic);
     56 bs_protos(bs_notimpl);
     57 
     58 /* Declare the fcomcons bus space tag */
     59 
     60 struct bus_space fcomcons_bs_tag = {
     61 	/* cookie */
     62 	.bs_cookie = NULL,
     63 
     64 	/* mapping/unmapping */
     65 	.bs_map = fcomcons_bs_map,
     66 	.bs_unmap = fcomcons_bs_unmap,
     67 	.bs_subregion = fcomcons_bs_subregion,
     68 
     69 	/* allocation/deallocation */
     70 	.bs_alloc = fcomcons_bs_alloc,
     71 	.bs_free = fcomcons_bs_free,
     72 
     73 	/* get kernel virtual address */
     74 	.bs_vaddr = 0, /* never used */
     75 
     76 	/* Mmap bus space for user */
     77 	.bs_mmap = bs_notimpl_bs_mmap,
     78 
     79 	/* barrier */
     80 	.bs_barrier = fcomcons_bs_barrier,
     81 
     82 	/* read (single) */
     83 	.bs_r_1 = bs_notimpl_bs_r_1,
     84 	.bs_r_2 = bs_notimpl_bs_r_2,
     85 	.bs_r_4 = generic_bs_r_4,
     86 	.bs_r_8 = bs_notimpl_bs_r_8,
     87 
     88 	/* read multiple */
     89 	.bs_rm_1 = bs_notimpl_bs_rm_1,
     90 	.bs_rm_2 = bs_notimpl_bs_rm_2,
     91 	.bs_rm_4 = bs_notimpl_bs_rm_4,
     92 	.bs_rm_8 = bs_notimpl_bs_rm_8,
     93 
     94 	/* read region */
     95 	.bs_rr_1 = bs_notimpl_bs_rr_1,
     96 	.bs_rr_2 = bs_notimpl_bs_rr_2,
     97 	.bs_rr_4 = bs_notimpl_bs_rr_4,
     98 	.bs_rr_8 = bs_notimpl_bs_rr_8,
     99 
    100 	/* write (single) */
    101 	.bs_w_1 = bs_notimpl_bs_w_1,
    102 	.bs_w_2 = bs_notimpl_bs_w_2,
    103 	.bs_w_4 = generic_bs_w_4,
    104 	.bs_w_8 = bs_notimpl_bs_w_8,
    105 
    106 	/* write multiple */
    107 	.bs_wm_1 = bs_notimpl_bs_wm_1,
    108 	.bs_wm_2 = bs_notimpl_bs_wm_2,
    109 	.bs_wm_4 = bs_notimpl_bs_wm_4,
    110 	.bs_wm_8 = bs_notimpl_bs_wm_8,
    111 
    112 	/* write region */
    113 	.bs_wr_1 = bs_notimpl_bs_wr_1,
    114 	.bs_wr_2 = bs_notimpl_bs_wr_2,
    115 	.bs_wr_4 = bs_notimpl_bs_wr_4,
    116 	.bs_wr_8 = bs_notimpl_bs_wr_8,
    117 
    118 	.bs_sm_1 = bs_notimpl_bs_sm_1,
    119 	.bs_sm_2 = bs_notimpl_bs_sm_2,
    120 	.bs_sm_4 = bs_notimpl_bs_sm_4,
    121 	.bs_sm_8 = bs_notimpl_bs_sm_8,
    122 
    123 	/* set region */
    124 	.bs_sr_1 = bs_notimpl_bs_sr_1,
    125 	.bs_sr_2 = bs_notimpl_bs_sr_2,
    126 	.bs_sr_4 = bs_notimpl_bs_sr_4,
    127 	.bs_sr_8 = bs_notimpl_bs_sr_8,
    128 
    129 	/* copy */
    130 	.bs_c_1 = bs_notimpl_bs_c_1,
    131 	.bs_c_2 = bs_notimpl_bs_c_2,
    132 	.bs_c_4 = bs_notimpl_bs_c_4,
    133 	.bs_c_8 = bs_notimpl_bs_c_8,
    134 };
    135 
    136 /* bus space functions */
    137 
    138 int
    139 fcomcons_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int cacheable, bus_space_handle_t *bshp)
    140 {
    141 	/*
    142 	 * Temporary implementation as all I/O is already mapped etc.
    143 	 *
    144 	 * Eventually this function will do the mapping check for multiple maps
    145 	 */
    146 	*bshp = bpa;
    147 	return(0);
    148 	}
    149 
    150 int
    151 fcomcons_bs_alloc(
    152 	void *t,
    153 	bus_addr_t rstart,
    154 	bus_addr_t rend,
    155 	bus_size_t size,
    156 	bus_size_t alignment,
    157 	bus_size_t boundary,
    158 	int cacheable,
    159 	bus_addr_t *bpap,
    160 	bus_space_handle_t *bshp)
    161 {
    162 	panic("fcomcons_alloc(): Help!");
    163 }
    164 
    165 
    166 void
    167 fcomcons_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
    168 {
    169 	/*
    170 	 * Temporary implementation
    171 	 */
    172 }
    173 
    174 void
    175 fcomcons_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
    176 {
    177 
    178 	panic("fcomcons_free(): Help!");
    179 	/* fcomcons_unmap() does all that we need to do. */
    180 /*	fcomcons_unmap(t, bsh, size);*/
    181 }
    182 
    183 int
    184 fcomcons_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp)
    185 {
    186 
    187 	*nbshp = bsh + offset;
    188 	return (0);
    189 }
    190 
    191 void
    192 fcomcons_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset, bus_size_t len, int flags)
    193 {
    194 }
    195 
    196 /* End of footbridge_com_io.c */
    197