1 ;----------------------------------------------------------;
2 ; BOS kernel Christoffer Bubach, 2003-2005. ;
3 ;----------------------------------------------------------;
5 ; Command table and some commands for the shell. ;
7 ;----------------------------------------------------------;
9 ; I should really do something about this file, divide it into
10 ; smaller ones or something. I'm just too lazy. Next version..
27 db 0xFF ; end of command table
30 call_table: dd show_ver ; commands.inc
31 dd show_help ; commands.inc
32 dd show_help ; commands.inc
33 dd show_about ; commands.inc
34 dd clrscr ; commands.inc
35 dd clrscr ; comamnds.inc
36 dd reboot ; commands.inc
37 dd dump_regs ; debug.inc
38 dd print_time ; time_date.inc
39 dd print_date ; time_date.inc
40 dd delay_test ; commands.inc
41 dd vga_test ; commands.inc
42 dd mem_test ; commands.inc
43 dd fdd_test ; commands.inc
47 ;--------------------------;
48 ; not a valid command ;
49 ;--------------------------;
50 not_a_valid_cmd db 13,10,'No such command or program exists.', 0
56 mov esi, not_a_valid_cmd
68 bos_ver_str db 13,10,'BOS version 0.04 by Christoffer Bubach, 2003-2005.', 0
82 ;--------------------;
84 ;--------------------;
85 bos_help_str db 13,10,13,10,' BOS 0.04 by Christoffer Bubach, 2003-2005.',13,10,\
86 '--------------------------------------------',13,10,\
87 'Type a command and press ENTER to execute it.',13,10,13,10,\
88 '"help" or "?" - Displays this text.',13,10,\
89 '"ver" - Shows version information.',13,10,\
90 '"about" - Shows information about the OS.',13,10,\
91 '"cls" or "clrscr" - Clears the screen.',13,10,\
92 '"memtest" - Shows memory info (and allocates/frees some, to test).',13,10,\
93 '"vgatest" - Test some VGA stuff.',13,10,\
94 '"fddtest" - Read and print bootsector from A:',13,10,\
95 '"delay" - Tests the delay function for 5 s.',13,10,\
96 '"time" - Prints current time.',13,10,\
97 '"date" - Prints current date.',13,10,\
98 '"regdump" - Dump some standard registers.',13,10,\
99 '"reboot" - Restarts the computer.',0
104 mov esi, bos_help_str
116 bos_about_str db 13,10,'About BOS',13,10,\
117 'Hmm.. I started with OS-dev in late 2003.. Anyway..',13,10,13,10,\
118 'Thanks for helping me get this far goes to:',13,10,\
119 'all people at mega-tokyo.com, osdever.net and flatassembler.net',13,10,\
120 'Robert ',153,'stling for Primula, http://ostling.no-ip.com/',13,10,\
121 'J.Thim for EelOS, http://www.ludd.luth.se/~ivileel/',13,10,\
122 'Tomasz Grysztar for fasm and fasmw, http://flatassembler.net/',13,10,\
123 'ASHLEY4, Candy, John S. Fine and Petroff Heroj.',0
128 mov esi, bos_about_str
137 ;-----------------------;
139 ;-----------------------;
146 jmp shell ; no normal return, as it gives an extra line feed
164 bos_delay_str db 13,10,'~1 second has passed.', 0
172 mov esi, bos_delay_str
182 bos_vga_str db 13,10,'It works..! :-D', 0
185 mov ax, 1 ; clear the screen
186 call set_mode_0x13 ; set mode 0x13
188 mov cx, 256 ; loop out some pixels
198 ; draw mario and some ground
204 call put_0x13_sprite ; in vga.inc
256 mov ax, 1 ; clear the screen
257 call set_mode_0x03 ; set mode 0x03
259 mov esi, bos_vga_str ; print that it worked!
267 ;--------------------------;
269 ;--------------------------;
272 mov bh, 7 ; make newline
278 mov dword [edi], 'shit' ; set DMA buffer to shit, as a test
287 mov cl, 0x01 ; sector
288 mov bl, 0x00 ; 1 = write
292 mov esi, 0x80000 ; dma buffer
298 call print_char ; print it. is it still
310 mov bl, 'E' ; error sign... :'(
314 call fdd_recalibrate ; do somthing about the error.. :P
323 ;------------------------------;
325 ;------------------------------;
327 bos_mem_str1 db 13,10,'Performing memory test. (debugging allocs assume 32mb RAM)', 0
328 bos_mem_str2 db 13,10,'Total installed memory (in bytes): ',0
329 bos_mem_str3 db 13,10,13,10,'Memory chunks:',0
330 bos_mem_str4 db 13,10,'Address Size Type Previous Next',0
331 bos_mem_str5 db 13,10,'-------------------------------------------------------',0
332 bos_mem_str6 db '0x',0
333 bos_mem_str7 db 'Free ',0
334 bos_mem_str8 db 'Used ',0
335 bos_mem_str9 db 'None ',0
336 bos_mem_str0 db ' ',0
337 bos_mem_crlf db 13,10,0
341 ;---------DEBUG---------
347 ;---------END DEBUG---------
355 ;---------DEBUG---------
357 je .free_the_test_block
359 mov ebx, 0x1000000 ;first test
360 mov [test_size2], ebx
362 mov [test_address2], ebx
364 mov ebx, 0xE00000 ; second test
370 mov ebx, 0x10000 ; third test
373 mov [test_address], ebx ; test allocation
381 .free_the_test_block:
382 mov ebx, [test_address]
383 mov ecx, [test_size] ; and freeing
385 mov ebx, [test_address2]
386 mov ecx, [test_size2] ; and freeing
390 ;---------END DEBUG---------
392 mov esi, bos_mem_str1
395 mov esi, bos_mem_str2
398 mov esi, bos_mem_str6
401 mov ebx, [ram_amount]
405 mov esi, bos_mem_str3
408 mov esi, bos_mem_str4
411 mov esi, bos_mem_str5
415 mov [current_mem_pos], 0
416 mov eax, [first_free]
419 ;-------------------------;
420 ; this is a used block ;
421 ;-------------------------;
423 mov eax, [current_mem_pos]
425 cmp eax, [ram_amount] ; .free will always let us
426 jae .end ; decide if we are to quit or not.
430 mov ebx, [ram_amount] ; no next block, use ram size
431 sub ebx, eax ; get size in ebx
445 mov [current_mem_pos], eax
448 ;-------------------------;
449 ; this is a free block ;
450 ;-------------------------;
452 mov eax, [current_mem_pos] ; current pos. in eax
453 mov ebx, [eax+4] ; current size in ebx
454 mov ecx, [eax] ; prev pointer in ecx
455 mov edx, [eax+8] ; next pointer in edx
460 mov [current_mem_pos], eax
470 ;-------------------------;
471 ; print mem block info ;
472 ;-------------------------;
474 push eax ; current pos
475 push ebx ; current size
476 push ecx ; prev pointer
477 push edx ; next pointer
481 mov esi, bos_mem_crlf
484 mov esi, bos_mem_str6
493 mov esi, bos_mem_str0
496 mov esi, bos_mem_str6
505 mov esi, bos_mem_str0
513 mov esi, bos_mem_str8 ; it's used
516 mov esi, bos_mem_str9
519 mov esi, bos_mem_str9
525 mov esi, bos_mem_str7 ; it's free
528 mov esi, bos_mem_str6
532 pop ebx ; pop the pushed ecx
533 mov cl, 0x04 ; into ebx instead.. ;)
535 mov esi, bos_mem_str0
538 mov esi, bos_mem_str6