1 #ifndef KERNEL_INTERN_H_
2 #define KERNEL_INTERN_H_
4 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
7 Desc: 64bit x86 kernel_intern.h
13 #include <aros/kernel.h>
14 #include <utility/tagitem.h>
17 typedef struct int_gate_64bit apicidt_t
;
22 #define STACK_SIZE 65536
24 #define DEF_IRQRETFUNC core_DefaultIRETQ
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 */
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) \
59 "mov %[user_ds],%%ds\n\t" \
60 "mov %[user_ds],%%es\n\t" \
61 "mov %%rsp,%%r12\n\t" \
64 "pushq %[iflags]\n\t" \
66 "movabsq $1f,%%r12\n\t" \
69 : : [user_ds] "r" (USER_DS), [ds] "i" (USER_DS), \
70 [cs] "i" (USER_CS), [iflags] "i" (_flags) \
73 #define FLAGS_INTENABLED 0x3002
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
);
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_*/