OSDN Git Service

FDDブートに変更
authorhideaki sago <hideaki sago@localhost>
Sun, 4 Mar 2012 13:44:52 +0000 (22:44 +0900)
committerhideaki sago <hideaki sago@localhost>
Sun, 4 Mar 2012 13:44:52 +0000 (22:44 +0900)
23 files changed:
API/Include/TryOS/Library/API/TryAPI.h
API/Include/TryOS/Library/Common/Common.h [new file with mode: 0644]
Boot/Boot.ls
Boot/Source/BootUtil.S
Boot/Source/Common.h
Boot/Source/Define.S [new file with mode: 0644]
Boot/Source/DescriptorTable.S
Boot/Source/Elf.h [new file with mode: 0644]
Boot/Source/Main.S
Boot/Source/ReadDisc.S
Boot/Source/SwitchMode.S
Builder/.cproject
Builder/.project
Builder/.settings/org.eclipse.cdt.core.prefs
Builder/Debug/.gitignore
Builder/Debug/Makefile
Kernel/.cproject
Kernel/.settings/org.eclipse.cdt.core.prefs [new file with mode: 0644]
Kernel/.settings/org.eclipse.cdt.ui.prefs [new file with mode: 0644]
Kernel/Kernel.ls
Kernel/Source/EntryPoint.S [new file with mode: 0644]
Kernel/Source/PagingSample.cpp [new file with mode: 0644]
Kernel/Source/TryKernel.cpp

index 592fa6c..0574a8f 100644 (file)
@@ -1,21 +1,10 @@
 /**
- * @file       TryAPI.h
  * @author     hideaki sago
  */
 
 #pragma once
 
-// 型定義
-typedef signed int si;
-typedef signed char s1;
-typedef signed short int s2;
-typedef signed long int s4;
-typedef signed long long int s8;
-typedef unsigned int ui;
-typedef unsigned char u1;
-typedef unsigned short int u2;
-typedef unsigned long int u4;
-typedef unsigned long long int u8;
+#include "Common.h"
 
 namespace TryOS
 {
diff --git a/API/Include/TryOS/Library/Common/Common.h b/API/Include/TryOS/Library/Common/Common.h
new file mode 100644 (file)
index 0000000..9100f98
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * @author     hideaki sago
+ */
+
+// 型定義
+typedef signed int si;
+typedef signed char s1;
+typedef signed short int s2;
+typedef signed long int s4;
+typedef signed long long int s8;
+typedef unsigned int ui;
+typedef unsigned char u1;
+typedef unsigned short int u2;
+typedef unsigned long int u4;
+typedef unsigned long long int u8;
+
+#pragma once
+
+namespace TryOS
+{
+namespace Library
+{
+namespace Common
+{
+
+}
+}
+}
+
index c552214..a87a176 100644 (file)
@@ -11,6 +11,11 @@ SECTIONS
                *(.text.entry);
                *(.text);
        }
+       
+       .rodata :
+       {
+               *(.rodata);
+       }
 
        .data :
        {
@@ -22,10 +27,11 @@ SECTIONS
                *(.bss);
        }
 
-       /* ã\83\96ã\83¼ã\83\88ã\82\92ã\83ªã\82µã\82¤ã\82ºã\81\99ã\82\8bã\80\82 */
-       .resize 2048 * 1 - 1:
+       /* ã\83\96ã\83¼ã\83\88ã\82»ã\82¯ã\82¿ã\82·ã\82°ã\83\8dã\83\81ã\83£ */
+       .resize 512 - 2:
        {
-               BYTE(0x00);
+               BYTE(0x55);
+               BYTE(0xaa);
        }
 
        /DISCARD/ :
index 00b47cf..3bd93e3 100644 (file)
@@ -7,24 +7,40 @@
 
 
 
+
+PORT_A                 = 0x0092
+
+
+
 .section .text
        .code16
 
 
-       /**
       * NMI割り込み有効化
       */
-       .global enableNMI
+/**
+ * NMI割り込み有効化
+ */
+.global enableNMI
 enableNMI:
-
+       // TODO nmiの割り込み有効化処理を記述
        ret
 
 
-       /**
       * NMI割り込み無効化
       */
-       .global disableNMI
+/**
+ * NMI割り込み無効化
+ */
+.global disableNMI
 disableNMI:
+       // TODO nmiの割り込み無効化処理を記述
+       ret
 
+
+/**
+ * A20ゲート開放
+ */
+.global unlockA20
+unlockA20:
+       inb             $PORT_A, %al
+       orb             $0b00000010, %al
+       outb    %al, $PORT_A // システムコントロールポート。
        ret
 
index 513d662..3afc403 100644 (file)
@@ -1,7 +1,3 @@
-/** @file Common.h
- *
- */
-
 #pragma once
 
 
@@ -36,8 +32,8 @@
 #define BOOT_LOADER_SEGMENT (ADDR_TO_SEGMENT(BOOT_LOADER_BASE, 0xff000))
 
 // ブートローダ用スタック領域
-#define BOOT_STACK_SEGMENT 0x70000 >> 4
-#define BOOT_STACK_OFFSET 0
+#define BOOT_STACK_SEGMENT (0x8000 >> 4)
+#define BOOT_STACK_OFFSET 0x8000
 
 // ISOファイルシステムワークセグメント・オフセット
 #define ISO_FS_WORK_SEGMENT (ADDR_TO_SEGMENT(ISO_FS_WORK_BASE, 0xf0000))
@@ -50,5 +46,6 @@
 #define KERNEL_IMAGE "TryKernel.img"
 #define KERNEL_IMAGE_PATH "/TryOS/Kernel/TryKernel.img"
 
-
-
+// スタック
+#define STACK_SEGMENT 0x8000
+#define STACK_POINTER 0
diff --git a/Boot/Source/Define.S b/Boot/Source/Define.S
new file mode 100644 (file)
index 0000000..2b93e21
--- /dev/null
@@ -0,0 +1,16 @@
+/**
+ * 各種データの定義
+ */
+
+#include "Common.h"
+
+
+
+.code16
+.section .rodata
+
+
+
+
+
+
index 0412ba8..09d3ad5 100644 (file)
@@ -27,8 +27,8 @@ IDT_LIMIT             = 0x07ff
        GDTR_TEMP
 ------------------------------------------------------------------------------*/
        .align          16
-       .global _GDTR_TEMP
-_GDTR_TEMP:
+.global tempGDTR
+tempGDTR:
 _GDTR_TEMP_Limit:
        .word           _GDT_END - gdt - 1
 _GDTR_TEMP_Base:
@@ -37,7 +37,7 @@ _GDTR_TEMP_Base:
 
 /*------------------------------------------------------------------------------
        GDTR
-------------------------------------------------------------------------------*/
+------------------------------------------------------------------------------*
        .align          16
 
 _GDTR:
@@ -45,7 +45,7 @@ _GDTR_Limit:
        .word           GDT_LIMIT
 _GDTR_Base:
        .long           GDT_BASE
