command help was optimized for all possible screen resolutions; command fdisk support...
[ZeXOS.git] / kernel / core / commands.c
blobbb1903ac6a080635be582a67b36d0096165c6d5e
1 /*
2 * ZeX/OS
3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <build.h>
23 #include <system.h>
24 #include <arch/io.h>
25 #include <string.h>
26 #include <partition.h>
27 #include <env.h>
28 #include <dev.h>
29 #include <vfs.h>
30 #include <fs.h>
31 #include <tty.h>
32 #include <proc.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <net/socket.h>
36 #include <module.h>
37 #include <commands.h>
38 #include <signal.h>
39 #include <smp.h>
40 #include <build.h>
41 #include <config.h>
42 #include <net/if.h>
43 #include <net/net.h>
44 #include <net/ip.h>
45 #include <net/ndp.h>
46 #include <net/tun.h>
47 #include <net/icmp.h>
48 #include <mouse.h>
50 command_t command_list;
51 extern partition_t partition_list;
53 unsigned char test[80];
55 typedef void (*void_fn_void_t)(void);
57 extern task_t task_list;
58 extern vfs_t vfs_list;
59 extern int cstrcmp (char *one, char *two);
60 extern unsigned long file_cache_id;
61 extern task_t *_curr_task;
62 extern module_t *module_load (char *modname);
63 extern unsigned long timer_ticks;
66 char *argparse (char *cmd)
68 unsigned cmd_len = strlen (cmd);
69 unsigned p = 1;
71 while (p < cmd_len) {
72 if (cmd[p] == ' ')
73 return cmd + p + 1;
75 p ++;
78 return "";
81 /*************************************************************\
82 | OMMANDs |
83 \*************************************************************/
86 unsigned command_help (char *command, unsigned len)
88 command_t *ctx;
90 tty_t *tty = currtty;
92 tty_cls (tty);
94 for (ctx = command_list.next; ctx != &command_list; ctx = ctx->next) {
95 printf ("%s : %s\n", ctx->name, ctx->desc);
97 if (tty->screen_y >= (tty_char.y-1)) {
98 if (!vgagui)
99 settextcolor (0, 15);
101 printf ("Press enter to continue");
103 settextcolor (15, 0);
104 printf (" ");
106 /* wait, until enter key is pressed */
107 while (1)
108 if (tty == currtty) {
109 if (getkey () != '\n')
110 schedule ();
111 else
112 break;
113 } else
114 schedule ();
116 tty_cls (tty);
120 return 1;
123 unsigned command_hdd (char *command, unsigned len)
125 #ifdef ARCH_i386
126 int t;
127 int m;
128 int c;
129 int c2;
130 int h;
131 int s;
133 outb (0x70, 0x12);
134 t = inb (0x71);
136 if (t >> 4 == 0)
137 printf ("/dev/hda not installed\n");
138 else {
139 outb (0x70, 0x1b);
140 c = inb (0x71);
141 outb (0x70, 0x1c);
142 c2 = inb (0x71);
143 outb (0x70, 0x1d);
144 h = inb (0x71);
145 outb (0x70, 0x23);
146 s = inb (0x71);
148 printf ("/dev/hda installed - CHS=%d-%d:%d:%d\n", c, c2, h, s);
151 if (t & 0xF == 0)
152 printf ("/dev/hdb not installed\n");
153 else {
154 outb (0x70, 0x24);
155 c = inb (0x71);
156 outb (0x70, 0x25);
157 c2 = inb (0x71);
158 outb (0x70, 0x26);
159 h = inb (0x71);
160 outb (0x70, 0x2c);
161 s = inb (0x71);
163 printf ("/dev/hdb installed - CHS=%d-%d:%d:%d\n", c, c2, h, s);
165 #endif
167 return 1;
170 unsigned command_reboot (char *command, unsigned len)
172 arch_cpu_reset ();
174 while (1);
176 return 1;
179 unsigned command_halt (char *command, unsigned len)
181 arch_cpu_shutdown ();
183 puts ("\nSystem halted\nPlease press power button ..");
185 int_disable ();
187 while(1);
189 return 1;
192 unsigned command_tasks (char *command, unsigned len)
194 puts ("id\tname\tpriority\n");
196 task_t *task;
197 for (task = task_list.next; task != &task_list; task = task->next)
198 printf ("%d\t%s\t%u\n", task->id, task->name, task->priority);
200 return 1;
203 unsigned command_ps (char *command, unsigned len)
205 proc_display ();
207 return 1;
210 unsigned command_uptime (char *command, unsigned len)
212 uptime ();
214 return 1;
217 unsigned command_version (char *command, unsigned len)
219 osinfo ();
221 return 1;
224 unsigned command_debug (char *command, unsigned len)
226 if (!debug) {
227 debug = 1;
228 DPRINT ("developer mode was enabled.");
230 return 1;
233 DPRINT ("developer mode was disabled.");
234 debug = 0;
236 return 1;
239 unsigned command_mount (char *command, unsigned len)
241 strcpy (test, argparse (command));
242 char devname[20];
243 char mountpoint[32];
245 unsigned l = strlen (test);
246 unsigned x = 0;
247 while (x < l) {
248 if (test[x] == ' ')
249 break;
250 x ++;
253 memcpy (devname, test, x);
254 devname[x] = '\0';
255 strcpy (mountpoint, argparse (test));
256 unsigned y = strlen (mountpoint);
258 if (mountpoint[y-1] != '/') {
259 mountpoint[y] = '/';
260 mountpoint[y+1] = '\0';
263 if (x && y) {
264 partition_t *p = partition_find (devname);
266 if (p)
267 mount (p, "", mountpoint);
268 else
269 printf ("ERROR -> partition %s does not exists\n", devname);
270 } else
271 mount_display ();
273 return 1;
276 unsigned command_umount (char *command, unsigned len)
278 char mountpoint[32];
279 strcpy (mountpoint, argparse (command));
281 unsigned y = strlen (mountpoint);
282 unsigned x = 0;
284 if (mountpoint[y-1] != '/') {
285 mountpoint[y] = '/';
286 mountpoint[y+1] = '\0';
289 if (y) {
290 partition_t *partition;
291 for (partition = partition_list.next; partition != &partition_list; partition = partition->next) {
292 if (umount (partition, mountpoint))
293 x ++;
296 if (!x)
297 printf ("ERROR -> directory %s is not mounted\n", mountpoint);
299 if (x > 1)
300 printf ("WARNING -> multiple (%d) umount of %s\n", x, mountpoint);
301 } else
302 return 0;
304 return 1;
307 unsigned command_env (char *command, unsigned len)
309 env_display ();
311 return 1;
314 unsigned command_cd (char *command, unsigned len)
316 strcpy (test, argparse (command));
318 cd (test);
320 return 1;
323 unsigned command_ls (char *command, unsigned len)
325 strcpy (test, argparse (command));
327 ls (test);
329 return 1;
332 unsigned command_cat (char *command, unsigned len)
334 strcpy (test, argparse (command));
336 cat (test);
338 return 1;
341 unsigned command_rm (char *command, unsigned len)
343 strcpy (test, argparse (command));
345 rm (test);
347 return 1;
350 unsigned command_mkdir (char *command, unsigned len)
352 strcpy (test, argparse (command));
354 mkdir (test);
356 return 1;
359 unsigned command_touch (char *command, unsigned len)
361 strcpy (test, argparse (command));
363 touch (test);
365 return 1;
368 unsigned command_exec (char *command, unsigned len)
370 if (!strncmp ("./", command, 2))
371 strcpy (test, command+2);
372 else
373 strcpy (test, argparse (command));
375 unsigned arg_len = strlen (argparse (test));
376 char arg[arg_len+1];
377 strcpy (arg, argparse (test));
378 arg[arg_len] = '\0';
380 unsigned test_len = strlen (test);
382 /* lock current tty keyboard */
383 tty_lock (currtty);
385 /* if there is argument after name, rewrite space character to zero */
386 if (test [test_len-(arg_len+1)] == ' ')
387 test [test_len-(arg_len+1)] = '\0';
388 else
389 test [test_len-arg_len] = '\0';
391 /* read file data from filesystem */
392 int ret = vfs_read (test, strlen (test));
394 if (ret < 0) {
395 printf ("%s: command not found\n", test);
396 DPRINT ("ERROR -> vfs_read () - '%s'\n", test);
397 tty_unlock (currtty);
398 return 0;
401 unsigned bin_len = file_cache_id;
403 unsigned char *bin = (unsigned char *) swmalloc (bin_len);
405 if (!bin) {
406 printf ("ERROR -> out of memory\n");
407 return 0;
410 /* copy image to page aligned memory */
411 memcpy (bin, file_cache, bin_len);
413 bin[file_cache_id] = '\0';
415 unsigned entry, code, data, data_off, bss;
416 int err = exec_elf (bin, &entry, &data, &data_off, &bss);
418 if (err != NULL) {
419 printf ("ERROR -> invalid ELF exec\n");
420 tty_unlock (currtty);
421 return 0;
424 /* create process */
425 proc_t *proc = proc_create (currtty, test, entry);
427 /* check for & character as app parameter */
428 unsigned d = 0;
429 while (d < arg_len) {
430 if (arg[d] == '&') {
431 if (proc_flag_set (proc, PROC_FLAG_DAEMON))
432 printf ("%s: started as daemon\n", test);
434 arg[d] = '\0';
436 if (arg_len > 2 && arg[d-1] == ' ') {
437 arg[d-1] = '\0';
438 arg_len --;
441 arg_len --;
443 break;
445 d ++;
448 if (!proc) {
449 printf ("ERROR -> Invalid process: %s\n", test);
451 tty_unlock (currtty);
453 /* free image of elf-bss section */
454 //flush_elf (bss);
456 /* free program image */
457 //pfree (bin);
458 return 0;
461 /* save process information to structure for later use */
462 proc->start = (unsigned) bin;
463 proc->code = entry;
464 proc->data = data;
465 proc->data_off = data_off;
466 proc->bss = bss;
467 proc->end = (unsigned) (bin + bin_len);
469 file_cache_id = 0;
471 /* well, set argument for out app */
472 proc_arg_set (proc, arg, arg_len);
474 proc_vmem_map (proc);
476 /* Is this process started as daemon ? */
477 /* wait here, until pid != 0*/
478 if (!(proc->flags & PROC_FLAG_DAEMON))
479 while (proc->pid)
480 schedule ();
482 /* enable interrupts */
483 int_enable ();
485 /* unlock tty console - user can write in */
486 tty_unlock (currtty);
488 _curr_task = proc->tty->task; // this is pretty needed for correct return to our tty task
490 if (!(proc->flags & PROC_FLAG_DAEMON)) {
491 if (!proc_done (proc))
492 while (1) // NOTE: heh, this is good stuff :P
493 schedule ();
495 /* free image of elf-bss section */
496 //flush_elf (bss);
498 /* free program image */
499 swfree (bin, bin_len);
502 /* switch to next task */
503 schedule ();
505 return 1;
508 unsigned command_lsdev (char *command, unsigned len)
510 dev_display ();
512 return 1;
515 unsigned command_login (char *command, unsigned len)
517 currtty->user = NULL;
518 currtty->logged = false;
520 settextcolor (7, 0);
521 puts ("login: ");
523 return 1;
526 unsigned command_serialw (char *command, unsigned len)
528 dev_t *dev = dev_find ("/dev/com0");
530 if (dev) {
531 unsigned len = strlen (argparse (command));
532 char data[len+1];
533 memcpy (data, argparse (command), len);
534 data[len] = '\0';
536 dev->handler (DEV_ACT_WRITE, data, len);
538 printf ("serialw: %s\n", data);
541 return 1;
544 unsigned command_serialr (char *command, unsigned len)
546 dev_t *dev = dev_find ("/dev/com0");
548 if (dev) {
549 char data[11];
551 dev->handler (DEV_ACT_READ, data, 1);
553 printf ("serialr: %s\n", data);
556 return 1;
559 unsigned command_fdisk (char *command, unsigned len)
561 char *parm = argparse (command);
563 fdisk (parm, strlen (parm));
565 return 1;
568 unsigned command_hdcat (char *command, unsigned len)
570 tty_lock (currtty);
572 dev_t *dev = (dev_t *) dev_find (argparse (command));
574 if (dev) {
575 partition_t p;
576 p.base_io = 0;
578 switch (dev->devname[7]) {
579 case 'a':
580 p.id = 0;
581 p.base_io = 0x1F0;
582 break;
583 case 'b':
584 p.id = 1;
585 p.base_io = 0x1F0;
586 break;
587 case 'c':
588 p.id = 0;
589 p.base_io = 0x170;
590 break;
591 case 'd':
592 p.id = 1;
593 p.base_io = 0x170;
594 break;
597 int c, d = 0;
598 unsigned char block[512];
600 printf ("dev: %s\n", dev->devname);
602 while (!key_pressed (1)) {
603 if (key_pressed (72) == 1) {
604 printf ("##block: %d\n", d);
605 dev->handler (DEV_ACT_READ, &p, block, "", d);
607 for (c = 0; c < 512; c ++)
608 putch ((unsigned) block[c]);
609 d ++;
612 usleep (5);
614 } else
615 printf ("Please specify block device, example: hdcat /dev/hda\n");
617 tty_unlock (currtty);
619 return 1;
622 unsigned command_free (char *command, unsigned len)
624 util_cmdfree ();
626 return 1;
629 unsigned command_date (char *command, unsigned len)
631 tm *t = rtc_getcurrtime ();
633 printf ("%02u:%02u:%02u, %u.%u.%u\n",
634 t->tm_hour, t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon, t->tm_year);
636 return 1;
640 Tone Frequency (Hz)
641 C 130.8
642 D 146.8
643 E 164.8
644 F 174.6
645 G 196.0
646 A 220.0
647 H 246.9
649 C 261.6
650 D 293.7
651 E 329.6
652 F 349.2
653 G 392.0
654 A 440.0
655 H 493.9
657 C 523.3
658 D 587.3
659 E 659.3
660 F 698.5
661 G 784.0
662 A 880.0
663 H 987.8
665 C 1046.5
666 D 1174.7
667 E 1318.5
668 F 1396.9
669 G 1568.0
670 A 1760.0
671 H 1975.5
674 void play_tone (dev_t *dev, char tone, char type, char time)
676 unsigned t = 2;
678 switch (type) {
679 case '1':
680 t = 1;
681 break;
682 case '2':
683 t = 2;
684 break;
685 case '3':
686 t = 3;
687 break;
688 case '4':
689 t = 4;
690 break;
694 unsigned tt = 1;
696 printf ("play_tone (.., %c, %d, %d);\n", tone, t, tt);
698 switch (tone) {
699 case 'c':
700 dev->handler (DEV_ACT_PLAY, 131*t);
701 break;
702 case 'd':
703 dev->handler (DEV_ACT_PLAY, 147*t);
704 break;
705 case 'e':
706 dev->handler (DEV_ACT_PLAY, 165*t);
707 break;
708 case 'f':
709 dev->handler (DEV_ACT_PLAY, 175*t);
710 break;
711 case 'g':
712 dev->handler (DEV_ACT_PLAY, 196*t);
713 break;
714 case 'a':
715 dev->handler (DEV_ACT_PLAY, 220*t);
716 break;
717 case 'h':
718 dev->handler (DEV_ACT_PLAY, 247*t);
719 break;
720 case 'C':
721 dev->handler (DEV_ACT_PLAY, 136*t);
722 break;
723 case 'F':
724 dev->handler (DEV_ACT_PLAY, 188*t);
725 break;
728 switch (time) {
729 case '0':
730 timer_wait (2500);
731 break;
732 case '1':
733 timer_wait (1250);
734 break;
735 case '2':
736 timer_wait (625);
737 break;
742 printf ("end: play_tone ();\n");
744 dev->handler (DEV_ACT_PLAY, 0);
747 void play_song (dev_t *dev, char *data)
749 printf ("play_song ();\n");
750 unsigned i = 0, l = strlen (data);
751 unsigned time = 1;
752 while (i != l) {
753 switch (data[i]) {
754 printf ("switch ()\n");
755 case 'p':
757 switch (data[i+1]) {
758 case '0':
759 timer_wait (2500);
760 break;
761 case '1':
762 timer_wait (1250);
763 break;
764 case '2':
765 timer_wait (625);
766 break;
770 i ++;
771 break;
772 case ' ':
773 break;
774 default:
775 play_tone (dev, data[i], data[i+1], data[i+2]);
776 i += 2;
777 break;
780 i ++;
785 unsigned command_spk (char *command, unsigned len)
787 unsigned int freq = 20;
789 dev_t *dev = dev_find ("/dev/pcspk");
791 if (dev) {
793 We wish you a merry christmas v1.0
795 D2(1/8) G2(1/8) G2(1/16) A2(1/16) G2(1/16) Fis2(1/16) E2(1/8) C2(1/8) E2(1/8) A2(1/8) A2(1/16) H2(1/16) A2(1/16) G2(1/16) Fis2(1/8) D2(1/4) H2(1/8) H2(1/16) C3(1/16) H2(1/16) A2(1/16) G2(1/8) E2(1/8) D2(1/16) D2(1/16) E2(1/8) A2(1/8) Fis2(1/8) G2(1/8)
798 play_song (dev, "d21 g21 g22 a22 g22 F22 e21 c21 e21 a21 a22 h22 a22 g22 F21 d20 h21 h22 c32 h22 a22 g21 e21 d22 d22 e21 a21 F21 g21");
800 timer_wait (2000);
803 We wish you a merry christmas v3.0
805 G2(1/8) C3(1/8) C3(1/16) D3(1/16) C3(1/16) H2(1/16) A2(1/4) D3(1/8) D3(1/16) E3(1/16) D3(1/16) C3(1/16) H2(1/4) G2(1/8) E3(1/8) E3(1/16) F3(1/16) E3(1/16) D3(1/16) C3(1/8) A2(1/8) G2(1/8) A2(1/8) D3(1/8) H2(1/8) C3(1/8)
808 play_song (dev, "g21 c31 c32 d32 c32 h22 a20 d31 d32 e32 d32 c32 h20 g21 e31 e32 f32 e32 d32 c31 a21 g21 a21 d31 h21 c31");
810 timer_wait (2000);
813 Dallas v2.0
814 G2(1/8) C3(1/8) P(1/16) G2(1/16) G3(1/8) C3(1/16) E3(1/8) D3(1/16) E3(1/16) C3(1/8) G2(1/8) C3(1/8) A3(1/8) G3(1/8) E3(1/16) F3(1/16) G3(1/8) G3(1/16) P(1/16) G2(1/8) C3(1/8) A3(1/8) G3(1/8) E3(1/16) F3(1/16) G3(1/8) D3(1/16) E3(1/16) C3(1/8) G2(1/8) C3(1/8) E3(1/16) F3(1/16) D3(1/8) G3(1/8) G3(1/8)
816 /* play_song (dev, "g21 c31 p2 g22 g31 c32 e31 d32 e32 c31 g21 c31 a31 g31 e32 f32 g31 g32 p2 g21 c31 a31 g31 e32 f32 g31 d32 e32 c31 g21 c31 e32 f32 d31 g31 g31");*/
818 //timer_wait (2000);
821 return 1;
824 extern bool bus_pci_acthandler (unsigned act, char *block, unsigned block_len);
825 extern netif_t netif_list;
826 extern void ext2_dump ();
827 void thread_test ()
829 while (1) {
831 kprintf ("hu\n");
833 unsigned long timer_start = timer_ticks + ((unsigned) 1 * 1000);
835 while (timer_start > timer_ticks)
836 schedule ();
840 extern unsigned start;
841 extern unsigned end;
842 extern bool ide_acthandler (unsigned act, partition_t *p, char *block, char *more, int n);
843 unsigned command_test (char *command, unsigned len)
845 /* int s, s2, t, l;
846 sockaddr_un local, remote;
848 char str[100];
850 if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
851 printf ("error\n");
852 return 0;
855 local.sun_family = AF_UNIX;
856 strcpy(local.sun_path, "test");
857 // unlink(local.sun_path);
858 l = strlen(local.sun_path) + sizeof(local.sun_family);
859 if (bind(s, (sockaddr *) &local, l) == -1) {
860 printf ("error2\n");
861 return 0;
864 if (listen(s, 5) == -1) {
865 printf ("error3\n");
866 return 0;
870 int done, n;
871 printf("Waiting for a connection... - %d\n", s);
872 t = sizeof(remote);
873 if ((s2 = accept(s, (struct sockaddr *)&remote, &t)) == -1) {
874 printf ("accept\n");
875 return 0;
878 printf("Connected - server - %d\n", s2);
880 done = 0;
883 unsigned m = 0;
885 while (m < 100) {
887 if (send(s2, "Jejda", 5, 0) < 0) {
888 printf ("send\n");
891 int ret = recv(s2, str, 99, 0);
893 if (ret > 0) {
894 str[ret] = '\0';
895 printf ("recv: %s : %d\n", str, ret);
898 m ++;
901 sclose(s2);
905 fdisk ("/dev/hda 0 83 50", 16);
907 //vfs_dirent ();
909 /*partition_t *p = partition_find ("/dev/hda0");
911 if (p)
912 mount (p, "", "/mnt/hdd/");
913 else
914 printf ("WARNING -> partition /dev/hda0 does not exists\n");
916 //char *t = (char *) 0x400000+0x1;
917 //*t = 0x1;
919 //printf ("ddd: 0x%x, 0x%x\n", start, end);
921 /* paging_disable ();
923 task_t *task = task_find (0);
925 if (!task)
926 return 0;
927 char *t = (char *) 0x400000;
928 *t = 0x12;
930 t = (char *) 0x0;
932 *t = 0x3;
934 printf ("Start2: 0x%x\n", *t);
935 unsigned r = page_mmap (task->page_cover, (void *) 0x0, (void *) 0x1000, 1, 0);
937 if (!r) {
938 printf ("Oj Oj\n");
939 paging_enable ();
940 return 0;
943 paging_enable ();*/
947 t = (char *) 0x0;
949 printf ("Start3: 0x%x\n", *t);
951 *t = 0x2;
953 paging_disable ();
955 t = (char *) 0x400000;
957 printf ("Start4: 0x%x\n", *t);
959 paging_enable ();*/
961 /*init_adm ();
963 cd ((char *) "/mnt/floppy");
965 unsigned i = 0;
967 //while (++ i < 100) {
968 command_exec ("exec zde", 8);
969 schedule ();
972 cd ("..");
973 cd ("..");
975 return 1;*/
977 /* Create virtual block device */
978 /*#ifdef ARCH_i386
979 dev_t *dev = (dev_t *) dev_register ("vbd", "Virtual Block Device", DEV_ATTR_BLOCK, (dev_handler_t *) &ide_acthandler);
981 partition_t *p = partition_add (dev, fs_supported ("znfs"));
983 znfs_init (partition_add (dev, fs_supported ("znfs")), "192.168.1.2"); // small HACK
985 if (p)
986 mount (p, "", "/mnt/hdd/");
987 else
988 printf ("WARNING -> partition /dev/hda0 does not exists\n");
990 cd ((char *) "/mnt/hdd");
991 #endif*/
992 //printf ("Je to na 0x%x\n", vesafb);
993 return 1;
995 extern char *vgafb;
996 extern char *vgadb;
997 unsigned command_test2 (char *command, unsigned len)
999 int s, t, l;
1000 sockaddr_un remote;
1001 char str[100];
1003 if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
1004 printf ("socket\n");
1005 return 0;
1008 printf("Trying to connect... - %d\n", s);
1010 remote.sun_family = AF_UNIX;
1011 strcpy(remote.sun_path, "test");
1012 l = strlen(remote.sun_path) + sizeof(remote.sun_family);
1013 if (connect(s, (sockaddr *)&remote, l) == -1) {
1014 printf ("connect\n");
1015 return 0;
1018 printf("Connected - Client\n");
1020 strcpy (str, "Jedna dve, hovno jde :)");
1022 unsigned m = 0;
1023 while (m < 100) {
1024 if ((t=recv(s, str, 99, 0)) > 0) {
1025 str[t] = '\0';
1026 printf("echo> %s", str);
1029 if (send(s, "hovno_hovno", 11, 0) == -1) {
1030 printf ("!send\n");
1031 return 0;
1033 m ++;
1036 sclose(s);
1038 return 1;
1041 unsigned command_test3 (char *command, unsigned len)
1044 return 1;
1047 unsigned command_test4 (char *command, unsigned len)
1051 return 1;
1054 unsigned command_mouse (char *command, unsigned len)
1056 printf ("PS/2 Mouse test\n");
1058 dev_t *dev = dev_find ("/dev/mouseps2");
1060 if (!dev)
1061 return 0;
1063 dev_mouse_t mouse;
1065 int ps2_fd = open ("/dev/mouseps2", O_RDONLY);
1067 if (!ps2_fd)
1068 return 0;
1070 printf ("dddd\n");
1072 while (!key_pressed (1)) {
1073 int r = read (ps2_fd, &mouse, sizeof (dev_mouse_t));
1075 if (!r) {
1076 kprintf ("oj oj\n");
1077 return 0;
1080 kprintf ("ps2mouse: x,y: %d, %d | 0x%x \n", mouse.pos_x, mouse.pos_y, mouse.flags);
1082 lseek (ps2_fd, 0, SEEK_SET);
1084 schedule ();
1087 return 1;
1090 unsigned command_vesa (char *command, unsigned len)
1092 if (!init_video_vesa ())
1093 printf ("vesa -> failed\n");
1095 return 1;
1098 unsigned command_kill (char *command, unsigned len)
1100 strcpy (test, argparse (currtty->shell));
1102 pid_t pid = (pid_t) atoi (test);
1104 proc_t *proc = proc_findbypid (pid);
1106 if (!proc) {
1107 printf ("kill: (%s) - No such process\n", test);
1108 return 0;
1111 /* send SIGTERM to selected process */
1112 if (!proc_signal (proc, SIGTERM))
1113 return 0;
1115 /* check for daemon */
1116 if (proc->flags & PROC_FLAG_DAEMON)
1117 if (!proc_done (proc))
1118 return 0;
1120 return 1;
1123 unsigned command_modprobe (char *command, unsigned len)
1125 unsigned arg_len = strlen (argparse (currtty->shell));
1126 char arg[arg_len+1];
1127 strcpy (arg, argparse (currtty->shell));
1128 arg[arg_len] = '\0';
1130 module_load (arg);
1132 return 1;
1135 unsigned command_lsmod (char *command, unsigned len)
1137 module_display ();
1139 return 1;
1142 #ifdef CONFIG_DRV_PCI
1143 unsigned command_lspci (char *command, unsigned len)
1145 #ifdef ARCH_i386
1146 pcidev_display ();
1147 #endif
1148 return 1;
1150 #endif
1152 unsigned command_iflist (char *command, unsigned len)
1154 iflist_display ();
1156 return 1;
1159 unsigned command_ifconfig (char *command, unsigned len)
1161 strcpy (test, argparse (command));
1162 char ifid[20];
1163 char ip[32];
1165 unsigned l = strlen (test);
1166 unsigned x = 0;
1167 while (x < l) {
1168 if (test[x] == ' ')
1169 break;
1170 x ++;
1173 memcpy (ifid, test, x);
1174 ifid[x] = '\0';
1176 strcpy (ip, argparse (test));
1177 unsigned y = strlen (ip);
1179 netif_t *netif = netif_findbyname (ifid);
1181 if (!netif) {
1182 printf ("ifconfig -> bad network interface name, example: eth0\n");
1183 return 0;
1186 net_ipv4 ipv4;
1187 net_ipv6 ipv6;
1188 if (ipv4 = net_proto_ip_convert (ip)) {
1189 netif_ip_addr (netif, ipv4);
1191 printf ("%s: IPv4 ", ifid);
1192 net_proto_ip_print (ipv4);
1193 printf (" - OK\n");
1194 } else if (net_proto_ipv6_convert (ipv6, ip)) {
1195 netif_ipv6_addr (netif, ipv6);
1197 printf ("%s: IPv6 ", ifid);
1198 net_proto_ipv6_print (ipv6);
1199 printf (" - OK\n");
1200 } else {
1201 printf ("ifconfig -> bad ip address format, example:\n\t\t192.168.1.1 for IPv4\n\t\tfc00:0:0:0:0:0:0:10 for IPv6\n");
1202 return 0;
1205 return 1;
1208 unsigned command_ifroute (char *command, unsigned len)
1210 strcpy (test, argparse (command));
1211 char ifid[20];
1212 char ip[32];
1214 unsigned l = strlen (test);
1215 unsigned x = 0;
1216 while (x < l) {
1217 if (test[x] == ' ')
1218 break;
1219 x ++;
1222 memcpy (ifid, test, x);
1223 ifid[x] = '\0';
1225 strcpy (ip, argparse (test));
1226 unsigned y = strlen (ip);
1228 netif_t *netif = netif_findbyname (ifid);
1230 if (!netif) {
1231 printf ("ifroute -> bad network interface name, example: eth0\n");
1232 return 0;
1235 unsigned char a;
1236 unsigned char b;
1237 unsigned char c;
1238 unsigned char d;
1240 unsigned g = 0;
1241 unsigned i = 0;
1243 unsigned h[4];
1245 while (i < y) {
1246 if (ip[i] == '.') {
1247 ip[i] = '\0';
1248 h[g] = i+1;
1249 g ++;
1252 i ++;
1255 if (g != 3) {
1256 printf ("ifroute -> bad ip address format, example: 192.168.1.254\n");
1257 return 0;
1260 a = atoi (ip);
1261 b = atoi (ip+h[0]);
1262 c = atoi (ip+h[1]);
1263 d = atoi (ip+h[2]);
1265 printf ("%s->gw: %d.%d.%d.%d - OK\n", ifid, a, b, c, d);
1267 return netif_gw_addr (netif, NET_IPV4_TO_ADDR (a, b, c, d));
1270 unsigned command_dnsconfig (char *command, unsigned len)
1272 strcpy (test, argparse (currtty->shell));
1274 if (!test)
1275 return 0;
1277 unsigned l = strlen (test);
1279 if (!l) {
1280 printf ("dnsconfig -> your domain name server is: ");
1281 net_proto_ip_print (dns_addr_get ());
1282 printf ("\n");
1284 return 0;
1287 printf ("dnsconfig: %s - OK\n", test);
1289 net_ipv4 dns = net_proto_ip_convert (test);
1291 if (!dns)
1292 return 0;
1294 dns_addr (dns);
1296 return 1;
1299 unsigned command_tunconfig (char *command, unsigned len)
1301 strcpy (test, argparse (currtty->shell));
1303 if (!test)
1304 return 0;
1306 unsigned l = strlen (test);
1308 if (!l) {
1309 printf ("tunconfig -> wrong syntax !\ntunconfig <ipv4tunnel> for enable or tunconfig 0 for disable\n");
1311 return 0;
1314 /* you can disable this service over character '0' as parameter */
1315 if (l == 1 && test[0] == '0') {
1316 tun6_addr (0);
1318 printf ("tunconfig: disabled - OK\n");
1320 return 1;
1323 /* classical ipv4 address from tunnel server */
1324 net_ipv4 tunnel = net_proto_ip_convert (test);
1326 if (!tunnel) {
1327 printf ("tunconfig -> wrong syntax !\nExample: tunconfig 216.66.80.30\n");
1329 return 0;
1332 tun6_addr (tunnel);
1334 printf ("tunconfig: ::%s - OK\n", test);
1336 return 1;
1339 unsigned command_kbdmap (char *command, unsigned len)
1341 strcpy (test, argparse (currtty->shell));
1343 if (!test)
1344 return 0;
1346 unsigned ret = keyboard_setlayout (test);
1348 if (ret)
1349 printf ("Keyboard layout was changed to '%s'\n", test);
1351 return ret;
1354 unsigned command_mkzexfs (char *command, unsigned len)
1356 #ifdef ARCH_i386
1357 strcpy (test, argparse (currtty->shell));
1359 if (!test)
1360 return 0;
1362 partition_t *p = partition_find ("/dev/hda0");
1364 mkzexfs (p);
1365 #endif
1366 return 1;
1369 unsigned command_mkext2 (char *command, unsigned len)
1371 #ifdef ARCH_i386
1372 strcpy (test, argparse (currtty->shell));
1374 if (!test)
1375 return 0;
1377 partition_t *p = partition_find ("/dev/hda0");
1379 mkext2 (p);
1380 #endif
1381 return 1;
1384 unsigned command_ping (char *command, unsigned len)
1386 strcpy (test, argparse (currtty->shell));
1388 if (!test)
1389 return 0;
1391 netif_t *netif = netif_findbyname ("eth0");
1393 if (!netif) {
1394 printf ("ping -> network interface does not exists\n");
1395 return 0;
1398 unsigned char a;
1399 unsigned char b;
1400 unsigned char c;
1401 unsigned char d;
1403 unsigned g = 0;
1404 unsigned i = 0;
1405 unsigned y = strlen (test);
1407 if (!y) {
1408 printf ("ping -> wrong syntax, please specify address\n");
1409 return 0;
1412 unsigned h[4];
1414 while (i < y) {
1415 if (test[i] == '.') {
1416 test[i] = '\0';
1417 h[g] = i+1;
1418 g ++;
1421 i ++;
1424 net_ipv4 target = 0;
1426 if (g != 3) {
1427 strcpy (test, argparse (currtty->shell));
1428 target = dns_cache_get (test);
1430 if (!target)
1431 target = dns_send_request (test);
1433 if (!target) {
1434 printf ("ping -> bad hostname or ip address format, example: 192.168.1.1\n");
1435 return 0;
1437 } else {
1438 a = atoi (test);
1439 b = atoi (test+h[0]);
1440 c = atoi (test+h[1]);
1441 d = atoi (test+h[2]);
1443 target = NET_IPV4_TO_ADDR (a, b, c, d);
1445 strcpy (test, argparse (currtty->shell));
1448 char address[20];
1449 net_proto_ip_convert2 (target, address);
1451 i = 0;
1453 while (i < 8) {
1454 unsigned long time_a = timer_ticks;
1455 unsigned ret = net_proto_icmp_ping (netif, target);
1456 if (ret) {
1457 printf ("ping -> %s (%s) - %ums\n", test, address, (timer_ticks - time_a));
1458 } else {
1459 printf ("ping -> Host %s is unreachable\n", test);
1460 break;
1463 i ++;
1466 return 1;
1469 unsigned command_ping6 (char *command, unsigned len)
1471 strcpy (test, argparse (currtty->shell));
1473 if (!test)
1474 return 0;
1476 netif_t *netif = netif_findbyname ("eth0");
1478 if (!netif) {
1479 printf ("ping -> network interface does not exists\n");
1480 return 0;
1483 unsigned short a;
1484 unsigned short b;
1485 unsigned short c;
1486 unsigned short d;
1487 unsigned short e;
1488 unsigned short f;
1489 unsigned short g;
1490 unsigned short h;
1492 unsigned j = 0;
1493 unsigned i = 0;
1494 unsigned y = strlen (test);
1496 if (!y) {
1497 printf ("ping -> wrong syntax, please specify ipv6 address\n");
1498 return 0;
1501 unsigned k[8];
1503 while (i < y) {
1504 if (test[i] == ':') {
1505 test[i] = '\0';
1506 k[j] = i+1;
1507 j ++;
1510 i ++;
1513 net_ipv6 target;
1515 if (j != 7) {
1516 /*strcpy (test, argparse (currtty->shell));
1517 target = dns_cache_get (test);
1519 if (!target)
1520 target = dns_send_request (test);
1522 if (!target) {*/
1523 // printf ("ping -> bad hostname or ip address format, example: 192.168.1.1\n");
1524 // return 0;
1526 printf ("ping -> wrong syntax, please specify ipv6 address\n");
1527 return 0;
1528 } else {
1529 char *endptr;
1531 a = strtol (test, &endptr, 16);
1532 b = strtol (test+k[0], &endptr, 16);
1533 c = strtol (test+k[1], &endptr, 16);
1534 d = strtol (test+k[2], &endptr, 16);
1535 e = strtol (test+k[3], &endptr, 16);
1536 f = strtol (test+k[4], &endptr, 16);
1537 g = strtol (test+k[5], &endptr, 16);
1538 h = strtol (test+k[6], &endptr, 16);
1540 NET_IPV6_TO_ADDR (target, a, b, c, d, e, f, g, h);
1542 //printf ("ipv6: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", a, b, c, d, e, f, g, h);
1544 strcpy (test, argparse (currtty->shell));
1547 char address[40];
1548 //net_proto_ipv6_convert2 (target, address);
1550 i = 0;
1552 while (i < 8) {
1553 unsigned long time_a = timer_ticks;
1554 unsigned ret = net_proto_icmp6_ping (netif, target);
1555 if (ret) {
1556 printf ("ping6 -> %s (%s) - %ums\n", test, test, (timer_ticks - time_a));
1557 } else {
1558 printf ("ping6 -> Host %s is unreachable\n", test);
1559 break;
1562 i ++;
1565 return 1;
1568 unsigned command_netexec (char *command, unsigned len)
1570 strcpy (test, argparse (command));
1572 if (!test)
1573 return 0;
1575 if (!strlen (test)) {
1576 printf ("Syntax:\nnetexec <ip_of_tftp> <filename> [parameters]\n");
1577 return 0;
1580 unsigned arg_len = strlen (argparse (test));
1581 char arg[arg_len+1];
1582 strcpy (arg, argparse (test));
1583 arg[arg_len] = '\0';
1585 unsigned test_len = strlen (test);
1586 test [test_len-arg_len] = '\0';
1588 if (test[test_len-arg_len-1] == ' ') {
1589 test[test_len-arg_len-1] = '\0';
1590 test_len --;
1593 char file[arg_len+1];
1594 unsigned file_len = 0;
1595 memcpy (file, arg, arg_len);
1596 while (file_len < arg_len) {
1597 if (file[file_len] == ' ') {
1598 file[file_len] = '\0';
1599 break;
1601 file_len ++;
1604 if (file[arg_len] != '\0')
1605 file[arg_len] = '\0';
1607 unsigned l = file_len;
1609 unsigned ret = tftp_client_connect (test, 69, file, &l);
1611 if (!ret) {
1612 printf ("tftp -> something go wrong !\n");
1613 return 0;
1616 printf ("tftp -> file length: %ubytes\t\t[OK]\n", l);
1618 char *bin = (unsigned char *) pmalloc (sizeof (char) * (l+1));
1620 if (!bin)
1621 return 0;
1623 int ret2 = tftp_client_read (ret, bin, l);
1625 if (!ret2) {
1626 printf ("tftp -> tftp_client_read () error\n");
1627 free (bin);
1628 return 0;
1631 memcpy (file_cache, bin, l);
1633 unsigned entry, code, data, data_off, bss;
1634 int err = exec_elf (bin, &entry, &data, &data_off, &bss);
1636 if (err != NULL) {
1637 printf ("ERROR -> invalid ELF exec\n");
1638 return 0;
1641 tty_lock (currtty);
1642 timer_wait (1);
1643 /* create process */
1644 proc_t *proc = proc_create (currtty, "netexec", entry);
1645 timer_wait (1);
1648 /* check for & character as app parameter */
1649 /* unsigned d = 0;
1650 while (d < arg_len) {
1651 if (arg[d] == '&') {
1652 if (proc_flag_set (proc, PROC_FLAG_DAEMON))
1653 printf ("%s: started as daemon\n", test);
1655 arg[d] = '\0';
1657 if (arg_len > 2 && arg[d-1] == ' ') {
1658 arg[d-1] = '\0';
1659 arg_len --;
1662 arg_len --;
1664 break;
1666 d ++;
1669 if (!proc) {
1670 printf ("ERROR -> Invalid process: %s\n", test);
1671 return 0;
1674 timer_wait (1);
1676 /* save process information to structure for later use */
1677 proc->start = (unsigned) bin;
1678 proc->code = entry;
1679 proc->data = data;
1680 proc->data_off = data_off;
1681 proc->bss = bss;
1682 proc->end = (unsigned) (bin + l);
1684 timer_wait (1);
1686 /* well, set argument for out app */
1687 proc_arg_set (proc, arg+file_len+1, arg_len-file_len-1);
1689 timer_wait (1);
1691 /* Is this process started as daemon ? */
1692 /* wait here, until pid != 0*/
1693 if (!(proc->flags & PROC_FLAG_DAEMON))
1694 while (proc->pid)
1695 schedule ();
1697 timer_wait (1);
1699 /* enable interrupts */
1700 int_enable ();
1702 /* unlock tty console - user can write in */
1703 tty_unlock (proc->tty);
1705 _curr_task = proc->tty->task; // this is pretty needed for correct return to our tty task
1707 if (!(proc->flags & PROC_FLAG_DAEMON)) {
1708 if (!proc_done (proc))
1709 while (1) // NOTE: heh, this is good stuff :P
1710 schedule ();
1712 /* free image of app */
1713 //flush_elf ();
1714 //kfree (bin);
1717 /* switch to next task */
1718 schedule ();
1720 sclose (ret);
1722 return 1;
1725 unsigned command_netcp (char *command, unsigned len)
1727 strcpy (test, argparse (command));
1729 if (!test)
1730 return 0;
1732 if (!strlen (test)) {
1733 printf ("Syntax:\nnetcp <ip_of_tftp> <tftp_file> <output_file>\n");
1734 return 0;
1737 unsigned arg_len = strlen (argparse (test));
1738 char arg[arg_len+1];
1739 strcpy (arg, argparse (test));
1740 arg[arg_len] = '\0';
1742 unsigned test_len = strlen (test);
1743 test [test_len-arg_len] = '\0';
1745 if (test[test_len-arg_len-1] == ' ') {
1746 test[test_len-arg_len-1] = '\0';
1747 test_len --;
1750 char file[arg_len+1];
1751 unsigned file_len = 0;
1752 memcpy (file, arg, arg_len);
1753 while (file_len < arg_len) {
1754 if (file[file_len] == ' ') {
1755 file[file_len] = '\0';
1756 break;
1758 file_len ++;
1761 if (file[arg_len] != '\0')
1762 file[arg_len] = '\0';
1764 unsigned l = file_len;
1766 unsigned ret = tftp_client_connect (test, 69, file, &l);
1768 if (!ret) {
1769 printf ("tftp -> something go wrong !\n");
1770 return 0;
1773 printf ("tftp -> file length: %ubytes\t\t[OK]\n", l);
1774 printf ("DDDDDDDD: '%s' :: '%s' :: '%s'\n", test, file, arg);
1775 char *bin = (unsigned char *) malloc (sizeof (char) * (l+1));
1777 if (!bin)
1778 return 0;
1780 int ret2 = tftp_client_read (ret, bin, l);
1782 if (!ret2) {
1783 printf ("tftp -> tftp_client_read () error\n");
1784 free (bin);
1785 return 0;
1788 sclose (ret);
1790 file_cache_id = 0;
1791 file_cache = bin;
1793 char *output = argparse (arg);
1795 if (!output) {
1796 free (bin);
1797 printf ("ERROR -> output file name is empty\n");
1798 return 0;
1801 int fd = open (output, O_WRONLY | O_CREAT);
1803 if (!fd) {
1804 free (bin);
1805 printf ("ERROR -> something go wrong with %s\n", output);
1806 return 0;
1809 ret = write (fd, bin, l);
1811 if (!ret) {
1812 free (bin);
1813 printf ("ERROR -> File '%s' could'nt be writed\n", output);
1816 file_cache = (unsigned char *) 0x350000;
1818 return 1;
1821 void task_savemode ()
1823 while (1) {
1824 /* disable cpu for cycle */
1825 arch_cpu_hlt ();
1826 schedule ();
1830 unsigned command_savemode (char *command, unsigned len)
1832 task_t *task = (task_t *) task_create ("savemode", (unsigned) &task_savemode, 16);
1834 if (!task) {
1835 printf ("ERROR -> Save mode thread was'nt created\n");
1836 return 0;
1839 printf ("Save mode was succefully started\n");
1841 return 1;
1844 unsigned command_cpuinfo (char *command, unsigned len)
1846 printf ("Processor info:\n");
1848 cat ("/proc/cpuinfo");
1850 return 1;
1853 unsigned command_adm (char *command, unsigned len)
1855 printf ("Automatic Device Mounter - init ()\n");
1857 init_adm ();
1859 return 1;
1862 unsigned command_ttyctrl (char *command, unsigned len)
1864 char *parm = argparse (command);
1866 if (!parm) {
1867 printf ("ttyctrl <operation> [parameter]\n\t\toperations: add; list; change <ttyid>");
1868 return 0;
1871 if (!strncmp (parm, "add", 3)) {
1872 tty_t *tty = tty_create ();
1874 if (!tty)
1875 return 0;
1877 settextcolor (7, 0);
1879 tty_write (tty, "\nlogin: ", 8);
1881 printf ("New tty '%s' was created\n", tty->name);
1882 } else
1883 if (!strncmp (parm, "list", 4)) {
1884 tty_listview ();
1885 } else
1886 if (!strncmp (parm, "change", 6)) {
1887 tty_t *tty = tty_find ((char *) argparse (parm));
1889 if (!tty)
1890 return 0;
1892 tty_change (tty);
1894 printf ("\n");
1897 return 1;
1900 /*************************************************************\
1901 | COMMAND's UTILS |
1902 \*************************************************************/
1904 unsigned command_parser (char *command, unsigned len)
1906 /* find first non-space in command */
1907 int i = 0;
1908 for (i = 0; i < len; i ++) {
1909 if (command[i] != ' ')
1910 break;
1912 command_t *ctx;
1914 /* try to find the command */
1915 for (ctx = command_list.next; ctx != &command_list; ctx = ctx->next) {
1916 if (!cstrcmp (ctx->name, command+i)) {
1917 ctx->handler (command+i, len-i);
1918 return 1;
1922 printf ("%s: command not found\n", command);
1924 return 0;
1927 void commands (int i)
1929 // currtty->shell_len has been set to zero already
1930 command_parser (currtty->shell, strlen(currtty->shell));
1933 unsigned command_register (char *name, char *desc, command_handler_t *handler, unsigned flags)
1935 command_t *c;
1936 /* we dont want commands with same name */
1937 for (c = command_list.next; c != &command_list; c = c->next)
1938 if (!strcmp(c->name, name))
1939 return 0;
1941 command_t *ctx;
1943 // alloc and init context
1944 ctx = (command_t *) kmalloc (sizeof (command_t));
1946 if (!ctx)
1947 return 0;
1949 unsigned name_len = strlen (name);
1950 ctx->name = (char *) kmalloc (sizeof (char) * name_len +1);
1952 if (!ctx->name)
1953 return 0;
1955 memcpy (ctx->name, name, name_len);
1956 ctx->name[name_len] = '\0';
1958 unsigned desc_len = strlen (desc);
1959 ctx->desc = (char *) kmalloc (sizeof (char) * desc_len +1);
1961 if (!ctx->desc)
1962 return 0;
1964 memcpy (ctx->desc, desc, desc_len);
1965 ctx->desc[desc_len] = '\0';
1967 ctx->handler = handler;
1968 ctx->flags = flags;
1970 ctx->next = &command_list;
1971 ctx->prev = command_list.prev;
1972 ctx->prev->next = ctx;
1973 ctx->next->prev = ctx;
1975 return 1;
1978 unsigned command_unregister (char *name)
1980 command_t *ctx;
1982 for (ctx = command_list.next; ctx != &command_list; ctx = ctx->next) {
1983 if (!strcmp(ctx->name, name)) {
1984 ctx->next->prev = ctx->prev;
1985 ctx->prev->next = ctx->next;
1987 return 1;
1991 return 0;
1994 /*************************************************************\
1995 | INITIALIZATION OF COMMANDS |
1996 \*************************************************************/
1998 unsigned int init_commands ()
2000 command_list.next = &command_list;
2001 command_list.prev = &command_list;
2003 // reg commands
2004 command_register ("help", "Displays list of available commands", &command_help, 0);
2005 command_register ("hdd", "Detect HDD", &command_hdd, 0);
2006 command_register ("reboot", "Reboot computer", &command_reboot, 0);
2007 command_register ("halt", "Shutdown computer", &command_halt, 0);
2008 command_register ("tasks", "Print all tasks", &command_tasks, 0);
2009 command_register ("ps", "Print all process", &command_ps, 0);
2010 command_register ("uptime", "Print uptime in seconds", &command_uptime, 0);
2011 command_register ("version", "Displays a version of system", &command_version, 0);
2012 command_register ("debug", "Change to developer mode", &command_debug, 0);
2013 command_register ("mount", "Mount device to selected directory", &command_mount, 0);
2014 command_register ("umount", "Unmount mounted directory", &command_umount, 0);
2015 command_register ("env", "Displays all env variables", &command_env, 0);
2016 command_register ("cd", "Change directory", &command_cd, 0);
2017 command_register ("ls", " Displays files in current directory", &command_ls, 0);
2018 command_register ("cat", "Displays text in selected file", &command_cat, 0);
2019 command_register ("rm", "Remove a file", &command_rm, 0);
2020 command_register ("mkdir", "Create a directory", &command_mkdir, 0);
2021 command_register ("touch", "Create a file", &command_touch, 0);
2022 command_register ("exec", "Execute a selected program", &command_exec, 0);
2023 command_register ("lsdev", "Displays found devices", &command_lsdev, 0);
2024 command_register ("login", "Login as another user", &command_login, 0);
2025 command_register ("fdisk", "Partition table manipulator", &command_fdisk, 0);
2026 command_register ("hdcat", "Read selected block of data from drive", &command_hdcat, 0);
2027 command_register ("free", "Display amount of free and used memory", &command_free, 0);
2028 command_register ("date", "Show current date and time", &command_date, 0);
2029 //command_register ("xmastime", "play noel on pc-speaker", &command_spk, 0);
2030 command_register ("test", "Some test", &command_test, 0);
2031 //command_register ("testb", "Some test", &command_test2, 0);
2032 //command_register ("testc", "Some test", &command_test3, 0);
2033 //command_register ("testd", "Some test", &command_test4, 0);
2034 //command_register ("vesa", "Some test", &command_vesa, 0);
2035 command_register ("kill", "Send a signal to process", &command_kill, 0);
2036 command_register ("modprobe", "program to add modules from the kernel", &command_modprobe, 0);
2037 command_register ("lsmod", "program to show the status of modules", &command_lsmod, 0);
2038 #ifdef CONFIG_DRV_PCI
2039 command_register ("lspci", "list all pci devices", &command_lspci, 0);
2040 #endif
2041 command_register ("mouse", "ps2 mouse test", &command_mouse, 0);
2042 command_register ("iflist", "Show network interface", &command_iflist, 0);
2043 command_register ("ifconfig", "Configure network interface", &command_ifconfig, 0);
2044 command_register ("ifroute", "Configure gateway address", &command_ifroute, 0);
2045 command_register ("dnsconfig", "Configure domain name server address", &command_dnsconfig, 0);
2046 #ifdef CONFIG_PROTO_TUN6
2047 command_register ("tunconfig", "Configure IPv6 tunnel server address", &command_tunconfig, 0);
2048 #endif
2049 command_register ("kbdmap", "Change keyboard layout", &command_kbdmap, 0);
2050 #ifdef CONFIG_DRV_ZEXFS
2051 command_register ("mkzexfs", "Create zexfs filesystem on hdd", &command_mkzexfs, 0);
2052 #endif
2053 #ifdef CONFIG_DRV_EXT2
2054 command_register ("mkext2", "Create ext2 filesystem on hdd", &command_mkext2, 0);
2055 #endif
2056 #ifdef CONFIG_PROTO_IPV4
2057 command_register ("ping", "Send ICMP echo request", &command_ping, 0);
2058 #endif
2059 #ifdef CONFIG_PROTO_IPV6
2060 command_register ("ping6", "Send ICMPv6 echo request", &command_ping6, 0);
2061 #endif
2062 command_register ("netexec", "Execute file from network", &command_netexec, 0);
2063 command_register ("netcp", "Copy file from network to filesystem", &command_netcp, 0);
2064 command_register ("savemode", "Make less cpu load", &command_savemode, 0);
2065 command_register ("cpuinfo", "Show CPU info", &command_cpuinfo, 0);
2067 command_register ("adm", "Automatic Device Mounter", &command_adm, 0);
2068 command_register ("ttyctrl", "TTY Console control", &command_ttyctrl, 0);
2070 return 1;