1 /* $NetBSD: alloc.c,v 1.2 2007/06/25 21:38:43 joerg Exp $ */
4 * Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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
32 #ifndef _X86EMU_X86EMU_I8254_H
33 #define _X86EMU_X86EMU_I8254_H
40 # include <sys/types.h>
43 struct x86emu_i8254_timer
{
44 /* Tick when the counter was started, 0 if it is inactive */
50 /* The initial value of the counter */
51 uint16_t active_counter
;
53 /* The current mode as bit pattern */
56 /* The current setting of the BCD flag */
60 uint16_t latched_counter
;
61 bool counter_is_latched
;
64 uint8_t latched_status
;
65 bool status_is_latched
;
68 bool read_lsb
, read_msb
;
77 bool write_lsb
, write_msb
;
81 struct x86emu_i8254_timer timer
[3];
82 struct timespec base_time
;
84 void (*gettime
)(struct timespec
*);
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);