Param parsing within the terminal implemented.
git-svn-id: https://spexeah.com:8443/svn/Asuro@232 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								bin/kernel.bin
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/kernel.bin
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/PCI.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/PCI.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/console.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/console.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/idt.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/idt.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/irq.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/irq.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr0.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr0.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr1.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr1.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr10.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr10.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr11.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr11.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr12.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr12.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr13.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr13.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr14.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr14.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr15.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr15.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr16.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr16.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr17.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr17.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr18.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr18.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr2.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr2.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr3.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr3.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr32.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr32.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr33.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr33.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr4.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr4.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr40.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr40.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr5.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr5.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr6.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr6.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr7.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr7.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr8.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr8.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/isr9.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr9.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/kernel.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/kernel.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/keyboard.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/keyboard.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/libpsystem.a
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/libpsystem.a
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/mouse.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/mouse.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/util.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/util.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -14,9 +14,15 @@ interface | ||||
| uses | ||||
|     console, | ||||
|     keyboard, | ||||
|     util; | ||||
|     util, | ||||
|     lmemorymanager; | ||||
|  | ||||
| type | ||||
|     PParamList = ^TParamList; | ||||
|     TParamList = record | ||||
|         Param : pchar; | ||||
|         Next  : PParamList;   | ||||
|     end; | ||||
|     TCommandBuffer = array[0..1023] of byte; | ||||
|     TCommandMethod = procedure(buf : TCommandBuffer); | ||||
|     TCommand = record | ||||
| @@ -34,9 +40,74 @@ var | ||||
| procedure run; | ||||
| procedure init; | ||||
| procedure registerCommand(command : pchar; method : TCommandMethod; description : pchar); | ||||
| function getParams(buf : TCommandBuffer) : PParamList; | ||||
|  | ||||
| implementation | ||||
|  | ||||
| function getParams(buf : TCommandBuffer) : PParamList; | ||||
| var | ||||
|     start, finish : uint32; | ||||
|     size : uint32; | ||||
|     ptr : uint32; | ||||
|     root : PParamList; | ||||
|     current : PParamList; | ||||
|  | ||||
| begin | ||||
|     root:= PParamList(kalloc(sizeof(TParamList))); | ||||
|     current:= root; | ||||
|     current^.next:= nil; | ||||
|     current^.Param:= nil; | ||||
|     start:= 0; | ||||
|     finish:= 0; | ||||
|     while (char(buf[finish]) <> ' ') and (buf[finish] <> 0) do begin | ||||
|         inc(finish); | ||||
|     end; | ||||
|     while buf[start] <> 0 do begin | ||||
|         start:=finish+1; | ||||
|         inc(finish); | ||||
|         while (char(buf[finish]) <> ' ') and (buf[finish] <> 0) do begin | ||||
|             inc(finish); | ||||
|         end;   | ||||
|         size:= finish - start; | ||||
|         if size > 0 then begin | ||||
|             ptr:= uint32(@buf[start]); | ||||
|             current^.Param:= pchar(kalloc(size+2)); | ||||
|             memset(uint32(current^.Param), 0, size+2); | ||||
|             memcpy(uint32(ptr), uint32(current^.Param), size); | ||||
|             current^.next:= PParamList(kalloc(sizeof(TParamList))); | ||||
|             current:= current^.next; | ||||
|             current^.next:= nil; | ||||
|             current^.Param:= nil; | ||||
|         end;       | ||||
|     end; | ||||
|     getParams:= root; | ||||
| end; | ||||
|  | ||||
| procedure testParams(buffer : TCommandBuffer); | ||||
| var | ||||
|     params : PParamList; | ||||
|  | ||||
| begin | ||||
|     params:= getParams(buffer); | ||||
|     while params^.Param <> nil do begin | ||||
|         writestringln(params^.Param); | ||||
|         params:= params^.next; | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| procedure echo(buffer : TCommandBuffer); | ||||
| var | ||||
|     idx : uint32; | ||||
|  | ||||
| begin | ||||
|     idx:= 5; | ||||
|     while buffer[idx] <> 0 do begin | ||||
|         console.writechar(char(buffer[idx])); | ||||
|         inc(idx); | ||||
|     end; | ||||
|     console.writestringln(''); | ||||
| end; | ||||
|  | ||||
| procedure clear(buffer : TCommandBuffer); | ||||
| begin | ||||
|     console.clear(); | ||||
| @@ -158,7 +229,9 @@ begin | ||||
|     memset(uint32(@buffer[0]), 0, 1024); | ||||
|     registerCommand('VERSION', @version, 'Display the running version of Asuro.'); | ||||
|     registerCommand('CLEAR', @clear, 'Clear the Screen.'); | ||||
|     registerCommand('HELP', @help, 'Lists all registered commands and their description.') | ||||
|     registerCommand('HELP', @help, 'Lists all registered commands and their description.'); | ||||
|     registerCommand('ECHO', @echo, 'Echo''s text to the terminal.'); | ||||
|     registerCommand('TESTPARAMS', @testParams, 'Tests param parsing.'); | ||||
| end; | ||||
|  | ||||
| procedure run; | ||||
|   | ||||
							
								
								
									
										14
									
								
								src/util.pas
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/util.pas
									
									
									
									
									
								
							| @@ -31,6 +31,7 @@ function inb(port : uint16) : uint8; | ||||
| function inw(port : uint16) : uint16; | ||||
| function inl(port : uint16) : uint32; | ||||
| procedure memset(location : uint32; value : uint8; size : uint32); | ||||
| procedure memcpy(source : uint32; dest : uint32; size : uint32); | ||||
| procedure psleep(t : uint16); | ||||
|  | ||||
| var | ||||
| @@ -189,4 +190,17 @@ begin | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| procedure memcpy(source : uint32; dest : uint32; size : uint32); | ||||
| var | ||||
|     src, dst : puint8; | ||||
|     i : uint32; | ||||
|  | ||||
| begin | ||||
|     for i:=0 to size-1 do begin | ||||
|         src:= puint8(source + i); | ||||
|         dst:= puint8(dest + i); | ||||
|         dst^:= src^; | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| end. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 kieron
					kieron