revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-pc / kernel / apic.h
blobfcf9d7237f9440b83d097f261677fda663aa27d1
1 #ifndef KERNEL_APIC_H
2 #define KERNEL_APIC_H
3 /*
4 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 $Id$
7 Desc: Generic AROS APIC definitions.
8 Lang: english
9 */
11 #include <asm/cpu.h>
13 #define APIC_MSI_BASE 0x7FFFFFFF
16 * Per-CPU data
17 * Even old IntelMP spec say that we should be prepared to handle different CPUs.
18 * This is why we have timer frequency here, not globally.
21 struct CPUMMUConfig
23 void *mmu_PML4;
24 void *mmu_PTE;
25 void *mmu_PDP;
26 void *mmu_PDE;
27 int mmu_PDEPageCount;
28 int mmu_PDEPageUsed;
31 struct CPUData
33 ULONG cpu_TimerFreq; /* Timer clock frequency */
34 UQUAD cpu_TSCFreq; /* Timestamp counter frequency */
35 apicid_t cpu_LocalID; /* Local APIC ID */
36 apicid_t cpu_PrivateID; /* Sub-system private (ACPI, whatever) ID - can differ */
37 icintrid_t cpu_ICID; /* NB - this is icintrid_t not icid_t */
38 void *cpu_TLS;
39 void *cpu_GDT;
40 void *cpu_IDT;
41 struct CPUMMUConfig *cpu_MMU;
42 UQUAD cpu_LAPICTick;
43 UQUAD cpu_LastCPULoadTime;
44 UQUAD cpu_SleepTime;
45 ULONG cpu_Load;
48 struct APICData
50 IPTR lapicBase; /* Local APIC base address */
51 ULONG apic_count; /* Total number of APICs in the system */
52 UWORD flags; /* See below */
53 struct CPUData cores[0]; /* Per-CPU data */
56 #define APF_8259 (1 << 0) /* Legacy PIC present */
57 #define APF_TIMER (1 << 1) /* APIC uses its own heartbeat timer */
59 #ifdef __x86_64__
60 #define APIC_BASE_MASK 0x000FFFFFFFFFF000
61 #else
62 #define APIC_BASE_MASK 0xFFFFF000
63 #endif
65 struct APICCPUWake_Data
67 APTR cpuw_apicstartrip;
68 IPTR cpuw_apicbase;
69 apicid_t cpuw_apicid;
73 ULONG core_APIC_Wake(APTR start_addr, apicid_t id, IPTR base);
74 UBYTE core_APIC_GetID(IPTR base);
75 void core_APIC_Init(struct APICData *data, apicid_t cpuNum);
76 void core_APIC_AckIntr(void);
78 /* This is callable in supervisor only */
79 static inline IPTR core_APIC_GetBase(void)
81 return rdmsri(0x1B) & APIC_BASE_MASK;
84 struct APICData *core_APIC_Probe(void);
86 apicid_t core_APIC_GetNumberFromLocal(struct APICData *, apicid_t);
87 apicid_t core_APIC_GetNumber(struct APICData *);
88 void core_APIC_GetMask(struct APICData *, apicid_t, cpumask_t *);
89 BOOL core_APIC_CPUInMask(apicid_t, cpumask_t *);
91 void core_SetupIDT(apicid_t, apicidt_t *);
92 BOOL core_SetIDTGate(apicidt_t *, int, uintptr_t, BOOL);
93 BOOL core_SetIRQGate(void *, int, uintptr_t);
94 void core_DefaultIRETQ();
96 ULONG core_APIC_AllocMSI(ULONG);
97 void core_APIC_RegisterMSI(void *);
99 extern struct IntrController APICInt_IntrController;
101 #endif /* !KERNEL_APIC_H */