1 /* 2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 3 ** Distributed under the terms of the NewOS License. 4 */ 5 #ifndef _NEWOS_KERNEL_ARCH_I386_SMP_PRIV_H 6 #define _NEWOS_KERNEL_ARCH_I386_SMP_PRIV_H 7 8 int i386_smp_interrupt(int vector); 9 void arch_smp_ack_interrupt(void); 10 int arch_smp_set_apic_timer(bigtime_t relative_timeout); 11 int arch_smp_clear_apic_timer(void); 12 int smp_intercpu_int_handler(void); 13 14 #define MP_FLT_SIGNATURE '_PM_' 15 #define MP_CTH_SIGNATURE 'PCMP' 16 17 #define APIC_DM_INIT (5 << 8) 18 #define APIC_DM_STARTUP (6 << 8) 19 #define APIC_LEVEL_TRIG (1 << 14) 20 #define APIC_ASSERT (1 << 13) 21 22 #define APIC_ENABLE 0x100 23 #define APIC_FOCUS (~(1 << 9)) 24 #define APIC_SIV (0xff) 25 26 #define APIC_ID ((unsigned int *) ((unsigned int) apic + 0x020)) 27 #define APIC_VERSION ((unsigned int *) ((unsigned int) apic + 0x030)) 28 #define APIC_TPRI ((unsigned int *) ((unsigned int) apic + 0x080)) 29 #define APIC_EOI ((unsigned int *) ((unsigned int) apic + 0x0b0)) 30 #define APIC_SIVR ((unsigned int *) ((unsigned int) apic + 0x0f0)) 31 #define APIC_ESR ((unsigned int *) ((unsigned int) apic + 0x280)) 32 #define APIC_ICR1 ((unsigned int *) ((unsigned int) apic + 0x300)) 33 #define APIC_ICR2 ((unsigned int *) ((unsigned int) apic + 0x310)) 34 #define APIC_LVTT ((unsigned int *) ((unsigned int) apic + 0x320)) 35 #define APIC_LINT0 ((unsigned int *) ((unsigned int) apic + 0x350)) 36 #define APIC_LVT3 ((unsigned int *) ((unsigned int) apic + 0x370)) 37 #define APIC_ICRT ((unsigned int *) ((unsigned int) apic + 0x380)) 38 #define APIC_CCRT ((unsigned int *) ((unsigned int) apic + 0x390)) 39 #define APIC_TDCR ((unsigned int *) ((unsigned int) apic + 0x3e0)) 40 41 #define APIC_ICR1_WRITE_MASK 0xfff3f000 42 #define APIC_ICR1_DELMODE_FIXED 0 43 #define APIC_ICR1_DELMODE_LOWESTPRI (1 << 8) 44 #define APIC_ICR1_DESTMODE_LOG (1 << 11) 45 #define APIC_ICR1_DESTMODE_PHYS 0 46 47 #define APIC_ICR1_READ_MASK 0xfff32000 48 #define APIC_ICR1_DELSTATUS (1 << 12) 49 50 #define APIC_ICR1_DEST_FIELD (0) 51 #define APIC_ICR1_DEST_SELF (1 << 18) 52 #define APIC_ICR1_DEST_ALL (2 << 18) 53 #define APIC_ICR1_DEST_ALL_BUT_SELF (3 << 18) 54 55 56 57 #define APIC_ICR2_MASK 0x00ffffff 58 59 #define APIC_TDCR_2 0x00 60 #define APIC_TDCR_4 0x01 61 #define APIC_TDCR_8 0x02 62 #define APIC_TDCR_16 0x03 63 #define APIC_TDCR_32 0x08 64 #define APIC_TDCR_64 0x09 65 #define APIC_TDCR_128 0x0a 66 #define APIC_TDCR_1 0x0b 67 68 #define APIC_LVTT_MASK 0x000310ff 69 #define APIC_LVTT_VECTOR 0x000000ff 70 #define APIC_LVTT_DS 0x00001000 71 #define APIC_LVTT_M 0x00010000 72 #define APIC_LVTT_TM 0x00020000 73 74 #define APIC_LVT_DM 0x00000700 75 #define APIC_LVT_IIPP 0x00002000 76 #define APIC_LVT_TM 0x00008000 77 #define APIC_LVT_M 0x00010000 78 #define APIC_LVT_OS 0x00020000 79 80 #define APIC_TPR_PRIO 0x000000ff 81 #define APIC_TPR_INT 0x000000f0 82 #define APIC_TPR_SUB 0x0000000f 83 84 #define APIC_SVR_SWEN 0x00000100 85 #define APIC_SVR_FOCUS 0x00000200 86 87 #define APIC_DEST_STARTUP 0x00600 88 89 #define LOPRIO_LEVEL 0x00000010 90 91 #define IOAPIC_ID 0x0 92 #define IOAPIC_VERSION 0x1 93 #define IOAPIC_ARB 0x2 94 #define IOAPIC_REDIR_TABLE 0x10 95 96 #define IPI_CACHE_FLUSH 0x40 97 #define IPI_INV_TLB 0x41 98 #define IPI_INV_PTE 0x42 99 #define IPI_INV_RESCHED 0x43 100 #define IPI_STOP 0x44 101 102 #define MP_EXT_PE 0 103 #define MP_EXT_BUS 1 104 #define MP_EXT_IO_APIC 2 105 #define MP_EXT_IO_INT 3 106 #define MP_EXT_LOCAL_INT 4 107 108 #define MP_EXT_PE_LEN 20 109 #define MP_EXT_BUS_LEN 8 110 #define MP_EXT_IO_APIC_LEN 8 111 #define MP_EXT_IO_INT_LEN 8 112 #define MP_EXT_LOCAL_INT_LEN 8 113 114 struct mp_config_table { 115 unsigned int signature; /* "PCMP" */ 116 unsigned short table_len; /* length of this structure */ 117 unsigned char mp_rev; /* spec supported, 1 for 1.1 or 4 for 1.4 */ 118 unsigned char checksum; /* checksum, all bytes add up to zero */ 119 char oem[8]; /* oem identification, not null-terminated */ 120 char product[12]; /* product name, not null-terminated */ 121 void *oem_table_ptr; /* addr of oem-defined table, zero if none */ 122 unsigned short oem_len; /* length of oem table */ 123 unsigned short num_entries; /* number of entries in base table */ 124 unsigned int apic; /* address of apic */ 125 unsigned short ext_len; /* length of extended section */ 126 unsigned char ext_checksum; /* checksum of extended table entries */ 127 }; 128 129 struct mp_flt_struct { 130 unsigned int signature; /* "_MP_" */ 131 struct mp_config_table *mpc; /* address of mp configuration table */ 132 unsigned char mpc_len; /* length of this structure in 16-byte units */ 133 unsigned char mp_rev; /* spec supported, 1 for 1.1 or 4 for 1.4 */ 134 unsigned char checksum; /* checksum, all bytes add up to zero */ 135 unsigned char mp_feature_1; /* mp system configuration type if no mpc */ 136 unsigned char mp_feature_2; /* imcrp */ 137 unsigned char mp_feature_3, mp_feature_4, mp_feature_5; /* reserved */ 138 }; 139 140 struct mp_ext_pe 141 { 142 unsigned char type; 143 unsigned char apic_id; 144 unsigned char apic_version; 145 unsigned char cpu_flags; 146 unsigned int signature; /* stepping, model, family, each four bits */ 147 unsigned int feature_flags; 148 unsigned int res1, res2; 149 }; 150 151 struct mp_ext_ioapic 152 { 153 unsigned char type; 154 unsigned char ioapic_id; 155 unsigned char ioapic_version; 156 unsigned char ioapic_flags; 157 unsigned int *addr; 158 }; 159 160 #endif 161 162