BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / c629653991780509799e2e00d3b074dc0e0ef313 / kernel

// Related

Nucleus

Barry Initial commit c629653 (3 years, 3 months ago)
diff --git a/kernel/000.S b/kernel/000.S
new file mode 100644
index 0000000..1ae6600
--- /dev/null
+++ b/kernel/000.S
@@ -0,0 +1,27 @@
+.section .multiboot, "a"
+.global header
+header:
+	.long 0x1BADB002
+	.long 1 | 2
+	.long -(0x1BADB002 + (1 | 2))
+
+	.long 0, 0, 0, 0, 0
+
+.section .bss
+stack_bottom:
+	.skip 16384
+stack_top:
+
+.section .text
+.extern kmain
+.global _start
+_start:
+	mov stack_top, %ebp
+	mov %ebp, %esp
+	push %ebx
+	push %esp
+	call kmain
+	cli
+_end:
+	hlt
+	jmp _end
diff --git a/kernel/main.c b/kernel/main.c
new file mode 100644
index 0000000..c2eb55d
--- /dev/null
+++ b/kernel/main.c
@@ -0,0 +1,21 @@
+/*
+ * This file contains the entrance point for the Kernel proper.  The code here
+ * is called by the bootloader when it finishes.  The kmain routine is
+ * responsible for setting up memory and starting the processes running.
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "multiboot.h"
+
+extern char _bss[], _end[];
+
+/* Kernel main function */
+_Noreturn void
+kmain(uint32_t esp, struct MultibootInfo *mbinfo)
+{
+	void *ebda = (void *) (*((uint16_t *) 0x040E) << 4);
+	memset(_bss, 0, _end - _bss);
+
+	while (1);
+}
diff --git a/kernel/multiboot.h b/kernel/multiboot.h
new file mode 100644
index 0000000..3fde8d0
--- /dev/null
+++ b/kernel/multiboot.h
@@ -0,0 +1,37 @@
+#ifndef MULTIBOOT_H
+#define MULTIBOOT_H
+
+#include <stdint.h>
+
+struct MultibootInfo {
+	uint32_t flags;
+	uint32_t memLower;
+	uint32_t memHigher;
+	uint32_t bootDev;
+	uint32_t cmdline;
+	uint32_t modsCount;
+	uint32_t modsAddr;
+
+	uint32_t symsNum;
+	uint32_t symsSize;
+	uint32_t symsAddr;
+	uint32_t symsShndx;
+
+	uint32_t mmapLen;
+	uint32_t mmapAddr;
+	uint32_t drivesLen;
+	uint32_t drivesAddr;
+
+	uint32_t configTable;
+	uint32_t bootLoader;
+	uint32_t apmTable;
+
+	uint32_t vbeControlInfo;
+	uint32_t vbeModeInfo;
+	uint16_t vbeMode;
+	uint16_t vbeInterfaceSeg;
+	uint16_t vbeInterfaceOff;
+	uint16_t vbeInterfaceLen;
+};
+
+#endif