-
+*/
 
 /*------------------------------------------------------------------------------
        GDT
@@ -53,38 +53,54 @@ _GDTR_Base:
        .align          16
 
 gdt:
-gdtNull:                       #0x0000
-       .word           0x0000
-       .word           0x0000
-       .byte           0x00
-       .byte           0x00
-       .byte           0x00
-       .byte           0x00
-
-gdtKernelCS:           #0x0008 Base:0x00000000, Limit:0xfffff(単位:Page), SegmentType:Code(Exe/Read)
-       .word           0xffff
-       .word           0x0000
-       .byte           0x00
-       .byte           0x9a
-       .byte           0xcf
-       .byte           0x00
-
-gdtKernelDS:           #0x0010 Base:0x00000000, Limit:0xfffff(単位:Page), SegmentType:Data(Read/Write)
-       .word           0xffff
-       .word           0x0000
-       .byte           0x00
-       .byte           0x92
-       .byte           0xcf
-       .byte           0x00
-
-gdtBootLoaderCS:       #0x0018 Base:0x00060000, Limit:0xfffff(単位:Page), SegmentType:Code(Exe/Read)
-       .word           0xffff
-       .word           0x0000
-       .byte           0x06
-       .byte           0x9a
-       .byte           0xcf
-       .byte           0x00
-
+gdtNull:       #0x0000
+       .word   0x0000
+       .word   0x0000
+       .byte   0x00
+       .byte   0x00
+       .byte   0x00
+       .byte   0x00
+
+// ブート用
+gdt08: # Base:0x0000 1000, Limit:0xfffff(単位:Page), SegmentType:Code(Exe/Read)
+       .word   0xffff  // Llimit[0-15]
+       .word   0x1000  // Base[0-15]
+       .byte   0x00    // Base[16-24]
+       .byte   0x9a    // P, DPL, S, Type, A
+       .byte   0xcf    // G, D/B, 予約, AVL, Limit[16-19]
+       .byte   0x00    // Base[25-32]
+
+gdt10: # Base:0x0000 1000, Limit:0xfffff(単位:Page), SegmentType:Data(Read/Write)
+       .word   0xffff
+       .word   0x1000
+       .byte   0x00
+       .byte   0x92
+       .byte   0xcf
+       .byte   0x00
+
+gdt18: # Base:0x0001 0000, Limit:0xfffff(単位:Page), SegmentType:Data(Read only)
+       .word   0xffff
+       .word   0x0000
+       .byte   0x01
+       .byte   0x90
+       .byte   0xcf
+       .byte   0x00
+
+gdt20: # Base:0x0010 0000, Limit:0xfffff(単位:Page), SegmentType:Code(Exe/Read)
+       .word   0xffff
+       .word   0x0000
+       .byte   0x10
+       .byte   0x9a
+       .byte   0xcf
+       .byte   0x00
+
+gdt28: # Base:0x0010 0000, Limit:0xfffff(単位:Page), SegmentType:Data(Read/Write)
+       .word   0xffff
+       .word   0x0000
+       .byte   0x10
+       .byte   0x92
+       .byte   0xcf
+       .byte   0x00
 
 _GDT_END:
 
diff --git a/Boot/Source/Elf.h b/Boot/Source/Elf.h
new file mode 100644 (file)
index 0000000..4d5e203
--- /dev/null
@@ -0,0 +1,482 @@
+#ifndef _LINUX_ELF_H
+#define _LINUX_ELF_H
+
+//#include <asm/elf.h>
+
+//typedef unsigned long        Elf32_Addr;
+//typedef unsigned short       Elf32_Half;
+//typedef unsigned long        Elf32_Off;
+//typedef long         Elf32_Sword;
+//typedef unsigned long        Elf32_Word;
+
+/* These constants are for the segment types stored in the image headers */
+#define PT_NULL    0
+#define PT_LOAD    1
+#define PT_DYNAMIC 2
+#define PT_INTERP  3
+#define PT_NOTE    4
+#define PT_SHLIB   5
+#define PT_PHDR    6
+#define PT_LOPROC  0x70000000
+#define PT_HIPROC  0x7fffffff
+
+/* These constants define the different elf file types */
+#define ET_NONE   0
+#define ET_REL    1
+#define ET_EXEC   2
+#define ET_DYN    3
+#define ET_CORE   4
+#define ET_LOPROC 5
+#define ET_HIPROC 6
+
+/* These constants define the various ELF target machines */
+#define EM_NONE  0
+#define EM_M32   1
+#define EM_SPARC 2
+#define EM_386   3
+#define EM_68K   4
+#define EM_88K   5
+#define EM_486   6   /* Perhaps disused */
+#define EM_860   7
+
+#define EM_MIPS                8       /* MIPS R3000 (officially, big-endian only) */
+
+#define EM_MIPS_RS4_BE 10      /* MIPS R4000 big-endian */
+
+#define EM_SPARC64     11      /* SPARC v9 (not official) 64-bit */
+
+#define EM_PARISC      15      /* HPPA */
+
+#define EM_SPARC32PLUS 18      /* Sun's "v8plus" */
+
+#define EM_PPC        20       /* PowerPC */
+
+/*
+ * This is an interim value that we will use until the committee comes
+ * up with a final number.
+ */
+#define EM_ALPHA       0x9026
+
+
+/* This is the info that is needed to parse the dynamic section of the file */
+#define DT_NULL                0
+#define DT_NEEDED      1
+#define DT_PLTRELSZ    2
+#define DT_PLTGOT      3
+#define DT_HASH                4
+#define DT_STRTAB      5
+#define DT_SYMTAB      6
+#define DT_RELA                7
+#define DT_RELASZ      8
+#define DT_RELAENT     9
+#define DT_STRSZ       10
+#define DT_SYMENT      11
+#define DT_INIT                12
+#define DT_FINI                13
+#define DT_SONAME      14
+#define DT_RPATH       15
+#define DT_SYMBOLIC    16
+#define DT_REL         17
+#define DT_RELSZ       18
+#define DT_RELENT      19
+#define DT_PLTREL      20
+#define DT_DEBUG       21
+#define DT_TEXTREL     22
+#define DT_JMPREL      23
+#define DT_LOPROC      0x70000000
+#define DT_HIPROC      0x7fffffff
+
+/* This info is needed when parsing the symbol table */
+#define STB_LOCAL  0
+#define STB_GLOBAL 1
+#define STB_WEAK   2
+
+#define STT_NOTYPE  0
+#define STT_OBJECT  1
+#define STT_FUNC    2
+#define STT_SECTION 3
+#define STT_FILE    4
+
+#define ELF32_ST_BIND(x) ((x) >> 4)
+#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
+
+/* Symbolic values for the entries in the auxiliary table
+   put on the initial stack */
+#define AT_NULL   0    /* end of vector */
+#define AT_IGNORE 1    /* entry should be ignored */
+#define AT_EXECFD 2    /* file descriptor of program */
+#define AT_PHDR   3    /* program headers for program */
+#define AT_PHENT  4    /* size of program header entry */
+#define AT_PHNUM  5    /* number of program headers */
+#define AT_PAGESZ 6    /* system page size */
+#define AT_BASE   7    /* base address of interpreter */
+#define AT_FLAGS  8    /* flags */
+#define AT_ENTRY  9    /* entry point of program */
+#define AT_NOTELF 10   /* program is not ELF */
+#define AT_UID    11   /* real uid */
+#define AT_EUID   12   /* effective uid */
+#define AT_GID    13   /* real gid */
+#define AT_EGID   14   /* effective gid */
+
+
+//typedef struct dynamic{
+//  Elf32_Sword d_tag;
+//  union{
+//    Elf32_Sword      d_val;
+//    Elf32_Addr       d_ptr;
+//  } d_un;
+//} Elf32_Dyn;
+
+//typedef struct {
+//  unsigned long long d_tag;          /* entry tag value */
+//  union {
+//    unsigned long long d_val;
+//    unsigned long long d_ptr;
+//  } d_un;
+//} Elf64_Dyn;
+
+/* The following are used with relocations */
+#define ELF32_R_SYM(x) ((x) >> 8)
+#define ELF32_R_TYPE(x) ((x) & 0xff)
+
+#define R_386_NONE     0
+#define R_386_32       1
+#define R_386_PC32     2
+#define R_386_GOT32    3
+#define R_386_PLT32    4
+#define R_386_COPY     5
+#define R_386_GLOB_DAT 6
+#define R_386_JMP_SLOT 7
+#define R_386_RELATIVE 8
+#define R_386_GOTOFF   9
+#define R_386_GOTPC    10
+#define R_386_NUM      11
+
+//typedef struct elf32_rel {
+//  Elf32_Addr r_offset;
+//  Elf32_Word r_info;
+//} Elf32_Rel;
+
+//typedef struct elf64_rel {
+//  unsigned long long r_offset;       /* Location at which to apply the action */
+//  unsigned long long r_info; /* index and type of relocation */
+//} Elf64_Rel;
+
+//typedef struct elf32_rela{
+//  Elf32_Addr r_offset;
+//  Elf32_Word r_info;
+//  Elf32_Sword        r_addend;
+//} Elf32_Rela;
+
+//typedef struct elf64_rela {
+//  unsigned long long r_offset;       /* Location at which to apply the action */
+//  unsigned long long r_info; /* index and type of relocation */
+//  unsigned long long r_addend;       /* Constant addend used to compute value */
+//} Elf64_Rela;
+
+//typedef struct elf32_sym{
+//  Elf32_Word st_name;
+//  Elf32_Addr st_value;
+//  Elf32_Word st_size;
+//  unsigned char      st_info;
+//  unsigned char      st_other;
+//  Elf32_Half st_shndx;
+//} Elf32_Sym;
+
+//typedef struct elf64_sym {
+//  unsigned int       st_name;                /* Symbol name, index in string tbl */
+//  unsigned char      st_info;                /* Type and binding attributes */
+//  unsigned char      st_other;               /* No defined meaning, 0 */
+//  unsigned short st_shndx;           /* Associated section index */
+//  unsigned long long st_value;               /* Value of the symbol */
+//  unsigned long long st_size;                /* Associated symbol size */
+//} Elf64_Sym;
+
+
+#define EI_NIDENT      16
+
+// ELFヘッダ
+//typedef struct elf32_hdr{
+//  unsigned char      e_ident[EI_NIDENT];
+//  Elf32_Half e_type;
+//  Elf32_Half e_machine;
+//  Elf32_Word e_version;
+//  Elf32_Addr e_entry;  /* Entry point */
+//  Elf32_Off  e_phoff;
+//  Elf32_Off  e_shoff;
+//  Elf32_Word e_flags;
+//  Elf32_Half e_ehsize;
+//  Elf32_Half e_phentsize;
+//  Elf32_Half e_phnum;
+//  Elf32_Half e_shentsize;
+//  Elf32_Half e_shnum;
+//  Elf32_Half e_shstrndx;
+//} Elf32_Ehdr;
+// シグネチャ 0x7f, 'E', 'L', 'F'
+#define EH_ID_SIGNATURE (0)
+#define EH_ID_SIGNATURE_SIZE (4)
+// 32, 64区分
+#define EH_ID_CLASS (EH_ID_SIGNATURE + EH_ID_SIGNATURE_SIZE)
+#define EH_ID_CLASS_SIZE (1)
+// エンディアン
+#define EH_ID_ENDIAN (EH_ID_CLASS + EH_ID_CLASS_SIZE)
+#define EH_ID_ENDIAN_SIZE (1)
+// バージョン
+#define EH_ID_VERSION (EH_ID_ENDIAN + EH_ID_ENDIAN_SIZE)
+#define EH_ID_VERSION_SIZE (1)
+// ABIタイプ
+#define EH_ID_ABI (EH_ID_VERSION + EH_ID_VERSION_SIZE)
+#define EH_ID_ABI_SIZE (1)
+// ABIバージョン
+#define EH_ID_ABI_VERSION (EH_ID_ABI + EH_ID_ABI_SIZE)
+#define EH_ID_ABI_VERSION_SIZE (1)
+// 予約
+#define EH_ID_RESERVED (EH_ID_ABI_VERSION + EH_ID_ABI_VERSION_SIZE)
+#define EH_ID_RESERVED_SIZE (7)
+// ファイルタイプ
+#define EH_FILE_TYPE (EH_ID_RESERVED + EH_ID_RESERVED_SIZE)
+#define EH_FILE_TYPE_SIZE (2)
+// アーキテクチャ
+#define EH_ARCHITECTURE (EH_FILE_TYPE + EH_FILE_TYPE_SIZE)
+#define EH_ARCHITECTURE_SIZE (2)
+// バージョン
+#define EH_VERSION (EH_ARCHITECTURE + EH_ARCHITECTURE_SIZE)
+#define EH_VERSION_SIZE (4)
+// エントリポイント
+#define EH_ENTRYPOINT (EH_VERSION + EH_VERSION_SIZE)
+#define EH_ENTRYPOINT_SIZE (4)
+// プログラム・ヘッダ・オフセット
+#define EH_PROGRAM_HEADER_OFFSET (EH_ENTRYPOINT + EH_ENTRYPOINT_SIZE)
+#define EH_PROGRAM_HEADER_OFFSET_SIZE (4)
+// セクション・ヘッダ・オフセット
+#define EH_SECTION_HEADER_OFFSET (EH_PROGRAM_HEADER_OFFSET + EH_PROGRAM_HEADER_OFFSET_SIZE)
+#define EH_SECTION_HEADER_OFFSET_SIZE (4)
+// フラグ(未使用らしい。)
+#define EH_FLAGS (EH_SECTION_HEADER_OFFSET + EH_SECTION_HEADER_OFFSET_SIZE)
+#define EH_FLAGS_SIZE (4)
+// ELFヘッダサイズ
+#define EH_EH_SIZE (EH_FLAGS + EH_FLAGS_SIZE)
+#define EH_EH_SIZE_SIZE (2)
+// プログラム・ヘッダ・サイズ
+#define EH_PROGRAM_HEADER_SIZE (EH_EH_SIZE + EH_EH_SIZE_SIZE)
+#define EH_PROGRAM_HEADER_SIZE_SIZE (2)
+// プログラム・ヘッダ数
+#define EH_NUM_PROGRAM_HEADER (EH_PROGRAM_HEADER_SIZE + EH_PROGRAM_HEADER_SIZE_SIZE)
+#define EH_NUM_PH_SIZE (2)
+// セクション・ヘッダ・サイズ
+#define EH_SECTION_HEADER_SIZE (EH_NUM_PROGRAM_HEADER + EH_NUM_PH_SIZE)
+#define EH_SECTION_HEADER_SIZE_SIZE (2)
+// セクション・ヘッダ数
+#define EH_NUM_SECTION_HEADER (EH_SECTION_HEADER_SIZE + EH_SECTION_HEADER_SIZE_SIZE)
+#define EH_NUM_SECTION_HEADER_SIZE (2)
+// セクション名番号
+#define EH_SECTION_STRING_INDEX (EH_NUM_SECTION_HEADER + EH_NUM_SECTION_HEADER_SIZE)
+#define EH_SECTION_STRING_INDEX_SIZE (2)
+
+
+
+
+//typedef struct elf64_hdr {
+//  unsigned char      e_ident[16];            /* ELF "magic number" */
+//  short int e_type;
+//  short unsigned int e_machine;
+//  int   e_version;
+//  unsigned long long e_entry;                /* Entry point virtual address */
+//  unsigned long long e_phoff;                /* Program header table file offset */
+//  unsigned long long e_shoff;                /* Section header table file offset */
+//  int   e_flags;
+//  short int e_ehsize;
+//  short int e_phentsize;
+//  short int e_phnum;
+//  short int e_shentsize;
+//  short int e_shnum;
+//  short int e_shstrndx;
+//} Elf64_Ehdr;
+
+/* These constants define the permissions on sections in the program
+   header, p_flags. */
+#define PF_R           0x4
+#define PF_W           0x2
+#define PF_X           0x1
+
+//typedef struct elf32_phdr{
+//  Elf32_Word p_type;
+//  Elf32_Off  p_offset;
+//  Elf32_Addr p_vaddr;
+//  Elf32_Addr p_paddr;
+//  Elf32_Word p_filesz;
+//  Elf32_Word p_memsz;
+//  Elf32_Word p_flags;
+//  Elf32_Word p_align;
+//} Elf32_Phdr;
+
+// セグメント・タイプ
+#define PH_TYPE (0)
+#define PH_TYPE_SIZE (4)
+// セグメント位置
+#define PH_OFFSET (PH_TYPE + PH_TYPE_SIZE)
+#define PH_OFFSET_SIZE (4)
+// 仮想アドレス
+#define PH_VIRTUAL_ADDRESS (PH_OFFSET + PH_OFFSET_SIZE)
+#define PH_VIRTUAL_ADDRESS_SIZE (4)
+// 物理アドレス
+#define PH_PHYSICAL_ADDRESS (PH_VIRTUAL_ADDRESS + PH_VIRTUAL_ADDRESS_SIZE)
+#define PH_PHYSICAL_ADDRESS_SIZE (4)
+// セグメント・サイズ
+#define PH_SEGMENT_SIZE (PH_PHYSICAL_ADDRESS + PH_PHYSICAL_ADDRESS_SIZE)
+#define PH_SEGMENT_SIZE_SIZE (4)
+// メモリ・サイズ
+#define PH_MEMORY_SIZE (PH_SEGMENT_SIZE + PH_SEGMENT_SIZE_SIZE)
+#define PH_MEMORY_SIZE_SIZE (4)
+// フラグ
+#define PH_FLAGS (PH_MEMORY_SIZE + PH_MEMORY_SIZE_SIZE)
+#define PH_FLAGS_SIZE (4)
+// アライメント
+#define PH_ALIGN (PH_FLAGS + PH_FLAGS_SIZE)
+#define PH_ALIGN_SIZE (4)
+
+//typedef struct elf64_phdr {
+//  int p_type;
+//  int p_flags;
+//  unsigned long long p_offset;               /* Segment file offset */
+//  unsigned long long p_vaddr;                /* Segment virtual address */
+//  unsigned long long p_paddr;                /* Segment physical address */
+//  unsigned long long p_filesz;               /* Segment size in file */
+//  unsigned long long p_memsz;                /* Segment size in memory */
+//  unsigned long long p_align;                /* Segment alignment, file & memory */
+//} Elf64_Phdr;
+
+/* sh_type */
+#define SHT_NULL       0
+#define SHT_PROGBITS   1
+#define SHT_SYMTAB     2
+#define SHT_STRTAB     3
+#define SHT_RELA       4
+#define SHT_HASH       5
+#define SHT_DYNAMIC    6
+#define SHT_NOTE       7
+#define SHT_NOBITS     8
+#define SHT_REL                9
+#define SHT_SHLIB      10
+#define SHT_DYNSYM     11
+#define SHT_NUM                12
+#define SHT_LOPROC     0x70000000
+#define SHT_HIPROC     0x7fffffff
+#define SHT_LOUSER     0x80000000
+#define SHT_HIUSER     0xffffffff
+
+/* sh_flags */
+#define SHF_WRITE      0x1
+#define SHF_ALLOC      0x2
+#define SHF_EXECINSTR  0x4
+#define SHF_MASKPROC   0xf0000000
+
+/* special section indexes */
+#define SHN_UNDEF      0
+#define SHN_LORESERVE  0xff00
+#define SHN_LOPROC     0xff00
+#define SHN_HIPROC     0xff1f
+#define SHN_ABS                0xfff1
+#define SHN_COMMON     0xfff2
+#define SHN_HIRESERVE  0xffff
+
+//typedef struct {
+//  Elf32_Word sh_name;
+//  Elf32_Word sh_type;
+//  Elf32_Word sh_flags;
+//  Elf32_Addr sh_addr;
+//  Elf32_Off  sh_offset;
+//  Elf32_Word sh_size;
+//  Elf32_Word sh_link;
+//  Elf32_Word sh_info;
+//  Elf32_Word sh_addralign;
+//  Elf32_Word sh_entsize;
+//} Elf32_Shdr;
+
+//typedef struct elf64_shdr {
+//  unsigned int       sh_name;                /* Section name, index in string tbl */
+//  unsigned int       sh_type;                /* Type of section */
+//  unsigned long long sh_flags;               /* Miscellaneous section attributes */
+//  unsigned long long sh_addr;                /* Section virtual addr at execution */
+//  unsigned long long sh_offset;              /* Section file offset */
+//  unsigned long long sh_size;                /* Size of section in bytes */
+//  unsigned int       sh_link;                /* Index of another section */
+//  unsigned int       sh_info;                /* Additional section information */
+//  unsigned long long sh_addralign;   /* Section alignment */
+//  unsigned long long sh_entsize;     /* Entry size if section holds table */
+//} Elf64_Shdr;
+
+#define        EI_MAG0         0               /* e_ident[] indexes */
+#define        EI_MAG1         1
+#define        EI_MAG2         2
+#define        EI_MAG3         3
+#define        EI_CLASS        4
+#define        EI_DATA         5
+#define        EI_VERSION      6
+#define        EI_PAD          7
+
+#define        ELFMAG0         0x7f            /* EI_MAG */
+#define        ELFMAG1         'E'
+#define        ELFMAG2         'L'
+#define        ELFMAG3         'F'
+#define        ELFMAG          "\177ELF"
+#define        SELFMAG         4
+
+#define        ELFCLASSNONE    0               /* EI_CLASS */
+#define        ELFCLASS32      1
+#define        ELFCLASS64      2
+#define        ELFCLASSNUM     3
+
+#define ELFDATANONE    0               /* e_ident[EI_DATA] */
+#define ELFDATA2LSB    1
+#define ELFDATA2MSB    2
+
+#define EV_NONE                0               /* e_version, EI_VERSION */
+#define EV_CURRENT     1
+#define EV_NUM         2
+
+/* Notes used in ET_CORE */
+#define NT_PRSTATUS    1
+#define NT_PRFPREG     2
+#define NT_PRPSINFO    3
+#define NT_TASKSTRUCT  4
+
+/* Note header in a PT_NOTE section */
+//typedef struct elf32_note {
+//  Elf32_Word n_namesz;       /* Name size */
+//  Elf32_Word n_descsz;       /* Content size */
+//  Elf32_Word n_type;         /* Content type */
+//} Elf32_Nhdr;
+
+/* Note header in a PT_NOTE section */
+/*
+ * For now we use the 32 bit version of the structure until we figure
+ * out whether we need anything better.  Note - on the Alpha, "unsigned int"
+ * is only 32 bits.
+ */
+//typedef struct elf64_note {
+//  unsigned int       n_namesz;       /* Name size */
+//  unsigned int       n_descsz;       /* Content size */
+//  unsigned int       n_type;         /* Content type */
+//} Elf64_Nhdr;
+
+#define ELF_START_MMAP 0x80000000
+
+#if ELF_CLASS == ELFCLASS32
+
+extern Elf32_Dyn _DYNAMIC [];
+#define elfhdr         elf32_hdr
+#define elf_phdr       elf32_phdr
+#define elf_note       elf32_note
+
+#else
+
+//extern Elf64_Dyn _DYNAMIC [];
+#define elfhdr         elf64_hdr
+#define elf_phdr       elf64_phdr
+#define elf_note       elf64_note
+
+#endif
+
+
+#endif /* _LINUX_ELF_H */
index c31f5a0..e789a32 100644 (file)
 #include "Common.h"
