OSDN Git Service

time.hの関数の実装開始
authorvosystems <doradora.motochan@gmail.com>
Sun, 19 Oct 2014 13:52:56 +0000 (22:52 +0900)
committervosystems <doradora.motochan@gmail.com>
Sun, 19 Oct 2014 13:52:56 +0000 (22:52 +0900)
36 files changed:
Kernel/ASM_Interrupt.o [new file with mode: 0644]
Kernel/FAT.o [new file with mode: 0644]
Kernel/GDT_IDT.o [new file with mode: 0644]
Kernel/Graphical.o [new file with mode: 0644]
Kernel/Interrupt.o [new file with mode: 0644]
Kernel/KeyBoard.o [new file with mode: 0644]
Kernel/Makefile
Kernel/Makefile~ [new file with mode: 0644]
Kernel/Message.o [new file with mode: 0644]
Kernel/System.c
Kernel/System.c~ [new file with mode: 0644]
Kernel/System.o [new file with mode: 0644]
Kernel/Vane.o [new file with mode: 0644]
Kernel/boot.c
Kernel/boot.c~ [new file with mode: 0644]
Kernel/boot.o [new file with mode: 0644]
Kernel/load.o [new file with mode: 0644]
Kernel/memory.o [new file with mode: 0644]
Kernel/scancode.o [new file with mode: 0644]
Kernel/stdio.c
Kernel/stdio.c~ [new file with mode: 0644]
Kernel/stdio.o [new file with mode: 0644]
Kernel/string.c~ [new file with mode: 0644]
Kernel/string.o [new file with mode: 0644]
Kernel/task.o [new file with mode: 0644]
Kernel/time.c [new file with mode: 0644]
Kernel/time.c~ [new file with mode: 0644]
Kernel/time.o [new file with mode: 0644]
Kernel/timer.o [new file with mode: 0644]
bin/Kernel.vsb
include/System.h [new file with mode: 0644]
include/System.h~ [new file with mode: 0644]
include/stdio.h
include/stdio.h~
include/time.h [new file with mode: 0644]
include/time.h~ [new file with mode: 0644]

diff --git a/Kernel/ASM_Interrupt.o b/Kernel/ASM_Interrupt.o
new file mode 100644 (file)
index 0000000..719191f
Binary files /dev/null and b/Kernel/ASM_Interrupt.o differ
diff --git a/Kernel/FAT.o b/Kernel/FAT.o
new file mode 100644 (file)
index 0000000..465757e
Binary files /dev/null and b/Kernel/FAT.o differ
diff --git a/Kernel/GDT_IDT.o b/Kernel/GDT_IDT.o
new file mode 100644 (file)
index 0000000..116c62a
Binary files /dev/null and b/Kernel/GDT_IDT.o differ
diff --git a/Kernel/Graphical.o b/Kernel/Graphical.o
new file mode 100644 (file)
index 0000000..ddaa211
Binary files /dev/null and b/Kernel/Graphical.o differ
diff --git a/Kernel/Interrupt.o b/Kernel/Interrupt.o
new file mode 100644 (file)
index 0000000..13a696b
Binary files /dev/null and b/Kernel/Interrupt.o differ
diff --git a/Kernel/KeyBoard.o b/Kernel/KeyBoard.o
new file mode 100644 (file)
index 0000000..7bdc78a
Binary files /dev/null and b/Kernel/KeyBoard.o differ
index 9c5d190..c1d7f71 100644 (file)
@@ -38,9 +38,10 @@ SYSTEM_C=System.c
 MESSAGE_C=Message.c
 TIMER_C=timer.c
 TASK_C=task.c
+TIME_C=time.c
 
 #オブジェクト
-BOOT_OBJ=${BOOT_S:.S=.o} ${BOOT_C:.c=.o} ${VANE_S:.S=.o} ${KEYBOARD_C:.c=.o} ${STDIO_C:.c=.o} ${GDT_IDT_C:.c=.o} ${INTERRUPT_C:.c=.o} ${STRING_C:.c=.o} ${ASM_INTERRUPT_S:.S=.o} ${SCANCODE_C:.c=.o} ${MEMMAN_C:.c=.o} ${FAT_C:.c=.o} ${GRAPHIC_C:.c=.o} ${SYSTEM_C:.c=.o} ${MESSAGE_C:.c=.o} ${TIMER_C:.c=.o} ${TASK_C:.c=.o}
+BOOT_OBJ=${BOOT_S:.S=.o} ${BOOT_C:.c=.o} ${VANE_S:.S=.o} ${KEYBOARD_C:.c=.o} ${STDIO_C:.c=.o} ${GDT_IDT_C:.c=.o} ${INTERRUPT_C:.c=.o} ${STRING_C:.c=.o} ${ASM_INTERRUPT_S:.S=.o} ${SCANCODE_C:.c=.o} ${MEMMAN_C:.c=.o} ${FAT_C:.c=.o} ${GRAPHIC_C:.c=.o} ${SYSTEM_C:.c=.o} ${MESSAGE_C:.c=.o} ${TIMER_C:.c=.o} ${TASK_C:.c=.o} ${TIME_C:.c=.o}
 
 kernel: ${BOOT_OBJ}
        ${LD} ${TARGET} ${BOOT_OBJ}
