OBJ := $(addsuffix .$(ARCH), $(OBJ))
MODS += $(addprefix ../Modules/, $(addsuffix .xo.$(ARCH),$(MODULES)))
BIN = ../Acess2.$(ARCH).bin
+GZBIN = ../Acess2.$(ARCH).gz
DEPFILES = $(filter %.o.$(ARCH),$(OBJ))
DEPFILES := $(DEPFILES:%.o.$(ARCH)=%.d.$(ARCH))
all: $(BIN)
clean:
- @$(RM) $(BIN) $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt $(OBJ) $(DEPFILES)
+ @$(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt $(OBJ) $(DEPFILES)
install: $(BIN)
- $(xCP) $(BIN) $(DISTROOT)
+ gzip -c $(BIN) > ../Acess2.$(ARCH).gz
+ $(xCP) ../Acess2.$(ARCH).gz $(DISTROOT)
apidoc:
doxygen Doxyfile.api
-BUILD_NUM = 2183
+BUILD_NUM = 2206
[extern gKernelEnd]\r
[section .multiboot]\r
mboot:\r
- ; Multiboot macros to make a few lines later more readable\r
- MULTIBOOT_PAGE_ALIGN equ 1<<0\r
- MULTIBOOT_MEMORY_INFO equ 1<<1\r
- MULTIBOOT_HEADER_MAGIC equ 0x1BADB002\r
- MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO\r
- MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)\r
+ ; Multiboot macros to make a few lines later more readable\r
+ MULTIBOOT_PAGE_ALIGN equ 1<<0\r
+ MULTIBOOT_MEMORY_INFO equ 1<<1\r
+ MULTIBOOT_HEADER_MAGIC equ 0x1BADB002\r
+ MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO\r
+ MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)\r
\r
- ; This is the GRUB Multiboot header. A boot signature\r
- dd MULTIBOOT_HEADER_MAGIC\r
- dd MULTIBOOT_HEADER_FLAGS\r
- dd MULTIBOOT_CHECKSUM\r
+ ; This is the GRUB Multiboot header. A boot signature\r
+ dd MULTIBOOT_HEADER_MAGIC\r
+ dd MULTIBOOT_HEADER_FLAGS\r
+ dd MULTIBOOT_CHECKSUM\r
dd mboot - KERNEL_BASE ;Location of Multiboot Header\r
\r
; Multiboot 2 Header\r
mboot2:\r
- MULTIBOOT2_HEADER_MAGIC equ 0xE85250D6\r
- MULTIBOOT2_HEADER_ARCH equ 0\r
- MULTIBOOT2_HEADER_LENGTH equ (mboot2_end-mboot2)\r
- MULTIBOOT2_CHECKSUM equ -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_HEADER_ARCH + MULTIBOOT2_HEADER_LENGTH)\r
+ MULTIBOOT2_HEADER_MAGIC equ 0xE85250D6\r
+ MULTIBOOT2_HEADER_ARCH equ 0\r
+ MULTIBOOT2_HEADER_LENGTH equ (mboot2_end-mboot2)\r
+ MULTIBOOT2_CHECKSUM equ -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_HEADER_ARCH + MULTIBOOT2_HEADER_LENGTH)\r
\r
- dd MULTIBOOT2_HEADER_MAGIC\r
- dd MULTIBOOT2_HEADER_ARCH\r
- dd MULTIBOOT2_HEADER_LENGTH\r
- dd MULTIBOOT2_CHECKSUM\r
+ dd MULTIBOOT2_HEADER_MAGIC\r
+ dd MULTIBOOT2_HEADER_ARCH\r
+ dd MULTIBOOT2_HEADER_LENGTH\r
+ dd MULTIBOOT2_CHECKSUM\r
; MBoot2 Address Header\r
dw 2, 0\r
dd 8 + 16\r
CPPFLAGS := -DMAX_CPUS=$(MAX_CPUS)
CFLAGS := $(KERNEL_CFLAGS)
ASFLAGS := -f elf64 -D MAX_CPUS=$(MAX_CPUS)
+LDFLAGS := -nostdlib -nodefaultlibs
ifeq ($(ARCH),amd64)
ASFLAGS += -D AMD64=1
A_OBJ = start32.ao start64.ao desctab.ao
-A_OBJ += main.o lib.o proc.o mm_virt.o mm_phys.o
+A_OBJ += main.o lib.o proc.o mm_virt.o mm_phys.o vm8086.o
+A_OBJ += kernelpanic.o
--- /dev/null
+/*
+ */
+
+// === PROTOTYPES ===
+void KernelPanic_SetMode(void);
+void KernelPanic_PutChar(char ch);
+
+
+void KernelPanic_SetMode(void)
+{
+}
+
+void KernelPanic_PutChar(char ch)
+{
+
+}
return __dest;
}
+void *memsetd(void *__dest, Uint32 __val, size_t __count)
+{
+ __asm__ __volatile__ ("rep stosl" : : "D"(__dest),"a"(__val),"c"(__count));
+ return __dest;
+}
+
_kernel_base = 0xFFFF800000000000;
-//lowStart = start - _kernel_base;
+/*
+lowStart = start - _kernel_base;
ENTRY(start)
OUTPUT_FORMAT(elf64-x86-64)
+*/
+OUTPUT_FORMAT(elf32-i386)
+OUTPUT_ARCH(i386:x86-64)
+ENTRY (start)
SECTIONS {
- . = 0x100000;
+ . = 0x100000 + SIZEOF_HEADERS;
__load_addr = .;
.multiboot : AT(ADDR(.multiboot)) {
*(.multiboot)
gKernelSymbols = .;
*(KEXPORT)
gKernelSymbolsEnd = .;
-
-
}
/*
.debug_abbrev : { *(.debug_abbrev) }
+/*
+ * Acess2 x86_64 Project
+ */
+#include <acess.h>
+
+// === GLOBALS ==
+
+// === CODE ===
+void kmain(Uint MbMagic, void *MbInfoPtr)
+{
+
+}
+
+void Arch_LoadBootModules(void)
+{
+
+}
+
+void StartupPrint(char *String)
+{
+
+}
}
+void MM_FinishVirtualInit(void)
+{
+
+}
+
/**
* \brief Map a physical page to a virtual one
*/
}
}
}
+
+tVAddr MM_NewWorkerStack(void)
+{
+ return 0;
+}
+
+tVAddr MM_NewKStack(void)
+{
+ return 0;
+}
[section .multiboot]
mboot:
- MULTIBOOT_MAGIC equ 0x1BADB002
- dd MULTIBOOT_MAGIC
+ ; Multiboot macros to make a few lines later more readable
+ MULTIBOOT_PAGE_ALIGN equ 1<<0
+ MULTIBOOT_MEMORY_INFO equ 1<<1
+ MULTIBOOT_AOUT_KLUDGE equ 1<<16
+ MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
+ MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO; | MULTIBOOT_AOUT_KLUDGE
+ MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
+
+ ; This is the GRUB Multiboot header. A boot signature
+ dd MULTIBOOT_HEADER_MAGIC
+ dd MULTIBOOT_HEADER_FLAGS
+ dd MULTIBOOT_CHECKSUM
+ [extern __load_addr]
+ [extern __bss_start]
+ [extern gKernelEnd]
+ ; a.out kludge
+ dd mboot ; Location of Multiboot Header
+ dd __load_addr ; Load address
+ dd __bss_start - KERNEL_BASE ; End of .data
+ dd gKernelEnd - KERNEL_BASE ; End of .bss (and kernel)
+ dd start - KERNEL_BASE ; Entrypoint
[extern start64]
[section .text]
[global start]
start:
+ ; Check for Long Mode support
+ mov eax, 0x80000001
+ cpuid
+ test edx, 1<<29
+ jz .not64bitCapable
+
; Enable PAE
mov eax, cr4
or eax, 0x80|0x20
jmp 0x08:start64 - KERNEL_BASE
+.not64bitCapable:
+ mov ah, 0x0F
+ mov edi, 0xB8000
+ mov esi, csNot64BitCapable - KERNEL_BASE
+
+.loop:
+ lodsb
+ test al, al
+ jz .hlt
+ stosw
+ jmp .loop
+
+.hlt:
+ jmp .hlt
+
[section .data]
[global gGDT]
gGDT:
gInitialPDP: ; Covers 512 GiB
dd gInitialPD - KERNEL_BASE + 3, 0
- times 511 dq 0
+ times 511 dq 0
gInitialPD: ; Covers 1 GiB
dd gInitialPT1 - KERNEL_BASE + 3, 0
dd gInitialPT2 - KERNEL_BASE + 3, 0
+ times 510 dq 0
gInitialPT1: ; Covers 2 MiB
- %assign i 1
+ %assign i 0
%rep 512
dq i*4096+3
%assign i i+1
%endrep
+[section .rodata]
+csNot64BitCapable:
+ db "Not 64-bit Capable",0
iret
+; int CallWithArgArray(void *Ptr, int NArgs, Uint *Args)
+; Call a function passing the array as arguments
+[global CallWithArgArray]
+CallWithArgArray:
+ push rbp
+ mov rbp, rsp
+ mov rcx, [rbp+3*8] ; Get NArgs
+ mov rdx, [rbp+4*8]
+
+.top:
+ mov rax, [rdx+rcx*8-8]
+ push rax
+ loop .top
+
+ mov rax, [rbp+2*8]
+ call rax
+ lea rsp, [rbp]
+ pop rbp
+ ret
+
[section .usertext]
User_Syscall_RetAndExit:
mov rdi, rax
void *VM8086_Allocate(tVM8086 *State, int Size, Uint16 *Segment, Uint16 *Offset)
{
-
+ return NULL;
}
void *VM8086_GetPointer(tVM8086 *State, Uint16 Segment, Uint16 Offset)
{
-
+ return NULL;
}
void VM8086_Int(tVM8086 *State, Uint8 Interrupt)
CC = x86_64-linux-gnu-gcc
LD = ld
-KERNEL_CFLAGS = -mcmodel=large
+KERNEL_CFLAGS = -mcmodel=large -nostdlib
ARCHDIR = x86_64
$(RM) $(BIN) $(BIN).dsm $(KOBJ) $(OBJ) $(DEPFILES)
install: $(BIN)
- $(xCP) $(BIN) $(DISTROOT)/Modules/$(NAME).kmd
+ifeq ($(BUILDTYPE),dynamic)
+ $(xCP) $(BIN) $(DISTROOT)/Modules/$(NAME).kmd.$(ARCH)
+else
+endif
ifeq ($(BUILDTYPE),dynamic)
$(BIN): %.kmd.$(ARCH): $(OBJ)