The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/chips/mc_clock.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991,1990 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        mc_clock.h,v $
   29  * Revision 2.6  91/06/19  11:53:57  rvb
   30  *      File moved here from mips/PMAX since it tries to be generic.
   31  *      [91/06/04            rvb]
   32  * 
   33  * Revision 2.5  91/05/14  17:24:30  mrt
   34  *      Correcting copyright
   35  * 
   36  * Revision 2.4  91/02/14  14:34:46  mrt
   37  *      New values for delay() function.
   38  *      [91/02/12  13:04:04  af]
   39  * 
   40  * Revision 2.3  91/02/05  17:42:40  mrt
   41  *      Added author notices
   42  *      [91/02/04  11:15:14  mrt]
   43  * 
   44  *      Changed to use new Mach copyright
   45  *      [91/02/02  12:13:53  mrt]
   46  * 
   47  * Revision 2.2  90/08/27  22:06:11  dbg
   48  *      Created, from Motorola MC146818 specs.
   49  *      [90/08/17            af]
   50  */
   51 /*
   52  *      File:   mc_clock.h
   53  *      Author: Alessandro Forin
   54  *      Date:   8/90
   55  *
   56  *      Definitions for the MC146818 Clock Driver
   57  */
   58 
   59 /*
   60  *      Functions this module implements
   61  */
   62 
   63 extern void     resettodr(/* */);       /* reset time-of-day register */
   64 extern void     startrtclock(/* */);    /* start real-time clock */
   65 extern void     stopclocks(/* */);      /* stop  real-time clock */
   66 extern boolean_t ackrtclock(/* */);     /* acknowledge interrupt, if any */
   67 extern boolean_t todr_running;          /* status */
   68 
   69 extern boolean_t mc_new_century;        /* patch this after year 2000 (honest!) */
   70 
   71 extern void     delay(/* int usecs */); /* waste that many microseconds */
   72 extern void     config_delay(/* int speed */);          /* for delay() */
   73 #define         MC_DELAY_PMAX   8
   74 #define         MC_DELAY_3MAX   12
   75 
   76 extern void     set_clock_addr(/* vm_offset_t addr */); /* RAM location */
   77 
   78 /*
   79  *      Real-Time Clock plus RAM device (MC146818)
   80  */
   81 
   82 /*
   83  * RAM Memory Map (as seen by the chip)
   84  */
   85 typedef struct {
   86         volatile unsigned char  mc_second;
   87         volatile unsigned char  mc_alarm_second;
   88         volatile unsigned char  mc_minute;
   89         volatile unsigned char  mc_alarm_minute;
   90         volatile unsigned char  mc_hour;
   91         volatile unsigned char  mc_alarm_hour;
   92         volatile unsigned char  mc_day_of_week;
   93         volatile unsigned char  mc_day_of_month;
   94         volatile unsigned char  mc_month;
   95         volatile unsigned char  mc_year;
   96         volatile unsigned char  mc_register_A;
   97         volatile unsigned char  mc_register_B;
   98         volatile unsigned char  mc_register_C;
   99         volatile unsigned char  mc_register_D;
  100         unsigned char           mc_non_volatile_ram[50];
  101 } mc_clock_t;
  102 
  103 /*
  104  * Register A defines (read/write)
  105  */
  106 
  107 #define MC_REG_A_RS     0x0f            /* Interrupt rate (and SQwave) select */
  108 #define MC_REG_A_DV     0x70            /* Divider select */
  109 #define MC_REG_A_UIP    0x80            /* Update In Progress (read-only bit) */
  110 
  111 /* Time base configuration */
  112 #define MC_BASE_4_MHz   0x00
  113 #define MC_BASE_1_MHz   0x10
  114 #define MC_BASE_32_KHz  0x20
  115 #define MC_BASE_NONE    0x60            /* actually, both of these reset */
  116 #define MC_BASE_RESET   0x70
  117 
  118 /* Interrupt rate table */
  119 #define MC_RATE_NONE    0x0             /* disabled */
  120 #define MC_RATE_1       0x1             /* 256Hz if MC_BASE_32_KHz, else 32768Hz */
  121 #define MC_RATE_2       0x2             /* 128Hz if MC_BASE_32_KHz, else 16384Hz */
  122 #define MC_RATE_8192_Hz 0x3             /* Tpi: 122.070 usecs */
  123 #define MC_RATE_4096_Hz 0x4             /* Tpi: 244.141 usecs */
  124 #define MC_RATE_2048_Hz 0x5             /* Tpi: 488.281 usecs */
  125 #define MC_RATE_1024_Hz 0x6             /* Tpi: 976.562 usecs */
  126 #define MC_RATE_512_Hz  0x7             /* Tpi: 1.953125 ms */
  127 #define MC_RATE_256_Hz  0x8             /* Tpi: 3.90625 ms */
  128 #define MC_RATE_128_Hz  0x9             /* Tpi: 7.8125 ms */
  129 #define MC_RATE_64_Hz   0xa             /* Tpi: 15.625 ms */
  130 #define MC_RATE_32_Hz   0xb             /* Tpi: 31.25 ms */
  131 #define MC_RATE_16_Hz   0xc             /* Tpi: 62.5 ms */
  132 #define MC_RATE_8_Hz    0xd             /* Tpi: 125 ms */
  133 #define MC_RATE_4_Hz    0xe             /* Tpi: 250 ms */
  134 #define MC_RATE_2_Hz    0xf             /* Tpi: 500 ms */
  135 
  136 /* Update cycle time */
  137 #define MC_UPD_4_MHz     248            /* usecs */
  138 #define MC_UPD_1_MHz     248            /* usecs */
  139 #define MC_UPD_32_KHz   1984            /* usecs */
  140 #define MC_UPD_MINIMUM   244            /* usecs, guaranteed if UIP=0 */
  141 
  142 /*
  143  * Register B defines (read/write)
  144  */
  145 
  146 #define MC_REG_B_DSE    0x01            /* Daylight Savings Enable */
  147 #define MC_REG_B_24HM   0x02            /* 24/12 Hour Mode */
  148 #define MC_REG_B_DM     0x04            /* Data Mode, 1=Binary 0=BCD */
  149 #define MC_REG_B_SQWE   0x08            /* Sqare Wave Enable */
  150 #define MC_REG_B_UIE    0x10            /* Update-ended Interrupt Enable */
  151 #define MC_REG_B_AIE    0x20            /* Alarm Interrupt Enable */
  152 #define MC_REG_B_PIE    0x40            /* Periodic Interrupt Enable */
  153 #define MC_REG_B_SET    0x80            /* Set NVram info, e.g. update time or ..*/
  154 #define MC_REG_B_STOP   MC_REG_B_SET    /* Stop updating the timing info */
  155 
  156 /*
  157  * Register C defines (read-only)
  158  */
  159 
  160 #define MC_REG_C_ZEROES 0x0f            /* Reads as zero bits  */
  161 #define MC_REG_C_UF     0x10            /* Update-ended interrupt flag */
  162 #define MC_REG_C_AF     0x20            /* Alarm interrupt flag */
  163 #define MC_REG_C_PF     0x40            /* Periodic interrupt flag */
  164 #define MC_REG_C_IRQF   0x80            /* Interrupt request flag */
  165 
  166 /*
  167  * Register D defines (read-only)
  168  */
  169 
  170 #define MC_REG_D_ZEROES 0x7f            /* Reads as zero bits  */
  171 #define MC_REG_D_VRT    0x80            /* Valid RAM and Time */
  172 

Cache object: 7d83ae5cf1a06e03f8e61475bebfac29


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.