diff --git a/Kernel/Makefile~ b/Kernel/Makefile~
new file mode 100644 (file)
index 0000000..9c5d190
--- /dev/null
@@ -0,0 +1,51 @@
+TARGET      = ../bin/Kernel.vsb
+
+#宣言
+CC                     = gcc
+RM                     = /bin/rm
+MV                     = /bin/mv
+LD                     = /usr/bin/ld
+LN_S           = ln -s
+AR                     = /usr/bin/ar
+RANLIB         = ranlib
+INCLUDES    = -I../include
+LIBVANE                = ../lib/libvanec.a ../lib/libvanego.a
+FLAGS          = -m32 -ffreestanding -fno-common -fno-builtin -fomit-frame-pointer -O2 -c
+FLAGSC         = -m32 -ffreestanding -fno-common -nostdlib -masm=intel -fno-builtin -fomit-frame-pointer -O2 -c
+LD          = ld -Ttext 0x100000 -T linkerscript -melf_i386 --oformat elf32-i386 -o
+
+#サフィックス
+.S.o:
+       ${CC} ${INCLUDES} ${FLAGS} $<
+.c.o:
+       ${CC} ${INCLUDES} ${FLAGSC} $<
+       
+#ソースコード
+BOOT_C=boot.c
+BOOT_S=load.S
+VANE_S=Vane.S
+KEYBOARD_C=KeyBoard.c
+GDT_IDT_C=GDT_IDT.c
+INTERRUPT_C=Interrupt.c
+STDIO_C=stdio.c
+STRING_C=string.c
+ASM_INTERRUPT_S=ASM_Interrupt.S
+SCANCODE_C=scancode.c
+MEMMAN_C=memory.c
+FAT_C=FAT.c
+GRAPHIC_C=Graphical.c
+SYSTEM_C=System.c
+MESSAGE_C=Message.c
+TIMER_C=timer.c
+TASK_C=task.c
+
+#オブジェクト
+BOOT_OBJ=${BOOT_S:.S=.o} ${BOOT_C:.c=.o} ${VANE_S:.S=.o} ${KEYBOARD_C:.c=.o} ${STDIO_C:.c=.o} ${GDT_IDT_C:.c=.o} ${INTERRUPT_C:.c=.o} ${STRING_C:.c=.o} ${ASM_INTERRUPT_S:.S=.o} ${SCANCODE_C:.c=.o} ${MEMMAN_C:.c=.o} ${FAT_C:.c=.o} ${GRAPHIC_C:.c=.o} ${SYSTEM_C:.c=.o} ${MESSAGE_C:.c=.o} ${TIMER_C:.c=.o} ${TASK_C:.c=.o}
+
+kernel: ${BOOT_OBJ}
+       ${LD} ${TARGET} ${BOOT_OBJ}
+
+${BOOT_OBJ}: ${BOOT_SRC}
+clean::
+       -${RM}  -f *~ *.lo *.o make.log *.bak .a.out .core .*.core
+
diff --git a/Kernel/Message.o b/Kernel/Message.o
new file mode 100644 (file)
index 0000000..de7590f
Binary files /dev/null and b/Kernel/Message.o differ
index 05253cc..89b8032 100644 (file)
@@ -86,5 +86,5 @@ void printtime(void)
 {
     unsigned char s[24], t[7];
     readrtc(t);
-    printf("\r%X%X/%X/%X %X:%X:%X", t[6], t[5], t[4], t[3], t[2], t[1], t[0]);
+    printf("%X%X/%X/%X %X:%X:%X", t[6], t[5], t[4], t[3], t[2], t[1], t[0]);
 }
diff --git a/Kernel/System.c~ b/Kernel/System.c~
new file mode 100644 (file)
index 0000000..89b8032
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+*System Functions
+*(C) 2014 VOSystems.
+*/
+#include <stdio.h>
+
+int vram_start_address;
+char vmode;
+short scrnX,scrnY;
+void init_qemuvga0(int x, int y, int c, int flag);
+/*int Check_VESA(void)
+{
+       in_virtual86mode();
+       if(VESA_Check()==0){
+               out_virtual86mode();
+               return 0;
+       }else{
+               out_virtual86mode();
+               return 1;
+       }
+}
+
+void ScreenVGA_Graphic(void)
+{/*
+       in_virtual86mode();
+       scrn320();
+       out_virtual86mode();
+       vram_start_address=0x000a0000;
+       scrnX=320;
+       scrnY=200;
+       init_qemuvga0(1024,600,32,0x41);
+}*/
+
+void set_qemuvga0reg(int reg, int dat)
+{
+    io_out16(0x01ce, reg);
+    io_out16(0x01cf, dat);
+    return;
+}
+
+void init_qemuvga0(int x, int y, int c, int flag)
+{
+    set_qemuvga0reg(0x0004, 0x0000);
+    set_qemuvga0reg(0x0001, x);
+    set_qemuvga0reg(0x0002, y);
+    set_qemuvga0reg(0x0003, c); /* 4, 8, 15, 16, 24, 32 */
+    set_qemuvga0reg(0x0005, 0x0000);
+    set_qemuvga0reg(0x0004, flag); /* リニアアクセスモードでVRAMの初期化をするなら0x41 */
+        /* bit7 : VRAM初期化抑制, bit6 : リニアアクセスモード, bit0 : 設定有効 */
+    scrnX = x;
+    scrnY = y;
+    vmode = c;
+    if ((flag & 0x40) == 0) {
+        vram_start_address = 0x000a0000;
+    } else {
+        vram_start_address = 0xe0000000;
+    }
+    return;
+}
+
+void readrtc(unsigned char *t)
+{
+    char err;
+    static unsigned char adr[7] = { 0x00, 0x02, 0x04, 0x07, 0x08, 0x09, 0x32 };
+    static unsigned char max[7] = { 0x60, 0x59, 0x23, 0x31, 0x12, 0x99, 0x99 };
+    int i;
+    for (;;) { /* 読み込みが成功するまで繰り返す */
+        err = 0;
+        for (i = 0; i < 7; i++) {
+            io_out8(0x70, adr[i]);
+            t[i] = io_in8(0x71);
+        }
+        for (i = 0; i < 7; i++) {
+            io_out8(0x70, adr[i]);
+            if (t[i] != io_in8(0x71) || (t[i] & 0x0f) > 9 || t[i] > max[i]) {
+                err = 1;
+            }
+        }
+        if (err == 0) {
+            return;
+        }
+    }
+}
+
+void printtime(void)
+{
+    unsigned char s[24], t[7];
+    readrtc(t);
+    printf("%X%X/%X/%X %X:%X:%X", t[6], t[5], t[4], t[3], t[2], t[1], t[0]);
+}
diff --git a/Kernel/System.o b/Kernel/System.o
new file mode 100644 (file)
index 0000000..37af87c
Binary files /dev/null and b/Kernel/System.o differ
diff --git a/Kernel/Vane.o b/Kernel/Vane.o
new file mode 100644 (file)
index 0000000..a141c3b
Binary files /dev/null and b/Kernel/Vane.o differ
index a50411f..a43aa85 100644 (file)
@@ -63,6 +63,7 @@ void cstart(unsigned long magic, unsigned long addr)
        printf("VOSystems Console Host [Version 0.1(build 10)]\n");
        
        /*Setting IDT*/
