1 /* $OpenBSD: i8259.h,v 1.6 2024/05/18 06:45:00 jsg Exp $ */ 2 /* 3 * Copyright (c) 2016 Mike Larkin <mlarkin@openbsd.org> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #include <sys/types.h> 19 20 #include <machine/vmmvar.h> 21 22 #define MASTER 0 23 #define SLAVE 1 24 25 #define ELCR0 0x4D0 26 #define ELCR1 0x4D1 27 28 #define ICW1_ICW4 (0x1 << 0) 29 #define ICW1_SNGL (0x1 << 1) 30 #define ICW1_ADI (0x1 << 2) 31 #define ICW1_LTIM (0x1 << 3) 32 #define ICW1_INIT (0x1 << 4) 33 #define ICW1_IVA1 (0x1 << 5) 34 #define ICW1_IVA2 (0x1 << 6) 35 #define ICW1_IVA3 (0x1 << 7) 36 #define ICW4_UP (0x1 << 0) 37 #define ICW4_AEOI (0x1 << 1) 38 #define ICW4_MS (0x1 << 2) 39 #define ICW4_BUF (0x1 << 3) 40 #define ICW4_SNFM (0x1 << 4) 41 42 #define OCW_SELECT (0x1 << 3) 43 44 #define OCW2_ROTATE_AEOI_CLEAR 0x00 45 #define OCW2_EOI 0x20 46 #define OCW2_NOP 0x40 47 #define OCW2_SEOI 0x60 48 #define OCW2_ROTATE_AEOI_SET 0x80 49 #define OCW2_ROTATE_NSEOI 0xA0 50 #define OCW2_SET_LOWPRIO 0xC0 51 #define OCW2_ROTATE_SEOI 0xE0 52 #define OCW3_RIS (0x1 << 0) 53 #define OCW3_RR (0x1 << 1) 54 #define OCW3_POLL (0x1 << 2) 55 #define OCW3_ACTION (0x1 << 3) 56 #define OCW3_SMM (0x1 << 5) 57 #define OCW3_SMACTION (0x1 << 6) 58 59 /* PIC functions called by device emulation code */ 60 void i8259_assert_irq(uint8_t); 61 void i8259_deassert_irq(uint8_t); 62 63 /* PIC functions called by the in/out exit handler */ 64 uint8_t vcpu_exit_i8259(struct vm_run_params *); 65 66 void i8259_init(void); 67 uint16_t i8259_ack(void); 68 uint8_t i8259_is_pending(void); 69 int i8259_restore(int); 70 int i8259_dump(int); 71 72 /* ELCR functions */ 73 void pic_set_elcr(uint8_t, uint8_t); 74 uint8_t vcpu_exit_elcr(struct vm_run_params *); 75