Sync usage with man page.
[netbsd-mini2440.git] / common / include / x86emu / x86emu_i8254.h
blob361eb8c0cc7f8f4b17fe21ed1924af08c7477533
1 /* $NetBSD: alloc.c,v 1.2 2007/06/25 21:38:43 joerg Exp $ */
3 /*-
4 * Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * 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
15 * the documentation and/or other materials provided with the
16 * distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
32 #ifndef _X86EMU_X86EMU_I8254_H
33 #define _X86EMU_X86EMU_I8254_H
35 #include <sys/time.h>
37 #ifndef _KERNEL
38 # include <stdbool.h>
39 #else
40 # include <sys/types.h>
41 #endif
43 struct x86emu_i8254_timer {
44 /* Tick when the counter was started, 0 if it is inactive */
45 uint64_t start_tick;
47 /* GATE is raised */
48 bool gate_high;
50 /* The initial value of the counter */
51 uint16_t active_counter;
53 /* The current mode as bit pattern */
54 uint8_t active_mode;
56 /* The current setting of the BCD flag */
57 bool active_is_bcd;
59 /* Latched counter */
60 uint16_t latched_counter;
61 bool counter_is_latched;
63 /* Latched status */
64 uint8_t latched_status;
65 bool status_is_latched;
67 /* Read counter */
68 bool read_lsb, read_msb;
70 /* Write counter */
71 uint8_t rw_status;
72 uint16_t new_counter;
73 uint8_t new_mode;
74 bool new_is_bcd;
75 bool null_count;
77 bool write_lsb, write_msb;
80 struct x86emu_i8254 {
81 struct x86emu_i8254_timer timer[3];
82 struct timespec base_time;
84 void (*gettime)(struct timespec *);
87 __BEGIN_DECLS
89 void x86emu_i8254_init(struct x86emu_i8254 *, void (*)(struct timespec *));
90 uint8_t x86emu_i8254_inb(struct x86emu_i8254 *, uint16_t);
91 void x86emu_i8254_outb(struct x86emu_i8254 *, uint16_t, uint8_t);
92 bool x86emu_i8254_claim_port(struct x86emu_i8254 *, uint16_t);
94 __END_DECLS
96 #endif