+       printTASK("Setting IDT.....");
        setupInterruptGate(DEF_IDT_INT_NUM_IRQ1,KeyBoard_Interrupt_asm);//Register Keyboard interrupt handler
        setupInterruptGate(DEF_IDT_INT_NUM_IRQ0,Timer_Interrupt_asm);//Register Timer interrupt handler
        idtr.size       = NUM_IDT * sizeof( GATE_DESCRIPTOR );
@@ -72,6 +73,7 @@ void cstart(unsigned long magic, unsigned long addr)
        printOK("Setting IDT.....");
        
        /*Setting GDT*/
+       printTASK("Setting GDT.....");
        /*set up null descriptor*/
        gdt[NULL_DESCRIPTOR].limitLo    = DEF_GDT_NULL_LIMIT;
        gdt[NULL_DESCRIPTOR].baseLo             = DEF_GDT_NULL_BASELO;
@@ -97,41 +99,49 @@ void cstart(unsigned long magic, unsigned long addr)
        
        load_gdt();
        printOK("Setting GDT.....");
-               
+       
+       printTASK("Init PIC.....");
        initPIC();
        printOK("Init PIC.....");
        
+       printTASK("Init Keyboard.....");
        initKeyboard();
        keyboardEnableKBD();
        printOK("Init Keyboard.....");
        
+       printTASK("Init Messaging Buffer.....");
        msg_init(&kernel,32,kernelbuf);
        printOK("Init Messaging Buffer.....");
        
+       printTASK("Init PIT.....");
        setPitCounter(100,DEF_PIT_COM_COUNTER0,DEF_PIT_COM_MODE_SQUAREWAVE);
        initPit();
        printOK("Init PIT.....");
        
+       printTASK("Starting Memory Manager.....");
        memman_init(memman);
        memman_free(memman,0x00001000,0x0009e000);
        memman_free(memman,0x00400000,((mbi->mem_lower+mbi->mem_upper)*1024)-0x00400000);
        printOK("Starting Memory Manager.....");
        
+       printTASK("Loading Memory Info.....");
        if(magic!=MULTIBOOT_BOOTLOADER_MAGIC){
                printFAIL("Loading Memory Info.....");
                
        }else{
                printOK("Loading Memory Info.....");
-               
+               printINFO("TotalMemory = ");
+               printf("%d MiB\n",(mbi->mem_lower+mbi->mem_upper+1024)/1024);
+               printINFO("Free Memory = ");
+               printf("%d MiB\n",memman_total(memman)/(1024*1024));
        }
-       printf("\n~Memory Information~\nLowMemory = %d KiB , UpperMemory = %d KiB , TotalMemory = %d MiB\n\n",mbi->mem_lower,
-               mbi->mem_upper,(mbi->mem_lower+mbi->mem_upper+1024)/1024);
-       
-       
-       printf("Free Memory = %d MiB\n\n",memman_total(memman)/(1024*1024));
        
