|
| 1 | +/* |
| 2 | + * Copyright (C) 2024 Philippe Aubertin. |
| 3 | + * All rights reserved. |
| 4 | +
|
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions |
| 7 | + * are met: |
| 8 | + * |
| 9 | + * 1. Redistributions of source code must retain the above copyright |
| 10 | + * notice, this list of conditions and the following disclaimer. |
| 11 | + * |
| 12 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | + * notice, this list of conditions and the following disclaimer in the |
| 14 | + * documentation and/or other materials provided with the distribution. |
| 15 | + * |
| 16 | + * 3. Neither the name of the author nor the names of other contributors |
| 17 | + * may be used to endorse or promote products derived from this software |
| 18 | + * without specific prior written permission. |
| 19 | + * |
| 20 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND |
| 21 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 22 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 23 | + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY |
| 24 | + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 25 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 26 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 27 | + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 29 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | + */ |
| 31 | + |
| 32 | +#ifndef JINUE_KERNEL_INFRASTRUCTURE_I686_DRIVERS_ASM_PIT8253_H |
| 33 | +#define JINUE_KERNEL_INFRASTRUCTURE_I686_DRIVERS_ASM_PIT8253_H |
| 34 | + |
| 35 | +/* I/O addresses */ |
| 36 | + |
| 37 | +#define PIT8253_IO_BASE 0x40 |
| 38 | + |
| 39 | +#define PIT8253_IO_COUNTER0 (PIT8253_IO_BASE + 0) |
| 40 | + |
| 41 | +#define PIT8253_IO_COUNTER1 (PIT8253_IO_BASE + 1) |
| 42 | + |
| 43 | +#define PIT8253_IO_COUNTER2 (PIT8253_IO_BASE + 2) |
| 44 | + |
| 45 | +#define PIT8253_IO_CW_REG (PIT8253_IO_BASE + 3) |
| 46 | + |
| 47 | +/* Individual flag definitions */ |
| 48 | + |
| 49 | +/** BCD (1) or binary (0) counter selection */ |
| 50 | +#define PIT8253_CW_BCD (1<<0) |
| 51 | + |
| 52 | +#define PIT8253_CW_M0 (1<<1) |
| 53 | + |
| 54 | +#define PIT8253_CW_M1 (1<<2) |
| 55 | + |
| 56 | +#define PIT8253_CW_M2 (1<<3) |
| 57 | + |
| 58 | +#define PIT8253_CW_RL0 (1<<4) |
| 59 | + |
| 60 | +#define PIT8253_CW_RL1 (1<<5) |
| 61 | + |
| 62 | +#define PIT8253_CW_SC0 (1<<6) |
| 63 | + |
| 64 | +#define PIT8253_CW_SC1 (1<<7) |
| 65 | + |
| 66 | +/* Combined flags - select counter */ |
| 67 | + |
| 68 | +#define PIT8253_CW_COUNTER0 0 |
| 69 | + |
| 70 | +#define PIT8253_CW_COUNTER1 PIT8253_CW_SC0 |
| 71 | + |
| 72 | +#define PIT8253_CW_COUNTER2 PIT8253_CW_SC1 |
| 73 | + |
| 74 | +/* Combined flags - read/load */ |
| 75 | + |
| 76 | +#define PIT8253_CW_LOAD_LSB_MSB (PIT8253_CW_RL1 | PIT8253_CW_RL0) |
| 77 | + |
| 78 | +/* Combined flags - mode */ |
| 79 | + |
| 80 | +/** Mode 0: interrupt on terminal count */ |
| 81 | +#define PIT8253_CW_MODE0 0 |
| 82 | + |
| 83 | +/** Mode 1: programmable one-shot */ |
| 84 | +#define PIT8253_CW_MODE1 PIT8253_CW_M0 |
| 85 | + |
| 86 | +/** Mode 2: rate generator */ |
| 87 | +#define PIT8253_CW_MODE2 PIT8253_CW_M1 |
| 88 | + |
| 89 | +/** Mode 3: square wave rate generator */ |
| 90 | +#define PIT8253_CW_MODE3 (PIT8253_CW_M1 | PIT8253_CW_M0) |
| 91 | + |
| 92 | +/** Mode 4: software-triggered strobe */ |
| 93 | +#define PIT8253_CW_MODE4 PIT8253_CW_M2 |
| 94 | + |
| 95 | +/** Mode 5: hardware-triggered strobe */ |
| 96 | +#define PIT8253_CW_MODE5 (PIT8253_CW_M2 | PIT8253_CW_M0) |
| 97 | + |
| 98 | +/* Frequency parameters */ |
| 99 | + |
| 100 | +/** Numerator of input frequency in MHz */ |
| 101 | +#define PIT8253_FREQ_N 105 |
| 102 | + |
| 103 | +/** Denominator of input frequency in MHz */ |
| 104 | +#define PIT8253_FREQ_D 88 |
| 105 | + |
| 106 | +#endif |
0 commit comments