Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:05

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  This file contains a typical set of register access routines which may be
0005  *  used with the mc68681 chip if accesses to the chip are as follows:
0006  *
0007  *    + registers are accessed as bytes
0008  *    + registers are only byte-aligned (no address gaps)
0009  *
0010  *  COPYRIGHT (c) 1989-1997.
0011  *  On-Line Applications Research Corporation (OAR).
0012  *
0013  * Redistribution and use in source and binary forms, with or without
0014  * modification, are permitted provided that the following conditions
0015  * are met:
0016  * 1. Redistributions of source code must retain the above copyright
0017  *    notice, this list of conditions and the following disclaimer.
0018  * 2. Redistributions in binary form must reproduce the above copyright
0019  *    notice, this list of conditions and the following disclaimer in the
0020  *    documentation and/or other materials provided with the distribution.
0021  *
0022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0023  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0025  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0026  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0027  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0028  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0029  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0030  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0031  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0032  * POSSIBILITY OF SUCH DAMAGE.
0033  */
0034 
0035 #include <rtems.h>
0036 
0037 #include <libchip/serial.h>
0038 #include <libchip/mc68681.h>
0039 
0040 #ifndef _MC68681_MULTIPLIER
0041 #define _MC68681_MULTIPLIER 1
0042 #define _MC68681_NAME(_X) _X
0043 #define _MC68681_TYPE uint8_t
0044 #endif
0045 
0046 #define CALCULATE_REGISTER_ADDRESS( _base, _reg ) \
0047   (_MC68681_TYPE *)((_base) + ((_reg) * _MC68681_MULTIPLIER ))
0048 
0049 /*
0050  *  MC68681 Get Register Routine
0051  */
0052 
0053 uint8_t   _MC68681_NAME(mc68681_get_register)(
0054   uintptr_t   ulCtrlPort,
0055   uint8_t     ucRegNum
0056 )
0057 {
0058   _MC68681_TYPE *port;
0059 
0060   port = CALCULATE_REGISTER_ADDRESS( ulCtrlPort, ucRegNum );
0061 
0062   return *port;
0063 }
0064 
0065 /*
0066  *  MC68681 Set Register Routine
0067  */
0068 
0069 void  _MC68681_NAME(mc68681_set_register)(
0070   uintptr_t   ulCtrlPort,
0071   uint8_t     ucRegNum,
0072   uint8_t     ucData
0073 )
0074 {
0075   _MC68681_TYPE *port;
0076 
0077   port = CALCULATE_REGISTER_ADDRESS( ulCtrlPort, ucRegNum );
0078 
0079   *port = ucData;
0080 }