VaneOSのメインGitリポジトリです。
リビジョン | 544e6725feee98ecb61dd3a50e51aa9d22a4a979 (tree) |
---|---|
日時 | 2014-10-26 12:52:05 |
作者 | ![]() |
コミッター | vosystems |
bug fix & add command
@@ -6,16 +6,32 @@ | ||
6 | 6 | #include<string.h> |
7 | 7 | |
8 | 8 | struct EnvVarCommon env; |
9 | +struct EnvShellCommon eshell; | |
9 | 10 | |
10 | -void set_env(void) | |
11 | +int admin_flag; | |
12 | + | |
13 | +inline void set_shell_env() | |
14 | +{ | |
15 | + strcpy(eshell.SHELL,"Vane Shell"); | |
16 | + eshell.major=0; | |
17 | + eshell.minor=2; | |
18 | + eshell.build=100; | |
19 | + eshell.revision=eshell.build; | |
20 | +} | |
21 | + | |
22 | +inline void set_env(void) | |
11 | 23 | { |
12 | 24 | strcpy(env.OS_NAME,"Vane Operating System"); |
13 | 25 | strcpy(env.PC_NAME,"Vane-Alpha"); |
14 | 26 | strcpy(env.USER_NAME,"Vane"); |
15 | 27 | strcpy(env.LANG,"en-us"); |
16 | - strcpy(env.SHELL,"Vane Shell"); | |
17 | 28 | env.major=0; |
18 | 29 | env.minor=4; |
19 | 30 | env.build=1000; |
20 | 31 | env.revision=env.build; |
32 | + | |
33 | + set_shell_env(); | |
34 | + env.SHELL=&eshell; | |
35 | + | |
36 | + admin_flag=0; | |
21 | 37 | } |
@@ -0,0 +1,10 @@ | ||
1 | +/* | |
2 | +*Graphic mode kernel source. | |
3 | +*(C) 2014 VOSystems. | |
4 | +*/ | |
5 | + | |
6 | +#include<Graphic.h> | |
7 | +#include<stdio.h> | |
8 | +#include<string.h> | |
9 | + | |
10 | + |
@@ -44,9 +44,11 @@ TASK_C=task.c | ||
44 | 44 | TIME_C=time.c |
45 | 45 | SCAN_C=scan.c |
46 | 46 | ENV_C=Env.c |
47 | +TOOLS_C=tools.c | |
48 | +CMD_C=cmd_shell.c | |
47 | 49 | |
48 | 50 | #オブジェクト |
49 | -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} ${ENV_C:.c=.o} | |
51 | +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} ${ENV_C:.c=.o} ${TOOLS_C:.c=.o} ${CMD_C:.c=.o} | |
50 | 52 | |
51 | 53 | kernel: ${BOOT_OBJ} |
52 | 54 | ${LD} ${TARGET} ${BOOT_OBJ} |
@@ -99,7 +99,14 @@ inline void shift_vga_text(void) | ||
99 | 99 | |
100 | 100 | inline void printVersion(void) |
101 | 101 | { |
102 | - printf("Vane Operating System [Version %d.%d(build %d)]\n",env.major, env.minor, env.build); | |
103 | - printf("Vane Shell [Version 0.2(build 100)]\n"); | |
104 | - printf("Copyright (C) 2013-2014 VaneOS Project. All rights reserved.\n"); | |
102 | + printf("%s [Version %d.%d(build %d)]\n",env.OS_NAME, env.major, env.minor, env.build); | |
103 | + printf("%s [Version %d.%d(build %d)]\n",env.SHELL->SHELL, env.SHELL->major, env.SHELL->minor, env.SHELL->build); | |
104 | + printCopyRight(); | |
105 | +} | |
106 | + | |
107 | +inline void printCopyRight(void) | |
108 | +{ | |
109 | + puts("Copyright (C) 2013-2014 VaneOS Project. All rights reserved.\n"); | |
110 | + puts("Copyright (C) 2013-2014 VOSystems. All rights reserved.\n"); | |
111 | + puts("Copyright (C) 2014 odeeen. All rights reserved.\n"); | |
105 | 112 | } |
@@ -117,8 +117,7 @@ VESA_Check: | ||
117 | 117 | RET |
118 | 118 | |
119 | 119 | VESA_640_480_SET: |
120 | - | |
121 | - MOV BX,0x4101 | |
120 | + MOV BX,0x0101 | |
122 | 121 | MOV AX,0x4F02 |
123 | 122 | INT 0x10 |
124 | 123 |
@@ -26,6 +26,7 @@ | ||
26 | 26 | #include<timer.h> |
27 | 27 | #include<System.h> |
28 | 28 | #include<Env.h> |
29 | +#include<tools.h> | |
29 | 30 | |
30 | 31 | /*PROTOTYPE*/ |
31 | 32 | void outPortByte( unsigned short address, unsigned char value ); |
@@ -140,10 +141,11 @@ void cstart(unsigned long magic, unsigned long addr) | ||
140 | 141 | } |
141 | 142 | printINFO("Boot Time and Day = "); |
142 | 143 | printtime(); |
143 | - putchar('\n'); | |
144 | + cr();cr(); | |
145 | + | |
144 | 146 | do{ |
145 | - puts("\nKernelShell/Root/>"); | |
146 | - scan_str(cmd); | |
147 | + ShowPrompt();//puts("\nKernelShell/Root/>"); | |
148 | + scan_str(cmd,sizeof(cmd)/sizeof(cmd[0])); | |
147 | 149 | |
148 | 150 | if(strcmp("time",cmd)==0){ |
149 | 151 | int in=0; |
@@ -154,17 +156,34 @@ void cstart(unsigned long magic, unsigned long addr) | ||
154 | 156 | io_hlt(); |
155 | 157 | io_hlt(); |
156 | 158 | io_hlt(); |
159 | + io_hlt(); | |
160 | + io_hlt(); | |
157 | 161 | } |
162 | + cr(); | |
158 | 163 | |
159 | 164 | }else if(strcmp("vane",cmd)==0){ |
160 | 165 | attr=CH_BLUE; |
161 | 166 | printVersion(); |
162 | 167 | attr=WHITE; |
163 | - | |
168 | + cr();cr(); | |
169 | + | |
170 | + }else if(strcmp("copyright",cmd)==0){ | |
171 | + attr=CH_GREE; | |
172 | + printCopyRight(); | |
173 | + attr=WHITE; | |
174 | + cr(); | |
175 | + | |
176 | + }else if(strcmp("cls",cmd)==0 || strcmp("clear",cmd)==0){ | |
177 | + ClearScreen(); | |
178 | + | |
164 | 179 | }else{ |
180 | + if(strcmp("exit",cmd)==0)break; | |
165 | 181 | printFAIL("Unknown this command"); |
182 | + cr(); | |
183 | + | |
166 | 184 | } |
167 | - }while(strcmp(cmd,"exit")); | |
185 | + //init_char_arrey(cmd,100); | |
186 | + }while(strcmp(cmd,"exit")!=0); | |
168 | 187 | while(1)io_hlt(); |
169 | 188 | return; |
170 | 189 | } |
@@ -0,0 +1,17 @@ | ||
1 | +/* | |
2 | +*command shell kernel | |
3 | +*(C) 2014 VOSystems. | |
4 | +*/ | |
5 | + | |
6 | +#include<stdio.h> | |
7 | +#include<Env.h> | |
8 | + | |
9 | +inline void ShowPrompt(void) | |
10 | +{ | |
11 | + printf("%s@%s: ~",env.USER_NAME, env.PC_NAME); | |
12 | + if(admin_flag==1){ | |
13 | + printf("# "); | |
14 | + }else{ | |
15 | + printf("$ "); | |
16 | + } | |
17 | +} |
@@ -3,6 +3,8 @@ | ||
3 | 3 | *(C) 2014 VOSystems. |
4 | 4 | */ |
5 | 5 | #include<stdio.h> |
6 | +#include<tools.h> | |
7 | +#include<VaneOS.h> | |
6 | 8 | |
7 | 9 | int scan_num(void) |
8 | 10 | { |
@@ -92,16 +94,19 @@ char scan_char(void) | ||
92 | 94 | return scan; |
93 | 95 | } |
94 | 96 | |
95 | -char* scan_str(char* in) | |
97 | +char* scan_str(char* in,size_t lengh) | |
96 | 98 | { |
97 | 99 | char* p=in; |
98 | 100 | char tmp=0; |
99 | 101 | unsigned int count=0; |
100 | 102 | |
103 | + init_char_arrey(in,lengh); | |
104 | + | |
101 | 105 | while(1){ |
102 | 106 | tmp=getch(); |
103 | 107 | if(tmp==' ' || tmp=='\n'){ |
104 | 108 | putchar('\n'); |
109 | + *p='\0'; | |
105 | 110 | break; |
106 | 111 | |
107 | 112 | }else if(tmp=='\b' && count>0){ |
@@ -12,9 +12,11 @@ char Generate_Scancode_To_ASCII_Code(void) | ||
12 | 12 | int scode=msg_get(&kernel)-buf_separate_keyboard;//getmsg(MSG_NUM_KEYBOARD); |
13 | 13 | if(256<=scode && scode<512)return 0; |
14 | 14 | |
15 | + msg_put(&kernel,0x00+buf_separate_keyboard); | |
16 | + | |
15 | 17 | if(scode==SC_LEFT_SHIFT || scode==SC_RIGHT_SHIFT){ |
16 | 18 | shift_flag=1; |
17 | - }else if((shift_flag==1 && scode==BREAK_NORMAL(SC_LEFT_SHIFT)) || (shift_flag==1 && scode==BREAK_NORMAL(SC_LEFT_SHIFT))){ | |
19 | + }else if(shift_flag==1 && (scode==BREAK_NORMAL(SC_LEFT_SHIFT) || scode==BREAK_NORMAL(SC_LEFT_SHIFT))){ | |
18 | 20 | shift_flag=0; |
19 | 21 | } |
20 | 22 |
@@ -413,6 +413,52 @@ char * uint_to_str_small_hex(char *buf, unsigned src, int base) { | ||
413 | 413 | return buf; |
414 | 414 | } |
415 | 415 | |
416 | +void sprintf(char* s,char* fmt, ...) | |
417 | +{ | |
418 | + char **arg = (char **) &fmt; | |
419 | + char c; | |
420 | + arg++; | |
421 | + | |
422 | + while((c = *fmt++) != 0) { | |
423 | + if(c != '%'){ | |
424 | + *s++ = c; | |
425 | + | |
426 | + }else{ | |
427 | + char buf[64]; | |
428 | + char *p; | |
429 | + c = *fmt++; | |
430 | + | |
431 | + if(c=='d'){ | |
432 | + // if value is minus, put '-' in the head | |
433 | + if( 0 > *((int *) arg) ) { | |
434 | + *s++ = '-'; | |
435 | + *((int *) arg) *= -1; | |
436 | + } | |
437 | + p = uint_to_str_small_hex(buf, *((unsigned *) arg++), 10); | |
438 | + strcpy(s,p); | |
439 | + | |
440 | + }else if(c=='x'){ | |
441 | + p = uint_to_str_small_hex(buf, *((unsigned *) arg++), 16); | |
442 | + strcpy(s,p); | |
443 | + | |
444 | + }else if(c=='X'){ | |
445 | + p = uint_to_str_big_hex(buf, *((unsigned *) arg++), 16); | |
446 | + strcpy(s,p); | |
447 | + | |
448 | + }else if(c=='s'){ | |
449 | + p = *arg++; | |
450 | + strcpy(s,p); | |
451 | + }else if(c=='c'){ | |
452 | + p=*arg++; | |
453 | + char send=*p; | |
454 | + *s++ = send; | |
455 | + }else{ | |
456 | + *s++ = c; | |
457 | + } | |
458 | + } | |
459 | + } | |
460 | +} | |
461 | + | |
416 | 462 | void printf(char* fmt, ...) |
417 | 463 | { |
418 | 464 | char **arg = (char **) &fmt; |
@@ -34,12 +34,9 @@ int strcmp(const char *s1, const char *s2) | ||
34 | 34 | return ((*(unsigned char*)s1<*(unsigned char*)s2) ? -1 : +1); |
35 | 35 | } |
36 | 36 | |
37 | -void strcpy(char* copy,const char* source) | |
37 | +char* strcpy(char* copy,const char* source) | |
38 | 38 | { |
39 | - while(*source!='\0') | |
40 | - { | |
41 | - *copy++ =*source++; | |
42 | - } | |
43 | - *copy='\0'; | |
44 | - return; | |
39 | + char* s=copy; | |
40 | + while((*s++ = *source++)!=0); | |
41 | + return copy; | |
45 | 42 | } |
@@ -0,0 +1,12 @@ | ||
1 | +/* | |
2 | +*useful tools | |
3 | +*(C) 2014 VOSystems. | |
4 | +*/ | |
5 | +#include<VaneOS.h> | |
6 | + | |
7 | +void init_char_arrey(char* arrey,size_t lengh) | |
8 | +{ | |
9 | + unsigned int i; | |
10 | + for(i=0;i<lengh;i++)*arrey++ =0; | |
11 | + return; | |
12 | +} |
@@ -6,12 +6,20 @@ | ||
6 | 6 | #ifndef _ENV_H_VANE_ |
7 | 7 | #define _ENV_H_VANE_ |
8 | 8 | |
9 | +struct EnvShellCommon | |
10 | +{ | |
11 | + char SHELL[32]; | |
12 | + unsigned int major, minor, build, revision; | |
13 | +}; | |
14 | + | |
9 | 15 | struct EnvVarCommon |
10 | 16 | { |
11 | - char* OS_NAME, PC_NAME, USER_NAME , LANG, SHELL; | |
17 | + char OS_NAME[32], PC_NAME[32], USER_NAME[32], LANG[6]; | |
12 | 18 | unsigned int major, minor, build, revision; |
19 | + struct EnvShellCommon *SHELL; | |
13 | 20 | }; |
14 | 21 | |
22 | +extern int admin_flag; | |
15 | 23 | extern struct EnvVarCommon env; |
16 | 24 | |
17 | 25 | #endif |
@@ -6,10 +6,17 @@ | ||
6 | 6 | #ifndef _ENV_H_VANE_ |
7 | 7 | #define _ENV_H_VANE_ |
8 | 8 | |
9 | +struct EnvShellCommon | |
10 | +{ | |
11 | + char SHELL[32]; | |
12 | + unsigned int major, minor, build, revision; | |
13 | +}; | |
14 | + | |
9 | 15 | struct EnvVarCommon |
10 | 16 | { |
11 | - char* PC_NAME, OS_NAME, USER_NAME , LANG, SHELL; | |
17 | + char OS_NAME[32], PC_NAME[32], USER_NAME[32], LANG[6]; | |
12 | 18 | unsigned int major, minor, build, revision; |
19 | + struct EnvShellCommon *SHELL; | |
13 | 20 | }; |
14 | 21 | |
15 | 22 | extern struct EnvVarCommon env; |
@@ -15,5 +15,6 @@ void set_qemuvga0reg(int reg, int dat); | ||
15 | 15 | void init_qemuvga0(int x, int y, int c, int flag); |
16 | 16 | void readrtc(unsigned char *t); |
17 | 17 | void printtime(void); |
18 | +void printCopyRight(void); | |
18 | 19 | |
19 | 20 | #endif |
@@ -0,0 +1,19 @@ | ||
1 | +/* | |
2 | +*System Functions | |
3 | +*(C) 2014 VOSystems. | |
4 | +*/ | |
5 | + | |
6 | +#ifndef _SYSTEM_H_VANE_ | |
7 | +#define _SYSTEM_H_VANE_ | |
8 | + | |
9 | +extern int vram_start_address; | |
10 | +extern char vmode; | |
11 | +extern short scrnX,scrnY; | |
12 | + | |
13 | +void init_qemuvga0(int x, int y, int c, int flag); | |
14 | +void set_qemuvga0reg(int reg, int dat); | |
15 | +void init_qemuvga0(int x, int y, int c, int flag); | |
16 | +void readrtc(unsigned char *t); | |
17 | +void printtime(void); | |
18 | + | |
19 | +#endif |
@@ -33,6 +33,8 @@ void init_all(void); | ||
33 | 33 | int getmsg(int msg_num); |
34 | 34 | void sendmsg(int msg,int msg_num); |
35 | 35 | |
36 | +#define cr() putchar('\n'); | |
37 | + | |
36 | 38 | #define COL8_000000 0 |
37 | 39 | #define COL8_FF0000 1 |
38 | 40 | #define COL8_00FF00 2 |
@@ -33,9 +33,6 @@ void init_all(void); | ||
33 | 33 | int getmsg(int msg_num); |
34 | 34 | void sendmsg(int msg,int msg_num); |
35 | 35 | |
36 | -enum VGA_PORTS; | |
37 | -enum CGTC_REGS; | |
38 | - | |
39 | 36 | #define COL8_000000 0 |
40 | 37 | #define COL8_FF0000 1 |
41 | 38 | #define COL8_00FF00 2 |
@@ -0,0 +1,11 @@ | ||
1 | +/* | |
2 | +*cmd shell header. | |
3 | +*(C) 2014 VOSystems. | |
4 | +*/ | |
5 | + | |
6 | +#ifndef _CMD_H_VANE_ | |
7 | +#define _CMD_H_VANE_ | |
8 | + | |
9 | +void ShowPrompt(void); | |
10 | + | |
11 | +#endif |
@@ -41,7 +41,7 @@ extern int kernelbuf[32]; | ||
41 | 41 | #define SC_W 0x11 |
42 | 42 | #define SC_X 0x2d |
43 | 43 | #define SC_Y 0x15 |
44 | -#define SC_Z 0x15 | |
44 | +#define SC_Z 0x2c | |
45 | 45 | |
46 | 46 | #define SC_0 0x0b |
47 | 47 | #define SC_1 0x02 |
@@ -54,7 +54,7 @@ extern int kernelbuf[32]; | ||
54 | 54 | #define SC_8 0x09 |
55 | 55 | #define SC_9 0x0a |
56 | 56 | |
57 | -#define SC_ZEN_HAN_KAKU 0x29 | |
57 | +#define SC_ZEN_HAN_KAKU 0x29 | |
58 | 58 | #define SC_ECOAL 0x0c |
59 | 59 | #define SC_TILDA 0x0d |
60 | 60 | #define SC_YEN 0x7d |
@@ -7,8 +7,8 @@ | ||
7 | 7 | |
8 | 8 | char Generate_Scancode_To_ASCII_Code(void); |
9 | 9 | |
10 | -extern struct msg_data keyboard; | |
11 | -extern int keybuf[32]; | |
10 | +extern struct msg_data kernel; | |
11 | +extern int kernelbuf[32]; | |
12 | 12 | |
13 | 13 | /*Flag Code*/ |
14 | 14 | #define BREAK_FLAG 0xf0 |
@@ -6,6 +6,6 @@ | ||
6 | 6 | #define _STRING_H_VANE_ |
7 | 7 | |
8 | 8 | int strcmp(const char*,const char*); |
9 | -void strcpy(char*,const char*); | |
9 | +char* strcpy(char*,const char*); | |
10 | 10 | |
11 | 11 | #endif |
@@ -0,0 +1,11 @@ | ||
1 | +/* | |
2 | + | |
3 | +*/ | |
4 | + | |
5 | +#ifndef _STRING_H_VANE_ | |
6 | +#define _STRING_H_VANE_ | |
7 | + | |
8 | +int strcmp(const char*,const char*); | |
9 | +void strcpy(char*,const char*); | |
10 | + | |
11 | +#endif |
@@ -0,0 +1,13 @@ | ||
1 | +/* | |
2 | +*useful tools | |
3 | +*(C) 2014 VOSystems. | |
4 | +*/ | |
5 | + | |
6 | +#ifndef _TOOLS_H_VANE_ | |
7 | +#define _TOOLS_H_VANE_ | |
8 | + | |
9 | +#include<VaneOS.h> | |
10 | + | |
11 | +void init_char_arrey(char* arrey,size_t lengh); | |
12 | + | |
13 | +#endif |
@@ -0,0 +1,11 @@ | ||
1 | +/* | |
2 | +*useful tools | |
3 | +*(C) 2014 VOSystems. | |
4 | +*/ | |
5 | + | |
6 | +#ifndef _TOOLS_H_VANE_ | |
7 | +#define _TOOLS_H_VANE_ | |
8 | + | |
9 | +void init_char_arrey(char* arrey,size_t lengh); | |
10 | + | |
11 | +#endif |