+#include "Elf.h"
 
+BOOT_INITIAL_SEGMENT = 0x7c00 >> 4
+BOOT_MAIN_SEGMENT = 0x1000 >> 4
 
+KERNEL_BUFFER = 0x10000
+KERNEL_DESTINATION = 0x100000
 
-#define STACK_SEGMENT 0x8000
-#define STACK_POINTER 0
 
+BOOT_CS = 0x0008
 
 .section .text
 .code16
 
-/*
+/**
  * エントリポイント
  * ここから始まる
  */
 .section .text.entry
-EntryPoint:
-       ljmp    $BOOT_LOADER_SEGMENT, $BootMain
+entryPoint:
+       ljmp    $BOOT_INITIAL_SEGMENT, $bootInit
 
 .section .text
-/*
- * ブートメイン
+
+/**
+ * ブートプログラム初期化
+ * 自身を0x7c00から0x1000に移動します。
  */
-BootMain:
-       #セグメントレジスタ初期化
-       movw    $BOOT_LOADER_SEGMENT, %ax
+bootInit:
+
+       // 実は、レジスタの初期値には、意味があるらしい。。
+       // 確か、インテルマニュアルに載ってた気がする。
+       // 取得するなら、ここしかない。
+
+       // 自身を0x7c00 から 0x1000 に移動
+       movw    $BOOT_INITIAL_SEGMENT, %ax
+       movw    %ax, %ds
+       movw    $BOOT_MAIN_SEGMENT, %ax
+       movw    %ax, %es
+       xorw    %si, %si
+       xorw    %di, %di
+       movw    $(512 / 4), %cx
+       rep movsl
+
+       // セグメントレジスタ初期化
        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からデータ読み取り