+       printf("%X %d\n",0x99,hex2dec_bcd(0x99));
+
        int in=0;
        while(in!='q'){
+               putchar('\r');
+               printINFO("Now Time and Day = ");
                printtime();
                if(kbhit()=='q')break;
                io_hlt();
@@ -143,8 +153,9 @@ void cstart(unsigned long magic, unsigned long addr)
        if(strcmp("time",cmd)==0){
                int in=0;
                while(in!='q'){
+                       putchar('\r');
                        printtime();
-                       if(kbhit()!=0)in=getch();
+                       if(kbhit()=='q')break;
                        io_hlt();
                }
        }
diff --git a/Kernel/boot.c~ b/Kernel/boot.c~
new file mode 100644 (file)
index 0000000..03b08ec
--- /dev/null
@@ -0,0 +1,252 @@
+/*!
+       boot.c
+       Kernel and Setting.
+       (C) 2013-2014 VOSystems.
+*/
+
+/*
+       Vane Operating System
+       Publish under The MIT License
+
+       MIT License
+       http://opensource.org/licenses/mit-license.php
+       Copyright (C) 2013-2014 VOSystems. All rights reserved.
+*/
+
+#include<multiboot.h>
+#include<VaneOS.h>
+#include<GDT_IDT.h>
+#include<KeyBoard.h>
+#include<Interrupt.h>
+#include<stdio.h>
+#include<scancode.h>
+#include<memory.h>
+#include<Graphic.h>
+#include<Message.h>
+#include<timer.h>
+#include<System.h>
+
+/*PROTOTYPE*/
+void outPortByte( unsigned short address, unsigned char value );
+unsigned char inPortByte( unsigned short address );
+void initPIC( void );
+int setPitCounter( int freq, unsigned char counter, unsigned char mode );
+void initPit( void );
+void clear_state(void);
+void hlt(void);
+
+/*!
+       load.S call this function
+       
+       Set All & Call shell
+       (C)2014 VOSystems.
+       create 2014/09/23
+       update 2014/10/15
+       author VOSystems
+*/
+void cstart(unsigned long magic, unsigned long addr)
+{
+       /*Common Settings*/
+       char cmd[100]={0};
+       struct MEMMAN *memman=(struct MEMMAN*)MEMMAN_ADDR;
+       multiboot_info_t *mbi;
+       
+       mbi = (multiboot_info_t *) addr;
+               
+       //ClearScreen();
+       break_flag=0;   system_key_code_flag=0;
+       screen=(unsigned short*)0xb8000;//VRam Setting
+       attr=WHITE;
+       
+       /*Start Set Main Code*/
+       printf("VOSystems Vane Operating System  [Version 0.2(build 300)]\n");
+       printf("VOSystems Console Host [Version 0.1(build 10)]\n");
+       
+       /*Setting IDT*/
+       printTASK("Setting IDT.....");
+       setupInterruptGate(DEF_IDT_INT_NUM_IRQ1,KeyBoard_Interrupt_asm);//Register Keyboard interrupt handler
+       setupInterruptGate(DEF_IDT_INT_NUM_IRQ0,Timer_Interrupt_asm);//Register Timer interrupt handler
+       idtr.size       = NUM_IDT * sizeof( GATE_DESCRIPTOR );
+       idtr.base       = ( GATE_DESCRIPTOR *)idt;
+       
+       load_idt();
+       printOK("Setting IDT.....");
+       
+       /*Setting GDT*/
+       printTASK("Setting GDT.....");
+       /*set up null descriptor*/
+       gdt[NULL_DESCRIPTOR].limitLo    = DEF_GDT_NULL_LIMIT;
+       gdt[NULL_DESCRIPTOR].baseLo             = DEF_GDT_NULL_BASELO;
+       gdt[NULL_DESCRIPTOR].baseMid    = DEF_GDT_NULL_BASEMID;
+       gdt[NULL_DESCRIPTOR].flags              = DEF_GDT_NULL_FLAGS;
+       gdt[NULL_DESCRIPTOR].baseHi             = DEF_GDT_NULL_BASEHI;
+       /* set up code descriptor */
+       gdt[CODE_DESCRIPTOR].limitLo    = DEF_GDT_CODE_LIMIT;
+       gdt[CODE_DESCRIPTOR].baseLo             = DEF_GDT_CODE_BASELO;
+       gdt[CODE_DESCRIPTOR].baseMid    = DEF_GDT_CODE_BASEMID;
+       gdt[CODE_DESCRIPTOR].flags              = DEF_GDT_CODE_FLAGS;
+       gdt[CODE_DESCRIPTOR].baseHi             = DEF_GDT_CODE_BASEHI;
+
+       /* set up data descriptor */
+       gdt[DATA_DESCRIPTOR].limitLo    = DEF_GDT_DATA_LIMIT;
+       gdt[DATA_DESCRIPTOR].baseLo             = DEF_GDT_DATA_BASELO;
+       gdt[DATA_DESCRIPTOR].baseMid    = DEF_GDT_DATA_BASEMID;
+       gdt[DATA_DESCRIPTOR].flags              = DEF_GDT_DATA_FLAGS;
+       gdt[DATA_DESCRIPTOR].baseHi             = DEF_GDT_DATA_BASEHI;
+       
+       gdtr.size       = NUM_GDT * sizeof( SEGMENT_DESCRIPTOR );
+       gdtr.base       = ( SEGMENT_DESCRIPTOR *)gdt;
+       
+       load_gdt();
+       printOK("Setting GDT.....");
+       
+       printTASK("Init PIC.....");
+       initPIC();
+       printOK("Init PIC.....");
+       
+       printTASK("Init Keyboard.....");
+       initKeyboard();
+       keyboardEnableKBD();
+       printOK("Init Keyboard.....");
+       
+       printTASK("Init Messaging Buffer.....");
+       msg_init(&kernel,32,kernelbuf);
+       printOK("Init Messaging Buffer.....");
+       
+       printTASK("Init PIT.....");
+       setPitCounter(100,DEF_PIT_COM_COUNTER0,DEF_PIT_COM_MODE_SQUAREWAVE);
+       initPit();
+       printOK("Init PIT.....");
+       
+       printTASK("Starting Memory Manager.....");
+       memman_init(memman);
+       memman_free(memman,0x00001000,0x0009e000);
+       memman_free(memman,0x00400000,((mbi->mem_lower+mbi->mem_upper)*1024)-0x00400000);
+       printOK("Starting Memory Manager.....");
+       
+       printTASK("Loading Memory Info.....");
+       if(magic!=MULTIBOOT_BOOTLOADER_MAGIC){
+               printFAIL("Loading Memory Info.....");
+               
+       }else{
+               printOK("Loading Memory Info.....");
+               printINFO("TotalMemory = ");
+               printf("%d MiB\n",(mbi->mem_lower+mbi->mem_upper+1024)/1024);
+               printINFO("Free Memory = ");
+               printf("%d MiB\n",memman_total(memman)/(1024*1024));
+       }
+       
+       printf("%X %d\n",0x12,hex2dec_bcd(0x12));
+
+       int in=0;
+       while(in!='q'){
+               putchar('\r');
+               printINFO("Now Time and Day = ");
+               printtime();
+               if(kbhit()=='q')break;
+               io_hlt();
+       }
+       putchar('\n');
+       
+       puts("KernelShell/Root/>");
+       scanf("%s",&cmd);
+       if(strcmp("time",cmd)==0){
+               int in=0;
+               while(in!='q'){
+                       putchar('\r');
+                       printtime();
+                       if(kbhit()=='q')break;
+                       io_hlt();
+               }
+       }
+       printf("%d %d %d",strcmp("time",cmd),strcmp("time\0",cmd),strcmp("time\n",cmd));
+       while(1)io_hlt();
+       return;
+}
+
+void outPortByte( unsigned short address, unsigned char value )
+{
+       __asm__ __volatile__( "out %%dx, %%al" : : "d"(address), "a"(value) );
+}
+
+unsigned char inPortByte( unsigned short address )
+{
+       unsigned char data;
+
+       __asm__ __volatile__( "mov %%dx, %%ax" : : "a"(address) );
+       __asm__ __volatile__( "in %al, %dx" );
+       __asm__ __volatile__( "mov %%bl, %%al" : "=b"(data) );
+       return( data );
+}
+
+void initPIC( void )
+{
+       disable();
+       
+       outPortByte( PORT_MASTER_PIC_COMMAND,   PIC_ICW1        );
+       outPortByte( PORT_SLAVE_PIC_COMMAND,    PIC_ICW1        );
+
+       outPortByte( PORT_MASTER_PIC_DATA,      PIC_MASTER_ICW2 );
+       outPortByte( PORT_SLAVE_PIC_DATA,       PIC_SLAVE_ICW2  );
+
+       outPortByte( PORT_MASTER_PIC_DATA,      PIC_MASTER_ICW3 );
+       outPortByte( PORT_SLAVE_PIC_DATA,       PIC_SLAVE_ICW3  );
+
+       outPortByte( PORT_MASTER_PIC_DATA,      PIC_MASTER_ICW4 );
+       outPortByte( PORT_SLAVE_PIC_DATA,       PIC_SLAVE_ICW4  );
+       
+       outPortByte( PORT_MASTER_PIC_IMR, (~PIC_IMR_MASK_IRQ0) & (~PIC_IMR_MASK_IRQ2 )  );
+       outPortByte( PORT_SLAVE_PIC_IMR, PIC_IMR_MASK_IRQ_ALL                           );
+       
+    outPortByte( PORT_MASTER_PIC_IMR, ( ~PIC_IMR_MASK_IRQ0 )
+                 & ( ~PIC_IMR_MASK_IRQ1 ) & ( ~PIC_IMR_MASK_IRQ2 ) );
+    outPortByte( PORT_SLAVE_PIC_IMR, PIC_IMR_MASK_IRQ_ALL          );
+    
+    enable();
+}
+
+int setPitCounter( int freq, unsigned char counter, unsigned char mode )
+{
+       unsigned short  count;
+       unsigned char   command;
+
+       /* --------------------------------------------------------------------- */
+       /*      calculate frequency                                              */
+       /* --------------------------------------------------------------------- */
+       count = ( unsigned short )( DEF_PIT_CLOCK / freq );
+
+       /* --------------------------------------------------------------------- */
+       /*      make initial command                                             */
+       /* --------------------------------------------------------------------- */
+       command = mode | DEF_PIT_COM_RL_DATA | counter;
+
+       outPortByte( PIT_REG_CONTROL, command );
+
+       /* --------------------------------------------------------------------- */
+       /*      send counter value                                               */
+       /* --------------------------------------------------------------------- */
+       outPortByte( PIT_REG_COUNTER0, ( unsigned char )( count & 0xFF          ) );
+       outPortByte( PIT_REG_COUNTER0, ( unsigned char )( ( count >> 8 ) & 0xFF ) );
+}
+
+/*
+       Funtion     :initPit
+       Input       :void
+       Output      :void
+       Return      :void 
+
+       Description :initialize pic
+*/
+void initPit( void )
+{
+       /* --------------------------------------------------------------------- */
+       /*      set counter0 100Hz                                               */
+       /* --------------------------------------------------------------------- */
+       setPitCounter( 100, DEF_PIT_COM_COUNTER0,  DEF_PIT_COM_MODE_SQUAREWAVE );
+       timer.count=0;
+       int i;
+       for(i=0;i<MAX_TIMER;i++)
+       {
+               timer.timers[i]->flags=0;
+       }
+}
diff --git a/Kernel/boot.o b/Kernel/boot.o
new file mode 100644 (file)
index 0000000..4bf4bb4
Binary files /dev/null and b/Kernel/boot.o differ
diff --git a/Kernel/load.o b/Kernel/load.o
new file mode 100644 (file)
index 0000000..dc385b1
Binary files /dev/null and b/Kernel/load.o differ
diff --git a/Kernel/memory.o b/Kernel/memory.o
new file mode 100644 (file)
index 0000000..9e13e86
Binary files /dev/null and b/Kernel/memory.o differ
diff --git a/Kernel/scancode.o b/Kernel/scancode.o
new file mode 100644 (file)
index 0000000..a7c8699
Binary files /dev/null and b/Kernel/scancode.o differ
index a96e38f..d914258 100644 (file)
@@ -213,67 +213,74 @@ void putchar(const char ch)
        return;
 }
 
