revert between 56095 -> 55830 in arch
[AROS.git] / arch / x86_64-pc / kernel / kernel_intern.h
blob8ed95815c16395200c0bd22d3f31f181467ec982
1 #ifndef KERNEL_INTERN_H_
2 #define KERNEL_INTERN_H_
3 /*
4 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 $Id$
7 Desc: 64bit x86 kernel_intern.h
8 Lang: english
9 */
11 #include <inttypes.h>
13 #include <aros/kernel.h>
14 #include <utility/tagitem.h>
15 #include <asm/cpu.h>
17 typedef struct int_gate_64bit apicidt_t;
19 #include "apic.h"
20 #include "tls.h"
22 #define STACK_SIZE 65536
24 #define DEF_IRQRETFUNC core_DefaultIRETQ
26 struct ACPIData;
27 struct IOAPICData;
30 * Boot-time private data.
31 * This structure is write-protected in user mode and survives warm restarts.
33 struct KernBootPrivate
35 IPTR _APICBase; /* Bootstrap APIC base address */
36 UWORD kbp_APIC_BSPID; /* Bootstrap APIC logical ID */
37 unsigned short debug_y_resolution; /* Parameters of screen's lower half ('vesahack' mode) */
38 void *debug_framebuffer;
39 IPTR SystemStack; /* System stack base address */
40 APTR BOOTTLS,
41 BOOTGDT,
42 BOOTIDT;
43 void *TSS;
44 struct CPUMMUConfig MMU;
47 extern struct KernBootPrivate *__KernBootPrivate;
49 #define IDT_SIZE sizeof(struct int_gate_64bit) * 256
50 #define GDT_SIZE sizeof(struct gdt_64bit) + 128
51 #define TLS_SIZE sizeof(tls_t)
52 #define TLS_ALIGN sizeof(APTR)
54 #define __save_flags(x) __asm__ __volatile__("pushfq ; popq %0":"=g" (x): /* no input */)
55 #define __restore_flags(x) __asm__ __volatile__("pushq %0 ; popfq": /* no output */ :"g" (x):"memory", "cc")
57 #define krnLeaveSupervisorRing(_flags) \
58 asm volatile ( \
59 "mov %[user_ds],%%ds\n\t" \
60 "mov %[user_ds],%%es\n\t" \
61 "mov %%rsp,%%r12\n\t" \
62 "pushq %[ds]\n\t" \
63 "pushq %%r12\n\t" \
64 "pushq %[iflags]\n\t" \
65 "pushq %[cs]\n\t" \
66 "movabsq $1f,%%r12\n\t" \
67 "pushq %%r12\n\t" \
68 "iretq\n1:" \
69 : : [user_ds] "r" (USER_DS), [ds] "i" (USER_DS), \
70 [cs] "i" (USER_CS), [iflags] "i" (_flags) \
71 : "r12")
73 #define FLAGS_INTENABLED 0x3002
75 /* Main boot code */
76 void core_Kick(struct TagItem *msg, void *target);
77 void kernel_cstart(const struct TagItem *msg);
78 void PlatformPostInit(void);
80 /** CPU Related Functions **/
81 void core_SetupGDT(struct KernBootPrivate *, apicid_t, APTR, APTR, APTR);
83 void core_SetupMMU(struct CPUMMUConfig *, IPTR memtop);
84 void core_InitMMU(struct CPUMMUConfig *);
85 void core_LoadMMU(struct CPUMMUConfig *);
87 void core_CPUSetup(apicid_t, APTR, IPTR);
89 /* */
90 void core_ProtKernelArea(intptr_t addr, intptr_t length, char p, char rw, char us);
91 void core_Supervisor(struct ExceptionContext *);
93 /* HW IRQ Related Functions */
94 struct ExceptionContext;
95 extern const void *IntrDefaultGates[256];
97 void ictl_Initialize(struct KernelBase *KernelBase);
99 void core_LeaveInterrupt(struct ExceptionContext *);
101 #endif /*KERNEL_INTERN_H_*/