+       // 0x1000 のブートメインへ。
+       ljmp    $BOOT_LOADER_SEGMENT, $bootMain
+
+
+/**
+ * ブートメイン
+ */
+bootMain:
+
+       // 割り込み禁止
+       cli
+
+       // A20ゲート開放
+       call    unlockA20
+
+       // メモリマップ取得する?
+
+
+       // CDからデータ読み取り(FDエミュレート)
        call    readDataFromCD
        jc              error
 
-       # カーネルに移動
+
+       // プロテクトモード移行
+       call    switchProtectMode
+.code32
+
+       // スタック初期化
+       movl    $0xf000, %esp
+
+       // カーネル展開
+       call    loadKernel
 
 
+       call    startKernel
 
+/*
+       jmp             halt32
+
+
+       hlt
+
+       // 割り込み許可
+       sti
+*/
+
+
+
+.code16
 
 
        # DEBUG デバッグ用
@@ -82,3 +143,54 @@ halt:
        jmp             halt
 
 
+
+.code32
+
+
+/**
+ * カーネルの展開
+ */
+loadKernel:
+       // elf を展開する。
+       // 0x10000 -> 0x100000
+       movw    $0x18, %ax
+       movw    %ax, %ds
+
+       movl    EH_PROGRAM_HEADER_OFFSET, %ebx
+       movl    PH_OFFSET(%ebx), %esi
+       movl    PH_SEGMENT_SIZE(%ebx), %ecx
+
+       movw    $0x28, %ax
+       movw    %ax, %es
+       xorl    %edi, %edi
+
+       rep movsb
+
+       ret
+
+/**
+ * カーネルの実行開始
+ */
+startKernel:
+       ljmp    $0x20, $0
+
+
+
+/*
+
+.global halt32
+halt32:
+       pushw   %ax
+       pushw   %ds
+       movw    $0x10, %ax
+       movw    %ax, %ds
+       movb    $'h' , %ds:0xb7100
+       movb    $'l' , %ds:0xb7102
+       movb    $'t' , %ds:0xb7104
+       popw    %ds
+       popw    %ax
+       hlt
+       jmp             halt32
+
+*/
+
index 9cd55dc..4c587bb 100644 (file)
@@ -38,13 +38,13 @@ CD_BLOCK_SIZE = 0x800
 
 
 // OS名長さ
-OS_NAME_LENGTH = osNameTail - osName - 1
+// OS_NAME_LENGTH = osNameTail - osName - 1
 
 // ファイル名長さ
 #OS_DIR_NAME_LENGTH = osDirNameTail - osDirName - 1
 #KERNEL_DIR_NAME_LENGTH = kernelDirNameTail - kernelDirName - 1
 #KERNEL_IMAGE_NAME_LENGTH = kernelImageNameTail - kernelImageName - 1
-KERNEL_IMAGE_PATH_LENGTH = kernelImagePathTail - kernelImagePath
+// KERNEL_IMAGE_PATH_LENGTH = kernelImagePathTail - kernelImagePath
 
 
 .code16
@@ -59,7 +59,7 @@ KERNEL_IMAGE_PATH_LENGTH = kernelImagePathTail - kernelImagePath
  *             2               バッファのオフセット
  *             2               バッファのセグメントセレクタ
  *             8               LBA
- */
+ *
 exDiscReadData:
 structSize:            .word   0
 readSectors:   .word   0
@@ -69,8 +69,8 @@ lba:
 lbaLow:                        .long   0
 lbaHigh:               .long   0
 exDiscReadDataTail:
-
-/* ■ data セクション ■ */
+*/
+/* ■ data セクション ■ *
 .section .data
 // OS名
 osName: .string OS_NAME
@@ -95,386 +95,102 @@ osNameSegOfs:
 volumeIdSegOfs:
        .word PVD_VOLUME_IDENTIFIER
        .word ISO_FS_WORK_SEGMENT
+*/
+
 
 /* ■ text セクション ■ */
 .section .text
 
 /**
- * ディスク読み取り
- * @return FLAGS.CF 0: 1:
+ * CDからデータ取得
+ * @return FLAGS.CF 0:成功 1:失敗
  */
 .global readDataFromCD
 readDataFromCD:
-       // 初期化
-       call    init
-       // ディスク検索
-       call    searchDisc
-       jc              readDataFromCD_error
-
-       // パステーブル読み込み
-       call    readPathTable
-       jc              readDataFromCD_error
-
-       // カーネルファイルを読み込む。
-       call    readKernelImage
-       jc              readDataFromCD_error
-
-
-       // TODO ファイルシステムを読み込む。
-
-
-       // TODO デバイスマネージャを読み込む。
-
-
-       // TODO CDドライバを読み込む。
-
-
-readDataFromCD_return:
-       ret
-readDataFromCD_error:
-       stc // キャリーフラグをセットして、異常終了を通知
-       jmp             readDataFromCD_return
-
-
-/**
- * 拡張INT13H初期化
- * @global 拡張ディスクリード用データ
- */
-init:
-       // 拡張ディスクリード用データ初期化
-       movw    $(exDiscReadDataTail - exDiscReadData), structSize
-       ret
-
-
-/**
- * ディスク検索
- * このOSのディスクを探します。
- * 検索のために、PVDを読み取ります。
- *
- * @global memory0x00060000 PVDデータ
- * @return EFLAGS.CF 0:エラーなし 1:エラーあり
- * @return dl ディスク番号
- */
-searchDisc:
        pushw   %ax
-       pushw   %cx
-       pushw   %dx
+       pushw   %bx
        pushw   %si
        pushw   %di
-       pushw   %ds
-       pushw   %es
-
-       // ディスク番号0x80 〜 0xffからPVDを読み取り、
-       // このOSのディスクかどうかを調べる
-       movb    $0x7f, %dl
-searchDisc_checkLoop:
-       incb    %dl
-       // 全てのディスクを読み取っても見つからない場合はエラー。
-       jz              searchDisc_error
-       call    exDiscCheck
-       jc              searchDisc_checkLoop // 拡張int13に対応していなければ次へ。
-
-       // PVD 読み取り
-       call    readPVD
-       jc              searchDisc_checkLoop // エラーが発生していたら、次へ。
-
-       // ボリューム識別子を比較してこのOSのディスクか確認する
-       // ds:si と es:di を比較
-       movw    $OS_NAME_LENGTH, %cx // 比較する長さを指定
-       ldsw    osNameSegOfs, %si
-       lesw    volumeIdSegOfs, %di
-       repe cmpsb // ボリューム識別子を比較
-       // ZFがfalse == 一致していない 場合は、次のディスクからPVDを読み取る
-       jnz             searchDisc_checkLoop
-       // 文字列を全て比較していなければ、次のディスクからPVDを読み取る
-       cmpw    $0, %cx
-       jne             searchDisc_checkLoop
-       clc // キャリーフラグをクリアして、正常終了を通知
-searchDisc_return:
-       popw    %es
-       popw    %ds
-       popw    %di
-       popw    %si
-       popw    %dx
-       popw    %cx
-       popw    %ax
-       ret
-searchDisc_error:
-       stc // キャリーフラグをセットして、異常終了を通知
-       jmp             searchDisc_return
-
-
-/**
- * 拡張INT13Hの存在確認
- *
- * @param dl ドライブ番号
- * @return FLAGS.CF 0:対応 1:非対応
- */
-exDiscCheck:
-       pushw   %ax
-       pushw   %bx
-       pushw   %cx
-       movb    $0x41, %ah
-       movw    $0x55aa, %bx
-       int             $0x13
-       jc              exDiscCheck_error
-       cmpw    $0xaa55, %bx
-       jne             exDiscCheck_error
-       andb    $0x01, %cl
-       jz              exDiscCheck_error
-       clc // キャリーフラグをクリアして、正常終了を通知
-exDiscCheck_return:
-       popw    %cx
-       popw    %bx
-       popw    %ax
-       ret
-exDiscCheck_error:
-       stc // キャリーフラグをセットして、異常終了を通知
-       jmp             exDiscCheck_return
 
+       // カーネル、FS、DM、etc..読み込み
+       movw    $0x1000, %ax
+       movw    %ax, %es
+       movw    $0, %bx
+       movw    $1, %ax
+       movw    $10, %si
+       movw    $0, %di
+       call    readData
 
-/**
- * 拡張ディスクリード
- *
- * @param dl ドライブ番号
- * @global 拡張ディスクリード用データ
- * @return FLAGS.CF 0:エラーなし 1:エラーあり
- */
-exDiscRead:
-       pushw   %ax
-       pushw   %si
-       movw    $exDiscReadData, %si
-       movw    $0x4200, %ax
-       int             $0x13
+readDataFromCD_return:
+       popw    %di
        popw    %si
+       popw    %bx
        popw    %ax
        ret
 
 
