1 /* $OpenBSD: i8259.h,v 1.7 2024/07/09 09:31:37 dv 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 #define MASTER 0 21 #define SLAVE 1 22 23 #define ELCR0 0x4D0 24 #define ELCR1 0x4D1 25 26 #define ICW1_ICW4 (0x1 << 0) 27 #define ICW1_SNGL (0x1 << 1) 28 #define ICW1_ADI (0x1 << 2) 29 #define ICW1_LTIM (0x1 << 3) 30 #define ICW1_INIT (0x1 << 4) 31 #define ICW1_IVA1 (0x1 << 5) 32 #define ICW1_IVA2 (0x1 << 6) 33 #define ICW1_IVA3 (0x1 << 7) 34 #define ICW4_UP (0x1 << 0) 35 #define ICW4_AEOI (0x1 << 1) 36 #define ICW4_MS (0x1 << 2) 37 #define ICW4_BUF (0x1 << 3) 38 #define ICW4_SNFM (0x1 << 4) 39 40 #define OCW_SELECT (0x1 << 3) 41 42 #define OCW2_ROTATE_AEOI_CLEAR 0x00 43 #define OCW2_EOI 0x20 44 #define OCW2_NOP 0x40 45 #define OCW2_SEOI 0x60 46 #define OCW2_ROTATE_AEOI_SET 0x80 47 #define OCW2_ROTATE_NSEOI 0xA0 48 #define OCW2_SET_LOWPRIO 0xC0 49 #define OCW2_ROTATE_SEOI 0xE0 50 #define OCW3_RIS (0x1 << 0) 51 #define OCW3_RR (0x1 << 1) 52 #define OCW3_POLL (0x1 << 2) 53 #define OCW3_ACTION (0x1 << 3) 54 #define OCW3_SMM (0x1 << 5) 55 #define OCW3_SMACTION (0x1 << 6) 56 57 /* PIC functions called by device emulation code */ 58 void i8259_assert_irq(uint8_t); 59 void i8259_deassert_irq(uint8_t); 60 61 /* PIC functions called by the in/out exit handler */ 62 uint8_t vcpu_exit_i8259(struct vm_run_params *); 63 64 void i8259_init(void); 65 uint16_t i8259_ack(void); 66 uint8_t i8259_is_pending(void); 67 int i8259_restore(int); 68 int i8259_dump(int); 69 70 /* ELCR functions */ 71 void pic_set_elcr(uint8_t, uint8_t); 72 uint8_t vcpu_exit_elcr(struct vm_run_params *); 73