OSDN Git Service

projects clean up 1
[pinoc/pinoc.git] / tryos / tryos_test / pinoc_x86 / test / PINoC / boot / tmp
diff --git a/tryos/tryos_test/pinoc_x86/test/PINoC/boot/tmp b/tryos/tryos_test/pinoc_x86/test/PINoC/boot/tmp
new file mode 100644 (file)
index 0000000..a926c3e
--- /dev/null
@@ -0,0 +1,200 @@
+#ifndef __BIOSCALL_H__
+#define __BIOSCALL_H__
+
+#include "realmode.h"
+
+/* waitkeybord */
+__asm__(
+               "waitkeybord:           \n\t"
+               "in    $0x64,    %al    \n\t"
+               "and   $0x02,    %al    \n\t"
+               "jnz   waitkeybord      \n\t"
+               "ret                    \n\t"
+);
+
+void io_A20GATE()
+{
+
+       __asm__(
+                       "movb    $0xff,    %al    \n\t"
+                       "outb    %al,      $0x21  \n\t"
+                       "nop                      \n\t"
+                       "outb    %al,      $0xa1  \n\t"
+
+                       "cli                      \n\t"
+       );
+
+       __asm__(
+                       "call    waitkeybord    \n\t"
+                       "movb    $0xd1,   %al    \n\t"
+                       "outb    %al,     $0x64  \n\t"
+                       "call    waitkeybord    \n\t"
+                       "movb    $0xdf,   %al    \n\t"
+                       "outb    %al,     $0x60  \n\t"
+                       "call    waitkeybord    \n\t"
+       );
+}
+
+void io_vga()
+{
+       __asm__(
+                       "movb    $0x00,    %ah    \n\t"
+                       "movb    $0x13,    %al    \n\t"
+                       "int     $0x10            \n\t" /* BIOS�ƤӽФ� */
+       );
+}
+
+/* void test() */
+/* { */
+/*   __asm__( */
+/*       "movw    $0x820,    %ax  \n\t" */
+/*       "movw    %ax,       %es  \n\t"  */
+/*       "movw    $0x00,     %bx  \n\t" /\* (ES * 16 + BX)�Υ��ɥ쥹���ɤ߹��� [0x8200����] *\/ */
+
+/*       "movb    $0x00,     %ch  \n\t" /\* ������0 *\/ */
+/*       "movb    $0x00,     %dh  \n\t" /\* �إå�0 *\/ */
+/*       "movb    $0x01,     %cl  \n\t" /\* ������2 *\/ */
+
+/*       "movw    $0x00,     %si  \n\t" /\* ���Բ�� *\/ */
+
+/*       "io_load_retry:          \n\t" */
+
+/*       "movb    $0x02,     %ah  \n\t" /\* �ǥ������ɤ߹��� *\/ */
+/*       "movb    $0x01,     %al  \n\t" /\* 1���������� *\/ */
+/*       "movb    $0x00,     %dl  \n\t" /\* �ɥ饤����0 *\/ */
+/*       "int     $0x13           \n\t" /\* �ǥ�����BIOS�ƤӽФ� *\/ */
+
+/*       "jnc     io_load_fin     \n\t" /\* �����ʤ�success�� *\/ */
+/*       "add     $0x01,     %si  \n\t" /\* ���Ԥ򥫥���� *\/ */
+/*       "cmp     $0x05,     %si  \n\t" */
+/*       "jae     io_load_fin     \n\t" /\* 5�󡢤ޤ��ϣ�����礭�����error *\/ */
+
+/*       "movb    $0x00,     %ah  \n\t" */
+/*       "movb    $0x00,     %dl  \n\t" */
+/*       "int     $0x13           \n\t" /\* �ɥ饤�֤ν�� *\/ */
+/*       "jmp     io_load_retry   \n\t" /\* ��ĩ�� *\/ */
+/*       ); */
+
+/*   __asm__("io_load_fin:"); */
+/* } */
+
+void io_debug(/* s1* _Str */)
+{
+       //__asm__(".org 0x100");
+
+       // s1 str[3][64] = {"Welcome to PINoC!!\r\n", "loading...\r\n", "starting PINoC...\r\n"};
+       /* s1 str[1][22] = {"Welcome to PINoC!!\r\n"}; */
+
+       /* ʸ�����ɽ�� */
+       /* __asm__( */
+       /*        "movb    $0x0e,   %%ah  \n\t" */
+
+       /*        "putloop:               \n\t" */
+       /*        "movb    (%0),    %%al  \n\t" */
+       /*        "add     $1,      %0    \n\t" */
+       /*        "cmpb    $0,      %%al  \n\t" */
+       /*        "je      io_debug_fin   \n\t" */
+       /*        "int     $0x10          \n\t" */
+       /*        "jmp     putloop        \n\t" */
+       /*        "io_debug_fin:          \n\t" */
+       /*        : : "r" (str[0]) : "%al", "%ah" */
+       /*        ); */
+
+       // �ǥХå���üʸ��
+       __asm__(
+                       "movb    $0x0e,   %ah  \n\t"
+                       "movb    $2   ,   %al  \n\t"
+                       "int     $0x10         \n\t"
+       );
+
+}
+
+void io_PROTECTMODE()
+{
+       __asm__(
+                       "movl    %cr0,      %eax    \n\t"
+                       "orl     $0x01,     %eax    \n\t"
+                       "movl    %eax,      %cr0    \n\t"
+                       "jmp     io_protect_pflash  \n\t"
+                       "io_protect_pflash:         \n\t"
+       );
+}
+
+#include "protectmode.h"
+
+void io_hlt()
+{
+       __asm__("hlt    \n\t");
+}
+
+void io_write(s1* vram, si xsize, si ysize, si xSrc, si ySrc, si color)
+{
+
+       si si_dst = 320 * ySrc;
+       si_dst += xSrc;
+
+       si si_i, si_ii;
+
+       FOR(si_i, ysize)
+       {
+               FOR(si_ii, xsize)
+               {
+                       vram[(si_dst + si_ii)] = color;
+               }
+               si_dst += 320;
+       }
+}
+
+s1 io_load()
+{
+
+       s1 flag = 1; /* �ɤ߹��ߤ�����ʤ�0 ���Ԥʤ�1������ */
+
+       __asm__(
+                       "movw    $0x820,    %%ax  \n\t"
+                       "movw    %%ax,      %%es  \n\t"
+                       "movw    $0x00,     %%bx  \n\t" /* (ES * 16 + BX)�Υ��ɥ쥹���ɤ߹��� [0x8200����] */
+
+                       "movb    $0x00,     %%ch  \n\t" /* ������0 */
+                       "movb    $0x00,     %%dh  \n\t" /* �إå�0 */
+                       "movb    $0x01,     %%cl  \n\t" /* ������2 */
+
+                       "movw    $0x00,     %%si  \n\t" /* ���Բ�� */
+
+                       "io_load_retry:          \n\t"
+
+                       "movb    $0x02,     %%ah  \n\t" /* �ǥ������ɤ߹��� */
+                       "movb    $0x01,     %%al  \n\t" /* 1���������� */
+                       "movb    $0x00,     %%dl  \n\t" /* �ɥ饤����0 */
+                       "int     $0x13           \n\t" /* �ǥ�����BIOS�ƤӽФ� */
+
+                       "jnc     io_load_success \n\t" /* �����ʤ�success�� */
+                       "add     $0x01,     %%si  \n\t" /* ���Ԥ򥫥���� */
+                       "cmp     $0x05,     %%si  \n\t"
+                       "jae     io_load_error   \n\t" /* 5�󡢤ޤ��ϣ�����礭�����error */
+
+                       "movb    $0x00,     %%ah  \n\t"
+                       "movb    $0x00,     %%dl  \n\t"
+                       "int     $0x13           \n\t" /* �ɥ饤�֤ν�� */
+                       "jmp     io_load_retry   \n\t" /* ��ĩ�� */
+                       : : : "%bx", "%ch", "%dh", "%cl", "%si"
+       );
+
+       /* return ̿���1�Ĥ����񤱤ʤ��餷�� */
+
+       __asm__(
+                       "io_load_error:        \n\t" /* ���� */
+                       "movb    $0x01,    %0  \n\t"
+                       "jmp     io_load_fin   \n\t"
+
+                       "io_load_success:      \n\t" /* ���� */
+                       "movb    0x00,     %0  \n\t"
+
+                       "io_load_fin:          \n\t"
+                       : "=r" (flag) : "0" (flag)
+       );
+
+       return flag;
+}
+
+#endif