-/**
- * PVD読み取り
- * PVDをディスクから読み取り、メモリに展開します。
- *
- * @param dl ドライブ番号
- * @return FLAGS.CF 0:エラーなし 1:エラーあり
- */
-readPVD:
-       movw    $ISO_FS_WORK_SEGMENT, bufSegment
-       movw    $PVD_BUF_OFFSET, bufOffset
-       movw    $1, readSectors
-       movl    $LBA_PVD, lbaLow
-       call    exDiscRead
-       ret
 
 
 /**
- * ã\83\91ã\82¹ã\83\86ã\83¼ã\83\96ã\83«読み取り
- * パステーブルをディスクから読み取り、メモリに展開します。
- *
- * @param dl ドライブ番号
- * @global PVD(パステーブル情報)
- * @return FLAGS.CF 0:エラーなし 1:エラーあり
+ * ã\83\87ã\83¼ã\82¿読み取り
+ * @param ax LBA(512Byte単位)0ベース
+ * @param si 読み取りセクタ数(512Byte単位)
+ * @param di ドライブ番号
+ * @param es:bx 読み取りデータ格納バッファ
+ * @return FLAGS.CF 0:成功 1:失敗
  */
-readPathTable:
-       pushl   %eax
-       pushl   %ebx
-       pushw   %ds
-       // パステーブルサイズ読み取り
-       movw    $ISO_FS_WORK_SEGMENT, %ax
-       movw    %ax, %ds
-       movl    PVD_PATH_TABLE_SIZE, %eax
-       // バイトサイズをブロックサイズに変換
-       byteToBlock %eax
-
-       // パステーブル読み取り
-       movl    PVD_PATH_TABLE_BASE, %ebx
-
-       // 拡張リード用データ構築
-       movw    $ISO_FS_WORK_SEGMENT, bufSegment
-       movw    $PT_BUF_OFFSET, bufOffset
-       movw    %ax, readSectors
-       movl    %ebx, lbaLow
-       call    exDiscRead
-
-       popw    %ds
-       popl    %ebx
-       popl    %eax
-       ret
-
-
-/**
- * パステーブルレコード取得
- *
- * @param es:di ファイルパスの先頭アドレス (例:"/TryOS/Kernel/TryKernel.img")
- * @param cx ファイルパスの文字列長
- * @return FLAGS.CF 0:エラーなし 1:エラーあり
- * @return (成功時)es:bx 該当パステーブルレコードの先頭アドレス
- */
-getPathRecord:
-       pushw   %ax
+readData:
        pushw   %cx
        pushw   %dx
-       pushw   %si
-       pushw   %ds
 
-       // セグメントセレクタをセット
-       movw    $ISO_FS_WORK_SEGMENT, %ax
-       movw    %ax, %ds
+       #論理セクタをCHSに変換
+       xorw    %dx, %dx
+       movw    $18, %cx
+       divw    %cx // 論理セクタ(ax) / 18 = シリンダ * 2 (ax) 余りセクタ(dx)
+       movb    %dl, %cl        // セクタ
+       movw    %di, %dx        // ドライブ(下位8ビットのみ)
+       movb    %al, %ch        // シリンダ
+       shrb    %ch                     // シリンダ
+       movb    %al, %dh        // ヘッド
+       andb    $1, %dh         // ヘッド
 
-       // cx初期化
-       //(cxはファイルパス全体の長さと
-       // それぞれのディレクトリ名の長さとして使っているため、
-       // 少し複雑になっています。)
-       pushw   %cx
-       xorw    %cx, %cx
-
-       movw    $PT_BUF_OFFSET, %bx // 読み取り位置
-       xorb    %dl, %dl
-
-
-// 次のエントリへ
-getPathRecord_nextDown:
-       incb    %dl // 親ディレクトリ番号
+readData_readLoop:
 
-       // ▼ファイルパスの操作
-       movw    %cx, %ax // 前のディレクトリ名の長さ
-       incw    %ax // '/'分増やす
-       // 前のディレクトリ名の長さ分diを進め、cxを減らす。
-       popw    %cx // 前のディレクトリ名の先頭からパスの終わりまでのサイズ
-       addw    %ax, %di // 現在のディレクトリ名の先頭アドレス
-       subw    %ax, %cx // 現在のディレクトリ名の先頭からパスの終わりまでのサイズ
+       incb    %cl // セクタをインクリメント(1ベースのため、これで良い。)
+       movw    $0x0201, %ax // ah:読み取りモード, al:セクタ数
 
-       // 現在のディレクトリ名の長さを取得する。
-       pushw   %di
-       pushw   %cx
-       movb    $'/', %al
-       repne scasb
-       movw    %cx, %ax
-       popw    %cx
-       popw    %di
-       // 終端までいったら終わり
-       jnz             getPathRecord_success // ZF = scasbの結果
-       pushw   %ax // ディレクトリの先頭からパスの終わりまでのサイズ
-       // ディレクトリ名のサイズをcxへ。
-       subw    %ax, %cx
-       decw    %cx // '/'分引く
-       // ▲ファイルパスの操作
-
-// ディレクトリ検索
-getPathRecord_findDirectory:
-       // ▼パステーブルの操作
-       // 次のエントリへ。
-       addw    (%bx), %bx // ディレクトリ名分足す。
-       addw    $9, %bx // パステーブルの固定長分足す。(1+1+4+2+1=9)
-       andw    $0xfffe, %bx // 偶数にする
-       // ディレクトリ名の長さが0なら終了と判断。
-       movw    (%bx), %ax
-       orw             %ax, %ax
-       jz              getPathRecord_error
-       // ディレクトリ名の長さが一致しなければ次へ
-       cmpw    %ax, %cx
-       jne             getPathRecord_findDirectory
-       // エントリ情報の取得
-       cmpb    6(%bx), %dl
-       jb              getPathRecord_findDirectory //  6(%bx) > %dl 自番号が親より小さければ次へ
-       ja              getPathRecord_error // 6(%bx) < %dl 自番号より親番号が大きい場合は異常
-       movw    %bx, %si
-       addw    $8, %si // ディレクトリ名の先頭位置
-       // ▲パステーブルの操作
-
-       // 親番号一致
-       // ディレクトリ名がstrと一致したら次の階層へ
-       pushw   %di
-       pushw   %cx
-       repe cmpsb
-       popw    %cx
-       popw    %di
-       // 一致したら次の階層へ
-       jz              getPathRecord_nextDown // ZF = cmpsbの結果
-       // 一致しなければ次のエントリへ
-       jmp             getPathRecord_findDirectory
+       // 読み取り
+       int             $0x13
+       jc              readData_return // 異常終了
 
+       // 指定のセクタ数読み取ったら終了
+       decw    %si
+       jz              readData_success
 
-getPathRecord_success:
-       movw    %ds, %ax
+       // バッファアドレスを進める
+       movw    %es, %ax
+       addw    $0x20, %ax
        movw    %ax, %es
-       clc // キャリーフラグをクリアして、正常終了を通知
-getPathRecord_return:
-       popw    %ds
-       popw    %si
-       popw    %dx
-       popw    %cx
-       popw    %ax
-       ret
-getPathRecord_error:
-       stc // キャリーフラグをセットして、異常終了を通知
-       jmp             getPathRecord_return
-
-
-/*
- * ファイル読み取り
- *
- * @param dl ドライブ番号
- * @param ディレクトリレコードのLBA
- * @param ファイル名の先頭アドレス
- */
-readFile:
-
-TODO ここから。
-       call    exDiscRead
-
-readFile_success:
-       clc // キャリーフラグをクリアして、正常終了を通知
-readFile_return:
-       ret
-readFile_error:
-       stc // キャリーフラグをセットして、異常終了を通知
-       jmp             readFile_return
-
-
-/**
- * カーネルイメージ読み取り
- *
- * @param dl ドライブ番号
- */
-readKernelImage:
-       pushw   %cx
-       pushw   %di
 
-       movw    $kernelImagePath, %di
-       movw    $KERNEL_IMAGE_PATH_LENGTH, %cx
-       call    getPathRecord
-       jc              readKernelImage_error
+       // 18セクタ(1シリンダ)読んでいなければもう一度
+       cmpb    $18, %cl
+       jb              readData_readLoop
 
-       readFile
+       // セクタ番号とシリンダ番号とヘッド番号の設定
+       xorb    %cl, %cl // セクタ番号リセット
+       addb    %dh, %ch // シリンダ番号を加算(表なら+0, 裏なら+1)
+       xorb    $1, %dh // ヘッド番号を反転
+       // もう一回。
+       jmp             readData_readLoop
 
-       jmp halt
+readData_success:
+       clc // 正常終了
 
-readKernelImage_success:
-       clc // キャリーフラグをクリアして、正常終了を通知
-readKernelImage_return:
-       popw    %di
+readData_return:
+       popw    %dx
        popw    %cx
        ret
-readKernelImage_error:
-       stc // キャリーフラグをセットして、異常終了を通知
-       jmp             readKernelImage_return
 
-/*
-
-       // Eint13でデータ読み込み(ISO 9660を読む)
-       // TODO
-
-       // プロテクトモードに移行
-       call    SwitchProtectMode
-
-       // 1MiBラインにデータを移動
-       // TODO
-
-       // リアルモードに移行
-       call    SwitchRealMode
-
-*/
 
 
 
index d0a77e8..442ec0b 100644 (file)
@@ -5,48 +5,59 @@
 
 #include "Common.h"
 
-#セグメント
-#SEG_REG                       = 0x6000
-KERNEL_CS                      = 0x0008                        #カーネル用コード・セグメント
-KERNEL_DS                      = 0x0010                        #カーネル用データ・セグメント
-BOOT_CS                                = 0x0018                        #ブートローダ用コード・セグメント(カーネル実行時には、このディスクリプタは削除する。)
+//セグメント
+//SEG_REG                      = 0x6000
+KERNEL_CS                      = 0x0008                        //カーネル用コード・セグメント
+KERNEL_DS                      = 0x0010                        //カーネル用データ・セグメント
+BOOT_CS                                = 0x0008                        //ブートローダ用コード・セグメント(カーネル実行時には、このディスクリプタは削除する。)
 
 
-CR0_PE                 = 0x00000001            #プロテクト・イネーブル・フラグ
-#CR0_PG                        = 0x80000000            #ページング・フラグ
+CR0_PE                 = 0x00000001            //プロテクト・イネーブル・フラグ
+//CR0_PG                       = 0x80000000            //ページング・フラグ
 
-       .section .text
-       .code16
+.section .text
+.code16
 