-void printOK(const char* msg)
+void printTASK(const char* msg)
 {
+       puts("[....]");
        attr=WHITE;
        puts(msg);
-       while(X<(80-6))/*80 charactors - [ OK ]*/
-       {
-               puts(" ");
-       }
+       return;
+}
+
+void printOK(const char* msg)
+{
+       putchar('\r');
+       attr=WHITE;
        puts("[ ");
        attr=GREEN;
-       puts("OK");
+       puts("ok");
+       attr=WHITE;
+       puts(" ]");
+
        attr=WHITE;
-       puts(" ]\n");
+       puts(msg);
+       puts("done.\n");
        return;
 }
 
 void printFAIL(const char* msg)
 {
+       putchar('\r');
        attr=WHITE;
-       puts(msg);
-       while(X<(80-6))/*80 charactors - [ OK ]*/
-       {
-               puts(" ");
-       }
        puts("[");
        attr=RED;
-       puts("FAIL");
+       puts("fail");
        attr=WHITE;
-       puts("]\n");
+       puts("]");
+
+       attr=WHITE;
+       puts(msg);
+       puts("\n");
        return;
 }
 
 void printWARN(const char* msg)
 {
+       putchar('\r');
        attr=WHITE;
-       puts(msg);
-       while(X<(80-6))/*80 charactors - [ OK ]*/
-       {
-               puts(" ");
-       }
        puts("[");
        attr=YELLOW;
-       puts("WARN");
+       puts("warn");
+       attr=YELLOW;
+       puts("]");
+
        attr=WHITE;
-       puts("]\n");
+       puts(msg);
+       puts("done.\n");
        return;
 }
 
 void printINFO(const char* msg)
 {
+       putchar('\r');
        attr=WHITE;
-       puts(msg);
-       while(X<(80-6))/*80 charactors - [ OK ]*/
-       {
-               puts(" ");
-       }
        puts("[");
        attr=CH_BLUE;
-       puts("WARN");
+       puts("info");
        attr=WHITE;
-       puts("]\n");
+       puts("]");
+
+       attr=WHITE;
+       puts(msg);
        return;
 }
 
