xref: /illumos-gate/usr/src/uts/intel/io/vmm/io/vatpic.h (revision 32640292)
1bf21cd93STycho Nightingale /*-
2bf21cd93STycho Nightingale  * Copyright (c) 2014 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
3bf21cd93STycho Nightingale  * All rights reserved.
4bf21cd93STycho Nightingale  *
5bf21cd93STycho Nightingale  * Redistribution and use in source and binary forms, with or without
6bf21cd93STycho Nightingale  * modification, are permitted provided that the following conditions
7bf21cd93STycho Nightingale  * are met:
8bf21cd93STycho Nightingale  * 1. Redistributions of source code must retain the above copyright
9bf21cd93STycho Nightingale  *    notice, this list of conditions and the following disclaimer.
10bf21cd93STycho Nightingale  * 2. Redistributions in binary form must reproduce the above copyright
11bf21cd93STycho Nightingale  *    notice, this list of conditions and the following disclaimer in the
12bf21cd93STycho Nightingale  *    documentation and/or other materials provided with the distribution.
13bf21cd93STycho Nightingale  *
14bf21cd93STycho Nightingale  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
15bf21cd93STycho Nightingale  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16bf21cd93STycho Nightingale  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17bf21cd93STycho Nightingale  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18bf21cd93STycho Nightingale  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19bf21cd93STycho Nightingale  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20bf21cd93STycho Nightingale  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21bf21cd93STycho Nightingale  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22bf21cd93STycho Nightingale  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23bf21cd93STycho Nightingale  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24bf21cd93STycho Nightingale  * SUCH DAMAGE.
25bf21cd93STycho Nightingale  */
26bf21cd93STycho Nightingale 
27bf21cd93STycho Nightingale #ifndef _VATPIC_H_
28bf21cd93STycho Nightingale #define	_VATPIC_H_
29bf21cd93STycho Nightingale 
30bf21cd93STycho Nightingale #include <isa/isareg.h>
31bf21cd93STycho Nightingale 
32bf21cd93STycho Nightingale #define	ICU_IMR_OFFSET	1
33bf21cd93STycho Nightingale 
34bf21cd93STycho Nightingale #define	IO_ELCR1	0x4d0
35bf21cd93STycho Nightingale #define	IO_ELCR2	0x4d1
36bf21cd93STycho Nightingale 
37bf21cd93STycho Nightingale struct vatpic *vatpic_init(struct vm *vm);
38bf21cd93STycho Nightingale void vatpic_cleanup(struct vatpic *vatpic);
39bf21cd93STycho Nightingale 
400e1453c3SPatrick Mooney int vatpic_master_handler(void *arg, bool in, uint16_t port, uint8_t bytes,
410e1453c3SPatrick Mooney     uint32_t *eax);
420e1453c3SPatrick Mooney int vatpic_slave_handler(void *arg, bool in, uint16_t port, uint8_t bytes,
430e1453c3SPatrick Mooney     uint32_t *eax);
440e1453c3SPatrick Mooney int vatpic_elc_handler(void *arg, bool in, uint16_t port, uint8_t bytes,
450e1453c3SPatrick Mooney     uint32_t *eax);
46bf21cd93STycho Nightingale 
47bf21cd93STycho Nightingale int vatpic_assert_irq(struct vm *vm, int irq);
48bf21cd93STycho Nightingale int vatpic_deassert_irq(struct vm *vm, int irq);
49bf21cd93STycho Nightingale int vatpic_pulse_irq(struct vm *vm, int irq);
502699b94cSPatrick Mooney int vatpic_set_irq_trigger(struct vm *vm, int irq,
512699b94cSPatrick Mooney     enum vm_intr_trigger trigger);
52bf21cd93STycho Nightingale 
53bf21cd93STycho Nightingale void vatpic_pending_intr(struct vm *vm, int *vecptr);
54bf21cd93STycho Nightingale void vatpic_intr_accepted(struct vm *vm, int vector);
55bf21cd93STycho Nightingale 
56bf21cd93STycho Nightingale #endif	/* _VATPIC_H_ */
57