-
-       .global switchProtectMode
+/**
+ * プロテクトモード切り替え
+ *
+ * 汎用レジスタは破壊されます。
+ * スタックは初期化されます。
+ * CS は0x08がセットされます。
+ * DS, ES, SS には0x10がセットされます。
+ * FS, GS には、0x00がセットされます。
+ */
+.global switchProtectMode
 switchProtectMode:
 
+       xorl    %ebx, %ebx
+       popw    %bx // 戻りアドレス
+
+
 /*
        1. 割り込みをディスエーブルにする。CLI 命令によってマスク可能ハードウェア割り込み
           がディスエーブルになる。NMI 割り込みは、外部回路によってディスエーブルにでき
           る。 (ソフトウェアは、モード切り替えの動作中に例外または割り込みが発生しないよ
           うに保証する必要がある。     )
 */
-
-       # 割り込み禁止
-       cli
-       # NMI割り込み禁止
+       // NMI割り込み禁止
        call    disableNMI
 
 
+
 /*
        2. LGDT 命令を実行して、GDTR レジスタに GDT のベースアドレスをロードする。
 */
-       # GDT読み込み
-       lgdt _GDTR_TEMP
+       // GDT読み込み
+       lgdt    tempGDTR
 
 
 /*
        3. 制御レジスタ CR0 の PE フラグ(またオプションで PG フラグ)を設定する MOV CR0
           命令を実行する。
 */
-       # プロテクトモード移行
+
+       // プロテクトモード移行
        movl    %cr0, %eax
        orl             $CR0_PE, %eax
        movl    %eax, %cr0
@@ -56,7 +67,7 @@ switchProtectMode:
        4. MOV CR0 命令のすぐ後で、far JMP 命令または far CALL 命令を実行する。    (この操作
           は通常、命令ストリーム内の次の命令への far ジャンプまたは far コールになる。          )
 */
-       # パイプラインフラッシュ
+       // パイプラインフラッシュ
        jmp             pipelineFlush
 pipelineFlush:
 
@@ -64,12 +75,13 @@ pipelineFlush:
        5. MOV CR0 命令の直後に JMP 命令または CALL 命令を実行すると、実行の流れが変化
           し、プロセッサが順次処理される。
 */
-       # 32bit移行
-       .code32
+       // 32bit移行
+.code32
        .byte   0x66
-       ljmp    $BOOT_CS, $setCodeSegment
+       ljmp    $0x08, $setCodeSegment
 setCodeSegment:
 
+
 /*
        6. ページングがイネーブルな場合、      MOV CR0 命令のコードと、    JMP 命令または CALL 命
           令のコードは、アイデンティティ・マッピングされたページから得たものでなければ
@@ -106,6 +118,16 @@ setCodeSegment:
                  メント・レジスタの値がリセットされ、新しいコード・セグメントに分岐する。
 */
 
+       // データ・セグメント初期化
+       movw    $0x10, %ax
+       movw    %ax, %ds
+       movw    %ax, %es
+       movw    %ax, %ss
+       // FS, GS は使わない。
+       xorl    %eax, %eax
+       movw    %ax, %fs
+       movw    %ax, %gs
+
 
 /*
           10. LIDT 命令を実行して、IDTR レジスタに保護モード IDT のアドレスとリミットをロー
@@ -120,228 +142,12 @@ setCodeSegment:
           ある。システム管理モードで、メモリを参照する命令が手順 3 と手順 4 の間に挿入さ
           れたときのような状況では、障害は直ちに認識される。
 */
-
-
-
-       # 割り込み許可
-       sti
-       # NMI割り込み許可
+       // NMI割り込み許可
        call    enableNMI
 
-       ret
-
-
-
-
-       .global switchRealMode
-switchRealMode:
-
-/*
-          1. 割り込みをディスエーブルにする。CLI 命令によってマスク可能ハードウェア割り込み
-              がディスエーブルになる。NMI 割り込みは、外部回路によってディスエーブルにでき
-              る。
-*/
-       # 割り込み禁止
-       cli
-       # NMI割り込み禁止
-       call    disableNMI
-
-
-
-/*
-          2. ページングがイネーブルである場合は、以下の各操作を行う。
-              - プログラム制御を、物理アドレスにアイデンティティ・マッピングされている(つ
-                 まり物理アドレスと同一の)リニアアドレスに転送する。
-              - GDT と IDT がアイデンティティ・マッピングされたページにあるようにする。
-              - CR0 レジスタ内の PG ビットをクリアする。
-              - 0H を CR3 レジスタに移動して TLB をフラッシュする。
-*/
-
-
-/*
-          3. プログラム制御を、64K バイト(FFFH)のリミットを持つ読み取り可能セグメントに
-              転送する。この動作によって、実アドレスモードで必要になるセグメント・リミット
-              が CS レジスタにロードされる。
-*/
-
-
-/*
-          4. SS、DS、ES、FS、GS の各セグメント・レジスタに、以下の値(実アドレスモードに
-              適した値)をストアしているディスクリプタのセレクタをロードする。
-                       - リミット = 64 K バイト(0FFFFH)
-                       - バイト・グラニュラリティ(G = O)
-                       - 上方拡張(E = O)
-                       - 書き込み可能(W = 1)
-                       - 存在(P = 1)
-                       - ベース = 任意の値
-*/
-
-
-/*
-       5. セグメント・レジスタには、ヌル以外のセグメント・セレクタがロードされなければな
-           らない。  そうしないと、 実アドレスモードでセグメント・レジスタを使用できなくなる。
-           セグメント・レジスタが再ロードされない場合は、保護モード時にロードされたディス
-           クリプタの属性によって実行が継続されることに注意しなければならない。
-*/
-
-
-
-/*
-       6. LIDT 命令を実行して、実アドレスモードの割り込みテーブルを指す。これは 1M バイ
-           トの実アドレスモードのアドレス範囲内にある。
-*/
-
-
-
-/*
-       7. CR0 レジスタ内の PE フラグをクリアして、実アドレスモードに切り替える。
-*/
-
-
-/*
-       8. far JMP 命令を実行して実アドレスモードのプログラムにジャンプする。この動作に
-           よって、命令キューがフラッシュされ、適切なベース値とアクセス権値が CS レジスタ
-           にロードされる。
-*/
-
-
-
-/*
-       9. 実アドレスモードのコードに必要であれば、SS、DS、ES、FS、GS の各レジスタをロー
-           ドする。これらのレジスタのどれかを実アドレスモードで使用しない場合は、そのレ
-           ジスタに O を書き込む。
-*/
-
-
-
-/*
-       10. STI 命令を実行して、マスク可能ハードウェア割り込みをイネーブルにする。また必要
-           なハードウェア動作を実行して NMI 割り込みをイネーブルにする。
-*/
-       # 割り込み許可
-       sti
-       # NMI割り込み許可
-       call    enableNMI
 
 
+       // 呼び出し元に戻る
+       pushl   %ebx
        ret
 