diff --git a/Kernel/stdio.c~ b/Kernel/stdio.c~
new file mode 100644 (file)
index 0000000..51d6aae
--- /dev/null
@@ -0,0 +1,373 @@
+/*
+*stdio for Charactor Shell
+*(C) 2014 VOSystems.
+*/
+
+#include<stdio.h>
+#include<string.h>
+#include<KeyBoard.h>
+#include<scancode.h>
+#include<stdarg.h>
+/*
+COLOR
+
+BRACK, BLUE, GREEN, CIAN, RED, MASENTA
+BRAWN, GLAY, D_GLAY, CH_BLUE, CH_GREE
+CH_CIAN, PINK, CH_MAS, YELLOW, WHITE
+*/
+
+#define COLUMNS (80)
+#define LINES (24)
+#define ATTRIBUTE (7)
+
+int asm_move_cursol(int ebp);
+
+unsigned short* screen;
+char attr;
+unsigned int X,Y;
+
+int kbhit(void)
+{
+       return Generate_Scancode_To_ASCII_Code();
+}
+void scanf(const char* fmt,...)
+{
+       va_list arg;
+       va_start(arg,char*,fmt);
+       char ch=*fmt++;
+       unsigned int count=0;
+       
+       while(ch!='\0'){
+       
+               if(ch=='%'){
+                       ch=*fmt++;
+                       
+                       if(ch=='d'){
+                               int buf=0;      char chbuf=0;
+                               count=0;
+                               while(1){
+                                       chbuf=getch();
+                                       buf*=10;
+                                       
+                                       if(chbuf=='1'){
+                                               buf+=1;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='2'){
+                                               buf+=2;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='3'){
+                                               buf+=3;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='4'){
+                                               buf+=4;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='5'){
+                                               buf+=5;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='6'){
+                                               buf+=6;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='7'){
+                                               buf+=7;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='8'){
+                                               buf+=8;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='9'){
+                                               buf+=9;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='0'){
+                                               buf+=0;
+                                               putchar(chbuf);
+                                               ++count;
+                                       }else if(chbuf=='\b' && count>=0){
+                                               buf/=10;
+                                               putchar(chbuf);
+                                               --count;
+                                       }else{
+                                               buf/=10;
+                                               va_arg(arg,int)=buf;
+                                               break;
+                                       }
+                               }
+                       }else if(ch=='s'){
+                               char *cmd;      cmd=va_arg(arg,char*);
+                               count=0;
+                               do{
+                                       *cmd=getch();
+                                       if(*cmd=='\n'){
+                                               putchar(*cmd);
+                                               *cmd='\0';
+                                               break;
+                                               
+                                       }else if(*cmd==' '){
+                                               putchar(' ');
+                                               *cmd='\0';
+                                               break;
+                                               
+                                       }else if(*cmd=='\b' && count>0){
+                                               *cmd-- = '\0';
+                                               count--;
+                                               putchar('\b');
+                                               
+                                       }else{
+                                               putchar(*cmd);
+                                               count++;
+                                               cmd++;
+                                               
+                                       }
+                               }while(1);
+                       
+                       }else if(ch=='c'){
+                               va_arg(arg,char)=getchar();
+                       }
+               }
+               ch=*fmt++;
+       }
+}
+
+char getchar(void)
+{
+       char code=0;
+       while(code==0)
+       {
+               code=Generate_Scancode_To_ASCII_Code();
+       }
+       putchar(code);
+       return code;
+}
+
+char getch(void)
+{
+       char code=0;
+       while(code==0)
+       {
+               code=Generate_Scancode_To_ASCII_Code();
+       }
+       return code;
+}
+
+void ClearScreen(void)
+{
+       screen=(unsigned short*)0xb8000;
+       X=0;Y=0;
+       while(screen<(unsigned short*)0xc0000)
+       {
+               *screen++ =NUM_NULL;
+       }
+       screen=(unsigned short*)0xb8000;
+       return;
+}
+
+void puts(const char* msg)
+{
+       
+       char ch;
+       ch=*msg++;
+       
+       while(ch!='\0')
+       {
+               putchar(ch);
+               ch=*msg++;
+       }
+       return;
+}
+
+void putchar(const char ch)
+{
+       if(ch=='\n'){
+               screen+=(80-X);/*80 charactors * 2byte - X charactors * 2 byte*/
+               Y+=1;
+               X=0;
+               
+       }else if(ch=='\t'){
+               *screen++ = (((attr)<<8) | ' ');
+               *screen++ = (((attr)<<8) | ' ');
+               X+=2;
+               
+       }else if(ch=='\r'){
+               while(X>0)
+               {
+                       *screen-- = (unsigned short)NUM_NULL;
+                       --X;
+               }
+       
+       }else if(ch=='\b'){
+               screen--;
+               *screen = (unsigned short)NUM_NULL;
+               --X;
+               
+       }else{
+               *screen++ = (((attr)<<8) | ch);
+               X+=1;
+       }
+       return;
+}
+
+void printTASK(const char* msg)
+{
+       puts("[....]");
+       attr=WHITE;
+       puts(msg);
+       return;
+}
+
+void printOK(const char* msg)
+{
+       putchar('\r');
+       attr=WHITE;
+       puts("[ ");
+       attr=GREEN;
+       puts("ok");
+       attr=WHITE;
+       puts(" ]");
+
+       attr=WHITE;
+       puts(msg);
+       puts("done.\n");
+       return;
+}
+
+void printFAIL(const char* msg)
+{
+       putchar('\r');
+       attr=WHITE;
+       puts("[");
+       attr=RED;
+       puts("fail");
+       attr=WHITE;
+       puts("]");
+
+       attr=WHITE;
+       puts(msg);
+       puts("done.\n");
+       return;
+}
+
+void printWARN(const char* msg)
+{
+       putchar('\r');
+       attr=WHITE;
+       puts("[");
+       attr=YELLOW;
+       puts("warn");
+       attr=YELLOW;
+       puts("]");
+
+       attr=WHITE;
+       puts(msg);
+       puts("done.\n");
+       return;
+}
+
+void printINFO(const char* msg)
+{
+       putchar('\r');
+       attr=WHITE;
+       puts("[");
+       attr=CH_BLUE;
+       puts("info");
+       attr=WHITE;
+       puts("]");
+
+       attr=WHITE;
+       puts(msg);
+       return;
+}
+
+char * uint_to_str_big_hex(char *buf, unsigned src, int base) {
+  char *p = buf;
+  char *p1, *p2;
+
+  do {
+    *p++ = "0123456789ABCDEF"[src%base];
+  } while(src /= base);
+
+  // Terminate BUF
+  *p = 0;
+
+  // Reverse BUF
+  for(p1=buf, p2=p-1; p1 < p2; p1++, p2--) {
+    char tmp = *p1;
+    *p1 = *p2;
+    *p2 = tmp;
+  }
+
+  return buf;
+}
+
+char * uint_to_str_small_hex(char *buf, unsigned src, int base) {
+  char *p = buf;
+  char *p1, *p2;
+
+  do {
+    *p++ = "0123456789abcdef"[src%base];
+  } while(src /= base);
+
+  // Terminate BUF
+  *p = 0;
+
+  // Reverse BUF
+  for(p1=buf, p2=p-1; p1 < p2; p1++, p2--) {
+    char tmp = *p1;
+    *p1 = *p2;
+    *p2 = tmp;
+  }
+
+  return buf;
+}
+
+void printf(char* fmt, ...)
+{
+       char **arg = (char **) &fmt;
+       char c;
+       arg++;
+
+       while((c = *fmt++) != 0) {
+               if(c != '%'){
+                       putchar(c);
+                       
+               }else{
+                       char buf[64];
+                       char *p;
+                       c = *fmt++;
+                       
+                       if(c=='d'){
+                               // if value is minus, put '-' in the head
+                               if( 0 > *((int *) arg) ) {
+                                       putchar('-');
+                                       *((int *) arg) *= -1;
+                               }
+                               p = uint_to_str_small_hex(buf, *((unsigned *) arg++), 10);
+                               puts(p);
+        
+                       }else if(c=='x'){
+                               p = uint_to_str_small_hex(buf, *((unsigned *) arg++), 16);
+                               puts(p);
+               
+               }else if(c=='X'){
+                       p = uint_to_str_big_hex(buf, *((unsigned *) arg++), 16);
+                               puts(p);
+               
+                       }else if(c=='s'){
+                               p = *arg++;
+                               puts(p);
+               }else if(c=='c'){
+                       p=*arg++;
+                       char send=*p;
+                       putchar(send);
+                       }else{
+                               putchar(c);
+               }       
+               }
+       }
+}
diff --git a/Kernel/stdio.o b/Kernel/stdio.o
new file mode 100644 (file)
index 0000000..9fe7055
Binary files /dev/null and b/Kernel/stdio.o differ
diff --git a/Kernel/string.c~ b/Kernel/string.c~
new file mode 100644 (file)
index 0000000..a3d79e2
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+
+*/
+#include<string.h>
+/*
+int strcmp(const char* ch1,const char* ch2)
+{
+       while(*ch1==*ch2)
+       {
+               if(*ch1=='\0' && *ch2=='\0'){
+                       return 0;
+               
+               }else if((*ch1=='\0' || *ch2=='\0') && (*ch1!=*ch2)){
+                       break;
+                       
+               }
+               ++ch1;  ++ch2;
+       }
+       return 1;
+}
+*//*
+int strcmp(const char *s1, const char *s2)
+{
+  register const unsigned char *ss1, *ss2;
+  for (ss1 = (const unsigned char*)s1, ss2 = (const unsigned char*)s2; *ss1 == *ss2 && *ss1 != '\0'; ss1++, ss2++);
+  return *ss1 - *ss2;
+}
+*/
+int strcmp(const char *s1, const char *s2)
+{
+       while (*s1 == *s2++)
+       {
+               if (*s1++ == 0)
+               {
+                       return (0);
+               }
+       }
+       return (*(unsigned char *)s1 - *(unsigned char *)--s2);
+}
+
+void strcpy(char* copy,const char* source)
+{
+       while(*source!='\0')
+       {
+               *copy=*source;
+               ++copy; ++source;
+       }
+       *copy='\0';
+       return;
+}
diff --git a/Kernel/string.o b/Kernel/string.o
new file mode 100644 (file)
index 0000000..4ae00b0
Binary files /dev/null and b/Kernel/string.o differ
diff --git a/Kernel/task.o b/Kernel/task.o
new file mode 100644 (file)
index 0000000..fbaf0b5
Binary files /dev/null and b/Kernel/task.o differ
diff --git a/Kernel/time.c b/Kernel/time.c
new file mode 100644 (file)
index 0000000..ae620e3
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+*time lib c functions
+*(C) 2014 VOSystems.
+*/
+
+#include<time.h>
+#include<stdio.h>
+/*
+struct tm* localtime(time_t* timer)
+{
+       struct tm* local;
+       
+}*/
+
+inline int hex2dec_bcd(int hex)
+{
+       int i,m,n=0;
+       m=hex/16;
+       if(0x0<=m && m<=0x9){
+               n+=m*10;
+       
+       }else{
+               n+=0;
+               
+       }
+       m=hex-(m*16);
+       if(0x0<=m && m<=0x9){
+               n+=m;
+       
+       }else{
+               n+=0;
+               
+       }
+       return n;
+       /*
+       int i,m,n;
+       n=hex;
+       m=0;
+       for(i=0xFFFF;i>0;i/=16)
+       {
+               m+=n/i;
+               n-=m*i;
+               m*=10;
+       }
+       return m;*/
+}
diff --git a/Kernel/time.c~ b/Kernel/time.c~
new file mode 100644 (file)
index 0000000..ba62303
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+*time lib c functions
+*(C) 2014 VOSystems.
+*/
+
+#include<time.h>
+#include<stdio.h>
+/*
+struct tm* localtime(time_t* timer)
+{
+       struct tm* local;
+       
+}*/
+
+inline int hex2dec_bcd(int hex)
+{
+       int i,m,n=0;
+       m=hex/16;
+       if(0x0<=m && m<=0x9){
+               n+=m*10;
+       
+       }else{
+               n+=0;
+               
+       }
+       m=hex-m;
+       if(0x0<=m && m<=0x9){
+               n+=m;
+       
+       }else{
+               n+=0;
+               
+       }
+       return n;
+       /*
+       int i,m,n;
+       n=hex;
+       m=0;
+       for(i=0xFFFF;i>0;i/=16)
+       {
+               m+=n/i;
+               n-=m*i;
+               m*=10;
+       }
+       return m;*/
+}
diff --git a/Kernel/time.o b/Kernel/time.o
new file mode 100644 (file)
index 0000000..fc19ecb
Binary files /dev/null and b/Kernel/time.o differ
diff --git a/Kernel/timer.o b/Kernel/timer.o
new file mode 100644 (file)
index 0000000..dcc1aa4
Binary files /dev/null and b/Kernel/timer.o differ
index cc25290..202b55b 100755 (executable)
Binary files a/bin/Kernel.vsb and b/bin/Kernel.vsb differ
diff --git a/include/System.h b/include/System.h
new file mode 100644 (file)
index 0000000..9f1a553
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+*System Functions
+*(C) 2014 VOSystems.
+*/
+
+#ifndef _SYSTEM_H_VANE_
+#define _SYSTEM_H_VANE_
+
+extern int vram_start_address;
+extern char vmode;
+extern short scrnX,scrnY;
+
+void init_qemuvga0(int x, int y, int c, int flag);
+void set_qemuvga0reg(int reg, int dat);
+void init_qemuvga0(int x, int y, int c, int flag);
+void readrtc(unsigned char *t);
+void printtime(void);
+
+#endif
diff --git a/include/System.h~ b/include/System.h~
new file mode 100644 (file)
index 0000000..e69de29
index 27b8e76..8845d9e 100644 (file)
@@ -47,5 +47,6 @@ void puts(const char* msg);
 void putchar(const char);
 void printOK(const char* msg);
 int kbhit(void);
