OSDN Git Service

プロジェクト構成、リポジトリ構成変更
[tryos/TryOS.git] / Boot / Source / Main.S
diff --git a/Boot/Source/Main.S b/Boot/Source/Main.S
new file mode 100644 (file)
index 0000000..c31f5a0
--- /dev/null
@@ -0,0 +1,84 @@
+#include "Common.h"
+
+
+
+#define STACK_SEGMENT 0x8000
+#define STACK_POINTER 0
+
+
+.section .text
+.code16
+
+/*
+ * エントリポイント
+ * ここから始まる
+ */
+.section .text.entry
+EntryPoint:
+       ljmp    $BOOT_LOADER_SEGMENT, $BootMain
+
+.section .text
+/*
+ * ブートメイン
+ */
+BootMain:
+       #セグメントレジスタ初期化
+       movw    $BOOT_LOADER_SEGMENT, %ax
+       movw    %ax, %ds
+       movw    %ax, %es
+       movw    %ax, %fs
+       movw    %ax, %gs
+
+       #スタック初期化
+       movw    $BOOT_STACK_OFFSET, %sp
+       movw    $BOOT_STACK_SEGMENT, %ax
+       movw    %ax, %ss
+
+       # CDからデータ読み取り
+       call    readDataFromCD
+       jc              error
+
+       # カーネルに移動
+
+
+
+
+
+       # DEBUG デバッグ用
+       movw    $0xb800, %ax
+       movw    %ax, %ds
+       movb    $'e' , %ds:0x0000
+       movb    $'n' , %ds:0x0002
+       movb    $'d' , %ds:0x0004
+       hlt
+       .byte 0xeb, 0xfd
+
+error:
+       # DEBUG デバッグ用
+       movw    $0xb800, %ax
+       movw    %ax, %ds
+       movb    $'e' , %ds:0x0000
+       movb    $'r' , %ds:0x0002
+       movb    $'r' , %ds:0x0004
+       hlt
+       .byte 0xeb, 0xfd
+
+       # ラベルなしのhaltループ。コピペして使える。
+       hlt
+       .byte 0xeb, 0xfd
+
+.global halt
+halt:
+       pushw   %ax
+       pushw   %ds
+       movw    $0xb800, %ax
+       movw    %ax, %ds
+       movb    $'h' , %ds:0x0000
+       movb    $'l' , %ds:0x0002
+       movb    $'t' , %ds:0x0004
+       popw    %ds
+       popw    %ax
+       hlt
+       jmp             halt
+
+