-
-/*
-     モード切り替え
-9.9.
-     プロセッサを保護モードで使用するには、モードの切り替えを実アドレスモードから
-     実行しなければならない。いったん保護モードに移行した後は、通常の場合、ソフト
-     ウェアが実アドレスモードに戻る必要はない。実アドレスモード(8086 モード)で実
-     行するように記述されたソフトウェアを実行するには、実アドレスモードに再度切り
-            ソフトウェアを仮想 8086 モードで実行するほうが一般的には便利であ
-     替えるよりも、
-     る。
-9-16
-                                                                  9
-                                                   プロセッサの管理と初期化
-       保護モードへの切り替え
-9.9.1.
-       保護モードに切り替える前に、システムデータ構造とコード・モジュールの必要最小
-                                                        9.8. 「保護モー
-       限のセットをメモリにロードしなければならない。            詳細については、 節
-       ド動作に対するソフトウェア初期化」         で説明している。     各テーブルが作成された後は、
-       ソフトウェア初期化コードを保護モードに切り替えられる。
-                        CR0 レジスタ内の PE フラグを設定する MOV CR0 命令を実行
-       保護モードに入るには、
-            (同じ命令で、レジスタ CR0 内の PG フラグを設定してページングをイネーブル
-       する。
-               )保護モードでの実行は 0 の CPL から開始する。
-       にできる。
-       32 ビット IA-32 プロセッサでは、  保護モードへの切り替えに必要な条件が少し異なる。
-       すべての 32 ビット IA-32 プロセッサ間でコードの上位互換性と下位互換性を確保する
-       ためには、以下の操作手順を実行する。
-       1. 割り込みをディスエーブルにする。 命令によってマスク可能ハードウェア割り込み
-                                CLI
-          がディスエーブルになる。NMI 割り込みは、外部回路によってディスエーブルにでき
-          る。 (ソフトウェアは、モード切り替えの動作中に例外または割り込みが発生しないよ
-          うに保証する必要がある。     )
-       2. LGDT 命令を実行して、GDTR レジスタに GDT のベースアドレスをロードする。
-       3. 制御レジスタ CR0 の PE フラグ(またオプションで PG フラグ)を設定する MOV CR0
-          命令を実行する。
-       4. MOV CR0 命令のすぐ後で、far JMP 命令または far CALL 命令を実行する。    (この操作
-          は通常、命令ストリーム内の次の命令への far ジャンプまたは far コールになる。          )
-       5. MOV CR0 命令の直後に JMP 命令または CALL 命令を実行すると、実行の流れが変化
-          し、プロセッサが順次処理される。
-       6. ページングがイネーブルな場合、      MOV CR0 命令のコードと、    JMP 命令または CALL 命
-          令のコードは、アイデンティティ・マッピングされたページから得たものでなければ
-          ならない(つまり、ジャンプ前のリニアアドレスが、ページングと保護モードがイネー
-          ブルになった後の物理アドレスと同一でなければならない) JMP 命令または CALL 命
-                                                  。
-          令のターゲット命令は、アイデンティティ・マッピングされる必要はない。
-       7. ローカル ディスクリプタ テーブルを使用する場合には、           LLDT 命令を実行して LDTR
-                ・         ・
-          レジスタに LDT のセグメント・セレクタをロードする。
-       8. LTR 命令を実行して、  セグメント・セレクタ付きタスクレジスタを初期保護モード・タ
-          スクへロードする。またはタスクスイッチに関する TSS 情報を保存できるメモリの書
-          き込み可能領域へロードする。
-       9. 保護モードに移行した後、セグメント・レジスタは実アドレスモードで保持していた
-          内容をそのまま保持し続ける。操作手順 4 の JMP 命令または CALL 命令が CS レジス
-                                                                9-17
-IA-32 インテル® アーキテクチャ・ソフトウェア・デベロッパーズ・マニュアル 下巻:システム・プログラミング・ガイド
-              タをリセットする。以下のどれかを実行して、残りのセグメント・レジスタの内容を
-              更新する。
-              - DS、SS、ES、FS、GS の各セグメント・レジスタを再ロードする。ES、FS、GS の
-                 各レジスタのなかで使用しないものがある場合、そのレジスタにヌルセレクタを
-                 ロードする。
-              - JMP 命令または CALL 命令を新しいタスクに対して実行する。これによって、セグ
-                 メント・レジスタの値がリセットされ、新しいコード・セグメントに分岐する。
-          10. LIDT 命令を実行して、IDTR レジスタに保護モード IDT のアドレスとリミットをロー
-              ドする。
-          11. STI 命令を実行して、マスク可能ハードウェア割り込みをイネーブルにし、また必要な
-              ハードウェア動作を実行して NMI 割り込みをイネーブルにする。
-          上記の手順 3 と手順 4 の間に他の命令が存在すると、不規則な障害が発生することが
-          ある。システム管理モードで、メモリを参照する命令が手順 3 と手順 4 の間に挿入さ
-          れたときのような状況では、障害は直ちに認識される。
-          実アドレスモードへの再切り替え
-9.9.2.
-          ソフトウェアが MOV CR0 命令によって CRO レジスタ内の PE ビットをクリアした場
-          合、プロセッサは実アドレスモードに切り替えられる。実アドレスモードに再移行す
-          るときは、以下の操作手順を実行する必要がある。
-          1. 割り込みをディスエーブルにする。 命令によってマスク可能ハードウェア割り込み
-                                     CLI
-              がディスエーブルになる。NMI 割り込みは、外部回路によってディスエーブルにでき
-              る。
-          2. ページングがイネーブルである場合は、以下の各操作を行う。
-              - プログラム制御を、物理アドレスにアイデンティティ・マッピングされている(つ
-                 まり物理アドレスと同一の)リニアアドレスに転送する。
-              - GDT と IDT がアイデンティティ・マッピングされたページにあるようにする。
-              - CR0 レジスタ内の PG ビットをクリアする。
-              - 0H を CR3 レジスタに移動して TLB をフラッシュする。
-          3. プログラム制御を、64K バイト(FFFH)のリミットを持つ読み取り可能セグメントに
-              転送する。この動作によって、実アドレスモードで必要になるセグメント・リミット
-              が CS レジスタにロードされる。
-          4. SS、DS、ES、FS、GS の各セグメント・レジスタに、以下の値(実アドレスモードに
-              適した値)をストアしているディスクリプタのセレクタをロードする。
-              - リミット = 64 K バイト(0FFFFH)
-9-18
-                                                9
-                                   プロセッサの管理と初期化
-    - バイト・グラニュラリティ(G = O)
-    - 上方拡張(E = O)
-    - 書き込み可能(W = 1)
-    - 存在(P = 1)
-    - ベース = 任意の値
-5. セグメント・レジスタには、ヌル以外のセグメント・セレクタがロードされなければな
-    らない。  そうしないと、 実アドレスモードでセグメント・レジスタを使用できなくなる。
-    セグメント・レジスタが再ロードされない場合は、保護モード時にロードされたディス
-    クリプタの属性によって実行が継続されることに注意しなければならない。
-6. LIDT 命令を実行して、実アドレスモードの割り込みテーブルを指す。これは 1M バイ
-    トの実アドレスモードのアドレス範囲内にある。
-7. CR0 レジスタ内の PE フラグをクリアして、実アドレスモードに切り替える。
-8. far JMP 命令を実行して実アドレスモードのプログラムにジャンプする。この動作に
-    よって、命令キューがフラッシュされ、適切なベース値とアクセス権値が CS レジスタ
-    にロードされる。
-9. 実アドレスモードのコードに必要であれば、SS、DS、ES、FS、GS の各レジスタをロー
-    ドする。これらのレジスタのどれかを実アドレスモードで使用しない場合は、そのレ
-    ジスタに O を書き込む。
-10. STI 命令を実行して、マスク可能ハードウェア割り込みをイネーブルにする。また必要
-    なハードウェア動作を実行して NMI 割り込みをイネーブルにする。
-
-
-*/
index 88da776..a16b92b 100644 (file)
@@ -20,7 +20,7 @@
                                        <folderInfo id="0.1215660714." name="/" resourcePath="">
                                                <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.403782632" name="ツールチェーンなし" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
                                                        <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.403782632.1175304969" name=""/>
-                                                       <builder autoBuildTarget="all" buildPath="${workspace_loc:/TryOS/Debug}" cleanBuildTarget="clean" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" id="org.eclipse.cdt.build.core.settings.default.builder.686110208" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make ビルダー" parallelizationNumber="1" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+                                                       <builder autoBuildTarget="all" buildPath="${ProjDirPath}/Debug" cleanBuildTarget="clean" enableAutoBuild="true" enableCleanBuild="true" enabledIncrementalBuild="true" id="org.eclipse.cdt.build.core.settings.default.builder.686110208" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make ビルダー" parallelizationNumber="1" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
                                                        <tool id="org.eclipse.cdt.build.core.settings.holder.libs.577738444" name="ライブラリー設定フォルダー" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
                                                        <tool id="org.eclipse.cdt.build.core.settings.holder.1442101858" name="アセンブリー" superClass="org.eclipse.cdt.build.core.settings.holder">
                                                                <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1667077743" languageId="org.eclipse.cdt.core.assembly" languageName="アセンブリー" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
                </cconfiguration>
                <cconfiguration id="0.1215660714.164616624">
                        <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1215660714.164616624" moduleId="org.eclipse.cdt.core.settings" name="Release">
+                               <macros>
+                                       <stringMacro name="BuildDir" type="VALUE_TEXT" value="${}"/>
+                               </macros>
                                <externalSettings/>
                                <extensions>
                                        <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
                                        <folderInfo id="0.1215660714.164616624." name="/" resourcePath="">
                                                <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1240621798" name="ツールチェーンなし" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
                                                        <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1240621798.200324006" name=""/>
-                                                       <builder buildPath="${workspace_loc:/TryOS/Release}" id="org.eclipse.cdt.build.core.settings.default.builder.1987712862" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make ビルダー" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
+                                                       <builder buildPath="${workspace_loc:/TryOS/Release}" enableAutoBuild="true" id="org.eclipse.cdt.build.core.settings.default.builder.1987712862" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make ビルダー" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
                                                        <tool id="org.eclipse.cdt.build.core.settings.holder.libs.1845962221" name="ライブラリー設定フォルダー" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
                                                        <tool id="org.eclipse.cdt.build.core.settings.holder.1119654089" name="アセンブリー" superClass="org.eclipse.cdt.build.core.settings.holder">
                                                                <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1508503783" languageId="org.eclipse.cdt.core.assembly" languageName="アセンブリー" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
index 95eabfc..61e47ea 100644 (file)
@@ -10,7 +10,6 @@
        <buildSpec>
                <buildCommand>
                        <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
-                       <triggers>clean,full,incremental,</triggers>
                        <arguments>
                                <dictionary>
                                        <key>?name?</key>
@@ -34,7 +33,7 @@
                                </dictionary>
                                <dictionary>
                                        <key>org.eclipse.cdt.make.core.buildLocation</key>
-                                       <value>${workspace_loc:/TryOS/Debug}</value>
+                                       <value>${ProjDirPath}/Debug</value>
                                </dictionary>
                                <dictionary>
                                        <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
@@ -46,7 +45,7 @@
                                </dictionary>
                                <dictionary>
                                        <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
-                                       <value>false</value>
+                                       <value>true</value>
                                </dictionary>
                                <dictionary>
                                        <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
index 5fb2878..73fd988 100644 (file)
@@ -1,4 +1,4 @@
-#Sun Sep 04 11:47:36 JST 2011
+#Sun Mar 04 22:17:49 JST 2012
 eclipse.preferences.version=1
 environment/project/0.1215660714/append=true
 environment/project/0.1215660714/appendContributed=true
@@ -34,7 +34,7 @@ org.eclipse.cdt.core.formatter.compact_else_if=true
 org.eclipse.cdt.core.formatter.continuation_indentation=1
 org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=1
 org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false
-org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=false
+org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=true
 org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true
 org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false
 org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true
index 218bd97..100cc01 100644 (file)
@@ -1 +1,3 @@
-/TryOS.iso
+TryOS.iso
+.zero144.bin
+.zero512.bin
index 0a71058..ff6a36e 100644 (file)
@@ -16,13 +16,14 @@ BUILD_CONFIG = Debug
 OS_NAME = TryOS
 TARGET = $(OS_NAME).iso
 
+
 # Boot
 BOOT_NAME = TryBoot
 BOOT_DIR = ../../Boot/
 BOOT_IMG_NAME = $(BOOT_NAME).img
 BOOT_IMG_PATH = $(BOOT_DIR)$(BUILD_CONFIG)/$(BOOT_IMG_NAME)
-BOOT_LOAD_SEGMENT = 0x0100
-BOOT_LOAD_SIZE = 4
+FD_IMG_NAME = FD.img
+BOOT_CATALOG = Boot.catalog
 
 # Kernel
 KERNEL_NAME = TryKernel
@@ -41,19 +42,17 @@ ISO_PATH_ROOT = ../ISORoot/
 ISO_PATH_OS_DIR = $(ISO_PATH_ROOT)$(OS_NAME)/
 ISO_PATH_BOOT_DIR = $(ISO_PATH_OS_DIR)Boot/
 ISO_PATH_BOOT_IMG = $(ISO_PATH_BOOT_DIR)$(BOOT_IMG_NAME)
+ISO_PATH_FD_IMG = $(ISO_PATH_BOOT_DIR)$(FD_IMG_NAME)
 ISO_PATH_KERNEL_DIR = $(ISO_PATH_OS_DIR)Kernel/
 ISO_PATH_KERNEL_IMG = $(ISO_PATH_KERNEL_DIR)$(KERNEL_IMG_NAME)
 ISO_PATH_APPS_DIR = $(ISO_PATH_ROOT)Apps/
 
 
 # ISO 9660ファイルシステムのイメージ作成オプション