+void printTASK(const char* msg);
 
 #endif
index 6910194..27b8e76 100644 (file)
@@ -46,5 +46,6 @@ void ClearScreen(void);
 void puts(const char* msg);
 void putchar(const char);
 void printOK(const char* msg);
+int kbhit(void);
 
 #endif
diff --git a/include/time.h b/include/time.h
new file mode 100644 (file)
index 0000000..1109cda
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+*lib c time header
+*(C) 2014 VOSystems.
+*/
+
+#ifndef _TIME_H_VANE_
+#define _TIME_H_VANE_
+
+typedef unsigned long long time_t;
+
+struct tm
+{
+       int tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_wday, tm_yday, tm_isdst;
+       unsigned long tm_year;
+};
+
+inline int hex2dec_bcd(int hex);
+
+#endif
diff --git a/include/time.h~ b/include/time.h~
new file mode 100644 (file)
index 0000000..3a49d31
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+*lib c time header
+*(C) 2014 VOSystems.
+*/
+
+#ifndef _TIME_H_VANE_
+#define _TIME_H_VANE_
+
+typedef time_t unsigned long long;
+struct tm
+{
+       int tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_wday, tm_yday, tm_isdst;
+       unsigned long tm_year;
+};
+
+inline int hex2dec_bcd(int hex);
+
+#endif