source: rtems/c/src/libchip/rtc/mc146818a_ioreg.c @ bb15d1d2

4.104.114.84.9
Last change on this file since bb15d1d2 was bb15d1d2, checked in by Jennifer Averett <Jennifer.Averett@…>, on Nov 22, 2004 at 10:27:19 PM

2004-11-22 Joel Sherrill <joel@…>

PR 693/misc

  • libchip/rtc/mc146818a_ioreg.c: Disable unless on a target with in/outport routines.
  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[29322a8d]1/*
2 *  This file contains a typical set of register access routines which may be
3 *  used with the MC146818A chip if accesses to the chip are as follows:
4 *
5 *    + registers are in I/O space
6 *    + registers are accessed as bytes
7 *    + registers are only byte-aligned (no address gaps)
8 *
9 *  COPYRIGHT (c) 1989-1997.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include <rtems.h>
20#include <bsp.h>
21
[bb15d1d2]22/*
23 *  At this point, not all CPUs or BSPs have defined in/out port routines.
24 */
25#if defined(__i386__) || defined(__PPC__)
26#if defined(inport_byte)
[d4d624e2]27uint32_t mc146818a_get_register(
28  uint32_t  ulCtrlPort,
29  uint8_t   ucRegNum
[29322a8d]30)
31{
[d4d624e2]32  uint8_t   val;
33  uint8_t   tmp;
[29322a8d]34
35  outport_byte( ulCtrlPort, ucRegNum );
36  inport_byte( 0x84, tmp );   /* Hack a delay to give chip time to settle */
37  inport_byte( ulCtrlPort+1, val );
38  inport_byte( 0x84, tmp );   /* Hack a delay to give chip time to settle */
39  return val;
40}
41
42void  mc146818a_set_register(
[d4d624e2]43  uint32_t  ulCtrlPort,
44  uint8_t   ucRegNum,
45  uint32_t  ucData
[29322a8d]46)
47{
48  outport_byte( ulCtrlPort, ucRegNum );
[d4d624e2]49  outport_byte( ulCtrlPort+1, (uint8_t)ucData );
[29322a8d]50}
[bb15d1d2]51#endif
52#endif
Note: See TracBrowser for help on using the repository browser.