-MKISOFS_OPTIONS += -b $(OS_NAME)/Boot/$(BOOT_IMG_NAME)
-MKISOFS_OPTIONS += -no-emul-boot
-MKISOFS_OPTIONS += -boot-load-seg $(BOOT_LOAD_SEGMENT)
-MKISOFS_OPTIONS += -boot-load-size $(BOOT_LOAD_SIZE)
-#MKISOFS_OPTIONS += -quiet
+MKISOFS_OPTIONS += -quiet
+MKISOFS_OPTIONS += -b TryOS/Boot/FD.img
+#MKISOFS_OPTIONS += -c $(BOOT_CATALOG)
 MKISOFS_OPTIONS += -d
-MKISOFS_OPTIONS += -gui
 MKISOFS_OPTIONS += -l
 MKISOFS_OPTIONS += -J
 MKISOFS_OPTIONS += -R
@@ -79,6 +78,7 @@ all: $(TARGET)
 
 PHONY += clean
 clean:
+       rm -f .*.bin
        rm -f $(OBJS) $(TARGET)
        rm -fr $(ISO_PATH_ROOT)
 
@@ -91,15 +91,27 @@ run: all
 
 
 
-
-$(TARGET): $(ISO_PATH_BOOT_IMG) $(ISO_PATH_KERNEL_IMG)
+# isoファイル作成
+$(TARGET): $(ISO_PATH_BOOT_IMG) $(ISO_PATH_KERNEL_IMG) $(ISO_PATH_FD_IMG)
        mkisofs $(MKISOFS_OPTIONS) -o $@ $(ISO_PATH_ROOT)
 
-
+# ブート用FDイメージ作成(1.44MiB)
+$(ISO_PATH_FD_IMG): $(ISO_PATH_BOOT_IMG) $(ISO_PATH_KERNEL_IMG)
+       dd if=/dev/zero count=1 > .zero512.bin
+       dd if=/dev/zero count=2880 > .zero144.bin
+       # ファイルサイズはこんな感じでとれるが。。。
+       # 文字列はやっ!
+#      wc -c < $(ISO_PATH_KERNEL_IMG)\
+#              | cat $(ISO_PATH_BOOT_IMG) -
+       cat $(ISO_PATH_BOOT_IMG) $(ISO_PATH_KERNEL_IMG) .zero144.bin\
+               | dd count=2880 > $@
+
+# ブートイメージ作成
 $(ISO_PATH_BOOT_IMG): $(BOOT_IMG_PATH)
        -mkdir -p $(ISO_PATH_BOOT_DIR)
        cp $(CP_OPTIONS) $^ $@
-       
+
+# カーネルイメージ作成
 $(ISO_PATH_KERNEL_IMG): $(KERNEL_IMG_PATH)
        -mkdir -p $(ISO_PATH_KERNEL_DIR)
        cp $(CP_OPTIONS) $^ $@
index 88b8220..384ef20 100644 (file)
@@ -33,6 +33,9 @@
                                                                <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1209073530" name="デバッグ・レベル" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
                                                                <option id="gnu.cpp.compiler.option.preprocessor.nostdinc.1363885386" name="システム・ディレクトリーを検索しない (-nostdinc)" superClass="gnu.cpp.compiler.option.preprocessor.nostdinc" value="true" valueType="boolean"/>
                                                                <option id="gnu.cpp.compiler.option.other.other.544076284" name="その他のフラグ" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -Wa,-a=&quot;Source/$*.lst&quot;" valueType="string"/>
+                                                               <option id="gnu.cpp.compiler.option.include.paths.1281131980" name="インクルード・パス (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/TryAPI/Include}&quot;"/>
+                                                               </option>
                                                                <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.93043261" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
                                                        </tool>
                                                        <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1743402946" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
@@ -40,6 +43,9 @@
                                                                <option id="gnu.c.compiler.exe.debug.option.debugging.level.116295993" name="デバッグ・レベル" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
                                                                <option id="gnu.c.compiler.option.preprocessor.nostdinc.1232114943" name="システム・ディレクトリーを検索しない (-nostdinc)" superClass="gnu.c.compiler.option.preprocessor.nostdinc" value="true" valueType="boolean"/>
                                                                <option id="gnu.c.compiler.option.misc.other.1620575501" name="その他のフラグ" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -Wa,-a=&quot;Source/$*.lst&quot;" valueType="string"/>
+                                                               <option id="gnu.c.compiler.option.include.paths.641220809" name="インクルード・パス (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/TryAPI/Include}&quot;"/>
+                                                               </option>
                                                                <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1593072622" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
                                                        </tool>
                                                        <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.604766559" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/>
                                                                <option id="gnu.cpp.link.option.nodeflibs.1208198987" name="デフォルト・ライブラリーを使用しない (-nodefaultlibs)" superClass="gnu.cpp.link.option.nodeflibs" value="true" valueType="boolean"/>
                                                                <option id="gnu.cpp.link.option.nostdlibs.696650464" name="始動またはデフォルト・ライブラリーなし (-nostdlib)" superClass="gnu.cpp.link.option.nostdlibs" value="true" valueType="boolean"/>
                                                                <option id="gnu.cpp.link.option.flags.1390226320" name="リンカー・フラグ" superClass="gnu.cpp.link.option.flags" value="-static -T&quot;${LS_FILE_PATH}&quot; -Map&quot;${MAP_FILE_PATH}&quot;" valueType="string"/>
+                                                               <option id="gnu.cpp.link.option.paths.1609477892" name="ライブラリー検索パス (-L)" superClass="gnu.cpp.link.option.paths"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1457541729" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
                                                                        <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
                                                                        <additionalInput kind="additionalinput" paths="$(LIBS)"/>
                                                                </inputType>
                                                        </tool>
-                                                       <tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1093522763" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
+                                                       <tool command="g++" id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1093522763" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
                                                                <option id="gnu.both.asm.option.flags.1476657002" name="アセンブラー・フラグ" superClass="gnu.both.asm.option.flags" value="-c -Wall -a=&quot;Source/$*.lst&quot;" valueType="string"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.assembler.input.814552943" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
                                                        </tool>
diff --git a/Kernel/.settings/org.eclipse.cdt.core.prefs b/Kernel/.settings/org.eclipse.cdt.core.prefs
new file mode 100644 (file)
index 0000000..c16d1b5
--- /dev/null
@@ -0,0 +1,152 @@
+#Sun Mar 04 22:17:49 JST 2012
+eclipse.preferences.version=1
+org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=36
+org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=36
+org.eclipse.cdt.core.formatter.alignment_for_compact_if=0
+org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=36
+org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16
+org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48
+org.eclipse.cdt.core.formatter.alignment_for_expression_list=0
+org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=36
+org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=36
+org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=36
+org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.cdt.core.formatter.brace_position_for_block=next_line
+org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=next_line
+org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=next_line
+org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=next_line
+org.eclipse.cdt.core.formatter.brace_position_for_switch=next_line
+org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=next_line
+org.eclipse.cdt.core.formatter.compact_else_if=true
+org.eclipse.cdt.core.formatter.continuation_indentation=1
+org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=1
+org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=true
+org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true
+org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false
+org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false
+org.eclipse.cdt.core.formatter.indent_empty_lines=false
+org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.cdt.core.formatter.indentation.size=4
+org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert
+org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
+org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert
+org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert
+org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert
+org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert
+org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert
+org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert
+org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert
+org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.cdt.core.formatter.lineSplit=80
+org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.cdt.core.formatter.tabulation.char=tab
+org.eclipse.cdt.core.formatter.tabulation.size=4
+org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false
diff --git a/Kernel/.settings/org.eclipse.cdt.ui.prefs b/Kernel/.settings/org.eclipse.cdt.ui.prefs
new file mode 100644 (file)
index 0000000..985bc7b
--- /dev/null
@@ -0,0 +1,4 @@
+#Sun Mar 04 21:32:27 JST 2012
+eclipse.preferences.version=1
+formatter_profile=_OS Project C/C++
+formatter_settings_version=1
index e6a5514..55a584b 100644 (file)
@@ -1,8 +1,9 @@
 
-/*OUTPUT_FORMAT("elf32-i386");*/
-OUTPUT_FORMAT("binary");
+OUTPUT_FORMAT("elf32-i386");
 OUTPUT_ARCH("i386");
 
+ENTRY(entryPoint);
+
 SECTIONS
 {
        .text :
diff --git a/Kernel/Source/EntryPoint.S b/Kernel/Source/EntryPoint.S
new file mode 100644 (file)
index 0000000..21bf94d
--- /dev/null
@@ -0,0 +1,26 @@
+.section .text
+.code32
+
+
+/**
+ * エントリポイント
+ * ここから始まる
+ */
+.section .text
+.global entryPoint
+entryPoint:
+
+
+init:
+
+       // TODO とにかく、今はC言語に移ろう!
+
+       movw    $0x28, %ax
+       movw    %ax, %ds
+       movw    %ax, %es
+       movw    %ax, %ss
+
+       movl    $0x100000, %esp
+
+
+       jmp             _Z10kernelInitv
diff --git a/Kernel/Source/PagingSample.cpp b/Kernel/Source/PagingSample.cpp
new file mode 100644 (file)
index 0000000..dd6392d
--- /dev/null
@@ -0,0 +1,12 @@
+#include <TryOS/Library/Common/Common.h>
+
+void setupPaging()
+{
+
+}
+
+class AbsPageEntry
+{
+       protected:
+               u4 mBaseAddress :24;
+};
index fe42724..55e52ae 100644 (file)
@@ -9,15 +9,29 @@
 //#include <iostream>
 //using namespace std;
 
-void dummy() {
-//     cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
-
-       return;
-}
 
+void kernelInit() {
+//
+//     char aiu[] = "aiueo...kkkkk";
+//     int a = 10;
+//     a += 9;
+//
+//     aiu[0] = 's';
 
-int dummy2() {
-       int a = 10;
-       a += 9;
-       return a;
+       while (true) {
+               __asm__( "hlt;" );
+       }
 }
+//
+//void dummy() {
+////   cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
+//
+//     return;
+//}
+//
+//
+//int dummy2() {
+//     int a = 10;
+//     a += 9;
+//     return a;
+//}