VaneOSのメインGitリポジトリです。
リビジョン | 62436ee1fdc39ad977491b910506a13587e5bf79 (tree) |
---|---|
日時 | 2014-10-25 16:44:55 |
作者 | ![]() |
コミッター | vosystems |
add time command
@@ -42,9 +42,10 @@ MESSAGE_C=Message.c | ||
42 | 42 | TIMER_C=timer.c |
43 | 43 | TASK_C=task.c |
44 | 44 | TIME_C=time.c |
45 | +SCAN_C=scan.c | |
45 | 46 | |
46 | 47 | #オブジェクト |
47 | -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} | |
48 | +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} ${SCAN_C:.c=.o} | |
48 | 49 | |
49 | 50 | kernel: ${BOOT_OBJ} |
50 | 51 | ${LD} ${TARGET} ${BOOT_OBJ} |
@@ -1,59 +0,0 @@ | ||
1 | -TARGET = ../bin/Kernel.vsb | |
2 | - | |
3 | -#宣言 | |
4 | -CC = gcc | |
5 | -RM = /bin/rm | |
6 | -MV = /bin/mv | |
7 | -LD = /usr/bin/ld | |
8 | -LN_S = ln -s | |
9 | -AR = /usr/bin/ar | |
10 | -RANLIB = ranlib | |
11 | -INCLUDES = -I../include | |
12 | -LIBVANE = ../lib/libvanec.a ../lib/libvanego.a | |
13 | -FLAGS = -m32 -ffreestanding -fno-common -fno-builtin -fomit-frame-pointer -O2 -c | |
14 | -FLAGSC = -m32 -ffreestanding -fno-common -nostdlib -masm=intel -fno-builtin -fomit-frame-pointer -O2 -c | |
15 | -LD = ld -Ttext 0x100000 -T linkerscript -melf_i386 --oformat elf32-i386 -o | |
16 | -FLAGSDEBUG = -ffreestanding -fno-common -nostdlib -masm=intel -fno-builtin -fomit-frame-pointer -O2 -c | |
17 | -file =boot.c | |
18 | -DEBUG_OBJ=../tmp/debug.o | |
19 | - | |
20 | -#サフィックス | |
21 | -.S.o: | |
22 | - ${CC} ${INCLUDES} ${FLAGS} $< | |
23 | -.c.o: | |
24 | - ${CC} ${INCLUDES} ${FLAGSC} $< | |
25 | - | |
26 | -#ソースコード | |
27 | -BOOT_C=boot.c | |
28 | -BOOT_S=load.S | |
29 | -VANE_S=Vane.S | |
30 | -KEYBOARD_C=KeyBoard.c | |
31 | -GDT_IDT_C=GDT_IDT.c | |
32 | -INTERRUPT_C=Interrupt.c | |
33 | -STDIO_C=stdio.c | |
34 | -STRING_C=string.c | |
35 | -ASM_INTERRUPT_S=ASM_Interrupt.S | |
36 | -SCANCODE_C=scancode.c | |
37 | -MEMMAN_C=memory.c | |
38 | -FAT_C=FAT.c | |
39 | -GRAPHIC_C=Graphical.c | |
40 | -SYSTEM_C=System.c | |
41 | -MESSAGE_C=Message.c | |
42 | -TIMER_C=timer.c | |
43 | -TASK_C=task.c | |
44 | -TIME_C=time.c | |
45 | - | |
46 | -#オブジェクト | |
47 | -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} | |
48 | - | |
49 | -kernel: ${BOOT_OBJ} | |
50 | - ${LD} ${TARGET} ${BOOT_OBJ} | |
51 | - | |
52 | -debug: | |
53 | - @ ${RM} -f ${DEBUG_OBJ} | |
54 | - ${CC} ${INCLUDES} ${FLAGSDEBUG} ${file} | |
55 | - | |
56 | -${BOOT_OBJ}: ${BOOT_SRC} | |
57 | -clean:: | |
58 | - -${RM} -f *~ *.lo *.o make.log *.bak .a.out .core .*.core | |
59 | - |
@@ -54,6 +54,7 @@ void cstart(unsigned long magic, unsigned long addr) | ||
54 | 54 | mbi = (multiboot_info_t *) addr; |
55 | 55 | |
56 | 56 | //ClearScreen(); |
57 | + vga_text_init(); | |
57 | 58 | break_flag=0; system_key_code_flag=0; |
58 | 59 | screen=(unsigned short*)0xb8000;//VRam Setting |
59 | 60 | attr=WHITE; |
@@ -135,31 +136,25 @@ void cstart(unsigned long magic, unsigned long addr) | ||
135 | 136 | printINFO("Free Memory = "); |
136 | 137 | printf("%d MiB\n",memman_total(memman)/(1024*1024)); |
137 | 138 | } |
138 | - | |
139 | - printf("%X %d\n",0x99,hex2dec_bcd(0x99)); | |
140 | - | |
141 | - int in=0; | |
142 | - while(in!='q'){ | |
143 | - putchar('\r'); | |
144 | - printINFO("Now Time and Day = "); | |
145 | - printtime(); | |
146 | - if(kbhit()=='q')break; | |
147 | - io_hlt(); | |
148 | - } | |
139 | + printINFO("Boot Time and Day = "); | |
140 | + printtime(); | |
149 | 141 | putchar('\n'); |
150 | - | |
151 | - puts("KernelShell/Root/>"); | |
152 | - scanf("%s",&cmd); | |
153 | - if(strcmp("time",cmd)==0){ | |
154 | - int in=0; | |
155 | - while(in!='q'){ | |
156 | - putchar('\r'); | |
157 | - printtime(); | |
158 | - if(kbhit()=='q')break; | |
159 | - io_hlt(); | |
142 | + do{ | |
143 | + puts("\nKernelShell/Root/>"); | |
144 | + scan_str(cmd); | |
145 | + | |
146 | + if(strcmp("time",cmd)==0){ | |
147 | + int in=0; | |
148 | + while(in!='q'){ | |
149 | + putchar('\r'); | |
150 | + printtime(); | |
151 | + if(kbhit()=='q')break; | |
152 | + io_hlt(); | |
153 | + io_hlt(); | |
154 | + io_hlt(); | |
155 | + } | |
160 | 156 | } |
161 | - } | |
162 | - printf("%d %d %d",strcmp("time",cmd),strcmp("time\0",cmd),strcmp("time\n",cmd)); | |
157 | + }while(strcmp(cmd,"exit")); | |
163 | 158 | while(1)io_hlt(); |
164 | 159 | return; |
165 | 160 | } |
@@ -0,0 +1,104 @@ | ||
1 | +/* | |
2 | +*scan form keyboard etc... | |
3 | +*(C) 2014 VOSystems. | |
4 | +*/ | |
5 | +#include<stdio.h> | |
6 | + | |
7 | +int scan_num(void) | |
8 | +{ | |
9 | + int scan=0; char tmp=0; | |
10 | + unsigned int count=0; | |
11 | + | |
12 | + while(1){ | |
13 | + tmp=getchar(); | |
14 | + | |
15 | + if(tmp=='0'){ | |
16 | + if(scan!=0){ | |
17 | + tmp*=10; | |
18 | + count++; | |
19 | + } | |
20 | + }else if(tmp=='1'){ | |
21 | + scan+=1; | |
22 | + scan*=10; | |
23 | + count++; | |
24 | + | |
25 | + }else if(tmp=='2'){ | |
26 | + scan+=2; | |
27 | + scan*=10; | |
28 | + count++; | |
29 | + | |
30 | + }else if(tmp=='3'){ | |
31 | + scan+=3; | |
32 | + scan*=10; | |
33 | + count++; | |
34 | + | |
35 | + }else if(tmp=='4'){ | |
36 | + scan+=4; | |
37 | + scan*=10; | |
38 | + count++; | |
39 | + | |
40 | + }else if(tmp=='5'){ | |
41 | + scan+=5; | |
42 | + scan*=10; | |
43 | + count++; | |
44 | + | |
45 | + }else if(tmp=='6'){ | |
46 | + scan+=6; | |
47 | + scan*=10; | |
48 | + count++; | |
49 | + | |
50 | + }else if(tmp=='7'){ | |
51 | + scan+=7; | |
52 | + scan*=10; | |
53 | + count++; | |
54 | + | |
55 | + }else if(tmp=='8'){ | |
56 | + scan+=8; | |
57 | + scan*=10; | |
58 | + count++; | |
59 | + | |
60 | + }else if(tmp=='9'){ | |
61 | + scan+=9; | |
62 | + scan*=10; | |
63 | + count++; | |
64 | + | |
65 | + }else if(tmp=='\b' && count>0){ | |
66 | + scan/=10; | |
67 | + count--; | |
68 | + | |
69 | + }else{ | |
70 | + scan/=10; | |
71 | + break; | |
72 | + } | |
73 | + } | |
74 | + return scan; | |
75 | +} | |
76 | + | |
77 | +char scan_char(void) | |
78 | +{ | |
79 | + char scan=0; | |
80 | + scan=getchar(); | |
81 | + return scan; | |
82 | +} | |
83 | + | |
84 | +char* scan_str(char* in) | |
85 | +{ | |
86 | + char* p=in; | |
87 | + char tmp=0; | |
88 | + unsigned int count=0; | |
89 | + | |
90 | + while(1){ | |
91 | + tmp=getchar(); | |
92 | + if(tmp==' ' || tmp=='\n'){ | |
93 | + break; | |
94 | + | |
95 | + }else if(tmp=='\b' && count>0){ | |
96 | + *p-- ='\0'; | |
97 | + count--; | |
98 | + }else{ | |
99 | + *p++ =tmp; | |
100 | + count++; | |
101 | + } | |
102 | + } | |
103 | + return in; | |
104 | +} |
@@ -8,6 +8,8 @@ | ||
8 | 8 | #include<KeyBoard.h> |
9 | 9 | #include<scancode.h> |
10 | 10 | #include<stdarg.h> |
11 | +#include<VaneOS.h> | |
12 | +#include<scan.h> | |
11 | 13 | /* |
12 | 14 | COLOR |
13 | 15 |
@@ -20,16 +22,84 @@ CH_CIAN, PINK, CH_MAS, YELLOW, WHITE | ||
20 | 22 | #define LINES (24) |
21 | 23 | #define ATTRIBUTE (7) |
22 | 24 | |
25 | +static unsigned int pos; | |
26 | + | |
27 | +enum VGA_PORTS{ | |
28 | + CRTC_ADDR = 0x3D4, | |
29 | + CRTC_DATA = 0x3D5 | |
30 | +}; | |
31 | + | |
32 | +enum CGTC_REGS{ | |
33 | + CRTC_CURSOR_H = 0x0E, | |
34 | + CRTC_CURSOR_L = 0x0F | |
35 | +}; | |
36 | +const unsigned int VGA_REG=0x03d4; | |
23 | 37 | int asm_move_cursol(int ebp); |
24 | 38 | |
25 | 39 | unsigned short* screen; |
26 | 40 | char attr; |
27 | 41 | unsigned int X,Y; |
28 | 42 | |
43 | +static const int COLS = 80; | |
44 | +static const int ROWS = 25; | |
45 | + | |
46 | +void vga_text_init(void) | |
47 | +{ | |
48 | + screen = VGA_ADDR; | |
49 | + | |
50 | + io_out8(CRTC_ADDR, CRTC_CURSOR_H); pos = (io_in8(CRTC_DATA) << 8); | |
51 | + io_out8(CRTC_ADDR, CRTC_CURSOR_L); pos |= (io_in8(CRTC_DATA) << 0); | |
52 | + | |
53 | + vga_text_screen_clear_screen(); | |
54 | + | |
55 | + attr = VGA_DEFAULT_ATTR; | |
56 | +} | |
57 | + | |
58 | +void vga_text_screen_clear_screen(void) | |
59 | +{ | |
60 | + size_t i; | |
61 | + for(i=0; i < COLS*ROWS ; i++) screen[i] = (uint16_t)0x0000; | |
62 | + pos = 0; | |
63 | +} | |
64 | + | |
65 | +void vga_text_update_cursor(void) | |
66 | +{ | |
67 | + pos=(Y*80)+X; | |
68 | + io_out8(CRTC_ADDR, CRTC_CURSOR_H); | |
69 | + io_out8(CRTC_DATA, pos >> 8 ); | |
70 | + io_out8(CRTC_ADDR, CRTC_CURSOR_L); | |
71 | + io_out8(CRTC_DATA, pos & 0xFF ); | |
72 | +} | |
73 | + | |
29 | 74 | int kbhit(void) |
30 | 75 | { |
31 | 76 | return Generate_Scancode_To_ASCII_Code(); |
32 | 77 | } |
78 | +/* | |
79 | +void scanf(const char* fmt,...) | |
80 | +{ | |
81 | + char **arg = (char **) &fmt; | |
82 | + arg++; | |
83 | + char ch=*fmt++; | |
84 | + while(ch!='\0'){ | |
85 | + if(ch!='%'){ | |
86 | + ch=*fmt++; | |
87 | + if(ch=='d'){ | |
88 | + int *p=*arg++; | |
89 | + *p=scan_num(); | |
90 | + | |
91 | + }else if(ch=='c'){ | |
92 | + char* p=*arg++; | |
93 | + *p=scan_char(); | |
94 | + | |
95 | + }else if(ch=='s'){ | |
96 | + char* p=*arg++; | |
97 | + *p=scan_str(*p); | |
98 | + } | |
99 | + } | |
100 | + } | |
101 | +}*/ | |
102 | + | |
33 | 103 | void scanf(const char* fmt,...) |
34 | 104 | { |
35 | 105 | va_list arg; |
@@ -186,6 +256,7 @@ void putchar(const char ch) | ||
186 | 256 | { |
187 | 257 | if(ch=='\n'){ |
188 | 258 | screen+=(80-X);/*80 charactors * 2byte - X charactors * 2 byte*/ |
259 | + pos+=(80-X); | |
189 | 260 | Y+=1; |
190 | 261 | X=0; |
191 | 262 |
@@ -193,23 +264,29 @@ void putchar(const char ch) | ||
193 | 264 | *screen++ = (((attr)<<8) | ' '); |
194 | 265 | *screen++ = (((attr)<<8) | ' '); |
195 | 266 | X+=2; |
267 | + pos+=2; | |
196 | 268 | |
197 | 269 | }else if(ch=='\r'){ |
198 | 270 | while(X>0) |
199 | 271 | { |
200 | 272 | *screen-- = (unsigned short)NUM_NULL; |
201 | 273 | --X; |
274 | + --pos; | |
202 | 275 | } |
203 | 276 | |
204 | 277 | }else if(ch=='\b'){ |
205 | 278 | screen--; |
206 | 279 | *screen = (unsigned short)NUM_NULL; |
207 | 280 | --X; |
281 | + --pos; | |
208 | 282 | |
209 | 283 | }else{ |
210 | 284 | *screen++ = (((attr)<<8) | ch); |
211 | 285 | X+=1; |
286 | + ++pos; | |
212 | 287 | } |
288 | + vga_text_update_cursor(); | |
289 | + | |
213 | 290 | return; |
214 | 291 | } |
215 | 292 |
@@ -28,14 +28,10 @@ int strcmp(const char *s1, const char *s2) | ||
28 | 28 | */ |
29 | 29 | int strcmp(const char *s1, const char *s2) |
30 | 30 | { |
31 | - while (*s1 == *s2++) | |
32 | - { | |
33 | - if (*s1++ == 0) | |
34 | - { | |
35 | - return 0; | |
36 | - } | |
31 | + for(;*s1==*s2; s1++,s2++){ | |
32 | + if(*s1=='\0')return 0; | |
37 | 33 | } |
38 | - return *(unsigned char *)s1 - *(unsigned char *)--s2; | |
34 | + return ((*(unsigned char*)s1<*(unsigned char*)s2) ? -1 : +1); | |
39 | 35 | } |
40 | 36 | |
41 | 37 | void strcpy(char* copy,const char* source) |
@@ -1,5 +0,0 @@ | ||
1 | -int main(void) | |
2 | -{ | |
3 | - printf("") | |
4 | - return 0; | |
5 | -} |
@@ -35,7 +35,7 @@ inline int hex2dec_bcd(int hex) | ||
35 | 35 | return n; |
36 | 36 | } |
37 | 37 | |
38 | -time_t time(time_t* timer) | |
38 | +/*time_t time(time_t* timer) | |
39 | 39 | { |
40 | 40 | if(timer!=NULL) |
41 | 41 | { |
@@ -49,4 +49,4 @@ time_t time(time_t* timer) | ||
49 | 49 | time[i]=hex2dec(gtime[i]); |
50 | 50 | } |
51 | 51 | |
52 | -} | |
52 | +}*/ |
@@ -55,10 +55,16 @@ typedef unsigned char BYTE; | ||
55 | 55 | typedef unsigned short WORD; |
56 | 56 | typedef unsigned long DWORD; |
57 | 57 | |
58 | -typedef unsigned long long u_int8_t; | |
59 | -typedef unsigned int u_int4_t; | |
60 | -typedef unsigned short u_int2_t; | |
61 | -typedef unsigned short u_int1_t; | |
58 | +typedef long long int64_t; | |
59 | +typedef int int32_t; | |
60 | +typedef short int16_t; | |
61 | +typedef char int8_t; | |
62 | + | |
63 | +typedef unsigned long long uint64_t; | |
64 | +typedef unsigned int uint32_t; | |
65 | +typedef unsigned short uint16_t; | |
66 | +typedef unsigned char uint8_t; | |
67 | +typedef unsigned long size_t; | |
62 | 68 | |
63 | 69 | #define ADR_BOOTINFO 0x00000ff0 |
64 | 70 | #define ADR_DISKIMG 0x00100000 |
@@ -58,8 +58,8 @@ typedef unsigned long DWORD; | ||
58 | 58 | typedef unsigned long long u_int8_t; |
59 | 59 | typedef unsigned int u_int4_t; |
60 | 60 | typedef unsigned short u_int2_t; |
61 | -typedef unsigned short u_int1_t; | |
62 | - | |
61 | +typedef unsigned char u_int1_t; | |
62 | +typedef unsigned long size_t; | |
63 | 63 | #define ADR_BOOTINFO 0x00000ff0 |
64 | 64 | #define ADR_DISKIMG 0x00100000 |
65 | 65 | #define FAT_DISK_PLASE 0x00020000 |
@@ -99,23 +99,4 @@ typedef struct | ||
99 | 99 | char fs_type[8]; |
100 | 100 | }bpb_data_t; |
101 | 101 | |
102 | -/* fifo.c *//* | |
103 | -struct TSS32 { | |
104 | - int backlink, esp0, ss0, esp1, ss1, esp2, ss2, cr3; | |
105 | - int eip, eflags, eax, ecx, edx, ebx, esp, ebp, esi, edi; | |
106 | - int es, cs, ss, ds, fs, gs; | |
107 | - int ldtr, iomap; | |
108 | -}; | |
109 | -struct TASK { | |
110 | - int sel, flags; | |
111 | - int level, priority; | |
112 | - struct FIFO32 fifo; | |
113 | - struct TSS32 tss; | |
114 | -}; | |
115 | - | |
116 | -void fifo32_init(struct FIFO32 *fifo, int size, int *buf, struct TASK *task); | |
117 | -int fifo32_put(struct FIFO32 *fifo, int data); | |
118 | -int fifo32_get(struct FIFO32 *fifo); | |
119 | -int fifo32_status(struct FIFO32 *fifo); | |
120 | -*/ | |
121 | 102 | #endif |
@@ -0,0 +1,13 @@ | ||
1 | +/* | |
2 | +*scan form keyboard etc... | |
3 | +*(C) 2014 VOSystems. | |
4 | +*/ | |
5 | + | |
6 | +#ifndef _SCAN_H_VANE_ | |
7 | +#define _SCAN_H_VANE_ | |
8 | + | |
9 | +int scan_num(void); | |
10 | +char scan_char(void); | |
11 | +char* scan_str(char* in); | |
12 | + | |
13 | +#endif |
@@ -5,6 +5,14 @@ extern unsigned short* screen; | ||
5 | 5 | extern char attr; |
6 | 6 | extern unsigned int X,Y; |
7 | 7 | |
8 | +void vga_text_init(void); | |
9 | +void vga_text_screen_clear_screen(void); | |
10 | +void vga_text_updata_cursor(void); | |
11 | + | |
12 | +#define VGA_DEFAULT_ATTR 0x0F | |
13 | + | |
14 | +#define VGA_ADDR 0xb8000 | |
15 | + | |
8 | 16 | #define BRACK 0x00 |
9 | 17 | #define BLUE 0x01 |
10 | 18 | #define GREEN 0x02 |
@@ -5,6 +5,12 @@ extern unsigned short* screen; | ||
5 | 5 | extern char attr; |
6 | 6 | extern unsigned int X,Y; |
7 | 7 | |
8 | +void vga_text_init(void); | |
9 | +void vga_text_screen_clear_screen(void); | |
10 | +void vga_text_updata_cursor(void); | |
11 | + | |
12 | +#define VGA_DEFAULT_ATTR 0x0F | |
13 | + | |
8 | 14 | #define BRACK 0x00 |
9 | 15 | #define BLUE 0x01 |
10 | 16 | #define GREEN 0x02 |
@@ -47,5 +53,6 @@ void puts(const char* msg); | ||
47 | 53 | void putchar(const char); |
48 | 54 | void printOK(const char* msg); |
49 | 55 | int kbhit(void); |
56 | +void printTASK(const char* msg); | |
50 | 57 | |
51 | 58 | #endif |